|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull Requests
Pull requests:
HistoryAllCommentsChangesGit/SVN commits
[2020-08-20 05:52 UTC] requinix@php.net
-Status: Open
+Status: Feedback
[2020-08-20 05:52 UTC] requinix@php.net
[2020-08-20 07:04 UTC] ASchmidt at Anamera dot net
-Status: Feedback
+Status: Open
[2020-08-20 07:04 UTC] ASchmidt at Anamera dot net
[2020-08-20 09:09 UTC] cmb@php.net
[2020-09-01 19:01 UTC] huynhat dot niit at gmail dot com
[2020-09-01 19:03 UTC] fgfgfgfgfg at gmail dot com
[2021-12-01 17:24 UTC] cmb@php.net
-Status: Open
+Status: Wont fix
-Assigned To:
+Assigned To: cmb
[2021-12-01 17:24 UTC] cmb@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 02:00:01 2025 UTC |
Description: ------------ Produced with a fresh PHP 7.4.9 instance, empty PHP.ini, and a fresh web site. Child classes that are defined BEFORE the parent class can be referenced by code prior to the class definitions if running PHP 7.3.21 - but it will FAIL as non-existing in 7.4.9. I've been struggling with various warnings/errors in WordPress and other code that imply invalid class/method references, and was finally able to extract the attached reproducable sample. Test script: --------------- <?php declare(strict_types=1); var_dump( class_exists( 'MySubclass1' ), class_exists( 'MySubclass2' ), class_exists( 'MyAbstract' ) ); // PHP 7.4.9 = FALSE, true, true (PHP 7.3.21 = TRUE, true, true) class MySubclass1 extends MyAbstract{} abstract class MyAbstract{} class MySubclass2 extends MyAbstract{} var_dump( class_exists( 'MySubclass1' ), class_exists( 'MySubclass2' ), class_exists( 'MyAbstract' ) ); // true, true, true // Produced with empty php.ini ! Expected result: ---------------- If a child class is defined before or after the parent class should yield consistent results, whether the child class is referenced earlier or later in the code - as it was in 7.3. IF it is NOT permitted to define "MySubclass1" before the parent class, then this should lead to an error at the point the definition is encountered. ACCEPTING the definition as valid but then producing chance errors depending solely on where the child class is referenced seems arbitrary when working in large projects. Actual result: -------------- Depending on whether the child class was defined before or after the parent, and whether that child class happens to be referenced before or after its definition, will yield different outcomes (exist / not exist)