From a8f0a7f0513844b706a283ce6694eec7f80f6ec9 Mon Sep 17 00:00:00 2001 From: Ondrej Mirtes Date: Sun, 13 Jun 2021 15:19:30 +0200 Subject: [PATCH 1/3] Build on PHP 8.1 --- .github/workflows/lint.yml | 1 + .github/workflows/static-analysis.yml | 1 + .github/workflows/tests.yml | 1 + conf/config.neon | 2 +- src/Php/PhpVersionFactory.php | 2 +- tests/PHPStan/Php/PhpVersionFactoryTest.php | 16 ++++++++++++++-- 6 files changed, 19 insertions(+), 4 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 22c3bd4f36..9b28208a5c 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -25,6 +25,7 @@ jobs: - "7.3" - "7.4" - "8.0" + - "8.1" steps: - name: "Checkout" diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 7e829b1f7b..225a488077 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -25,6 +25,7 @@ jobs: - "7.3" - "7.4" - "8.0" + - "8.1" operating-system: [ubuntu-latest, windows-latest] script: - "make phpstan" diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 63439d983c..7d5c0b86d8 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -23,6 +23,7 @@ jobs: - "7.3" - "7.4" - "8.0" + - "8.1" operating-system: [ ubuntu-latest, windows-latest ] script: - "make tests" diff --git a/conf/config.neon b/conf/config.neon index aa13516293..8855892b6f 100644 --- a/conf/config.neon +++ b/conf/config.neon @@ -256,7 +256,7 @@ parametersSchema: minimumNumberOfJobsPerProcess: int(), buffer: int() ]) - phpVersion: schema(anyOf(schema(int(), min(70100), max(80099))), nullable()) + phpVersion: schema(anyOf(schema(int(), min(70100), max(80199))), nullable()) polluteScopeWithLoopInitialAssignments: bool() polluteScopeWithAlwaysIterableForeach: bool() polluteCatchScopeWithTryAssignments: bool() diff --git a/src/Php/PhpVersionFactory.php b/src/Php/PhpVersionFactory.php index 8d726313fd..6923cf467d 100644 --- a/src/Php/PhpVersionFactory.php +++ b/src/Php/PhpVersionFactory.php @@ -27,7 +27,7 @@ public function create(): PhpVersion $parts = explode('.', $this->composerPhpVersion); $tmp = (int) $parts[0] * 10000 + (int) ($parts[1] ?? 0) * 100 + (int) ($parts[2] ?? 0); $tmp = max($tmp, 70100); - $versionId = min($tmp, 80099); + $versionId = min($tmp, 80199); } if ($versionId === null) { diff --git a/tests/PHPStan/Php/PhpVersionFactoryTest.php b/tests/PHPStan/Php/PhpVersionFactoryTest.php index ad255411b9..4f581524c2 100644 --- a/tests/PHPStan/Php/PhpVersionFactoryTest.php +++ b/tests/PHPStan/Php/PhpVersionFactoryTest.php @@ -55,8 +55,14 @@ public function dataCreate(): array [ null, '8.1', - 80099, - '8.0.99', + 80100, + '8.1', + ], + [ + null, + '8.2', + 80199, + '8.1.99', ], [ null, @@ -64,6 +70,12 @@ public function dataCreate(): array 80095, '8.0.95', ], + [ + null, + '8.1.2', + 80102, + '8.1.2', + ], ]; } From 0932c7be7fd0c3ec338c799dcbd5a40cd2284032 Mon Sep 17 00:00:00 2001 From: Ondrej Mirtes Date: Sun, 13 Jun 2021 15:41:31 +0200 Subject: [PATCH 2/3] Fix --- tests/PHPStan/Analyser/NodeScopeResolverTest.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/PHPStan/Analyser/NodeScopeResolverTest.php b/tests/PHPStan/Analyser/NodeScopeResolverTest.php index 0fa1d535f4..7f91ed430f 100644 --- a/tests/PHPStan/Analyser/NodeScopeResolverTest.php +++ b/tests/PHPStan/Analyser/NodeScopeResolverTest.php @@ -311,9 +311,11 @@ public function dataFileAsserts(): iterable yield from $this->gatherAssertTypes(__DIR__ . '/data/throw-points/while.php'); yield from $this->gatherAssertTypes(__DIR__ . '/data/throw-points/try-catch.php'); yield from $this->gatherAssertTypes(__DIR__ . '/data/phpdoc-pseudotype-override.php'); - require_once __DIR__ . '/data/phpdoc-pseudotype-namespace.php'; - yield from $this->gatherAssertTypes(__DIR__ . '/data/phpdoc-pseudotype-namespace.php'); + if (PHP_VERSION_ID < 80100) { + require_once __DIR__ . '/data/phpdoc-pseudotype-namespace.php'; + yield from $this->gatherAssertTypes(__DIR__ . '/data/phpdoc-pseudotype-namespace.php'); + } yield from $this->gatherAssertTypes(__DIR__ . '/data/phpdoc-pseudotype-global.php'); yield from $this->gatherAssertTypes(__DIR__ . '/data/generic-traits.php'); yield from $this->gatherAssertTypes(__DIR__ . '/data/bug-4423.php'); From 4daf10b68cbaab51737530c73f1d9bde13ddb9fe Mon Sep 17 00:00:00 2001 From: Ondrej Mirtes Date: Sun, 13 Jun 2021 15:51:06 +0200 Subject: [PATCH 3/3] Fix --- .github/workflows/lint.yml | 2 +- .github/workflows/static-analysis.yml | 2 +- .github/workflows/tests.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 9b28208a5c..3066ebe929 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -44,7 +44,7 @@ jobs: run: "composer install --no-interaction --no-progress --no-suggest" - name: "Transform source code" - if: matrix.php-version != '7.4' && matrix.php-version != '8.0' + if: matrix.php-version != '7.4' && matrix.php-version != '8.0' && matrix.php-version != '8.1' run: php bin/transform-source.php - name: "Lint" diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 225a488077..f5e5c9571e 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -51,7 +51,7 @@ jobs: run: "composer require --dev phpunit/phpunit:^7.5.20 brianium/paratest:^4.0 --update-with-dependencies" - name: "Transform source code" - if: matrix.php-version != '7.4' && matrix.php-version != '8.0' + if: matrix.php-version != '7.4' && matrix.php-version != '8.0' && matrix.php-version != '8.1' run: php bin/transform-source.php - name: "PHPStan" diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 7d5c0b86d8..fcc2289896 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -47,7 +47,7 @@ jobs: run: "composer install --no-interaction --no-progress --no-suggest" - name: "Transform source code" - if: matrix.php-version != '7.4' && matrix.php-version != '8.0' + if: matrix.php-version != '7.4' && matrix.php-version != '8.0' && matrix.php-version != '8.1' run: php bin/transform-source.php - name: "Tests"