Skip to content

Commit f6da18a

Browse files
authored
Fix NodeVisitor return type by allowing Node
1 parent dcbd2ea commit f6da18a

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

docs/class-reference.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1350,7 +1350,7 @@ visitor API:
13501350
]
13511351
]);
13521352

1353-
@phpstan-type NodeVisitor callable(Node): (VisitorOperation|null|false|void)
1353+
@phpstan-type NodeVisitor callable(Node): (VisitorOperation|Node|null|false|void)
13541354
@phpstan-type VisitorArray array<string, NodeVisitor>|array<string, array<string, NodeVisitor>>
13551355

13561356
@see \GraphQL\Tests\Language\VisitorTest

phpstan.neon.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ parameters:
3535
path: tests
3636

3737
# Cannot satisfy input covariance
38-
- '~(expects|should return) array<string, array<string, callable\(GraphQL\\Language\\AST\\Node\): \(GraphQL\\Language\\VisitorOperation\|void\|false\|null\)>\|\(callable\(GraphQL\\Language\\AST\\Node\): \(GraphQL\\Language\\VisitorOperation\|void\|false\|null\)\)>(,| but returns)?~'
38+
- '~(expects|should return) array\<string, array\<string, callable\(GraphQL\\Language\\AST\\Node\)\: \(GraphQL\\Language\\AST\\Node\|GraphQL\\Language\\VisitorOperation\|void\|false\|null\)\>\|\(callable\(GraphQL\\Language\\AST\\Node\)\: \(GraphQL\\Language\\AST\\Node\|GraphQL\\Language\\VisitorOperation\|void\|false\|null\)\)\>(,| but returns)?~'
3939

4040
# No need to have @throws in methods that are never called
4141
## PHPUnit

src/Language/Visitor.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
* ]
9090
* ]);
9191
*
92-
* @phpstan-type NodeVisitor callable(Node): (VisitorOperation|null|false|void)
92+
* @phpstan-type NodeVisitor callable(Node): (VisitorOperation|Node|null|false|void)
9393
* @phpstan-type VisitorArray array<string, NodeVisitor>|array<string, array<string, NodeVisitor>>
9494
*
9595
* @see \GraphQL\Tests\Language\VisitorTest
@@ -478,7 +478,7 @@ public static function visitWithTypeInfo(TypeInfo $typeInfo, array $visitor): ar
478478
/**
479479
* @phpstan-param VisitorArray $visitor
480480
*
481-
* @return (callable(Node $node, string|int|null $key, Node|NodeList<Node>|null $parent, array<int, int|string> $path, array<int, Node|NodeList<Node>> $ancestors): (VisitorOperation|Node|null))|(callable(Node): (VisitorOperation|void|false|null))|null
481+
* @return (callable(Node $node, string|int|null $key, Node|NodeList<Node>|null $parent, array<int, int|string> $path, array<int, Node|NodeList<Node>> $ancestors): (VisitorOperation|Node|null))|(callable(Node): (VisitorOperation|Node|void|false|null))|null
482482
*/
483483
protected static function extractVisitFn(array $visitor, string $kind, bool $isLeaving): ?callable
484484
{

0 commit comments

Comments
 (0)