Bug #63021 [NEW]: var_export() does not export Closures
| From: | dexen dot devries at gmail dot com | Date: | Thu, 06 Sep 2012 10:36:22 +0000 |
| Subject: | Bug #63021 [NEW]: var_export() does not export Closures | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-173209@lists.php.net to get a copy of this message | ||
From: dexen dot devries at gmail dot com
Operating system:
PHP version: 5.4.6
Package: *Programming Data Structures
Bug Type: Bug
Bug description:var_export() does not export Closures
Description:
------------
While var_dump() produces sensible output for Closures, output of the
var_export() is pretty much useless.
Test script:
---------------
<?php
$a = range(1, 3);
$foo = function($n) use($a) {
return $a[$n];
};
var_dump($foo);
var_export($foo);
Expected result:
----------------
object(Closure)#1 (2) {
["static"]=>
array(1) {
["a"]=>
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
}
}
["parameter"]=>
array(1) {
["$n"]=>
string(10) "<required>"
}
}
(((resembling the following:)))
object(Closure)#1 (2) {
["static"]=>
array(1) {
["a"]=>
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
}
}
["parameter"]=>
array(1) {
["$n"]=>
string(10) "<required>"
}
}
Actual result:
--------------
object(Closure)#1 (2) {
["static"]=>
array(1) {
["a"]=>
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
}
}
["parameter"]=>
array(1) {
["$n"]=>
string(10) "<required>"
}
}
Closure::__set_state(array(
))
--
Edit bug report at https://bugs.php.net/bug.php?id=63021&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=63021&r=trysnapshot54
Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=63021&r=trysnapshot53
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=63021&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=63021&r=fixed
Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=63021&r=needdocs
Fixed in release: https://bugs.php.net/fix.php?id=63021&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=63021&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=63021&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=63021&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=63021&r=support
Expected behavior: https://bugs.php.net/fix.php?id=63021&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=63021&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=63021&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=63021&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=63021&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=63021&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=63021&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=63021&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=63021&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=63021&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=63021&r=mysqlcfg