[TYPO3-core] Coding Guidelines about PHP Namespaces

Stefan Neufeind typo3.neufeind at speedpartner.de
Sun Mar 24 14:59:08 CET 2013


On 03/24/2013 01:15 PM, Jigal van Hemert wrote:
> 
> On 24-3-2013 10:41, Benjamin Mack wrote:

[...]

>> I'm not a namespace expert but this seems logical for me to make the
>> code more descriptive.
> 
> There is not functional need to use "use", but it makes the code more
> readable. Instead of having long, complete namespaces only a single name
> is used.
> 
> However, it seems rather confusing to use a different name instead of
> the class name.
> 
> use TYPO3\CMS\Frontend as Frontend;
> is superfluous as it is equal to:
> use TYPO3\CMS\Frontend;

I agree that using "use" where it makes sense sounds like a good idea to
make the code a bit more readable and still taking advantage of namespacing.

Imho we should make a list (which can be extended) or what long
classnames we substitute to what (like "Frontend" above). That way we
have a consistent view of the code and not somebody aliasing Core to
t3lib :-) (Benni, I liked that idea though.)
And I'd suggest we discourage usage of "use" without an "as" as well as
using aliases not in the list yet (which can be extended on the go when
we need it).

I expect such a list would contain at most 10 or so commonly used
classnames and their aliases.


Regards,
 Stefan


More information about the TYPO3-team-core mailing list