From 271b628798de5b9f060e11a82f776aaf7c828d96 Mon Sep 17 00:00:00 2001 From: Kyle Date: Sun, 14 Feb 2021 19:19:55 +0100 Subject: [PATCH 1/4] [Console] Fix PHP 8.1 null error for preg_match flag Since PHP 8.1, null is no longer accepted as $flags, default integer `0` value should be used instead. --- Input/StringInput.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Input/StringInput.php b/Input/StringInput.php index 5032b340a..d43187d28 100644 --- a/Input/StringInput.php +++ b/Input/StringInput.php @@ -52,12 +52,12 @@ private function tokenize($input) $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 From 3650057f1c18dea3cfffdcf2f7c5e39215dcd7b8 Mon Sep 17 00:00:00 2001 From: Yendric Date: Sun, 14 Feb 2021 23:09:09 +0100 Subject: [PATCH 2/4] [Console] fix QuestionHelper::getHiddenResponse() not working with space in project directory name --- Helper/QuestionHelper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Helper/QuestionHelper.php b/Helper/QuestionHelper.php index e7ea00555..d211fcfd1 100644 --- a/Helper/QuestionHelper.php +++ b/Helper/QuestionHelper.php @@ -412,7 +412,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(''); From 654d0c82276fde189d785170c496302212696e67 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Sun, 21 Feb 2021 20:10:16 +0100 Subject: [PATCH 3/4] Switched to non-null defaults in exception constructors --- Exception/CommandNotFoundException.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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() { From bee5a5b7c80b477693d8600d19045385bcced9bc Mon Sep 17 00:00:00 2001 From: Pierre-Olivier Vares Date: Mon, 22 Feb 2021 09:25:14 +0100 Subject: [PATCH 4/4] In calls to mb_ functions, silently transform arg into string In PHP8, a number of functions who were accepting null arguments will only accept string ones. In the polyfill, mb_* functions are declared with a trict type checking of "string". Therefore, we deprecate the use of non string arguments, so that it won't break when either using the polyfill, or future php8 versions. --- Helper/Helper.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Helper/Helper.php b/Helper/Helper.php index 0ddddf6bc..0521aaf7d 100644 --- a/Helper/Helper.php +++ b/Helper/Helper.php @@ -47,6 +47,8 @@ public function getHelperSet() */ public static function strlen($string) { + $string = (string) $string; + if (false === $encoding = mb_detect_encoding($string, null, true)) { return \strlen($string); } @@ -65,6 +67,8 @@ public static function strlen($string) */ public static function substr($string, $from, $length = null) { + $string = (string) $string; + if (false === $encoding = mb_detect_encoding($string, null, true)) { return substr($string, $from, $length); }