[TYPO3-core] Use "namespace" directive for relative namespaces

Jigal van Hemert jigal.van.hemert at typo3.org
Mon Feb 25 14:28:27 CET 2013


Hi,

On 25-2-2013 13:28, Bernhard Kraft wrote:
> I would like to ask if there is some effort or interest to use the
> "namespace" directive of PHP in the TYPO3 core:
> http://www.php.net/manual/en/language.namespaces.basics.php
>
> For example in "sysext/cms/index_ts.php": Instead of prefixing EVERY
> call to \TYPO3\CMS\Core\... with this prefix we could declare a
> namespace for this file at the top:
>
> namespace \TYPO3\CMS\Core;
>
> And then simply use "Utility\MathUtility" or "Utility\GeneralUtility".
> I guess this would make the code a little more readable. Similar to the
> "import" statements at the top of a java class.

If a class is used more than a few times (approx. 3 or more, nothing set 
in stone) it would be nice to use the complete namespace for that class. 
Using partial namespaces would be less desirable IMO.

This was hard to do automatically, so it was left out in the initial 
namespace operation.
Feel free to make patches for the files in the core. (Each patch a 
limited number of files to prevent mega-patches :-) )

It does improve readability, but because there is no functional impact 
nobody has taken the trouble to spend time on this.

-- 
Jigal van Hemert
TYPO3 Core Team member

TYPO3 .... inspiring people to share!
Get involved: typo3.org


More information about the TYPO3-team-core mailing list