private function StringInput::tokenize in Zircon Profile 8.0
Same name and namespace in other branches
- 8 vendor/symfony/console/Input/StringInput.php \Symfony\Component\Console\Input\StringInput::tokenize()
Tokenizes a string.
Parameters
string $input The input to tokenize:
Return value
array An array of tokens
Throws
\InvalidArgumentException When unable to parse input (should never happen)
1 call to StringInput::tokenize()
- StringInput::__construct in vendor/
symfony/ console/ Input/ StringInput.php - Constructor.
File
- vendor/
symfony/ console/ Input/ StringInput.php, line 60
Class
- StringInput
- StringInput represents an input provided as a string.
Namespace
Symfony\Component\Console\InputCode
private function tokenize($input) {
$tokens = 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)) {
$tokens[] = $match[1] . $match[2] . stripcslashes(str_replace(array(
'"\'',
'\'"',
'\'\'',
'""',
), '', substr($match[3], 1, strlen($match[3]) - 2)));
}
elseif (preg_match('/' . self::REGEX_QUOTED_STRING . '/A', $input, $match, null, $cursor)) {
$tokens[] = stripcslashes(substr($match[0], 1, strlen($match[0]) - 2));
}
elseif (preg_match('/' . self::REGEX_STRING . '/A', $input, $match, null, $cursor)) {
$tokens[] = stripcslashes($match[1]);
}
else {
// should never happen
throw new \InvalidArgumentException(sprintf('Unable to parse input near "... %s ..."', substr($input, $cursor, 10)));
}
$cursor += strlen($match[0]);
}
return $tokens;
}