Skip to content

Commit f51a9a4

Browse files
authored
Fix problems found by the newest version of PHPStan (#1084)
1 parent d7361e0 commit f51a9a4

File tree

5 files changed

+1
-9
lines changed

5 files changed

+1
-9
lines changed

src/Language/Parser.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,6 @@ private function parseOperationType(): string
605605
*/
606606
private function parseVariableDefinitions(): NodeList
607607
{
608-
// @phpstan-ignore-next-line generic type of empty NodeList is not initialized
609608
return $this->peek(Token::PAREN_L)
610609
? $this->many(
611610
Token::PAREN_L,
@@ -703,7 +702,6 @@ private function parseArguments(bool $isConst): NodeList
703702
? fn (): ArgumentNode => $this->parseConstArgument()
704703
: fn (): ArgumentNode => $this->parseArgument();
705704

706-
// @phpstan-ignore-next-line generic type of empty NodeList is not initialized
707705
return $this->peek(Token::PAREN_L)
708706
? $this->many(Token::PAREN_L, $parseFn, Token::PAREN_R)
709707
: new NodeList([]);
@@ -1224,7 +1222,6 @@ private function parseFieldDefinition(): FieldDefinitionNode
12241222
*/
12251223
private function parseArgumentsDefinition(): NodeList
12261224
{
1227-
// @phpstan-ignore-next-line generic type of empty NodeList is not initialized
12281225
return $this->peek(Token::PAREN_L)
12291226
? $this->many(
12301227
Token::PAREN_L,
@@ -1340,7 +1337,6 @@ private function parseEnumTypeDefinition(): EnumTypeDefinitionNode
13401337
*/
13411338
private function parseEnumValuesDefinition(): NodeList
13421339
{
1343-
// @phpstan-ignore-next-line generic type of empty NodeList is not initialized
13441340
return $this->peek(Token::BRACE_L)
13451341
? $this->many(
13461342
Token::BRACE_L,
@@ -1388,7 +1384,6 @@ private function parseInputObjectTypeDefinition(): InputObjectTypeDefinitionNode
13881384
*/
13891385
private function parseInputFieldsDefinition(): NodeList
13901386
{
1391-
// @phpstan-ignore-next-line generic type of empty NodeList is not initialized
13921387
return $this->peek(Token::BRACE_L)
13931388
? $this->many(
13941389
Token::BRACE_L,

src/Language/Printer.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,6 @@ protected function p(?Node $node, bool $isDescription = false): string
218218
return 'fragment ' . $this->p($node->name)
219219
. $this->wrap(
220220
'(',
221-
// @phpstan-ignore-next-line generic type of empty NodeList is not recognized
222221
$this->printList($node->variableDefinitions ?? new NodeList([]), ', '),
223222
')'
224223
)

src/Validator/Rules/QueryComplexity.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ public function __construct(int $maxQueryComplexity)
4949
public function getVisitor(QueryValidationContext $context): array
5050
{
5151
$this->context = $context;
52-
53-
// @phpstan-ignore-next-line Initializing with an empty array does not set the generic type
5452
$this->variableDefs = new NodeList([]);
5553
$this->fieldNodeAndDefs = new ArrayObject();
5654

tests/Language/NodeListTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public function testThrowsOnInvalidArrays(): void
5151

5252
public function testPushNodes(): void
5353
{
54+
/** @var NodeList<NameNode> $nodeList */
5455
$nodeList = new NodeList([]);
5556
self::assertCount(0, $nodeList);
5657

tests/Language/VisitorTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,6 @@ public function testAllowsEditingRootNodeOnEnterAndLeave(): void
236236
'enter' => function (DocumentNode $node) use ($ast): DocumentNode {
237237
$this->checkVisitorFnArgs($ast, func_get_args());
238238
$tmp = clone $node;
239-
// @phpstan-ignore-next-line generic type of empty NodeList is not initialized
240239
$tmp->definitions = new NodeList([]);
241240
$tmp->didEnter = true;
242241

0 commit comments

Comments
 (0)