2
2
3
3
namespace PHPStan \Diagnose ;
4
4
5
+ use Phar ;
5
6
use PHPStan \Command \Output ;
6
7
use PHPStan \ExtensionInstaller \GeneratedConfig ;
7
8
use PHPStan \Internal \ComposerHelper ;
8
9
use PHPStan \Php \PhpVersion ;
9
10
use function class_exists ;
10
11
use function count ;
12
+ use function dirname ;
13
+ use function is_file ;
11
14
use function sprintf ;
12
15
use const PHP_VERSION_ID ;
13
16
14
17
class PHPStanDiagnoseExtension implements DiagnoseExtension
15
18
{
16
19
17
- public function __construct (private PhpVersion $ phpVersion )
20
+ /**
21
+ * @param string[] $composerAutoloaderProjectPaths
22
+ */
23
+ public function __construct (
24
+ private PhpVersion $ phpVersion ,
25
+ private array $ composerAutoloaderProjectPaths ,
26
+ )
18
27
{
19
28
}
20
29
@@ -30,11 +39,25 @@ public function print(Output $output): void
30
39
$ this ->phpVersion ->getVersionString (),
31
40
$ this ->phpVersion ->getSourceLabel (),
32
41
));
42
+ $ output ->writeLineFormatted ('' );
43
+
33
44
$ output ->writeLineFormatted (sprintf (
34
45
'<info>PHPStan version:</info> %s ' ,
35
46
ComposerHelper::getPhpStanVersion (),
36
47
));
48
+ $ output ->writeLineFormatted ('<info>PHPStan running from:</info> ' );
49
+ $ pharRunning = Phar::running (false );
50
+ if ($ pharRunning !== '' ) {
51
+ $ output ->writeLineFormatted (dirname ($ pharRunning ));
52
+ } else {
53
+ if (isset ($ _SERVER ['argv ' ][0 ]) && is_file ($ _SERVER ['argv ' ][0 ])) {
54
+ $ output ->writeLineFormatted ($ _SERVER ['argv ' ][0 ]);
55
+ } else {
56
+ $ output ->writeLineFormatted ('Unknown ' );
57
+ }
58
+ }
37
59
$ output ->writeLineFormatted ('' );
60
+
38
61
if (class_exists ('PHPStan\ExtensionInstaller\GeneratedConfig ' )) {
39
62
$ output ->writeLineFormatted ('<info>Extension installer:</info> ' );
40
63
if (count (GeneratedConfig::EXTENSIONS ) === 0 ) {
@@ -47,6 +70,12 @@ public function print(Output $output): void
47
70
$ output ->writeLineFormatted ('<info>Extension installer:</info> Not installed ' );
48
71
}
49
72
$ output ->writeLineFormatted ('' );
73
+
74
+ $ output ->writeLineFormatted ('<info>Discovered Composer project roots:</info> ' );
75
+ foreach ($ this ->composerAutoloaderProjectPaths as $ composerAutoloaderProjectPath ) {
76
+ $ output ->writeLineFormatted ($ composerAutoloaderProjectPath );
77
+ }
78
+ $ output ->writeLineFormatted ('' );
50
79
}
51
80
52
81
}
0 commit comments