From 60f80fd49e6f7c5130d2f5ffe70637bf656a1ca7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Thu, 14 Nov 2024 21:42:04 -0300 Subject: [PATCH 1/4] Bump PHP minimum version to 7.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maurício Meneghini Fauth --- .github/workflows/lint-and-analyse-php.yml | 8 ++++---- .github/workflows/tests.yml | 2 +- .scrutinizer.yml | 2 +- CHANGELOG.md | 3 +++ composer.json | 8 ++++---- phpstan-baseline.neon | 9 +++++++-- 6 files changed, 20 insertions(+), 12 deletions(-) diff --git a/.github/workflows/lint-and-analyse-php.yml b/.github/workflows/lint-and-analyse-php.yml index 24dd987..909e666 100644 --- a/.github/workflows/lint-and-analyse-php.yml +++ b/.github/workflows/lint-and-analyse-php.yml @@ -11,10 +11,10 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - - name: Set up PHP 7.1 + - name: Set up PHP 7.2 uses: shivammathur/setup-php@v2 with: - php-version: 7.1 + php-version: 7.2 tools: composer:v2 - name: Validate composer.json and composer.lock @@ -34,10 +34,10 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - - name: Set up PHP 7.1 + - name: Set up PHP 7.2 uses: shivammathur/setup-php@v2 with: - php-version: 7.1 + php-version: 7.2 tools: composer:v2 - name: Install Composer dependencies diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5ff1cbf..48c25fc 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -11,7 +11,7 @@ jobs: continue-on-error: ${{ matrix.experimental }} strategy: matrix: - php-version: ['7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3'] + php-version: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3'] extensions: [':apcu, mbstring', 'apcu, mbstring'] os: [ubuntu-latest] experimental: [false] diff --git a/.scrutinizer.yml b/.scrutinizer.yml index f707aaf..5e2e829 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -17,7 +17,7 @@ build: nodes: analysis: environment: - php: 7.1 + php: 7.2 dependencies: before: - composer install diff --git a/CHANGELOG.md b/CHANGELOG.md index 0338e53..5e1bfb7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## [Unreleased] +* Bump PHP minimum version to 7.2 +* Add support for Symfony 7 + ## [5.3.1] - 2023-08-23 * Add function guards to the global functions (#44) diff --git a/composer.json b/composer.json index 07ddfb3..5b3cbc6 100644 --- a/composer.json +++ b/composer.json @@ -27,13 +27,13 @@ ] }, "require": { - "php": "^7.1 || ^8.0", - "symfony/expression-language": "^4.0 || ^5.0 || ^6.0" + "php": "^7.2 || ^8.0", + "symfony/expression-language": "^5.0 || ^6.0 || ^7.0" }, "require-dev": { - "phpunit/phpunit": "^7.5 || ^8.5 || ^9.6 || ^10.3", + "phpunit/phpunit": "^8.5 || ^9.6 || ^10.5", "phpmyadmin/coding-standard": "^3.0.0", - "phpstan/phpstan": "^1.4.6" + "phpstan/phpstan": "^1.12" }, "autoload": { "psr-4": { diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index ffb5d79..aaeb8c4 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1,15 +1,20 @@ parameters: ignoreErrors: - - message: "#^Strict comparison using \\=\\=\\= between string and false will always evaluate to false\\.$#" + message: "#^Offset 'lang' on array\\{0\\: string, lang\\: non\\-falsy\\-string, 1\\: non\\-falsy\\-string, country\\?\\: string, 2\\?\\: string, charset\\?\\: string, 3\\?\\: string, modifier\\?\\: non\\-empty\\-string, \\.\\.\\.\\} on left side of \\?\\? always exists and is not nullable\\.$#" count: 1 - path: src/StringReader.php + path: src/Loader.php - message: "#^Cannot cast mixed to int\\.$#" count: 1 path: src/Translator.php + - + message: "#^Parameter \\#1 \\$str of function ltrim expects string, string\\|false given\\.$#" + count: 1 + path: src/Translator.php + - message: "#^Strict comparison using \\=\\=\\= between non\\-empty\\-array\\ and false will always evaluate to false\\.$#" count: 1 From 8f541590a843abd0a5271cd9ba4512ab86456259 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Tue, 19 Nov 2024 18:06:32 -0300 Subject: [PATCH 2/4] Add PHPStan strict rules MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maurício Meneghini Fauth --- composer.json | 12 ++- phpstan-baseline.neon | 225 ++++++++++++++++++++++++++++++++++++++++++ phpstan.neon.dist | 6 +- 3 files changed, 239 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index 5b3cbc6..6e70241 100644 --- a/composer.json +++ b/composer.json @@ -31,9 +31,13 @@ "symfony/expression-language": "^5.0 || ^6.0 || ^7.0" }, "require-dev": { - "phpunit/phpunit": "^8.5 || ^9.6 || ^10.5", "phpmyadmin/coding-standard": "^3.0.0", - "phpstan/phpstan": "^1.12" + "phpstan/extension-installer": "^1.4", + "phpstan/phpstan": "^1.12", + "phpstan/phpstan-deprecation-rules": "^1.2", + "phpstan/phpstan-phpunit": "^1.4", + "phpstan/phpstan-strict-rules": "^1.6", + "phpunit/phpunit": "^8.5 || ^9.6 || ^10.5" }, "autoload": { "psr-4": { @@ -46,8 +50,10 @@ } }, "config": { + "sort-packages": true, "allow-plugins": { - "dealerdirect/phpcodesniffer-composer-installer": true + "dealerdirect/phpcodesniffer-composer-installer": true, + "phpstan/extension-installer": true } }, "suggest": { diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index aaeb8c4..56b0bf1 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1,15 +1,110 @@ parameters: ignoreErrors: + - + message: "#^Only booleans are allowed in \\|\\|, mixed given on the right side\\.$#" + count: 1 + path: src/Cache/ApcuCache.php + + - + message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" + count: 1 + path: src/Loader.php + + - + message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#" + count: 2 + path: src/Loader.php + + - + message: "#^Dynamic call to static method PhpMyAdmin\\\\MoTranslator\\\\Loader\\:\\:listLocales\\(\\)\\.$#" + count: 1 + path: src/Loader.php + + - + message: "#^Method PhpMyAdmin\\\\MoTranslator\\\\Loader\\:\\:detectlocale\\(\\) should return string but returns mixed\\.$#" + count: 1 + path: src/Loader.php + - message: "#^Offset 'lang' on array\\{0\\: string, lang\\: non\\-falsy\\-string, 1\\: non\\-falsy\\-string, country\\?\\: string, 2\\?\\: string, charset\\?\\: string, 3\\?\\: string, modifier\\?\\: non\\-empty\\-string, \\.\\.\\.\\} on left side of \\?\\? always exists and is not nullable\\.$#" count: 1 path: src/Loader.php + - + message: "#^Only booleans are allowed in an elseif condition, string\\|null given\\.$#" + count: 2 + path: src/Loader.php + + - + message: "#^Only booleans are allowed in an if condition, int\\|false given\\.$#" + count: 1 + path: src/Loader.php + + - + message: "#^Only booleans are allowed in an if condition, string given\\.$#" + count: 1 + path: src/Loader.php + + - + message: "#^Only booleans are allowed in an if condition, string\\|null given\\.$#" + count: 5 + path: src/Loader.php + + - + message: "#^Casting to int something that's already int\\.$#" + count: 1 + path: src/MoParser.php + + - + message: "#^Method PhpMyAdmin\\\\MoTranslator\\\\StringReader\\:\\:readint\\(\\) should return int but returns mixed\\.$#" + count: 1 + path: src/StringReader.php + + - + message: "#^Method PhpMyAdmin\\\\MoTranslator\\\\StringReader\\:\\:readintarray\\(\\) should return array\\ but returns array\\.$#" + count: 1 + path: src/StringReader.php + - message: "#^Cannot cast mixed to int\\.$#" count: 1 path: src/Translator.php + - + message: "#^Dynamic call to static method PhpMyAdmin\\\\MoTranslator\\\\Translator\\:\\:extractPluralCount\\(\\)\\.$#" + count: 1 + path: src/Translator.php + + - + message: "#^Dynamic call to static method PhpMyAdmin\\\\MoTranslator\\\\Translator\\:\\:extractPluralsForms\\(\\)\\.$#" + count: 1 + path: src/Translator.php + + - + message: "#^Dynamic call to static method PhpMyAdmin\\\\MoTranslator\\\\Translator\\:\\:sanitizePluralExpression\\(\\)\\.$#" + count: 1 + path: src/Translator.php + + - + message: "#^Foreach overwrites \\$header with its value variable\\.$#" + count: 1 + path: src/Translator.php + + - + message: "#^Method PhpMyAdmin\\\\MoTranslator\\\\Translator\\:\\:extractPluralsForms\\(\\) should return string but returns \\(string\\|false\\)\\.$#" + count: 1 + path: src/Translator.php + + - + message: "#^Only numeric types are allowed in \\-, int\\|null given on the left side\\.$#" + count: 1 + path: src/Translator.php + + - + message: "#^Parameter \\#1 \\$str of function ltrim expects string, \\(string\\|false\\) given\\.$#" + count: 1 + path: src/Translator.php + - message: "#^Parameter \\#1 \\$str of function ltrim expects string, string\\|false given\\.$#" count: 1 @@ -20,6 +115,101 @@ parameters: count: 1 path: src/Translator.php + - + message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertFalse\\(\\)\\.$#" + count: 1 + path: tests/Cache/ApcuCacheFactoryTest.php + + - + message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertInstanceOf\\(\\)\\.$#" + count: 1 + path: tests/Cache/ApcuCacheFactoryTest.php + + - + message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertSame\\(\\)\\.$#" + count: 2 + path: tests/Cache/ApcuCacheFactoryTest.php + + - + message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:markTestSkipped\\(\\)\\.$#" + count: 1 + path: tests/Cache/ApcuCacheFactoryTest.php + + - + message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertEquals\\(\\)\\.$#" + count: 2 + path: tests/Cache/ApcuCacheTest.php + + - + message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertFalse\\(\\)\\.$#" + count: 4 + path: tests/Cache/ApcuCacheTest.php + + - + message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertSame\\(\\)\\.$#" + count: 11 + path: tests/Cache/ApcuCacheTest.php + + - + message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertTrue\\(\\)\\.$#" + count: 1 + path: tests/Cache/ApcuCacheTest.php + + - + message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:markTestSkipped\\(\\)\\.$#" + count: 1 + path: tests/Cache/ApcuCacheTest.php + + - + message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:markTestSkipped\\(\\)\\.$#" + count: 1 + path: tests/Cache/ApcuDisabledTest.php + + - + message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertEquals\\(\\)\\.$#" + count: 1 + path: tests/Cache/InMemoryCacheTest.php + + - + message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertFalse\\(\\)\\.$#" + count: 1 + path: tests/Cache/InMemoryCacheTest.php + + - + message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertSame\\(\\)\\.$#" + count: 4 + path: tests/Cache/InMemoryCacheTest.php + + - + message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertTrue\\(\\)\\.$#" + count: 1 + path: tests/Cache/InMemoryCacheTest.php + + - + message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertEquals\\(\\)\\.$#" + count: 9 + path: tests/FunctionsTest.php + + - + message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertEquals\\(\\)\\.$#" + count: 13 + path: tests/LoaderTest.php + + - + message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:isInstanceOf\\(\\)\\.$#" + count: 1 + path: tests/LoaderTest.php + + - + message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:markTestSkipped\\(\\)\\.$#" + count: 1 + path: tests/LoaderTest.php + + - + message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\TestCase\\:\\:once\\(\\)\\.$#" + count: 1 + path: tests/LoaderTest.php + - message: "#^Method PhpMyAdmin\\\\MoTranslator\\\\Tests\\\\LoaderTest\\:\\:localeList\\(\\) return type has no value type specified in iterable type array\\.$#" count: 1 @@ -35,6 +225,11 @@ parameters: count: 1 path: tests/LoaderTest.php + - + message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertEquals\\(\\)\\.$#" + count: 16 + path: tests/MoFilesTest.php + - message: "#^Method PhpMyAdmin\\\\MoTranslator\\\\Tests\\\\MoFilesTest\\:\\:getFiles\\(\\) return type has no value type specified in iterable type array\\.$#" count: 1 @@ -55,6 +250,11 @@ parameters: count: 1 path: tests/MoFilesTest.php + - + message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertEquals\\(\\)\\.$#" + count: 3 + path: tests/PluralFormulaTest.php + - message: "#^Method PhpMyAdmin\\\\MoTranslator\\\\Tests\\\\PluralFormulaTest\\:\\:pluralCounts\\(\\) return type has no value type specified in iterable type array\\.$#" count: 1 @@ -70,6 +270,11 @@ parameters: count: 1 path: tests/PluralFormulaTest.php + - + message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertSame\\(\\)\\.$#" + count: 3 + path: tests/PluralTest.php + - message: "#^Method PhpMyAdmin\\\\MoTranslator\\\\Tests\\\\PluralTest\\:\\:dataProviderPluralForms\\(\\) return type has no value type specified in iterable type array\\.$#" count: 1 @@ -80,3 +285,23 @@ parameters: count: 1 path: tests/PluralTest.php + - + message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertFileExists\\(\\)\\.$#" + count: 2 + path: tests/StringReaderTest.php + + - + message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertSame\\(\\)\\.$#" + count: 2 + path: tests/StringReaderTest.php + + - + message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertEquals\\(\\)\\.$#" + count: 6 + path: tests/TranslatorTest.php + + - + message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertSame\\(\\)\\.$#" + count: 6 + path: tests/TranslatorTest.php + diff --git a/phpstan.neon.dist b/phpstan.neon.dist index ec02511..83b771a 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -5,4 +5,8 @@ parameters: paths: - src - tests - reportUnmatchedIgnoredErrors: true + checkBenevolentUnionTypes: true + checkUninitializedProperties: true + checkDynamicProperties: true + checkTooWideReturnTypesInProtectedAndPublicMethods: true + checkImplicitMixed: true From 5878e38a039aeb1359fce95b01faacece954ed48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Wed, 20 Nov 2024 16:38:01 -0300 Subject: [PATCH 3/4] Prefer PHPUnit self calls instead of $this MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Done using PreferPHPUnitSelfCallRector. Signed-off-by: Maurício Meneghini Fauth --- phpstan-baseline.neon | 97 +---------------------- tests/Cache/ApcuCacheFactoryTest.php | 8 +- tests/Cache/ApcuCacheTest.php | 36 ++++----- tests/Cache/InMemoryCacheTest.php | 14 ++-- tests/FunctionsTest.php | 72 +++-------------- tests/LoaderTest.php | 56 ++++---------- tests/MoFilesTest.php | 112 ++++----------------------- tests/PluralFormulaTest.php | 15 +--- tests/PluralTest.php | 6 +- tests/StringReaderTest.php | 8 +- tests/TranslatorTest.php | 24 +++--- 11 files changed, 90 insertions(+), 358 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 56b0bf1..971c409 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -115,46 +115,11 @@ parameters: count: 1 path: src/Translator.php - - - message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertFalse\\(\\)\\.$#" - count: 1 - path: tests/Cache/ApcuCacheFactoryTest.php - - - - message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertInstanceOf\\(\\)\\.$#" - count: 1 - path: tests/Cache/ApcuCacheFactoryTest.php - - - - message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertSame\\(\\)\\.$#" - count: 2 - path: tests/Cache/ApcuCacheFactoryTest.php - - message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:markTestSkipped\\(\\)\\.$#" count: 1 path: tests/Cache/ApcuCacheFactoryTest.php - - - message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertEquals\\(\\)\\.$#" - count: 2 - path: tests/Cache/ApcuCacheTest.php - - - - message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertFalse\\(\\)\\.$#" - count: 4 - path: tests/Cache/ApcuCacheTest.php - - - - message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertSame\\(\\)\\.$#" - count: 11 - path: tests/Cache/ApcuCacheTest.php - - - - message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertTrue\\(\\)\\.$#" - count: 1 - path: tests/Cache/ApcuCacheTest.php - - message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:markTestSkipped\\(\\)\\.$#" count: 1 @@ -166,33 +131,8 @@ parameters: path: tests/Cache/ApcuDisabledTest.php - - message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertEquals\\(\\)\\.$#" - count: 1 - path: tests/Cache/InMemoryCacheTest.php - - - - message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertFalse\\(\\)\\.$#" + message: "#^Call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertSame\\(\\) with array\\ and array\\ will always evaluate to false\\.$#" count: 1 - path: tests/Cache/InMemoryCacheTest.php - - - - message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertSame\\(\\)\\.$#" - count: 4 - path: tests/Cache/InMemoryCacheTest.php - - - - message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertTrue\\(\\)\\.$#" - count: 1 - path: tests/Cache/InMemoryCacheTest.php - - - - message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertEquals\\(\\)\\.$#" - count: 9 - path: tests/FunctionsTest.php - - - - message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertEquals\\(\\)\\.$#" - count: 13 path: tests/LoaderTest.php - @@ -225,11 +165,6 @@ parameters: count: 1 path: tests/LoaderTest.php - - - message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertEquals\\(\\)\\.$#" - count: 16 - path: tests/MoFilesTest.php - - message: "#^Method PhpMyAdmin\\\\MoTranslator\\\\Tests\\\\MoFilesTest\\:\\:getFiles\\(\\) return type has no value type specified in iterable type array\\.$#" count: 1 @@ -250,11 +185,6 @@ parameters: count: 1 path: tests/MoFilesTest.php - - - message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertEquals\\(\\)\\.$#" - count: 3 - path: tests/PluralFormulaTest.php - - message: "#^Method PhpMyAdmin\\\\MoTranslator\\\\Tests\\\\PluralFormulaTest\\:\\:pluralCounts\\(\\) return type has no value type specified in iterable type array\\.$#" count: 1 @@ -270,11 +200,6 @@ parameters: count: 1 path: tests/PluralFormulaTest.php - - - message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertSame\\(\\)\\.$#" - count: 3 - path: tests/PluralTest.php - - message: "#^Method PhpMyAdmin\\\\MoTranslator\\\\Tests\\\\PluralTest\\:\\:dataProviderPluralForms\\(\\) return type has no value type specified in iterable type array\\.$#" count: 1 @@ -285,23 +210,3 @@ parameters: count: 1 path: tests/PluralTest.php - - - message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertFileExists\\(\\)\\.$#" - count: 2 - path: tests/StringReaderTest.php - - - - message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertSame\\(\\)\\.$#" - count: 2 - path: tests/StringReaderTest.php - - - - message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertEquals\\(\\)\\.$#" - count: 6 - path: tests/TranslatorTest.php - - - - message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertSame\\(\\)\\.$#" - count: 6 - path: tests/TranslatorTest.php - diff --git a/tests/Cache/ApcuCacheFactoryTest.php b/tests/Cache/ApcuCacheFactoryTest.php index b6262b1..53b16a8 100644 --- a/tests/Cache/ApcuCacheFactoryTest.php +++ b/tests/Cache/ApcuCacheFactoryTest.php @@ -43,7 +43,7 @@ public function testGetInstanceReturnApcuCache(): void { $factory = new ApcuCacheFactory(); $instance = $factory->getInstance(new MoParser(null), 'foo', 'bar'); - $this->assertInstanceOf(ApcuCache::class, $instance); + self::assertInstanceOf(ApcuCache::class, $instance); } public function testConstructorSetsTtl(): void @@ -59,7 +59,7 @@ public function testConstructorSetsTtl(): void sleep($ttl * 2); apcu_fetch('mo_' . $locale . '.' . $domain . '.' . $msgid, $success); - $this->assertFalse($success); + self::assertFalse($success); } public function testConstructorSetsReloadOnMiss(): void @@ -76,7 +76,7 @@ public function testConstructorSetsReloadOnMiss(): void apcu_delete('mo_' . $locale . '.' . $domain . '.' . $msgid); $actual = $instance->get($msgid); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } public function testConstructorSetsPrefix(): void @@ -93,6 +93,6 @@ public function testConstructorSetsPrefix(): void $factory->getInstance($parser, $locale, $domain); $actual = apcu_fetch($prefix . $locale . '.' . $domain . '.' . $msgid); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } } diff --git a/tests/Cache/ApcuCacheTest.php b/tests/Cache/ApcuCacheTest.php index 5fa06f4..cc3be25 100644 --- a/tests/Cache/ApcuCacheTest.php +++ b/tests/Cache/ApcuCacheTest.php @@ -53,7 +53,7 @@ public function testConstructorLoadsCache(): void new ApcuCache(new MoParser(__DIR__ . '/../data/little.mo'), $locale, $domain); $actual = apcu_fetch('mo_' . $locale . '.' . $domain . '.' . $msgid); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } public function testConstructorSetsTtl(): void @@ -67,9 +67,9 @@ public function testConstructorSetsTtl(): void sleep($ttl * 2); apcu_fetch('mo_' . $locale . '.' . $domain . '.' . $msgid, $success); - $this->assertFalse($success); + self::assertFalse($success); apcu_fetch('mo_' . $locale . '.' . $domain . '.' . ApcuCache::LOADED_KEY, $success); - $this->assertFalse($success); + self::assertFalse($success); } public function testConstructorSetsReloadOnMiss(): void @@ -91,7 +91,7 @@ public function testConstructorSetsReloadOnMiss(): void apcu_delete($prefix . $locale . '.' . $domain . '.' . $msgid); $actual = $cache->get($msgid); - $this->assertEquals($expected, $actual); + self::assertSame($expected, $actual); } public function testConstructorSetsPrefix(): void @@ -105,7 +105,7 @@ public function testConstructorSetsPrefix(): void new ApcuCache(new MoParser(__DIR__ . '/../data/little.mo'), $locale, $domain, 0, true, $prefix); $actual = apcu_fetch($prefix . $locale . '.' . $domain . '.' . $msgid); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } public function testEnsureTranslationsLoadedSetsLoadedKey(): void @@ -117,7 +117,7 @@ public function testEnsureTranslationsLoadedSetsLoadedKey(): void new ApcuCache(new MoParser(__DIR__ . '/../data/little.mo'), $locale, $domain); $actual = apcu_fetch('mo_' . $locale . '.' . $domain . '.' . ApcuCache::LOADED_KEY); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } public function testEnsureTranslationsLoadedHonorsLock(): void @@ -136,9 +136,9 @@ public function testEnsureTranslationsLoadedHonorsLock(): void new ApcuCache(new MoParser(__DIR__ . '/../data/little.mo'), $locale, $domain); $actual = apcu_fetch($lock); - $this->assertSame(1, $actual); + self::assertSame(1, $actual); apcu_fetch('mo_' . $locale . '.' . $domain . '.' . $msgid, $success); - $this->assertFalse($success); + self::assertFalse($success); } public function testGetReturnsMsgstr(): void @@ -149,7 +149,7 @@ public function testGetReturnsMsgstr(): void $cache = new ApcuCache(new MoParser(__DIR__ . '/../data/little.mo'), 'foo', 'bar'); $actual = $cache->get($msgid); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } public function testGetReturnsMsgidForCacheMiss(): void @@ -159,7 +159,7 @@ public function testGetReturnsMsgidForCacheMiss(): void $cache = new ApcuCache(new MoParser(null), 'foo', 'bar'); $actual = $cache->get($expected); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } public function testStoresMsgidOnCacheMiss(): void @@ -172,7 +172,7 @@ public function testStoresMsgidOnCacheMiss(): void $cache->get($expected); $actual = apcu_fetch('mo_' . $locale . '.' . $domain . '.' . $expected); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } public function testGetReloadsOnCacheMiss(): void @@ -186,7 +186,7 @@ public function testGetReloadsOnCacheMiss(): void apcu_delete('mo_' . $locale . '.' . $domain . '.' . ApcuCache::LOADED_KEY); $actual = $cache->get($msgid); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } public function testReloadOnMissHonorsLock(): void @@ -209,7 +209,7 @@ public function testReloadOnMissHonorsLock(): void }); $actual = $method->invoke($cache, $msgid); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } public function testSetSetsMsgstr(): void @@ -221,21 +221,21 @@ public function testSetSetsMsgstr(): void $cache->set($msgid, $expected); $actual = $cache->get($msgid); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } public function testHasReturnsFalse(): void { $cache = new ApcuCache(new MoParser(null), 'foo', 'bar'); $actual = $cache->has('Column'); - $this->assertFalse($actual); + self::assertFalse($actual); } public function testHasReturnsTrue(): void { $cache = new ApcuCache(new MoParser(__DIR__ . '/../data/little.mo'), 'foo', 'bar'); $actual = $cache->has('Column'); - $this->assertTrue($actual); + self::assertTrue($actual); } public function testSetAllSetsTranslations(): void @@ -250,7 +250,7 @@ public function testSetAllSetsTranslations(): void foreach ($translations as $msgid => $expected) { $actual = $cache->get($msgid); - $this->assertEquals($expected, $actual); + self::assertSame($expected, $actual); } } @@ -265,6 +265,6 @@ public function testCacheStoresPluralForms(): void $msgstr = $cache->get($msgid); $actual = explode(chr(0), $msgstr); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } } diff --git a/tests/Cache/InMemoryCacheTest.php b/tests/Cache/InMemoryCacheTest.php index c81a56e..8047f92 100644 --- a/tests/Cache/InMemoryCacheTest.php +++ b/tests/Cache/InMemoryCacheTest.php @@ -19,7 +19,7 @@ public function testConstructorParsesCache(): void $parser = new MoParser(__DIR__ . '/../data/little.mo'); $cache = new InMemoryCache($parser); $actual = $cache->get('Column'); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } public function testGetReturnsMsgidForCacheMiss(): void @@ -27,7 +27,7 @@ public function testGetReturnsMsgidForCacheMiss(): void $expected = 'Column'; $cache = new InMemoryCache(new MoParser(null)); $actual = $cache->get($expected); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } public function testSetSetsMsgstr(): void @@ -37,21 +37,21 @@ public function testSetSetsMsgstr(): void $cache = new InMemoryCache(new MoParser(null)); $cache->set($msgid, $expected); $actual = $cache->get($msgid); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } public function testHasReturnsFalse(): void { $cache = new InMemoryCache(new MoParser(null)); $actual = $cache->has('Column'); - $this->assertFalse($actual); + self::assertFalse($actual); } public function testHasReturnsTrue(): void { $cache = new InMemoryCache(new MoParser(__DIR__ . '/../data/little.mo')); $actual = $cache->has('Column'); - $this->assertTrue($actual); + self::assertTrue($actual); } public function testSetAllSetsTranslations(): void @@ -64,7 +64,7 @@ public function testSetAllSetsTranslations(): void $cache->setAll($translations); foreach ($translations as $msgid => $expected) { $actual = $cache->get($msgid); - $this->assertEquals($expected, $actual); + self::assertSame($expected, $actual); } } @@ -77,6 +77,6 @@ public function testGetAllReturnsTranslations(): void $cache = new InMemoryCache(new MoParser(null)); $cache->setAll($expected); $actual = $cache->getAll(); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } } diff --git a/tests/FunctionsTest.php b/tests/FunctionsTest.php index 8551957..3a3621c 100644 --- a/tests/FunctionsTest.php +++ b/tests/FunctionsTest.php @@ -24,79 +24,25 @@ public function setUp(): void public function testGettext(): void { - $this->assertEquals( - 'Typ', - _gettext('Type') - ); + self::assertSame('Typ', _gettext('Type')); - $this->assertEquals( - 'Typ', - __('Type') - ); + self::assertSame('Typ', __('Type')); - $this->assertEquals( - '%d sekundy', - _ngettext( - '%d second', - '%d seconds', - 2 - ) - ); + self::assertSame('%d sekundy', _ngettext('%d second', '%d seconds', 2)); - $this->assertEquals( - '%d seconds', - _npgettext( - 'context', - '%d second', - '%d seconds', - 2 - ) - ); + self::assertSame('%d seconds', _npgettext('context', '%d second', '%d seconds', 2)); - $this->assertEquals( - 'Tabulka', - _pgettext( - 'Display format', - 'Table' - ) - ); + self::assertSame('Tabulka', _pgettext('Display format', 'Table')); } public function testDomain(): void { - $this->assertEquals( - 'Typ', - _dgettext('phpmyadmin', 'Type') - ); + self::assertSame('Typ', _dgettext('phpmyadmin', 'Type')); - $this->assertEquals( - '%d sekundy', - _dngettext( - 'phpmyadmin', - '%d second', - '%d seconds', - 2 - ) - ); + self::assertSame('%d sekundy', _dngettext('phpmyadmin', '%d second', '%d seconds', 2)); - $this->assertEquals( - '%d seconds', - _dnpgettext( - 'phpmyadmin', - 'context', - '%d second', - '%d seconds', - 2 - ) - ); + self::assertSame('%d seconds', _dnpgettext('phpmyadmin', 'context', '%d second', '%d seconds', 2)); - $this->assertEquals( - 'Tabulka', - _dpgettext( - 'phpmyadmin', - 'Display format', - 'Table' - ) - ); + self::assertSame('Tabulka', _dpgettext('phpmyadmin', 'Display format', 'Table')); } } diff --git a/tests/LoaderTest.php b/tests/LoaderTest.php index f8ff148..3eb16ec 100644 --- a/tests/LoaderTest.php +++ b/tests/LoaderTest.php @@ -26,10 +26,7 @@ class LoaderTest extends TestCase */ public function testListLocales(string $locale, array $expected): void { - $this->assertEquals( - $expected, - Loader::listLocales($locale) - ); + self::assertSame($expected, Loader::listLocales($locale)); } /** @@ -153,10 +150,10 @@ public function testLocaleChange(): void $loader->textdomain('phpmyadmin'); $loader->bindtextdomain('phpmyadmin', __DIR__ . '/data/locale/'); $translator = $loader->getTranslator('phpmyadmin'); - $this->assertEquals('Typ', $translator->gettext('Type')); + self::assertSame('Typ', $translator->gettext('Type')); $loader->setlocale('be_BY'); $translator = $loader->getTranslator('phpmyadmin'); - $this->assertEquals('Тып', $translator->gettext('Type')); + self::assertSame('Тып', $translator->gettext('Type')); } /** @@ -166,10 +163,7 @@ public function testGetTranslator(string $domain, string $locale, string $otherd { $loader = $this->getLoader($domain, $locale); $translator = $loader->getTranslator($otherdomain); - $this->assertEquals( - $expected, - $translator->gettext('Type') - ); + self::assertSame($expected, $translator->gettext('Type')); } /** @@ -225,38 +219,26 @@ public function testInstance(): void $loader->bindtextdomain('phpmyadmin', __DIR__ . '/data/locale/'); $translator = $loader->getTranslator(); - $this->assertEquals( - 'Typ', - $translator->gettext('Type') - ); + self::assertSame('Typ', $translator->gettext('Type')); /* Ensure the object survives */ $loader = Loader::getInstance(); $translator = $loader->getTranslator(); - $this->assertEquals( - 'Typ', - $translator->gettext('Type') - ); + self::assertSame('Typ', $translator->gettext('Type')); /* Ensure the object can support different locale files for the same domain */ $loader = Loader::getInstance(); $loader->setlocale('be_BY'); $loader->bindtextdomain('phpmyadmin', __DIR__ . '/data/locale/'); $translator = $loader->getTranslator(); - $this->assertEquals( - 'Тып', - $translator->gettext('Type') - ); + self::assertSame('Тып', $translator->gettext('Type')); } public function testDetect(): void { $GLOBALS['lang'] = 'foo'; $loader = Loader::getInstance(); - $this->assertEquals( - 'foo', - $loader->detectlocale() - ); + self::assertSame('foo', $loader->detectlocale()); unset($GLOBALS['lang']); } @@ -274,27 +256,15 @@ public function testDetectEnv(): void unset($GLOBALS['lang']); putenv('LC_ALL=baz'); - $this->assertEquals( - 'baz', - $loader->detectlocale() - ); + self::assertSame('baz', $loader->detectlocale()); putenv('LC_ALL'); putenv('LC_MESSAGES=bar'); - $this->assertEquals( - 'bar', - $loader->detectlocale() - ); + self::assertSame('bar', $loader->detectlocale()); putenv('LC_MESSAGES'); putenv('LANG=barr'); - $this->assertEquals( - 'barr', - $loader->detectlocale() - ); + self::assertSame('barr', $loader->detectlocale()); putenv('LANG'); - $this->assertEquals( - 'en', - $loader->detectlocale() - ); + self::assertSame('en', $loader->detectlocale()); } public function testSetCacheFactory(): void @@ -320,6 +290,6 @@ public function testSetCacheFactory(): void $translator = $loader->getTranslator($domain); $actual = $translator->gettext('Type'); - $this->assertEquals($expected, $actual); + self::assertSame($expected, $actual); } } diff --git a/tests/MoFilesTest.php b/tests/MoFilesTest.php index a36f057..9cbcfc5 100644 --- a/tests/MoFilesTest.php +++ b/tests/MoFilesTest.php @@ -24,15 +24,9 @@ class MoFilesTest extends TestCase public function testMoFileTranslate(string $filename): void { $parser = $this->getTranslator($filename); - $this->assertEquals( - 'Pole', - $parser->gettext('Column') - ); + self::assertSame('Pole', $parser->gettext('Column')); // Non existing string - $this->assertEquals( - 'Column parser', - $parser->gettext('Column parser') - ); + self::assertSame('Column parser', $parser->gettext('Column parser')); } /** @@ -51,55 +45,13 @@ public function testMoFilePlurals(string $filename): void $expected0 = '%d sekund'; } - $this->assertEquals( - $expected0, - $parser->ngettext( - '%d second', - '%d seconds', - 0 - ) - ); - $this->assertEquals( - '%d sekunda', - $parser->ngettext( - '%d second', - '%d seconds', - 1 - ) - ); - $this->assertEquals( - $expected2, - $parser->ngettext( - '%d second', - '%d seconds', - 2 - ) - ); - $this->assertEquals( - $expected0, - $parser->ngettext( - '%d second', - '%d seconds', - 5 - ) - ); - $this->assertEquals( - $expected0, - $parser->ngettext( - '%d second', - '%d seconds', - 10 - ) - ); + self::assertSame($expected0, $parser->ngettext('%d second', '%d seconds', 0)); + self::assertSame('%d sekunda', $parser->ngettext('%d second', '%d seconds', 1)); + self::assertSame($expected2, $parser->ngettext('%d second', '%d seconds', 2)); + self::assertSame($expected0, $parser->ngettext('%d second', '%d seconds', 5)); + self::assertSame($expected0, $parser->ngettext('%d second', '%d seconds', 10)); // Non existing string - $this->assertEquals( - '"%d" seconds', - $parser->ngettext( - '"%d" second', - '"%d" seconds', - 10 - ) - ); + self::assertSame('"%d" seconds', $parser->ngettext('"%d" second', '"%d" seconds', 10)); } /** @@ -108,13 +60,7 @@ public function testMoFilePlurals(string $filename): void public function testMoFileContext(string $filename): void { $parser = $this->getTranslator($filename); - $this->assertEquals( - 'Tabulka', - $parser->pgettext( - 'Display format', - 'Table' - ) - ); + self::assertSame('Tabulka', $parser->pgettext('Display format', 'Table')); } /** @@ -123,14 +69,7 @@ public function testMoFileContext(string $filename): void public function testMoFileNotTranslated(string $filename): void { $parser = $this->getTranslator($filename); - $this->assertEquals( - '%d second', - $parser->ngettext( - '%d second', - '%d seconds', - 1 - ) - ); + self::assertSame('%d second', $parser->ngettext('%d second', '%d seconds', 1)); } /** @@ -165,26 +104,13 @@ public function testEmptyMoFile(string $file): void $parser = new MoParser($file); $translator = new Translator(new InMemoryCache($parser)); if (basename($file) === 'magic.mo') { - $this->assertEquals(Translator::ERROR_BAD_MAGIC, $parser->error); + self::assertSame(Translator::ERROR_BAD_MAGIC, $parser->error); } else { - $this->assertEquals(Translator::ERROR_READING, $parser->error); + self::assertSame(Translator::ERROR_READING, $parser->error); } - $this->assertEquals( - 'Table', - $translator->pgettext( - 'Display format', - 'Table' - ) - ); - $this->assertEquals( - '"%d" seconds', - $translator->ngettext( - '"%d" second', - '"%d" seconds', - 10 - ) - ); + self::assertSame('Table', $translator->pgettext('Display format', 'Table')); + self::assertSame('"%d" seconds', $translator->ngettext('"%d" second', '"%d" seconds', 10)); } /** @@ -193,14 +119,8 @@ public function testEmptyMoFile(string $file): void public function testExists(string $file): void { $parser = $this->getTranslator($file); - $this->assertEquals( - true, - $parser->exists('Column') - ); - $this->assertEquals( - false, - $parser->exists('Column parser') - ); + self::assertTrue($parser->exists('Column')); + self::assertFalse($parser->exists('Column parser')); } /** diff --git a/tests/PluralFormulaTest.php b/tests/PluralFormulaTest.php index 541caa4..06f1261 100644 --- a/tests/PluralFormulaTest.php +++ b/tests/PluralFormulaTest.php @@ -19,10 +19,7 @@ class PluralFormulaTest extends TestCase */ public function testExtractPluralsForms(string $header, string $expected): void { - $this->assertEquals( - $expected, - Translator::extractPluralsForms($header) - ); + self::assertSame($expected, Translator::extractPluralsForms($header)); } /** @@ -63,10 +60,7 @@ public static function pluralExtractionData(): array */ public function testPluralCounts(string $expr, int $expected): void { - $this->assertEquals( - $expected, - Translator::extractPluralCount($expr) - ); + self::assertSame($expected, Translator::extractPluralCount($expr)); } /** @@ -107,10 +101,7 @@ public static function pluralCounts(): array */ public function testPluralExpression(string $expr, string $expected): void { - $this->assertEquals( - $expected, - Translator::sanitizePluralExpression($expr) - ); + self::assertSame($expected, Translator::sanitizePluralExpression($expr)); } /** diff --git a/tests/PluralTest.php b/tests/PluralTest.php index fe4afb6..3651db4 100644 --- a/tests/PluralTest.php +++ b/tests/PluralTest.php @@ -29,7 +29,7 @@ public function testNpgettext(int $number, string $expected): void { $parser = $this->getTranslator(''); $result = $parser->npgettext('context', "%d pig went to the market\n", "%d pigs went to the market\n", $number); - $this->assertSame($expected, $result); + self::assertSame($expected, $result); } /** @@ -60,7 +60,7 @@ public function testNgettext(): void $translationKey = implode(chr(0), ["%d pig went to the market\n", "%d pigs went to the market\n"]); $parser->setTranslation($translationKey, ''); $result = $parser->ngettext("%d pig went to the market\n", "%d pigs went to the market\n", 1); - $this->assertSame('', $result); + self::assertSame('', $result); } /** @@ -115,7 +115,7 @@ public function testNgettextSelectString(string $pluralForms): void $translationKey = implode(chr(0), ["%d pig went to the market\n", "%d pigs went to the market\n"]); $parser->setTranslation($translationKey, 'ok'); $result = $parser->ngettext("%d pig went to the market\n", "%d pigs went to the market\n", 1); - $this->assertSame('ok', $result); + self::assertSame('ok', $result); } private function getTranslator(string $filename): Translator diff --git a/tests/StringReaderTest.php b/tests/StringReaderTest.php index 17dc794..1af9fe2 100644 --- a/tests/StringReaderTest.php +++ b/tests/StringReaderTest.php @@ -17,22 +17,22 @@ class StringReaderTest extends TestCase public function testReadFails(): void { $tempFile = (string) tempnam(sys_get_temp_dir(), 'phpMyAdmin_StringReaderTest'); - $this->assertFileExists($tempFile); + self::assertFileExists($tempFile); $stringReader = new StringReader($tempFile); unlink($tempFile); $actual = $stringReader->read(-1, -1); - $this->assertSame('', $actual); + self::assertSame('', $actual); } public function testReadIntArray(): void { $tempFile = (string) tempnam(sys_get_temp_dir(), 'phpMyAdmin_StringReaderTest'); file_put_contents($tempFile, "\0\0\0\0\0\0\0\0\0\0\0\0"); - $this->assertFileExists($tempFile); + self::assertFileExists($tempFile); $stringReader = new StringReader($tempFile); unlink($tempFile); $actual = $stringReader->readintarray('V', 2, 2); - $this->assertSame([ + self::assertSame([ 1 => 0, 2 => 0, ], $actual); diff --git a/tests/TranslatorTest.php b/tests/TranslatorTest.php index dd135b5..d70bc20 100644 --- a/tests/TranslatorTest.php +++ b/tests/TranslatorTest.php @@ -22,7 +22,7 @@ public function testConstructorWithFilenameParam(): void $expected = 'Pole'; $translator = new Translator(__DIR__ . '/data/little.mo'); $actual = $translator->gettext('Column'); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } public function testConstructorWithNullParam(): void @@ -30,7 +30,7 @@ public function testConstructorWithNullParam(): void $expected = 'Column'; $translator = new Translator(null); $actual = $translator->gettext($expected); - $this->assertSame($expected, $actual); + self::assertSame($expected, $actual); } /** @@ -39,7 +39,7 @@ public function testConstructorWithNullParam(): void public function testGettext(): void { $translator = $this->getTranslator(''); - $this->assertEquals('Test', $translator->gettext('Test')); + self::assertSame('Test', $translator->gettext('Test')); } /** @@ -49,7 +49,7 @@ public function testSetTranslation(): void { $translator = $this->getTranslator(''); $translator->setTranslation('Test', 'Translation'); - $this->assertEquals('Translation', $translator->gettext('Test')); + self::assertSame('Translation', $translator->gettext('Test')); } /** @@ -60,12 +60,12 @@ public function testGetSetTranslations(): void $transTable = ['Test' => 'Translation']; $translator = $this->getTranslator(''); $translator->setTranslations($transTable); - $this->assertEquals('Translation', $translator->gettext('Test')); - $this->assertSame($transTable, $translator->getTranslations()); + self::assertSame('Translation', $translator->gettext('Test')); + self::assertSame($transTable, $translator->getTranslations()); $translator = $this->getTranslator(null); $translator->setTranslations($transTable); - $this->assertSame($transTable, $translator->getTranslations()); - $this->assertEquals('Translation', $translator->gettext('Test')); + self::assertSame($transTable, $translator->getTranslations()); + self::assertSame('Translation', $translator->gettext('Test')); $transTable = [ 'Test' => 'Translation', 'shouldIWriteTests' => 'as much as possible', @@ -73,12 +73,12 @@ public function testGetSetTranslations(): void ]; $translator = $this->getTranslator(''); $translator->setTranslations($transTable); - $this->assertSame($transTable, $translator->getTranslations()); - $this->assertEquals('as much as possible', $translator->gettext('shouldIWriteTests')); + self::assertSame($transTable, $translator->getTranslations()); + self::assertSame('as much as possible', $translator->gettext('shouldIWriteTests')); $translator = $this->getTranslator(null); $translator->setTranslations($transTable); - $this->assertSame($transTable, $translator->getTranslations()); - $this->assertEquals('it depends', $translator->gettext('is it hard')); + self::assertSame($transTable, $translator->getTranslations()); + self::assertSame('it depends', $translator->gettext('is it hard')); } public function testGetTranslationsThrowsException(): void From 871bf9e20d9089ea8cc398a7a78daa30e4cd8247 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Fri, 22 Nov 2024 12:28:32 -0300 Subject: [PATCH 4/4] Do not allow PHP 8.4 builds to fail MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Allows PHP 8.5 builds to fails. Signed-off-by: Maurício Meneghini Fauth --- .github/workflows/tests.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 48c25fc..c147219 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -11,14 +11,14 @@ jobs: continue-on-error: ${{ matrix.experimental }} strategy: matrix: - php-version: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3'] + php-version: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4'] extensions: [':apcu, mbstring', 'apcu, mbstring'] os: [ubuntu-latest] experimental: [false] composer-options: [''] include: - - { php-version: '8.4', experimental: true, os: ubuntu-latest, composer-options: '--ignore-platform-req=php+', extensions: 'apcu, mbstring' } - - { php-version: '8.4', experimental: true, os: ubuntu-latest, composer-options: '--ignore-platform-req=php+', extensions: ':apcu, mbstring' } + - { php-version: '8.5', experimental: true, os: ubuntu-latest, composer-options: '--ignore-platform-req=php+', extensions: 'apcu, mbstring' } + - { php-version: '8.5', experimental: true, os: ubuntu-latest, composer-options: '--ignore-platform-req=php+', extensions: ':apcu, mbstring' } steps: - name: Checkout code uses: actions/checkout@v4