Bug #69665 [NEW]: Classes must be declared before instantiating if using interfaces

From: Date: Tue, 19 May 2015 22:16:31 +0000
Subject: Bug #69665 [NEW]: Classes must be declared before instantiating if using interfaces
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-192770@lists.php.net to get a copy of this message
From: me at mikkel dot ca Operating system: Ubuntu 12.04.5 LTS PHP version: 5.6.9 Package: Class/Object related Bug Type: Bug Bug description:Classes must be declared before instantiating if using interfaces Description: ------------ PHP parses files for functions and classes before executing code. This is handy and improves code readability, but there's one exception: if a class is using an interface, then it must be declared before being referenced. If this is a technical limitation, the error message in this case should be more descriptive than the current "Class 'MyClass' not found". The PHP 4 to 5.0.x migration guide is the only place I've found in the documentation that mentions this limitation: http://php.net/manual/pl/migration5.incompatible.php "In some cases classes must be declared before use. It only happens if some of the new features of PHP 5 (such as interfaces) are used. Otherwise the behaviour is the old." Maybe after 10 years this should be fixed? Test script: --------------- http://pastie.org/10197520 -- Edit bug report at https://bugs.php.net/bug.php?id=69665&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=69665&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=69665&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=69665&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=69665&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=69665&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=69665&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=69665&r=needscript Try newer version: https://bugs.php.net/fix.php?id=69665&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=69665&r=support Expected behavior: https://bugs.php.net/fix.php?id=69665&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=69665&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=69665&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=69665&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=69665&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=69665&r=dst IIS Stability: https://bugs.php.net/fix.php?id=69665&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=69665&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=69665&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=69665&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=69665&r=mysqlcfg

« previous php.bugs (#192770) next »