[TYPO3-50-general] Coding Guidelines: Rule for long criteria line breaks - Voting

Patrick-Emil Zörner paddyez at gmail.com
Fri Aug 29 17:29:58 CEST 2008


2008/8/28 Tim Eilers <tim.eilers at web.de>:
> Hi folks,
> while coding Sniffs and reading other people code i often jumped about
> long criterias which where breaked into several lines, which is conform
> to our currenct coding guideline rule:
> ----
> if (weHaveALotOfCriteria() &&
>   notEverythingFitsIntoOneLine() ||
>   youJustTendToLikeIt()) {
>      doThis();
> ----
> While this looks easy to read it can be very difficult in complex code.
> I would suggest to change the rule to this:
> ----
> if (weHaveALotOfCriteria()
>   && notEverythingFitsIntoOneLine()
>   || youJustTendToLikeIt()) {
>      doThis();
> ----

Please read a smiley after each of my rather provocative sentences so
I do not need to make one after each sentence.

> Advantage:
> You clearly can see, that the line belongs to a longer criteria.

Can you?

> I am interested in your opinion, what do you think?

Is this going to lead to a discussion tabs vs. spaces, 8 spaces vs. 4 spaces?

> If all or many will agree, i would also do a Sniff, which checks it.

What PHP really lacks is a tool like perltidy [1]. Whatever it does
you will know what it will look like in the end. So you can have your
own script running over the code when getting the source. And before
you check in your code you run "phptidy".



1. http://perltidy.sourceforge.net/

More information about the TYPO3-project-5_0-general mailing list