diff --git a/src/Input/ShellInput.php b/src/Input/ShellInput.php index 10ca2b5b..a185c6fd 100644 --- a/src/Input/ShellInput.php +++ b/src/Input/ShellInput.php @@ -19,6 +19,8 @@ */ class ShellInput extends StringInput { + public const REGEX_STRING = '([^\s]+?)(?:\s|(? '\0', "\t" => '\t', "\n" => '\n', @@ -71,16 +71,15 @@ protected function style($style, $value, $attr = []): string } $styled = ''; - $map = self::$controlCharsMap; $cchr = $this->styles['cchr']; - $chunks = \preg_split(self::$controlCharsRx, $value, -1, \PREG_SPLIT_NO_EMPTY | \PREG_SPLIT_DELIM_CAPTURE); + $chunks = \preg_split(self::CONTROL_CHARS, $value, -1, \PREG_SPLIT_NO_EMPTY | \PREG_SPLIT_DELIM_CAPTURE); foreach ($chunks as $chunk) { - if (\preg_match(self::$onlyControlCharsRx, $chunk)) { + if (\preg_match(self::ONLY_CONTROL_CHARS, $chunk)) { $chars = ''; $i = 0; do { - $chars .= isset($map[$chunk[$i]]) ? $map[$chunk[$i]] : \sprintf('\x%02X', \ord($chunk[$i])); + $chars .= isset(self::CONTROL_CHARS_MAP[$chunk[$i]]) ? self::CONTROL_CHARS_MAP[$chunk[$i]] : \sprintf('\x%02X', \ord($chunk[$i])); } while (isset($chunk[++$i])); $chars = $this->formatter->escape($chars);