@@ -173,7 +173,7 @@ private function guessGitVersion(array $packageConfig, string $path): array
173173 $ featurePrettyVersion = $ prettyVersion ;
174174
175175 // try to find the best (nearest) version branch to assume this feature's version
176- $ result = $ this ->guessFeatureVersion ($ packageConfig , $ version , $ branches , 'git rev-list %candidate%..%branch% ' , $ path );
176+ $ result = $ this ->guessFeatureVersion ($ packageConfig , $ version , $ branches , [ 'git ' , ' rev-list ' , ' %candidate%..%branch% '] , $ path );
177177 $ version = $ result ['version ' ];
178178 $ prettyVersion = $ result ['pretty_version ' ];
179179 }
@@ -248,7 +248,7 @@ private function guessHgVersion(array $packageConfig, string $path): ?array
248248 $ branches = array_map ('strval ' , array_keys ($ driver ->getBranches ()));
249249
250250 // try to find the best (nearest) version branch to assume this feature's version
251- $ result = $ this ->guessFeatureVersion ($ packageConfig , $ version , $ branches , 'hg log -r " not ancestors( \'%candidate% \') and ancestors( \'%branch% \')" --template "{node} \\n" ' , $ path );
251+ $ result = $ this ->guessFeatureVersion ($ packageConfig , $ version , $ branches , [ 'hg ' , ' log ' , ' -r ' , ' not ancestors( \'%candidate% \') and ancestors( \'%branch% \') ' , ' --template ' , ' "{node} \\n" '] , $ path );
252252 $ result ['commit ' ] = '' ;
253253 $ result ['feature_version ' ] = $ version ;
254254 $ result ['feature_pretty_version ' ] = $ version ;
@@ -261,13 +261,12 @@ private function guessHgVersion(array $packageConfig, string $path): ?array
261261
262262 /**
263263 * @param array<string, mixed> $packageConfig
264- * @param string[] $branches
265- *
266- * @phpstan-param non-empty-string $scmCmdline
264+ * @param list<string> $branches
265+ * @param list<string> $scmCmdline
267266 *
268267 * @return array{version: string|null, pretty_version: string|null}
269268 */
270- private function guessFeatureVersion (array $ packageConfig , ?string $ version , array $ branches , string $ scmCmdline , string $ path ): array
269+ private function guessFeatureVersion (array $ packageConfig , ?string $ version , array $ branches , array $ scmCmdline , string $ path ): array
271270 {
272271 $ prettyVersion = $ version ;
273272
@@ -309,7 +308,9 @@ private function guessFeatureVersion(array $packageConfig, ?string $version, arr
309308 continue ;
310309 }
311310
312- $ cmdLine = str_replace (['%candidate% ' , '%branch% ' ], [$ candidate , $ branch ], $ scmCmdline );
311+ $ cmdLine = array_map (static function (string $ component ) use ($ candidate , $ branch ) {
312+ return str_replace (['%candidate% ' , '%branch% ' ], [$ candidate , $ branch ], $ component );
313+ }, $ scmCmdline );
313314 $ promises [] = $ this ->process ->executeAsync ($ cmdLine , $ path )->then (function (Process $ process ) use (&$ length , &$ version , &$ prettyVersion , $ candidateVersion , &$ promises ): void {
314315 if (!$ process ->isSuccessful ()) {
315316 return ;
0 commit comments