mirror of
https://github.com/php/php-src.git
synced 2026-03-30 12:13:02 +02:00
* Include the source location in Closure names This change makes stack traces involving Closures, especially multiple different Closures, much more useful, because it's more easily visible *which* closure was called for a given stack frame. The implementation is similar to that of anonymous classes which already include the file name and line number within their generated classname. * Update scripts/dev/bless_tests.php for closure naming * Adjust existing tests for closure naming * Adjust tests for closure naming that were not caught locally * Drop the namespace from closure names This is redundant with the included filename. * Include filename and line number as separate keys in Closure debug info * Fix test * Fix test * Include the surrounding class and function name in closure names * Fix test * Relax test expecations * Fix tests after merge * NEWS / UPGRADING
121 lines
1.8 KiB
PHP
121 lines
1.8 KiB
PHP
--TEST--
|
|
Bug #52193 (converting closure to array yields empty array)
|
|
--FILE--
|
|
<?php
|
|
|
|
var_dump((array) 1);
|
|
var_dump((array) NULL);
|
|
var_dump((array) new stdclass);
|
|
var_dump($h = (array) function () { return 2; });
|
|
var_dump($h[0]());
|
|
|
|
$i = function () use (&$h) {
|
|
return $h;
|
|
};
|
|
|
|
var_dump($x = (array)$i);
|
|
var_dump($y = $x[0]);
|
|
var_dump($y());
|
|
|
|
$items = range(1, 5);
|
|
$func = function(){ return 'just a test'; };
|
|
|
|
array_splice($items, 0 , 4, $func);
|
|
var_dump($items);
|
|
|
|
?>
|
|
--EXPECTF--
|
|
array(1) {
|
|
[0]=>
|
|
int(1)
|
|
}
|
|
array(0) {
|
|
}
|
|
array(0) {
|
|
}
|
|
array(1) {
|
|
[0]=>
|
|
object(Closure)#%d (3) {
|
|
["name"]=>
|
|
string(%d) "{closure:%s:%d}"
|
|
["file"]=>
|
|
string(%d) "%s"
|
|
["line"]=>
|
|
int(%d)
|
|
}
|
|
}
|
|
int(2)
|
|
array(1) {
|
|
[0]=>
|
|
object(Closure)#%d (4) {
|
|
["name"]=>
|
|
string(%d) "{closure:%s:%d}"
|
|
["file"]=>
|
|
string(%d) "%s"
|
|
["line"]=>
|
|
int(%d)
|
|
["static"]=>
|
|
array(1) {
|
|
["h"]=>
|
|
&array(1) {
|
|
[0]=>
|
|
object(Closure)#%d (3) {
|
|
["name"]=>
|
|
string(%d) "{closure:%s:%d}"
|
|
["file"]=>
|
|
string(%d) "%s"
|
|
["line"]=>
|
|
int(%d)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
object(Closure)#%d (4) {
|
|
["name"]=>
|
|
string(%d) "{closure:%s:%d}"
|
|
["file"]=>
|
|
string(%d) "%s"
|
|
["line"]=>
|
|
int(%d)
|
|
["static"]=>
|
|
array(1) {
|
|
["h"]=>
|
|
&array(1) {
|
|
[0]=>
|
|
object(Closure)#%d (3) {
|
|
["name"]=>
|
|
string(%d) "{closure:%s:%d}"
|
|
["file"]=>
|
|
string(%d) "%s"
|
|
["line"]=>
|
|
int(%d)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
array(1) {
|
|
[0]=>
|
|
object(Closure)#%d (3) {
|
|
["name"]=>
|
|
string(%d) "{closure:%s:%d}"
|
|
["file"]=>
|
|
string(%d) "%s"
|
|
["line"]=>
|
|
int(%d)
|
|
}
|
|
}
|
|
array(2) {
|
|
[0]=>
|
|
object(Closure)#%d (3) {
|
|
["name"]=>
|
|
string(%d) "{closure:%s:%d}"
|
|
["file"]=>
|
|
string(%d) "%s"
|
|
["line"]=>
|
|
int(%d)
|
|
}
|
|
[1]=>
|
|
int(5)
|
|
}
|