GraphQL\Utils\TypeInfo::leave PHP Method

leave() public method

public leave ( Node $node )
$node GraphQL\Language\AST\Node
    function leave(Node $node)
    {
        switch ($node->kind) {
            case NodeKind::SELECTION_SET:
                array_pop($this->parentTypeStack);
                break;
            case NodeKind::FIELD:
                array_pop($this->fieldDefStack);
                array_pop($this->typeStack);
                break;
            case NodeKind::DIRECTIVE:
                $this->directive = null;
                break;
            case NodeKind::OPERATION_DEFINITION:
            case NodeKind::INLINE_FRAGMENT:
            case NodeKind::FRAGMENT_DEFINITION:
                array_pop($this->typeStack);
                break;
            case NodeKind::VARIABLE_DEFINITION:
                array_pop($this->inputTypeStack);
                break;
            case NodeKind::ARGUMENT:
                $this->argument = null;
                array_pop($this->inputTypeStack);
                break;
            case NodeKind::LST:
            case NodeKind::OBJECT_FIELD:
                array_pop($this->inputTypeStack);
                break;
        }
    }

Usage Example

Example #1
0
 /**
  * Creates a new visitor instance which maintains a provided TypeInfo instance
  * along with visiting visitor.
  */
 static function visitWithTypeInfo(TypeInfo $typeInfo, $visitor)
 {
     return ['enter' => function ($node) use($typeInfo, $visitor) {
         $typeInfo->enter($node);
         $fn = self::getVisitFn($visitor, $node->kind, false);
         if ($fn) {
             $result = call_user_func_array($fn, func_get_args());
             if ($result) {
                 $typeInfo->leave($node);
                 if ($result instanceof Node) {
                     $typeInfo->enter($result);
                 }
             }
             return $result;
         }
         return null;
     }, 'leave' => function ($node) use($typeInfo, $visitor) {
         $fn = self::getVisitFn($visitor, $node->kind, true);
         $result = $fn ? call_user_func_array($fn, func_get_args()) : null;
         $typeInfo->leave($node);
         return $result;
     }];
 }
All Usage Examples Of GraphQL\Utils\TypeInfo::leave