Bug #53742 [NEW]: Late static binding does not work via reflection

From: Date: Thu, 13 Jan 2011 20:22:52 +0000
Subject: Bug #53742 [NEW]: Late static binding does not work via reflection
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-157892@lists.php.net to get a copy of this message
From:             
Operating system: Windows 7 x64
PHP version:      Irrelevant
Package:          Scripting Engine problem
Bug Type:         Bug
Bug description:Late static binding does not work via reflection

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 bug report at http://bugs.php.net/bug.php?id=53742&edit=1
-- 
Try a snapshot (PHP 5.2):            http://bugs.php.net/fix.php?id=53742&r=trysnapshot52
Try a snapshot (PHP 5.3):            http://bugs.php.net/fix.php?id=53742&r=trysnapshot53
Try a snapshot (trunk):              http://bugs.php.net/fix.php?id=53742&r=trysnapshottrunk
Fixed in SVN:                        http://bugs.php.net/fix.php?id=53742&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=53742&r=needdocs
Fixed in release:                    http://bugs.php.net/fix.php?id=53742&r=alreadyfixed
Need backtrace:                      http://bugs.php.net/fix.php?id=53742&r=needtrace
Need Reproduce Script:               http://bugs.php.net/fix.php?id=53742&r=needscript
Try newer version:                   http://bugs.php.net/fix.php?id=53742&r=oldversion
Not developer issue:                 http://bugs.php.net/fix.php?id=53742&r=support
Expected behavior:                   http://bugs.php.net/fix.php?id=53742&r=notwrong
Not enough info:                     http://bugs.php.net/fix.php?id=53742&r=notenoughinfo
Submitted twice:                     http://bugs.php.net/fix.php?id=53742&r=submittedtwice
register_globals:                    http://bugs.php.net/fix.php?id=53742&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=53742&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=53742&r=dst
IIS Stability:                       http://bugs.php.net/fix.php?id=53742&r=isapi
Install GNU Sed:                     http://bugs.php.net/fix.php?id=53742&r=gnused
Floating point limitations:          http://bugs.php.net/fix.php?id=53742&r=float
No Zend Extensions:                  http://bugs.php.net/fix.php?id=53742&r=nozend
MySQL Configuration Error:           http://bugs.php.net/fix.php?id=53742&r=mysqlcfg



Thread (6 messages)

« previous php.bugs (#157892) next »