Skip to content

Releases: shipmonk-rnd/dead-code-detector

0.7.0

23 Dec 12:41
c9602b5
Compare
Choose a tag to compare

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`

0.6.0

11 Nov 15:05
e3c3729
Compare
Choose a tag to compare

Dependencies

  • requires phpstan/phpstan 2.0

0.5.1

06 Nov 13:59
bcfa0a0
Compare
Choose a tag to compare

Fixes:

  • Disable mixed calls diagnosis for trackMixedCalls: false (#109)

0.5.0

04 Nov 14:47
a3ddfe2
Compare
Choose a tag to compare

New features

  • Ability to automatically remove dead code (#103)
    • via vendor/bin/phpstan analyse --error-format removeDeadCode
  • Support calls over mixed (#105)
    • e.g. $unknownClass->method()

Dependencies

  • requires phpstan/phpstan 1.11.7 (was 1.11.0) (#107)

0.4.0

24 Oct 10:58
fc01208
Compare
Choose a tag to compare

Major changes:

  • Dead cycles detection (#99)
    • Also, all transitively dead methods are reported within the first run:
 ------ ------------------------------------------------------------------------
  Line   src/App/Facade/UserFacade.php
 ------ ------------------------------------------------------------------------
  26     Unused App\Facade\UserFacade::updateUserAddress
         🪪  shipmonk.deadMethod
         💡 Thus App\Entity\User::updateAddress is transitively also unused
         💡 Thus App\Entity\Address::setPostalCode is transitively also unused
         💡 Thus App\Entity\Address::setCountry is transitively also unused
         💡 Thus App\Entity\Address::setStreet is transitively also unused

New features:

  • phpunit: support data providers in children classes (#97)
  • symfony: support #[AsCommand], #[AsController], Bundle children (#89)
  • doctrine: support EntityRepository constructor (#90)

Fixes:

  • vendor: properly detect vendor-originating methods (#101)

0.3.0

13 Sep 14:50
f5b9054
Compare
Choose a tag to compare

Major changes:

  • Performance boost ~20% (#74, #79)
  • EntrypointProvider interface changed (#74)
    • Just extend SimpleMethodEntrypointProvider for easy transition

New features

  • Support dead __clone methods (#80)

Fixes

  • Fix many trait related edgecases (#70, #75, #76, #78)
  • Fix missing nette provider in config (#81)

0.2.1

05 Sep 12:47
780dc3f
Compare
Choose a tag to compare

Fixes

  • Fix invalid file reported for non-overridden dead trait methods (#67)

0.2.0

05 Sep 08:31
ca10541
Compare
Choose a tag to compare

New features:

  • Autodetect library magic calls (#31, #38, #40, #51):
    • symfony: DIC constructors, events, routes, ...
    • nette: render, action, handle, inject, smart object, ...
    • phpunit: test methods
    • doctrine: events
    • phpstan: DIC constructors
    • Also, any overridden method that originates in vendor is no longer reported
  • Dead constructors detection! (#39)
  • Support class-string calls like $classString::method() (#45)
  • Support array callbacks like [$this, 'method'] (#42)
  • Support nullsafe call chain like $object?->first()::second() (#46)
  • Support dynamic method calls like $object->$method() (#52)

Improvements:

  • Improve single process post-analysis runtime by 50% (#47)
  • Proper hierarchy call detection (#48, #54)

Dependencies:

  • requires phpstan/phpstan 1.11.0 (was 1.10.30)

0.1.2

15 Jul 10:19
3fc29fd
Compare
Choose a tag to compare

Fixes:

  • Significantly reduce resultCache size (#30)
    • ~50% reduction

0.1.1

05 Jul 07:46
6f0b3d1
Compare
Choose a tag to compare

Fixes:

  • Fix exception in case of non-existent class (#28)