[TYPO3-dev] Coding guidelines questions: commas in array, tabs

Ernesto Baschny [cron IT] ernst at cron-it.de
Mon May 19 17:01:53 CEST 2008


Hi Oli,

I agree to all your points.

If I recall correctly, we agreed that for formatting a particular array 
common sense is needed, so that we just have recommendations but 
depending on the case the formatting can be done differently to make it 
"look good".

I also think if the array contain multiple lines we should have a last 
"," after last element (for easy continuation and nicer patches).

Cheers,
Ernesto


Oliver Klee wrote: on 19.05.2008 16:50:
> Hi everybody,
> 
> after the (very productive!) coding guidelines (CGL) session at the 
> T3DD08, I wondered about three possible special cases of or exceptions 
> from the rules we decided on.
> 
> I'd like know whether this already is covered by the new CGL (and I just 
> missed it) or how this should be handled.
> 
> 
> 1. We decided that there should be a comma even after the last element 
> of an array:
> 
>   $foo = array(
>     'bar',
>     'foobar',
>   );
> 
> 
> 1a. Should this also apply to single-element arrays?
>   $foo = array(
>     'bar',
>   );
> 
> (My vote is to *keep* the comma in this case. -> *no* exception to the 
> general rule)
> 
> 
> 1b. Should this also apply to arrays that use one line only?
>   $foo = array('bar');
>     vs.
>   $foo = array('bar',);
> 
>   $foo = array(11, 42);
>     vs.
>   $foo = array(11, 42,);
> 
> (My vote is to *drop* the comma in this case. -> *exception* to the 
> general rule)
> 
> 
> 2. We decided that tabs should only be used at the beginning of lines, 
> but not after a non-tab character.
> 
> Does this also apply to tabs after @param, @return, @author?
> 
>   @param<tab>integer<tab><tab>number of elements to display, must be > 0
> 
> 
> (My vote is to use *spaces* in this, not tabs. -> *no* exception to the 
> general rule)
> 
> 
> Best regards,
> 
> 
> Oliver




More information about the TYPO3-dev mailing list