From fa33632958f44c4b2eba668a7da1e156370e4f10 Mon Sep 17 00:00:00 2001 From: Bruce Weirdan Date: Tue, 4 Jan 2022 10:25:00 +0200 Subject: [PATCH 1/4] Bump PHP version to 7.4 Also exclude 8.2+ for now - we don't know if current Psalm version would be compatible with that. --- .github/workflows/ci.yml | 2 +- composer.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8ae030d4f46..b9b7d2edcfc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,7 +9,7 @@ jobs: - name: Set up PHP uses: shivammathur/setup-php@v2 with: - php-version: '7.1' + php-version: '7.4' tools: composer:v2 coverage: none diff --git a/composer.json b/composer.json index 67e1687a34e..db1cd2a84db 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,7 @@ } ], "require": { - "php": "^7.1|^8", + "php": "^7.4 || ~8.0.0 || ~8.1.0", "ext-SimpleXML": "*", "ext-ctype": "*", "ext-dom": "*", From 20567ff72067c50686d97def7365542af202802f Mon Sep 17 00:00:00 2001 From: Bruce Weirdan Date: Tue, 4 Jan 2022 11:29:00 +0200 Subject: [PATCH 2/4] Remove the polyfill we no longer need --- composer.json | 5 +--- psalm.xml.dist | 1 - src/spl_object_id.php | 54 ------------------------------------------- 3 files changed, 1 insertion(+), 59 deletions(-) delete mode 100644 src/spl_object_id.php diff --git a/composer.json b/composer.json index db1cd2a84db..93fd17b9f01 100644 --- a/composer.json +++ b/composer.json @@ -80,10 +80,7 @@ "autoload": { "psr-4": { "Psalm\\": "src/Psalm/" - }, - "files": [ - "src/spl_object_id.php" - ] + } }, "autoload-dev": { "psr-4": { diff --git a/psalm.xml.dist b/psalm.xml.dist index 0343b7cb1fc..c1ddfa58bf3 100644 --- a/psalm.xml.dist +++ b/psalm.xml.dist @@ -34,7 +34,6 @@ - diff --git a/src/spl_object_id.php b/src/spl_object_id.php deleted file mode 100644 index 8b30da94ab3..00000000000 --- a/src/spl_object_id.php +++ /dev/null @@ -1,54 +0,0 @@ -isUserDefined()) { - /** - * See https://github.com/runkit7/runkit_object_id for a faster native version for php <= 7.1 - * - * @param object $object - * @return int The object id - */ - function spl_object_id($object): int - { - return runkit_object_id($object); - } - } elseif (PHP_INT_SIZE === 8) { - /** - * See https://github.com/runkit7/runkit_object_id for a faster native version for php <= 7.1 - * - * @param object $object - * @return int (The object id, XORed with a random number) - */ - function spl_object_id($object): int - { - $hash = spl_object_hash($object); - // Fit this into a php long (32-bit or 64-bit signed int). - // The first 16 hex digits (64 bytes) vary, the last 16 don't. - // Values are usually padded with 0s at the front. - return intval(substr($hash, 1, 15), 16); - } - } else { - /** - * See https://github.com/runkit7/runkit_object_id for a faster native version for php <= 7.1 - * - * @param object $object - * @return int (The object id, XORed with a random number) - */ - function spl_object_id($object): int - { - $hash = spl_object_hash($object); - // Fit this into a php long (32-bit or 64-bit signed int). - // The first 16 hex digits (64 bytes) vary, the last 16 don't. - // Values are usually padded with 0s at the front. - return intval(substr($hash, 9, 7), 16); - } - } -} From cf962eebc2a1fe39e939321c4efa136411875939 Mon Sep 17 00:00:00 2001 From: Bruce Weirdan Date: Tue, 4 Jan 2022 11:40:55 +0200 Subject: [PATCH 3/4] Promote conditional tests to always-running --- tests/ClosureTest.php | 16 ++++++++-------- tests/FunctionCallTest.php | 12 ++++++------ tests/Traits/InvalidCodeAnalysisTestTrait.php | 6 +----- tests/Traits/ValidCodeAnalysisTestTrait.php | 14 +------------- tests/TypeReconciliation/ConditionalTest.php | 2 +- 5 files changed, 17 insertions(+), 33 deletions(-) diff --git a/tests/ClosureTest.php b/tests/ClosureTest.php index 64a17a53d28..a9291d88923 100644 --- a/tests/ClosureTest.php +++ b/tests/ClosureTest.php @@ -330,7 +330,7 @@ public function callTheInvokableIndirectly(): bool { } }', ], - 'PHP71-mirrorCallableParams' => [ + 'mirrorCallableParams' => [ ' [ + 'closureFromCallableInvokableNamedClass' => [ ' [ + 'closureFromCallableInvokableAnonymousClass' => [ ' [ + 'publicCallableFromInside' => [ ' [ + 'protectedCallableFromInside' => [ ' [ + 'closureFromCallableNamedFunction' => [ ' 'TypeDoesNotContainType', ], - 'PHP71-closureFromCallableInvokableNamedClassWrongArgs' => [ + 'closureFromCallableInvokableNamedClassWrongArgs' => [ ' 'DuplicateParam', ], - 'PHP71-privateCallable' => [ + 'privateCallable' => [ ' 'int', ], ], - 'PHP73-hrtime' => [ + 'hrtime' => [ ' 'array{0: int, 1: int}', ], ], - 'PHP73-hrtimeCanBeFloat' => [ + 'hrtimeCanBeFloat' => [ ' [ + 'allowIsCountableToInformType' => [ ' 'array', ], ], - 'PHP72-pregMatchWithFlagUnmatchedAsNull' => [ + 'pregMatchWithFlagUnmatchedAsNull' => [ ' [ @@ -1353,7 +1353,7 @@ function takesInt(int $i) : void {} '$matches===' => 'array', ], ], - 'PHP72-pregMatchWithFlagOffsetCaptureAndUnmatchedAsNull' => [ + 'pregMatchWithFlagOffsetCaptureAndUnmatchedAsNull' => [ ' [ @@ -1399,7 +1399,7 @@ function foo(int $a, string $b, bool $c) : array { return compact("a", "b", "c"); }', ], - 'PHP73-setCookiePhp73' => [ + 'setCookiePhp73' => [ 'getTestName(); - if (strpos($test_name, 'PHP71-') !== false) { - if (version_compare(PHP_VERSION, '7.1.0', '<')) { - $this->markTestSkipped('Test case requires PHP 7.1.'); - } - } elseif (strpos($test_name, 'PHP80-') !== false) { + if (strpos($test_name, 'PHP80-') !== false) { if (version_compare(PHP_VERSION, '8.0.0', '<')) { $this->markTestSkipped('Test case requires PHP 8.0.'); } diff --git a/tests/Traits/ValidCodeAnalysisTestTrait.php b/tests/Traits/ValidCodeAnalysisTestTrait.php index 46a57ac4a22..0bef93d31b8 100644 --- a/tests/Traits/ValidCodeAnalysisTestTrait.php +++ b/tests/Traits/ValidCodeAnalysisTestTrait.php @@ -39,19 +39,7 @@ public function testValidCode( string $php_version = '7.3' ): void { $test_name = $this->getTestName(); - if (strpos($test_name, 'PHP71-') !== false) { - if (version_compare(PHP_VERSION, '7.1.0', '<')) { - $this->markTestSkipped('Test case requires PHP 7.1.'); - } - } elseif (strpos($test_name, 'PHP72-') !== false) { - if (version_compare(PHP_VERSION, '7.2.0', '<')) { - $this->markTestSkipped('Test case requires PHP 7.2.'); - } - } elseif (strpos($test_name, 'PHP73-') !== false) { - if (version_compare(PHP_VERSION, '7.3.0', '<')) { - $this->markTestSkipped('Test case requires PHP 7.3.'); - } - } elseif (strpos($test_name, 'PHP80-') !== false) { + if (strpos($test_name, 'PHP80-') !== false) { if (version_compare(PHP_VERSION, '8.0.0', '<')) { $this->markTestSkipped('Test case requires PHP 8.0.'); } diff --git a/tests/TypeReconciliation/ConditionalTest.php b/tests/TypeReconciliation/ConditionalTest.php index 670c3bb138f..a786b2ca64c 100644 --- a/tests/TypeReconciliation/ConditionalTest.php +++ b/tests/TypeReconciliation/ConditionalTest.php @@ -1006,7 +1006,7 @@ function f() { return rand(0,1) ? "f" : 1.1; } atan($a); atan($b);', ], - 'PHP71-removeNonCallable' => [ + 'removeNonCallable' => [ ' Date: Tue, 4 Jan 2022 12:43:12 +0200 Subject: [PATCH 4/4] Tighten dependency ranges --- composer.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index 93fd17b9f01..6cc57bf5284 100644 --- a/composer.json +++ b/composer.json @@ -28,12 +28,12 @@ "composer/semver": "^1.4 || ^2.0 || ^3.0", "composer/xdebug-handler": "^1.1 || ^2.0 || ^3.0", "dnoegel/php-xdg-base-dir": "^0.1.1", - "felixfbecker/advanced-json-rpc": "^3.0.3", + "felixfbecker/advanced-json-rpc": "^3.1", "felixfbecker/language-server-protocol": "^1.5", "netresearch/jsonmapper": "^1.0 || ^2.0 || ^3.0 || ^4.0", "nikic/php-parser": "^4.13", "openlss/lib-array2xml": "^1.0", - "sebastian/diff": "^3.0 || ^4.0", + "sebastian/diff": "^4.0", "symfony/console": "^3.4.17 || ^4.1.6 || ^5.0 || ^6.0", "webmozart/path-util": "^2.3" }, @@ -42,16 +42,16 @@ }, "require-dev": { "ext-curl": "*", - "bamarni/composer-bin-plugin": "^1.2", + "bamarni/composer-bin-plugin": "^1.4", "brianium/paratest": "^4.0||^6.0", "php-parallel-lint/php-parallel-lint": "^1.2", "phpdocumentor/reflection-docblock": "^5", "phpmyadmin/sql-parser": "5.1.0||dev-master", - "phpspec/prophecy": ">=1.9.0", + "phpspec/prophecy": ">=1.10.2", "phpunit/phpunit": "^9.0", "psalm/plugin-phpunit": "^0.16.1", "slevomat/coding-standard": "^7.0", - "squizlabs/php_codesniffer": "^3.5", + "squizlabs/php_codesniffer": "^3.6", "symfony/process": "^4.3 || ^5.0 || ^6.0", "weirdan/prophecy-shim": "^1.0 || ^2.0" },