<?php
class Foo
{
function test() { echo "foo\n"; }
}
class Bar extends Foo
{
function __construct()
{
[$this, 'test']();
[$this, 'parent::test']();
}
function test() { echo "bar\n"; }
}
new Bar;
bar
Fatal error: Uncaught Error: Call to undefined method Bar::parent::test() in /in/Z0HId:13
Stack trace:
#0 /in/Z0HId(19): Bar->__construct()
#1 {main}
thrown in /in/Z0HId on line 13
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
bar
Fatal error: Uncaught Error: Call to undefined method Bar::parent::test() in /in/Z0HId:13
Stack trace:
#0 /in/Z0HId(19): Bar->__construct()
#1 {main}
thrown in /in/Z0HId on line 13
Process exited with code 255.
Output for 5.6.38
Parse error: syntax error, unexpected '(' in /in/Z0HId on line 12
Process exited with code 255.