Skip to content

Commit f96c40b

Browse files
author
DKravtsov
committed
phpcpd 8.2.1 release. Fixed codefragment value for xml report.
1 parent e22d0e5 commit f96c40b

File tree

15 files changed

+157
-139
lines changed

15 files changed

+157
-139
lines changed

ChangeLog.md

+6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
All notable changes in PHPCPD are documented in this file using the [Keep a CHANGELOG](http://keepachangelog.com/) principles.
44

5+
## [8.2.1] - 2025-05-03
6+
7+
### Updated
8+
9+
* Fixed codefragment value for xml report.
10+
511
## [8.2.0] - 2025-05-01
612

713
### Added

build.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<project name="phpcpd" default="setup">
33
<property name="basedir" value="." override="false"/>
4-
<property name="version" value="8.2.0" override="false"/>
4+
<property name="version" value="8.2.1" override="false"/>
55
<target name="setup" depends="clean,install-dependencies"/>
66

77
<target name="clean" description="Cleanup build artifacts">

composer.lock

+6-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/report.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -36,29 +36,29 @@ This format uses `xml` to output the duplications in a more structured format. T
3636
Report file example:
3737
```
3838
<?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.0" timestamp="2025-04-29T17:39:52+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">
39+
<pmd-cpd xmlns="https://systemsdk.github.io/phpcpd/report" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" phpcpdVersion="8.2.1" timestamp="2025-04-29T17:39:52+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">
4040
<duplication lines="59" tokens="136">
4141
<file line="116" endline="175" path="/var/www/html/tests/Fixture/Math.php"/>
4242
<file line="217" endline="276" path="/var/www/html/tests/Fixture/Math.php"/>
4343
<codefragment><![CDATA[ public function div($v1, $v2)
4444
{
4545
$v3 = $v1 / ($v2 + $v1);
46-
if ($v3 &gt; 14)
46+
if ($v3 > 14)
4747
{
4848
$v4 = 0;
49-
for ($i = 0; $i &lt; $v3; $i++)
49+
for ($i = 0; $i < $v3; $i++)
5050
{
5151
$v4 += ($v2 * $i);
5252
}
5353
}
54-
$v5 = ($v4 &lt; $v3 ? ($v3 - $v4) : ($v4 - $v3));
54+
$v5 = ($v4 < $v3 ? ($v3 - $v4) : ($v4 - $v3));
5555
5656
$v6 = ($v1 * $v2 * $v3 * $v4 * $v5);
5757
5858
$d = array($v1, $v2, $v3, $v4, $v5, $v6);
5959
6060
$v7 = 1;
61-
for ($i = 0; $i &lt; $v6; $i++)
61+
for ($i = 0; $i < $v6; $i++)
6262
{
6363
shuffle( $d );
6464
$v7 = $v7 + $i * end($d);
@@ -71,22 +71,22 @@ Report file example:
7171
}
7272
7373
$v3 = $v1 / ($v2 + $v1);
74-
if ($v3 &gt; 14)
74+
if ($v3 > 14)
7575
{
7676
$v4 = 0;
77-
for ($i = 0; $i &lt; $v3; $i++)
77+
for ($i = 0; $i < $v3; $i++)
7878
{
7979
$v4 += ($v2 * $i);
8080
}
8181
}
82-
$v5 = ($v4 &lt; $v3 ? ($v3 - $v4) : ($v4 - $v3));
82+
$v5 = ($v4 < $v3 ? ($v3 - $v4) : ($v4 - $v3));
8383
8484
$v6 = ($v1 * $v2 * $v3 * $v4 * $v5);
8585
8686
$d = array($v1, $v2, $v3, $v4, $v5, $v6);
8787
8888
$v7 = 1;
89-
for ($i = 0; $i &lt; $v6; $i++)
89+
for ($i = 0; $i < $v6; $i++)
9090
{
9191
shuffle( $d );
9292
$v7 = $v7 + $i * end($d);

readme.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Note: This tool is distributed as a [PHP Archive (PHAR)](https://php.net/phar).
2929
## Usage example
3030
```
3131
$ php ./vendor/bin/phpcpd --fuzzy --verbose src tests
32-
Copy/Paste Detector 8.2.0
32+
Copy/Paste Detector 8.2.1
3333
14/14 [==============================>] 100%
3434
Found 1 code clones with 17 duplicated lines in 1 files:
3535

releases/phpcpd-8.2.1.phar

134 KB
Binary file not shown.

releases/phpcpd-latest.phar

-111 Bytes
Binary file not shown.

src/Cli/Application.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
final class Application
3030
{
31-
public const string VERSION = '8.2.0';
31+
public const string VERSION = '8.2.1';
3232

3333
/**
3434
* @param array<int, string> $argv

src/Log/AbstractXmlLogger.php

+2-6
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,11 @@
99
use Systemsdk\PhpCPD\Exceptions\LoggerException;
1010

1111
use function file_put_contents;
12-
use function htmlspecialchars;
1312
use function mb_convert_encoding;
1413
use function ord;
1514
use function preg_replace;
1615
use function strlen;
1716

18-
use const ENT_COMPAT;
19-
2017
abstract class AbstractXmlLogger
2118
{
2219
protected DOMDocument $document;
@@ -98,12 +95,11 @@ protected function isUtf8(string $string): bool
9895
protected function escapeForXml(string $string): string
9996
{
10097
$string = $this->convertToUtf8($string);
101-
$string = (string)preg_replace(
98+
99+
return (string)preg_replace(
102100
'/[^\x09\x0A\x0D\x{0020}-\x{D7FF}\x{E000}-\x{FFFD}]/u',
103101
"\xEF\xBF\xBD",
104102
$string
105103
);
106-
107-
return htmlspecialchars($string, ENT_COMPAT);
108104
}
109105
}

tests/Fixture/pmd_expected.xml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<pmd-cpd xmlns="https://systemsdk.github.io/phpcpd/report" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" phpcpdVersion="8.2.0" timestamp="%datetime%" version="1.0.0" xsi:schemaLocation="https://systemsdk.github.io/phpcpd/report https://systemsdk.github.io/phpcpd/report/phpcpd-report-v1_0_0.xsd">
2+
<pmd-cpd xmlns="https://systemsdk.github.io/phpcpd/report" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" phpcpdVersion="%version%" timestamp="%datetime%" version="1.0.0" xsi:schemaLocation="https://systemsdk.github.io/phpcpd/report https://systemsdk.github.io/phpcpd/report/phpcpd-report-v1_0_0.xsd">
33
<duplication lines="4" tokens="4">
44
<file line="8" endline="12" path="%file1%"/>
55
<file line="8" endline="12" path="%file2%"/>
6-
<codefragment>function getAsciiEscapeChar(): string
6+
<codefragment><![CDATA[function getAsciiEscapeChar(): string
77
{
88
return '�';
99
}
10-
</codefragment>
10+
]]></codefragment>
1111
</duplication>
1212
</pmd-cpd>

tests/Unit/PMDTest.php

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use DateTime;
88
use DateTimeInterface;
99
use PHPUnit\Framework\TestCase;
10+
use Systemsdk\PhpCPD\Cli\Application;
1011
use Systemsdk\PhpCPD\CodeClone;
1112
use Systemsdk\PhpCPD\CodeCloneFile;
1213
use Systemsdk\PhpCPD\CodeCloneMap;
@@ -45,6 +46,7 @@ protected function setUp(): void
4546
$expectedPmdLogContents = strtr(
4647
$expectedPmdLogTemplate,
4748
[
49+
'%version%' => Application::VERSION,
4850
'%datetime%' => (new DateTime())->format(DateTimeInterface::ATOM),
4951
'%file1%' => $this->testFile1,
5052
'%file2%' => $this->testFile2,

tools/01_phpunit/composer.lock

+33-21
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)