|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2013-02-26 14:11 UTC] pollita@php.net
-Status: Open
+Status: Closed
-Assigned To:
+Assigned To: pollita
[2013-02-26 14:11 UTC] pollita@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 14:00:01 2025 UTC |
Description: ------------ Hi, 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: runkit_import('foo.class.php',RUNKIT_IMPORT_CLASSES|RUNKIT_IMPORT_OVERRIDE); 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: runkit_import('foo.class.php',RUNKIT_IMPORT_CLASSES|RUNKIT_IMPORT_OVERRIDE); runkit_class_adopt('Foo','FooParent'); 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: http://owly.homelinux.net/~nevans/code/runkit/foo.class.phps Test: http://owly.homelinux.net/~nevans/code/runkit/test.phps 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.