本文整理汇总了PHP中Phan\Language\UnionType::asGenericArrayTypes方法的典型用法代码示例。如果您正苦于以下问题:PHP UnionType::asGenericArrayTypes方法的具体用法?PHP UnionType::asGenericArrayTypes怎么用?PHP UnionType::asGenericArrayTypes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Phan\Language\UnionType
的用法示例。
在下文中一共展示了UnionType::asGenericArrayTypes方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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->asGenericArrayTypes();
if ($node->children['expr']->kind == \ast\AST_VAR) {
$variable_name = (new ContextNode($this->code_base, $this->context, $node))->getVariableName();
if (Variable::isSuperglobalVariableWithName($variable_name)) {
return $this->analyzeSuperglobalDim($node, $variable_name);
}
}
// Recurse into whatever we're []'ing
$context = (new AssignmentVisitor($this->code_base, $this->context, $node, $right_type, true))($node->children['expr']);
return $context;
}
示例2: 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->asGenericArrayTypes();
if ($node->children['expr']->kind == \ast\AST_VAR) {
$variable_name = (new ContextNode($this->code_base, $this->context, $node))->getVariableName();
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);
return $this->context->withGlobalScopeVariable($variable);
}
}
}
// Recurse into whatever we're []'ing
$context = (new AssignmentVisitor($this->code_base, $this->context, $node, $right_type, true))($node->children['expr']);
return $context;
}