From: nicolas dot grekas+php at gmail dot com Operating system: Linux & Windows PHP version: 5.2.5 PHP Bug Type: Scripting Engine problem Bug description: autoload fails with complex loading scheme
Description: ------------ Hard to explain, see code... I think that PHP should be able to handle this kind of loading scheme. Here is what I thought this code would do : 1. __autoload('A') is called 2. inside this call for A: 2.1 class B is defined, which extends C 2.2 as C is not defined, __autoload('C') is called 2.3 inside this call for C: 2.3.1 class C is defined 2.3.2 (now we have everything needed for class B, haven't we ?) 2.3.3 class A extends B 2.4 we leave the __autoload('C') context 3. we leave the __autoload('A') context The bug is at step 2.3.3 : "class A extends B" triggers an autoload('B'), which should not occurs, as B should be already defined, thanks to 2.3.2... Reproduce code: --------------- <?php function __autoload($class) { switch ($class) { case 'A': case 'B': class B extends C {}; break; case 'C': class C {}; class A extends B {}; break; } } echo (int) class_exists('A'); Expected result: ---------------- 1 Actual result: -------------- Fatal error: Cannot redeclare class B in [...] on line 9 -- Edit bug report at http://bugs.php.net/?id=44848&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=44848&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=44848&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=44848&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=44848&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=44848&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=44848&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=44848&r=needscript Try newer version: http://bugs.php.net/fix.php?id=44848&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=44848&r=support Expected behavior: http://bugs.php.net/fix.php?id=44848&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=44848&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=44848&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=44848&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=44848&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=44848&r=dst IIS Stability: http://bugs.php.net/fix.php?id=44848&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=44848&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=44848&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=44848&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=44848&r=mysqlcfg