Doc #62446 [NEW]: static call of non-static function breaks context of late static binding

From: Date: Fri, 29 Jun 2012 08:00:28 +0000
Subject: Doc #62446 [NEW]: static call of non-static function breaks context of late static binding
Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-8511@lists.php.net to get a copy of this message
From: picht at eventit dot ag Operating system: ubuntu 2.6.32-41-server PHP version: 5.3.14 Package: Documentation problem Bug Type: Documentation Problem Bug description:static call of non-static function breaks context of late static binding Description: ------------ When calling a non-static function statically the late static binding context still points to the calling class context. This should be documented on the static keyword page. Test script: --------------- <?php class a { public static function foo() { echo 'foo a'; } public function bar() { // expecting to call a::foo or b::foo // calls c::foo instead static::foo(); } } class b extends a { public static function foo() { echo 'foo b'; } } class c { public function test() { b::bar(); } public static function foo() { echo 'foo c'; } } $c = new c(); $c->test(); Expected result: ---------------- Documentation suggest b::foo will be called Actual result: -------------- Documentation warns about c::foo getting called -- Edit bug report at https://bugs.php.net/bug.php?id=62446&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=62446&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=62446&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=62446&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=62446&r=fixed Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=62446&r=needdocs Fixed in release: https://bugs.php.net/fix.php?id=62446&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=62446&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=62446&r=needscript Try newer version: https://bugs.php.net/fix.php?id=62446&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=62446&r=support Expected behavior: https://bugs.php.net/fix.php?id=62446&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=62446&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=62446&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=62446&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=62446&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=62446&r=dst IIS Stability: https://bugs.php.net/fix.php?id=62446&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=62446&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=62446&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=62446&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=62446&r=mysqlcfg

« previous php.doc.bugs (#8511) next »