This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| en:dev:all:psr:psr-1 [25.05.2015 18:39] – [Namespaces und Klassennamen] Manuela v.d.Decken | en:dev:all:psr:psr-1 [03.06.2015 15:55] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| 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:// | [size=10]originating from [[http:// | ||
| ====== Basic Coding Standard ====== | ====== Basic Coding Standard ====== | ||
| Line 12: | Line 10: | ||
| * Files MUST use only UTF-8 without BOM for PHP code. | * Files MUST use only UTF-8 without BOM for PHP code. | ||
| * Files SHOULD either declare symbols (classes, functions, constants, etc.) **OR** contain directly executabl code (//**cause side-effects**// | * Files SHOULD either declare symbols (classes, functions, constants, etc.) **OR** contain directly executabl code (//**cause side-effects**// | ||
| - | * Namespaces and classes MUST follow an " | + | * Namespaces and classes MUST follow an " |
| * Class names MUST be declared in // | * Class names MUST be declared in // | ||
| * Class constants MUST be declared in all upper case with underscore separators. | * Class constants MUST be declared in all upper case with underscore separators. | ||
| Line 67: | Line 65: | ||
| </ | </ | ||
| - | ===== Namespaces | + | ===== Namespaces |
| - | Die Benennung von Namespaces | + | Namespaces |
| - | Das bedeutet, dass jede Klasse | + | This means each class is in a file by itself, and is in a namespace of at least one level: a top-level vendor name. |
| - | Klassennamen MÜSSEN | + | Class names MUST be declared |
| - | :!: //Anpassung für WB:// Interfaces | + | :!: //Adaption for WB:// Interfaces |
| + | Code written for PHP 5.3 and after MUST use formal namespaces. | ||
| - | Code der für PHP-5.3 und höher geschrieben wird MUSS formale Namespace nutzen. | + | For example: |
| - | Beispiel: | ||
| <PHP> | <PHP> | ||
| <?php | <?php | ||
| - | // php 5.3 und später: | + | // PHP 5.3 and later: |
| namespace Vendor\Model; | namespace Vendor\Model; | ||
| Line 92: | Line 90: | ||
| <PHP> | <PHP> | ||
| <?php | <?php | ||
| - | // php 5.3 und später: | + | // PHP 5.3 and later: |
| namespace Vendor\Model; | namespace Vendor\Model; | ||
| Line 99: | Line 97: | ||
| } | } | ||
| </ | </ | ||
| - | Code der für PHP-Versionen vor 5.3 geschrieben wird SOLL die Konvention der Pseudo-Namespaces mit **Vendor_** | + | Code written for 5.2.x and before SHOULD use the pseudo-namespacing convention of **Vendor_** |
| <PHP> | <PHP> | ||
| <?php | <?php | ||
| - | // PHP 5.2.x und früher: | + | // PHP 5.2.x and earlier: |
| class Vendor_Model_Foo | class Vendor_Model_Foo | ||
| { | { | ||
| Line 109: | Line 107: | ||
| <PHP> | <PHP> | ||
| <?php | <?php | ||
| - | // PHP 5.2.x und früher: | + | // PHP 5.2.x and earlier: |
| class Vendor_Model_FooAbstract | class Vendor_Model_FooAbstract | ||
| { | { | ||
| Line 115: | Line 113: | ||
| </ | </ | ||
| - | ===== Klassen- Konstanten, Eigenschaften und Methoden | + | ===== Class Constants, Properties, and Methods |
| - | Das Term 'Klasse' | + | |
| + | The term 'class' | ||
| + | ==== Constants ==== | ||
| + | |||
| + | Class constants MUST be declared in all upper case with underscore separators. For example: | ||
| - | ==== Konstanten ==== | ||
| - | Klassenkonstanten MÜSSEN vollständig in Großbuchstaben deklariert werden. Der Unterstrich trennt einzelne Worte. | ||
| <PHP> | <PHP> | ||
| <?php | <?php | ||
| Line 127: | Line 127: | ||
| { | { | ||
| const VERSION = ' | const VERSION = ' | ||
| - | const DATE_APPROVED = '2014-08-12'; | + | const DATE_APPROVED = '2012-06-01'; |
| } | } | ||
| </ | </ | ||
| - | ==== Eigenschaften | + | ==== Properties |
| - | Dieser Leitfaden vermeidet absichtlich jede Empfehlung in Bezug auf die Verwendung von $**StudlyCaps**, | + | |
| - | Welche Namenskonvention auch benutzt wird, sie SOLLTE konsistent in einem vertretbaren Rahmen angewendet werden. | + | |
| - | :!: //Anpassung an WB:// Es MUSS durchgehend überall das **StudlyCaps** | + | This guide intentionally avoids any recommendation regarding the use of $**StudlyCaps**, |
| - | >>' | + | Whatever naming convention is used SHOULD be applied consistently within a reasonable scope. That scope may be vendor-level, |
| + | |||
| + | :!: //Adaption to WB:// It is REQUIRED that the **StudlyCaps** | ||
| + | >>' | ||
| <PHP> | <PHP> | ||
| Line 144: | Line 145: | ||
| </ | </ | ||
| - | ==== Methoden ==== | ||
| - | Methodennamen MÜSSEN in **camelCase()** deklariert werden. | ||
| + | ==== Methods ==== | ||
| + | |||
| + | Method names MUST be declared in **camelCase()**. | ||
| --- // | --- // | ||