Skip to content

Commit 6b0162e

Browse files
Improve output of --check-version CLI option
1 parent 6d70c68 commit 6b0162e

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

src/TextUI/Command.php

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,17 +1142,31 @@ protected function handleVersionCheck(): void
11421142
{
11431143
$this->printVersionString();
11441144

1145-
$latestVersion = file_get_contents('https://phar.phpunit.de/latest-version-of/phpunit');
1146-
$isOutdated = version_compare($latestVersion, Version::id(), '>');
1145+
$latestVersion = file_get_contents('https://phar.phpunit.de/latest-version-of/phpunit');
1146+
$latestCompatibleVersion = file_get_contents('https://phar.phpunit.de/latest-version-of/phpunit-' . explode('.', Version::series())[0]);
11471147

1148-
if ($isOutdated) {
1148+
$notLatest = version_compare($latestVersion, Version::id(), '>');
1149+
$notLatestCompatible = version_compare($latestCompatibleVersion, Version::id(), '>');
1150+
1151+
if ($notLatest || $notLatestCompatible) {
1152+
print 'You are not using the latest version of PHPUnit.' . PHP_EOL;
1153+
} else {
1154+
print 'You are using the latest version of PHPUnit.' . PHP_EOL;
1155+
}
1156+
1157+
if ($notLatestCompatible) {
1158+
printf(
1159+
'The latest version compatible with PHPUnit %s is PHPUnit %s.' . PHP_EOL,
1160+
Version::id(),
1161+
$latestCompatibleVersion
1162+
);
1163+
}
1164+
1165+
if ($notLatest) {
11491166
printf(
1150-
'You are not using the latest version of PHPUnit.' . PHP_EOL .
11511167
'The latest version is PHPUnit %s.' . PHP_EOL,
11521168
$latestVersion
11531169
);
1154-
} else {
1155-
print 'You are using the latest version of PHPUnit.' . PHP_EOL;
11561170
}
11571171

11581172
exit(TestRunner::SUCCESS_EXIT);

0 commit comments

Comments
 (0)