ceford / j4xdemos-com-mywalks

Joomla 4 Component Example Code and Tutorial Explanation
26 stars 13 forks source link

Wrong description of what the PHP 'use' statement does. #9

Open phunsoft opened 2 years ago

phunsoft commented 2 years ago

Hi, I'm developing my first joomla! component and am glad to have found your Mywalks project. The description helps a lot to slowlxy get used to how this all is supposed to work. Great and thanks for this.

I have found this statement:

The use Joomla\CMS\Language\Text statement loads the class that converts string keys to string values.

on https://docs.joomla.org/Part_1:_The_Site_code#The_Component_Router, which is wrong. The PHP 'use' statement does not load a class. It merely defines an alias for a namespaced component, such as a class, so it is easier to use it in the code.

The above use statement is equivalent to

use Joomla\CMS\Language\Text as Text;

and it defines "Text" to be an alias. So instead of writing

$var = new Joomla\CMS\Language\Text\Text;

one can simply write

$var = new Text;

You might want to change the text in the description.

Regards Peter