@@ -52,15 +52,31 @@ protected function initialize(InputInterface $input, OutputInterface $output): v
52
52
53
53
protected function execute (InputInterface $ input , OutputInterface $ output ): int
54
54
{
55
+ $ paths = $ input ->getArgument ('paths ' );
56
+ $ memoryLimit = $ input ->getOption ('memory-limit ' );
57
+ $ autoloadFile = $ input ->getOption ('autoload-file ' );
58
+ $ configuration = $ input ->getOption ('configuration ' );
59
+ $ level = $ input ->getOption (self ::OPTION_LEVEL );
60
+
61
+ if (
62
+ !is_array ($ paths )
63
+ || (!is_string ($ memoryLimit ) && $ memoryLimit !== null )
64
+ || (!is_string ($ autoloadFile ) && $ autoloadFile !== null )
65
+ || (!is_string ($ configuration ) && $ configuration !== null )
66
+ || (!is_string ($ level ) && $ level !== null )
67
+ ) {
68
+ throw new \PHPStan \ShouldNotHappenException ();
69
+ }
70
+
55
71
try {
56
72
$ inceptionResult = CommandHelper::begin (
57
73
$ input ,
58
74
$ output ,
59
- $ input -> getArgument ( ' paths ' ) ,
60
- $ input -> getOption ( ' memory-limit ' ) ,
61
- $ input -> getOption ( ' autoload-file ' ) ,
62
- $ input -> getOption ( ' configuration ' ) ,
63
- $ input -> getOption ( self :: OPTION_LEVEL )
75
+ $ paths ,
76
+ $ memoryLimit ,
77
+ $ autoloadFile ,
78
+ $ configuration ,
79
+ $ level
64
80
);
65
81
} catch (\PHPStan \Command \InceptionNotSuccessfulException $ e ) {
66
82
return 1 ;
@@ -75,6 +91,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int
75
91
$ errorFormat = $ oldErrorFormat ;
76
92
}
77
93
94
+ if (!is_string ($ errorFormat ) && $ errorFormat !== null ) {
95
+ throw new \PHPStan \ShouldNotHappenException ();
96
+ }
97
+
78
98
$ container = $ inceptionResult ->getContainer ();
79
99
$ errorFormatterServiceName = sprintf ('errorFormatter.%s ' , $ errorFormat );
80
100
if (!$ container ->hasService ($ errorFormatterServiceName )) {
@@ -93,14 +113,20 @@ protected function execute(InputInterface $input, OutputInterface $output): int
93
113
94
114
/** @var AnalyseApplication $application */
95
115
$ application = $ container ->getByType (AnalyseApplication::class);
116
+
117
+ $ debug = $ input ->getOption ('debug ' );
118
+ if (!is_bool ($ debug )) {
119
+ throw new \PHPStan \ShouldNotHappenException ();
120
+ }
121
+
96
122
return $ inceptionResult ->handleReturn (
97
123
$ application ->analyse (
98
124
$ inceptionResult ->getFiles (),
99
125
$ inceptionResult ->isOnlyFiles (),
100
126
$ inceptionResult ->getConsoleStyle (),
101
127
$ errorFormatter ,
102
128
$ inceptionResult ->isDefaultLevelUsed (),
103
- $ input -> getOption ( ' debug ' )
129
+ $ debug
104
130
)
105
131
);
106
132
}
0 commit comments