<?php
class Foo
{
public function bar()
{
return static function () {
var_dump($this);
};
}
public function baz()
{
return function () {
var_dump($this);
};
}
}
$f->bar()();
$f->baz()();
Warning: Undefined variable $f in /in/vsDJZ on line 20
Fatal error: Uncaught Error: Call to a member function bar() on null in /in/vsDJZ:20
Stack trace:
#0 {main}
thrown in /in/vsDJZ on line 20
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 variable $f in /in/vsDJZ on line 20
Fatal error: Uncaught Error: Call to a member function bar() on null in /in/vsDJZ:20
Stack trace:
#0 {main}
thrown in /in/vsDJZ on line 20
Process exited with code 255.
Notice: Undefined variable: f in /in/vsDJZ on line 20
Fatal error: Uncaught Error: Call to a member function bar() on null in /in/vsDJZ:20
Stack trace:
#0 {main}
thrown in /in/vsDJZ on line 20
Process exited with code 255.
Output for 7.3.32 - 7.3.33
Fatal error: Uncaught Error: Call to a member function bar() on null in /in/vsDJZ:20
Stack trace:
#0 {main}
thrown in /in/vsDJZ on line 20
Process exited with code 255.
Output for 7.0.0 - 7.0.4
Notice: Undefined variable: f in /in/vsDJZ on line 20
Fatal error: Uncaught Error: Call to a member function bar() on unknown in /in/vsDJZ:20
Stack trace:
#0 {main}
thrown in /in/vsDJZ on line 20
Process exited with code 255.
Output for 5.5.24 - 5.5.35, 5.6.8 - 5.6.28
Parse error: syntax error, unexpected '(' in /in/vsDJZ on line 20
Process exited with code 255.