From 44d754ac7dd3d08972c6740e6ad3f8f24d7eab32 Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Thu, 26 Dec 2024 09:07:27 +0000 Subject: [PATCH] Requires PHP 8.1+ ; Updated dependencies + fixes --- .github/workflows/check.yml | 4 ++-- Makefile | 8 ++++---- VERSION | 2 +- composer.json | 10 +++++----- phpstan.neon | 2 +- phpunit.xml.dist | 32 ++++++++++++++++++-------------- resources/debian/compat | 2 +- resources/debian/control | 2 +- resources/rpm/rpm.spec | 4 ++-- src/Bidi.php | 4 ++-- src/Bidi/StepN.php | 2 +- src/Bidi/StepX.php | 2 +- src/Convert.php | 2 +- test/Bidi/StepITest.php | 6 ++++-- test/Bidi/StepLTest.php | 4 ++-- test/Bidi/StepNTest.php | 13 +++++-------- test/Bidi/StepWTest.php | 25 +++++++++---------------- test/Bidi/StepXTest.php | 4 ++-- test/Bidi/StepXtenTest.php | 4 ++-- test/BidiTest.php | 8 +++----- test/ConvertTest.php | 25 +++++++------------------ 21 files changed, 74 insertions(+), 91 deletions(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 8ca381e..bf9c5e3 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -23,7 +23,7 @@ jobs: strategy: fail-fast: false matrix: - php-version: ["8.0", "8.1", "8.2", "8.3"] + php-version: ["8.1", "8.2", "8.3", "8.4"] experimental: [false] os: [ubuntu-latest] coverage-extension: [pcov] @@ -50,7 +50,7 @@ jobs: - name: Run all tests run: make qa - name: Send coverage - uses: codecov/codecov-action@v3 + uses: codecov/codecov-action@v5 with: flags: php-${{ matrix.php-version }}-${{ matrix.os }} name: php-${{ matrix.php-version }}-${{ matrix.os }} diff --git a/Makefile b/Makefile index 9305ee1..a1197dd 100644 --- a/Makefile +++ b/Makefile @@ -170,7 +170,7 @@ endif deps: ensuretarget rm -rf ./vendor/* ($(COMPOSER) install -vvv --no-interaction) - curl --silent --show-error --fail --location --output ./vendor/phpstan.phar https://github.com/phpstan/phpstan/releases/download/1.10.41/phpstan.phar \ + curl --silent --show-error --fail --location --output ./vendor/phpstan.phar https://github.com/phpstan/phpstan/releases/download/2.0.4/phpstan.phar \ && chmod +x ./vendor/phpstan.phar # Generate source code documentation @@ -212,8 +212,8 @@ endif .PHONY: lint lint: ./vendor/bin/phpcs --ignore="./vendor/" --standard=phpcs.xml src test - ./vendor/bin/phpmd src text codesize,unusedcode,naming,design --exclude vendor - ./vendor/bin/phpmd test text unusedcode,naming,design + ./vendor/bin/phpmd src text codesize,unusedcode,naming,design --exclude */vendor/* + ./vendor/bin/phpmd test text unusedcode,naming,design --exclude */vendor/* php -r 'exit((int)version_compare(PHP_MAJOR_VERSION, "7", ">"));' || ./vendor/phpstan.phar analyse # Run all tests and reports @@ -261,7 +261,7 @@ tag: .PHONY: test test: cp phpunit.xml.dist phpunit.xml - ./vendor/bin/phpunit --migrate-configuration || true + #./vendor/bin/phpunit --migrate-configuration || true XDEBUG_MODE=coverage ./vendor/bin/phpunit --stderr test # Remove all installed files diff --git a/VERSION b/VERSION index a6e7bcb..c945ef1 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.0.17 +2.0.18 diff --git a/composer.json b/composer.json index ee2bcff..053d6c0 100644 --- a/composer.json +++ b/composer.json @@ -19,16 +19,16 @@ } ], "require": { - "php": ">=8.0", + "php": ">=8.1", "ext-mbstring": "*", "ext-pcre": "*", "tecnickcom/tc-lib-unicode-data": "^2.0" }, "require-dev": { - "pdepend/pdepend": "2.13.0", - "phpmd/phpmd": "2.13.0", - "phpunit/phpunit": "10.1.2 || 9.6.13", - "squizlabs/php_codesniffer": "3.7.2" + "pdepend/pdepend": "2.16.2", + "phpmd/phpmd": "2.15.0", + "phpunit/phpunit": "11.5.2 || 10.5.40", + "squizlabs/php_codesniffer": "3.11.2" }, "autoload": { "psr-4": { diff --git a/phpstan.neon b/phpstan.neon index bf592ce..86bd47d 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -3,7 +3,7 @@ parameters: paths: - src - test - scanDirectories: + excludePaths: - vendor ignoreErrors: reportUnmatchedIgnoredErrors: false diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 45a9033..27ac7f9 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,27 +1,31 @@ + stopOnFailure="false"> ./test - - - src - - + + + src + + + + + + + + - - - + diff --git a/resources/debian/compat b/resources/debian/compat index ec63514..f599e28 100644 --- a/resources/debian/compat +++ b/resources/debian/compat @@ -1 +1 @@ -9 +10 diff --git a/resources/debian/control b/resources/debian/control index c127e76..ba93ceb 100644 --- a/resources/debian/control +++ b/resources/debian/control @@ -10,6 +10,6 @@ Vcs-Git: https://github.com/~#VENDOR#~/~#PROJECT#~.git Package: ~#PKGNAME#~ Provides: php-~#PROJECT#~ Architecture: all -Depends: php (>= 8.0.0), php-mbstring, php-tecnickcom-tc-lib-unicode-data (<< 3.0.0), php-tecnickcom-tc-lib-unicode-data (>= 2.0.17), ${misc:Depends} +Depends: php (>= 8.1.0), php-mbstring, php-tecnickcom-tc-lib-unicode-data (<< 3.0.0), php-tecnickcom-tc-lib-unicode-data (>= 2.0.18), ${misc:Depends} Description: PHP Unicode methods. PHP library containing Unicode methods. diff --git a/resources/rpm/rpm.spec b/resources/rpm/rpm.spec index 6bcc86f..eb202a9 100644 --- a/resources/rpm/rpm.spec +++ b/resources/rpm/rpm.spec @@ -16,9 +16,9 @@ URL: https://github.com/%{gh_owner}/%{gh_project} BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-%(%{__id_u} -n) BuildArch: noarch -Requires: php(language) >= 8.0.0 +Requires: php(language) >= 8.1.0 Requires: php-composer(%{c_vendor}/tc-lib-unicode-data) < 3.0.0 -Requires: php-composer(%{c_vendor}/tc-lib-unicode-data) >= 2.0.17 +Requires: php-composer(%{c_vendor}/tc-lib-unicode-data) >= 2.0.18 Requires: php-pcre Requires: php-mbstring diff --git a/src/Bidi.php b/src/Bidi.php index 16674d4..2ddfef2 100644 --- a/src/Bidi.php +++ b/src/Bidi.php @@ -159,7 +159,7 @@ public function __construct( * @param ?array $ordarr Array of UTF-8 codepoints (if empty it will be generated from $str or $chrarr) * @param string $forcedir If 'R' forces RTL, if 'L' forces LTR * - * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * @SuppressWarnings("PHPMD.CyclomaticComplexity") */ protected function setInput( ?string $str = null, @@ -272,7 +272,7 @@ protected function getParagraphs(): array /** * Process the string * - * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * @SuppressWarnings("PHPMD.CyclomaticComplexity") */ protected function process(): void { diff --git a/src/Bidi/StepN.php b/src/Bidi/StepN.php index 5aadb68..44ed2df 100644 --- a/src/Bidi/StepN.php +++ b/src/Bidi/StepN.php @@ -288,7 +288,7 @@ protected function processN1next(int &$jdx): string * * @param int $idx Start index */ - protected function getNextN1Char(int $idx): int|float + protected function getNextN1Char(int $idx): int { $jdx = ($idx + 1); while (($jdx < $this->seq['length']) && ($this->seq['item'][$jdx]['type'] == 'NI')) { diff --git a/src/Bidi/StepX.php b/src/Bidi/StepX.php index 6c76905..dedf53f 100644 --- a/src/Bidi/StepX.php +++ b/src/Bidi/StepX.php @@ -151,7 +151,7 @@ protected function processX(): void * @param int $pos Original character position in the input string * @param int $ord Char code * - * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * @SuppressWarnings("PHPMD.CyclomaticComplexity") */ protected function processXcase(int $pos, int $ord): void { diff --git a/src/Convert.php b/src/Convert.php index a7ca6e2..dfb86be 100644 --- a/src/Convert.php +++ b/src/Convert.php @@ -53,7 +53,7 @@ public function chr(int $ord): string public function ord(string $chr): int { $uni = unpack('N', mb_convert_encoding($chr, 'UCS-4BE', 'UTF-8')); - if ($uni === false) { + if (($uni === false) || (!isset($uni[1])) || (!is_int($uni[1]))) { throw new UniException('Error converting string'); } diff --git a/test/Bidi/StepITest.php b/test/Bidi/StepITest.php index ffe0e6e..456258e 100644 --- a/test/Bidi/StepITest.php +++ b/test/Bidi/StepITest.php @@ -18,6 +18,7 @@ use Com\Tecnick\Unicode\Bidi\StepI; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; /** * Bidi Test @@ -33,8 +34,6 @@ class StepITest extends TestCase { /** - * @dataProvider stepIDataProvider - * * @param array{ * 'e': int, * 'edir': string, @@ -55,7 +54,10 @@ class StepITest extends TestCase * 'x': int, * }>, * } $seq Isolated Sequence array + * + * @param mixed $expected Expected result */ + #[DataProvider('stepIDataProvider')] public function testStepI(array $seq, mixed $expected): void { $stepi = new StepI($seq); diff --git a/test/Bidi/StepLTest.php b/test/Bidi/StepLTest.php index 493e7c8..bc68ce4 100644 --- a/test/Bidi/StepLTest.php +++ b/test/Bidi/StepLTest.php @@ -18,6 +18,7 @@ use Com\Tecnick\Unicode\Bidi\StepL; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; /** * Bidi Test @@ -33,8 +34,6 @@ class StepLTest extends TestCase { /** - * @dataProvider stepLDataProvider - * * @param array $chardata */ + #[DataProvider('stepLDataProvider')] public function testStepL(array $chardata, int $pel, int $maxlevel, mixed $expected): void { $stepl = new StepL($chardata, $pel, $maxlevel); diff --git a/test/Bidi/StepNTest.php b/test/Bidi/StepNTest.php index 2a94fcc..39fe37a 100644 --- a/test/Bidi/StepNTest.php +++ b/test/Bidi/StepNTest.php @@ -18,6 +18,7 @@ use Com\Tecnick\Unicode\Bidi\StepN; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; /** * Bidi Test @@ -33,8 +34,6 @@ class StepNTest extends TestCase { /** - * @dataProvider stepN0DataProvider - * * @param array{ * 'e': int, * 'edir': string, @@ -56,6 +55,7 @@ class StepNTest extends TestCase * }>, * } $seq Isolated Sequence array */ + #[DataProvider('stepN0DataProvider')] public function testStepN0(array $seq, mixed $expected): void { $stepn = new StepN($seq, false); @@ -1533,8 +1533,6 @@ public static function stepN0DataProvider(): array } /** - * @dataProvider stepN1DataProvider - * * @param array{ * 'e': int, * 'edir': string, @@ -1556,6 +1554,7 @@ public static function stepN0DataProvider(): array * }>, * } $seq Isolated Sequence array */ + #[DataProvider('stepN1DataProvider')] public function testStepN1(array $seq, mixed $expected): void { $stepn = new \Com\Tecnick\Unicode\Bidi\StepN($seq, false); @@ -2558,8 +2557,6 @@ public static function stepN1DataProvider(): array } /** - * @dataProvider stepN2DataProvider - * * @param array{ * 'e': int, * 'edir': string, @@ -2581,6 +2578,7 @@ public static function stepN1DataProvider(): array * }>, * } $seq Isolated Sequence array */ + #[DataProvider('stepN2DataProvider')] public function testStepN2(array $seq, mixed $expected): void { $stepn = new \Com\Tecnick\Unicode\Bidi\StepN($seq, false); @@ -2663,8 +2661,6 @@ public static function stepN2DataProvider(): array } /** - * @dataProvider stepNDataProvider - * * @param array{ * 'e': int, * 'edir': string, @@ -2686,6 +2682,7 @@ public static function stepN2DataProvider(): array * }>, * } $seq Isolated Sequence array */ + #[DataProvider('stepNDataProvider')] public function testStepN(array $seq, mixed $expected): void { $stepn = new \Com\Tecnick\Unicode\Bidi\StepN($seq); diff --git a/test/Bidi/StepWTest.php b/test/Bidi/StepWTest.php index 863df7b..c915073 100644 --- a/test/Bidi/StepWTest.php +++ b/test/Bidi/StepWTest.php @@ -18,6 +18,7 @@ use Com\Tecnick\Unicode\Bidi\StepW; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; /** * Bidi Test @@ -33,8 +34,6 @@ class StepWTest extends TestCase { /** - * @dataProvider stepWDataProvider - * * @param array{ * 'e': int, * 'edir': string, @@ -56,6 +55,7 @@ class StepWTest extends TestCase * }>, * } $seq */ + #[DataProvider('stepWDataProvider')] public function testStepW(array $seq, mixed $expected): void { $stepw = new StepW($seq); @@ -199,8 +199,6 @@ public static function stepWDataProvider(): array } /** - * @dataProvider stepW1DataProvider - * * @param array{ * 'e': int, * 'edir': string, @@ -222,6 +220,7 @@ public static function stepWDataProvider(): array * }>, * } $seq */ + #[DataProvider('stepW1DataProvider')] public function testStepW1(array $seq, mixed $expected): void { $stepw = new \Com\Tecnick\Unicode\Bidi\StepW($seq, false); @@ -630,8 +629,6 @@ public static function stepW1DataProvider(): array } /** - * @dataProvider stepW2DataProvider - * * @param array{ * 'e': int, * 'edir': string, @@ -653,6 +650,7 @@ public static function stepW1DataProvider(): array * }>, * } $seq */ + #[DataProvider('stepW2DataProvider')] public function testStepW2(array $seq, mixed $expected): void { $stepw = new \Com\Tecnick\Unicode\Bidi\StepW($seq, false); @@ -1121,8 +1119,6 @@ public static function stepW2DataProvider(): array } /** - * @dataProvider stepW3DataProvider - * * @param array{ * 'e': int, * 'edir': string, @@ -1144,6 +1140,7 @@ public static function stepW2DataProvider(): array * }>, * } $seq */ + #[DataProvider('stepW3DataProvider')] public function testStepW3(array $seq, mixed $expected): void { $stepw = new \Com\Tecnick\Unicode\Bidi\StepW($seq, false); @@ -1268,8 +1265,6 @@ public static function stepW3DataProvider(): array } /** - * @dataProvider stepW4DataProvider - * * @param array{ * 'e': int, * 'edir': string, @@ -1291,6 +1286,7 @@ public static function stepW3DataProvider(): array * }>, * } $seq */ + #[DataProvider('stepW4DataProvider')] public function testStepW4(array $seq, mixed $expected): void { $stepw = new \Com\Tecnick\Unicode\Bidi\StepW($seq, false); @@ -1607,8 +1603,6 @@ public static function stepW4DataProvider(): array } /** - * @dataProvider stepW5DataProvider - * * @param array{ * 'e': int, * 'edir': string, @@ -1630,6 +1624,7 @@ public static function stepW4DataProvider(): array * }>, * } $seq */ + #[DataProvider('stepW5DataProvider')] public function testStepW5(array $seq, mixed $expected): void { $stepw = new \Com\Tecnick\Unicode\Bidi\StepW($seq, false); @@ -2072,8 +2067,6 @@ public static function stepW5DataProvider(): array } /** - * @dataProvider stepW6DataProvider - * * @param array{ * 'e': int, * 'edir': string, @@ -2095,6 +2088,7 @@ public static function stepW5DataProvider(): array * }>, * } $seq */ + #[DataProvider('stepW6DataProvider')] public function testStepW6(array $seq, mixed $expected): void { $stepw = new \Com\Tecnick\Unicode\Bidi\StepW($seq, false); @@ -2457,8 +2451,6 @@ public static function stepW6DataProvider(): array } /** - * @dataProvider stepW7DataProvider - * * @param array{ * 'e': int, * 'edir': string, @@ -2480,6 +2472,7 @@ public static function stepW6DataProvider(): array * }>, * } $seq */ + #[DataProvider('stepW7DataProvider')] public function testStepW7(array $seq, mixed $expected): void { $stepw = new \Com\Tecnick\Unicode\Bidi\StepW($seq, false); diff --git a/test/Bidi/StepXTest.php b/test/Bidi/StepXTest.php index c65c3d0..2c72fb9 100644 --- a/test/Bidi/StepXTest.php +++ b/test/Bidi/StepXTest.php @@ -18,6 +18,7 @@ use Com\Tecnick\Unicode\Bidi\StepX; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; /** * Bidi Test @@ -33,10 +34,9 @@ class StepXTest extends TestCase { /** - * @dataProvider stepXDataProvider - * * @param array $ordarr Array of character codes */ + #[DataProvider('stepXDataProvider')] public function testStepX(array $ordarr, int $pel, mixed $expected): void { $stepx = new StepX($ordarr, $pel); diff --git a/test/Bidi/StepXtenTest.php b/test/Bidi/StepXtenTest.php index 34186f8..195d97e 100644 --- a/test/Bidi/StepXtenTest.php +++ b/test/Bidi/StepXtenTest.php @@ -18,6 +18,7 @@ use Com\Tecnick\Unicode\Bidi\StepXten; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; /** * Bidi Test @@ -33,8 +34,6 @@ class StepXtenTest extends TestCase { /** - * @dataProvider stepXtenDataProvider - * * @param array $chardata */ + #[DataProvider('stepXtenDataProvider')] public function testStepXteN(array $chardata, mixed $expected): void { $stepxten = new StepXten($chardata, 0); diff --git a/test/BidiTest.php b/test/BidiTest.php index 89b200f..696c9b3 100644 --- a/test/BidiTest.php +++ b/test/BidiTest.php @@ -17,6 +17,7 @@ namespace Test; use Com\Tecnick\Unicode\Bidi; +use PHPUnit\Framework\Attributes\DataProvider; /** * Bidi Test @@ -38,14 +39,13 @@ public function testException(): void } /** - * @dataProvider inputDataProvider - * * @param ?string $str String to convert (if null it will be generated from $chrarr or $ordarr) * @param ?array $chrarr Array of UTF-8 chars (if empty it will be generated from $str or $ordarr) * @param ?array $ordarr Array of UTF-8 codepoints (if empty it will be generated from $str or $chrarr) * @param string $forcedir If 'R' forces RTL, if 'L' forces LTR * @param bool $shaping If true enable the shaping algorithm */ + #[DataProvider('inputDataProvider')] public function testStr( ?string $str = null, ?array $chrarr = null, @@ -83,9 +83,7 @@ public static function inputDataProvider(): array ]; } - /** - * @dataProvider bidiStrDataProvider - */ + #[DataProvider('bidiStrDataProvider')] public function testBidiStr(string $str, mixed $expected, string $forcedir = ''): void { $bidi = new Bidi($str, null, null, $forcedir, true); diff --git a/test/ConvertTest.php b/test/ConvertTest.php index a3150fe..c6f631c 100644 --- a/test/ConvertTest.php +++ b/test/ConvertTest.php @@ -18,6 +18,7 @@ use Com\Tecnick\Unicode\Data\Latin; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; /** * Convert Test @@ -37,9 +38,7 @@ protected function getTestObject(): \Com\Tecnick\Unicode\Convert return new \Com\Tecnick\Unicode\Convert(); } - /** - * @dataProvider chrDataProvider - */ + #[DataProvider('chrDataProvider')] public function testChr(int $ord, mixed $expected): void { $convert = $this->getTestObject(); @@ -47,9 +46,7 @@ public function testChr(int $ord, mixed $expected): void $this->assertEquals($expected, $chr); } - /** - * @dataProvider chrDataProvider - */ + #[DataProvider('chrDataProvider')] public function testOrd(mixed $expected, string $chr): void { $convert = $this->getTestObject(); @@ -138,9 +135,7 @@ public function testLatinArrToStr(): void $this->assertEquals('09AZaz', $res); } - /** - * @dataProvider strToHexDataProvider - */ + #[DataProvider('strToHexDataProvider')] public function testStrToHex(string $str, mixed $hex): void { $convert = $this->getTestObject(); @@ -148,9 +143,7 @@ public function testStrToHex(string $str, mixed $hex): void $this->assertEquals($hex, $res); } - /** - * @dataProvider strToHexDataProvider - */ + #[DataProvider('strToHexDataProvider')] public function testHexToStr(mixed $str, string $hex): void { $convert = $this->getTestObject(); @@ -172,9 +165,7 @@ public static function strToHexDataProvider(): array ]; } - /** - * @dataProvider toUTF16BEDataProvider - */ + #[DataProvider('toUTF16BEDataProvider')] public function testToUTF16BE(string $str, mixed $exp): void { $convert = $this->getTestObject(); @@ -194,9 +185,7 @@ public static function toUTF16BEDataProvider(): array ]; } - /** - * @dataProvider toUTF8DataProvider - */ + #[DataProvider('toUTF8DataProvider')] public function testToUTF8(string $str, mixed $exp, string $enc = null): void { $convert = $this->getTestObject();