phpcpd
finds duplicate code in PHP projects
TLDR
Find duplicate code
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.
CAVEATS
Similar but intentionally different code may be flagged. Very large codebases may be slow. Maintained as archived project.
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.
