@@ -46,30 +46,60 @@ The coding standard targets **PHP 7.4+** (`php_version` is set to `70400` in `ph
4646- ** Line endings** : Unix (` \n ` )
4747- ** Encoding** : UTF-8
4848- ** ` declare(strict_types=1) ` ** : Required on the first line of every file
49+ - ** Short syntax** : ` [] ` required instead of ` array() ` and ` list() `
50+ - ** Short type casts** : ` (int) ` not ` (integer) ` , ` (bool) ` not ` (boolean) `
51+ - ** One statement per line**
52+ - ** Space after type casts**
53+ - ** No inline control structures** (braces always required)
54+ - ** ` new ` with parentheses** required
55+ - ** Trailing comma** required in multiline arrays
56+ - ** One blank line** between class members and between methods
57+ - ** Class constant visibility** required
58+ - ** Empty lines** around class braces
59+ - ** Trait use** declaration formatting and spacing enforced
60+ - ** No useless parentheses or semicolons**
4961
5062### Naming and Namespaces
5163- Namespace ` PHPStan ` is mapped to ` src/ ` and ` tests/ ` directories (type name must match file name)
5264- ` use ` statements must be alphabetically sorted (case-insensitive, PSR-12 compatible)
5365- No group ` use ` declarations
5466- No unused ` use ` statements
67+ - No useless ` use ` aliases
5568- Global functions and constants must be explicitly imported (no fallback)
5669- No superfluous ` Abstract ` prefix on abstract classes or ` Interface ` suffix on interfaces
70+ - camelCase required for method names and variable names
71+ - Constants must be ` UPPER_CASE `
72+ - ` ::class ` syntax preferred over class name strings
5773
5874### Type Hints
5975- Parameter, property, and return type hints are enforced
6076- Useless PHPDoc annotations (that just duplicate native type hints) are flagged
6177- ` null ` type hint must appear last in union types
78+ - Short type hints required (` int ` not ` integer ` , ` bool ` not ` boolean ` )
79+ - Nullable type hint required for parameters with ` null ` default value
6280
6381### Code Quality
6482- Early exit pattern is encouraged
6583- Static closures required where possible
6684- Strict comparison operators required (` === ` /` !== ` , not ` == ` /` != ` )
85+ - Logical operators ` && ` /` || ` required (not ` and ` /` or ` )
6786- No Yoda comparisons
6887- No ` empty() ` usage
88+ - No assignments in conditions
6989- Combined assignment operators required where applicable
7090- Null coalesce operator (` ?? ` ) and null coalesce assignment (` ??= ` ) required where applicable
7191- Unused variables are flagged
92+ - Useless variables are flagged
93+ - Unused inherited variables passed to closures are flagged
7294- Variables in double-quoted strings are disallowed (use ` sprintf() ` instead)
95+ - No unnecessary string concatenation
96+ - Must catch ` \Throwable ` , not ` \Exception `
97+ - Dead catch blocks are flagged
98+ - No ` global ` keyword
99+ - No inner/nested function declarations
100+ - No deprecated PHP functions
101+ - No empty comments
102+ - Useless ` @inheritDoc ` comments are flagged
73103
74104### Excluded Patterns
75105- ` tests/*/data ` and ` tests/*/data-attributes ` directories are excluded from checks (these contain test fixture files in the extension repositories)
0 commit comments