mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Move some low-hanging fruit, creating new directories for the tests for * access modifiers * `class_alias()` * constant expressions * constructor property promotion * `__debugInfo()` * dereferencing * first class callable syntax Additionally, move some tests into the existing subdirectory for closure-related tests Work towards GH-15631
68 lines
971 B
PHP
68 lines
971 B
PHP
--TEST--
|
|
Closure 026: Assigning a closure object to an array in $this
|
|
--FILE--
|
|
<?php
|
|
|
|
class foo {
|
|
public $a;
|
|
public function __construct() {
|
|
$a =& $this;
|
|
|
|
$a->a[] = function() {
|
|
return 1;
|
|
};
|
|
|
|
var_dump($this);
|
|
|
|
var_dump($this->a[0]());
|
|
}
|
|
}
|
|
|
|
$x = new foo;
|
|
|
|
print "--------------\n";
|
|
|
|
foreach ($x as $b => $c) {
|
|
var_dump($b, $c);
|
|
var_dump($c[0]());
|
|
}
|
|
|
|
?>
|
|
--EXPECTF--
|
|
object(foo)#%d (1) {
|
|
["a"]=>
|
|
array(1) {
|
|
[0]=>
|
|
object(Closure)#%d (4) {
|
|
["name"]=>
|
|
string(%d) "{closure:%s:%d}"
|
|
["file"]=>
|
|
string(%d) "%s"
|
|
["line"]=>
|
|
int(%d)
|
|
["this"]=>
|
|
*RECURSION*
|
|
}
|
|
}
|
|
}
|
|
int(1)
|
|
--------------
|
|
string(1) "a"
|
|
array(1) {
|
|
[0]=>
|
|
object(Closure)#%d (4) {
|
|
["name"]=>
|
|
string(%d) "{closure:%s:%d}"
|
|
["file"]=>
|
|
string(%d) "%s"
|
|
["line"]=>
|
|
int(%d)
|
|
["this"]=>
|
|
object(foo)#%d (1) {
|
|
["a"]=>
|
|
*RECURSION*
|
|
}
|
|
}
|
|
}
|
|
int(1)
|