Phan\Language\UnionType::asGenericArrayTypes PHP Method

asGenericArrayTypes() public method

public asGenericArrayTypes ( ) : UnionType
return UnionType Get a new type for each type in this union which is the generic array version of this type. For instance, 'int|float' will produce 'int[]|float[]'.
    public function asGenericArrayTypes() : UnionType
    {
        return new UnionType($this->type_set->map(function (Type $type) : Type {
            return $type->asGenericArrayType();
        }));
    }

Usage Example

Beispiel #1
0
 /**
  * @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;
 }
All Usage Examples Of Phan\Language\UnionType::asGenericArrayTypes