Releases: shipmonk-rnd/dead-code-detector
Releases · shipmonk-rnd/dead-code-detector
0.11.0
New features
- Support unknown member names like
$foo->$unknown()
(#189)- Such call marks all methods of
$foo
as used (including possible descendants, ancestors, traits, ...)
- Such call marks all methods of
- Reflection provider:
- New Twig provider:
- Support
#[AsTwigFilter]
,#[AsTwigFunction]
,#[AsTwigTest]
andnew TwigFilter(..., callback)
counterparts (#194, @zacharylund)
- Support
Fixes:
- Fix origin file reference for traits (#190)
- Report dead method line at its name (#192)
- Fix mixed calls diagnostics when custom excluder is used (#196)
Breaking changes:
- Inline ignores of method with attribute need to move (#192):
- #[Deprecated] // @phpstan-ignore shipmonk.deadMethod
- public function someMethod(): void
+ #[Deprecated]
+ public function someMethod(): void // @phpstan-ignore shipmonk.deadMethod
0.10.2
0.10.1
Improvements
- Debug: Changing references not to invalidate result cache (#169)
- Autoremove: warn about kept excluded usages (#175)
• Removed method UserFacade::deadMethod
! Excluded usage at tests/User/UserFacadeTest.php:241 left intact
- Improve descendant detection for const fetches (#176)
Dependencies
phpstan/phpstan
now requires^2.1.9
(was^2.1.7
) (#169)
0.10.0
New features:
parameters:
shipmonkDeadCode:
debug:
usagesOf:
- App\User\Entity\Address::__construct
with -vvv
outputs e.g.:
App\User\Entity\Address::__construct
|
| Marked as alive by:
| entry virtual usage from ShipMonk\PHPStan\DeadCode\Provider\SymfonyUsageProvider (Route method via #[Route] attribute)
| calls App\User\RegisterUserController::__invoke:36
| calls App\User\UserFacade::registerUser:142
| calls App\User\Entity\Address::__construct
|
| Found 2 usages:
| • src/User/UserFacade.php:142
| • tests/User/Entity/AddressTest.php:64 - excluded by tests excluder
- Improved possible descendant detection (#151)
- e.g.
new Foo->method()
does not markmethod
as used onFoo
children anymore
- e.g.
Improvements:
- Skip private constructors only when those have zero params (#159)
- Reduce result cache size (#168)
- Support Symfony's
defaultIndexMethod
onAutowireLocator
/AutowireIterator
attribute (#161, @ruudk)
Dependencies
- Requires
phpstan/phpstan ^2.1.7
(was^2.0.0
) (#151)
Breaking changes
ClassMemberUsage
now requiresUsageOrigin
, not optionallyClassMethodRef
(#165)UsageOriginDetector
was removed (#165)- use either
UsageOrigin::createRegular
orUsageOrigin::createVirtual
- use either
- Virtual usages emitted by
ReflectionBasedMemberUsageProvider
now require note (#171)true
=>VirtualUsageData::withNote('why considered used')
false
=>null
- parameter
trackMixedAccess
was replaced with excluder (#167)
parameters:
shipmonkDeadCode:
- trackMixedAccess: false
+ usageExcluders:
+ usageOverMixed:
+ enabled: true
0.9.2
0.9.1
0.9.0
0.8.1
0.8.0
New features
- Symfony:
Fixes
0.7.0
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
- Just implement
- Detect reflection usages (#120)
- e.g.
$reflectionClass->getMethod('foo')
marksfoo
method as used
- e.g.
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`