PHP: static methods and instances
Hello.
As it stated at http://php.net/manual/en/language.oop5.static.php
Static properties cannot be accessed through the object using the arrow operator ->
Then why in PhpStorm (as of 5.0.4) there is autocompletion for the case like this:
class Test { public function __construct(){} public static function staticMethod(){} } Test::staticMethod(); // OK
$test = new Test(); $test->staticMethod() //<--------- here is it! Not OK, but it's being proposed!
Regards.
Roman.
Please sign in to leave a comment.
Hi there,
But it works -- PHP does not complain about it:
Result:
In any case: http://youtrack.jetbrains.com/issue/WI-1716 ; http://youtrack.jetbrains.com/issue/WI-8800 -- State: Won't fix
I know that it works... But isn't it a violation of the official language specs (or recommendations)?
It's not the fault of PhpStorm if php engine allow that.