From 19d982478b4a8d47cfefd17fdd72de109642724e Mon Sep 17 00:00:00 2001 From: Simon Podlipsky Date: Sat, 5 Jul 2025 10:19:50 +0300 Subject: [PATCH 1/2] feat: remove SchemaConfig::assertMaybeLazyObjectType() The methods are typed so I was wondering that we don't need the runtime validation. Also can remove `@throws InvariantViolation`. --- src/Type/SchemaConfig.php | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/src/Type/SchemaConfig.php b/src/Type/SchemaConfig.php index d82c164d9..77a3a4c65 100644 --- a/src/Type/SchemaConfig.php +++ b/src/Type/SchemaConfig.php @@ -144,13 +144,10 @@ public function getQuery() /** * @param MaybeLazyObjectType $query * - * @throws InvariantViolation - * * @api */ public function setQuery($query): self { - $this->assertMaybeLazyObjectType($query); $this->query = $query; return $this; @@ -169,13 +166,10 @@ public function getMutation() /** * @param MaybeLazyObjectType $mutation * - * @throws InvariantViolation - * * @api */ public function setMutation($mutation): self { - $this->assertMaybeLazyObjectType($mutation); $this->mutation = $mutation; return $this; @@ -194,13 +188,10 @@ public function getSubscription() /** * @param MaybeLazyObjectType $subscription * - * @throws InvariantViolation - * * @api */ public function setSubscription($subscription): self { - $this->assertMaybeLazyObjectType($subscription); $this->subscription = $subscription; return $this; @@ -315,22 +306,4 @@ public function setExtensionASTNodes(array $extensionASTNodes): self return $this; } - - /** - * @param mixed $maybeLazyObjectType Should be MaybeLazyObjectType - * - * @throws InvariantViolation - */ - protected function assertMaybeLazyObjectType($maybeLazyObjectType): void - { - if ($maybeLazyObjectType instanceof ObjectType || is_callable($maybeLazyObjectType) || is_null($maybeLazyObjectType)) { - return; - } - - $notMaybeLazyObjectType = is_object($maybeLazyObjectType) - ? get_class($maybeLazyObjectType) - : gettype($maybeLazyObjectType); - $objectTypeClass = ObjectType::class; - throw new InvariantViolation("Expected instanceof {$objectTypeClass}, a callable that returns such an instance, or null, got: {$notMaybeLazyObjectType}."); - } } From 7275422c6ef5b50ce1bd948faf4a32b4b9dd6359 Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Sat, 5 Jul 2025 07:20:47 +0000 Subject: [PATCH 2/2] Autofix --- docs/class-reference.md | 6 ------ 1 file changed, 6 deletions(-) diff --git a/docs/class-reference.md b/docs/class-reference.md index e9fd2ed9d..fda7f50f9 100644 --- a/docs/class-reference.md +++ b/docs/class-reference.md @@ -748,8 +748,6 @@ function getQuery() /** * @param MaybeLazyObjectType $query * - * @throws InvariantViolation - * * @api */ function setQuery($query): self @@ -768,8 +766,6 @@ function getMutation() /** * @param MaybeLazyObjectType $mutation * - * @throws InvariantViolation - * * @api */ function setMutation($mutation): self @@ -788,8 +784,6 @@ function getSubscription() /** * @param MaybeLazyObjectType $subscription * - * @throws InvariantViolation - * * @api */ function setSubscription($subscription): self