1

I have written this method in a parent class in order to be able to get instances of children too.

   /** @return static */
        public static function getInstance()
        {
            /** @var $instance static */
            static $instance = false;
            if (!$instance) {
                $instance = new static();
            }
            return $instance;
        }

When I get the instance, PhpStorm doesn't know about child class implementation (methods, constants, etc). How can I tell him about them?

In snippet I am suggesting @return and @var as methods that work in contexts that don't imply static refference.

4

1 回答 1

1

@return static确实在 PhpStorm 6 中工作(我在 6.0.2 中测试过。)所以如果你想使用这个功能,你应该升级到最新版本。

于 2013-05-20T19:23:02.970 回答