Browse Source

Allow execution under PHP 8

Dariusz Ruminski 4 years ago
parent
commit
1006d53fde
3 changed files with 30 additions and 7 deletions
  1. 0 2
      .github/workflows/ci.yml
  2. 2 2
      php-cs-fixer
  3. 28 3
      tests/AutoReview/CiConfigurationTest.php

+ 0 - 2
.github/workflows/ci.yml

@@ -53,7 +53,6 @@ jobs:
           - operating-system: 'ubuntu-20.04'
             php-version: '8.0'
             composer-flags: '--ignore-platform-req=php' # as this is a version not yet officially supported by PHP CS Fixer
-            PHP_CS_FIXER_IGNORE_ENV: 1
 
           - operating-system: 'windows-latest'
             php-version: '7.4'
@@ -127,7 +126,6 @@ jobs:
         run: sed 's/enforceTimeLimit="true"/enforceTimeLimit="false"/g' phpunit.xml.dist > phpunit.xml
 
       - name: Run tests
-        continue-on-error: ${{ matrix.php-version == '8.0' }}
         env:
           PHP_CS_FIXER_IGNORE_ENV: ${{ matrix.PHP_CS_FIXER_IGNORE_ENV }}
           FAST_LINT_TEST_CASES: ${{ matrix.FAST_LINT_TEST_CASES }}

+ 2 - 2
php-cs-fixer

@@ -23,8 +23,8 @@ if (defined('HHVM_VERSION_ID')) {
     } else {
         exit(1);
     }
-} elseif (!defined('PHP_VERSION_ID') || \PHP_VERSION_ID < 50600 || \PHP_VERSION_ID >= 70500) {
-    fwrite(STDERR, "PHP needs to be a minimum version of PHP 5.6.0 and maximum version of PHP 7.4.*.\n");
+} elseif (!defined('PHP_VERSION_ID') || \PHP_VERSION_ID < 50600 || \PHP_VERSION_ID >= 80100) {
+    fwrite(STDERR, "PHP needs to be a minimum version of PHP 5.6.0 and maximum version of PHP 8.0.*.\n");
     fwrite(STDERR, 'Current PHP version: '.PHP_VERSION.".\n");
 
     if (defined('PHP_VERSION_ID') && \PHP_VERSION_ID === 80000) {

+ 28 - 3
tests/AutoReview/CiConfigurationTest.php

@@ -40,10 +40,20 @@ final class CiConfigurationTest extends TestCase
             $supportedVersions[] = '5.6';
         }
 
-        for ($version = $supportedMinPhp; $version <= $supportedMaxPhp; $version += 0.1) {
-            $supportedVersions[] = sprintf('%.1f', $version);
+        if ($supportedMaxPhp >= 8) {
+            $supportedVersions = array_merge(
+                $supportedVersions,
+                self::generateMinorVersionsRange($supportedMinPhp, 7.4)
+            );
+
+            $supportedMinPhp = 8;
         }
 
+        $supportedVersions = array_merge(
+            $supportedVersions,
+            self::generateMinorVersionsRange($supportedMinPhp, $supportedMaxPhp)
+        );
+
         $ciVersions = $this->getAllPhpVersionsUsedByCiForTests();
 
         static::assertGreaterThanOrEqual(1, \count($ciVersions));
@@ -56,7 +66,7 @@ final class CiConfigurationTest extends TestCase
     {
         $ciVersionsForDeployments = $this->getAllPhpVersionsUsedByCiForDeployments();
         $ciVersions = $this->getAllPhpVersionsUsedByCiForTests();
-        $expectedPhp = $this->getMaxPhpVersionFromEntryFile();
+        $expectedPhp = '7.4'; // can't run dev-tools on 8.0 yet; $this->getMaxPhpVersionFromEntryFile();
 
         if (\in_array($expectedPhp.'snapshot', $ciVersions, true)) {
             // last version of used PHP is snapshot. we should test against previous one, that is stable
@@ -74,6 +84,17 @@ final class CiConfigurationTest extends TestCase
         }
     }
 
+    private static function generateMinorVersionsRange($from, $to)
+    {
+        $range = [];
+
+        for ($version = $from; $version <= $to; $version += 0.1) {
+            $range[] = sprintf('%.1f', $version);
+        }
+
+        return $range;
+    }
+
     private static function ensureTraversableContainsIsAvailable()
     {
         if (!class_exists(TraversableContains::class)) {
@@ -93,6 +114,10 @@ final class CiConfigurationTest extends TestCase
 
     private static function assertUpcomingPhpVersionIsCoveredByCiJob($lastSupportedVersion, array $ciVersions)
     {
+        if ('8.0' === $lastSupportedVersion) {
+            return; // no further releases available yet
+        }
+
         self::ensureTraversableContainsIsAvailable();
 
         static::assertThat($ciVersions, static::logicalOr(