3v4l.org

run code in 500+ PHP versions simultaneously
<?php final class Foo { /** * @param list<string> $foo */ public function baz(array $foo): string { return implode(array_map(static fn (string $fooItem) => $this->bar($fooItem), $foo)); } private function bar(string $value): string { return sprintf('Whatever: %s', $value); } } $foo = (new Foo())->baz(['ooq']);
Output for 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
Fatal error: Uncaught Error: Using $this when not in object context in /in/qvRWF:10 Stack trace: #0 [internal function]: Foo::{closure:Foo::baz():10}('ooq') #1 /in/qvRWF(10): array_map(Object(Closure), Array) #2 /in/qvRWF(19): Foo->baz(Array) #3 {main} thrown in /in/qvRWF on line 10
Process exited with code 255.
Output for 7.4.0 - 7.4.33, 8.0.1 - 8.0.30, 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30
Fatal error: Uncaught Error: Using $this when not in object context in /in/qvRWF:10 Stack trace: #0 [internal function]: Foo::{closure}('ooq') #1 /in/qvRWF(10): array_map(Object(Closure), Array) #2 /in/qvRWF(19): Foo->baz(Array) #3 {main} thrown in /in/qvRWF on line 10
Process exited with code 255.

preferences:
108.64 ms | 1290 KiB | 4 Q