Skip to content

Commit 4a54c22

Browse files
author
DKravtsov
committed
phpcpd 9.1.0 release.
1 parent 7f105e9 commit 4a54c22

15 files changed

Lines changed: 87 additions & 97 deletions

File tree

‎.idea/inspectionProfiles/Project_Default.xml‎

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎composer.lock‎

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎docs/images/report_example_01.png‎

-53.9 KB
Loading

‎docs/report.md‎

Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,48 @@
1-
# PHP Copy/Paste Detector report
2-
This document describing how you can generate report.
1+
# HTML Report Generation
2+
This document describes how to generate visual, interactive HTML reports from `phpcpd`'s XML output. These reports make it significantly easier to navigate, analyze, and share code duplication metrics with your team.
33

4-
## Requirements for html report generation
5-
* [Xalan](https://xalan.apache.org) tool
6-
* created folder (f.e. `reports/phpcpd`) with write access where you want to save your report
4+
## Requirements
5+
To generate HTML reports, ensure you have the following:
6+
* The [Xalan](https://xalan.apache.org) XSLT processor installed locally or within your Docker container.
7+
* A dedicated output directory (e.g., `reports/phpcpd/`) with write permissions.
78

8-
Note: You can find some already-made examples inside our solutions on our [GitHub page](https://github.com/systemsdk)
9+
Note: You can find fully configured examples within the open-source projects hosted on our [GitHub page](https://github.com/systemsdk).
910

10-
## Steps for html report generation
11-
You need to run the next commands for html report generation:
11+
## Generation Steps
12+
Follow these steps to analyze your code and compile the HTML report:
1213

13-
1. Run PHP Copy/Paste Detector
14+
1. Run PHPCPD to generate an XML report
1415
```bash
1516
php ./vendor/bin/phpcpd --fuzzy --verbose --log-pmd=reports/phpcpd/phpcpd-report-v1.xml src
1617
```
1718

18-
Note: `src` is a folder where your php source code for analyzing
19+
Note: In this example, `src` represents the directory containing the PHP source code you wish to analyze.
1920

20-
2. Run xalan tool for report generation
21+
2. Run Xalan to convert the XML into HTML
2122
```bash
2223
xalan -in reports/phpcpd/phpcpd-report-v1.xml -xsl https://systemsdk.github.io/phpcpd/report/phpcpd-html-v1_0_0.xslt -out reports/phpcpd/phpcpd-report-v1.html
2324
```
2425

25-
3. Now you can open the report using your web-browser
26+
3. View the Report
27+
Open the newly generated `reports/phpcpd/phpcpd-report-v1.html` file in any modern web browser.
2628

27-
![Path mappings](images/report_example_01.png)
29+
You can view a live [Example Report here](https://systemsdk.github.io/phpcpd/report/report-example.html).
2830

29-
[Example](https://systemsdk.github.io/phpcpd/report/report-example.html)
31+
![Path mappings](images/report_example_01.png)
3032

31-
Note: Please use menu items `Enable datatable`, `Disable datatabl` for enable/disable [DataTables](https://datatables.net/).
33+
Tip: Use the `Enable datatable` and `Disable datatable` menu items at the top of the HTML report to toggle the interactive [DataTables](https://datatables.net/) grid for advanced sorting and searching.
3234

33-
## Xml report format
34-
This format uses `xml` to output the duplications in a more structured format. The `xml` format can then further be processed using `xslt` transformations. See section xslt below for examples.
35+
## XML Report Format
36+
Under the hood, `phpcpd` outputs the duplications in a structured `XML` format. This structured data can then be processed further using XSLT transformations.
3537

36-
Report file example:
37-
```
38+
Here is an example of the generated XML output:
39+
```xml
3840
<?xml version="1.0" encoding="UTF-8"?>
39-
<pmd-cpd xmlns="https://systemsdk.github.io/phpcpd/report" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" phpcpdVersion="8.2.4" timestamp="2025-11-07T21:42:17+00:00" version="1.0.0" xsi:schemaLocation="https://systemsdk.github.io/phpcpd/report https://systemsdk.github.io/phpcpd/report/phpcpd-report-v1_0_0.xsd">
40-
<duplication lines="59" tokens="136">
41-
<file line="116" endline="175" path="/var/www/html/tests/Fixture/Math.php"/>
42-
<file line="217" endline="276" path="/var/www/html/tests/Fixture/Math.php"/>
43-
<codefragment><![CDATA[ public function div($v1, $v2)
41+
<pmd-cpd xmlns="https://systemsdk.github.io/phpcpd/report" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" suppressedClones="11" suppressedLines="140" phpcpdVersion="9.1.0" timestamp="2026-09-02T13:11:49+00:00" version="1.0.0" xsi:schemaLocation="https://systemsdk.github.io/phpcpd/report https://systemsdk.github.io/phpcpd/report/phpcpd-report-v1_0_0.xsd">
42+
<duplication lines="59" tokens="136" exact="false">
43+
<file line="116" endline="175" path="/var/www/html/tests/Fixture/Math.php"/>
44+
<file line="217" endline="276" path="/var/www/html/tests/Fixture/Math.php"/>
45+
<codefragment><![CDATA[ public function div($v1, $v2)
4446
{
4547
$v3 = $v1 / ($v2 + $v1);
4648
if ($v3 > 14)
@@ -100,20 +102,20 @@ Report file example:
100102
101103
return $v8;
102104
]]></codefragment>
103-
</duplication>
105+
</duplication>
104106
</pmd-cpd>
105107
```
106108

107-
## Xslt
108-
This is not a direct report format. But you can use one of the following `xslt` stylesheets to convert the report into `html`. Or you can write your own stylesheet.
109+
## XSLT Stylesheets
110+
While XML is the direct report format, you can use XSLT stylesheets to convert the report into HTML.
109111

110-
`https://systemsdk.github.io/phpcpd/report/phpcpd-html-v1_0_0.xslt`
112+
We provide an official, ready-to-use XSLT stylesheet: `https://systemsdk.github.io/phpcpd/report/phpcpd-html-v1_0_0.xslt`.
111113

112-
This stylesheet is available and using for html report generation mentioned above.
114+
This stylesheet is utilized in the generation example above. It requires JavaScript to be enabled and uses [Bootstrap](https://getbootstrap.com/), [jQuery](https://jquery.com/), and [DataTables](https://datatables.net/) to provide a responsive user interface.
113115

114-
It requires javascript enabled and uses [Bootstrap](https://getbootstrap.com/), [jQuery](https://jquery.com/), and [DataTables](https://datatables.net/).
116+
Tip: Alternatively, you are free to write and apply your own custom XSLT stylesheet to match your internal corporate branding.
115117

116-
## Schema versions
117-
PHP Copy/Paste detector tool is building xml report that has schema `https://systemsdk.github.io/phpcpd/report/phpcpd-report-v1_0_0.xsd`.
118+
## Schema Versions
119+
The PHP Copy/Paste Detector generates XML reports that strictly adhere to the following schema: `https://systemsdk.github.io/phpcpd/report/phpcpd-report-v1_0_0.xsd`.
118120

119-
You can find xsd versions history [here](schema.md).
121+
For details regarding schema version history and specifications, please refer to the [Schema Documentation](schema.md).

‎docs/schema.md‎

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
# PHPCPD Report Schema
2-
This document describing PHPCPD report schema.
2+
This document describes the official XML schema used by `phpcpd` to generate structured code duplication reports. This schema ensures that the exported XML is strictly typed and can be reliably parsed by external reporting tools, CI/CD pipelines, or XSLT processors (such as Xalan) to generate HTML representations.
33

4-
## PHPCPD Report Schema 1.0.0
5-
Namespace: `https://systemsdk.github.io/phpcpd/report`
6-
7-
Schema Location: `https://systemsdk.github.io/phpcpd/report/phpcpd-report-v1_0_0.xsd`
8-
9-
Current Version: 1.0.0 (since phpcpd 8.2.0)
10-
11-
Last Change: 2026-08-31
4+
## Version 1.0.0 Specifications
5+
* **Namespace:** `https://systemsdk.github.io/phpcpd/report`
6+
* **Schema Location:** [`phpcpd-report-v1_0_0.xsd`](https://systemsdk.github.io/phpcpd/report/phpcpd-report-v1_0_0.xsd)
7+
* **Introduced In:** `phpcpd` version 8.2.0
8+
* **Last Updated:** 2026-08-31

‎docs/support.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ make phpstan
111111

112112
make phpcpd-run
113113
make phpcpd-html-report
114+
make phpcpd-sarif-report
114115

115116
make logs
116117
```

‎readme.md‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
# PHP Copy/Paste Detector (PHPCPD)
2-
3-
> **An enterprise-grade static analysis tool for detecting code duplication in modern PHP applications.**
2+
An enterprise-grade static analysis tool for detecting code duplication in modern PHP applications.
43

54
`phpcpd` analyzes your PHP source code to find structurally identical clones, helping your team reduce technical debt, enforce DRY (Don't Repeat Yourself) principles, and maintain high architectural standards.
65

76
Optimized for modern workflows, this tool provides seamless integration with CI/CD pipelines, GitHub Code Scanning (SARIF), and enterprise reporting systems.
87

9-
**Note:** This repository is an actively maintained, heavily upgraded continuation of the abandoned [sebastianbergmann/phpcpd](https://github.com/sebastianbergmann/phpcpd). It has been re-architected to meet the strict demands of enterprise environments and modern PHP 8.4+ standards.
8+
Note: This repository is an actively maintained, heavily upgraded continuation of the abandoned [sebastianbergmann/phpcpd](https://github.com/sebastianbergmann/phpcpd). It has been re-architected to meet the strict demands of enterprise environments and modern PHP 8.4+ standards.
109

1110
[![PHP Copy/Paste Detector](https://github.com/systemsdk/phpcpd/actions/workflows/ci.yml/badge.svg)](https://github.com/systemsdk/phpcpd/actions/workflows/ci.yml)
1211
[![Coverage Status](https://coveralls.io/repos/github/systemsdk/phpcpd/badge.svg)](https://coveralls.io/github/systemsdk/phpcpd)
@@ -66,7 +65,7 @@ Found 1 code clones with 17 duplicated lines in 1 files:
6665
0.05% duplicated lines out of 32210 total lines of code.
6766
Average code clone size is 17 lines, the largest code clone has 17 lines
6867

69-
ℹ️ Note: 1 clones (38 lines) were suppressed by #[SuppressCpd] attributes.
68+
ℹ️ Note: 1 clone(s) (38 lines) were suppressed by #[SuppressCpd] attribute(s).
7069

7170
Time: 00:00.373, Memory: 10.00 MB
7271
```

‎releases/phpcpd-9.1.0.phar‎

-296 Bytes
Binary file not shown.

‎releases/phpcpd-latest.phar‎

35.9 KB
Binary file not shown.

‎report/phpcpd-html-v1_0_0.xslt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
</tr>
6868
</table>
6969
<xsl:if test="cpd:pmd-cpd/attribute::suppressedClones &gt; 0">
70-
<p>ℹ️ Note: <font color="#0000FF"><xsl:value-of select="cpd:pmd-cpd/attribute::suppressedClones"/></font> clones (<font color="#0000FF"><xsl:value-of select="cpd:pmd-cpd/attribute::suppressedLines"/></font> lines) were suppressed by #[SuppressCpd] attributes.</p>
70+
<p>ℹ️ Note: <font color="#0000FF"><xsl:value-of select="cpd:pmd-cpd/attribute::suppressedClones"/></font> clone(s) (<font color="#0000FF"><xsl:value-of select="cpd:pmd-cpd/attribute::suppressedLines"/></font> lines) were suppressed by #[SuppressCpd] attribute(s).</p>
7171
</xsl:if>
7272
</div>
7373
</div>

0 commit comments

Comments
 (0)