Skip to content

Commit d1dee90

Browse files
committed
bug #760 only use attributes if PHP >= 8 && Symfony >= 5.2 (jrushlow)
This PR was squashed before being merged into the 1.0-dev branch. Discussion ---------- only use attributes if PHP >= 8 && Symfony >= 5.2 fixes #750 Commits ------- 4dd942f only use attributes if PHP >= 8 && Symfony >= 5.2
2 parents 3fcd887 + 4dd942f commit d1dee90

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/Util/PhpCompatUtil.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Bundle\MakerBundle\Util;
1313

1414
use Symfony\Bundle\MakerBundle\FileManager;
15+
use Symfony\Component\HttpKernel\Kernel;
1516

1617
/**
1718
* @author Jesse Rushlow <[email protected]>
@@ -32,7 +33,7 @@ public function canUseAttributes(): bool
3233
{
3334
$version = $this->getPhpVersion();
3435

35-
return version_compare($version, '8alpha', '>=');
36+
return version_compare($version, '8alpha', '>=') && Kernel::VERSION_ID >= 50200;
3637
}
3738

3839
protected function getPhpVersion(): string

tests/Util/PhpVersionTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Bundle\MakerBundle\FileManager;
1616
use Symfony\Bundle\MakerBundle\Util\PhpCompatUtil;
17+
use Symfony\Component\HttpKernel\Kernel;
1718

1819
/**
1920
* @author Jesse Rushlow <[email protected]>
@@ -52,6 +53,15 @@ public function testUsesPhpPlatformFromComposerJsonFile(string $version, bool $e
5253

5354
$result = $version->canUseAttributes();
5455

56+
/*
57+
* Symfony 5.2 is required to compare the result. Otherwise it will always
58+
* return false regardless of the PHP Version. If the test suite is run w/
59+
* Symfony < 5.2, we assert false here but still rely on the assertions above.
60+
*/
61+
if (Kernel::VERSION_ID < 50200) {
62+
$expectedResult = false;
63+
}
64+
5565
self::assertSame($expectedResult, $result);
5666
}
5767

0 commit comments

Comments
 (0)