diff --git a/src/Runner/Version.php b/src/Runner/Version.php index 59ddf15011d..3bfaaf163bf 100644 --- a/src/Runner/Version.php +++ b/src/Runner/Version.php @@ -51,6 +51,11 @@ public static function series(): string return implode('.', array_slice(explode('.', $version), 0, 2)); } + public static function majorVersionNumber(): int + { + return (int) explode('.', self::series())[0]; + } + public static function getVersionString(): string { return 'PHPUnit ' . self::id() . ' by Sebastian Bergmann and contributors.'; diff --git a/src/TextUI/Command/Commands/VersionCheckCommand.php b/src/TextUI/Command/Commands/VersionCheckCommand.php index bdb135dc21c..30a3c56ac3d 100644 --- a/src/TextUI/Command/Commands/VersionCheckCommand.php +++ b/src/TextUI/Command/Commands/VersionCheckCommand.php @@ -9,7 +9,6 @@ */ namespace PHPUnit\TextUI\Command; -use function explode; use function file_get_contents; use function sprintf; use function version_compare; @@ -25,7 +24,7 @@ final class VersionCheckCommand implements Command public function execute(): Result { $latestVersion = file_get_contents('https://phar.phpunit.de/latest-version-of/phpunit'); - $latestCompatibleVersion = file_get_contents('https://phar.phpunit.de/latest-version-of/phpunit-' . explode('.', Version::series())[0]); + $latestCompatibleVersion = file_get_contents('https://phar.phpunit.de/latest-version-of/phpunit-' . Version::majorVersionNumber()); $notLatest = version_compare($latestVersion, Version::id(), '>'); $notLatestCompatible = version_compare($latestCompatibleVersion, Version::id(), '>');