diff --git a/.github/workflows/continuous_integration.yml b/.github/workflows/continuous_integration.yml index 3573d65..49ffa10 100644 --- a/.github/workflows/continuous_integration.yml +++ b/.github/workflows/continuous_integration.yml @@ -15,8 +15,13 @@ jobs: strategy: matrix: - install-args: ['', '--prefer-lowest'] - php-version: ['7.4', '8.0'] + include: + - install-args: "--prefer-lowest" + php-version: "8.1" + - install-args: "" + php-version: "8.1" + - install-args: "" + php-version: "8.2" fail-fast: false steps: diff --git a/composer.json b/composer.json index 87e73ef..09f6bf3 100644 --- a/composer.json +++ b/composer.json @@ -13,26 +13,27 @@ { "name": "David N\u00e9grier", "email": "d.negrier@thecodingmachine.com", - "homepage": "http://mouf-php.com" + "homepage": "https://workadventu.re" } ], "scripts": { "test": "phpunit" }, "require": { - "php": ">=7.2|^8", - "thecodingmachine/graphqlite": "^6.0", - "illuminate/console": "^5.7|^6.0|^7|^8|^9", - "illuminate/container": "^5.7|^6.0|^7|^8|^9", - "illuminate/support": "^5.7|^6.0|^7|^8|^9", - "illuminate/cache": "^5.7|^6.0|^7|^8|^9", + "php": "^8.1", + "thecodingmachine/graphqlite": "^v6.2.1", + "illuminate/console": "^9 || ^10", + "illuminate/container": "^9 || ^10", + "illuminate/support": "^9 || ^10", + "illuminate/cache": "^9 || ^10", "symfony/psr-http-message-bridge": "^1.3.0 || ^2", "laminas/laminas-diactoros": "^2.2.2", - "symfony/cache": "^4.3 || ^5 || ^6" + "symfony/cache": "^4.3 || ^5 || ^6", + "psr/container": "^2.0.2" }, "require-dev": { - "orchestra/testbench": "^3.7.7 || ^4 || ^5", - "phpunit/phpunit": "^7.5.4 || ^8.3", + "orchestra/testbench": "^7 || ^8", + "phpunit/phpunit": "^9.6.6 || ^10.0.19", "ext-sqlite3": "*" }, "autoload": { @@ -47,7 +48,7 @@ }, "extra": { "branch-alias": { - "dev-master": "6.0.x-dev" + "dev-master": "6.1.x-dev" }, "laravel": { "providers": [ diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 562bbbd..2f3f9c0 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,36 +1,25 @@ - - - - - ./tests/ - - - - - - - - - - - src/ - - src/routes - - - - - - - + + + + src/ + + + src/routes + + + + + + + + + ./tests/ + + + + + + + diff --git a/src/Exceptions/ValidateException.php b/src/Exceptions/ValidateException.php index d6cb007..d563f27 100644 --- a/src/Exceptions/ValidateException.php +++ b/src/Exceptions/ValidateException.php @@ -19,22 +19,11 @@ public static function create(string $message, string $argumentName) return $exception; } - /** - * @return bool - */ - public function isClientSafe() + public function isClientSafe(): bool { return true; } - /** - * @return string - */ - public function getCategory() - { - return 'Validate'; - } - /** * Returns the "extensions" object attached to the GraphQL error. diff --git a/src/Mappers/PaginatorTypeMapper.php b/src/Mappers/PaginatorTypeMapper.php index 3900fee..e110a77 100644 --- a/src/Mappers/PaginatorTypeMapper.php +++ b/src/Mappers/PaginatorTypeMapper.php @@ -5,6 +5,7 @@ namespace TheCodingMachine\GraphQLite\Laravel\Mappers; use GraphQL\Type\Definition\InputObjectType; +use GraphQL\Type\Definition\NamedType; use GraphQL\Type\Definition\NullableType; use GraphQL\Type\Definition\OutputType; use GraphQL\Type\Definition\Type; @@ -196,11 +197,11 @@ public function canMapNameToType(string $typeName): bool * * @param string $typeName The name of the GraphQL type * - * @return Type&((ResolvableMutableInputInterface&InputObjectType)|MutableObjectType|MutableInterfaceType) + * @return Type&NamedType&((ResolvableMutableInputInterface&InputObjectType)|MutableObjectType|MutableInterfaceType) * * @throws CannotMapTypeExceptionInterface */ - public function mapNameToType(string $typeName): Type + public function mapNameToType(string $typeName): Type&NamedType { if (strpos($typeName, 'LengthAwarePaginatorResult_') === 0) { $subTypeName = substr($typeName, 27); diff --git a/src/Mappers/Parameters/ParameterValidator.php b/src/Mappers/Parameters/ParameterValidator.php index e490656..a1e57b6 100644 --- a/src/Mappers/Parameters/ParameterValidator.php +++ b/src/Mappers/Parameters/ParameterValidator.php @@ -6,6 +6,7 @@ use GraphQL\Type\Definition\InputType; use GraphQL\Type\Definition\ResolveInfo; +use GraphQL\Type\Definition\Type; use Illuminate\Validation\Factory as ValidationFactory; use TheCodingMachine\GraphQLite\Exceptions\GraphQLAggregateException; use TheCodingMachine\GraphQLite\Laravel\Exceptions\ValidateException; @@ -45,11 +46,8 @@ public function __construct(InputTypeParameterInterface $parameter, string $para /** * @param array $args - * @param mixed $context - * - * @return mixed */ - public function resolve(?object $source, array $args, $context, ResolveInfo $info) + public function resolve(?object $source, array $args, mixed $context, ResolveInfo $info): mixed { $value = $this->parameter->resolve($source, $args, $context, $info); @@ -68,7 +66,7 @@ public function resolve(?object $source, array $args, $context, ResolveInfo $inf return $value; } - public function getType(): InputType + public function getType(): InputType&Type { return $this->parameter->getType(); } @@ -78,10 +76,7 @@ public function hasDefaultValue(): bool return $this->parameter->hasDefaultValue(); } - /** - * @return mixed - */ - public function getDefaultValue() + public function getDefaultValue(): mixed { return $this->parameter->getDefaultValue(); } diff --git a/src/SanePsr11ContainerAdapter.php b/src/SanePsr11ContainerAdapter.php index dca053d..ac34eb0 100644 --- a/src/SanePsr11ContainerAdapter.php +++ b/src/SanePsr11ContainerAdapter.php @@ -53,7 +53,7 @@ public function get($id) * * @return bool */ - public function has($id) + public function has($id): bool { if (class_exists($id) && !$this->container->has($id)) { try { diff --git a/tests/Providers/GraphQLiteServiceProviderTest.php b/tests/Providers/GraphQLiteServiceProviderTest.php index 72d53d7..94c3aca 100644 --- a/tests/Providers/GraphQLiteServiceProviderTest.php +++ b/tests/Providers/GraphQLiteServiceProviderTest.php @@ -87,21 +87,19 @@ public function testValidator() $response->assertJson([ 'errors' => [ [ - 'message' => 'The foo must be a valid email address.', 'extensions' => [ 'argument' => 'foo', - 'category' => 'Validate' ], ], [ - 'message' => 'The bar must be greater than 42.', 'extensions' => [ 'argument' => 'bar', - 'category' => 'Validate' ], ] ] ]); + $this->assertStringContainsString('must be a valid email address.', $response->json('errors')[0]['message']); + $this->assertStringContainsString('must be greater than 42.', $response->json('errors')[1]['message']); $this->assertSame(400, $response->getStatusCode(), $response->getContent()); } @@ -114,34 +112,31 @@ public function testValidatorMultiple() [ 'extensions' => [ 'argument' => 'foo', - 'category' => 'Validate' ], ], [ - 'message' => 'The foo must be a valid IPv4 address.', 'extensions' => [ 'argument' => 'foo', - 'category' => 'Validate' ], ] ] ]); - $this->assertStringContainsString('The foo must start with one of the following: 192', $response->json('errors')[0]['message']); + $this->assertStringContainsString('must start with one of the following: 192', $response->json('errors')[0]['message']); + $this->assertStringContainsString('must be a valid IPv4 address.', $response->json('errors')[1]['message']); $this->assertSame(400, $response->getStatusCode(), $response->getContent()); $response = $this->json('POST', '/graphql', ['query' => '{ testValidatorMultiple(foo:"192.168.1") }']); $response->assertJson([ 'errors' => [ [ - 'message' => 'The foo must be a valid IPv4 address.', 'extensions' => [ 'argument' => 'foo', - 'category' => 'Validate' ], ] ] ]); + $this->assertStringContainsString('must be a valid IPv4 address.', $response->json('errors')[0]['message']); $this->assertSame(400, $response->getStatusCode(), $response->getContent()); @@ -152,12 +147,11 @@ public function testValidatorMultiple() [ 'extensions' => [ 'argument' => 'foo', - 'category' => 'Validate' ], ] ] ]); - $this->assertStringContainsString('The foo must start with one of the following: 192', $response->json('errors')[0]['message']); + $this->assertStringContainsString('must start with one of the following: 192', $response->json('errors')[0]['message']); $this->assertSame(400, $response->getStatusCode(), $response->getContent());