Releases: shipmonk-rnd/phpstan-rules
Releases 路 shipmonk-rnd/phpstan-rules
2.4.1
2.4.0
New features
- enforceEnumMatchRule: new rule enforcing usage of
match ($enum)
instead of exhaustive elseifs for enums (#94)- it tries to improve "too smart" enum analysis of PHPStan 1.10+, see reasoning
- forbidAssignmentNotMatchingVarDoc: ability to allow narrowing by config
allowNarrowing: true
(#92)- see differences with new native PHPStan check in readme
- forbidUselessNullableReturn: support also functions and closures (#97, #99)
- enforceListReturn: support also functions (#96)
Fixes
- forbidUnusedException: fix false positive within match arm (#90)
Improvements
Dependencies
phpstan/phpstan
now requires at least 1.10.0 (was 1.9.1, see #84)
2.3.1
2.3.0
New features
- enforceListReturn: prefer
@return list<T>
over@return array<T>
where possible (#76) - forbidIdenticalClassComparison: deny
===
,!==
for configured objects (useful forDateTimeInterface
,Brick/Money
and similar)
Fixes
- forbidCustomFunctions: proper config validation (#83)
- forbidUnusedException: fix false positive within ternary or yield (#79)
- forbidUnusedMatch: fix false positive within ternary (#79)
- uselessPrivatePropertyNullabilityRule: fix false positive with non-typehinted properties (#78)
- uselessNullableReturn: fix false positive with
return;
(#82)
Dependencies:
phpstan/phpstan
now requires at least 1.9.1 (was 1.8.7, see #76)
2.2.0
New features
- installable by extension-installer, see official docs how to use it (#72)
2.1.1
2.1.0
New features:
- forbidCast: denies casting you configure - by default only
(object)
,(array)
and(unset)
- enforceNativeReturnTypehint: enforces usage of native return typehints if supported by your PHP version
- forbidPhpDocNullabilityMismatchWithNativeTypehint: denies invalid phpdocs without null when native type contains null
- forbidNullInInterpolatedString: disallows using nullable expressions within double-quoted strings like
"Hi $name!"
Fixes:
- forbidUnusedMatchResult: Do not report if all arms contain assignment.
Dependencies:
2.0.1
2.0.0
Major changes 馃帀
- Much easier setup. Just include
vendor/shipmonk/phpstan-rules/rules.neon
in your codebase; no need to register all rules, visitors and tags as before (#44)- Also, you can easily enable/disable rules one by one like this:
includes:
- vendor/shipmonk/phpstan-rules/rules.neon
parameters:
shipmonkRules:
allowNamedArgumentOnlyInAttributes:
enabled: false
New features
- New rule
ForbidNullInAssignOperationsRule
: checking no null is involved in+=, *=
etc - Improved
ForbidAssignmentNotMatchingVarDocRule
: added option to allow type narrowing for individual var docs by/** @var Type allow-narrowing */
, thx @MartinMystikJonas (#45)
Improvements
ForbidFetchOnMixedRule
andForbidMethodCallOnMixedRule
does not make sense on level9, so it gets autodisabled in that case (#38)
Error message changes
ForbidAssignmentNotMatchingVarDocRule
now reports type narrowing with different message (#45)
1.2.0
New features
- New rule
EnforceReadonlyPublicPropertyRule
for protecting all your public properties by requiring readonly modifier - New rule
ForbidAssignmentNotMatchingVarDocRule
that verifies if the assignment to the variable with inline phpdoc matches the type - New rule
ForbidUnusedMatchResultRule
detecting forgotten usage of match result - New rule
ForbidNullInBinaryOperationsRule
to ensure no null value is involved in binary operations - New rule
ForbidVariableTypeOverwritingRule
denying type change when overwriting variables