NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
Packagist
Packagist, #916 most downloaded on Packagist
Dead code detector to find unused PHP code via PHPStan extension. Can automatically remove dead PHP code. Supports libraries like Symfony, Doctrine, PHPUnit etc. Detects dead cycles. Can detect dead code that is tested.
Latest stable
1.4.2
Last release 2 months ago
18 Sep 2026
Ships fairly regularly
a new release about every 2 weeks
Nearly every release is documented
notes for 50 of 50 stable releases
Nothing withdrawn
no release was ever pulled
3 years old
50 releases · first in 2023
Drag across the ruler to compare, or tap a release to open it.
Custom providers can implement ActivatableUsageProvider to be skipped entirely when disabled (#434, @staabm)
ActivatableUsageProvider to be skipped entirely when disabled (#434, @staabm)devPaths (#448, @edalzell)FromMethod template usage for AsLiveComponent (#444)Fix non-deterministic order of transitive tips (#426, @ondrejmirtes)
Your coding agent can read these notes before it upgrades. Set up the MCP server →
Via nested destructuring assignments
$ref = &$this->value;[[$this->nested]] = [['a']];foreach targets (#415)
foreach ($items as $this->currentItem)#[MapInput] DTOs (#421)#[Interact] on invokable commands without #[AsCommand] (#417)#[UniqueEntity] attributes (#416)RemoveClassMemberVisitor (#406)static keyword in collectors (#412)TestsUsageExcluder: match dev paths on directory boundary (#409)AutoconfigureTag doctrine.event_listener attributes (#420)Symfony: fix crash on #[Assert\Callback] with closure callback (PHP 8.5) #405
#[Assert\Callback] with closure callback (PHP 8.5) #405Composer: detect static methods referenced in composer scripts
#[MapRequestPayload] and #[MapQueryString] DTOs (#339)Detect class constants referenced in PhpDocs
afterSending/shouldSend, plus queueable hooks (viaConnections, viaQueues, withDelay, withMessageGroups, messageGroup, deduplicationId, withDeduplicators) on ShouldQueue notificationscontext()/render()/report() on any Throwable\Facades\App\SomeClass::someMethod() marks the underlying \App\SomeClass::someMethod() as usedtest* / #[TestRule] public methods registered under phpat.test tag in PHPStan DIC
test* / #[TestRule] public methods registered under phpat.test tag in PHPStan DICusagesOf in only-files analysis (#382)#[ParamProviders('...')] attribute (#379)Fix crash on array callable with unknown part, _since PHPStan 2.1.54_ (#373, @alfredbez)
Nette: support constructor calls of DIC services (#369, @spaze)
neon/neon to be installedparameters:
shipmonkDeadCode:
usageProviders:
nette:
containerNeonPaths:
- app/config/services.neon
#[AsTwigComponent] classes to templates (#366)FormRequest methods (#370, @JeftaAtSiip)Treat array_column() string keys as property reads
array_column() string keys as property reads (#362)Symfony: mark constructor of #[AsEventListener] host class as used
#[AsEventListener] host class as used (#356)Symfony: skip services not instantiated by the DIC
Laravel: Blade view data support
view(), View::make()/first(), response()->view(), ->with() as usedView::composer()/View::creator(), including 'Class@method' syntaxdata_class mapping (#334)
get*/set*/is*/has*/can*/add*/remove*), public properties, and __construct on data classes as useddata_class from OptionsResolver, AbstractController::createForm(), FormFactoryInterface::create() and related methods(array) cast, get_object_vars(), get_mangled_object_vars(), json_encode(), serialize()JsonSerializable, __serialize(), Serializable#[AutowireIterator]/#[AutowireLocator] via DIC XML (#336)
'app.handler') are now mapped to concrete classes, fixing false positives on defaultIndexMethod/defaultPriorityMethodshipmonkDeadCode.usageProviders.symfony.containerXmlPaths must be set up#[AsTwigComponent(template: new FromMethod(...))] (#341)#[MapInput] in console commands (#340)#[PostRemove] lifecycle callback detection (#337)ToolEvents to listener heuristic (#342)@dataProvider annotation recognition (#338)Detection of all dead members is implemented and stable!
Route::get(), post(), put(), patch(), delete(), any(), match(), resource(), apiResource()
[Controller::class, 'method']'Controller@method'Controller::classEvent::listen(), Event::subscribe()handle* methods whose first parameter has a class typeSchedule::job()Gate::define() (callable + invokable), Gate::policy()$this->authorize() calls resolve policy class via Laravel's namespace convention (Models\ → Policies\)__construct, handle on Illuminate\Console\Command subclasses__construct, handle, failed, middleware, retryUntil, uniqueId, tags, backoff, uniqueVia, displayName on ShouldQueue / Dispatchable classes__construct, register, boothandle, terminate, __construct (detected by first parameter type Illuminate\Http\Request)via, toMail, toArray, toDatabase, toBroadcast, toVonage, toSlackauthorize, rules, messages, attributes, prepareForValidation, passedValidation, failedValidation, failedAuthorizationbefore, viewAny, view, create, update, delete, restore, forceDelete (heuristic via \Policies\ namespace + Policy suffix)build, content, envelope, attachments, headersbroadcastWith, broadcastAs, broadcastWhenpaginationInformationrouteNotificationFor* methodsboot, booted, casts, newFactoryscope* methodsIlluminate\Database\Eloquent\Relations\*Illuminate\Database\Eloquent\Casts\Attributeget*Attribute() / set*Attribute()Model::observe() calls + #[ObservedBy] attribute (all observer event methods)definition, configurerunup, down#[Autoconfigure(constructor:, calls:)], #[AutowireCallable], #[TaggedIterator], #[TaggedLocator], #[Required] on properties, #[AsSchedule], #[AsCronTask], #[AsPeriodicTask], !php/enum references in config yamls (#317)containerXmlPaths configuration - no need for phpstan/phpstan-doctrine for DIC calls analysis (#325)#[AsTwigComponent]/#[AsLiveComponent] (constructor, mount()), #[LiveProp], #[LiveAction], #[LiveListener], lifecycle hooks (#329)new ReflectionMethod(Class, 'method') (#313)PHP ^8.1 (was ^7.4) (#296)phpstan/phpstan ^2.1.41, (was ^2.1.23) (#297)Fix false-positive for self-referencing property access in property hooks
Dead properties detection (#277, #281, #291)
$controller->render('my.twig', ['param' => $viewModel]),#[Template] controller methodsTwig\Environment::render() and similardefaultPriorityMethod (#286, @alcohol)#[Interact] attribute for commands (#288, @mjanser)test* methods, setUp/tearDown, @dataProvider (#299)ApiPhpDocUsageProvider: only count phpdocs within analysed files (#284)parameters:
shipmonkDeadCode:
detect:
deadEnumCases: false
deadProperties:
neverRead: false
neverWritten: false
Fix infinite run for huge unused subtrees while groupping errors
Support phpbench entrypoints (#262, @simPod)
stream_wrapper_register magic (#266)usageProviders.symfony.configDirusageExcluders.tests.devPathsphpstan/phpstan now requires ^2.1.23 (was ^2.1.12) (#254)Support #[AutoconfigureTag('doctrine.event_listener')]
#[AsDoctrineListener] #[AutoconfigureTag('doctrine.event_listener')] Fix disabling dead methods detection
Support #[AsTransitionListenerWorkflow] and other Event listener attributes (#248, by @S1ructure)
#[AsTransitionListenerWorkflow] and other Event listener attributes (#248, by @S1ructure)#[AsMessageHandler] attribute (#247, by @S1ructure)Property hooks partial support; fix crash & false positives
Symfony: support anonymous services in DIC
@api over enums and enum cases (#240)ReflectionClass<object>::getMethods() etc. (#241)Detect dead enum cases (#197); _off by default, enable by:_ `neon parameters: shipmonkDeadCode: detect: deadEnumCases: true `
parameters:
shipmonkDeadCode:
detect:
deadEnumCases: true
@final class is inherited (#233)ClassMemberRef is now generic, you may need to update phpdocs of thoseClassConstantRef constructor now requires TrinaryLogic $isEnumCase argumentphpstan/phpstan now requires ^2.1.12 (was ^2.1.9)Detect also overriden vendor constants
Fix false positive with interface parent
tests excluder not to exclude mixed usages in tests
usageProviders.symfony.configDir wiring (#216)PHPUnit: support #[DataProviderExternal]
#[DataProviderExternal] (#212)Support @api phpdoc for marking public API of libraries or tools
@api phpdoc for marking public API of libraries or tools (#200)
phpstan/phpstan-src itself :tada:Fix custom `devPaths` config for tests excluder
devPaths config for tests excluder (#202)composer.json for tests excluder (#203)Support unknown member names like $foo->$unknown()
$foo->$unknown() (#189)
$foo as used (including possible descendants, ancestors, traits, ...)ReflectionClass->getMethods() now mark alive also methods of descendants (#189)ReflectionClass<object> (#193)
$anyObjectReflection->getMethod('foo') marks all foo methods of all types as aliveusageOverMixed excluder#[AsTwigFilter], #[AsTwigFunction], #[AsTwigTest] and new TwigFilter(..., callback) counterparts (#194, @zacharylund)- #[Deprecated] // @phpstan-ignore shipmonk.deadMethod
- public function someMethod(): void
+ #[Deprecated]
+ public function someMethod(): void // @phpstan-ignore shipmonk.deadMethod
detect usages in #[Assert\Callback] (#180, @zacharylund)
#[Assert\Callback] (#180, @zacharylund)repositoryMethod in #[UniqueEntity] (#184)Debug: Changing references not to invalidate result cache
• Removed method UserFacade::deadMethod
! Excluded usage at tests/User/UserFacadeTest.php:241 left intact
phpstan/phpstan now requires ^2.1.9 (was ^2.1.7) (#169)Allow debugging of usages (#165, #172): ```neon parameters: shipmonkDeadCode: debug: usagesOf:
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
new Foo->method() does not mark method as used on Foo children anymoredefaultIndexMethod on AutowireLocator/AutowireIterator attribute (#161, @ruudk)phpstan/phpstan ^2.1.7 (was ^2.0.0) (#151)ClassMemberUsage now requires UsageOrigin, not optionally ClassMethodRef (#165)UsageOriginDetector was removed (#165)
UsageOrigin::createRegular or UsageOrigin::createVirtualReflectionBasedMemberUsageProvider now require note (#171)
true => VirtualUsageData::withNote('why considered used')false => nulltrackMixedAccess was replaced with excluder (#167)parameters:
shipmonkDeadCode:
- trackMixedAccess: false
+ usageExcluders:
+ usageOverMixed:
+ enabled: true
TestsUsageExcluder: fix path normalization for phar files
TestsUsageExcluder: normalize provided paths
Members used only in tests can be reported as dead
parameters:
shipmonkDeadCode:
usageExcluders:
tests:
enabled: true # off by default
MemberUsageExcluder interfaceSymfony: fix DIC filepath for phpstan-symfony 2.0.2
detect constants used in config yamls via !php const Foo\Bar::BAZ
!php const Foo\Bar::BAZ (#131)factory: [Acme\SerializerFactory, create] (#128)Full dead class constant detection support
$unknown::CONST)--error-format removeDeadCode)PHP 8.2)constant('PDO::ATTR_ERRMODE'))!php/const Foo::BAR usages from your yamls)MemberUsageProvider$reflectionClass->getMethod('foo') marks foo method as usedEventSubscriberInterface::getSubscribedEvents (#122)Doctrine\Common\EventSubscriber::getSubscribedEvents (#127)# 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`
## Dependencies - requires `phpstan/phpstan 2.0`
phpstan/phpstan 2.0Disable mixed calls diagnosis for trackMixedCalls: false
trackMixedCalls: false (#109)Ability to automatically remove dead code
vendor/bin/phpstan analyse --error-format removeDeadCode$unknownClass->method()phpstan/phpstan 1.11.7 (was 1.11.0) (#107)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
#[AsCommand], #[AsController], Bundle children (#89)Performance boost ~20% (#74, #79)
EntrypointProvider interface changed (#74)
SimpleMethodEntrypointProvider for easy transition__clone methods (#80)nette provider in config (#81)Fix invalid file reported for non-overridden dead trait methods
Autodetect library magic calls (#31, #38, #40, #51):
symfony: DIC constructors, events, routes, ...nette: render, action, handle, inject, smart object, ...phpunit: test methodsdoctrine: eventsphpstan: DIC constructorsvendor is no longer reported$classString::method() (#45)[$this, 'method'] (#42)$object?->first()::second() (#46)$object->$method() (#52)phpstan/phpstan 1.11.0 (was 1.10.30)Significantly reduce resultCache size
resultCache size (#30)
Fix exception in case of non-existent class
Open-sourced dead method detection
One column per month.