Phan\Language\Type\CallableType::instanceWithClosureFQSEN PHP Method

instanceWithClosureFQSEN() public static method

public static instanceWithClosureFQSEN ( Phan\Language\FQSEN $fqsen )
$fqsen Phan\Language\FQSEN
    public static function instanceWithClosureFQSEN(FQSEN $fqsen)
    {
        // Use an instance with no memoized or lazily initialized results.
        // Avoids picking up changes to CallableType::instance() in the case that a result depends on asFQSEN()
        $instance = clone self::callableInstance();
        $instance->fqsen = $fqsen;
        return $instance;
    }

Usage Example

 /**
  * Visit a node with kind `\ast\AST_CLOSURE`
  *
  * @param Node $node
  * A node of the type indicated by the method name that we'd
  * like to figure out the type that it produces.
  *
  * @return UnionType
  * The set of types that are possibly produced by the
  * given node
  */
 public function visitClosure(Decl $node) : UnionType
 {
     // The type of a closure is the fqsen pointing
     // at its definition
     $closure_fqsen = FullyQualifiedFunctionName::fromClosureInContext($this->context);
     $type = CallableType::instanceWithClosureFQSEN($closure_fqsen)->asUnionType();
     return $type;
 }