Description
The following code:
<?php
print_r(get_declared_interfaces());
print_r(get_declared_classes());
if (interface_exists('a')) {
return;
}
interface a {}
interface b extends a {}
class c {}
class d extends c {}
Only a appear in get_declared_interfaces(), both c and d appear in get_declared_classes(), perhaps they should be consistent?
We were trying to use if (interface_exists('a')) return; to prevent redeclaring an interface (upgrading legacy code from require_once to SPL autoload), but discovered that adding interface_exists() to old code would prevent them being loaded even when there are no new autoloaded version registered.
Also at first we are assuming get_declared_interfaces(), get_declared_classes() won't include code after them, but seems this is expected behavior.
PHP Version
PHP 8.5.2 (cli) (built: Jan 13 2026 21:40:53) (NTS)
Copyright (c) The PHP Group
Built by Homebrew
Zend Engine v4.5.2, Copyright (c) Zend Technologies
with Zend OPcache v8.5.2, Copyright (c), by Zend Technologies
Operating System
No response