[CCA Standards] Was missfällt an PSR-1 und PSR-2 :: brace placement

David Greminger, 1up GmbH david.greminger at 1up.io
Fr Mai 2 11:00:03 CEST 2014


Da kann ich nur zustimmen!

Grüsse
David

___

David Greminger

B.Sc. in Computer Science UAS Zurich
Software Engineer
_________________________________
1up GmbH
Web development at its finest.

Weinmarkt 15
CH - 6004 Luzern

Phone: +41 41 511 21 00
Skype: david.greminger
Mail: david.greminger at 1up.io
Web: http://1up.io

Am 02.05.2014 um 10:26 schrieb Tristan Lins <tristan.lins at bit3.de>:

> [PSR-2] 1. Overview #2
> 
>> Opening braces for control structures MUST go on the same line, ...
> 
> Bzgl. der öffnenden Klammer stimme ich dem zu, aber die schließende
> Klammer sollte imo eine eigene Zeile bekommen.
> 
> Also
> 
>> if (...) {
>>    ...
>> }
>> else {
>>    ...
>> }
> 
> anstatt
> 
>> if (...) {
>>    ...
>> } else {
>>    ...
>> }
> 
> Begründung: Wenn man die "Einrückungslinie" entlang geht, kann man so
> besser lesen, wo das if anfängt und wo der nächste elseif/else Block
> anfängt, als wenn vor dem elseif/else erst noch eine "störende" } steht.
> 
> -----
> 
> Duplicate: [PSR-2] 5.1. if, elseif, else
> 
>> Note the placement of parentheses, spaces, and braces; and that else
>> and elseif are on the same line as the closing brace from the earlier
>> body.
> 
> -----
> 
> [PSR-2] 5.3. while, do while
> 
>> ... Note the placement of parentheses, spaces, and braces.
> 
> Auch hier gehört das while imo in eine eigene Zeile.
> 
> Also
> 
>> do {
>>    // structure body;
>> }
>> while ($expr);
> 
> anstatt
> 
>> do {
>>    // structure body;
>> } while ($expr);
> 
> Begründung: s.o.
> 
> -----
> 
> [PSR-2] 5.6. try, catch
> 
>> ... Note the placement of parentheses, spaces, and braces.
> 
> Auch hier gehören die catch'es in eine eigene Zeile.
> 
> Also
> 
>> try {
>>    // try body
>> }
>> catch (FirstExceptionType $e) {
>>    // catch body
>> }
>> catch (OtherExceptionType $e) {
>>    // catch body
>> }
> 
> anstatt
> 
>> try {
>>    // try body
>> } catch (FirstExceptionType $e) {
>>    // catch body
>> } catch (OtherExceptionType $e) {
>>    // catch body
>> }
> 
> Begründung: s.o.
> 
> -- 
> Tristan Lins - Inhaber, Softwareentwickler
> bit3 UG (haftungsbeschränkt)
> Im Coenen Palais · Hofstr. 272 · 56077 Koblenz
> info at bit3.de · http://bit3.de · 0261-45093253
> Amtsgericht Koblenz, HRB 23386
> _______________________________________________
> Standards mailing list
> Standards at lists.c-c-a.org
> http://lists.c-c-a.org/mailman/listinfo/standards

-------------- nächster Teil --------------
Ein Dateianhang mit Binärdaten wurde abgetrennt...
Dateiname   : signature.asc
Dateityp    : application/pgp-signature
Dateigröße  : 495 bytes
Beschreibung: Message signed with OpenPGP using GPGMail
URL         : <http://lists.c-c-a.org/pipermail/standards/attachments/20140502/da2b9ed7/attachment.sig>


More information about the Standards mailing list