PHP Dead Code Detector

Author(s)
Sebastian Bergmann
Website
https://github.com/sebastianbergmann/phpdcd
License
BSD 3-clause "New" or "Revised" License
GitHub
sebastianbergmann/phpdcd
Packagist
sebastian/phpdcd
DockerHub
phpqa/phpdcd

0 0 0

PHP Dead Code Detector is a Dead Code Detector (DCD) for PHP code.

It scans a PHP project for all declared functions and methods and reports those as being "dead code" that are not called at least once.

This project is no longer maintained and its repository is only kept for archival purposes.

Installation

Install from a Composer package as a dev dependency (with Composer)

Make sure you have Composer installed.

Require it as a dev dependency:
composer require --dev sebastian/phpdcd
Run it:
php vendor/bin/phpdcd

Install from a Composer package as a global CLI utility (with Composer)

Make sure you have Composer installed.

Require it as a global CLI utility:
composer global require sebastian/phpdcd
Run it:
phpdcd
Make sure your global vendor binaries directory is in your $PATH environment variable. Check the Composer documentation for more information.

Install from a PHP Archive (with curl or wget)

The PHPUnit documentation has a clear manual on how to install PHARs on Windows.

If you have the Suhosin extension enabled, make sure to allow the execution of PHARs in your php.ini:
suhosin.executor.include.whitelist = phar

Locally
Download it:
wget -O phpdcd.phar https://phar.phpunit.de/phpdcd.phar
or
curl -sSL https://phar.phpunit.de/phpdcd.phar -o phpdcd.phar
Use it:
php phpdcd.phar
Globally
Download it:
wget -O phpdcd.phar https://phar.phpunit.de/phpdcd.phar
or
curl -sSL https://phar.phpunit.de/phpdcd.phar -o phpdcd.phar
Install it as an executable:
chmod a+x phpdcd.phar
sudo mv phpdcd.phar /usr/local/bin/phpdcd
Use it:
phpdcd