mirror of
https://github.com/php/php-src.git
synced 2024-09-21 18:07:23 +00:00
902d64390e
Writing to a proprety that hasn't been declared is deprecated, unless the class uses the #[AllowDynamicProperties] attribute or defines __get()/__set(). RFC: https://wiki.php.net/rfc/deprecate_dynamic_properties
56 lines
739 B
PHP
56 lines
739 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 (1) {
|
|
["this"]=>
|
|
*RECURSION*
|
|
}
|
|
}
|
|
}
|
|
int(1)
|
|
--------------
|
|
string(1) "a"
|
|
array(1) {
|
|
[0]=>
|
|
object(Closure)#%d (1) {
|
|
["this"]=>
|
|
object(foo)#%d (1) {
|
|
["a"]=>
|
|
*RECURSION*
|
|
}
|
|
}
|
|
}
|
|
int(1)
|