public function parse()
{
if ($this->isQuotedString()) {
return array($this->input);
}
if (strpos('=,;?', substr($this->input, 0, 1)) !== false) {
throw new \ErrorException('Expecting a variable name or an expression, got: ' . $this->input, 13);
}
preg_match_all('/(?<![<>=!])=(?!>|=)|[\\[\\]\\{\\}\\(\\),;\\.]|(?!:):|->/', preg_replace_callback('/[a-zA-Z0-9\\\\_\\x7f-\\xff]*\\((?:[0-9\\/%\\.\\s*+-]++|(?R))*+\\)/', function ($match) {
// no need to keep separators in simple PHP expressions (functions calls, parentheses, calculs)
return str_repeat(' ', strlen($match[0]));
}, preg_replace_callback('/([\'"]).*?(?<!\\\\)(?:\\\\{2})*\\1/', function ($match) {
// do not take separators in strings
return str_repeat(' ', strlen($match[0]));
}, $this->input)), $separators, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE);
$this->separators = $separators[0];
if (count($this->separators) === 0) {
if (strstr('0123456789-+("\'$', substr($this->input, 0, 1)) === false) {
//$this->input = $this->phpizeExpression('addDollarIfNeeded', $this->input);
$this->input = static::addDollarIfNeeded($this->input);
}
return array($this->input);
}
// add a pseudo separator for the end of the input
array_push($this->separators, array(null, strlen($this->input)));
return $this->parseBetweenSeparators();
}