Skip to content

Commit

Permalink
Stanning for tests (#1288)
Browse files Browse the repository at this point in the history
* property access

* ignore never read, only written

* use template args

* ignore lines

* Apply php-cs-fixer changes

Co-authored-by: shmax <shmax@users.noreply.github.com>
  • Loading branch information
shmax and shmax authored Jan 25, 2023
1 parent fc6723f commit ff7419b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 18 deletions.
18 changes: 1 addition & 17 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -93,20 +93,4 @@ parameters:
-
message: "#^SplObjectStorage\\<GraphQL\\\\Language\\\\AST\\\\SelectionSetNode, array\\{array\\<string, array\\<int, array\\{GraphQL\\\\Type\\\\Definition\\\\Type, GraphQL\\\\Language\\\\AST\\\\FieldNode, GraphQL\\\\Type\\\\Definition\\\\FieldDefinition\\|null\\}\\>\\>, array\\<int, string\\>\\}\\> does not accept array\\<int, mixed\\>\\.$#"
count: 1
path: src/Validator/Rules/OverlappingFieldsCanBeMerged.php

-
message: "#^Method GraphQL\\\\Tests\\\\Language\\\\VisitorTest\\:\\:getNodeByPath\\(\\) return type with generic class GraphQL\\\\Language\\\\AST\\\\NodeList does not specify its types\\: T$#"
count: 1
path: tests/Language/VisitorTest.php

-
message: "#^Variable property access on mixed\\.$#"
count: 2
path: tests/Language/VisitorTest.php

-
message: "#^Property GraphQL\\\\Tests\\\\Type\\\\SchemaTest\\:\\:\\$implementingType is never read, only written\\.$#"
count: 1
path: tests/Type/SchemaTest.php

path: src/Validator/Rules/OverlappingFieldsCanBeMerged.php
2 changes: 2 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ parameters:
# PHPStan does not play nicely with markTestSkipped()
- message: "~Unreachable statement - code above always terminates~"
path: tests
- message: "#^Property GraphQL\\\\Tests\\\\Type\\\\SchemaTest\\:\\:\\$implementingType is never read, only written\\.$#"
path: tests

includes:
- phpstan-baseline.neon
Expand Down
4 changes: 3 additions & 1 deletion tests/Language/VisitorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ private function checkVisitorFnArgs(DocumentNode $ast, array $args, bool $isEdit
if ($parent instanceof NodeList) {
self::assertEquals($node, $parent[$key]);
} else {
/** @phpstan-ignore-next-line */
self::assertEquals($node, $parent->{$key});
}

Expand All @@ -82,7 +83,7 @@ private function checkVisitorFnArgs(DocumentNode $ast, array $args, bool $isEdit
/**
* @param array<string|int> $path
*
* @return Node|NodeList
* @return Node|NodeList<SelectionNode&Node>
*/
private function getNodeByPath(DocumentNode $ast, array $path): object
{
Expand All @@ -92,6 +93,7 @@ private function getNodeByPath(DocumentNode $ast, array $path): object
if ($result instanceof NodeList) {
$result = $result[$key];
} else {
/** @phpstan-ignore-next-line */
$result = $result->{$key};
}
}
Expand Down

0 comments on commit ff7419b

Please sign in to comment.