本文整理汇总了PHP中Twig_Node_Expression::getNode方法的典型用法代码示例。如果您正苦于以下问题:PHP Twig_Node_Expression::getNode方法的具体用法?PHP Twig_Node_Expression::getNode怎么用?PHP Twig_Node_Expression::getNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Twig_Node_Expression
的用法示例。
在下文中一共展示了Twig_Node_Expression::getNode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: invalidArgumentTypeParseError
/**
* Throws an exception with detailled error message in case of argument parse errors.
*
* @param Twig_Node_Expression $argument The invalid/unexpected argument node.
* @param Twig_Node_Expression $node The Filter or Function node to which the $argument belongs.
* @throws InvalidArgumentException (The main purpose.)
* @throws LogicException In case an unexpected $node argument was passed.
*/
protected function invalidArgumentTypeParseError(Twig_Node_Expression $argument, Twig_Node_Expression $node)
{
switch (true) {
case $node instanceof Twig_Node_Expression_Function:
$name = $node->getAttribute('name');
break;
case $node instanceof Twig_Node_Expression_Filter:
$name = $node->getNode('filter')->getAttribute('value');
break;
default:
throw new LogicException(sprintf("Don't know how to get name of node %s to throw an InvalidArgumentException", get_class($node)));
}
throw new InvalidArgumentException(sprintf('Invalid argument of type %s for %s in %s on line %d', get_class($argument), $name, $this->file, $node->getLine()));
}