LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

phpcpd

finds duplicate code in PHP projects

TLDR

Find duplicate code
$ phpcpd [src/]
copy
Set minimum lines
$ phpcpd --min-lines [10] [src/]
copy
Set minimum tokens
$ phpcpd --min-tokens [50] [src/]
copy
Exclude directory
$ phpcpd --exclude [vendor] [src/]
copy
Output to file
$ phpcpd --log-pmd [report.xml] [src/]
copy
Check multiple directories
$ phpcpd [src/] [lib/]
copy
Fuzzy matching
$ phpcpd --fuzzy [src/]
copy

SYNOPSIS

phpcpd [--min-lines n] [--min-tokens n] [--exclude dir] [options] directories

DESCRIPTION

phpcpd (PHP Copy/Paste Detector) finds duplicate code in PHP projects. It identifies code that should be refactored.Token-based analysis finds similar code blocks. Renaming variables doesn't hide duplications.Thresholds control sensitivity. Higher minimums find larger, more significant duplications.Fuzzy matching finds near-duplicates. Code with minor differences is also detected.Reports show file locations and duplicated content. Integration with CI tools enables automated checks.

PARAMETERS

--min-lines N

Minimum lines for duplication.
--min-tokens N
Minimum tokens for duplication.
--exclude DIR
Exclude directory.
--log-pmd FILE
PMD-CPD XML format.
--fuzzy
Fuzzy matching.
--suffix EXT
File suffix to check.
-v, --verbose
Verbose output.
--help
Show help.

INSTALL

sudo dnf install phpcpd
copy

CAVEATS

Similar but intentionally different code may be flagged. Very large codebases may be slow. Note: phpcpd has been archived by its author and is no longer actively maintained. Consider alternative static analysis tools for new projects.

HISTORY

phpcpd was created by Sebastian Bergmann as part of the PHP QA toolset. It helps maintain code quality by detecting copy-pasted code blocks.

SEE ALSO

phpcs(1), phpcbf(1), phpmd(1), phpstan(1)

Braincup
Open source brain training for math, memory and focus
Braincup mini-games
41 mini-games · Apache-2.0
No ads · No tracking
Play in browser
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid
276 stars
From the maker of Linux Command Library
Copied to clipboard
Braincup
Open source brain training for math, memory and focus. 41 mini-games, from mental arithmetic to Sudoku, N-Back and Solo Chess.
Apache-2.0 licensed · No ads · No tracking · No account
From the maker of Linux Command Library
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid