sebastian/phpcpd
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
phpunit/php-file-iterator | 3.0.6 | 8.05 kB | BSD-3-Clause | prod | |
phpunit/php-timer | 5.0.3 | 9.68 kB | BSD-3-Clause | prod | |
sebastian/cli-parser | 1.0.2 | - | BSD-3-Clause | prod | |
sebastian/version | 3.0.2 | 4.76 kB | BSD-3-Clause | prod |
Sebastian/phpcpd, also known as PHP Copy/Paste Detector (PHPCPD), is an SEO-friendly tool that identifies duplicate and redundant PHP code in your software projects. It is a Copy/Paste Detector (CPD) specifically tailored for PHP, efficiently helping to maintain code integrity by detecting and highlighting copied and pasted blocks of codes in PHP projects.
Using Sebastian Bergmann's PHPCPD is straightforward. The tool is distributed as a PHP Archive (PHAR). You can use the wget command in your terminal to download the PHPCPD tool as follows:
$ wget https://phar.phpunit.de/phpcpd.phar
To verify that the tool is installed correctly, you can check its version using this command:
$ php phpcpd.phar --version
Sebastian's PHP Copy/Paste Detector is recommended to be managed with Phive, which further streamlines dependency management for your project:
$ phive install phpcpd
$ ./tools/phpcpd --version
The copied code within your project can be detected by running the following command:
$ php phpcpd.phar --fuzzy your_directory_name
This command conducts a fuzzy search within the specified directory and will return results indicating the number of clones found, the number of duplicated lines, and the files containing the duplicated code.
On running these commands, it is important to replace "your_directory_name" with the name of the directory you want to be evaluated for copied code.
The official documentation for PHPCPD is not explicitly mentioned in the README, however given it is a project started by Sebastian Bergmann, you could likely find pertinent information and documentation on his GitHub page (https://github.com/sebastianbergmann) or on the official PHPUnit documentation website (https://phpunit.de/), as PHPUnit and PHPCPD share the same author.