<?php
interface Contract
{
const PASSWORD_RESET = 'passwords.reset';
public function reset(): void;
}
class A implements Contract
{
public function reset(): void
{
echo static::PASSWORD_RESET, "\n";
}
}
class B extends A {
const PASSWORD_RESET = 'foobar';
}
(new A())->reset();
(new B())->reset();
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
passwords.reset
foobar
Output for 7.0.0 - 7.0.33
passwords.reset
Fatal error: Uncaught TypeError: Return value of A::reset() must be an instance of void, none returned in /in/YjLvn:15
Stack trace:
#0 /in/YjLvn(22): A->reset()
#1 {main}
thrown in /in/YjLvn on line 15
Process exited with code 255.