Edit report at http://bugs.php.net/bug.php?id=52193&edit=1
ID: 52193 Updated by: [email protected] Reported by: neto dot joaobatista at gmail dot com Summary: converting closure to array yields empty array -Status: Open +Status: Closed Type: Bug Package: Arrays related Operating System: Linux, Fedora 13 64 bits PHP Version: 5.3.3RC1 -Assigned To: +Assigned To: felipe New Comment: This bug has been fixed in SVN. Snapshots of the sources are packaged every three hours; this change will be in the next snapshot. You can grab the snapshot at http://snaps.php.net/. Thank you for the report, and for helping us make PHP better. Previous Comments: ------------------------------------------------------------------------ [2010-06-26 19:14:36] [email protected] Automatic comment from SVN on behalf of felipe Revision: http://svn.php.net/viewvc/?view=revision&revision=300765 Log: - Fixed bug #52193 (converting closure to array yields empty array) ------------------------------------------------------------------------ [2010-06-26 17:11:36] neto dot joaobatista at gmail dot com Description: ------------ array_splice don't works with Closures. Test script: --------------- <?php $items = array( 'to remove' , 'item' ); var_dump( phpversion() ); array_splice( $items , 0 , 1 , 'works with strings' ); var_dump( $items ); array_splice( $items , 0 , 1 , 10 ); //with numbers var_dump( $items ); array_splice( $items , 0 , 1 , true ); //with booleans var_dump( $items ); array_splice( $items , 0 , 1 , array( 'it\'s' , 'ok' ) ); //with arrays var_dump( $items ); $items = array( 'to remove' , 'item' ); $func = function(){ return 'just a test'; }; array_splice( $items , 0 , 1 , $func ); //but not with Closures var_dump( $items ); Expected result: ---------------- string(5) "5.3.0" array(2) { [0]=> string(18) "works with strings" [1]=> string(4) "item" } array(2) { [0]=> int(10) [1]=> string(4) "item" } array(2) { [0]=> bool(true) [1]=> string(4) "item" } array(3) { [0]=> string(4) "it's" [1]=> string(2) "ok" [2]=> string(4) "item" } array(2) { [0]=> object(Closure)#2 (0) { } [1]=> string(4) "item" } Actual result: -------------- PHP 5.3.0: string(5) "5.3.0" array(2) { [0]=> string(18) "works with strings" [1]=> string(4) "item" } array(2) { [0]=> int(10) [1]=> string(4) "item" } array(2) { [0]=> bool(true) [1]=> string(4) "item" } array(3) { [0]=> string(4) "it's" [1]=> string(2) "ok" [2]=> string(4) "item" } array(1) { [0]=> string(4) "item" } -------------------------------------------- PHP 5.3.2 string(5) "5.3.2" array(2) { [0]=> string(18) "works with strings" [1]=> string(4) "item" } array(2) { [0]=> int(10) [1]=> string(4) "item" } array(2) { [0]=> bool(true) [1]=> string(4) "item" } array(3) { [0]=> string(4) "it's" [1]=> string(2) "ok" [2]=> string(4) "item" } array(1) { [0]=> string(4) "item" } -------------------------------------------- PHP 5.3.3-dev string(9) "5.3.3-dev" array(2) { [0]=> string(18) "works with strings" [1]=> string(4) "item" } array(2) { [0]=> int(10) [1]=> string(4) "item" } array(2) { [0]=> bool(true) [1]=> string(4) "item" } array(3) { [0]=> string(4) "it's" [1]=> string(2) "ok" [2]=> string(4) "item" } array(1) { [0]=> string(4) "item" } ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=52193&edit=1
