diff --git a/src/Console/PrintSchemaCommand.php b/src/Console/PrintSchemaCommand.php index 6bd7831374..6ee53d2ca7 100644 --- a/src/Console/PrintSchemaCommand.php +++ b/src/Console/PrintSchemaCommand.php @@ -5,9 +5,7 @@ use GraphQL\Type\Introspection; use GraphQL\Utils\SchemaPrinter; use Illuminate\Console\Command; -use Illuminate\Contracts\Filesystem\Filesystem; use Illuminate\Filesystem\FilesystemManager; -use Illuminate\Support\Facades\Storage; use Nuwave\Lighthouse\Federation\FederationPrinter; use Nuwave\Lighthouse\Schema\AST\ASTCache; use Nuwave\Lighthouse\Schema\SchemaBuilder; @@ -56,9 +54,10 @@ public function handle(ASTCache $cache, FilesystemManager $filesystemManager, Sc if ($this->option('write')) { $disk = $this->option('disk'); - if (! is_string($disk) && ! is_null($disk)) { + if (! is_string($disk) && ! is_null($disk)) { // @phpstan-ignore-line can be array $diskType = gettype($disk); $this->error("Expected option disk to be string or null, got: {$diskType}."); + return; } diff --git a/src/Deprecation/DetectDeprecatedUsage.php b/src/Deprecation/DetectDeprecatedUsage.php index e78942f974..77bf102b8d 100644 --- a/src/Deprecation/DetectDeprecatedUsage.php +++ b/src/Deprecation/DetectDeprecatedUsage.php @@ -25,13 +25,13 @@ class DetectDeprecatedUsage extends ValidationRule /** @var DeprecationHandler */ protected $deprecationHandler; - /** @param DeprecationHandler $deprecationHandler */ + /** @param DeprecationHandler $deprecationHandler */ public function __construct(callable $deprecationHandler) { $this->deprecationHandler = $deprecationHandler; } - /** @param DeprecationHandler $deprecationHandler */ + /** @param DeprecationHandler $deprecationHandler */ public static function handle(callable $deprecationHandler): void { DocumentValidator::addRule(new static($deprecationHandler)); diff --git a/src/Exceptions/DefinitionException.php b/src/Exceptions/DefinitionException.php index 8d326377e0..ec2ab51354 100644 --- a/src/Exceptions/DefinitionException.php +++ b/src/Exceptions/DefinitionException.php @@ -2,7 +2,6 @@ namespace Nuwave\Lighthouse\Exceptions; -use Exception; use GraphQL\Error\ClientAware; /** diff --git a/src/Execution/Arguments/ArgPartitioner.php b/src/Execution/Arguments/ArgPartitioner.php index b5ec1818d7..3cfd836f58 100644 --- a/src/Execution/Arguments/ArgPartitioner.php +++ b/src/Execution/Arguments/ArgPartitioner.php @@ -85,7 +85,7 @@ public static function relationMethods( /** * Attach a nested argument resolver to an argument. * - * @param \ReflectionClass<\Illuminate\Database\Eloquent\Model>|null $model + * @param \ReflectionClass<\Illuminate\Database\Eloquent\Model>|null $model */ protected static function attachNestedArgResolver(string $name, Argument &$argument, ?\ReflectionClass $model): void { diff --git a/src/Federation/BatchedEntityResolver.php b/src/Federation/BatchedEntityResolver.php index 167e7840d7..aa49c56a41 100644 --- a/src/Federation/BatchedEntityResolver.php +++ b/src/Federation/BatchedEntityResolver.php @@ -7,7 +7,7 @@ interface BatchedEntityResolver /** * Resolve multiple entities of a single type in one batch. * - * @param array> $representations + * @param array> $representations * * @return iterable must preserve the count and keys of $representations */ diff --git a/src/Federation/EntityResolverProvider.php b/src/Federation/EntityResolverProvider.php index 2584f4f490..4485e2b93f 100644 --- a/src/Federation/EntityResolverProvider.php +++ b/src/Federation/EntityResolverProvider.php @@ -261,7 +261,7 @@ public function firstSatisfiedKeyFields(Collection $keyFieldsSelections, array $ ?? throw new Error('Representation does not satisfy any set of uniquely identifying keys: ' . \Safe\json_encode($representation)); } - /** @param array $representation */ + /** @param array $representation */ protected function hydrateExternalFields(Model $model, array $representation, ObjectTypeDefinitionNode $definition): void { foreach ($definition->fields as $field) { diff --git a/src/GraphQL.php b/src/GraphQL.php index 96afd811f3..daabc4fb15 100644 --- a/src/GraphQL.php +++ b/src/GraphQL.php @@ -64,7 +64,7 @@ public function __construct( * * @api * - * @param array|null $variables + * @param array|null $variables * * @return array */ @@ -95,7 +95,7 @@ public function executeQueryString( * you will probably want to call `->toArray($debug)` on it, * with $debug being a combination of flags in @see \GraphQL\Error\DebugFlag * - * @param array|null $variables + * @param array|null $variables * * @return array */ diff --git a/src/Pagination/PaginationArgs.php b/src/Pagination/PaginationArgs.php index 43b22f35c2..b2a52e5e3e 100644 --- a/src/Pagination/PaginationArgs.php +++ b/src/Pagination/PaginationArgs.php @@ -78,7 +78,7 @@ protected static function calculateCurrentPage(int $first, int $after, int $defa * * @param \Illuminate\Database\Query\Builder|\Laravel\Scout\Builder|\Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Eloquent\Relations\Relation $builder * - * @return Paginator + * @return \Illuminate\Contracts\Pagination\Paginator */ public function applyToBuilder(QueryBuilder|ScoutBuilder|EloquentBuilder|Relation $builder): Paginator { diff --git a/src/Pagination/PaginatorField.php b/src/Pagination/PaginatorField.php index ba5244b64b..750b9c554d 100644 --- a/src/Pagination/PaginatorField.php +++ b/src/Pagination/PaginatorField.php @@ -13,9 +13,9 @@ class PaginatorField * @return array{ * count: int, * currentPage: int, - * firstItem: int, + * firstItem: int|null, * hasMorePages: bool, - * lastItem: int, + * lastItem: int|null, * lastPage: int, * perPage: int, * total: int, diff --git a/src/Pagination/SimplePaginatorField.php b/src/Pagination/SimplePaginatorField.php index a57053483b..8eaf623d6a 100644 --- a/src/Pagination/SimplePaginatorField.php +++ b/src/Pagination/SimplePaginatorField.php @@ -15,8 +15,8 @@ class SimplePaginatorField * @return array{ * count: int, * currentPage: int, - * firstItem: int, - * lastItem: int, + * firstItem: int|null, + * lastItem: int|null, * perPage: int, * hasMorePages: bool, * } diff --git a/src/Schema/AST/ASTHelper.php b/src/Schema/AST/ASTHelper.php index a314e834cb..b071ed5b81 100644 --- a/src/Schema/AST/ASTHelper.php +++ b/src/Schema/AST/ASTHelper.php @@ -139,7 +139,7 @@ public static function getUnderlyingNamedTypeNode(Node $node): NamedTypeNode /** * Extract a named argument from a given directive node. * - * @param mixed $default is returned if the directive does not have the argument + * @param mixed $default is returned if the directive does not have the argument */ public static function directiveArgValue(DirectiveNode $directive, string $name, mixed $default = null): mixed { diff --git a/src/Schema/AST/ExecutableTypeNodeConverter.php b/src/Schema/AST/ExecutableTypeNodeConverter.php index cb055bff9e..a2d805466a 100644 --- a/src/Schema/AST/ExecutableTypeNodeConverter.php +++ b/src/Schema/AST/ExecutableTypeNodeConverter.php @@ -13,7 +13,7 @@ public function __construct( protected TypeRegistry $typeRegistry, ) {} - /** @param \GraphQL\Type\Definition\Type&\GraphQL\Type\Definition\NullableType $type */ + /** @param \GraphQL\Type\Definition\Type&\GraphQL\Type\Definition\NullableType $type */ protected function nonNull(mixed $type): NonNull { return Type::nonNull($type); @@ -22,7 +22,7 @@ protected function nonNull(mixed $type): NonNull /** * @template T of \GraphQL\Type\Definition\Type * - * @param T|callable():T $type + * @param T|callable():T $type * * @return \GraphQL\Type\Definition\ListOfType */ diff --git a/src/Schema/AST/FallbackTypeNodeConverter.php b/src/Schema/AST/FallbackTypeNodeConverter.php index f6fabfcf40..a36eb80d51 100644 --- a/src/Schema/AST/FallbackTypeNodeConverter.php +++ b/src/Schema/AST/FallbackTypeNodeConverter.php @@ -22,7 +22,7 @@ protected function nonNull(mixed $type): NonNull /** * @template T of Type * - * @param T|callable():T $type + * @param T|callable():T $type * * @return ListOfType */ diff --git a/src/Schema/Directives/AggregateDirective.php b/src/Schema/Directives/AggregateDirective.php index 605fc0f0d5..b0a4811f7d 100644 --- a/src/Schema/Directives/AggregateDirective.php +++ b/src/Schema/Directives/AggregateDirective.php @@ -111,10 +111,7 @@ public function resolveField(FieldValue $fieldValue): callable if (is_string($relation)) { return function (Model $parent, array $args, GraphQLContext $context, ResolveInfo $resolveInfo): Deferred { $relationBatchLoader = BatchLoaderRegistry::instance( - array_merge( - $this->qualifyPath($args, $resolveInfo), - [$this->function(), $this->column()], - ), + [...$this->qualifyPath($args, $resolveInfo), $this->function(), $this->column()], fn (): RelationBatchLoader => new RelationBatchLoader( new AggregateModelsLoader( $this->relation(), @@ -144,16 +141,16 @@ public function resolveField(FieldValue $fieldValue): callable $builderResolver = $this->getResolverFromArgument('builder'); return function (mixed $root, array $args, GraphQLContext $context, ResolveInfo $resolveInfo) use ($builderResolver) { - $query = $builderResolver($root, $args, $context, $resolveInfo); + $builder = $builderResolver($root, $args, $context, $resolveInfo); assert( - $query instanceof QueryBuilder || $query instanceof EloquentBuilder, + $builder instanceof QueryBuilder || $builder instanceof EloquentBuilder, "The method referenced by the builder argument of the @{$this->name()} directive on {$this->nodeName()} must return a Builder.", ); - $this->makeBuilderDecorator($root, $args, $context, $resolveInfo)($query); + $this->makeBuilderDecorator($root, $args, $context, $resolveInfo)($builder); - return $query->{$this->function()}($this->column()); + return $builder->{$this->function()}($this->column()); }; } diff --git a/src/Schema/Directives/BaseDirective.php b/src/Schema/Directives/BaseDirective.php index f76cc50265..84ec3ca41c 100644 --- a/src/Schema/Directives/BaseDirective.php +++ b/src/Schema/Directives/BaseDirective.php @@ -120,7 +120,7 @@ protected function directiveHasArgument(string $name): bool * * @api * - * @param mixed $default Use this over `??` to preserve explicit `null` + * @param mixed $default Use this over `??` to preserve explicit `null` * * @return mixed The argument value or the default */ @@ -257,7 +257,7 @@ protected function namespaceModelClass(string $modelClassCandidate): string * * @api * - * @param array $names + * @param array $names */ protected function validateMutuallyExclusiveArguments(array $names): void { diff --git a/src/Schema/Directives/ComplexityDirective.php b/src/Schema/Directives/ComplexityDirective.php index 5c3e08dd3c..addd007a2d 100644 --- a/src/Schema/Directives/ComplexityDirective.php +++ b/src/Schema/Directives/ComplexityDirective.php @@ -2,7 +2,6 @@ namespace Nuwave\Lighthouse\Schema\Directives; -use Nuwave\Lighthouse\Pagination\PaginationManipulator; use Nuwave\Lighthouse\Schema\Values\FieldValue; use Nuwave\Lighthouse\Support\Contracts\ComplexityResolverDirective; use Nuwave\Lighthouse\Support\Utils; diff --git a/src/Schema/ResolverProvider.php b/src/Schema/ResolverProvider.php index eace20079d..4da836922c 100644 --- a/src/Schema/ResolverProvider.php +++ b/src/Schema/ResolverProvider.php @@ -26,7 +26,7 @@ public function provideResolver(FieldValue $fieldValue): \Closure // Return any non-null value to continue nested field resolution // when the root Query type is returned as part of the result. if (ASTHelper::getUnderlyingTypeName($fieldValue->getField()) === RootType::QUERY) { - return static fn () => true; + return static fn (): bool => true; } return \Closure::fromCallable( diff --git a/src/Schema/TypeRegistry.php b/src/Schema/TypeRegistry.php index a806d5b856..160ef1ce23 100644 --- a/src/Schema/TypeRegistry.php +++ b/src/Schema/TypeRegistry.php @@ -168,7 +168,7 @@ public function register(Type $type): self * * @api * - * @param callable(): \GraphQL\Type\Definition\Type&\GraphQL\Type\Definition\NamedType $type + * @param callable(): \GraphQL\Type\Definition\Type&\GraphQL\Type\Definition\NamedType $type */ public function registerLazy(string $name, callable $type): self { @@ -200,7 +200,7 @@ public function overwrite(Type $type): self * * @api * - * @param callable(): \GraphQL\Type\Definition\Type&\GraphQL\Type\Definition\NamedType $type + * @param callable(): \GraphQL\Type\Definition\Type&\GraphQL\Type\Definition\NamedType $type */ public function overwriteLazy(string $name, callable $type): self { diff --git a/src/Validation/RulesGatherer.php b/src/Validation/RulesGatherer.php index ad11f2e0d5..d4c29121d5 100644 --- a/src/Validation/RulesGatherer.php +++ b/src/Validation/RulesGatherer.php @@ -2,7 +2,6 @@ namespace Nuwave\Lighthouse\Validation; -use Illuminate\Contracts\Validation\Rule; use Illuminate\Support\Carbon; use Illuminate\Support\Collection; use Illuminate\Validation\ValidationRuleParser; diff --git a/src/Validation/Validator.php b/src/Validation/Validator.php index cc13605e5d..efa239bd86 100644 --- a/src/Validation/Validator.php +++ b/src/Validation/Validator.php @@ -31,7 +31,7 @@ public function setArgs(ArgumentSet $args): void * Retrieve the value of an argument or the default. * * @param string $key the key of the argument, may use dot notation to get nested values - * @param mixed $default returned in case the argument is not present + * @param mixed $default returned in case the argument is not present */ protected function arg(string $key, mixed $default = null): mixed { diff --git a/tests/Integration/Schema/Directives/AggregateDirectiveTest.php b/tests/Integration/Schema/Directives/AggregateDirectiveTest.php index 6a1e7fcae9..ae11436eaa 100644 --- a/tests/Integration/Schema/Directives/AggregateDirectiveTest.php +++ b/tests/Integration/Schema/Directives/AggregateDirectiveTest.php @@ -285,7 +285,7 @@ public function testAggregateWithBuilder(): void ]); } - /** @param array{difficulty: int, exclude: int} $args */ + /** @param array{difficulty: int, exclude: int} $args */ public function builder(mixed $root, array $args): Builder { return DB::table('tasks') diff --git a/tests/Integration/Subscriptions/Storage/RedisStorageManagerTest.php b/tests/Integration/Subscriptions/Storage/RedisStorageManagerTest.php index 9d15702225..0c560215fa 100644 --- a/tests/Integration/Subscriptions/Storage/RedisStorageManagerTest.php +++ b/tests/Integration/Subscriptions/Storage/RedisStorageManagerTest.php @@ -110,7 +110,7 @@ public function testSocketIDStoredOnSubscribe(): void $this->assertSame('1234.1234', $createdSubscriber->socket_id); } - /** @param array $headers */ + /** @param array $headers */ protected function querySubscription(string $topic = /** @lang GraphQL */ 'taskUpdated(id: 123)', array $headers = []): TestResponse { return $this->graphQL(/** @lang GraphQL */ " diff --git a/tests/Unit/Pagination/PaginationTypeTest.php b/tests/Unit/Pagination/PaginationTypeTest.php index 39bc4d6fb3..4741d4c760 100644 --- a/tests/Unit/Pagination/PaginationTypeTest.php +++ b/tests/Unit/Pagination/PaginationTypeTest.php @@ -11,7 +11,7 @@ final class PaginationTypeTest extends TestCase /** * @dataProvider invalidPaginationTypes * - * @param string $type An invalid type + * @param string $type An invalid type */ public function testThrowsExceptionForUnsupportedTypes(string $type): void { diff --git a/tests/Unit/Subscriptions/Broadcasters/PusherBroadcasterTest.php b/tests/Unit/Subscriptions/Broadcasters/PusherBroadcasterTest.php index 514c7201fa..e2d36063ef 100644 --- a/tests/Unit/Subscriptions/Broadcasters/PusherBroadcasterTest.php +++ b/tests/Unit/Subscriptions/Broadcasters/PusherBroadcasterTest.php @@ -53,7 +53,7 @@ public function testPusherNeverUsesLoggerInterface(): void $this->broadcast($subscriber); } - /** @param \Nuwave\Lighthouse\Subscriptions\Subscriber&\PHPUnit\Framework\MockObject\MockObject $subscriber */ + /** @param \Nuwave\Lighthouse\Subscriptions\Subscriber&\PHPUnit\Framework\MockObject\MockObject $subscriber */ private function broadcast(object $subscriber): void { $broadcastManager = $this->app->make(BroadcastManager::class); diff --git a/tests/Utils/Models/Task.php b/tests/Utils/Models/Task.php index 2575ab3413..2bab3da234 100644 --- a/tests/Utils/Models/Task.php +++ b/tests/Utils/Models/Task.php @@ -97,7 +97,7 @@ public function user(): BelongsTo } /** - * @param \Illuminate\Database\Eloquent\Builder $query + * @param \Illuminate\Database\Eloquent\Builder $query * * @return \Illuminate\Database\Eloquent\Builder */ @@ -107,7 +107,7 @@ public function scopeCompleted(EloquentBuilder $query): EloquentBuilder } /** - * @param \Illuminate\Database\Eloquent\Builder $query + * @param \Illuminate\Database\Eloquent\Builder $query * @param array $args * * @return \Illuminate\Database\Eloquent\Builder @@ -118,7 +118,7 @@ public function scopeFoo(EloquentBuilder $query, array $args): EloquentBuilder } /** - * @param \Illuminate\Database\Eloquent\Builder $query + * @param \Illuminate\Database\Eloquent\Builder $query * @param iterable $tags * * @return \Illuminate\Database\Eloquent\Builder diff --git a/tests/Utils/Models/User.php b/tests/Utils/Models/User.php index e8a14b23f8..ac18cbae92 100644 --- a/tests/Utils/Models/User.php +++ b/tests/Utils/Models/User.php @@ -120,8 +120,8 @@ public function team(): BelongsTo } /** - * @param \Illuminate\Database\Eloquent\Builder $query - * @param array{company: string} $args + * @param \Illuminate\Database\Eloquent\Builder $query + * @param array{company: string} $args * * @return \Illuminate\Database\Eloquent\Builder */ @@ -132,7 +132,7 @@ public function scopeCompanyName(EloquentBuilder $query, array $args): EloquentB } /** - * @param \Illuminate\Database\Eloquent\Builder $query + * @param \Illuminate\Database\Eloquent\Builder $query * * @return \Illuminate\Database\Eloquent\Builder */ diff --git a/tests/Utils/Models/WithEnum.php b/tests/Utils/Models/WithEnum.php index a9fd32b6a5..6b56e489ed 100644 --- a/tests/Utils/Models/WithEnum.php +++ b/tests/Utils/Models/WithEnum.php @@ -29,7 +29,7 @@ final class WithEnum extends Model ]; /** - * @param \Illuminate\Database\Eloquent\Builder $builder + * @param \Illuminate\Database\Eloquent\Builder $builder * * @return \Illuminate\Database\Eloquent\Builder */