|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #57754 Problems with inherited classes
Submitted: 2007-07-20 19:03 UTC Modified: 2013-02-26 14:11 UTC
From: owlmanatt at gmail dot com Assigned: pollita (profile)
Status: Closed Package: runkit (PECL)
PHP Version: 5.1.2 OS: Ubuntu Linux 6.06 LTS
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.
Block user comment
Status: Assign to:
Bug Type:
From: owlmanatt at gmail dot com
New email:
PHP Version: OS:


 [2007-07-20 19:03 UTC] owlmanatt at gmail dot com

I'm having some trouble with runkit_import and runkit_class_adopt. I've tested this w/ PHP 5.1.2, Runkit 0.9 AND Runkit's CVS HEAD. The behaviours have been observed in both 0.9 and HEAD. I have attepted this all from the command line and from Apache2/mod_php5.

To summarize, I have two classes - Foo and FooParent. FooParent has one method, and Foo also has this method in it.

First, I tried Foo extends FooParent. I would use runkit_import for the initial load of the class file (instead of require/include), and it would load the class and behave as expected.

However, when the class is loaded with runkit_import for the second time, I get the following error:

Fatal error: Cannot redeclare class foo in /home/nevans/classkit/foo.class.php on line 23

This is how I am calling it:

If I take the extends FooParent out of the class definition, I am able to re-load the class as many times as I like without any fatal errors.

So, fine - I saw a potential workaround with runkit_class_adopt. I commented out the extends FooParent in Foo's class definition and tried to load it like this:


However, this causes a different problem. When runkit_adopt_class executes for the first time, I get this warning:

Warning: runkit_class_adopt(): Error inheriting parent method: sayDesu() in /home/nevans/classkit/test.php on line 18

Fatal error: Cannot access parent:: when current class scope has no parent in /home/nevans/classkit/foo.class.php on line 21

The fatal error implies that the class was not adopted by FooParent successfully.

Please see the link to my example code for further details.

Reproduce code:
Class definitions:


Expected result:
In the first case, using just runkit_import, I expect the class to be re-loaded successfully.

In the second case, using runkit_import and runkit_class_adopt, I expect runkit_class_adopt to properly load the parent's methods in and child the class to FooParent.

Actual result:
See the description.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2013-02-26 14:11 UTC]
-Status: Open +Status: Closed -Assigned To: +Assigned To: pollita
 [2013-02-26 14:11 UTC]
The fix for this bug has been committed.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at

 For Windows:
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Thu Oct 05 00:01:24 2023 UTC