From:             codextasy at gmail dot com
Operating system: Windows, Linux
PHP version:      5.2.10
PHP Bug Type:     Scripting Engine problem
Bug description:  Cyclic inclusion of classes

Description:
------------
There is a bug with cyclic inclusion of files with class definition.

There are three classes - A, B, C - each placed in a separate file -
A.php, B.php, C.php - all in the same directory.

B is a derived class of A, C is a derived of B.
So, B.php includes A.php (using require_once), C.php includes B.php.

A.php contains both class A and function f(), which is subsequently
called. f() includes 'C.php'.

When trying to request B.php (or include it from another file) I get Fatal
error: Class 'B' not found C.php on line 4.



Reproduce code:
---------------
Three files here:

--------[ A.php ]--------
<?

class A {}

function f()
{
  include 'C.php';
}

f();

?>
--------[ B.php ]--------
<?
require_once 'A.php';

class B extends A {}
?>

--------[ C.php ]--------
<?
require_once 'B.php';

class C extends B {}
?>


Expected result:
----------------
No error when requesting or including B.php.

Actual result:
--------------
Fatal error: Class 'B' not found in /srv/www/test/C.php on line 4

-- 
Edit bug report at http://bugs.php.net/?id=48686&edit=1
-- 
Try a CVS snapshot (PHP 5.2):        
http://bugs.php.net/fix.php?id=48686&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):        
http://bugs.php.net/fix.php?id=48686&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):        
http://bugs.php.net/fix.php?id=48686&r=trysnapshot60
Fixed in CVS:                        
http://bugs.php.net/fix.php?id=48686&r=fixedcvs
Fixed in CVS and need be documented: 
http://bugs.php.net/fix.php?id=48686&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=48686&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=48686&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=48686&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=48686&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=48686&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=48686&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=48686&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=48686&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=48686&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=48686&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=48686&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=48686&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=48686&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=48686&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=48686&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=48686&r=mysqlcfg

Reply via email to