Doc #64059 [NEW]: Backwards Incompatible __callStatic Behavior

From: Date: Wed, 23 Jan 2013 22:46:20 +0000
Subject: Doc #64059 [NEW]: Backwards Incompatible __callStatic Behavior
Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-9463@lists.php.net to get a copy of this message
From: php at anthonybishopric dot com Operating system: All PHP version: 5.4.11 Package: Documentation problem Bug Type: Documentation Problem Bug description:Backwards Incompatible __callStatic Behavior Description: ------------ PHP 5.4 seems to have changed the behavior of __callStatic when invoked inside the object context of the defining class. If both __call and __callStatic are defined, then inaccessible methods when invoked with a static context are sent to __callStatic. However, inside an object context, inaccessible methods that use the 'static', 'self' or $classname to invoke the method still get delegated to __call. In 5.3, statically invoked, inaccessible methods delegated to __callStatic, no matter where they are invoked. This is a breaking change that should be listed on the PHP 5.4 backwards incompatible change list. If this is an unintended change it should be fixed as a bug. Test script: --------------- class Magic{ public static function __callStatic($name, $args){ echo "__callStatic($name) invoked!\n"; } public function __call($name, $args){ echo "__call($name) invoked!\n"; } public function foo(){ Magic::bar(); // __call, but should be __callStatic static::bar(); // __call, but should be __callStatic self::bar(); // __call, but should be __callStatic $this->bar(); // correctly is __call } } $magic = new Magic(); $magic->foo(); Expected result: ---------------- __callStatic(bar) invoked! __callStatic(bar) invoked! __callStatic(bar) invoked! __call(bar) invoked! Actual result: -------------- __call(bar) invoked! __call(bar) invoked! __call(bar) invoked! __call(bar) invoked! -- Edit bug report at https://bugs.php.net/bug.php?id=64059&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=64059&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=64059&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=64059&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=64059&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=64059&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=64059&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=64059&r=needscript Try newer version: https://bugs.php.net/fix.php?id=64059&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=64059&r=support Expected behavior: https://bugs.php.net/fix.php?id=64059&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=64059&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=64059&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=64059&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=64059&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=64059&r=dst IIS Stability: https://bugs.php.net/fix.php?id=64059&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=64059&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=64059&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=64059&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=64059&r=mysqlcfg

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