php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #19312 Problem on class heritance / class definition order
Submitted: 2002-09-09 07:23 UTC Modified: 2002-09-09 10:38 UTC
From: scallop at iki dot fi Assigned:
Status: Duplicate Package: Feature/Change Request
PHP Version: 4.2.3 OS: Linux / Solaris
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: scallop at iki dot fi
New email:
PHP Version: OS:

 

 [2002-09-09 07:23 UTC] scallop at iki dot fi
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)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-09-09 08:56 UTC] scallop at iki dot fi
I just noticed (sorry, tried before but couldn't find any reports) that this issue has been discussed before in bug 6418.

Placing my comments in there ..
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sat Dec 07 11:01:24 2019 UTC