<?php
trait Evil {
public function say($msg) { echo 'I am evil! ' . $msg; }
}
class Human {
use Evil;
public function say($msg) {
echo 'I am not evil, even though I should say it after this anyway.';
parent::say($msg);
}
}
(new Human)->say('Hello World');
Fatal error: Cannot use "parent" when current class scope has no parent in /in/CT8sl 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
Fatal error: Cannot use "parent" when current class scope has no parent in /in/CT8sl on line 13
Process exited with code 255.
Output for 7.4.0 - 7.4.33
Deprecated: Cannot use "parent" when current class scope has no parent in /in/CT8sl on line 13
I am not evil, even though I should say it after this anyway.
Fatal error: Uncaught Error: Cannot access parent:: when current class scope has no parent in /in/CT8sl:13
Stack trace:
#0 /in/CT8sl(17): Human->say('Hello World')
#1 {main}
thrown in /in/CT8sl on line 13
Process exited with code 255.
I am not evil, even though I should say it after this anyway.
Fatal error: Uncaught Error: Cannot access parent:: when current class scope has no parent in /in/CT8sl:13
Stack trace:
#0 /in/CT8sl(17): Human->say('Hello World')
#1 {main}
thrown in /in/CT8sl on line 13
Process exited with code 255.
I am not evil, even though I should say it after this anyway.
Fatal error: Cannot access parent:: when current class scope has no parent in /in/CT8sl on line 13
Process exited with code 255.