[TYPO3-core] Coding Guidelines about PHP Namespaces

Benjamin Mack benni at typo3.org
Sun Mar 24 10:41:47 CET 2013


Hey,

as I recently have some commits flying around where "bugfixes" introduce
the namespaces declaration "use" like this

namespace TYPO3\CMS\Frontend\ContentObject;
use TYPO3\CMS\Core\Utility\GeneralUtility;

I feel like we should have some kind of definition when or for what kind
of namespaces we want to use "use", but then do it everywhere where it
makes sense. This info should be added to the official CGL, otherwise
we'll have some really dirty code, even after the namespaces cleanup ;-).

I suggest: Every core class has the following lines

use TYPO3\CMS\Core as CMS;
use TYPO3\CMS\Core\Utility as Utility;
use TYPO3\CMS\Backend as Backend;
use TYPO3\CMS\Frontend as Frontend;

I'm not a namespace expert but this seems logical for me to make the
code more descriptive.

I could also live with "don't use "use" at all".

My other option to make the cleanup complete:
  use TYPO3\CMS\Core as t3lib;
;-)


Thanks for your feedback.
Enjoy!

Benni.


More information about the TYPO3-team-core mailing list