From 9cdb0057bf94dc0f84a66e6989176c560d1d3b51 Mon Sep 17 00:00:00 2001 From: Greg Korba Date: Sat, 17 Feb 2024 21:36:59 +0100 Subject: [PATCH] Introduce PHP compatibility check --- .github/workflows/sca.yml | 3 + .gitignore | 1 + composer.json | 2 + dev-tools/composer.json | 5 +- dev-tools/composer.lock | 530 +++++++++++++++++- .../phpcs-php-compatibility.xml | 26 + tests/AutoReview/CiConfigurationTest.php | 44 +- 7 files changed, 591 insertions(+), 20 deletions(-) create mode 100644 dev-tools/php-compatibility/phpcs-php-compatibility.xml diff --git a/.github/workflows/sca.yml b/.github/workflows/sca.yml index cf5bc97e324..b1917e12389 100644 --- a/.github/workflows/sca.yml +++ b/.github/workflows/sca.yml @@ -70,6 +70,9 @@ jobs: - name: Check - phpstan run: ./dev-tools/vendor/bin/phpstan analyse --ansi + - name: Check - PHP compatibility + run: composer php-compatibility + - name: Check - composer-unused run: ./dev-tools/vendor/bin/composer-unused --no-progress --excludePackage=composer/xdebug-handler diff --git a/.gitignore b/.gitignore index a45dc70858d..37d233c47bd 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ /compose.override.yaml /composer.lock /dev-tools/bin/ +/dev-tools/php-compatibility/cache.json /dev-tools/phpstan/cache/ /dev-tools/vendor/ /php-cs-fixer.phar diff --git a/composer.json b/composer.json index b498074ba92..9319e876262 100644 --- a/composer.json +++ b/composer.json @@ -94,6 +94,7 @@ "@composer normalize --working-dir=dev-tools --dry-run ../composer.json", "@composer normalize --working-dir=dev-tools --dry-run composer.json" ], + "php-compatibility": "@php dev-tools/vendor/bin/phpcs -p --standard=dev-tools/php-compatibility/phpcs-php-compatibility.xml", "phpstan": "@php -d memory_limit=512M dev-tools/vendor/bin/phpstan analyse", "phpstan:baseline": "@php -d memory_limit=512M dev-tools/vendor/bin/phpstan analyse --generate-baseline=./dev-tools/phpstan/baseline.php", "qa": "@quality-assurance", @@ -155,6 +156,7 @@ "install-tools": "Install DEV tools", "mess-detector": "Analyse code with Mess Detector", "normalize": "Run normalization for composer.json files", + "php-compatibility": "Check compatibility with all supported PHP versions", "phpstan": "Run PHPStan analysis", "phpstan:baseline": "Dump PHPStan baseline file - use only for updating, do not add new errors when possible", "post-autoload-dump": "Run additional tasks after installing/updating main dependencies", diff --git a/dev-tools/composer.json b/dev-tools/composer.json index 50181af346c..095d79c99c3 100644 --- a/dev-tools/composer.json +++ b/dev-tools/composer.json @@ -5,6 +5,8 @@ "icanhazstring/composer-unused": "^0.8.11", "maglnet/composer-require-checker": "^4.8.0", "mi-schi/phpmd-extension": "^4.3.0", + "phpcompatibility/php-compatibility": "10.x-dev as 9.99.0", + "phpcompatibility/phpcompatibility-symfony": "^1.2", "phpmd/phpmd": "^2.15.0", "phpstan/extension-installer": "^1.3.1", "phpstan/phpstan": "^1.10.51", @@ -15,7 +17,8 @@ "allow-plugins": { "ergebnis/composer-normalize": true, "infection/extension-installer": false, - "phpstan/extension-installer": true + "phpstan/extension-installer": true, + "dealerdirect/phpcodesniffer-composer-installer": true }, "optimize-autoloader": true, "platform": { diff --git a/dev-tools/composer.lock b/dev-tools/composer.lock index 323a0a9788e..8ff1092ce4b 100644 --- a/dev-tools/composer.lock +++ b/dev-tools/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "218d9b2ee2fe04222a62526c1ff66667", + "content-hash": "c8da1f64962ac185b42b0dc0f07d5264", "packages": [ { "name": "composer-unused/contracts", @@ -260,6 +260,84 @@ ], "time": "2022-02-25T21:32:43+00:00" }, + { + "name": "dealerdirect/phpcodesniffer-composer-installer", + "version": "v1.0.0", + "source": { + "type": "git", + "url": "https://github.com/PHPCSStandards/composer-installer.git", + "reference": "4be43904336affa5c2f70744a348312336afd0da" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPCSStandards/composer-installer/zipball/4be43904336affa5c2f70744a348312336afd0da", + "reference": "4be43904336affa5c2f70744a348312336afd0da", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^1.0 || ^2.0", + "php": ">=5.4", + "squizlabs/php_codesniffer": "^2.0 || ^3.1.0 || ^4.0" + }, + "require-dev": { + "composer/composer": "*", + "ext-json": "*", + "ext-zip": "*", + "php-parallel-lint/php-parallel-lint": "^1.3.1", + "phpcompatibility/php-compatibility": "^9.0", + "yoast/phpunit-polyfills": "^1.0" + }, + "type": "composer-plugin", + "extra": { + "class": "PHPCSStandards\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin" + }, + "autoload": { + "psr-4": { + "PHPCSStandards\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Franck Nijhof", + "email": "franck.nijhof@dealerdirect.com", + "homepage": "http://www.frenck.nl", + "role": "Developer / IT Manager" + }, + { + "name": "Contributors", + "homepage": "https://github.com/PHPCSStandards/composer-installer/graphs/contributors" + } + ], + "description": "PHP_CodeSniffer Standards Composer Installer Plugin", + "homepage": "http://www.dealerdirect.com", + "keywords": [ + "PHPCodeSniffer", + "PHP_CodeSniffer", + "code quality", + "codesniffer", + "composer", + "installer", + "phpcbf", + "phpcs", + "plugin", + "qa", + "quality", + "standard", + "standards", + "style guide", + "stylecheck", + "tests" + ], + "support": { + "issues": "https://github.com/PHPCSStandards/composer-installer/issues", + "source": "https://github.com/PHPCSStandards/composer-installer" + }, + "time": "2023-01-05T11:28:13+00:00" + }, { "name": "ergebnis/composer-normalize", "version": "2.41.1", @@ -1234,6 +1312,363 @@ ], "time": "2023-12-17T18:09:59+00:00" }, + { + "name": "phpcompatibility/php-compatibility", + "version": "dev-develop", + "source": { + "type": "git", + "url": "https://github.com/PHPCompatibility/PHPCompatibility.git", + "reference": "e5cd2e244097fb62c5ac8f1153a26a73c3a50438" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibility/zipball/e5cd2e244097fb62c5ac8f1153a26a73c3a50438", + "reference": "e5cd2e244097fb62c5ac8f1153a26a73c3a50438", + "shasum": "" + }, + "require": { + "php": ">=5.4", + "phpcsstandards/phpcsutils": "^1.0.9", + "squizlabs/php_codesniffer": "^3.8.0" + }, + "replace": { + "wimg/php-compatibility": "*" + }, + "require-dev": { + "php-parallel-lint/php-console-highlighter": "^1.0.0", + "php-parallel-lint/php-parallel-lint": "^1.3.2", + "phpcsstandards/phpcsdevcs": "^1.1.3", + "phpcsstandards/phpcsdevtools": "^1.2.0", + "phpunit/phpunit": "^4.8.36 || ^5.7.21 || ^6.0 || ^7.0 || ^8.0 || ^9.3.4 || ^10.1.0", + "yoast/phpunit-polyfills": "^1.0.5 || ^2.0.0" + }, + "suggest": { + "roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues." + }, + "default-branch": true, + "type": "phpcodesniffer-standard", + "extra": { + "branch-alias": { + "dev-master": "9.x-dev", + "dev-develop": "10.x-dev" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-3.0-or-later" + ], + "authors": [ + { + "name": "Wim Godden", + "homepage": "https://github.com/wimg", + "role": "lead" + }, + { + "name": "Juliette Reinders Folmer", + "homepage": "https://github.com/jrfnl", + "role": "lead" + }, + { + "name": "Contributors", + "homepage": "https://github.com/PHPCompatibility/PHPCompatibility/graphs/contributors" + } + ], + "description": "A set of sniffs for PHP_CodeSniffer that checks for PHP cross-version compatibility.", + "homepage": "http://techblog.wimgodden.be/tag/codesniffer/", + "keywords": [ + "compatibility", + "phpcs", + "standards", + "static analysis" + ], + "support": { + "issues": "https://github.com/PHPCompatibility/PHPCompatibility/issues", + "security": "https://github.com/PHPCompatibility/PHPCompatibility/security/policy", + "source": "https://github.com/PHPCompatibility/PHPCompatibility" + }, + "funding": [ + { + "url": "https://github.com/PHPCompatibility", + "type": "github" + }, + { + "url": "https://github.com/jrfnl", + "type": "github" + }, + { + "url": "https://opencollective.com/php_codesniffer", + "type": "open_collective" + } + ], + "time": "2024-02-12T16:57:44+00:00" + }, + { + "name": "phpcompatibility/phpcompatibility-paragonie", + "version": "1.3.2", + "source": { + "type": "git", + "url": "https://github.com/PHPCompatibility/PHPCompatibilityParagonie.git", + "reference": "bba5a9dfec7fcfbd679cfaf611d86b4d3759da26" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibilityParagonie/zipball/bba5a9dfec7fcfbd679cfaf611d86b4d3759da26", + "reference": "bba5a9dfec7fcfbd679cfaf611d86b4d3759da26", + "shasum": "" + }, + "require": { + "phpcompatibility/php-compatibility": "^9.0" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.7", + "paragonie/random_compat": "dev-master", + "paragonie/sodium_compat": "dev-master" + }, + "suggest": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.7 || This Composer plugin will sort out the PHP_CodeSniffer 'installed_paths' automatically.", + "roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues." + }, + "type": "phpcodesniffer-standard", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-3.0-or-later" + ], + "authors": [ + { + "name": "Wim Godden", + "role": "lead" + }, + { + "name": "Juliette Reinders Folmer", + "role": "lead" + } + ], + "description": "A set of rulesets for PHP_CodeSniffer to check for PHP cross-version compatibility issues in projects, while accounting for polyfills provided by the Paragonie polyfill libraries.", + "homepage": "http://phpcompatibility.com/", + "keywords": [ + "compatibility", + "paragonie", + "phpcs", + "polyfill", + "standards", + "static analysis" + ], + "support": { + "issues": "https://github.com/PHPCompatibility/PHPCompatibilityParagonie/issues", + "source": "https://github.com/PHPCompatibility/PHPCompatibilityParagonie" + }, + "time": "2022-10-25T01:46:02+00:00" + }, + { + "name": "phpcompatibility/phpcompatibility-passwordcompat", + "version": "1.0.4", + "source": { + "type": "git", + "url": "https://github.com/PHPCompatibility/PHPCompatibilityPasswordCompat.git", + "reference": "b55723509ca46e53e840b02034f3e09d95a40a9a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibilityPasswordCompat/zipball/b55723509ca46e53e840b02034f3e09d95a40a9a", + "reference": "b55723509ca46e53e840b02034f3e09d95a40a9a", + "shasum": "" + }, + "require": { + "phpcompatibility/php-compatibility": "^9.0" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.7", + "ircmaxell/password-compat": "dev-master" + }, + "suggest": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.7 || This Composer plugin will sort out the PHP_CodeSniffer 'installed_paths' automatically.", + "roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues." + }, + "type": "phpcodesniffer-standard", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-3.0-or-later" + ], + "authors": [ + { + "name": "Wim Godden", + "role": "lead" + }, + { + "name": "Juliette Reinders Folmer", + "role": "lead" + } + ], + "description": "A ruleset for PHP_CodeSniffer to check for PHP cross-version compatibility issues in projects, while accounting for polyfills provided by ircmaxell's password_compat library.", + "homepage": "http://phpcompatibility.com/", + "keywords": [ + "compatibility", + "password_compat", + "phpcs", + "polyfill", + "standards", + "static analysis" + ], + "support": { + "issues": "https://github.com/PHPCompatibility/PHPCompatibilityPasswordCompat/issues", + "source": "https://github.com/PHPCompatibility/PHPCompatibilityPasswordCompat" + }, + "time": "2022-10-23T14:40:26+00:00" + }, + { + "name": "phpcompatibility/phpcompatibility-symfony", + "version": "1.2.1", + "source": { + "type": "git", + "url": "https://github.com/PHPCompatibility/PHPCompatibilitySymfony.git", + "reference": "eb694b1f35555d4133b5cd39748f5213564bc386" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibilitySymfony/zipball/eb694b1f35555d4133b5cd39748f5213564bc386", + "reference": "eb694b1f35555d4133b5cd39748f5213564bc386", + "shasum": "" + }, + "require": { + "phpcompatibility/php-compatibility": "^9.0", + "phpcompatibility/phpcompatibility-paragonie": "^1.0", + "phpcompatibility/phpcompatibility-passwordcompat": "^1.0" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.7", + "symfony/polyfill-php54": "1.19", + "symfony/polyfill-php55": "1.19", + "symfony/polyfill-php56": "1.19", + "symfony/polyfill-php70": "1.19", + "symfony/polyfill-php71": "1.19", + "symfony/polyfill-php72": "dev-main", + "symfony/polyfill-php73": "dev-main", + "symfony/polyfill-php74": "dev-main", + "symfony/polyfill-php80": "dev-main" + }, + "suggest": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.7 || This Composer plugin will sort out the PHP_CodeSniffer 'installed_paths' automatically.", + "roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues." + }, + "type": "phpcodesniffer-standard", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-3.0-or-later" + ], + "authors": [ + { + "name": "Wim Godden", + "role": "lead" + }, + { + "name": "Juliette Reinders Folmer", + "role": "lead" + } + ], + "description": "A set of rulesets for PHP_CodeSniffer to check for PHP cross-version compatibility issues in projects, while accounting for polyfills provided by the Symfony polyfill libraries.", + "homepage": "http://phpcompatibility.com/", + "keywords": [ + "compatibility", + "phpcs", + "polyfill", + "standards", + "static analysis", + "symfony" + ], + "support": { + "issues": "https://github.com/PHPCompatibility/PHPCompatibilitySymfony/issues", + "source": "https://github.com/PHPCompatibility/PHPCompatibilitySymfony" + }, + "time": "2022-10-23T15:44:06+00:00" + }, + { + "name": "phpcsstandards/phpcsutils", + "version": "1.0.9", + "source": { + "type": "git", + "url": "https://github.com/PHPCSStandards/PHPCSUtils.git", + "reference": "908247bc65010c7b7541a9551e002db12e9dae70" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPCSStandards/PHPCSUtils/zipball/908247bc65010c7b7541a9551e002db12e9dae70", + "reference": "908247bc65010c7b7541a9551e002db12e9dae70", + "shasum": "" + }, + "require": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.4.1 || ^0.5 || ^0.6.2 || ^0.7 || ^1.0", + "php": ">=5.4", + "squizlabs/php_codesniffer": "^3.8.0 || 4.0.x-dev@dev" + }, + "require-dev": { + "ext-filter": "*", + "php-parallel-lint/php-console-highlighter": "^1.0", + "php-parallel-lint/php-parallel-lint": "^1.3.2", + "phpcsstandards/phpcsdevcs": "^1.1.6", + "yoast/phpunit-polyfills": "^1.1.0 || ^2.0.0" + }, + "type": "phpcodesniffer-standard", + "extra": { + "branch-alias": { + "dev-stable": "1.x-dev", + "dev-develop": "1.x-dev" + } + }, + "autoload": { + "classmap": [ + "PHPCSUtils/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-3.0-or-later" + ], + "authors": [ + { + "name": "Juliette Reinders Folmer", + "homepage": "https://github.com/jrfnl", + "role": "lead" + }, + { + "name": "Contributors", + "homepage": "https://github.com/PHPCSStandards/PHPCSUtils/graphs/contributors" + } + ], + "description": "A suite of utility functions for use with PHP_CodeSniffer", + "homepage": "https://phpcsutils.com/", + "keywords": [ + "PHP_CodeSniffer", + "phpcbf", + "phpcodesniffer-standard", + "phpcs", + "phpcs3", + "standards", + "static analysis", + "tokens", + "utility" + ], + "support": { + "docs": "https://phpcsutils.com/", + "issues": "https://github.com/PHPCSStandards/PHPCSUtils/issues", + "security": "https://github.com/PHPCSStandards/PHPCSUtils/security/policy", + "source": "https://github.com/PHPCSStandards/PHPCSUtils" + }, + "funding": [ + { + "url": "https://github.com/PHPCSStandards", + "type": "github" + }, + { + "url": "https://github.com/jrfnl", + "type": "github" + }, + { + "url": "https://opencollective.com/php_codesniffer", + "type": "open_collective" + } + ], + "time": "2023-12-08T14:50:00+00:00" + }, { "name": "phpmd/phpmd", "version": "2.15.0", @@ -1674,6 +2109,86 @@ }, "time": "2021-07-14T16:46:02+00:00" }, + { + "name": "squizlabs/php_codesniffer", + "version": "3.9.0", + "source": { + "type": "git", + "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", + "reference": "d63cee4890a8afaf86a22e51ad4d97c91dd4579b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/d63cee4890a8afaf86a22e51ad4d97c91dd4579b", + "reference": "d63cee4890a8afaf86a22e51ad4d97c91dd4579b", + "shasum": "" + }, + "require": { + "ext-simplexml": "*", + "ext-tokenizer": "*", + "ext-xmlwriter": "*", + "php": ">=5.4.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.3.4" + }, + "bin": [ + "bin/phpcbf", + "bin/phpcs" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.x-dev" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Greg Sherwood", + "role": "Former lead" + }, + { + "name": "Juliette Reinders Folmer", + "role": "Current lead" + }, + { + "name": "Contributors", + "homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer/graphs/contributors" + } + ], + "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", + "homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer", + "keywords": [ + "phpcs", + "standards", + "static analysis" + ], + "support": { + "issues": "https://github.com/PHPCSStandards/PHP_CodeSniffer/issues", + "security": "https://github.com/PHPCSStandards/PHP_CodeSniffer/security/policy", + "source": "https://github.com/PHPCSStandards/PHP_CodeSniffer", + "wiki": "https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki" + }, + "funding": [ + { + "url": "https://github.com/PHPCSStandards", + "type": "github" + }, + { + "url": "https://github.com/jrfnl", + "type": "github" + }, + { + "url": "https://opencollective.com/php_codesniffer", + "type": "open_collective" + } + ], + "time": "2024-02-16T15:06:51+00:00" + }, { "name": "symfony/config", "version": "v7.0.0", @@ -3386,9 +3901,18 @@ } ], "packages-dev": [], - "aliases": [], + "aliases": [ + { + "package": "phpcompatibility/php-compatibility", + "version": "10.9999999.9999999.9999999-dev", + "alias": "9.99.0", + "alias_normalized": "9.99.0.0" + } + ], "minimum-stability": "stable", - "stability-flags": [], + "stability-flags": { + "phpcompatibility/php-compatibility": 20 + }, "prefer-stable": false, "prefer-lowest": false, "platform": { diff --git a/dev-tools/php-compatibility/phpcs-php-compatibility.xml b/dev-tools/php-compatibility/phpcs-php-compatibility.xml new file mode 100644 index 00000000000..aefaa2700a4 --- /dev/null +++ b/dev-tools/php-compatibility/phpcs-php-compatibility.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + tests/Fixtures/**/* + + + + + + ../../src/ + ../../tests/ + diff --git a/tests/AutoReview/CiConfigurationTest.php b/tests/AutoReview/CiConfigurationTest.php index 0dba7de6509..7a46c93d538 100644 --- a/tests/AutoReview/CiConfigurationTest.php +++ b/tests/AutoReview/CiConfigurationTest.php @@ -45,23 +45,10 @@ public function testThatPhpVersionEnvsAreSetProperly(): void public function testTestJobsRunOnEachPhp(): void { - $supportedVersions = []; $supportedMinPhp = (float) $this->getMinPhpVersionFromEntryFile(); $supportedMaxPhp = (float) $this->getMaxPhpVersionFromEntryFile(); - if ($supportedMaxPhp >= 8) { - $supportedVersions = array_merge( - $supportedVersions, - self::generateMinorVersionsRange($supportedMinPhp, 7.4) - ); - - $supportedMinPhp = 8; - } - - $supportedVersions = [ - ...$supportedVersions, - ...self::generateMinorVersionsRange($supportedMinPhp, $supportedMaxPhp), - ]; + $supportedVersions = self::generateMinorVersionsRange($supportedMinPhp, $supportedMaxPhp); self::assertTrue(\count($supportedVersions) > 0); @@ -73,6 +60,7 @@ public function testTestJobsRunOnEachPhp(): void self::assertUpcomingPhpVersionIsCoveredByCiJob(end($supportedVersions), $ciVersions); self::assertSupportedPhpVersionsAreCoveredByCiJobs($supportedVersions, $this->getPhpVersionsUsedForBuildingOfficialImages()); self::assertSupportedPhpVersionsAreCoveredByCiJobs($supportedVersions, $this->getPhpVersionsUsedForBuildingLocalImages()); + self::assertPhpCompatibilityRangeIsValid($supportedMinPhp, $supportedMaxPhp); } public function testDeploymentJobsRunOnLatestStablePhpThatIsSupportedByTool(): void @@ -103,9 +91,17 @@ public function testDeploymentJobsRunOnLatestStablePhpThatIsSupportedByTool(): v private static function generateMinorVersionsRange(float $from, float $to): array { $range = []; + $lastMinorVersions = [7.4]; + $version = $from; - for ($version = $from; $version <= $to; $version += 0.1) { + while ($version <= $to) { $range[] = sprintf('%.1f', $version); + + if (\in_array($version, $lastMinorVersions, true)) { + $version = ceil($version); + } else { + $version += 0.1; + } } return $range; @@ -162,6 +158,22 @@ private static function assertSupportedPhpVersionsAreCoveredByCiJobs(array $supp )); } + private static function assertPhpCompatibilityRangeIsValid(float $supportedMinPhp, float $supportedMaxPhp): void + { + $matchResult = Preg::match( + '//', + file_get_contents(__DIR__.'/../../dev-tools/php-compatibility/phpcs-php-compatibility.xml'), + $capture + ); + + if (!$matchResult) { + throw new \LogicException('Can\'t parse PHP version range for verifying compatibility.'); + } + + self::assertSame($supportedMinPhp, (float) $capture['min']); + self::assertSame($supportedMaxPhp, (float) $capture['max']); + } + /** * @return array */ @@ -257,7 +269,7 @@ private function getPhpVersionsUsedByGitHub(): array $phpVersions[] = $job['php-version']; } - return $phpVersions; + return array_unique($phpVersions); } /**