|
2 | 2 |
|
3 | 3 | All notable changes to this project will be documented in this file, in reverse chronological order by release.
|
4 | 4 |
|
| 5 | +## 2.0.0 - TBD |
| 6 | + |
| 7 | +### Added |
| 8 | + |
| 9 | +- [#5](https://github.com/zendframework/zend-coding-standard/pull/5) adds |
| 10 | + online documentation: https://docs.zendframework.com/zend-coding-standard/ |
| 11 | +- [#5](https://github.com/zendframework/zend-coding-standard/pull/5) adds |
| 12 | + PSR-12 rules. |
| 13 | + |
| 14 | + *NOTE:* PSR-12 is not finalized. e.g. The `!` operator and `:` placement for |
| 15 | + return values are still under discussion. We will change these rules, and, |
| 16 | + when PSR-12 is finalized, adapt them. |
| 17 | +- [#5](https://github.com/zendframework/zend-coding-standard/pull/5) extends |
| 18 | + PSR-12 with ZendFramework specific rules: |
| 19 | + |
| 20 | + *NOTE:* Most of these rules should look familiar as they are already being |
| 21 | + used in components rewritten for PHP 7.1. |
| 22 | + |
| 23 | + - There should be one space on either side of an equals sign used to assign |
| 24 | + a value to a variable. In case of a block of related assignments, more |
| 25 | + space may be inserted before the equal sign to promote readability. |
| 26 | + - Short array syntax must be used to define arrays. |
| 27 | + - All values in multiline arrays must be indented with 4 spaces. |
| 28 | + - All array values must be followed by a comma, including the last value. |
| 29 | + - Whitespace is not allowed around the opening bracket or before the |
| 30 | + closing bracket when referencing an array. |
| 31 | + - The `global` keyword may not be used. |
| 32 | + - The `PHP_SAPI` constant must be used instead of the `php_sapi_name()` |
| 33 | + function. |
| 34 | + - PHP function calls must be in lowercase. |
| 35 | + - PHP functions which are an alias may not be used. |
| 36 | + - Deprecated functions should not be used. |
| 37 | + - Comments may be omitted and should not be used for typehinted arguments. |
| 38 | + - Comments may not start with `#`. |
| 39 | + - Comments may not be empty. |
| 40 | + - The words _private_, _protected_, _static_, _constructor_, _deconstructor_, |
| 41 | + _Created by_, _getter_ and _setter_, may not be used in comments. |
| 42 | + - The annotations `@api`, `@author`, `@category`, `@created`, `@package`, |
| 43 | + `@subpackage` and `@version` may not be used in comments. Git commits |
| 44 | + provide accurate information. |
| 45 | + - The asterisks in a doc comment should align, and there should be one space |
| 46 | + between the asterisk and tag. |
| 47 | + - Comment tags `@param`, `@throws` and `@return` should not be aligned or |
| 48 | + contain multiple spaces between the tag, type and description. |
| 49 | + - If a function throws any exceptions, they should be documented in `@throws` |
| 50 | + tags. |
| 51 | + - The `@var` tag may be used in inline comments to document the _Type_ of |
| 52 | + properties. |
| 53 | + - Single-line comments with a `@var` tag should be written as one-liners. |
| 54 | + - Shorthand scalar typehint variants must be used in docblocks. |
| 55 | + - Each PHP file should have a page level docblock with `@see`, `@copyright` |
| 56 | + and `@license`. The copyright date should only be adjusted if the file has |
| 57 | + changed. |
| 58 | + - Each PHP file should have a strict type declaration at the top after the |
| 59 | + page level docblock. |
| 60 | + - Import statements should be alphabetically sorted. |
| 61 | + - Import statements should not be grouped. |
| 62 | + - Each import statement should be on its own line. |
| 63 | + - Absolute class name references, functions and constants should be imported. |
| 64 | + - Unused import statements are not allowed. |
| 65 | + - Classes and function within the same namespace should not be imported. |
| 66 | + - Imports should not have an alias with the same name. |
| 67 | + - A class should not have unused private constants, (or write-only) |
| 68 | + properties and methods. |
| 69 | + - Class name resolution via `::class` should be used instead of |
| 70 | + `__CLASS__`, `get_class()`, `get_class($this)`, `get_called_class()` and |
| 71 | + `get_parent_class()`. |
| 72 | + - Methods may not have the final declaration in classes declared as final. |
| 73 | + - The colon used with return type declarations MUST be surrounded with 1 |
| 74 | + space. |
| 75 | + - Nullable and optional arguments, which are marked as `= null`, must have |
| 76 | + the `?` symbol present. |
| 77 | + - Control Structures must have at least one statement inside of the body. |
| 78 | + - Catch blocks may be empty. |
| 79 | + - Catch blocks must be reachable. |
| 80 | + - Catch blocks must use `Throwable` instead of `Exception`. |
| 81 | + - The not (`!`) operator must be followed by exactly one space. |
| 82 | + - The `&&` and `||` operators must be used instead of `AND` and `OR`. |
| 83 | + - The null coalescing operator `??` should be used when possible. |
| 84 | + - Assignment operators (eg `+=`, `.=`) should be used when possible. |
| 85 | + - Unused variables should not be passed to closures via `use`. |
| 86 | + - The code may not contain unreachable code. |
| 87 | + - The backtick operator may not be used for execution of shell commands. |
| 88 | + - Class and Interface names should be unique in a project and must have a |
| 89 | + unique fully qualified name. |
| 90 | + - Methods that only call the parent method should not be defined. |
| 91 | + - Files that contain PHP code should only have PHP code and should not have |
| 92 | + any _"inline HTML"_. |
| 93 | + - There must be exactly one space after a type cast. |
| 94 | + - Constructors should be named `__construct`, not after the class. |
| 95 | + - The opening PHP tag should be the first item in the file. |
| 96 | + - Strings should not be concatenated together unless used in multiline for |
| 97 | + readability. |
| 98 | + - Loose `==` and `!=` comparison operators should not be used. Use `===` |
| 99 | + and `!==` instead. |
| 100 | + - Language constructs must be used without parentheses where possible. |
| 101 | + - Short list syntax `[...]` should be used instead of `list(...)`. |
| 102 | + - Short form of type keywords must be used. i.e. `bool` instead of |
| 103 | + `boolean`, `int` instead of `integer`, etc. The `binary` and `unset` cast |
| 104 | + operators are not allowed. |
| 105 | + - Parentheses should not be used if they can be omitted. |
| 106 | + - Semicolons `;` should not be used if they can be omitted. |
| 107 | + - Variables should be returned directly instead of assigned to a variable |
| 108 | + which is not used. |
| 109 | + - The `self` keyword should be used instead of the current class name, and |
| 110 | + should not have spaces around `::`. |
| 111 | + - Static methods should not use `$this`. |
| 112 | + - Double quote strings may only be used if they contain variables. |
| 113 | + - Strings should not be enclosed in parentheses when being echoed. |
| 114 | + - Type casts should not have whitespace inside the parentheses. |
| 115 | + - The opening brace for functions should be on a new line with no blank |
| 116 | + lines surrounding it. |
| 117 | + - The PHP constructs `echo`, `print`, `return`, `include`, `include_once`, |
| 118 | + `require`, `require_once`, and `new`, should have one space after them. |
| 119 | + - The object operator `->` should not have any spaces around it. |
| 120 | + - Semicolons should not have spaces before them. |
| 121 | + - The code should not contain superfluous whitespaces. e.g. multiple empty |
| 122 | + lines, trailing spaces, etc. |
| 123 | + |
| 124 | +### Changed |
| 125 | + |
| 126 | +- Nothing. |
| 127 | + |
| 128 | +### Deprecated |
| 129 | + |
| 130 | +- Nothing. |
| 131 | + |
| 132 | +### Removed |
| 133 | + |
| 134 | +- Nothing. |
| 135 | + |
| 136 | +### Fixed |
| 137 | + |
| 138 | +- Nothing. |
| 139 | + |
5 | 140 | ## 1.0.0 - 2016-11-09
|
6 | 141 |
|
7 | 142 | Initial public release. Incorporates rules for:
|
|
0 commit comments