public parse ( |
||
$token | ||
리턴 |
public function parse(Token $token) : FunctionCallValue
{
parent::parse($token);
if (1 !== preg_match(self::REGEX, $token->getValue(), $matches)) {
throw ExpressionLanguageExceptionFactory::createForUnparsableToken($token);
}
$function = $matches['function'];
if ('identity' === $function) {
$arguments = [new EvaluatedValue($matches['arguments'])];
} elseif ('current' === $function) {
$arguments = [new ValueForCurrentValue()];
} else {
$arguments = $this->parseArguments($this->parser, trim($matches['arguments']));
}
return new FunctionCallValue($function, $arguments);
}
public function testCanParseArgumentsForCurrentValue() { // Arguments should be discarded $token = new Token('<current( arg0 , arg1 )>', new TokenType(TokenType::FUNCTION_TYPE)); $expected = new FunctionCallValue('current', [new ValueForCurrentValue()]); $parser = new FunctionTokenParser(new FakeParser()); $actual = $parser->parse($token); $this->assertEquals($expected, $actual); $this->assertInstanceOf(ValueForCurrentValue::class, $actual->getArguments()[0]); }