diff --git a/Exception/CommandNotFoundException.php b/Exception/CommandNotFoundException.php index 69d5cb996..590a71c77 100644 --- a/Exception/CommandNotFoundException.php +++ b/Exception/CommandNotFoundException.php @@ -21,10 +21,10 @@ class CommandNotFoundException extends \InvalidArgumentException implements Exce private $alternatives; /** - * @param string $message Exception message to throw - * @param array $alternatives List of similar defined names - * @param int $code Exception code - * @param \Throwable $previous Previous exception used for the exception chaining + * @param string $message Exception message to throw + * @param string[] $alternatives List of similar defined names + * @param int $code Exception code + * @param \Throwable|null $previous Previous exception used for the exception chaining */ public function __construct(string $message, array $alternatives = [], int $code = 0, \Throwable $previous = null) { @@ -34,7 +34,7 @@ public function __construct(string $message, array $alternatives = [], int $code } /** - * @return array A list of similar defined names + * @return string[] A list of similar defined names */ public function getAlternatives() { diff --git a/Helper/Helper.php b/Helper/Helper.php index e52e31515..f82dd286f 100644 --- a/Helper/Helper.php +++ b/Helper/Helper.php @@ -45,6 +45,8 @@ public function getHelperSet() */ public static function strlen(?string $string) { + $string = (string) $string; + if (false === $encoding = mb_detect_encoding($string, null, true)) { return \strlen($string); } @@ -59,6 +61,8 @@ public static function strlen(?string $string) */ public static function substr(string $string, int $from, int $length = null) { + $string = (string) $string; + if (false === $encoding = mb_detect_encoding($string, null, true)) { return substr($string, $from, $length); } diff --git a/Helper/QuestionHelper.php b/Helper/QuestionHelper.php index 054c24192..c0fb5461f 100644 --- a/Helper/QuestionHelper.php +++ b/Helper/QuestionHelper.php @@ -411,7 +411,7 @@ private function getHiddenResponse(OutputInterface $output, $inputStream, bool $ $exe = $tmpExe; } - $sExec = shell_exec($exe); + $sExec = shell_exec('"'.$exe.'"'); $value = $trimmable ? rtrim($sExec) : $sExec; $output->writeln(''); diff --git a/Input/StringInput.php b/Input/StringInput.php index 2890b0f5f..2625514ef 100644 --- a/Input/StringInput.php +++ b/Input/StringInput.php @@ -48,12 +48,12 @@ private function tokenize(string $input): array $length = \strlen($input); $cursor = 0; while ($cursor < $length) { - if (preg_match('/\s+/A', $input, $match, null, $cursor)) { - } elseif (preg_match('/([^="\'\s]+?)(=?)('.self::REGEX_QUOTED_STRING.'+)/A', $input, $match, null, $cursor)) { + if (preg_match('/\s+/A', $input, $match, 0, $cursor)) { + } elseif (preg_match('/([^="\'\s]+?)(=?)('.self::REGEX_QUOTED_STRING.'+)/A', $input, $match, 0, $cursor)) { $tokens[] = $match[1].$match[2].stripcslashes(str_replace(['"\'', '\'"', '\'\'', '""'], '', substr($match[3], 1, \strlen($match[3]) - 2))); - } elseif (preg_match('/'.self::REGEX_QUOTED_STRING.'/A', $input, $match, null, $cursor)) { + } elseif (preg_match('/'.self::REGEX_QUOTED_STRING.'/A', $input, $match, 0, $cursor)) { $tokens[] = stripcslashes(substr($match[0], 1, \strlen($match[0]) - 2)); - } elseif (preg_match('/'.self::REGEX_STRING.'/A', $input, $match, null, $cursor)) { + } elseif (preg_match('/'.self::REGEX_STRING.'/A', $input, $match, 0, $cursor)) { $tokens[] = stripcslashes($match[1]); } else { // should never happen