Req #67347 [Opn->Nab]: Access to static class properties inconsistent

From: Date: Wed, 28 May 2014 15:00:31 +0000
Subject: Req #67347 [Opn->Nab]: Access to static class properties inconsistent
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-185953@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=67347&edit=1 ID: 67347 Updated by: bwoebi@php.net Reported by: fleshgrinder at gmx dot at Summary: Access to static class properties inconsistent -Status: Open +Status: Not a bug Type: Feature/Change Request Package: *General Issues Operating System: Debian Wheezy PHP Version: 5.6.0beta3 Block user comment: N Private report: N New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php $foo::$foo is access of a static property on a dynamic class name. Pretty clear what it should mean. But $bar->foo::$foo isn't implemented to avoid confusion: is it now like $a = $bar->foo; $a::$foo; or like $a = foo::$foo; $bar->$a; ? That's why it was preferred to not implement it in the first place. Previous Comments: ------------------------------------------------------------------------ [2014-05-27 19:45:40] fleshgrinder at gmx dot at Note that the following works: $bar = new Bar(); $foo = $bar->foo; echo $foo::$foo; // Prints 'foo' ------------------------------------------------------------------------ [2014-05-27 19:42:53] fleshgrinder at gmx dot at Description: ------------ Accessing static properties is inconsistent and doesn't make much sense. Test script: --------------- class Foo { public static $foo = "foo"; } class Bar { public $foo; public function __construct() { $this->foo = new Foo(); } } Expected result: ---------------- Either $foo::$foo to result in some kind of ERROR or WARNING or $bar->foo::$foo has to work as well. Otherwise it's not consistent. Actual result: -------------- $foo = new Foo(); echo $foo::$foo; // Works and prints 'foo' echo $foo->foo; // STRICT WARNING echo $foo->$foo; // FATAL ERROR $bar = new Bar(); echo $bar->foo::$foo; // PARSE ERROR echo $bar->foo->foo; // STRICT WARNING echo $bar->foo->$foo; // FATAL ERROR ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=67347&edit=1

« previous php.bugs (#185953) next »