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.
0
3 comments

Hi there,

But it works -- PHP does not complain about it:

<?php
class Test
{
    public function __construct()
    {
    }


    public static function staticMethod()
    {
        echo "meow!\n";
    }
}


Test::staticMethod();

$test = new Test();
$test->staticMethod();


Result:

E:\Projects\php\php.exe E:\Projects\web\_idetest\test.php
meow!
meow!


Process finished with exit code 0


In any case: http://youtrack.jetbrains.com/issue/WI-1716 ; http://youtrack.jetbrains.com/issue/WI-8800 -- State: Won't fix

0

I know that it works... But isn't it a violation of the official language specs (or recommendations)?

0

It's not the fault of PhpStorm if php engine allow that.

0

Please sign in to leave a comment.