php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #52039 Closure problem with 5.3.2
Submitted: 2010-06-10 13:53 UTC Modified: 2010-08-09 00:52 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: neto dot joaobatista at gmail dot com Assigned: felipe (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 5.3.2 OS: Linux, Fedora 13 64 bits
Private report: No CVE-ID: None
 [2010-06-10 13:53 UTC] neto dot joaobatista at gmail dot com
Description:
------------
NULL when using Closures with "use" keyword in PHP 5.3.2

Test script:
---------------
<?php
$test = 'Closure test';
$closure = function() use ( $test ) { return $test; };

var_dump( phpversion() , $closure );

Expected result:
----------------
PHP 5.3.0 output:

string(5) "5.3.0"
object(Closure)#1 (1) {
  ["static"]=>
  array(1) {
    ["test"]=>
    string(12) "Closure test"
  }
}

Actual result:
--------------
PHP 5.3.2 output:

string(5) "5.3.2"
NULL

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-06-10 14:09 UTC] degeberg@php.net
-Status: Open +Status: Feedback
 [2010-06-10 14:09 UTC] degeberg@php.net
Please try using this snapshot:

  http://snaps.php.net/php5.3-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/

I get the following output:

string(9) "5.3.3-dev"
object(Closure)#1 (1) {
  ["static"]=>
  array(1) {
    ["test"]=>
    string(12) "Closure test"
  }
}
 [2010-06-10 17:18 UTC] neto dot joaobatista at gmail dot com
New information,

PHP: 5.3.0, 5.3.2 and 5.3.3 works fine as CLI

Output from 5.3.3

string(9) "5.3.3-dev"
object(Closure)#1 (1) {
  ["static"]=>
  array(1) {
    ["test"]=>
    string(12) "Closure test"
  }
}

Using PHP 5.3.3-dev as CGI works too:

string(9) "5.3.3-dev"
object(Closure)#1 (1) {
  ["static"]=>
  array(1) {
    ["test"]=>
    string(12) "Closure test"
  }
}

I just couldn't test 5.3.3-dev as Apache module yet, but 5.3.2 doesn't work as module, giving me:

string(5) "5.3.2"
NULL

Server Version: Apache/2.2.15 (Unix) DAV/2 PHP/5.3.2 mod_python/3.3.1 Python/2.6.4 mod_ssl/2.2.15 OpenSSL/1.0.0-fips mod_perl/2.0.4 Perl/v5.10.1
 [2010-08-09 00:52 UTC] felipe@php.net
-Status: Feedback +Status: Closed -Assigned To: +Assigned To: felipe
 [2010-08-09 00:52 UTC] felipe@php.net
Surely it will show the same result on Apache... Closed.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 13 20:01:33 2025 UTC