Bug #79474 [Nab->Csd]: get_declared_classes Wrong loading order Inheritance

From: Date: Wed, 15 Apr 2020 08:50:16 +0000
Subject: Bug #79474 [Nab->Csd]: get_declared_classes Wrong loading order Inheritance
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-226583@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=79474&edit=1 ID: 79474 Updated by: phpdocbot@php.net Reported by: ahwelp at universo dot univates dot br Summary: get_declared_classes Wrong loading order Inheritance -Status: Not a bug +Status: Closed Type: Bug Package: Class/Object related Operating System: Linux PHP Version: 7.4.4 Block user comment: N Private report: N New Comment: Automatic comment on behalf of cmb Revision: http://git.php.net/?p=doc/en.git;a=commit;h=e4bb74f6edd6695e8cd860a2ce14c30fcc68444b Log: Fix #79474: get_declared_classes Wrong loading order Inheritance Previous Comments: ------------------------------------------------------------------------ [2020-04-15 08:50:01] cmb@php.net Automatic comment from SVN on behalf of cmb Revision: http://svn.php.net/viewvc/?view=revision&revision=349660 Log: Fix #79474: get_declared_classes Wrong loading order Inheritance ------------------------------------------------------------------------ [2020-04-14 20:44:04] ahwelp at universo dot univates dot br It there any work arround besides read the array backwards, ignoring the last element untill the String do not start with Composer\Autoload... ------------------------------------------------------------------------ [2020-04-14 20:12:10] nikic@php.net The order changes as part of variance support, which may introduce cyclic dependencies between classes, in which case "dependencies before dependents" is no longer a well-defined order. ------------------------------------------------------------------------ [2020-04-14 20:04:18] ahwelp at universo dot univates dot br @requinix I don't think so. The documentation page of php.net do not specify a order besides the user comment. @nikic Taking a look at the source, the commit https://github.com/php/php-src/commit/3d90b770e8d490989294101745d161b8347ae9d4 links to the bug #77631 and add that the order is undefined. Yes, this function don't have a defined order behavior on the documentation, but it feels conceptualy strange to load the child class before it's parent. The combined top-down bottom-up approach allow the classes to be loaded in arbitrary order (unlike C), but with the PSR-4 it not up to the developer to include the files and have some kind of controll over the include order. I could not find why the behavior changed, performance maybe? And like @requinix said, for 15 years users expect this behavior from the function. I don't know where and when the requisites for this function were defined and if it's possible to change the requisits. ------------------------------------------------------------------------ [2020-04-14 16:57:10] nikic@php.net Order of get_declared_classes() is unspecified. PHP 7.4, just like previous PHP versions, returns classes in order of registration. PHP 7.4, unlike previous PHP versions, can register a class before its parents, if that was the order in which the classes were loaded. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=79474 -- Edit this bug report at https://bugs.php.net/bug.php?id=79474&edit=1

« previous php.bugs (#226583) next »