User Tools

Site Tools


en:dev:all:psr:psr-2

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
en:dev:all:psr:psr-2 [26.05.2015 20:09] – [while, do while] translated mrbasemanen:dev:all:psr:psr-2 [31.03.2017 06:59] (current) – [try, catch] Manuela v.d.Decken
Line 1: Line 1:
-FIXME **This page is not fully translated, yet. Please help completing the translation.**\\ //(remove this paragraph once the translation is finished)// 
- 
 [size=10]originating from  [[http://www.php-fig.org/psr/psr-2/|PHP-FIG PSR-2]][/size] [size=10]originating from  [[http://www.php-fig.org/psr/psr-2/|PHP-FIG PSR-2]][/size]
 ====== Coding Style Guide ====== ====== Coding Style Guide ======
Line 291: Line 289:
  
 ==== for ==== ==== for ====
-Ein **for**-Statement sieht wie nachfolgend ausBeachten Sie die Plazierung von KlammernLeerstellen und geschweiften Klammern+**for** statement looks like the followingNote the placement of parenthesesspaces, and braces.
 <PHP> <PHP>
 for ($i = 0; $i < 10; $i++) { for ($i = 0; $i < 10; $i++) {
Line 297: Line 295:
 } }
 </PHP> </PHP>
- 
  
 ==== foreach ==== ==== foreach ====
-Ein **foreach**-Statement sieht wie nachfolgend ausBeachten Sie die Plazierung von KlammernLeerstellen und geschweiften Klammern+**foreach** statement looks like the followingNote the placement of parenthesesspaces, and braces.
 <PHP> <PHP>
 foreach ($iterable as $key => $value) { foreach ($iterable as $key => $value) {
Line 308: Line 305:
  
  
-==== try, catch ==== +==== try, catch, finally ==== 
-Ein **try catch**-Statement sieht wie nachfolgend ausBeachten Sie die Plazierung von KlammernLeerstellen und geschweiften Klammern+**try catch** block looks like the followingNote the placement of parentheses, spacesand braces.
 <PHP> <PHP>
 try { try {
Line 317: Line 314:
 } catch (OtherExceptionType $e) { } catch (OtherExceptionType $e) {
     // catch body     // catch body
 +} finally {
 +    // finally body
 } }
 </PHP> </PHP>
Line 322: Line 321:
  
 ===== Closures ===== ===== Closures =====
-  * Closures MÜSSEN mit einem Leerzeichen nach denm Schlüsselwort **function** und je einem Leerzeichen vor und nach dem Schlüsselwort **use** deklariert werden+  * Closures MUST be declared with a space after the **function** keyword, and a space before and after the **use** keyword
-  * Die öffnende, geschweifte Klammer MUSS in der selben Zeile wie das Schlüsselwort **function** sein und die schließende Klammer MUSS in der nächsten Zeile nach dem Funktionskörper sein+  * The opening brace MUST go on the same line as the **function** keyword, and the closing brace MUST go on the next line following the body
-  * Nach der öffnenden Klammer der Argumentenliste DARF NICHT ein Leerzeichen stehen und vor der schließenden Klammer DARF NICHT ein Leerzeichen sein+  * There MUST NOT be a space after the opening parenthesis of the argument list or variable list, and there MUST NOT be a space before the closing parenthesis of the argument list or variable list
-  * In der Argumentenliste und der Variablenliste DARF NICHT ein Leerzeichen vor einem Komma stehen und nach einem Komma MUSS ein Leerzeichen sein+  * In the argument list and variable list, there MUST NOT be a space before each comma, and there MUST be one space after each comma
-  * Closure Argumente mit Vorgabewerten (default) MÜSSEN an das Ende der Argumentenliste+  * Closure arguments with default values MUST go at the end of the argument list
-Eine Closure Deklaration sieht wie nachfolgend ausBeachten Sie die Plazierung von KlammernLeerstellen und geschweiften Klammern. +A closure declaration looks like the followingNote the placement of parenthesescommas, spaces, and braces:
 <PHP> <PHP>
 $closureWithArgs = function ($arg1, $arg2) { $closureWithArgs = function ($arg1, $arg2) {
Line 337: Line 336:
 }; };
 </PHP> </PHP>
-  * Argumenten- und Variablenlisten KÖNNEN über mehrere Zeilen gesplittet werdenwenn jede Unterzeile um eine Stufe eingerückt wirdWenn so verfahren wirdMUSS das erste Element in die nächste Zeile und es DARF NICHT mehr als ein Argument oder Variable je Zeile angegeben werden+  * Argument lists and variable lists MAY be split across multiple lineswhere each subsequent line is indented onceWhen doing so, the first item in the list MUST be on the next line, and there MUST be only one argument or variable per line
-  * Wenn eine Argumenten- oder Variablenliste gesplittet wirdso MUSS die schließende Klammer und die öffnende geschweifte Klammer mit einer Leerstelle dazwischen in eine eigene Zeile+  * When the ending list (whether or arguments or variables) is split across multiple linesthe closing parenthesis and opening brace MUST be placed together on their own line with one space between them
-Beispiele von Closures mit und ohne Argumentenliste und Variableliste die über mehrere Zeilen gesplittet sind.+  * The following are examples of closures with and without argument lists and variable lists split across multiple lines.
 <PHP> <PHP>
 $longArgs_noVars = function ( $longArgs_noVars = function (
Line 385: Line 384:
 }; };
 </PHP> </PHP>
-Beachten Sie, dass die Formatierungsregeln auch greifen, wenn ein  Closure direkt in einem Funktions- oder Methodenaufruf als Argument eingesetzt ist.+Note that the formatting rules also apply when the closure is used directly in a function or method call as an argument.
 <PHP> <PHP>
 $foo->bar( $foo->bar(
Line 395: Line 394:
 ); );
 </PHP> </PHP>
- 
- 
- 
- 
  
  
en/dev/all/psr/psr-2.1432670971.txt.gz · Last modified: 03.06.2015 15:55 (external edit)