[TYPO3-core] Coding Guidelines about PHP Namespaces

Jigal van Hemert jigal.van.hemert at typo3.org
Mon Mar 25 10:29:41 CET 2013


On 25-3-2013 9:53, Karsten Dambekalns wrote:
> On 24.03.2013, at 22:53, Thomas Maroschik <tmaroschik at dfau.de> wrote:
>> Am 24.03.13 13:32, schrieb Jigal van Hemert:
>>> This looks highly confusing. Why is a class called "Annotations" if you
>>> use it in the code as "Flow".
>>> use TYPO3\CMS\Core\Authentication\BackendUserAuthentication as DataHandler
>> You have to know Flow for that special case. You import in the
>> example a namespace and not a classname. There is no Annotations class
>> there. You need this for the doctrine annotations reader to work. Every
>> annotation is represented by a class.
> I disagree with the "You have to know Flow for that special case"
> statement :) This is regular namespace use in PHP that can be used
> everywhere a PHP namespace can be used. Neither tied to Flow nor to
> Doctrine Annotations.

The technical use is of course a regular option for namespaces. I think 
that Thomas either meant that the reason why "Flow" was chosen as the 
alias requires some knowledge of the structure of flow, or that he used 
the word 'special' instead of 'specific' or 'particular'.

> Also it helps if you keep "use" in mind as "use" - *not* "import"
> because nothing is imported. It just acts as a "search and replace" in a
> (rough) sense.

Can you file an issue with the PHP folks to change their documentation, 
please? Everywhere in the docs they use the terms 'import' and 
'aliasing' when the functionality of the "use" operator is described.

Some quotes:
"PHP namespaces support three kinds of aliasing or importing"
"In PHP, aliasing is accomplished with the use operator"
"Scoping rules for importing
The use keyword must be declared (...)"


Jigal van Hemert
TYPO3 CMS Core Team member

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

More information about the TYPO3-team-core mailing list