Blog

Navigate to declarations

PhpStorm can navigate to functions and classes out of the box but there is added support for Joomla specific cases. The Joomla specific cases it can understand are:

  • Language strings
  • HTMLHelper

 Language strings

In Joomla multi-lingual support is enabled through the JText function. A common way to enter a language string is like this:

echo Text::_('JGLOBAL_NO_MATCHING_RESULTS');

This will translate to "No Matching Results" but to find in which language file this string is to be found is usually quite a search. PhpStorm makes it easy that you can navigate to the language file by hitting CTRL-B / CMD-B. If the language string is present in more than one file, a popup is shown with the possible options.

HTMLHelper

The JHtml class is used throughout Joomla to generate HTML elements, load stylesheets, load Javascript files, and a bunch of other things. To use a JHtml class the following code is used:

echo HTMLHelper:_('searchtools.sort', 'JSTATUS', 'a.state', $listDirn, $listOrder

To find where the sort function is located is quite the challenge because you first need to go to HTMLHelper and follow the code from there. PhpStorm makes life a lot easier by jumping straight to the sort function if you hit CTRL-B / CMD-B on the searchtools.sort.

Not only can you jump to the function declaration, PhpStorm will also show you the documentation for the function by hitting CTRL-Q / F1. This will help in understanding the parameters required and/or available for that specific function.