Req #63454 [NEW]: Inheriting static function with static variable defined in a trait.

From: Date: Wed, 07 Nov 2012 13:19:03 +0000
Subject: Req #63454 [NEW]: Inheriting static function with static variable defined in a trait.
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-174552@lists.php.net to get a copy of this message
From: zetruger at gmail dot com Operating system: Xubuntu 12.04 PHP version: 5.4.8 Package: Class/Object related Bug Type: Feature/Change Request Bug description:Inheriting static function with static variable defined in a trait. Description: ------------ There is a difference between inheriting static function with static variable defined in a trait of a base class and the same function defined in a base class directly. Test script: --------------- <?php trait Foo { static public function theSameFunc() { static $var = NULL; if (is_null($var)) $var = get_called_class(); return $var; } } class A { use Foo; //static public function theSameFunc() { // static $var = NULL; // if (is_null($var)) $var = get_called_class(); // return $var; //} } class B extends A {} class C extends B {} var_dump(A::theSameFunc()); var_dump(B::theSameFunc()); var_dump(C::theSameFunc()); class D extends C {} class E extends D {} class F extends E {} var_dump(D::theSameFunc()); var_dump(E::theSameFunc()); var_dump(F::theSameFunc()); ?> Expected result: ---------------- string(1) "A" string(1) "B" string(1) "C" string(1) "D" string(1) "E" string(1) "F" Actual result: -------------- string(1) "A" string(1) "B" string(1) "C" string(1) "C" string(1) "C" string(1) "C" -- Edit bug report at https://bugs.php.net/bug.php?id=63454&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=63454&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=63454&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=63454&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=63454&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=63454&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=63454&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=63454&r=needscript Try newer version: https://bugs.php.net/fix.php?id=63454&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=63454&r=support Expected behavior: https://bugs.php.net/fix.php?id=63454&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=63454&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=63454&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=63454&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=63454&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=63454&r=dst IIS Stability: https://bugs.php.net/fix.php?id=63454&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=63454&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=63454&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=63454&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=63454&r=mysqlcfg

« previous php.bugs (#174552) next »