本文整理匯總了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()));
}