diff --git a/composer.json b/composer.json index 54be707a0..41292f3bb 100644 --- a/composer.json +++ b/composer.json @@ -28,7 +28,7 @@ }, "require-dev": { "beberlei/porpaginas": "^2.0", - "doctrine/coding-standard": "^13.0", + "doctrine/coding-standard": "^13.0 || ^14.0", "ecodev/graphql-upload": "^7.0", "laminas/laminas-diactoros": "^3.5", "php-coveralls/php-coveralls": "^2.7", diff --git a/src/Types/MutableInputObjectType.php b/src/Types/MutableInputObjectType.php index 5ee9c574a..8cd91c6b0 100644 --- a/src/Types/MutableInputObjectType.php +++ b/src/Types/MutableInputObjectType.php @@ -7,6 +7,7 @@ use GraphQL\Error\InvariantViolation; use GraphQL\Type\Definition\InputObjectField; use GraphQL\Type\Definition\InputObjectType; +use GraphQL\Type\Definition\InputType; use GraphQL\Type\Definition\Type; use RuntimeException; @@ -18,7 +19,6 @@ * It can be later extended with the "Decorate" annotation * * @phpstan-import-type InputObjectConfig from InputObjectType - * @phpstan-import-type ArgumentType from InputObjectField * @phpstan-import-type InputObjectFieldConfig from InputObjectField */ class MutableInputObjectType extends InputObjectType implements MutableInputInterface @@ -90,21 +90,16 @@ public function getFields(): array $this->finalFields = parent::getFields(); foreach ($this->fieldsCallables as $fieldsCallable) { $fieldDefinitions = $fieldsCallable(); - /** @var (ArgumentType)[] $fieldDefinitions */ foreach ($fieldDefinitions as $name => $fieldDefinition) { + assert(is_string($name)); if ($fieldDefinition instanceof Type) { - $fieldDefinition = ['type' => $fieldDefinition]; + assert($fieldDefinition instanceof InputType); + $this->finalFields[$name] = new InputObjectField(['name' => $name, 'type' => $fieldDefinition]); + } else { + /** @phpstan-var InputObjectFieldConfig $fieldDefinition */ + $fieldDefinition['name'] = $name; + $this->finalFields[$name] = new InputObjectField($fieldDefinition); } - assert(is_string($name)); - // @codingStandardsIgnoreStart - /** - * @var InputObjectFieldConfig $config - */ - // @codingStandardsIgnoreEnd - - $config = $fieldDefinition; - $config['name'] = $name; - $this->finalFields[$name] = new InputObjectField($config); } } if (empty($this->finalFields)) {