1414use function class_exists ;
1515use function count ;
1616use function dirname ;
17+ use function end ;
1718use function explode ;
1819use function implode ;
1920use function in_array ;
21+ use function is_array ;
2022use function is_file ;
2123use function is_readable ;
24+ use function is_string ;
2225use function sprintf ;
2326use function str_starts_with ;
2427use function strlen ;
@@ -29,11 +32,13 @@ final class PHPStanDiagnoseExtension implements DiagnoseExtension
2932{
3033
3134 /**
35+ * @param int|array{min: int, max: int}|null $configPhpVersion
3236 * @param string[] $composerAutoloaderProjectPaths
3337 * @param string [] $allConfigFiles
3438 */
3539 public function __construct (
3640 private PhpVersion $ phpVersion ,
41+ private int |array |null $ configPhpVersion ,
3742 private FileHelper $ fileHelper ,
3843 private array $ composerAutoloaderProjectPaths ,
3944 private array $ allConfigFiles ,
@@ -57,11 +62,27 @@ public function print(Output $output): void
5762 ));
5863 }
5964
60- $ output ->writeLineFormatted (sprintf (
61- '<info>PHP version for analysis:</info> %s (from %s) ' ,
62- $ this ->phpVersion ->getVersionString (),
63- $ this ->phpVersion ->getSourceLabel (),
64- ));
65+ if (
66+ $ this ->phpVersion ->getSource () === PhpVersion::SOURCE_CONFIG
67+ && is_array ($ this ->configPhpVersion )
68+ ) {
69+ $ minVersion = new PhpVersion ($ this ->configPhpVersion ['min ' ]);
70+ $ maxVersion = new PhpVersion ($ this ->configPhpVersion ['max ' ]);
71+
72+ $ output ->writeLineFormatted (sprintf (
73+ '<info>PHP version for analysis:</info> %s-%s (from %s) ' ,
74+ $ minVersion ->getVersionString (),
75+ $ maxVersion ->getVersionString (),
76+ $ this ->phpVersion ->getSourceLabel (),
77+ ));
78+
79+ } else {
80+ $ output ->writeLineFormatted (sprintf (
81+ '<info>PHP version for analysis:</info> %s (from %s) ' ,
82+ $ this ->phpVersion ->getVersionString (),
83+ $ this ->phpVersion ->getSourceLabel (),
84+ ));
85+ }
6586 $ output ->writeLineFormatted ('' );
6687
6788 $ output ->writeLineFormatted (sprintf (
0 commit comments