Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove ArrayAccess from NodeList and enforce contiguous int keys #1323

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Revert "Fully revert NodeList changes"
This reverts commit 75d647a.
spawnia committed Feb 22, 2023
commit bb26398a6351ad71c49d5c89c6e17b9e874ab179
4 changes: 2 additions & 2 deletions src/Language/Visitor.php
Original file line number Diff line number Diff line change
@@ -224,7 +224,7 @@ public static function visit(object $root, array $visitor, ?array $keyMap = null
throw new \Exception("Can only add Node to NodeList, got: {$notNode}.");
}

$node[$editKey] = $editValue;
$node->set($editKey, $editValue);
} else {
$node->{$editKey} = $editValue;
}
@@ -246,7 +246,7 @@ public static function visit(object $root, array $visitor, ?array $keyMap = null
? $index
: $keys[$index];
$node = $parent instanceof NodeList
? $parent[$key]
? $parent->get($key)
: $parent->{$key};
}
if ($node === null) {
4 changes: 2 additions & 2 deletions tests/Error/ErrorTest.php
Original file line number Diff line number Diff line change
@@ -114,8 +114,8 @@ public function testSerializesToIncludeMessageAndLocations(): void
{
$ast = Parser::parse('{ field }');
/** @var OperationDefinitionNode $operationDefinition */
$operationDefinition = $ast->definitions[0];
$node = $operationDefinition->selectionSet->selections[0];
$operationDefinition = $ast->definitions->get(0);
$node = $operationDefinition->selectionSet->selections->get(0);
$e = new Error('msg', [$node]);

self::assertEquals(