@@ -305,15 +305,15 @@ private function quote(string $argument): string
305
305
$ quoteCharacter = $ this ->getQuoteCharacter ();
306
306
307
307
if ($ quoteCharacter === '' ) {
308
- return $ argument ;
308
+ return $ this -> escapeSpaces ( $ argument) ;
309
309
}
310
310
311
311
if (strpos ($ argument , $ quoteCharacter ) !== false ) {
312
312
if ($ quoteCharacter === self ::QUOTE_SINGLE ) {
313
- return '$ ' . $ quoteCharacter . $ this ->escape ($ argument ) . $ quoteCharacter ;
313
+ return '$ ' . $ quoteCharacter . $ this ->escapeQuotes ($ argument ) . $ quoteCharacter ;
314
314
}
315
315
316
- return $ quoteCharacter . $ this ->escape ($ argument ) . $ quoteCharacter ;
316
+ return $ quoteCharacter . $ this ->escapeQuotes ($ argument ) . $ quoteCharacter ;
317
317
}
318
318
319
319
return $ quoteCharacter . $ argument . $ quoteCharacter ;
@@ -324,11 +324,21 @@ private function quote(string $argument): string
324
324
* @param string $argument
325
325
* @return string
326
326
*/
327
- private function escape (string $ argument ): string
327
+ private function escapeQuotes (string $ argument ): string
328
328
{
329
329
return str_replace ($ this ->getQuoteCharacter (), '\\' . $ this ->getQuoteCharacter (), $ argument );
330
330
}
331
331
332
+ /**
333
+ * Escapes spaces in the argument when no quoting is used
334
+ * @param string $argument
335
+ * @return string
336
+ */
337
+ private function escapeSpaces (string $ argument ): string
338
+ {
339
+ return str_replace (' ' , '\\ ' , $ argument );
340
+ }
341
+
332
342
/**
333
343
* Converts option from user-friendly format ot internal format
334
344
* @param array<mixed> $options
0 commit comments