phpstan-strict-rules
phpstan-strict-rules copied to clipboard
Extra strict and opinionated rules for PHPStan
# Feature request I think this is okay. ```php $var = 'apple'; $var = 'nice ' . $var; ``` But many developers tend to stuff other type into the same...
```php private static function printExceptionMessage(\Throwable $e) : string{ $errstr = preg_replace('/\s+/', ' ', trim($e->getMessage())); $errno = $e->getCode(); try{ $errno = ErrorTypeToStringMap::get($errno); }catch(\InvalidArgumentException $e){ //pass } $errfile = Filesystem::cleanPath($e->getFile()); $errline =...
Hi, the following code doesn't report any warning, but the `continue` statement is useless: ```php $foo = [1, 2, 3]; $bar = [$foo]; foreach ($bar as $var) { foreach ($var...
In [doctrine/dbal](https://github.com/doctrine/dbal), the Schema and Driver APIs use `array` parameters heavily (e.g. as connection parameters and column definitions). While overall the value type is mixed, each array element usually has...
Const overrides violate const invariants and are not LSP-compliant (types can be changed randomly). There may be dragons when constants are used with `static::` (sniff request to forbid that: https://github.com/slevomat/coding-standard/issues/473)...
Hi, I would like to enable for Closures the two rules already present for normal functions, `MissingFunctionParameterTypehintRule` and `MissingFunctionReturnTypehintRule`. I found that master branch has this commit https://github.com/phpstan/phpstan-strict-rules/commit/491540d3bfa11e218cdba868c4128891ba63b72f which already...
Originally reported as https://github.com/slevomat/coding-standard/issues/563 but impossible to implement there. The idea is to ensure that `final` classes don't contain any **new** `protected` members. Such members can be made `private` because...
The check `checkAlwaysTrueCheckTypeFunctionCall` incorrectly assumes that the result of adding two integers is always an integer: ```php function addExact(int $augend, int $addend) : int { $result = $augend + $addend;...
Similar to arithmetic operators (`+`/`-`/`*`/`/`/`**`/`%`), loose comparison operators **should only** be used for numeric values. This is true for `==`, `!=`, ``, `=` and ``. Using any of these operators...
Related: https://github.com/phpstan/phpstan/issues/791 A weak comparison error should be thrown for such case: ```php