From 00804230d65d0aae1f3e246dedbe0c9b0845bcc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Va=C5=A1ek=20Henzl?= Date: Sat, 19 Feb 2022 13:30:22 +1300 Subject: [PATCH 01/11] Align `Utils::suggestionList()` with the reference implementation --- src/Utils/LexicalDistance.php | 133 +++++++++++++++++++++++++++++ src/Utils/Utils.php | 24 ++---- tests/Type/EnumTypeTest.php | 3 +- tests/Utils/SuggestionListTest.php | 72 +++++++++++++--- 4 files changed, 204 insertions(+), 28 deletions(-) create mode 100644 src/Utils/LexicalDistance.php diff --git a/src/Utils/LexicalDistance.php b/src/Utils/LexicalDistance.php new file mode 100644 index 000000000..015e6c637 --- /dev/null +++ b/src/Utils/LexicalDistance.php @@ -0,0 +1,133 @@ + + */ + private array $inputArray; + + /** + * @var array> + */ + private array $rows; + + public function __construct(string $input) + { + $this->input = $input; + $this->inputLowerCase = \strtolower($input); + $this->inputArray = self::stringToArray($this->inputLowerCase); + + $length = \mb_strlen($input); + $this->rows = [ + \array_fill(0, $length, 0), + \array_fill(0, $length, 0), + \array_fill(0, $length, 0), + ]; + } + + public function measure(string $option, float $threshold): ?int + { + if ($this->input === $option) { + return 0; + } + + $optionLowerCase = \strtolower($option); + + // Any case change counts as a single edit + if ($this->inputLowerCase === $optionLowerCase) { + return 1; + } + + $a = self::stringToArray($optionLowerCase); + $b = $this->inputArray; + + if (\count($a) < \count($b)) { + $tmp = $a; + $a = $b; + $b = $tmp; + } + + $aLength = \count($a); + $bLength = \count($b); + + if ($aLength - $bLength > $threshold) { + return null; + } + + $rows = &$this->rows; + for ($j = 0; $j <= $bLength; ++$j) { + $rows[0][$j] = $j; + } + + for ($i = 1; $i <= $aLength; ++$i) { + $upRow = &$rows[($i - 1) % 3]; + $currentRow = &$rows[$i % 3]; + + $smallestCell = ($currentRow[0] = $i); + for ($j = 1; $j <= $bLength; ++$j) { + $cost = $a[$i - 1] === $b[$j - 1] ? 0 : 1; + + $currentCell = \min( + $upRow[$j] + 1, // delete + $currentRow[$j - 1] + 1, // insert + $upRow[$j - 1] + $cost, // substitute + ); + + if ($i > 1 && $j > 1 && $a[$i - 1] === $b[$j - 2] && $a[$i - 2] === $b[$j - 1]) { + // transposition + $doubleDiagonalCell = $rows[($i - 2) % 3][$j - 2]; + $currentCell = \min($currentCell, $doubleDiagonalCell + 1); + } + + if ($currentCell < $smallestCell) { + $smallestCell = $currentCell; + } + + $currentRow[$j] = $currentCell; + } + + // Early exit, since distance can't go smaller than smallest element of the previous row. + if ($smallestCell > $threshold) { + return null; + } + } + + $distance = $rows[$aLength % 3][$bLength]; + + return $distance <= $threshold ? $distance : null; + } + + /** + * @return array + */ + private static function stringToArray(string $str): array + { + $array = []; + foreach (\mb_str_split($str) as $char) { + $array[] = \mb_ord($char); + } + + return $array; + } +} diff --git a/src/Utils/Utils.php b/src/Utils/Utils.php index 3c853b6fd..5b2b529cb 100644 --- a/src/Utils/Utils.php +++ b/src/Utils/Utils.php @@ -7,7 +7,6 @@ use function array_reduce; use function array_shift; use function array_slice; -use function asort; use function count; use function dechex; use function func_get_args; @@ -24,7 +23,6 @@ use function is_scalar; use function is_string; use function json_encode; -use function levenshtein; use function mb_convert_encoding; use function mb_strlen; use function mb_substr; @@ -36,7 +34,6 @@ use function range; use function sprintf; use stdClass; -use function strtolower; use function unpack; class Utils @@ -348,10 +345,6 @@ static function ($list, $index) use ($selected, $selectedLength): string { * Given an invalid input string and a list of valid options, returns a filtered * list of valid options sorted based on their similarity with the input. * - * Includes a custom alteration from Damerau-Levenshtein to treat case changes - * as a single edit which helps identify mis-cased values with an edit distance - * of 1 - * * @param array $options * * @return array @@ -359,22 +352,21 @@ static function ($list, $index) use ($selected, $selectedLength): string { public static function suggestionList(string $input, array $options): array { $optionsByDistance = []; + $lexicalDistance = new LexicalDistance($input); $threshold = mb_strlen($input) * 0.4 + 1; foreach ($options as $option) { - if ($input === $option) { - $distance = 0; - } else { - $distance = (strtolower($input) === strtolower($option) - ? 1 - : levenshtein($input, $option)); - } + $distance = $lexicalDistance->measure($option, $threshold); - if ($distance <= $threshold) { + if ($distance !== null) { $optionsByDistance[$option] = $distance; } } - asort($optionsByDistance); + \uksort($optionsByDistance, static function (string $a, string $b) use ($optionsByDistance) { + $distanceDiff = $optionsByDistance[$a] - $optionsByDistance[$b]; + + return $distanceDiff !== 0 ? $distanceDiff : \strnatcmp($a, $b); + }); return array_keys($optionsByDistance); } diff --git a/tests/Type/EnumTypeTest.php b/tests/Type/EnumTypeTest.php index 276b1eba1..a541f3b35 100644 --- a/tests/Type/EnumTypeTest.php +++ b/tests/Type/EnumTypeTest.php @@ -348,8 +348,7 @@ public function testDoesNotAcceptValuesWithIncorrectCasing(): void '{ colorEnum(fromEnum: green) }', null, [ - // Improves upon the reference implementation - 'message' => 'Value "green" does not exist in "Color" enum. Did you mean the enum value "GREEN"?', + 'message' => 'Value "green" does not exist in "Color" enum. Did you mean the enum value "GREEN" or "RED"?', 'locations' => [new SourceLocation(1, 23)], ] ); diff --git a/tests/Utils/SuggestionListTest.php b/tests/Utils/SuggestionListTest.php index b0221c488..e2ce94cd7 100644 --- a/tests/Utils/SuggestionListTest.php +++ b/tests/Utils/SuggestionListTest.php @@ -7,17 +7,13 @@ class SuggestionListTest extends TestCase { - // DESCRIBE: suggestionList - /** + * @see describe('suggestionList') * @see it('Returns results when input is empty') */ public function testResturnsResultsWhenInputIsEmpty(): void { - self::assertEquals( - Utils::suggestionList('', ['a']), - ['a'] - ); + self::assertEquals(Utils::suggestionList('', ['a']), ['a']); } /** @@ -25,20 +21,76 @@ public function testResturnsResultsWhenInputIsEmpty(): void */ public function testReturnsEmptyArrayWhenThereAreNoOptions(): void { + self::assertEquals(Utils::suggestionList('input', []), []); + } + + /** + * @see it('Returns options with small lexical distance') + */ + public function testReturnsOptionsWithSmallLexicalDistance(): void + { + self::assertEquals(Utils::suggestionList('greenish', ['green']), ['green']); + self::assertEquals(Utils::suggestionList('green', ['greenish']), ['greenish']); + } + + /** + * @see it('Rejects options with distance that exceeds threshold') + */ + public function testRejectsOptionsWithDistanceThatExceedsThreshold(): void + { + self::assertEquals(Utils::suggestionList('aaaa', ['aaab']), ['aaab']); + self::assertEquals(Utils::suggestionList('aaaa', ['aabb']), ['aabb']); + self::assertEquals(Utils::suggestionList('aaaa', ['abbb']), []); + self::assertEquals(Utils::suggestionList('ab', ['ca']), []); + } + + /** + * @see it('Returns options with different case') + */ + public function testReturnsOptionsWithDifferentCase(): void + { + self::assertEquals( + Utils::suggestionList('verylongstring', ['VERYLONGSTRING']), + ['VERYLONGSTRING'] + ); + self::assertEquals( + Utils::suggestionList('VERYLONGSTRING', ['verylongstring']), + ['verylongstring'] + ); self::assertEquals( - Utils::suggestionList('input', []), - [] + Utils::suggestionList('VERYLONGSTRING', ['VeryLongString']), + ['VeryLongString'] ); } /** - * @see it('Returns options sorted based on similarity') + * @see it('Returns options with transpositions') */ - public function testReturnsOptionsSortedBasedOnSimilarity(): void + public function testReturnsOptionsWithTranspositions(): void + { + self::assertEquals(Utils::suggestionList('agr', ['arg']), ['arg']); + self::assertEquals(Utils::suggestionList('214365879', ['123456789']), ['123456789']); + } + + /** + * @see it('Returns options sorted based on lexical distance') + */ + public function testReturnsOptionsSortedBasedOnLexicalDistance(): void { self::assertEquals( Utils::suggestionList('abc', ['a', 'ab', 'abc']), ['abc', 'ab', 'a'] ); } + + /** + * @see it('Returns options with the same lexical distance sorted lexicographically') + */ + public function testReturnsOptionsWithTheSameLexicalDistanceSortedLexicographically(): void + { + self::assertEquals( + Utils::suggestionList('a', ['az', 'ax', 'ay']), + ['ax', 'ay', 'az'] + ); + } } From 3202bc45a26bbcb9c09f2b976d9787f28cd5847c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Va=C5=A1ek=20Henzl?= Date: Sat, 19 Feb 2022 14:02:02 +1300 Subject: [PATCH 02/11] Add changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6b1e6bea6..591322ba6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,6 +41,7 @@ You can find and compare releases at the [GitHub release page](https://github.co - Throw if `Introspection::fromSchema()` returns no data - Reorganize abstract class `ASTValidationContext` to interface `ValidationContext` - Reorganize AST interfaces related to schema and type extensions +- Align `Utils::suggestionList()` with the reference implementation (#1075) ### Added From 858ac323d6d2493b0567d16fb5fe54443ad35fb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Va=C5=A1ek=20Henzl?= Date: Sat, 5 Mar 2022 12:05:01 +1300 Subject: [PATCH 03/11] Fix typo --- tests/Utils/SuggestionListTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Utils/SuggestionListTest.php b/tests/Utils/SuggestionListTest.php index e2ce94cd7..462b752f3 100644 --- a/tests/Utils/SuggestionListTest.php +++ b/tests/Utils/SuggestionListTest.php @@ -11,7 +11,7 @@ class SuggestionListTest extends TestCase * @see describe('suggestionList') * @see it('Returns results when input is empty') */ - public function testResturnsResultsWhenInputIsEmpty(): void + public function testReturnsResultsWhenInputIsEmpty(): void { self::assertEquals(Utils::suggestionList('', ['a']), ['a']); } From 38bffd755b445facc103f7b96b6ae1e5c707fbc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Va=C5=A1ek=20Henzl?= Date: Sat, 5 Mar 2022 12:36:14 +1300 Subject: [PATCH 04/11] Add comments --- src/Utils/LexicalDistance.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Utils/LexicalDistance.php b/src/Utils/LexicalDistance.php index 015e6c637..c2b73d85d 100644 --- a/src/Utils/LexicalDistance.php +++ b/src/Utils/LexicalDistance.php @@ -23,6 +23,8 @@ class LexicalDistance private string $inputLowerCase; /** + * List of char codes in the input string. + * * @var array */ private array $inputArray; @@ -119,6 +121,8 @@ public function measure(string $option, float $threshold): ?int } /** + * Returns a list of char codes in the given string. + * * @return array */ private static function stringToArray(string $str): array From c1e7e991fe873f86eadb8a24dcfff6162937c04e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Va=C5=A1ek=20Henzl?= Date: Sat, 5 Mar 2022 12:37:03 +1300 Subject: [PATCH 05/11] Fix tests --- tests/Utils/SuggestionListTest.php | 70 +++++++++++++++++++++--------- 1 file changed, 50 insertions(+), 20 deletions(-) diff --git a/tests/Utils/SuggestionListTest.php b/tests/Utils/SuggestionListTest.php index 462b752f3..aa44250fa 100644 --- a/tests/Utils/SuggestionListTest.php +++ b/tests/Utils/SuggestionListTest.php @@ -13,7 +13,10 @@ class SuggestionListTest extends TestCase */ public function testReturnsResultsWhenInputIsEmpty(): void { - self::assertEquals(Utils::suggestionList('', ['a']), ['a']); + self::assertSame( + ['a'], + Utils::suggestionList('', ['a']), + ); } /** @@ -21,7 +24,10 @@ public function testReturnsResultsWhenInputIsEmpty(): void */ public function testReturnsEmptyArrayWhenThereAreNoOptions(): void { - self::assertEquals(Utils::suggestionList('input', []), []); + self::assertSame( + [], + Utils::suggestionList('input', []), + ); } /** @@ -29,8 +35,14 @@ public function testReturnsEmptyArrayWhenThereAreNoOptions(): void */ public function testReturnsOptionsWithSmallLexicalDistance(): void { - self::assertEquals(Utils::suggestionList('greenish', ['green']), ['green']); - self::assertEquals(Utils::suggestionList('green', ['greenish']), ['greenish']); + self::assertSame( + ['green'], + Utils::suggestionList('greenish', ['green']), + ); + self::assertSame( + ['greenish'], + Utils::suggestionList('green', ['greenish']), + ); } /** @@ -38,10 +50,22 @@ public function testReturnsOptionsWithSmallLexicalDistance(): void */ public function testRejectsOptionsWithDistanceThatExceedsThreshold(): void { - self::assertEquals(Utils::suggestionList('aaaa', ['aaab']), ['aaab']); - self::assertEquals(Utils::suggestionList('aaaa', ['aabb']), ['aabb']); - self::assertEquals(Utils::suggestionList('aaaa', ['abbb']), []); - self::assertEquals(Utils::suggestionList('ab', ['ca']), []); + self::assertSame( + ['aaab'], + Utils::suggestionList('aaaa', ['aaab']), + ); + self::assertSame( + ['aabb'], + Utils::suggestionList('aaaa', ['aabb']), + ); + self::assertSame( + [], + Utils::suggestionList('aaaa', ['abbb']), + ); + self::assertSame( + [], + Utils::suggestionList('ab', ['ca']), + ); } /** @@ -49,17 +73,17 @@ public function testRejectsOptionsWithDistanceThatExceedsThreshold(): void */ public function testReturnsOptionsWithDifferentCase(): void { - self::assertEquals( + self::assertSame( + ['VERYLONGSTRING'], Utils::suggestionList('verylongstring', ['VERYLONGSTRING']), - ['VERYLONGSTRING'] ); - self::assertEquals( + self::assertSame( + ['verylongstring'], Utils::suggestionList('VERYLONGSTRING', ['verylongstring']), - ['verylongstring'] ); - self::assertEquals( + self::assertSame( + ['VeryLongString'], Utils::suggestionList('VERYLONGSTRING', ['VeryLongString']), - ['VeryLongString'] ); } @@ -68,8 +92,14 @@ public function testReturnsOptionsWithDifferentCase(): void */ public function testReturnsOptionsWithTranspositions(): void { - self::assertEquals(Utils::suggestionList('agr', ['arg']), ['arg']); - self::assertEquals(Utils::suggestionList('214365879', ['123456789']), ['123456789']); + self::assertSame( + ['arg'], + Utils::suggestionList('agr', ['arg']), + ); + self::assertSame( + ['123456789'], + Utils::suggestionList('214365879', ['123456789']), + ); } /** @@ -77,9 +107,9 @@ public function testReturnsOptionsWithTranspositions(): void */ public function testReturnsOptionsSortedBasedOnLexicalDistance(): void { - self::assertEquals( + self::assertSame( + ['abc', 'ab', 'a'], Utils::suggestionList('abc', ['a', 'ab', 'abc']), - ['abc', 'ab', 'a'] ); } @@ -88,9 +118,9 @@ public function testReturnsOptionsSortedBasedOnLexicalDistance(): void */ public function testReturnsOptionsWithTheSameLexicalDistanceSortedLexicographically(): void { - self::assertEquals( + self::assertSame( + ['ax', 'ay', 'az'], Utils::suggestionList('a', ['az', 'ax', 'ay']), - ['ax', 'ay', 'az'] ); } } From 18da3ddb431e380af9c43254a17f172e39910316 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Va=C5=A1ek=20Henzl?= Date: Sat, 5 Mar 2022 12:41:10 +1300 Subject: [PATCH 06/11] Fix `suggestionList` to always return string values --- src/Utils/Utils.php | 3 ++- tests/Utils/SuggestionListTest.php | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Utils/Utils.php b/src/Utils/Utils.php index 9f8da7ed7..d413e14c9 100644 --- a/src/Utils/Utils.php +++ b/src/Utils/Utils.php @@ -287,6 +287,7 @@ static function ($list, $index) use ($selected, $selectedLength): string { */ public static function suggestionList(string $input, array $options): array { + /** @var array $optionsByDistance */ $optionsByDistance = []; $lexicalDistance = new LexicalDistance($input); $threshold = mb_strlen($input) * 0.4 + 1; @@ -304,6 +305,6 @@ public static function suggestionList(string $input, array $options): array return $distanceDiff !== 0 ? $distanceDiff : \strnatcmp($a, $b); }); - return array_keys($optionsByDistance); + return array_map('strval', array_keys($optionsByDistance)); } } diff --git a/tests/Utils/SuggestionListTest.php b/tests/Utils/SuggestionListTest.php index aa44250fa..2988001c3 100644 --- a/tests/Utils/SuggestionListTest.php +++ b/tests/Utils/SuggestionListTest.php @@ -123,4 +123,12 @@ public function testReturnsOptionsWithTheSameLexicalDistanceSortedLexicographica Utils::suggestionList('a', ['az', 'ax', 'ay']), ); } + + public function testReturnsNumericStringOptionsAsStrings(): void + { + self::assertSame( + ['12', '13', '14'], + Utils::suggestionList('1', ['12', '13', '14']), + ); + } } From a325b8125f73e22db6ef4b096828c03c6f22264b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Va=C5=A1ek=20Henzl?= Date: Sat, 5 Mar 2022 12:46:48 +1300 Subject: [PATCH 07/11] Rename variable in a loop --- src/Utils/LexicalDistance.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Utils/LexicalDistance.php b/src/Utils/LexicalDistance.php index c2b73d85d..44a1cd251 100644 --- a/src/Utils/LexicalDistance.php +++ b/src/Utils/LexicalDistance.php @@ -78,8 +78,8 @@ public function measure(string $option, float $threshold): ?int } $rows = &$this->rows; - for ($j = 0; $j <= $bLength; ++$j) { - $rows[0][$j] = $j; + for ($i = 0; $i <= $bLength; ++$i) { + $rows[0][$i] = $i; } for ($i = 1; $i <= $aLength; ++$i) { From 2e4bccbed946d8008bc29fd8a45c7b69d4c5f8f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Va=C5=A1ek=20Henzl?= Date: Sat, 5 Mar 2022 13:31:06 +1300 Subject: [PATCH 08/11] Remove unnecessary initialisation --- src/Utils/LexicalDistance.php | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/Utils/LexicalDistance.php b/src/Utils/LexicalDistance.php index 44a1cd251..19e81380a 100644 --- a/src/Utils/LexicalDistance.php +++ b/src/Utils/LexicalDistance.php @@ -32,20 +32,13 @@ class LexicalDistance /** * @var array> */ - private array $rows; + private array $rows = []; public function __construct(string $input) { $this->input = $input; $this->inputLowerCase = \strtolower($input); $this->inputArray = self::stringToArray($this->inputLowerCase); - - $length = \mb_strlen($input); - $this->rows = [ - \array_fill(0, $length, 0), - \array_fill(0, $length, 0), - \array_fill(0, $length, 0), - ]; } public function measure(string $option, float $threshold): ?int From cb5f97990ae5f24de87596efbc7139c7cd2ed97a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Va=C5=A1ek=20Henzl?= Date: Mon, 14 Mar 2022 21:39:34 +1300 Subject: [PATCH 09/11] Add comment about `measure()` returning `int|null` --- src/Utils/LexicalDistance.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Utils/LexicalDistance.php b/src/Utils/LexicalDistance.php index 19e81380a..abb24c0fe 100644 --- a/src/Utils/LexicalDistance.php +++ b/src/Utils/LexicalDistance.php @@ -15,6 +15,9 @@ * of 1. * * This distance can be useful for detecting typos in input or sorting + * + * Unlike the native levenshtein() function that always returns int, LexicalDistance::measure() returns int|null. + * It takes into account the threshold and returns null if the measured distance is bigger. */ class LexicalDistance { From b455fbb18c60e403af0c7a052a4adbb11aa31de7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Va=C5=A1ek=20Henzl?= Date: Mon, 14 Mar 2022 21:47:06 +1300 Subject: [PATCH 10/11] Remove unnecessary class field --- src/Utils/LexicalDistance.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/Utils/LexicalDistance.php b/src/Utils/LexicalDistance.php index abb24c0fe..33f0f23db 100644 --- a/src/Utils/LexicalDistance.php +++ b/src/Utils/LexicalDistance.php @@ -32,11 +32,6 @@ class LexicalDistance */ private array $inputArray; - /** - * @var array> - */ - private array $rows = []; - public function __construct(string $input) { $this->input = $input; @@ -73,7 +68,8 @@ public function measure(string $option, float $threshold): ?int return null; } - $rows = &$this->rows; + /** @var array> $rows */ + $rows = []; for ($i = 0; $i <= $bLength; ++$i) { $rows[0][$i] = $i; } From 7251b8014438a423473784ece0897b5b0a948504 Mon Sep 17 00:00:00 2001 From: vhenzl Date: Mon, 14 Mar 2022 08:52:47 +0000 Subject: [PATCH 11/11] Apply php-cs-fixer changes --- tests/Error/ErrorTest.php | 2 +- tests/Executor/DeferredFieldsTest.php | 8 ++++---- tests/Type/ResolveInfoTest.php | 2 +- tests/Utils/BreakingChangesFinderTest.php | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/Error/ErrorTest.php b/tests/Error/ErrorTest.php index 21e964ad6..db2340108 100644 --- a/tests/Error/ErrorTest.php +++ b/tests/Error/ErrorTest.php @@ -201,7 +201,7 @@ public function getNodes(): ?array self::assertEquals([1 => 2], $locatedError->getPositions()); self::assertNotNull($locatedError->getSource()); - $error = new class('msg', new NullValueNode([]), null, [], ) extends Error { + $error = new class('msg', new NullValueNode([]), null, []) extends Error { public function getNodes(): ?array { return [new NullValueNode([])]; diff --git a/tests/Executor/DeferredFieldsTest.php b/tests/Executor/DeferredFieldsTest.php index 22d2b0315..62c12b0c7 100644 --- a/tests/Executor/DeferredFieldsTest.php +++ b/tests/Executor/DeferredFieldsTest.php @@ -592,10 +592,10 @@ public function testDeferredChaining(): void } '); - $author1 = ['name' => 'John'/*, 'bestFriend' => ['name' => 'Dirk']*/]; - $author2 = ['name' => 'Jane'/*, 'bestFriend' => ['name' => 'Joe']*/]; - $author3 = ['name' => 'Joe'/*, 'bestFriend' => ['name' => 'Jane']*/]; - $author4 = ['name' => 'Dirk'/*, 'bestFriend' => ['name' => 'John']*/]; + $author1 = ['name' => 'John'/* , 'bestFriend' => ['name' => 'Dirk'] */]; + $author2 = ['name' => 'Jane'/* , 'bestFriend' => ['name' => 'Joe'] */]; + $author3 = ['name' => 'Joe'/* , 'bestFriend' => ['name' => 'Jane'] */]; + $author4 = ['name' => 'Dirk'/* , 'bestFriend' => ['name' => 'John'] */]; $story1 = ['title' => 'Story #8', 'author' => $author1]; $story2 = ['title' => 'Story #3', 'author' => $author3]; diff --git a/tests/Type/ResolveInfoTest.php b/tests/Type/ResolveInfoTest.php index 5b40d8c75..188a67100 100644 --- a/tests/Type/ResolveInfoTest.php +++ b/tests/Type/ResolveInfoTest.php @@ -322,7 +322,7 @@ public function testMergedFragmentsFieldSelection(): void 'url' => true, ], 'replies' => [ - 'body' => true, //this would be missing if not for the fix https://github.com/webonyx/graphql-php/pull/98 + 'body' => true, // this would be missing if not for the fix https://github.com/webonyx/graphql-php/pull/98 'author' => [ 'id' => true, 'name' => true, diff --git a/tests/Utils/BreakingChangesFinderTest.php b/tests/Utils/BreakingChangesFinderTest.php index 9f30b35d4..853f3521a 100644 --- a/tests/Utils/BreakingChangesFinderTest.php +++ b/tests/Utils/BreakingChangesFinderTest.php @@ -30,7 +30,7 @@ public function setUp(): void ]); } - //DESCRIBE: findBreakingChanges + // DESCRIBE: findBreakingChanges /** * @see it('should detect if a type was removed or not') @@ -1769,7 +1769,7 @@ public function testShouldDetectIfATypeWasAddedToAUnionType(): void ], ]); // logially equivalent to type1; findTypesRemovedFromUnions should not - //treat this as different than type1 + // treat this as different than type1 $type1a = new ObjectType([ 'name' => 'Type1', 'fields' => [