PHP 클래스 GraphQL\Language\Visitor

파일 보기 프로젝트 열기: webonyx/graphql-php 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$visitorKeys

공개 메소드들

메소드 설명
getVisitFn ( $visitor, $kind, $isLeaving ) : null
removeNode ( ) Remove current node
skipNode ( ) Skip current node
stop ( ) : VisitorOperation Break visitor
visit ( $root, $visitor, $keyMap = null ) visit() will walk through an AST using a depth first traversal, calling the visitor's enter function at each node in the traversal, and calling the leave function after visiting that node and all of it's child nodes.
visitInParallel ( $visitors ) : array
visitWithTypeInfo ( TypeInfo $typeInfo, $visitor ) Creates a new visitor instance which maintains a provided TypeInfo instance along with visiting visitor.

메소드 상세

getVisitFn() 공개 정적인 메소드

public static getVisitFn ( $visitor, $kind, $isLeaving ) : null
$visitor
$kind
$isLeaving
리턴 null

removeNode() 공개 정적인 메소드

Remove current node
public static removeNode ( )

skipNode() 공개 정적인 메소드

Skip current node
public static skipNode ( )

stop() 공개 정적인 메소드

Break visitor
public static stop ( ) : VisitorOperation
리턴 VisitorOperation

visit() 공개 정적인 메소드

By returning different values from the enter and leave functions, the behavior of the visitor can be altered, including skipping over a sub-tree of the AST (by returning false), editing the AST by returning a value or null to remove the value, or to stop the whole traversal by returning BREAK. When using visit() to edit an AST, the original AST will not be modified, and a new version of the AST with the changes applied will be returned from the visit function. var editedAST = visit(ast, { enter(node, key, parent, path, ancestors) { @return undefined: no action false: skip visiting this node visitor.BREAK: stop visiting altogether null: delete this node any value: replace this node with the returned value }, leave(node, key, parent, path, ancestors) { @return undefined: no action visitor.BREAK: stop visiting altogether null: delete this node any value: replace this node with the returned value } }); Alternatively to providing enter() and leave() functions, a visitor can instead provide functions named the same as the kinds of AST nodes, or enter/leave visitors at a named key, leading to four permutations of visitor API: 1) Named visitors triggered when entering a node a specific kind. visit(ast, { Kind(node) { enter the "Kind" node } }) 2) Named visitors that trigger upon entering and leaving a node of a specific kind. visit(ast, { Kind: { enter(node) { enter the "Kind" node } leave(node) { leave the "Kind" node } } }) 3) Generic visitors that trigger upon entering and leaving any node. visit(ast, { enter(node) { enter any node }, leave(node) { leave any node } }) 4) Parallel visitors for entering and leaving nodes of a specific kind. visit(ast, { enter: { Kind(node) { enter the "Kind" node } }, leave: { Kind(node) { leave the "Kind" node } } })
public static visit ( $root, $visitor, $keyMap = null )

visitInParallel() 정적인 공개 메소드

static public visitInParallel ( $visitors ) : array
$visitors
리턴 array

visitWithTypeInfo() 정적인 공개 메소드

Creates a new visitor instance which maintains a provided TypeInfo instance along with visiting visitor.
static public visitWithTypeInfo ( TypeInfo $typeInfo, $visitor )
$typeInfo GraphQL\Utils\TypeInfo

프로퍼티 상세

$visitorKeys 공개적으로 정적으로 프로퍼티

public static $visitorKeys