Skip to content

Commit

Permalink
Allow execution under PHP 8
Browse files Browse the repository at this point in the history
  • Loading branch information
keradus committed Jan 18, 2021
1 parent ad2c5c7 commit 1006d53
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 7 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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 }}
Expand Down
4 changes: 2 additions & 2 deletions php-cs-fixer
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
31 changes: 28 additions & 3 deletions tests/AutoReview/CiConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,20 @@ public function testTestJobsRunOnEachPhp()
$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));
Expand All @@ -56,7 +66,7 @@ public function testDeploymentJobsRunOnLatestStablePhpThatIsSupportedByTool()
{
$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
Expand All @@ -74,6 +84,17 @@ public function testDeploymentJobsRunOnLatestStablePhpThatIsSupportedByTool()
}
}

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)) {
Expand All @@ -93,6 +114,10 @@ private static function ensureTraversableContainsIsAvailable()

private static function assertUpcomingPhpVersionIsCoveredByCiJob($lastSupportedVersion, array $ciVersions)
{
if ('8.0' === $lastSupportedVersion) {
return; // no further releases available yet
}

self::ensureTraversableContainsIsAvailable();

static::assertThat($ciVersions, static::logicalOr(
Expand Down

0 comments on commit 1006d53

Please sign in to comment.