Bug #78124 [NEW]: Subclass of an included class not available

From: Date: Fri, 07 Jun 2019 19:02:23 +0000
Subject: Bug #78124 [NEW]: Subclass of an included class not available
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-221181@lists.php.net to get a copy of this message
From: aschmidt at anamera dot net Operating system: Win x64 PHP version: 7.2.19 Package: Scripting Engine problem Bug Type: Bug Bug description:Subclass of an included class not available Description: ------------ If a class extends a parent class from an include/require, then the subclass cannot be referenced until AFTER the class definition. However, if a class extends a parent class from the SAME script, then the subclass CAN be referenced anywhere in the code. I can't tell at what point this broke, but this appears to have worked in earlier 7.2 releases. Test script: --------------- <?php declare(strict_types=1); require( 'bug2.php' ); // Error: mySubClass2 does NOT exist! var_dump( class_exists( 'myClass1', FALSE ), class_exists( 'mySubClass1', FALSE ), class_exists( 'myParentClass', FALSE ), class_exists( 'mySubClass2', FALSE ) ); class myClass1 { const myConst = 'C1'; } class mySubClass1 extends myClass1 { const myConst = 'S1'; } class mySubClass2 extends myParentClass { const myConst = 'S2'; } // Correct: Now mySubClass2 DOES exist! var_dump( class_exists( 'myClass1', FALSE ), class_exists( 'mySubClass1', FALSE ), class_exists( 'myParentClass', FALSE ), class_exists( 'mySubClass2', FALSE ) ); Content of file "bug2.php": <?php declare(strict_types=1); class myParentClass { const myConst = 'Parent'; } Expected result: ---------------- subclass_bug.php:7:boolean true subclass_bug.php:7:boolean true subclass_bug.php:7:boolean true subclass_bug.php:7:boolean true Actual result: -------------- subclass_bug.php:7:boolean true subclass_bug.php:7:boolean true subclass_bug.php:7:boolean true subclass_bug.php:7:boolean false -- Edit bug report at https://bugs.php.net/bug.php?id=78124&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=78124&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=78124&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=78124&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=78124&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=78124&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=78124&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=78124&r=needscript Try newer version: https://bugs.php.net/fix.php?id=78124&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=78124&r=support Expected behavior: https://bugs.php.net/fix.php?id=78124&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=78124&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=78124&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=78124&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=78124&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=78124&r=dst IIS Stability: https://bugs.php.net/fix.php?id=78124&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=78124&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=78124&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=78124&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=78124&r=mysqlcfg

« previous php.bugs (#221181) next »