PhpStorm is my favorite IDE, I use it on a daily basis. Currently I work on a PHP project that use a custom PHP framework. This project and framework do not follow best PHP practices and do not focus on writing clean, readable code.
In the source code we call functions to get a new instance of a class. For example:
cAlert()->addError('...')
The function cAlert is declared on a PHP file included by the framework:
function cAlert() {
return c('Alert');
}
function c($className) {
return ClassCall::getActive($className);
}
ClassCall create a new instance or get an active instance of the class. Finally the Alert class is used:
class Alert {
public function addError($error) {
...
}
}
Problem
While editing the source code, I would like to navigate to the location of methods. This PhpStorm/IntelliJ feature doesn't seem to undestrand this specific architecture.
PhpStorm cannot find declaration to go to for the addError method of the class Alert (but it can find of course the cAlert method).
Question
I understand that PhpStorm cannot automatically resolve this method declaration.
Is it possible to configure the IDE in order to manually link, in my example, cAlert() with the Alert class?

cAlert()method returns nothing (void) -- that's why you see such "Cannot find declaration" message. Your particular code example can be solved by adding PHPDoc comment forcAlert()method with@return MyClassin it.cAlert()method return a instance ofAlertthroughreturn ClassCall::getActive($className);. But many thanks because/** @return Alert */solve the problem! Of course, that was it, how could I not have thought of that before!