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

From: Date: Sun, 25 Nov 2012 12:45:37 +0000
Subject: Req #63454 [Com]: Inheriting static function with static variable defined in a trait.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-174927@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=63454&edit=1 ID: 63454 Comment by: cheap-michael-kors-handbags at hotmail dot com Reported by: zetruger at gmail dot com Summary: Inheriting static function with static variable defined in a trait. Status: Open Type: Feature/Change Request Package: Class/Object related Operating System: Xubuntu 12.04 PHP Version: 5.4.8 Block user comment: N Private report: N New Comment: I think if you have gone to <a href="http://www.cheap-michael-kors-handbags-outlet.com/"><strong>michael kors handbags outlet</strong></a>,then you will find the <a href="http://www.cheap-michael-kors-handbags-outlet.com/"><strong>michael kors factory outlet</strong></a> is really so good .In fact its function is nice too.All stuffs here are <a href="http://www.cheap-michael-kors-handbags-outlet.com/"><strong>michael kors handbags</strong></a>.I think you won't be empty-handed. Previous Comments: ------------------------------------------------------------------------ [2012-11-25 12:45:15] beatdrdre at hotmail dot com Whereever we go,we always hope to get perfect things.<a href="http://www.cheap-beats-by-dre-sale-outlet.com/"><strong>beats by dre sale</strong></a> is such a place that offer me good items.<a href="http://www.cheap-beats-by-dre-sale-outlet.com/"><strong>wholesale beats by dre</strong></a> is quite good with the service.I like the <a href="http://www.cheap-beats-by-dre-sale-outlet.com/"><strong>beats by dre outlet</strong></a>.So I want you can love it too. ------------------------------------------------------------------------ [2012-11-07 20:16:31] zetruger at gmail dot com I think static variables must be set to default value or nulled automaticly in the moment of defining their classes. It does not work with traits. ------------------------------------------------------------------------ [2012-11-07 19:19:18] mail+php at requinix dot net Seems like a bug: the order of class declarations and var_dumps matters. With class A { ... } var_dump(A::theSameFunc()); class B extends A {} class C extends B {} class D extends C {} class E extends D {} class F extends E {} var_dump(B::theSameFunc()); var_dump(C::theSameFunc()); var_dump(D::theSameFunc()); var_dump(E::theSameFunc()); var_dump(F::theSameFunc()); I get AAAAAA, but with class A { ... } class B extends A {} class C extends B {} class D extends C {} var_dump(A::theSameFunc()); var_dump(B::theSameFunc()); var_dump(C::theSameFunc()); var_dump(D::theSameFunc()); class E extends D {} class F extends E {} var_dump(E::theSameFunc()); var_dump(F::theSameFunc()); I get ABCDDD. ------------------------------------------------------------------------ [2012-11-07 14:46:48] zetruger at gmail dot com I suppose it's a bug isn't it? Or is it normal behavior? ------------------------------------------------------------------------ [2012-11-07 14:32:24] laruence@php.net it's not about triat, it's about run-time or compile-time. the following script behavior the same as your test script: <?php function __autoload($ce) { eval(<<<'PHP' class A { static public function theSameFunc() { static $var = NULL; if (is_null($var)) $var = get_called_class(); return $var; } } PHP ); } var_dump(A::theSameFunc()); class B extends A {} var_dump(B::theSameFunc()); ?> output: string(1) "A" string(1) "A" ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=63454 -- Edit this bug report at https://bugs.php.net/bug.php?id=63454&edit=1

« previous php.bugs (#174927) next »