Reflection and Late Static Binding

Bug #60367 Reflection and Late Static Binding
Submitted: 2011-11-23 16:57 UTC Modified: 2011-11-24 09:18 UTC
Votes:4
Avg. Score:4.8 ± 0.4
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:1 (50.0%)
From: woody dot gilk at kohanaframework dot org Assigned: laruence (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 5.3.8 OS: OSX 10.6.8
Private report: No CVE-ID: None

 [2011-11-23 16:57 UTC] woody dot gilk at kohanaframework dot org

Description:
------------
When calling a method that exists only in the parent class with Reflection, the 
incorrect class is used.

This bug is highly related to #53742, but has a different test case. The root 
cause may be exactly the same.

Test script:
---------------
abstract class A {

	const WHAT = 'wrong';

	public static function call() {
		echo static::WHAT;
	}

}

class B extends A {

	const WHAT = 'correct';

}

B::call();

$class = new ReflectionClass('B');
$class->getMethod('call')->invoke(null);


Expected result:
----------------
"correct"

Actual result:
--------------
"wrong"

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports

 [2013-04-03 20:26 UTC] david at orlandophp dot org

Any chance this will be back-ported to older versions of PHP? This bug affects 
the Reflection API in all versions of PHP from 5.3 to 5.3.8, which is widely 
distributed. A patch release would be appreciated.