本文整理汇总了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;
}