55namespace Rector \Tests \Parallel \Command ;
66
77use Iterator ;
8+ use PHPStan \Turbo \TurboExtensionSelector ;
89use PHPUnit \Framework \Attributes \DataProvider ;
910use Rector \ChangesReporting \Output \ConsoleOutputFormatter ;
1011use Rector \Configuration \Option ;
@@ -72,7 +73,7 @@ public static function provideDataSpacedMainScript(): Iterator
7273 self ::COMMAND => 'process ' ,
7374 Option::SOURCE => ['src ' ],
7475 ],
75- "' " . PHP_BINARY . "' ' " . self ::SPACED_DUMMY_MAIN_SCRIPT . "' ' " . $ cliInputOptionsAsString . "' worker --port 2000 --identifier 'identifier' 'src' --output-format 'json' --no-ansi " ,
76+ "' " . PHP_BINARY . "' " . self :: turboExtensionArguments () . " ' " . self ::SPACED_DUMMY_MAIN_SCRIPT . "' ' " . $ cliInputOptionsAsString . "' worker --port 2000 --identifier 'identifier' 'src' --output-format 'json' --no-ansi " ,
7677 ];
7778
7879 yield [
@@ -81,7 +82,7 @@ public static function provideDataSpacedMainScript(): Iterator
8182 Option::SOURCE => ['src ' ],
8283 '-- ' . Option::OUTPUT_FORMAT => ConsoleOutputFormatter::NAME ,
8384 ],
84- "' " . PHP_BINARY . "' ' " . self ::SPACED_DUMMY_MAIN_SCRIPT . "' ' " . $ cliInputOptionsAsString . "' worker --port 2000 --identifier 'identifier' 'src' --output-format 'json' --no-ansi " ,
85+ "' " . PHP_BINARY . "' " . self :: turboExtensionArguments () . " ' " . self ::SPACED_DUMMY_MAIN_SCRIPT . "' ' " . $ cliInputOptionsAsString . "' worker --port 2000 --identifier 'identifier' 'src' --output-format 'json' --no-ansi " ,
8586 ];
8687
8788 yield [
@@ -91,7 +92,7 @@ public static function provideDataSpacedMainScript(): Iterator
9192 '-- ' . Option::OUTPUT_FORMAT => ConsoleOutputFormatter::NAME ,
9293 '-- ' . Option::DEBUG => true ,
9394 ],
94- "' " . PHP_BINARY . "' ' " . self ::SPACED_DUMMY_MAIN_SCRIPT . "' ' " . $ cliInputOptionsAsString . "' worker --debug --port 2000 --identifier 'identifier' 'src' --output-format 'json' --no-ansi " ,
95+ "' " . PHP_BINARY . "' " . self :: turboExtensionArguments () . " ' " . self ::SPACED_DUMMY_MAIN_SCRIPT . "' ' " . $ cliInputOptionsAsString . "' worker --debug --port 2000 --identifier 'identifier' 'src' --output-format 'json' --no-ansi " ,
9596 ];
9697
9798 yield [
@@ -102,7 +103,7 @@ public static function provideDataSpacedMainScript(): Iterator
102103 '-- ' . Option::DEBUG => true ,
103104 '-- ' . Option::XDEBUG => true ,
104105 ],
105- "' " . PHP_BINARY . "' ' " . self ::SPACED_DUMMY_MAIN_SCRIPT . "' ' " . $ cliInputOptionsAsString . "' worker --debug --xdebug --port 2000 --identifier 'identifier' 'src' --output-format 'json' --no-ansi " ,
106+ "' " . PHP_BINARY . "' " . self :: turboExtensionArguments () . " ' " . self ::SPACED_DUMMY_MAIN_SCRIPT . "' ' " . $ cliInputOptionsAsString . "' worker --debug --xdebug --port 2000 --identifier 'identifier' 'src' --output-format 'json' --no-ansi " ,
106107 ];
107108 }
108109
@@ -143,7 +144,7 @@ public static function provideData(): Iterator
143144 self ::COMMAND => 'process ' ,
144145 Option::SOURCE => ['src ' ],
145146 ],
146- "' " . PHP_BINARY . "' ' " . self ::DUMMY_MAIN_SCRIPT . "' ' " . $ cliInputOptionsAsString . "' worker --port 2000 --identifier 'identifier' 'src' --output-format 'json' --no-ansi " ,
147+ "' " . PHP_BINARY . "' " . self :: turboExtensionArguments () . " ' " . self ::DUMMY_MAIN_SCRIPT . "' ' " . $ cliInputOptionsAsString . "' worker --port 2000 --identifier 'identifier' 'src' --output-format 'json' --no-ansi " ,
147148 ];
148149
149150 yield [
@@ -152,7 +153,7 @@ public static function provideData(): Iterator
152153 Option::SOURCE => ['src ' ],
153154 '-- ' . Option::OUTPUT_FORMAT => ConsoleOutputFormatter::NAME ,
154155 ],
155- "' " . PHP_BINARY . "' ' " . self ::DUMMY_MAIN_SCRIPT . "' ' " . $ cliInputOptionsAsString . "' worker --port 2000 --identifier 'identifier' 'src' --output-format 'json' --no-ansi " ,
156+ "' " . PHP_BINARY . "' " . self :: turboExtensionArguments () . " ' " . self ::DUMMY_MAIN_SCRIPT . "' ' " . $ cliInputOptionsAsString . "' worker --port 2000 --identifier 'identifier' 'src' --output-format 'json' --no-ansi " ,
156157 ];
157158
158159 yield [
@@ -162,7 +163,7 @@ public static function provideData(): Iterator
162163 '-- ' . Option::OUTPUT_FORMAT => ConsoleOutputFormatter::NAME ,
163164 '-- ' . Option::DEBUG => true ,
164165 ],
165- "' " . PHP_BINARY . "' ' " . self ::DUMMY_MAIN_SCRIPT . "' ' " . $ cliInputOptionsAsString . "' worker --debug --port 2000 --identifier 'identifier' 'src' --output-format 'json' --no-ansi " ,
166+ "' " . PHP_BINARY . "' " . self :: turboExtensionArguments () . " ' " . self ::DUMMY_MAIN_SCRIPT . "' ' " . $ cliInputOptionsAsString . "' worker --debug --port 2000 --identifier 'identifier' 'src' --output-format 'json' --no-ansi " ,
166167 ];
167168
168169 yield [
@@ -173,7 +174,7 @@ public static function provideData(): Iterator
173174 '-- ' . Option::DEBUG => true ,
174175 '-- ' . Option::XDEBUG => true ,
175176 ],
176- "' " . PHP_BINARY . "' ' " . self ::DUMMY_MAIN_SCRIPT . "' ' " . $ cliInputOptionsAsString . "' worker --debug --xdebug --port 2000 --identifier 'identifier' 'src' --output-format 'json' --no-ansi " ,
177+ "' " . PHP_BINARY . "' " . self :: turboExtensionArguments () . " ' " . self ::DUMMY_MAIN_SCRIPT . "' ' " . $ cliInputOptionsAsString . "' worker --debug --xdebug --port 2000 --identifier 'identifier' 'src' --output-format 'json' --no-ansi " ,
177178 ];
178179
179180 yield [
@@ -183,7 +184,7 @@ public static function provideData(): Iterator
183184 '-- ' . Option::OUTPUT_FORMAT => ConsoleOutputFormatter::NAME ,
184185 '-- ' . Option::MEMORY_LIMIT => '-1 ' ,
185186 ],
186- "' " . PHP_BINARY . "' ' " . self ::DUMMY_MAIN_SCRIPT . "' ' " . $ cliInputOptionsAsString . "' worker --memory-limit='-1' --port 2000 --identifier 'identifier' 'src' --output-format 'json' --no-ansi " ,
187+ "' " . PHP_BINARY . "' " . self :: turboExtensionArguments () . " ' " . self ::DUMMY_MAIN_SCRIPT . "' ' " . $ cliInputOptionsAsString . "' worker --memory-limit='-1' --port 2000 --identifier 'identifier' 'src' --output-format 'json' --no-ansi " ,
187188 ];
188189
189190 yield [
@@ -193,10 +194,30 @@ public static function provideData(): Iterator
193194 '-- ' . Option::OUTPUT_FORMAT => ConsoleOutputFormatter::NAME ,
194195 '-- ' . Option::PHP => true ,
195196 ],
196- "' " . PHP_BINARY . "' ' " . self ::DUMMY_MAIN_SCRIPT . "' ' " . $ cliInputOptionsAsString . "' worker --php --port 2000 --identifier 'identifier' 'src' --output-format 'json' --no-ansi " ,
197+ "' " . PHP_BINARY . "' " . self :: turboExtensionArguments () . " ' " . self ::DUMMY_MAIN_SCRIPT . "' ' " . $ cliInputOptionsAsString . "' worker --php --port 2000 --identifier 'identifier' 'src' --output-format 'json' --no-ansi " ,
197198 ];
198199 }
199200
201+ /**
202+ * The worker gets PHPStan Turbo through two -d options, when PHPStan ships a binary for this runtime
203+ */
204+ private static function turboExtensionArguments (): string
205+ {
206+ $ extensionPath = TurboExtensionSelector ::findExtensionForWorkers ();
207+ if ($ extensionPath === null ) {
208+ return '' ;
209+ }
210+
211+ $ arguments = [
212+ '-d ' ,
213+ "extension=' " . $ extensionPath . "' " ,
214+ '-d ' ,
215+ TurboExtensionSelector::EXTENSION_PATH_INI . "=' " . $ extensionPath . "' " ,
216+ ];
217+
218+ return implode (' ' , array_map (escapeshellarg (...), $ arguments )) . ' ' ;
219+ }
220+
200221 private function cleanUpEmptyQuoteExpectedCommandOutput (string $ result ): string
201222 {
202223 if ($ this ->isWindows ()) {
0 commit comments