php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32290 call_user_func_array() calls wrong class method within child class
Submitted: 2005-03-13 13:04 UTC Modified: 2005-03-13 14:26 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 1 (0.0%)
From: ladoo at gmx dot at Assigned: helly (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 5.0.3 OS: *
Private report: No CVE-ID: None
 [2005-03-13 13:04 UTC] ladoo at gmx dot at
Description:
------------
I have a class A and a class B which extends A. Both have a equally named method. When I try to call A::method with call_user_func_array it calls B::method instead.

Reproduce code:
---------------
class A {
	public function doSomething($i)
	{
		return --$i;
	}
}

class B extends A {
	public function doSomething($i)
	{
		$i++;
		if ($i >= 100) return 100;
		return call_user_func_array(array("A","doSomething"), array($i));
	}
}
$x = new B();
echo $x->doSomething(1);

Expected result:
----------------
1

Actual result:
--------------
100

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-03-13 14:26 UTC] helly@php.net
This bug has been fixed in CVS.

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/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 06:01:30 2024 UTC