Skip to content

Commit 7625bf1

Browse files
committed
print composer.json version only if phpVersion in phpstan.neon is int or null
1 parent 1ec3046 commit 7625bf1

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

src/Diagnose/PHPStanDiagnoseExtension.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -54,23 +54,6 @@ public function print(Output $output): void
5454
$phpRuntimeVersion->getVersionString(),
5555
));
5656

57-
$minComposerPhpVersion = $this->composerPhpVersionFactory->getMinVersion();
58-
$maxComposerPhpVersion = $this->composerPhpVersionFactory->getMaxVersion();
59-
if ($minComposerPhpVersion !== null && $maxComposerPhpVersion !== null) {
60-
if ($minComposerPhpVersion->getVersionId() !== $maxComposerPhpVersion->getVersionId()) {
61-
$output->writeLineFormatted(sprintf(
62-
'<info>PHP composer.json required version:</info> %s-%s',
63-
$minComposerPhpVersion->getVersionString(),
64-
$maxComposerPhpVersion->getVersionString(),
65-
));
66-
} else {
67-
$output->writeLineFormatted(sprintf(
68-
'<info>PHP composer.json required version:</info> %s',
69-
$minComposerPhpVersion->getVersionString(),
70-
));
71-
}
72-
}
73-
7457
if (
7558
$this->phpVersion->getSource() === PhpVersion::SOURCE_CONFIG
7659
&& is_array($this->configPhpVersion)
@@ -86,6 +69,23 @@ public function print(Output $output): void
8669
));
8770

8871
} else {
72+
$minComposerPhpVersion = $this->composerPhpVersionFactory->getMinVersion();
73+
$maxComposerPhpVersion = $this->composerPhpVersionFactory->getMaxVersion();
74+
if ($minComposerPhpVersion !== null && $maxComposerPhpVersion !== null) {
75+
if ($minComposerPhpVersion->getVersionId() !== $maxComposerPhpVersion->getVersionId()) {
76+
$output->writeLineFormatted(sprintf(
77+
'<info>PHP composer.json required version:</info> %s-%s',
78+
$minComposerPhpVersion->getVersionString(),
79+
$maxComposerPhpVersion->getVersionString(),
80+
));
81+
} else {
82+
$output->writeLineFormatted(sprintf(
83+
'<info>PHP composer.json required version:</info> %s',
84+
$minComposerPhpVersion->getVersionString(),
85+
));
86+
}
87+
}
88+
8989
$output->writeLineFormatted(sprintf(
9090
'<info>PHP version for analysis:</info> %s (from %s)',
9191
$this->phpVersion->getVersionString(),

0 commit comments

Comments
 (0)