Bug #78887 [Fbk->NoF]: Changed order in get_declared_classes() with parent(s) loaded by autoloader

From: Date: Sun, 08 Dec 2019 04:22:08 +0000
Subject: Bug #78887 [Fbk->NoF]: Changed order in get_declared_classes() with parent(s) loaded by autoloader
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-224122@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=78887&edit=1 ID: 78887 Updated by: php-bugs@lists.php.net Reported by: andi dot wr at googlemail dot com Summary: Changed order in get_declared_classes() with parent(s) loaded by autoloader -Status: Feedback +Status: No Feedback Type: Bug Package: SPL related Operating System: Linux PHP Version: 7.4.0 Private report: N New Comment: No feedback was provided. The bug is being suspended because we assume that you are no longer experiencing the problem. If this is not the case and you are able to provide the information that was requested earlier, please do so and change the status of the bug back to "Re-Opened". Thank you. Previous Comments: ------------------------------------------------------------------------ [2019-11-29 22:43:25] nikic@php.net Definitely unspecified behavior, at best an upgrading note can be added for this. ------------------------------------------------------------------------ [2019-11-29 14:56:56] requinix@php.net Sounds like undefined behavior to me. Is there documentation somewhere that says they'll be returned in a certain order? ------------------------------------------------------------------------ [2019-11-29 14:54:47] andi dot wr at googlemail dot com Description: ------------ After loading a class which inherits from other classes and parent classes are loaded by autoloader, get_declared_classes() gives another order than in previous PHP versions. < 7.4: parent => child 7.4: child => parent Result of code example (reverse order of get_declared_classes()): Array ( [0] => A [1] => B ... ) vs. Array ( [0] => B [1] => A ... ) Url: https://3v4l.org/lEnsR Test script: --------------- <?php spl_autoload_register(function($class){ if ($class === 'A') { eval("class A { }"); } }); class B extends A { } print_r(array_reverse(get_declared_classes())); Expected result: ---------------- Parent class(es) should be declared before child class. Actual result: -------------- Parent classes are declared before child class. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=78887&edit=1

« previous php.bugs (#224122) next »