<?php declare(strict_types = 1);
class Foo
{
public function __construct()
{
$closure = static function () : void {
$this->baz();
};
$closure();
}
public function bar() : void {}
}
new Foo();
Fatal error: Uncaught Error: Using $this when not in object context in /in/nr5Bl:8
Stack trace:
#0 /in/nr5Bl(10): Foo::{closure}()
#1 /in/nr5Bl(16): Foo->__construct()
#2 {main}
thrown in /in/nr5Bl on line 8
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
Fatal error: Uncaught Error: Using $this when not in object context in /in/nr5Bl:8
Stack trace:
#0 /in/nr5Bl(10): Foo::{closure}()
#1 /in/nr5Bl(16): Foo->__construct()
#2 {main}
thrown in /in/nr5Bl on line 8
Process exited with code 255.
Output for 5.6.0 - 5.6.40
Warning: Unsupported declare 'strict_types' in /in/nr5Bl on line 1
Parse error: syntax error, unexpected ':', expecting '{' in /in/nr5Bl on line 7
Process exited with code 255.