From b9388bf87aa648d741229def5c170496a48d5203 Mon Sep 17 00:00:00 2001 From: Chris Doehring Date: Sun, 16 Oct 2022 22:00:38 +0200 Subject: [PATCH 01/10] Test against php 8.2 --- .github/workflows/tests.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index e63cb93784..4bfa7c4b50 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -24,6 +24,7 @@ jobs: - '7.4' - '8.0' - '8.1' + - '8.2' include: - operating-system: 'windows-latest' php-version: '7.1' @@ -59,9 +60,9 @@ jobs: run: composer update --no-interaction --no-progress --optimize-autoloader - name: Run tests - if: ${{ '8.1' != matrix.php-version }} + if: ${{ '8.1' != matrix.php-version && '8.2' != matrix.php-version }} run: ./vendor/bin/simple-phpunit - name: Run tests for php 8.1 - if: ${{ '8.1' == matrix.php-version }} + if: ${{ '8.1' == matrix.php-version || '8.2' == matrix.php-version }} run: SYMFONY_PHPUNIT_VERSION=9.5 ./vendor/bin/simple-phpunit From f1e63e11bb5e413b3ef233a42dcdac21c8a6d926 Mon Sep 17 00:00:00 2001 From: Chris Doehring Date: Sun, 16 Oct 2022 22:07:39 +0200 Subject: [PATCH 02/10] Fix DateTime century test --- test/Faker/Core/DateTimeTest.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/Faker/Core/DateTimeTest.php b/test/Faker/Core/DateTimeTest.php index 4b7da9fd76..b14e9ec0c8 100644 --- a/test/Faker/Core/DateTimeTest.php +++ b/test/Faker/Core/DateTimeTest.php @@ -215,7 +215,10 @@ public function testCentury() $century = $this->extension->century(); self::assertIsString($century); - self::assertEquals('XIX', $century); + self::assertContains( + $century, + ['I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX', 'X', 'XI', 'XII', 'XIII', 'XIV', 'XV', 'XVI', 'XVII', 'XVIII', 'XIX', 'XX', 'XXI'] + ); } public function testTimezone() From 879bc37ce3638cbbdc8a676552f8363eb405b767 Mon Sep 17 00:00:00 2001 From: Chris Doehring Date: Sun, 16 Oct 2022 22:21:28 +0200 Subject: [PATCH 03/10] Fix generator unique test --- test/Faker/GeneratorTest.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/test/Faker/GeneratorTest.php b/test/Faker/GeneratorTest.php index 4b14d7315f..ce873b61ac 100644 --- a/test/Faker/GeneratorTest.php +++ b/test/Faker/GeneratorTest.php @@ -274,13 +274,14 @@ public function word(): string $uniqueGenerator = $generator->unique(); - $generatedWords = [ - $uniqueGenerator->word(), - $uniqueGenerator->word(), - $uniqueGenerator->word(), - ]; - - self::assertEquals($words, $generatedWords); + $remainingWords = $words; + // ensure that all words are found only once + for ($i = 0; $i < count($words); $i++) { + $word = $uniqueGenerator->word(); + $foundKey = array_search($word, $remainingWords); + self::assertNotFalse($foundKey); + unset($remainingWords[$foundKey]); + } } public function testUniqueReturnsUniqueGeneratorThatThrowsWhenItCanNotGenerateUniqueValuesAnymore(): void From 2d16f1b679ba757b437c4d0c9ccb000909556449 Mon Sep 17 00:00:00 2001 From: Chris Doehring Date: Sun, 16 Oct 2022 23:03:23 +0200 Subject: [PATCH 04/10] Optimize php 8.2 deprecations --- .github/workflows/tests.yml | 2 +- phpunit.xml.dist | 3 +++ src/Faker/Calculator/Iban.php | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4bfa7c4b50..3e10c68592 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -63,6 +63,6 @@ jobs: if: ${{ '8.1' != matrix.php-version && '8.2' != matrix.php-version }} run: ./vendor/bin/simple-phpunit - - name: Run tests for php 8.1 + - name: Run tests for php >= 8.1 if: ${{ '8.1' == matrix.php-version || '8.2' == matrix.php-version }} run: SYMFONY_PHPUNIT_VERSION=9.5 ./vendor/bin/simple-phpunit diff --git a/phpunit.xml.dist b/phpunit.xml.dist index d9104c7b8e..d5421da8a7 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -9,6 +9,9 @@ columns="max" verbose="true" > + + + ./test/Faker diff --git a/src/Faker/Calculator/Iban.php b/src/Faker/Calculator/Iban.php index c8fae24239..470bf0391a 100644 --- a/src/Faker/Calculator/Iban.php +++ b/src/Faker/Calculator/Iban.php @@ -17,7 +17,7 @@ public static function checksum($iban) $checkString = substr($iban, 4) . substr($iban, 0, 2) . '00'; // Replace all letters with their number equivalents - $checkString = preg_replace_callback('/[A-Z]/', ['self', 'alphaToNumberCallback'], $checkString); + $checkString = preg_replace_callback('/[A-Z]/', [self::class, 'alphaToNumberCallback'], $checkString); // Perform mod 97 and subtract from 98 $checksum = 98 - self::mod97($checkString); From e550ed29d2a302f8bd5069dc0581baccc3c70afd Mon Sep 17 00:00:00 2001 From: Chris Doehring Date: Sun, 16 Oct 2022 23:06:57 +0200 Subject: [PATCH 05/10] Optimize php 8.2 deprecations --- phpunit.xml.dist | 2 +- src/Faker/Calculator/Iban.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index d5421da8a7..7dc06f9480 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -10,7 +10,7 @@ verbose="true" > - + diff --git a/src/Faker/Calculator/Iban.php b/src/Faker/Calculator/Iban.php index 470bf0391a..c8fae24239 100644 --- a/src/Faker/Calculator/Iban.php +++ b/src/Faker/Calculator/Iban.php @@ -17,7 +17,7 @@ public static function checksum($iban) $checkString = substr($iban, 4) . substr($iban, 0, 2) . '00'; // Replace all letters with their number equivalents - $checkString = preg_replace_callback('/[A-Z]/', [self::class, 'alphaToNumberCallback'], $checkString); + $checkString = preg_replace_callback('/[A-Z]/', ['self', 'alphaToNumberCallback'], $checkString); // Perform mod 97 and subtract from 98 $checksum = 98 - self::mod97($checkString); From d4fee3016d9c8c93b5c0e6a6263705f5426ea866 Mon Sep 17 00:00:00 2001 From: Chris Doehring Date: Sun, 16 Oct 2022 23:09:24 +0200 Subject: [PATCH 06/10] Optimize php 8.2 deprecations --- test/Faker/GeneratorTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/Faker/GeneratorTest.php b/test/Faker/GeneratorTest.php index ce873b61ac..01e9245e3e 100644 --- a/test/Faker/GeneratorTest.php +++ b/test/Faker/GeneratorTest.php @@ -276,9 +276,9 @@ public function word(): string $remainingWords = $words; // ensure that all words are found only once - for ($i = 0; $i < count($words); $i++) { + for ($i = 0; $i < count($words); ++$i) { $word = $uniqueGenerator->word(); - $foundKey = array_search($word, $remainingWords); + $foundKey = array_search($word, $remainingWords, true); self::assertNotFalse($foundKey); unset($remainingWords[$foundKey]); } From 92f0d04b0130359eebb3f2866493265f10ab2dad Mon Sep 17 00:00:00 2001 From: Chris Doehring Date: Fri, 28 Oct 2022 20:52:29 +0200 Subject: [PATCH 07/10] Revert "Fix generator unique test" This reverts commit 879bc37c --- test/Faker/GeneratorTest.php | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/test/Faker/GeneratorTest.php b/test/Faker/GeneratorTest.php index 01e9245e3e..4b14d7315f 100644 --- a/test/Faker/GeneratorTest.php +++ b/test/Faker/GeneratorTest.php @@ -274,14 +274,13 @@ public function word(): string $uniqueGenerator = $generator->unique(); - $remainingWords = $words; - // ensure that all words are found only once - for ($i = 0; $i < count($words); ++$i) { - $word = $uniqueGenerator->word(); - $foundKey = array_search($word, $remainingWords, true); - self::assertNotFalse($foundKey); - unset($remainingWords[$foundKey]); - } + $generatedWords = [ + $uniqueGenerator->word(), + $uniqueGenerator->word(), + $uniqueGenerator->word(), + ]; + + self::assertEquals($words, $generatedWords); } public function testUniqueReturnsUniqueGeneratorThatThrowsWhenItCanNotGenerateUniqueValuesAnymore(): void From 525882a43183d3a2c0aba7beb8692c82063ed79e Mon Sep 17 00:00:00 2001 From: Chris Doehring Date: Sat, 29 Oct 2022 09:42:23 +0200 Subject: [PATCH 08/10] Revert "Fix DateTime century test" This reverts commit f1e63e11bb5e413b3ef233a42dcdac21c8a6d926. --- test/Faker/Core/DateTimeTest.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/test/Faker/Core/DateTimeTest.php b/test/Faker/Core/DateTimeTest.php index b14e9ec0c8..4b7da9fd76 100644 --- a/test/Faker/Core/DateTimeTest.php +++ b/test/Faker/Core/DateTimeTest.php @@ -215,10 +215,7 @@ public function testCentury() $century = $this->extension->century(); self::assertIsString($century); - self::assertContains( - $century, - ['I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX', 'X', 'XI', 'XII', 'XIII', 'XIV', 'XV', 'XVI', 'XVII', 'XVIII', 'XIX', 'XX', 'XXI'] - ); + self::assertEquals('XIX', $century); } public function testTimezone() From 7deca4ce789724920e779fb9ed47aa16eebae0b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=B6ller?= Date: Thu, 8 Dec 2022 16:09:49 +0100 Subject: [PATCH 09/10] Fix: Adjust number of allowed deprecations --- phpunit.xml.dist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 7dc06f9480..45918edb55 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -10,7 +10,7 @@ verbose="true" > - + From 5d172c2c0281d16ac3c14dfdfb590d3c57cfd26a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=B6ller?= Date: Thu, 8 Dec 2022 16:10:42 +0100 Subject: [PATCH 10/10] Fix: Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2445daf3f0..c78db20da6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## [Unreleased](https://github.com/FakerPHP/Faker/compare/v1.20.0...main) - Dropped support for PHP 7.1, 7.2, and 7.3 (#543) +- Added support for PHP 8.2 (#528) ## [2022-07-20, v1.20.0](https://github.com/FakerPHP/Faker/compare/v1.19.0..v1.20.0)