shipmonk/phpstan-rules
40 super-strict PHPStan rules from ShipMonk to close gaps even in extra-strict setups. Installs as an extension, configurable per rule (enable/disable, tweak defaults), with options like safer comparisons, enum generics checks, and more.
forbidVariableTypeOverwriting: fix false positive with fluent $this returns (#350)forbidUnusedException & forbidUnusedMatchResult support remaining edge cases like string concat (#353)forbidUselessNullableReturn: fix false positive with property hooks (https://github.com/shipmonk-rnd/phpstan-rules/pull/355)forbidCheckedExceptionInYieldingMethod: support functions and (immediately-invoked) closures (#345)forbidCheckedExceptionInCallable: fix reported file for traits (#342)forbidCast: avoid failure on (void) cast (#336, @dragosprotung)enforceReadonlyPublicProperty: skip untyped props + add excludePropertyWithDefaultValue option (#334, @devfrey)enforceReadonlyPublicProperty: skip static properties (#333, @devfrey)
enforceReadonlyPublicProperty support asymmetric visibility (#331, @JanTvrdik)forbidArithmeticOperationOnNonNumber add support for BcMath\Number (#321, @JokubasR)enforceNativeReturnTypehint fix false positive for unions with template type (#325, @mspirkov)forbidPhpDocNullabilityMismatchWithNativeTypehint: ignore void methods (#328, @mspirkov)phpstan/phpstan now requires ^2.1.32 (#331)forbidUselessNullableReturn: no error for overridable methods (#314 by @vrana)forbidUnusedClosureParameters: report unused trailing params for closures and array functions (#313)enforceNativeReturnTypehint: fix property hook false positive (#309)forbidUnusedMatchResult: fix false positive for usage in arrow function (#305, @maryo)enforceReadonlyPublicProperty: fix false positive with hooked properties (#303)forbidUnusedException: fix ->getException()::class false positive (#299)forbidCast: fix custom blacklist configuration (#297, @forrest79)phpstan/phpstan requires ^2.1.8 (#296)new class extends DeniedParent {} $this->deniedMethod(...)array_map([$this, 'deniedMethod'], $a)array_map('denied_function', $a)phpstan/phpstan now requires 2.0.0 (#274)phpstan/phpstan now requires 1.12.5 (was 1.11.0) (#272)parameters:
shipmonkRules:
enableAllRules: false
allowComparingOnlyComparableTypes:
enabled: true
int|string in array keys (deny null, bool, float etc) (#254)immediatelyCalledCallables (we now respect native [@param-immediately-invoked-callable](https://github.com/param-immediately-invoked-callable), see docs) (#240)reportRegardlessOfReturnType is now true by defaultphpstan/phpstan now requires at least 1.11.0 (was 1.10.51)
1.11.0 comes with error identifiers (which we support since 2.10.0)Parent|Child even in multi-catch and [@throws](https://github.com/throws) (#231, #232)call_user_func & forward_static_call is immediatelly called (#212)nikic/php-parser requirement (#222)
phpstan/phpstan now requires at least 1.10.51 (was 1.10.30) (#206)array_unique($enums, SORT_REGULAR) (#196)natcasesort (#197)Child|Parent within unions or intersections; there is no mixed|false, just mixed (#185)usort($items, fn ($a, $b) => [$a->updatedAt, $a->id] <=> [$b->updatedAt, $b->id])$a + $b over non numbers (#180)$i++, $i--, ++$i, --$i with any non-integer (#179)+= etc (#171)How can I help you explore Laravel packages today?