<?php
spl_autoload_register(function($cname){
if ($cname == 'IMyInterface') {
interface IMyInterface {
// Use any class or interface constant as value of FOO.
// I'll just use some constant available out of the box, to keep it simple:
const FOO = FilesystemIterator::CURRENT_AS_PATHNAME;
}
} elseif ($cname == 'Foo') {
class Foo implements IMyInterface {}
} elseif ($cname == 'Bar') {
class Bar extends Foo implements IMyInterface {}
}
});
// Foo is super-class for Bar.
// uncomment below line to trigger the error:
$F = new Foo();
// this should run without errors at any time, but if Foo is instantiated
// prior to this line, then the error is triggered:
$B = new Bar();
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 inherit previously-inherited or override constant FOO from interface IMyInterface in /in/VpWO9 on line 12
Process exited with code 255.