Phan\Analysis\ArgumentType::analyzeNodeUnionTypeCast PHP Method

analyzeNodeUnionTypeCast() private static method

Emit a log message if the type of the given node cannot be cast to the given type
private static analyzeNodeUnionTypeCast ( ast\Node | null | string | integer $node, Context $context, CodeBase $code_base, UnionType $cast_type, Closure $issue_instance ) : boolean
$node ast\Node | null | string | integer A node or whatever php-ast feels like returning
$context Phan\Language\Context
$code_base Phan\CodeBase
$cast_type Phan\Language\UnionType
$issue_instance Closure
return boolean True if the cast is possible, else false
    private static function analyzeNodeUnionTypeCast($node, Context $context, CodeBase $code_base, UnionType $cast_type, \Closure $issue_instance) : bool
    {
        // Get the type of the node
        $node_type = UnionType::fromNode($context, $code_base, $node);
        // See if it can be cast to the given type
        $can_cast = $node_type->canCastToUnionType($cast_type);
        // If it can't, emit the log message
        if (!$can_cast) {
            Issue::maybeEmitInstance($code_base, $context, $issue_instance($node_type));
        }
        return $can_cast;
    }