Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sebastianbergmann/phpdcd
Dead Code Detector (DCD) for PHP code.
https://github.com/sebastianbergmann/phpdcd
Last synced: about 2 months ago
JSON representation
Dead Code Detector (DCD) for PHP code.
- Host: GitHub
- URL: https://github.com/sebastianbergmann/phpdcd
- Owner: sebastianbergmann
- License: other
- Archived: true
- Created: 2009-11-29T19:41:13.000Z (almost 15 years ago)
- Default Branch: master
- Last Pushed: 2015-10-12T14:26:34.000Z (about 9 years ago)
- Last Synced: 2024-09-20T20:12:04.001Z (about 2 months ago)
- Language: PHP
- Homepage:
- Size: 592 KB
- Stars: 412
- Watchers: 25
- Forks: 47
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
**This project is no longer maintained and its repository is only kept for archival purposes.**
[![Latest Stable Version](https://poser.pugx.org/sebastian/phpdcd/v/stable.png)](https://packagist.org/packages/sebastian/phpdcd)
[![Build Status](https://travis-ci.org/sebastianbergmann/phpdcd.png?branch=master)](https://travis-ci.org/sebastianbergmann/phpdcd)# PHP Dead Code Detector (PHPDCD)
**phpdcd** 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.
## Limitations
As PHP is a very dynamic programming language, the static analysis performed by **phpdcd** does not recognize function or method calls that are performed using one of the following language features:
* Reflection API
* `call_user_func()` and `call_user_func_array()`
* Usage of the `new` operator with variable class names
* Variable class names for static method calls such as `$class::method()`
* Variable function or method names such as `$function()` or `$object->$method()`
* Automatic calls to methods such as `__toString()` or `Iterator::*()`Also note that infering the type of a variable is limited to type-hinted arguments (`function foo(Bar $bar) {}`) and direct object creation (`$object = new Clazz`)
## Installation
### PHP Archive (PHAR)
The easiest way to obtain PHPDCD is to download a [PHP Archive (PHAR)](http://php.net/phar) that has all required dependencies of PHPDCD bundled in a single file:
wget https://phar.phpunit.de/phpdcd.phar
chmod +x phpdcd.phar
mv phpdcd.phar /usr/local/bin/phpdcdYou can also immediately use the PHAR after you have downloaded it, of course:
wget https://phar.phpunit.de/phpdcd.phar
php phpdcd.phar### Composer
Simply add a dependency on `sebastian/phpdcd` to your project's `composer.json` file if you use [Composer](http://getcomposer.org/) to manage the dependencies of your project. Here is a minimal example of a `composer.json` file that just defines a development-time dependency on PHPDCD:
{
"require-dev": {
"sebastian/phpdcd": "*"
}
}For a system-wide installation via Composer, you can run:
composer global require 'sebastian/phpdcd=*'
Make sure you have `~/.composer/vendor/bin/` in your path.