php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #57649 runkit_import() - methods not added - multiple classes in one file
Submitted: 2007-05-05 11:11 UTC Modified: 2013-02-26 22:58 UTC
From: guessmoor at yahoo dot de Assigned: pollita (profile)
Status: Closed Package: runkit (PECL)
PHP Version: 5.2.1 OS: win xp
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: guessmoor at yahoo dot de
New email:
PHP Version: OS:

 

 [2007-05-05 11:11 UTC] guessmoor at yahoo dot de
Description:
------------
I am running php5.2.1 as apache2.2 module
It seems that there is a problem with multiple classes in a single file with runkit_import.
The reproduce-code throws the following error:
Fatal error: Call to undefined method a::foo()

When i define 'class c' before 'class a' in the same file, everythings ok.

Reproduce code:
---------------
#file main.php
<?class b { public function foobar() { echo "foobar()\n"; } }
class a extends b {} runkit_import( "class_a.php" );
$a = new a();
$a->foobar();
$a->foo();?>
#---------------------------------------#
#file class_a.php
<?class a { public function foo() { echo "foo()\n" } }
class c {} # Define class c before class a in this file works.
?>

Expected result:
----------------
foobar()
foo()

Actual result:
--------------
foobar()
Fatal error: Call to undefined method a::foo() in X:\main.php on line 5

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-05-05 11:13 UTC] guessmoor at yahoo dot de
changed the summary.
 [2013-02-26 22:58 UTC] pollita@php.net
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
http://snaps.php.net/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.

The bug you described was a side-effect of a different (but no less real) bug.  
Fixed via https://github.com/php/pecl-php-
runkit/commit/ff3e1d5297bdd5bfbba92377eefe369cd5c6dceb for PHP5 only.

For PHP4 you can workaround it by just making sure your classes have a definition 
(even an empty one) before importing.
 [2013-02-26 22:58 UTC] pollita@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: pollita
 [2013-05-18 23:45 UTC] dzenovich@php.net
Fixed for both PHP4 & PHP5 in the master branch at https://github.com/zenovich/runkit
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 12:01:31 2024 UTC