Edit report at https://bugs.php.net/bug.php?id=53742&edit=1

 ID:                 53742
 Updated by:         larue...@php.net
 Reported by:        blue-tidus159 at hotmail dot com
 Summary:            Late static binding does not work via reflection
-Status:             Open
+Status:             Closed
 Type:               Bug
 Package:            Scripting Engine problem
 Operating System:   Windows 7 x64
 PHP Version:        Irrelevant
-Assigned To:        
+Assigned To:        laruence
 Block user comment: N
 Private report:     N

 New Comment:

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


Previous Comments:
------------------------------------------------------------------------
[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

Reply via email to