I want to use PhpStorm on Joomla project but I can not use "Go to Class Declaration" (Ctrl+B
) on main Joomla classes. For example JFactory::getApplication()
.
But with my own functions in custom plugin that option works great.
What it can be wrong there?
You only need that to work on legacy code. With the introduction of namespaces, most classnames have changed.
JFactory is a now non-existent class - it has been removed from the core. For compatibility's sake, a class alias is provided at runtime, so PHP can find the new class instead. PhpStorm (and other IDEs) don't know about those aliases (there are a lot more of them).
To solve the problem, Joomla provides a stub, that tells the IDE where to find the new class. Just run
$ php build/stubGenerator.php
This will generate a stubs.php
file in your project's root directory with the proper information.
For new code, don't use those old classnames - use their new name instead. The new classnames make it much more likely, that your new code will run on Joomla! 4.0.