#19312 [NEW]: Problem on class heritance / class definition order

From: Date: Mon, 09 Sep 2002 12:23:07 +0000
Subject: #19312 [NEW]: Problem on class heritance / class definition order
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-18764@lists.php.net to get a copy of this message
From: scallop@iki.fi Operating system: Linux / Solaris PHP version: 4.2.3 PHP Bug Type: Scripting Engine problem Bug description: Problem on class heritance / class definition order Consider the following code: <?php class C extends B { } class B extends A { } class A { } ?> The code above produces a fatal error: "Cannot inherit from undefined class b" According to Jani (quote from bug #13165), "Classes must be defined in order. They can be in different order if they are in same file though." It seems to me that the order of class declarations doesn't matter as long as they are in the same file AND there are only two levels of inheritance (child extends parent). In this example, there are three levels of inheritance (child extends parent extends superclass) and in this case, the order of class definitions DOES matter. I realize there is a simple workaround by changing the order of these class declarations. This is just fine in simple cases like above but in a very complex class hierarchy this is a real problem. Tested on: - 4.1.2 (installed as apache module, SunOS 5.8, Apache 1.3.26) - 4.2.3 (installed as apache module, Red Hat 7.1, Apache 1.3.22) - 4.3.0 alpha2 (ZE 2? installed as apache module, Red Hat 7.1, Apache 1.3.22) -- Edit bug report at http://bugs.php.net/?id=19312&edit=1 -- Try a CVS snapshot: http://bugs.php.net/fix.php?id=19312&r=trysnapshot Fixed in CVS: http://bugs.php.net/fix.php?id=19312&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=19312&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=19312&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=19312&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=19312&r=support Expected behavior: http://bugs.php.net/fix.php?id=19312&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=19312&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=19312&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=19312&r=globals

« previous php.bugs (#18764) next »