<?php
class A{
private $stuff = 10;
function test(){
return new class($this){
function __construct(A $s){
$this->s;
}
function test(){
return $this->s->stuff;
}
};
}
}
$x = new A;
$x->test()->text();
Warning: Undefined property: class@anonymous::$s in /in/cWBKH on line 8
Fatal error: Uncaught Error: Call to undefined method class@anonymous::text() in /in/cWBKH:19
Stack trace:
#0 {main}
thrown in /in/cWBKH on line 19
Process exited with code 255.
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
Warning: Undefined property: class@anonymous::$s in /in/cWBKH on line 8
Fatal error: Uncaught Error: Call to undefined method class@anonymous::text() in /in/cWBKH:19
Stack trace:
#0 {main}
thrown in /in/cWBKH on line 19
Process exited with code 255.
Notice: Undefined property: class@anonymous::$s in /in/cWBKH on line 8
Fatal error: Uncaught Error: Call to undefined method class@anonymous::text() in /in/cWBKH:19
Stack trace:
#0 {main}
thrown in /in/cWBKH on line 19
Process exited with code 255.
Output for 7.3.32 - 7.3.33
Fatal error: Uncaught Error: Call to undefined method class@anonymous::text() in /in/cWBKH:19
Stack trace:
#0 {main}
thrown in /in/cWBKH on line 19
Process exited with code 255.
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.40
Parse error: syntax error, unexpected 'class' (T_CLASS) in /in/cWBKH on line 6
Process exited with code 255.