From 56528674d502a3e6f98a3c740303bf45e34a9132 Mon Sep 17 00:00:00 2001 From: Ondrej Mirtes Date: Sun, 23 Mar 2025 14:57:01 +0100 Subject: [PATCH 1/6] Remove config.platform --- composer.json | 3 --- 1 file changed, 3 deletions(-) diff --git a/composer.json b/composer.json index 212c518..60ba1e7 100644 --- a/composer.json +++ b/composer.json @@ -19,9 +19,6 @@ "phpunit/phpunit": "^9.6" }, "config": { - "platform": { - "php": "7.4.6" - }, "sort-packages": true }, "extra": { From 81b0e81e4ed449fb1b82e0620c60b53cc641d583 Mon Sep 17 00:00:00 2001 From: Ondrej Mirtes Date: Sun, 23 Mar 2025 14:58:54 +0100 Subject: [PATCH 2/6] Test multiple PHPUnit versions --- .github/workflows/build.yml | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 88543fb..07de108 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -97,6 +97,21 @@ jobs: dependencies: - "lowest" - "highest" + phpunit-version: + - "^9.5" + - "^10.5" + - "^11.5" + exclude: + - php-version: "7.4" + phpunit-version: "^10.5" + - php-version: "8.0" + phpunit-version: "^10.5" + - php-version: "7.4" + phpunit-version: "^11.5" + - php-version: "8.0" + phpunit-version: "^11.5" + - php-version: "8.1" + phpunit-version: "^11.5" steps: - name: "Checkout" @@ -108,6 +123,9 @@ jobs: coverage: "none" php-version: "${{ matrix.php-version }}" + - name: "Require specific PHPUnit version" + run: "composer require --dev phpunit/phpunit:${{ matrix.phpunit-version }}" + - name: "Install lowest dependencies" if: ${{ matrix.dependencies == 'lowest' }} run: "composer update --prefer-lowest --no-interaction --no-progress" @@ -136,6 +154,21 @@ jobs: dependencies: - "lowest" - "highest" + phpunit-version: + - "^9.5" + - "^10.5" + - "^11.5" + exclude: + - php-version: "7.4" + phpunit-version: "^10.5" + - php-version: "8.0" + phpunit-version: "^10.5" + - php-version: "7.4" + phpunit-version: "^11.5" + - php-version: "8.0" + phpunit-version: "^11.5" + - php-version: "8.1" + phpunit-version: "^11.5" steps: - name: "Checkout" @@ -149,6 +182,9 @@ jobs: extensions: mbstring tools: composer:v2 + - name: "Require specific PHPUnit version" + run: "composer require --dev phpunit/phpunit:${{ matrix.phpunit-version }}" + - name: "Install lowest dependencies" if: ${{ matrix.dependencies == 'lowest' }} run: "composer update --prefer-lowest --no-interaction --no-progress" From 54879846ab215f6c9dd3f5641a48e7c135486a40 Mon Sep 17 00:00:00 2001 From: Ondrej Mirtes Date: Sun, 23 Mar 2025 15:05:58 +0100 Subject: [PATCH 3/6] Data providers must be static --- .../PHPUnit/AssertFunctionTypeSpecifyingExtensionTest.php | 6 +++--- .../PHPUnit/AssertMethodTypeSpecifyingExtensionTest.php | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/Type/PHPUnit/AssertFunctionTypeSpecifyingExtensionTest.php b/tests/Type/PHPUnit/AssertFunctionTypeSpecifyingExtensionTest.php index 2d43f8b..4405c4d 100644 --- a/tests/Type/PHPUnit/AssertFunctionTypeSpecifyingExtensionTest.php +++ b/tests/Type/PHPUnit/AssertFunctionTypeSpecifyingExtensionTest.php @@ -9,14 +9,14 @@ class AssertFunctionTypeSpecifyingExtensionTest extends TypeInferenceTestCase { /** @return mixed[] */ - public function dataFileAsserts(): iterable + public static function dataFileAsserts(): iterable { if (function_exists('PHPUnit\\Framework\\assertInstanceOf')) { - yield from $this->gatherAssertTypes(__DIR__ . '/data/assert-function.php'); + yield from self::gatherAssertTypes(__DIR__ . '/data/assert-function.php'); } if (function_exists('PHPUnit\\Framework\\assertObjectHasProperty')) { - yield from $this->gatherAssertTypes(__DIR__ . '/data/assert-function-9.6.11.php'); + yield from self::gatherAssertTypes(__DIR__ . '/data/assert-function-9.6.11.php'); } return []; diff --git a/tests/Type/PHPUnit/AssertMethodTypeSpecifyingExtensionTest.php b/tests/Type/PHPUnit/AssertMethodTypeSpecifyingExtensionTest.php index e1841e0..0b36c2b 100644 --- a/tests/Type/PHPUnit/AssertMethodTypeSpecifyingExtensionTest.php +++ b/tests/Type/PHPUnit/AssertMethodTypeSpecifyingExtensionTest.php @@ -8,9 +8,9 @@ class AssertMethodTypeSpecifyingExtensionTest extends TypeInferenceTestCase { /** @return mixed[] */ - public function dataFileAsserts(): iterable + public static function dataFileAsserts(): iterable { - yield from $this->gatherAssertTypes(__DIR__ . '/data/assert-method.php'); + yield from self::gatherAssertTypes(__DIR__ . '/data/assert-method.php'); } /** From c19563c050f9925f10eb9d2f66be8fc48b65f714 Mon Sep 17 00:00:00 2001 From: Ondrej Mirtes Date: Sun, 23 Mar 2025 15:09:31 +0100 Subject: [PATCH 4/6] Remove deprecated assert --- tests/Type/PHPUnit/data/assert-function.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tests/Type/PHPUnit/data/assert-function.php b/tests/Type/PHPUnit/data/assert-function.php index 851e07b..0fabf59 100644 --- a/tests/Type/PHPUnit/data/assert-function.php +++ b/tests/Type/PHPUnit/data/assert-function.php @@ -53,12 +53,6 @@ public function arrayHasStringKey(array $a, \ArrayAccess $b): void assertType("ArrayAccess", $b); } - public function objectHasAttribute(object $a): void - { - assertObjectHasAttribute('property', $a); - assertType("object&hasProperty(property)", $a); - } - public function testEmpty($a): void { assertEmpty($a); From b013ac92318a7eb5eb072a92f89ef7404d6264c2 Mon Sep 17 00:00:00 2001 From: Ondrej Mirtes Date: Sun, 23 Mar 2025 15:15:12 +0100 Subject: [PATCH 5/6] Do not generate code coverage --- phpunit.xml | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/phpunit.xml b/phpunit.xml index 8f71615..420ef74 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -12,20 +12,6 @@ failOnWarning="true" xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xml" > - - - ./src - - - - - - - tests From 672303b64273e1d7c0386e0ee1a9fdcadb085cf0 Mon Sep 17 00:00:00 2001 From: Ondrej Mirtes Date: Sun, 23 Mar 2025 15:23:33 +0100 Subject: [PATCH 6/6] Always install nikic/php-parser v5 --- composer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/composer.json b/composer.json index 60ba1e7..be6b3bd 100644 --- a/composer.json +++ b/composer.json @@ -13,6 +13,7 @@ "phpunit/phpunit": "<7.0" }, "require-dev": { + "nikic/php-parser": "^5", "php-parallel-lint/php-parallel-lint": "^1.2", "phpstan/phpstan-deprecation-rules": "^2.0", "phpstan/phpstan-strict-rules": "^2.0",