Phan\Language\UnionType::fromNode PHP Method

fromNode() public static method

public static fromNode ( Context $context, CodeBase $code_base, ast\Node | string | null $node, boolean $should_catch_issue_exception = true ) : UnionType
$context Context The context of the parser at the node for which we'd like to determine a type
$code_base Phan\CodeBase The code base within which we're operating
$node ast\Node | string | null The node for which we'd like to determine its type
$should_catch_issue_exception boolean Set to true to cause loggable issues to be thrown instead of emitted as issues to the log.
return UnionType
    public static function fromNode(Context $context, CodeBase $code_base, $node, bool $should_catch_issue_exception = true) : UnionType
    {
        return UnionTypeVisitor::unionTypeFromNode($code_base, $context, $node, $should_catch_issue_exception);
    }

Usage Example

Beispiel #1
0
 /**
  * @param Node $node
  * An AST_VAR node
  *
  * @param Context $context
  * The context in which the variable is found
  *
  * @param CodeBase $code_base
  *
  * @return Variable
  * A variable begotten from a node
  */
 public static function fromNodeInContext(Node $node, Context $context, CodeBase $code_base, bool $should_check_type = true) : Variable
 {
     $variable_name = AST::variableName($node);
     // Get the type of the assignment
     $union_type = $should_check_type ? UnionType::fromNode($context, $code_base, $node) : new UnionType();
     $variable = new Variable($context->withLineNumberStart($node->lineno ?? 0)->withLineNumberEnd($node->endLineno ?? 0), $variable_name, $union_type, $node->flags);
     return $variable;
 }
All Usage Examples Of Phan\Language\UnionType::fromNode