I create alias for static class using class_alias function:
<?php
/**
* 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
B::doSomething();
Everything work ok, except autocomplete is not working when I type B::
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:
<?php
// /** @alias <full_name_of_original_class> <alias_name> */
/** @alias A B */
B::doSomething();
Current PHPDoc (and PSR-5) has no @alias
or similar tag
Same with PhpStorm
One day PhpStorm may support class_alias()
. https://youtrack.jetbrains.com/issue/WI-11936 -- watch this ticket (star/vote/comment) to get notified on any progress.
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).