New features:
- Full dead class constant detection support (#113)
- Transitive detection (e.g. constant fetched in dead method is dead)
- Usages over mixed (e.g.
$unknown::CONST
)
- Auto-removal (via
--error-format removeDeadCode
)
- Trait constants (available since
PHP 8.2
)
- constant function (e.g.
constant('PDO::ATTR_ERRMODE')
)
- customizable (e.g. you can extract
!php/const Foo::BAR
usages from your yamls)
- AST-based usage providers (#117)
- Just implement
MemberUsageProvider
- Allows to emit member usages based on e.g. methods calls
- Handy for command buses, event systems, serializers and more
- Detect reflection usages (#120)
- e.g.
$reflectionClass->getMethod('foo')
marks foo
method as used
Improvements:
- Symfony & Doctrine: improve usage provider extendability (#121)
- Symfony: precise detection of
EventSubscriberInterface::getSubscribedEvents
(#122)
- Doctrine: precise detection of
Doctrine\Common\EventSubscriber::getSubscribedEvents
(#127)
Breaking changes:
- Renames (to fit constant usages and AST-based providers):
# classes & methods
- `ShipMonk\PHPStan\DeadCode\Provider\MethodEntrypointProvider::getEntrypoints(): list<ReflectionMethod>`
+ `ShipMonk\PHPStan\DeadCode\Provider\MemberUsageProvider::getUsages(): list<ClassMemberUsage>`
- `ShipMonk\PHPStan\DeadCode\Provider\SimpleMethodEntrypointProvider::isEntrypointMethod(): bool`
+ `ShipMonk\PHPStan\DeadCode\Provider\ReflectionBasedMemberUsageProvider::shouldMarkMethodAsUsed(): bool`
# neon config params
- `parameters.shipmonkDeadCode.entrypoints`
+ `parameters.shipmonkDeadCode.usageProviders`
- `parameters.shipmonkDeadCode.trackCallsOnMixed`
+ `parameters.shipmonkDeadCode.trackMixedAccess`
# neon service tag
- `shipmonk.deadCode.entrypointProvider`
+ `shipmonk.deadCode.memberUsageProvider`