本文整理匯總了PHP中Phan\Language\UnionType::asGenericTypes方法的典型用法代碼示例。如果您正苦於以下問題:PHP UnionType::asGenericTypes方法的具體用法?PHP UnionType::asGenericTypes怎麽用?PHP UnionType::asGenericTypes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Phan\Language\UnionType
的用法示例。
在下文中一共展示了UnionType::asGenericTypes方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: visitDim
/**
* @param Node $node
* A node to parse
*
* @return Context
* A new or an unchanged context resulting from
* parsing the node
*/
public function visitDim(Node $node) : Context
{
// Make the right type a generic (i.e. int -> int[])
$right_type = $this->right_type->asGenericTypes();
if ($node->children['expr']->kind == \ast\AST_VAR) {
$variable_name = AST::variableName($node);
if ('GLOBALS' === $variable_name) {
$dim = $node->children['dim'];
if (is_string($dim)) {
// You're not going to believe this, but I just
// found a piece of code like $GLOBALS[mt_rand()].
// Super weird, right?
assert(is_string($dim), "dim is not a string at {$this->context}");
$variable = new Variable($this->context, $dim, $this->right_type, $node->flags ?? 0);
$this->context->getScope()->withGlobalVariable($variable);
return $this->context;
}
}
}
// Recurse into whatever we're []'ing
$context = (new Element($node->children['expr']))->acceptKindVisitor(new AssignmentVisitor($this->context, $this->code_base, $node, $right_type));
return $context;
}