Download the PHP package shipmonk/dead-code-detector without Composer
On this page you can find all versions of the php package shipmonk/dead-code-detector. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download shipmonk/dead-code-detector
More information about shipmonk/dead-code-detector
Files in shipmonk/dead-code-detector
Download shipmonk/dead-code-detector
More information about shipmonk/dead-code-detector
Files in shipmonk/dead-code-detector
Vendor shipmonk
Package dead-code-detector
Short Description Dead code detector to find unused PHP code via PHPStan extension.
License MIT
Package dead-code-detector
Short Description Dead code detector to find unused PHP code via PHPStan extension.
License MIT
Please rate this library. Is it a good library?
Informations about the package dead-code-detector
Dead code detector for PHP
PHPStan rules to find unused code in your project with ease!
Installation:
Use official extension-installer or just load the rules:
Supported libraries
- Any overridden method that originates in
vendor
is not reported as dead - We also support many magic calls in following libraries:
Symfony:
- constructor calls for DIC services!
phpstan/phpstan-symfony
withcontainerXmlPath
must be used
#[AsEventListener]
attribute#[Required]
attribute#[Route]
attributesonKernelResponse
,onKernelRequest
, etc
Doctrine:
#[AsEntityListener]
attributeDoctrine\ORM\Events::*
eventsDoctrine\Common\EventSubscriber
methods- lifecycle event attributes
#[PreFlush]
,#[PostLoad]
, ...
PHPUnit:
- data provider methods
testXxx
methods- annotations like
@test
,@before
,@afterClass
etc - attributes like
#[Test]
,#[Before]
,#[AfterClass]
etc
PHPStan:
- constructor calls for DIC services (rules, extensions, ...)
Nette:
handleXxx
,renderXxx
,actionXxx
,injectXxx
,createComponentXxx
SmartObject
magic calls for@property
annotations
All those libraries are autoenabled when found within your composer dependencies. If you want to force enable/disable some of them, you can:
Customization:
- If your application does some magic calls unknown to this library, you can implement your own entrypoint provider.
- Just tag it with
shipmonk.deadCode.entrypointProvider
and implementShipMonk\PHPStan\DeadCode\Provider\EntrypointProvider
- You can simplify your implementation by extending
ShipMonk\PHPStan\DeadCode\Provider\MethodBasedEntrypointProvider
Comparison with tomasvotruba/unused-public
- You can see detailed comparison PR
- Basically, their analysis is less precise and less flexible. Mainly:
- It cannot detect dead constructors
- It does not properly detect calls within inheritance hierarchy
- It does not offer any custom adjustments of used methods
- It has almost no built-it library extensions
- It ignores trait methods
- Is lacks many minor features like class-string calls, dynamic method calls, array callbacks, nullsafe call chains etc
Limitations:
- Only method calls are detected so far
- Including constructors, static methods, trait methods, interface methods, first class callables, clone, etc.
- Any calls on mixed types are not detected, e.g.
$unknownClass->method()
- Anonymous classes are ignored (PHPStan limitation)
- Does not check most magic methods (
__get
,__set
etc) - Call-graph not implemented so far
- No transitive check is performed (dead method called only from dead method)
- No dead cycles are detected (e.g. dead method calling itself)
Contributing
- Check your code by
composer check
- Autofix coding-style by
composer fix:cs
- All functionality must be tested
Supported PHP versions
- PHP 7.4 - 8.3
All versions of dead-code-detector with dependencies
PHP Build Version
Package Version
The package shipmonk/dead-code-detector contains the following files
Loading the files please wait ....