[php-src] Issue #21190: get_declared_interfaces() does not include interfaces extending from other interfaces if script returns early

From: Date: Tue, 10 Feb 2026 12:58:30 +0000
Subject: [php-src] Issue #21190: get_declared_interfaces() does not include interfaces extending from other interfaces if script returns early
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-251678@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/21190 Author: tiberiusteng ### Description The following code: ```php <?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')) exit; 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 ```plain 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_

« previous php.bugs (#251678) next »