Edit report at https://bugs.php.net/bug.php?id=63021&edit=1

 ID:                 63021
 Updated by:         larue...@php.net
 Reported by:        dexen dot devries at gmail dot com
 Summary:            var_export() does not export Closures
 Status:             Open
-Type:               Bug
+Type:               Feature/Change Request
 Package:            *Programming Data Structures
 PHP Version:        5.4.6
 Block user comment: N
 Private report:     N

 New Comment:

closure can not be serialized.. change to feature request instead.


Previous Comments:
------------------------------------------------------------------------
[2012-09-06 10:36:21] dexen dot devries at gmail dot com

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 this bug report at https://bugs.php.net/bug.php?id=63021&edit=1

Reply via email to