From e8aaa586cb531d127cec6fda9a30216f119a3098 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Tue, 15 Oct 2024 15:31:29 +0100 Subject: [PATCH] feat: php 8.4 support --- .github/workflows/tests.yml | 2 +- composer.json | 13 +++---- phpstan.neon | 9 ----- src/Factories/Attributes/Attribute.php | 2 +- src/Factories/TestCaseFactory.php | 2 +- src/KernelDump.php | 2 +- .../Parallel/Paratest/WrapperRunner.php | 2 +- tests/.snapshots/success.txt | 32 +---------------- tests/Overrides/VersionsTest.php | 18 ---------- tests/Unit/Support/DatasetInfo.php | 36 ------------------- tests/Visual/Parallel.php | 2 +- 11 files changed, 14 insertions(+), 106 deletions(-) delete mode 100644 tests/Overrides/VersionsTest.php delete mode 100644 tests/Unit/Support/DatasetInfo.php diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 89d68db8..ff20914d 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -14,7 +14,7 @@ jobs: matrix: os: [ubuntu-latest, macos-latest, windows-latest] symfony: ['6.4', '7.0'] - php: ['8.1', '8.2', '8.3'] + php: ['8.1', '8.2', '8.3', '8.4'] dependency_version: [prefer-lowest, prefer-stable] exclude: - php: '8.1' diff --git a/composer.json b/composer.json index 0a4cc173..1acdf4a1 100644 --- a/composer.json +++ b/composer.json @@ -20,13 +20,14 @@ "php": "^8.1.0", "brianium/paratest": "^7.3.1", "nunomaduro/collision": "^7.10.0|^8.4.0", - "nunomaduro/termwind": "^1.15.1|^2.0.1", + "nunomaduro/termwind": "^1.15.1|^2.1.0", "pestphp/pest-plugin": "^2.1.1", "pestphp/pest-plugin-arch": "^2.7.0", - "phpunit/phpunit": "^10.5.17" + "phpunit/phpunit": "^10.5.36" }, "conflict": { - "phpunit/phpunit": ">10.5.17", + "filp/whoops": "<2.16.0", + "phpunit/phpunit": ">10.5.36", "sebastian/exporter": "<5.1.0", "webmozart/assert": "<1.11.0" }, @@ -51,9 +52,9 @@ ] }, "require-dev": { - "pestphp/pest-dev-tools": "^2.16.0", - "pestphp/pest-plugin-type-coverage": "^2.8.5", - "symfony/process": "^6.4.0|^7.1.3" + "pestphp/pest-dev-tools": "^2.17.0", + "pestphp/pest-plugin-type-coverage": "^2.8.7", + "symfony/process": "^6.4.0|^7.1.5" }, "minimum-stability": "dev", "prefer-stable": true, diff --git a/phpstan.neon b/phpstan.neon index 1cd3a087..9ed48871 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,6 +1,5 @@ includes: - vendor/phpstan/phpstan-strict-rules/rules.neon - - vendor/ergebnis/phpstan-rules/rules.neon - vendor/thecodingmachine/phpstan-strict-rules/phpstan-strict-rules.neon parameters: @@ -12,12 +11,4 @@ parameters: reportUnmatchedIgnoredErrors: true ignoreErrors: - - "#has a nullable return type declaration.#" - - "#Language construct isset\\(\\) should not be used.#" - - "#is not allowed to extend#" - - "#is concrete, but does not have a Test suffix#" - - "#with a nullable type declaration#" - "#type mixed is not subtype of native#" - - "# with null as default value#" - - "#has parameter \\$closure with default value.#" - - "#has parameter \\$description with default value.#" diff --git a/src/Factories/Attributes/Attribute.php b/src/Factories/Attributes/Attribute.php index e8af0e77..21df216d 100644 --- a/src/Factories/Attributes/Attribute.php +++ b/src/Factories/Attributes/Attribute.php @@ -20,7 +20,7 @@ abstract class Attribute * @param array $attributes * @return array */ - public function __invoke(TestCaseMethodFactory $method, array $attributes): array // @phpstan-ignore-line + public function __invoke(TestCaseMethodFactory $method, array $attributes): array { return $attributes; } diff --git a/src/Factories/TestCaseFactory.php b/src/Factories/TestCaseFactory.php index 6d4330e8..07d0c19b 100644 --- a/src/Factories/TestCaseFactory.php +++ b/src/Factories/TestCaseFactory.php @@ -194,7 +194,7 @@ final class TestCaseFactory } PHP; - eval($classCode); // @phpstan-ignore-line + eval($classCode); } catch (ParseError $caught) { throw new RuntimeException(sprintf( "Unable to create test case for test file at %s. \n %s", diff --git a/src/KernelDump.php b/src/KernelDump.php index 150e44ae..e1c67da5 100644 --- a/src/KernelDump.php +++ b/src/KernelDump.php @@ -40,7 +40,7 @@ final class KernelDump */ public function disable(): void { - @ob_clean(); // @phpstan-ignore-line + @ob_clean(); if ($this->buffer !== '') { $this->flush(); diff --git a/src/Plugins/Parallel/Paratest/WrapperRunner.php b/src/Plugins/Parallel/Paratest/WrapperRunner.php index 61755bac..c046ed28 100644 --- a/src/Plugins/Parallel/Paratest/WrapperRunner.php +++ b/src/Plugins/Parallel/Paratest/WrapperRunner.php @@ -391,7 +391,7 @@ final class WrapperRunner implements RunnerInterface $testSuite = (new LogMerger)->merge($this->junitFiles); (new Writer)->write( - $testSuite, + $testSuite, // @phpstan-ignore-line $this->options->configuration->logfileJunit(), ); } diff --git a/tests/.snapshots/success.txt b/tests/.snapshots/success.txt index 3dde887c..aebb806b 100644 --- a/tests/.snapshots/success.txt +++ b/tests/.snapshots/success.txt @@ -1173,16 +1173,6 @@ PASS Tests\Hooks\BeforeEachTest ✓ global beforeEach execution order - PASS Tests\Overrides\VersionsTest - ✓ versions with dataset "Runner/Filter/NameFilterIterator.php" - ✓ versions with dataset "Runner/ResultCache/DefaultResultCache.php" - ✓ versions with dataset "Runner/TestSuiteLoader.php" - ✓ versions with dataset "TextUI/Command/Commands/WarmCodeCoverageCacheCommand.php" - ✓ versions with dataset "TextUI/Output/Default/ProgressPrinter/Subscriber/TestSkippedSubscriber.php" - ✓ versions with dataset "TextUI/TestSuiteFilterProcessor.php" - ✓ versions with dataset "Event/Value/ThrowableBuilder.php" - ✓ versions with dataset "Logging/JUnit/JunitXmlLogger.php" - PASS Tests\PHPUnit\CustomAffixes\InvalidTestName ✓ it runs file names like @#$%^&()-_=+.php @@ -1287,26 +1277,6 @@ ✓ it can resolve builtin value types ✓ it cannot resolve a parameter without type - PASS Tests\Unit\Support\DatasetInfo - ✓ it can check if dataset is defined inside a Datasets directory with ('/var/www/project/tests/Datase…rs.php', true) - ✓ it can check if dataset is defined inside a Datasets directory with ('/var/www/project/tests/Datasets.php', false) - ✓ it can check if dataset is defined inside a Datasets directory with ('/var/www/project/tests/Featur…rs.php', true) - ✓ it can check if dataset is defined inside a Datasets directory with ('/var/www/project/tests/Featur…rs.php', false) - ✓ it can check if dataset is defined inside a Datasets directory with ('/var/www/project/tests/Featur…ts.php', false) - ✓ it can check if dataset is defined inside a Datasets.php file with ('/var/www/project/tests/Datase…rs.php', false) - ✓ it can check if dataset is defined inside a Datasets.php file with ('/var/www/project/tests/Datasets.php', true) - ✓ it can check if dataset is defined inside a Datasets.php file with ('/var/www/project/tests/Featur…rs.php', false) #1 - ✓ it can check if dataset is defined inside a Datasets.php file with ('/var/www/project/tests/Featur…rs.php', false) #2 - ✓ it can check if dataset is defined inside a Datasets.php file with ('/var/www/project/tests/Featur…ts.php', true) - ✓ it computes the dataset scope with ('/var/www/project/tests/Datase…rs.php', '/var/www/project/tests') - ✓ it computes the dataset scope with ('/var/www/project/tests/Datasets.php', '/var/www/project/tests') - ✓ it computes the dataset scope with ('/var/www/project/tests/Featur…rs.php', '/var/www/project/tests/Features') - ✓ it computes the dataset scope with ('/var/www/project/tests/Featur…rs.php', '/var/www/project/tests/Featur…rs.php') #1 - ✓ it computes the dataset scope with ('/var/www/project/tests/Featur…ts.php', '/var/www/project/tests/Features') - ✓ it computes the dataset scope with ('/var/www/project/tests/Featur…rs.php', '/var/www/project/tests/Featur…ollers') - ✓ it computes the dataset scope with ('/var/www/project/tests/Featur…rs.php', '/var/www/project/tests/Featur…rs.php') #2 - ✓ it computes the dataset scope with ('/var/www/project/tests/Featur…ts.php', '/var/www/project/tests/Featur…ollers') - PASS Tests\Unit\Support\ExceptionTrace ✓ it ensures the given closures reports the correct class name ✓ it ensures the given closures reports the correct class name and suggests the [uses()] function @@ -1425,4 +1395,4 @@ WARN Tests\Visual\Version - visual snapshot of help command output - Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 20 skipped, 1014 passed (2407 assertions) \ No newline at end of file + Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 20 skipped, 988 passed (2381 assertions) \ No newline at end of file diff --git a/tests/Overrides/VersionsTest.php b/tests/Overrides/VersionsTest.php deleted file mode 100644 index 1fdd63c0..00000000 --- a/tests/Overrides/VersionsTest.php +++ /dev/null @@ -1,18 +0,0 @@ -toBe($expectedHash); -})->with(function () { - foreach (BootOverrides::FILES as $hash => $file) { - $path = implode(DIRECTORY_SEPARATOR, [ - dirname(__DIR__, 2), - 'vendor/phpunit/phpunit/src', - $file, - ]); - yield $file => [$path, $hash]; - } -}); diff --git a/tests/Unit/Support/DatasetInfo.php b/tests/Unit/Support/DatasetInfo.php deleted file mode 100644 index dfe2b417..00000000 --- a/tests/Unit/Support/DatasetInfo.php +++ /dev/null @@ -1,36 +0,0 @@ -toBe($inside); -})->with([ - ['file' => '/var/www/project/tests/Datasets/Numbers.php', 'inside' => true], - ['file' => '/var/www/project/tests/Datasets.php', 'inside' => false], - ['file' => '/var/www/project/tests/Features/Datasets/Numbers.php', 'inside' => true], - ['file' => '/var/www/project/tests/Features/Numbers.php', 'inside' => false], - ['file' => '/var/www/project/tests/Features/Datasets.php', 'inside' => false], -]); - -it('can check if dataset is defined inside a Datasets.php file', function (string $path, bool $inside) { - expect(DatasetInfo::isADatasetsFile($path))->toBe($inside); -})->with([ - ['file' => '/var/www/project/tests/Datasets/Numbers.php', 'inside' => false], - ['file' => '/var/www/project/tests/Datasets.php', 'inside' => true], - ['file' => '/var/www/project/tests/Features/Datasets/Numbers.php', 'inside' => false], - ['file' => '/var/www/project/tests/Features/Numbers.php', 'inside' => false], - ['file' => '/var/www/project/tests/Features/Datasets.php', 'inside' => true], -]); - -it('computes the dataset scope', function (string $file, string $scope) { - expect(DatasetInfo::scope($file))->toBe($scope); -})->with([ - ['file' => '/var/www/project/tests/Datasets/Numbers.php', 'scope' => '/var/www/project/tests'], - ['file' => '/var/www/project/tests/Datasets.php', 'scope' => '/var/www/project/tests'], - ['file' => '/var/www/project/tests/Features/Datasets/Numbers.php', 'scope' => '/var/www/project/tests/Features'], - ['file' => '/var/www/project/tests/Features/Numbers.php', 'scope' => '/var/www/project/tests/Features/Numbers.php'], - ['file' => '/var/www/project/tests/Features/Datasets.php', 'scope' => '/var/www/project/tests/Features'], - ['file' => '/var/www/project/tests/Features/Controllers/Datasets/Numbers.php', 'scope' => '/var/www/project/tests/Features/Controllers'], - ['file' => '/var/www/project/tests/Features/Controllers/Numbers.php', 'scope' => '/var/www/project/tests/Features/Controllers/Numbers.php'], - ['file' => '/var/www/project/tests/Features/Controllers/Datasets.php', 'scope' => '/var/www/project/tests/Features/Controllers'], -]); diff --git a/tests/Visual/Parallel.php b/tests/Visual/Parallel.php index 3dad50db..d17e694e 100644 --- a/tests/Visual/Parallel.php +++ b/tests/Visual/Parallel.php @@ -16,7 +16,7 @@ $run = function () { test('parallel', function () use ($run) { expect($run('--exclude-group=integration')) - ->toContain('Tests: 1 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 16 skipped, 999 passed (2360 assertions)') + ->toContain('Tests: 1 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 16 skipped, 973 passed (2334 assertions)') ->toContain('Parallel: 3 processes'); })->skipOnWindows();