phpcpd-next
github.com
- Free plan
- Linux
- API
- Self-hosted
What phpcpd-next is
phpcpd-next is a free, MIT-licensed token-based detector for copied and similar PHP code in repositories. It targets PHP 8.4 and later and is a successor to Sebastian Bergmann’s phpcpd. Its standard scan combines Rabin-Karp exact matching with TokenBag detection for reordered code; an optional unified engine looks for exact, renamed, gapped, and reordered clones. An optional orphan scan identifies unreferenced classes, interfaces, traits, enums, and functions. Results can be produced in the console, PMD-CPD XML, JSON, or SARIF 2.1.0. For CI workflows, it offers meaningful exit codes, result caching, and a per-file incremental index; findings of clones produce exit status 1. Documented integrations include PHPUnit, a headless in-process API, framework presets, and SARIF upload to GitHub Code Scanning. Installation options include a Composer development dependency, a global Composer package, or a source installation. It requires PHP 8.4 or later, ext-dom, and ext-mbstring, with no Composer runtime dependencies. The project cautions that advanced engines are research-grade and can have higher false-positive rates than the default detection set.
Who it suits
It suits PHP teams scanning repositories for copied or reordered code, especially those integrating scans into CI. Users considering the optional advanced engines should account for their stated higher false-positive rates.
Good to know, and what to watch
- Offers console, PMD-CPD XML, JSON, and SARIF reports.
- Provides caching and a per-file incremental index.
- Clone findings return exit status 1.
- Has zero Composer runtime dependencies.
- Licensed under MIT.
- Requires PHP 8.4 or later.
- Requires ext-dom and ext-mbstring.
- Advanced engines may produce more false positives.
- Clone percentages do not replace review of design repetition.
Plans
Every plan and priceOpen source
Open source
The verdict
phpcpd-next offers multiple clone-detection modes and reporting options for repository and CI workflows. Its PHP requirements and the research-grade status of advanced engines are important considerations.
What the maker publishes
- CI use
- Meaningful exit codes, result caching, and a per-file incremental index support CI use; clone findings produce exit status 1. source
- Detection
- Its default run combines Rabin-Karp exact matching with TokenBag detection of reordered code; an opt-in unified engine detects exact, renamed, gapped, and reordered clones. source
- Founded
- 2026 source
- Integrations
- The project documents PHPUnit integration, an in-process headless API, framework presets, and SARIF upload to GitHub Code Scanning. source
- License
- The project states that phpcpd-next is licensed under MIT. source
- Limit: design repetition
- The README says the duplicated-line percentage measures copied tokens and cannot substitute for reviewing structural repetition in code design. source
- Limit: research engines
- The README describes advanced engines as opt-in and research-grade, with higher false-positive rates on real-world code than the default set. source
- Orphan detection
- The optional --orphans mode finds unreferenced classes, interfaces, traits, enums, and functions. source
- Purpose
- phpcpd-next is a token-based copy/paste detector for PHP 8.4+ and a successor to Sebastian Bergmann’s phpcpd. source
- Reports
- It provides console, PMD-CPD XML, JSON, and SARIF 2.1.0 output formats. source
- Requirements
- It requires PHP 8.4+, ext-dom, and ext-mbstring, and lists zero Composer runtime dependencies. source
- Setup
- The documented installation is as a Composer development dependency, as a global Composer package, or from source. source
- Support
- The opened project page describes contribution guidance and a Contributor License Agreement; it does not state a paid support plan. source
Checked against the maker's pages on 5 Oct 2026.