本文整理匯總了PHP中PhpParser\Node\Expr::getType方法的典型用法代碼示例。如果您正苦於以下問題:PHP Expr::getType方法的具體用法?PHP Expr::getType怎麽用?PHP Expr::getType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PhpParser\Node\Expr
的用法示例。
在下文中一共展示了Expr::getType方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: parseOperatorNode
private function parseOperatorNode(Node\Expr $node)
{
$nodeType = str_replace('Expr_', '', $node->getType());
switch (true) {
case isset(self::$assignOperatorsMap[$nodeType]):
return Expression::assign($this->parseNode($node->var), self::$assignOperatorsMap[$nodeType], $this->parseNode($node->expr));
case $node instanceof Node\Expr\Instanceof_:
return Expression::binaryOperation($this->parseNode($node->expr), Operators\Binary::IS_INSTANCE_OF, $this->parseNameNode($node->class));
case isset(self::$binaryOperatorsMap[$nodeType]):
return Expression::binaryOperation($this->parseNode($node->left), self::$binaryOperatorsMap[$nodeType], $this->parseNode($node->right));
case isset(self::$unaryOperatorsMap[$nodeType]):
return Expression::unaryOperation(self::$unaryOperatorsMap[$nodeType], $this->parseNode(isset($node->expr) ? $node->expr : $node->var));
case isset(self::$castOperatorMap[$nodeType]):
return Expression::cast(self::$castOperatorMap[$nodeType], $this->parseNode($node->expr));
default:
return null;
}
}
示例2: canRef
/**
* Determines whether or not a parameter can be reference (e.g. vars can be referenced, while function calls cannot)
*
* @param \PhpParser\Node\Expr $value
* @return bool
*/
private static function canRef($value)
{
$type = $value->getType();
if (isset(self::$can_ref[$type])) {
return true;
} else {
if ($value instanceof \PhpParser\Node\Expr\ArrayDimFetch) {
if (!self::canRef($value->var)) {
return false;
}
// an ugly hack for ArrayAccess objects that are used as "$this['something']"
if ($value->var instanceof \PhpParser\Node\Expr\Variable && $value->var->name == 'this') {
return false;
}
return true;
}
}
return false;
}