*
* @param Twig_NodeInterface $node The node to compile
*
- * @return Twig_Compiler The current compiler instance
+ * @return Twig_CompilerInterface The current compiler instance
*/
function compile(Twig_NodeInterface $node);
return $node;
}
- public function getFunctionNode($node)
+ public function getFunctionNode(Twig_Node_Expression_Name $node)
{
$args = $this->parseArguments();
);
}
- public function parseNotTestExpression($parser, $node)
+ public function parseNotTestExpression(Twig_Parser $parser, $node)
{
return new Twig_Node_Expression_Unary_Not($this->parseTestExpression($parser, $node), $parser->getCurrentToken()->getLine());
}
- public function parseTestExpression($parser, $node)
+ public function parseTestExpression(Twig_Parser $parser, $node)
{
$stream = $parser->getStream();
$name = $stream->expect(Twig_Token::NAME_TYPE);
$arguments = null;
if ($stream->test(Twig_Token::PUNCTUATION_TYPE, '(')) {
- $arguments = $parser->getExpressionParser()->parseArguments($node);
+ $arguments = $parser->getExpressionParser()->parseArguments();
}
return new Twig_Node_Expression_Test($node, $name->getValue(), $arguments, $parser->getCurrentToken()->getLine());
function needsEnvironment();
+ function needsContext();
+
function getSafe(Twig_Node $filterArgs);
function getPreEscape();
function needsEnvironment();
+ function needsContext();
+
function getSafe(Twig_Node $filterArgs);
}
return $node;
}
- protected function traverseForVisitor($visitor, Twig_NodeInterface $node = null)
+ protected function traverseForVisitor(Twig_NodeVisitorInterface $visitor, Twig_NodeInterface $node = null)
{
if (null === $node) {
return null;
array_shift($this->importedFunctions);
}
+ /**
+ * Gets the expression parser.
+ *
+ * @return Twig_ExpressionParser The expression parser
+ */
public function getExpressionParser()
{
return $this->expressionParser;
$this->parent = $parent;
}
+ /**
+ * Gets the token stream.
+ *
+ * @return Twig_TokenStream The token stream
+ */
public function getStream()
{
return $this->stream;
}
+ /**
+ * Gets the current token.
+ *
+ * @return Twig_Token The current token
+ */
public function getCurrentToken()
{
return $this->stream->getCurrent();
}
/**
- * Tests the current token for a type.
+ * Tests the current token for a type and/or a value.
*
- * The first argument is the type
- * of the token (if not given Twig_Token::NAME_TYPE), the second the
- * value of the token (if not given value is not checked).
+ * Parameters may be:
+ * * just type
+ * * type and value (or array of possible values)
+ * * just value (or array of possible values) (NAME_TYPE is used as type)
*
- * The token value can be an array if multiple checks should be
- * performed.
- *
- * @param integer $type The type to test
+ * @param array|integer $type The type to test
* @param array|string|null $values The token value
*
* @return Boolean
return new Twig_Node_AutoEscape($value, $body, $lineno, $this->getTag());
}
- public function decideBlockEnd($token)
+ public function decideBlockEnd(Twig_Token $token)
{
return $token->test('endautoescape');
}
return new Twig_Node_BlockReference($name, $lineno, $this->getTag());
}
- public function decideBlockEnd($token)
+ public function decideBlockEnd(Twig_Token $token)
{
return $token->test('endblock');
}
return new Twig_Node_Print($filter, $token->getLine(), $this->getTag());
}
- public function decideBlockEnd($token)
+ public function decideBlockEnd(Twig_Token $token)
{
return $token->test('endfilter');
}
return new Twig_Node_For($keyTarget, $valueTarget, $seq, $body, $else, $lineno, $this->getTag());
}
- public function decideForFork($token)
+ public function decideForFork(Twig_Token $token)
{
return $token->test(array('else', 'endfor'));
}
- public function decideForEnd($token)
+ public function decideForEnd(Twig_Token $token)
{
return $token->test('endfor');
}
return new Twig_Node_If(new Twig_Node($tests), $else, $lineno, $this->getTag());
}
- public function decideIfFork($token)
+ public function decideIfFork(Twig_Token $token)
{
return $token->test(array('elseif', 'else', 'endif'));
}
- public function decideIfEnd($token)
+ public function decideIfEnd(Twig_Token $token)
{
return $token->test(array('endif'));
}
return null;
}
- public function decideBlockEnd($token)
+ public function decideBlockEnd(Twig_Token $token)
{
return $token->test('endmacro');
}
return new Twig_Node_Sandbox($body, $token->getLine(), $this->getTag());
}
- public function decideBlockEnd($token)
+ public function decideBlockEnd(Twig_Token $token)
{
return $token->test('endsandbox');
}
return new Twig_Node_Set($capture, $names, $values, $lineno, $this->getTag());
}
- public function decideBlockEnd($token)
+ public function decideBlockEnd(Twig_Token $token)
{
return $token->test('endset');
}
return new Twig_Node_Spaceless($body, $lineno, $this->getTag());
}
- public function decideSpacelessEnd($token)
+ public function decideSpacelessEnd(Twig_Token $token)
{
return $token->test('endspaceless');
}
/**
* Constructor.
*
- * @param array|Iterable $parsers An Iterable of Twig_TokenParserInterface instances
- * @param array|Iterable $brokers An Iterable of Twig_TokenParserBrokerInterface instances
+ * @param array|Traversable $parsers A Traversable of Twig_TokenParserInterface instances
+ * @param array|Traversable $brokers A Traversable of Twig_TokenParserBrokerInterface instances
*/
public function __construct($parsers = array(), $brokers = array())
{
public function setParser(Twig_ParserInterface $parser)
{
$this->parser = $parser;
- foreach($this->parsers as $tokenParser) {
+ foreach ($this->parsers as $tokenParser) {
$tokenParser->setParser($parser);
}
- foreach($this->brokers as $broker) {
+ foreach ($this->brokers as $broker) {
$broker->setParser($parser);
}
}