Bug #53742 [Com]: Late static binding does not work via reflection
Edit report at https://bugs.php.net/bug.php?id=53742&edit=1
ID: 53742
Comment by: david at orlandophp dot org
Reported by: blue-tidus159 at hotmail dot com
Summary: Late static binding does not work via reflection
Status: Closed
Type: Bug
Package: Scripting Engine problem
Operating System: Windows 7 x64
PHP Version: Irrelevant
Assigned To: laruence
Block user comment: N
Private report: N
New Comment:
Any chance this will get back-ported into older versions? It's still broken in
PHP 5.3.x up until 5.3.8, which represents a widely distributed range of
versions.
Previous Comments:
------------------------------------------------------------------------
[2011-12-21 07:13:42] laruence@php.net
This bug has been fixed in SVN.
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.
dup to #60367
------------------------------------------------------------------------
[2011-12-21 07:02:47] will dot fitch at gmail dot com
This is fixed in 5.4 and HEAD:
Fatal error: Class A contains 1 abstract method and must therefore be declared
abstract or implement the remaining methods (A::callLate)
------------------------------------------------------------------------
[2011-08-04 19:13:37] josh at joshbutts dot com
Still exists in PHP 5.3.5. Reproducible with the script above.
------------------------------------------------------------------------
[2011-05-12 20:06:23] phdaemon at gmail dot com
I experienced this bug when building a new automation framework using PHPUnit +
selenium.
IT seems that PHPUnit uses reflection to instantiate a static function called
suite which handles an array of browsers and duplicating a testcase to run in
each one.
I was on the latest ubuntu package: PHP 5.3.3-1ubuntu9.5 with Suhosin-Patch
(cli) (built: May 3 2011 00:49:55)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
I got around it by switching the reflection to call_user_func but this should
probably be fixed as PHPUnit is very popular.
------------------------------------------------------------------------
[2011-01-13 21:22:52] blue-tidus159 at hotmail dot com
Description:
------------
When a static method is called through reflection, late static binding does not work. Probably
because the getMethod() returns the method associated to the parent class.
Test script:
---------------
class A{
public static function call(){
static::callLate();
}
public static abstract function callLate();
}
class B{
public static function callLate(){
echo 'Late static binding';
}
}
B::call();
$class = new ReflectionClass('B');
$class->getMethod('call')->invoke(null);
Expected result:
----------------
Late static binding
Late static binding
Actual result:
--------------
Late static binding
Cannot call abstract method B::callLate()
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=53742&edit=1
Thread (6 messages)