[Neos] CGL Questions
Bastian Waidelich
bastian at typo3.org
Mon Oct 14 11:00:48 CEST 2013
Rens Admiraal wrote:
Hey Rens,
thanks for all your cleanup work during the weekend, I'd like to
nominate you "Flow housekeeper of the month"!
> I did some tries with the QA team a while ago to get the QA-Teams sniff
> packages compatible with Flow. It seems like they didn't do anything
> with it yet, so I'll do another try in some lost minutes... But more
> important I think it's a good thing if we start running the codesniffs
> regularly.
+1 did you give it another try in the meantime? ;)
> * Usage of functions in foreach / if / for / switch statements
> Do we allow this? For example:
>
> foreach ($this->getSomeArray() as $v) { ....
I think there is no reason not to allow this. Especially for foreach()
as PHP creates a copy of the subject anyways.
For if, for & switch I don't see a problem either. The function will
only be executed once in any case.
Only drawback *could* be lack of readability, and here other CGL rules
apply. So I'd be in favor not adding a rule for this specifically.
> * Do we allow empty catch statements?
> Example:
>
> } catch (\Exception $e) { // just some comments or nothing }}
Why not and what else to do? I mean it's usually an indicator for a
clumsy architecture but I don't think that we should add this to the
CGL. We could however extend the CGL-section at some point adding more
architectural topics (like composition over inheritance etc)
> * How do we format use statements?
> Will we use 1 use statement like:
>
> use Class 1,
> Class 2;
>
> Or do we add all use statements on a new line?
As Aske wrote, we decided to go for one use statement per line for now.
This is also mentioned in the latest version of the CGL[1]
[1]
http://docs.typo3.org/flow/TYPO3FlowDocumentation/latest/TheDefinitiveGuide/PartV/CodingGuideLines/PHP.html#importing-namespaces
--
Bastian Waidelich
--
Core Developer Team
TYPO3 .... inspiring people to share!
Get involved: typo3.org
More information about the Neos
mailing list