userlond userlond - 1 year ago 127
PHP Question

PhpStorm PHPDocs document static facade class type to enable autocomplete

I create alias for static class using class_alias function:

* Class A
class A {
static function doSomething() {
print 42;
// create alias, now calling B:: is the same like A::
class_alias('A', 'B');

// here autocomplete is not working

Everything work ok, except autocomplete is not working when I type
and press Ctrl + Space.

Does PHPDoc or PhpStorm has some magic to help autocomplete to tell type of alias class to enable autocomplete, something as:

// /** @alias <full_name_of_original_class> <alias_name> */
/** @alias A B */

  1. Current PHPDoc (and PSR-5) has no @alias or similar tag

  2. Same with PhpStorm

  3. One day PhpStorm may support class_alias(). -- watch this ticket (star/vote/comment) to get notified on any progress.

  4. The only option I can offer you is to create something like class B extends A {} in a separate file that will be used by IDE only. BTW -- that's how Laravel's facades are supported (a way to tell IDE what those classes can do/what methods they have etc).