Search code examples
phpphpstormstatic-methodsphpdoc

PHPDoc to describe dynamic reference to static method


    $class = 'MyClass';
    $class::method();

Is it possible to add auto-complete of ::method(); with PHPDoc?


Solution

  • Yes. But this way only:

    <?php
    $class = 'MyClass';
    /** @var MyClass|string $class */
    $class::method();
    

    enter image description here