From 5ab521c6b67d69f12b0b6535f09ff0e9645a2d8c Mon Sep 17 00:00:00 2001 From: Benedikt Franke Date: Tue, 11 Jun 2024 09:44:01 +0200 Subject: [PATCH] Update tooling --- composer.json | 5 ++++- rector.php | 2 +- src/Async/AsyncDirective.php | 2 +- src/Pagination/PaginationManipulator.php | 1 + tests/Integration/Async/AsyncDirectiveTest.php | 2 +- tests/Unit/Schema/Directives/HideDirectiveTest.php | 3 ++- tests/Unit/Schema/Directives/ShowDirectiveTest.php | 3 ++- 7 files changed, 12 insertions(+), 6 deletions(-) diff --git a/composer.json b/composer.json index 51931772db..3382c3f9ec 100644 --- a/composer.json +++ b/composer.json @@ -91,7 +91,10 @@ "psr-4": { "Benchmarks\\": "benchmarks/", "Tests\\": "tests/" - } + }, + "files": [ + "vendor/dms/phpunit-arraysubset-asserts/src/ArraySubsetAsserts.php" + ] }, "config": { "allow-plugins": { diff --git a/rector.php b/rector.php index 6429884752..39f11214d9 100644 --- a/rector.php +++ b/rector.php @@ -34,7 +34,7 @@ ]); $rectorConfig->skip([ __DIR__ . '/src/Tracing/FederatedTracing/Proto', // Generated code - __DIR__ . '/tests/database/migrations', // Does not fit autoloading standards + __DIR__ . '/tests/database/migrations', // Does not fit autoloader standards __DIR__ . '/tests/LaravelPhpdocAlignmentFixer.php', // Copied from Laravel CallableThisArrayToAnonymousFunctionRector::class, // Callable in array form is shorter and more efficient IssetOnPropertyObjectToPropertyExistsRector::class, // isset() is nice when moving towards typed properties diff --git a/src/Async/AsyncDirective.php b/src/Async/AsyncDirective.php index d8490e8ed4..3e8b23f04f 100644 --- a/src/Async/AsyncDirective.php +++ b/src/Async/AsyncDirective.php @@ -71,7 +71,7 @@ public function manipulateFieldDefinition(DocumentAST &$documentAST, FieldDefini $parentName = $parentType->name->value; if ($parentName !== RootType::MUTATION) { $location = "{$parentName}.{$fieldDefinition->name->value}"; - throw new DefinitionException("The @async directive must only be used on fields of the root type mutation, found it on {$location}."); + throw new DefinitionException("The @async directive must only be used on root mutation fields, found it on {$location}."); } } } diff --git a/src/Pagination/PaginationManipulator.php b/src/Pagination/PaginationManipulator.php index 8db1dd9a7b..74a10d2468 100644 --- a/src/Pagination/PaginationManipulator.php +++ b/src/Pagination/PaginationManipulator.php @@ -378,6 +378,7 @@ private function maybeInheritCacheControlDirective(): string /** If federation v2 is used, add the @shareable directive to the pagination generic types. */ private function maybeAddShareableDirective(): string { + // Not using Illuminate\Container\Container::getInstance() here as it causes PHPStan issues if (app()->providerIsLoaded(FederationServiceProvider::class) && FederationHelper::isUsingFederationV2($this->documentAST)) { return /** @lang GraphQL */ '@shareable'; } diff --git a/tests/Integration/Async/AsyncDirectiveTest.php b/tests/Integration/Async/AsyncDirectiveTest.php index 0d68ad25cd..7d1b97d7b8 100644 --- a/tests/Integration/Async/AsyncDirectiveTest.php +++ b/tests/Integration/Async/AsyncDirectiveTest.php @@ -80,7 +80,7 @@ public function testDispatchesMutationOnCustomQueue(): void public function testOnlyOnMutations(): void { $this->expectExceptionObject(new DefinitionException( - 'The @async directive must only be used on fields of the root type mutation, found it on Query.foo.', + 'The @async directive must only be used on root mutation fields, found it on Query.foo.', )); $this->buildSchema(/** @lang GraphQL */ ' type Query { diff --git a/tests/Unit/Schema/Directives/HideDirectiveTest.php b/tests/Unit/Schema/Directives/HideDirectiveTest.php index 4ebd0c97be..f5c0542a48 100644 --- a/tests/Unit/Schema/Directives/HideDirectiveTest.php +++ b/tests/Unit/Schema/Directives/HideDirectiveTest.php @@ -2,6 +2,7 @@ namespace Tests\Unit\Schema\Directives; +use Illuminate\Container\Container; use Tests\TestCase; final class HideDirectiveTest extends TestCase @@ -59,7 +60,7 @@ public function testHiddenWhenManuallySettingEnv(): void } '; - app()->instance('env', 'production'); + Container::getInstance()->instance('env', 'production'); $this->graphQL($introspectionQuery) ->assertJsonCount(0, 'data.__schema.queryType.fields'); } diff --git a/tests/Unit/Schema/Directives/ShowDirectiveTest.php b/tests/Unit/Schema/Directives/ShowDirectiveTest.php index 9845c57b39..8840366e2f 100644 --- a/tests/Unit/Schema/Directives/ShowDirectiveTest.php +++ b/tests/Unit/Schema/Directives/ShowDirectiveTest.php @@ -2,6 +2,7 @@ namespace Tests\Unit\Schema\Directives; +use Illuminate\Container\Container; use Tests\TestCase; final class ShowDirectiveTest extends TestCase @@ -59,7 +60,7 @@ public function testShownOnAnotherEnv(): void } '; - app()->instance('env', 'production'); + Container::getInstance()->instance('env', 'production'); $this->graphQL($introspectionQuery) ->assertJsonCount(1, 'data.__schema.queryType.fields') ->assertJsonPath('data.__schema.queryType.fields.0.name', 'hiddenField');