Skip to content

Commit

Permalink
Use PHP_VERSION_ID instead of version_compare()
Browse files Browse the repository at this point in the history
As we do elsewhere
  • Loading branch information
weirdan committed Mar 3, 2024
1 parent 64a3272 commit 87e2af4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
5 changes: 2 additions & 3 deletions tests/Traits/InvalidCodeAnalysisTestTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@
use function strpos;
use function strtoupper;
use function substr;
use function version_compare;

use const PHP_OS;
use const PHP_VERSION;
use const PHP_VERSION_ID;

/**
* @psalm-type DeprecatedDataProviderArrayNotation = array{
Expand Down Expand Up @@ -53,7 +52,7 @@ public function testInvalidCode(
): void {
$test_name = $this->getTestName();
if (strpos($test_name, 'PHP80-') !== false) {
if (version_compare(PHP_VERSION, '8.0.0', '<')) {
if (PHP_VERSION_ID < 8_00_00) {
$this->markTestSkipped('Test case requires PHP 8.0.');
}

Expand Down
7 changes: 3 additions & 4 deletions tests/Traits/ValidCodeAnalysisTestTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@
use function strpos;
use function strtoupper;
use function substr;
use function version_compare;

use const PHP_OS;
use const PHP_VERSION;
use const PHP_VERSION_ID;

trait ValidCodeAnalysisTestTrait
{
Expand Down Expand Up @@ -44,15 +43,15 @@ public function testValidCode(
): void {
$test_name = $this->getTestName();
if (strpos($test_name, 'PHP80-') !== false) {
if (version_compare(PHP_VERSION, '8.0.0', '<')) {
if (PHP_VERSION_ID < 8_00_00) {
$this->markTestSkipped('Test case requires PHP 8.0.');
}

if ($php_version === null) {
$php_version = '8.0';
}
} elseif (strpos($test_name, 'PHP81-') !== false) {
if (version_compare(PHP_VERSION, '8.1.0', '<')) {
if (PHP_VERSION_ID < 8_01_00) {
$this->markTestSkipped('Test case requires PHP 8.1.');
}

Expand Down

0 comments on commit 87e2af4

Please sign in to comment.