Skip to content

Commit a2a9ae1

Browse files
authored
Merge pull request #60 from dsavina/chore/general-upgrade
Upgrade dependencies to prepare 5.0.0 release
2 parents ae2c741 + a89df76 commit a2a9ae1

18 files changed

+60
-73
lines changed

.travis.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,20 @@ matrix:
1515
include:
1616
# Test the latest stable release
1717
- php: 7.2
18-
- php: 7.4
18+
- php: 8.0
1919
env: COVERAGE=true PHPUNIT_FLAGS="-v --coverage-text"
2020

2121
# Test LTS versions.
22-
- php: 7.4
22+
- php: 8.0
2323
env: DEPENDENCIES="symfony/lts:^4"
2424

2525
# Latest commit to master
26-
- php: 7.4
26+
- php: 8.0
2727
env: STABILITY="dev"
2828

2929
allow_failures:
3030
# Minimum supported dependencies with the latest and oldest PHP version
31-
- php: 7.4
31+
- php: 8.0
3232
env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" SYMFONY_DEPRECATIONS_HELPER="weak_vendors"
3333
- php: 7.2
3434
env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" SYMFONY_DEPRECATIONS_HELPER="weak_vendors"

GraphqliteBundle.php

-21
This file was deleted.

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
[![Coverage Status](https://coveralls.io/repos/thecodingmachine/graphqlite-symfony-validator-bridge/badge.svg?branch=master&service=github)](https://coveralls.io/github/thecodingmachine/graphqlite-symfony-validator-bridge?branch=master)
66

77

8-
# Graphqlite - Symfony validator bridge
8+
# GraphQLite - Symfony validator bridge
99

1010
A bridge between GraphQLite and the Symfony Validator component
1111

composer.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
],
1919
"require" : {
2020
"php" : ">=7.2",
21-
"thecodingmachine/graphqlite" : "^4.1",
22-
"symfony/validator": "^4 | ^5",
21+
"thecodingmachine/graphqlite" : "^5.0",
22+
"symfony/validator": "^4.2 | ^5",
2323
"doctrine/annotations": "^1.6"
2424
},
2525
"require-dev": {
@@ -28,7 +28,7 @@
2828
"phpstan/phpstan": "^0.12.14",
2929
"php-coveralls/php-coveralls": "^2.1.0",
3030
"symfony/translation": "^4",
31-
"doctrine/coding-standard": "^7.0"
31+
"doctrine/coding-standard": "^9.0"
3232
},
3333
"scripts": {
3434
"phpstan": "phpstan analyse src/ -c phpstan.neon --level=7 --no-progress",
@@ -38,17 +38,17 @@
3838
},
3939
"autoload" : {
4040
"psr-4" : {
41-
"TheCodingMachine\\Graphqlite\\Validator\\" : "src/"
41+
"TheCodingMachine\\GraphQLite\\Validator\\" : "src/"
4242
}
4343
},
4444
"autoload-dev" : {
4545
"psr-4" : {
46-
"TheCodingMachine\\Graphqlite\\Validator\\" : "tests/"
46+
"TheCodingMachine\\GraphQLite\\Validator\\" : "tests/"
4747
}
4848
},
4949
"extra": {
5050
"branch-alias": {
51-
"dev-master": "4.1.x-dev"
51+
"dev-master": "5.0.x-dev"
5252
}
5353
},
5454
"minimum-stability": "dev",

phpcs.xml.dist

+13
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,17 @@
4949
<property name="enableNativeTypeHint" value="false"/>
5050
</properties>
5151
</rule>
52+
53+
<!-- Disable "mixed" type hints only available since PHP 8.0 -->
54+
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHint">
55+
<properties>
56+
<property name="enableMixedTypeHint" value="false"/>
57+
</properties>
58+
</rule>
59+
60+
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint">
61+
<properties>
62+
<property name="enableMixedTypeHint" value="false"/>
63+
</properties>
64+
</rule>
5265
</ruleset>

src/Annotations/Assertion.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22

33
declare(strict_types=1);
44

5-
namespace TheCodingMachine\Graphqlite\Validator\Annotations;
5+
namespace TheCodingMachine\GraphQLite\Validator\Annotations;
66

77
use BadMethodCallException;
88
use Symfony\Component\Validator\Constraint;
99
use TheCodingMachine\GraphQLite\Annotations\ParameterAnnotationInterface;
10+
1011
use function is_array;
1112
use function ltrim;
1213

@@ -41,7 +42,7 @@ public function __construct(array $values)
4142
}
4243

4344
$this->for = ltrim($values['for'], '$');
44-
$this->constraint = is_array($values['constraint']) ? $values['constraint'] : [ $values['constraint'] ];
45+
$this->constraint = is_array($values['constraint']) ? $values['constraint'] : [$values['constraint']];
4546
}
4647

4748
public function getTarget(): string

src/ConstraintViolationException.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
namespace TheCodingMachine\Graphqlite\Validator;
5+
namespace TheCodingMachine\GraphQLite\Validator;
66

77
use Exception;
88
use Symfony\Component\Validator\ConstraintViolationInterface;
@@ -46,12 +46,12 @@ public function getExtensions(): array
4646
{
4747
$extensions = [];
4848
$code = $this->violation->getCode();
49-
if ($code !== null) {
49+
if (! empty($code)) {
5050
$extensions['code'] = $code;
5151
}
5252

5353
$propertyPath = $this->violation->getPropertyPath();
54-
if ($propertyPath !== null) {
54+
if (! empty($propertyPath)) {
5555
$extensions['field'] = $propertyPath;
5656
}
5757

src/Mappers/Parameters/AssertParameterMiddleware.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
namespace TheCodingMachine\Graphqlite\Validator\Mappers\Parameters;
5+
namespace TheCodingMachine\GraphQLite\Validator\Mappers\Parameters;
66

77
use phpDocumentor\Reflection\DocBlock;
88
use phpDocumentor\Reflection\Type;
@@ -15,7 +15,8 @@
1515
use TheCodingMachine\GraphQLite\Mappers\Parameters\ParameterMiddlewareInterface;
1616
use TheCodingMachine\GraphQLite\Parameters\InputTypeParameterInterface;
1717
use TheCodingMachine\GraphQLite\Parameters\ParameterInterface;
18-
use TheCodingMachine\Graphqlite\Validator\Annotations\Assertion;
18+
use TheCodingMachine\GraphQLite\Validator\Annotations\Assertion;
19+
1920
use function array_map;
2021
use function array_merge;
2122

src/Mappers/Parameters/InvalidAssertionAnnotationException.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
namespace TheCodingMachine\Graphqlite\Validator\Mappers\Parameters;
5+
namespace TheCodingMachine\GraphQLite\Validator\Mappers\Parameters;
66

77
use Exception;
88
use ReflectionParameter;

src/Mappers/Parameters/ParameterValidator.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
namespace TheCodingMachine\Graphqlite\Validator\Mappers\Parameters;
5+
namespace TheCodingMachine\GraphQLite\Validator\Mappers\Parameters;
66

77
use GraphQL\Type\Definition\InputType;
88
use GraphQL\Type\Definition\ResolveInfo;
@@ -12,7 +12,7 @@
1212
use Symfony\Component\Validator\Validator\ValidatorInterface;
1313
use Symfony\Contracts\Translation\TranslatorInterface;
1414
use TheCodingMachine\GraphQLite\Parameters\InputTypeParameterInterface;
15-
use TheCodingMachine\Graphqlite\Validator\ValidationFailedException;
15+
use TheCodingMachine\GraphQLite\Validator\ValidationFailedException;
1616

1717
class ParameterValidator implements InputTypeParameterInterface
1818
{

src/ValidationFailedException.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
namespace TheCodingMachine\Graphqlite\Validator;
5+
namespace TheCodingMachine\GraphQLite\Validator;
66

77
use GraphQL\Error\ClientAware;
88
use InvalidArgumentException;

tests/Annotations/AssertionTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace TheCodingMachine\Graphqlite\Validator\Annotations;
3+
namespace TheCodingMachine\GraphQLite\Validator\Annotations;
44

55
use BadMethodCallException;
66
use PHPUnit\Framework\TestCase;

tests/ConstraintValidationExceptionTest.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
<?php
22

3-
namespace TheCodingMachine\Graphqlite\Validator;
3+
namespace TheCodingMachine\GraphQLite\Validator;
44

55
use PHPUnit\Framework\TestCase;
66
use Symfony\Component\Validator\ConstraintViolation;
7-
use Symfony\Component\Validator\ConstraintViolationList;
87

98
class ConstraintValidationExceptionTest extends TestCase
109
{

tests/Fixtures/Controllers/UserController.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
<?php
22

33

4-
namespace TheCodingMachine\Graphqlite\Validator\Fixtures\Controllers;
4+
namespace TheCodingMachine\GraphQLite\Validator\Fixtures\Controllers;
55

66

77
use Symfony\Component\Validator\Constraints as Assert;
88
use Symfony\Component\Validator\Validator\ValidatorInterface;
99
use TheCodingMachine\GraphQLite\Annotations\Mutation;
1010
use TheCodingMachine\GraphQLite\Annotations\Query;
11-
use TheCodingMachine\Graphqlite\Validator\Fixtures\Types\User;
12-
use TheCodingMachine\Graphqlite\Validator\Annotations\Assertion;
13-
use TheCodingMachine\Graphqlite\Validator\ValidationFailedException;
11+
use TheCodingMachine\GraphQLite\Validator\Fixtures\Types\User;
12+
use TheCodingMachine\GraphQLite\Validator\Annotations\Assertion;
13+
use TheCodingMachine\GraphQLite\Validator\ValidationFailedException;
1414

1515
class UserController
1616
{

tests/Fixtures/InvalidControllers/InvalidController.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?php
22

33

4-
namespace TheCodingMachine\Graphqlite\Validator\Fixtures\InvalidControllers;
4+
namespace TheCodingMachine\GraphQLite\Validator\Fixtures\InvalidControllers;
55

66

77
use GraphQL\Type\Definition\ResolveInfo;
88
use Symfony\Component\Validator\Constraints as Assert;
99
use TheCodingMachine\GraphQLite\Annotations\Query;
10-
use TheCodingMachine\Graphqlite\Validator\Annotations\Assertion;
10+
use TheCodingMachine\GraphQLite\Validator\Annotations\Assertion;
1111

1212
class InvalidController
1313
{

tests/Fixtures/Types/User.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22

33

4-
namespace TheCodingMachine\Graphqlite\Validator\Fixtures\Types;
4+
namespace TheCodingMachine\GraphQLite\Validator\Fixtures\Types;
55
use Symfony\Component\Validator\Constraints as Assert;
66
use TheCodingMachine\GraphQLite\Annotations\Field;
77
use TheCodingMachine\GraphQLite\Annotations\Type;

tests/IntegrationTest.php

+13-19
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,29 @@
11
<?php
22

33

4-
namespace TheCodingMachine\Graphqlite\Validator;
4+
namespace TheCodingMachine\GraphQLite\Validator;
55

66

77
use Doctrine\Common\Annotations\AnnotationReader;
8-
use GraphQL\Error\Debug;
8+
use GraphQL\Error\DebugFlag;
99
use GraphQL\GraphQL;
1010
use GraphQL\Type\Schema;
1111
use Mouf\Picotainer\Picotainer;
1212
use PHPUnit\Framework\TestCase;
1313
use Psr\Container\ContainerInterface;
1414
use Symfony\Component\Cache\Adapter\ArrayAdapter;
15-
use Symfony\Component\Cache\Adapter\Psr16Adapter;
1615
use Symfony\Component\Cache\Psr16Cache;
17-
use Symfony\Component\Cache\Simple\ArrayCache;
1816
use Symfony\Component\Translation\Translator;
1917
use Symfony\Component\Validator\ContainerConstraintValidatorFactory;
2018
use Symfony\Component\Validator\Validator\ValidatorInterface;
2119
use Symfony\Component\Validator\ValidatorBuilder;
2220
use Symfony\Contracts\Translation\TranslatorInterface;
2321
use TheCodingMachine\GraphQLite\Containers\BasicAutoWiringContainer;
24-
use TheCodingMachine\GraphQLite\Containers\EmptyContainer;
2522
use TheCodingMachine\GraphQLite\Exceptions\WebonyxErrorHandler;
2623
use TheCodingMachine\GraphQLite\SchemaFactory;
27-
use TheCodingMachine\Graphqlite\Validator\Fixtures\Controllers\UserController;
28-
use TheCodingMachine\Graphqlite\Validator\Mappers\Parameters\AssertParameterMiddleware;
29-
use TheCodingMachine\Graphqlite\Validator\Mappers\Parameters\InvalidAssertionAnnotationException;
30-
use function var_dump;
31-
use function var_export;
32-
use const JSON_PRETTY_PRINT;
24+
use TheCodingMachine\GraphQLite\Validator\Fixtures\Controllers\UserController;
25+
use TheCodingMachine\GraphQLite\Validator\Mappers\Parameters\AssertParameterMiddleware;
26+
use TheCodingMachine\GraphQLite\Validator\Mappers\Parameters\InvalidAssertionAnnotationException;
3327

3428
class IntegrationTest extends TestCase
3529
{
@@ -51,8 +45,8 @@ private function getSchemaFactory(): SchemaFactory
5145
]);
5246

5347
$schemaFactory = new SchemaFactory(new Psr16Cache(new ArrayAdapter()), new BasicAutoWiringContainer($container));
54-
$schemaFactory->addControllerNamespace('TheCodingMachine\Graphqlite\Validator\Fixtures\Controllers');
55-
$schemaFactory->addTypeNamespace('TheCodingMachine\Graphqlite\Validator\Fixtures\Types');
48+
$schemaFactory->addControllerNamespace('TheCodingMachine\GraphQLite\Validator\Fixtures\Controllers');
49+
$schemaFactory->addTypeNamespace('TheCodingMachine\GraphQLite\Validator\Fixtures\Types');
5650
$schemaFactory->addParameterMiddleware(new AssertParameterMiddleware(new ContainerConstraintValidatorFactory($container), $container->get(ValidatorInterface::class), $container->get(TranslatorInterface::class)));
5751

5852
return $schemaFactory;
@@ -83,7 +77,7 @@ public function testEndToEndThrowException(): void
8377
$result->setErrorsHandler([WebonyxErrorHandler::class, 'errorHandler']);
8478
$result->setErrorFormatter([WebonyxErrorHandler::class, 'errorFormatter']);
8579

86-
$errors = $result->toArray(Debug::RETHROW_UNSAFE_EXCEPTIONS)['errors'];
80+
$errors = $result->toArray(DebugFlag::RETHROW_UNSAFE_EXCEPTIONS)['errors'];
8781
$this->assertSame('The email \'"foofgdjkerbrtehrthjker.com"\' is not a valid email.', $errors[0]['message']);
8882
$this->assertSame('email', $errors[0]['extensions']['field']);
8983
$this->assertSame('Validate', $errors[0]['extensions']['category']);
@@ -112,7 +106,7 @@ public function testEndToEndAssert(): void
112106
$result->setErrorsHandler([WebonyxErrorHandler::class, 'errorHandler']);
113107
$result->setErrorFormatter([WebonyxErrorHandler::class, 'errorFormatter']);
114108

115-
$errors = $result->toArray(Debug::RETHROW_UNSAFE_EXCEPTIONS)['errors'];
109+
$errors = $result->toArray(DebugFlag::RETHROW_UNSAFE_EXCEPTIONS)['errors'];
116110

117111
// TODO: find why message is not in French...
118112
$this->assertSame('This value is not a valid email address.', $errors[0]['message']);
@@ -135,7 +129,7 @@ public function testEndToEndAssert(): void
135129
$result->setErrorsHandler([WebonyxErrorHandler::class, 'errorHandler']);
136130
$result->setErrorFormatter([WebonyxErrorHandler::class, 'errorFormatter']);
137131

138-
$data = $result->toArray(Debug::RETHROW_UNSAFE_EXCEPTIONS)['data'];
132+
$data = $result->toArray(DebugFlag::RETHROW_UNSAFE_EXCEPTIONS)['data'];
139133
$this->assertSame('[email protected]', $data['findByMail']['email']);
140134

141135
// Test default parameter
@@ -154,19 +148,19 @@ public function testEndToEndAssert(): void
154148
$result->setErrorsHandler([WebonyxErrorHandler::class, 'errorHandler']);
155149
$result->setErrorFormatter([WebonyxErrorHandler::class, 'errorFormatter']);
156150

157-
$data = $result->toArray(Debug::RETHROW_UNSAFE_EXCEPTIONS)['data'];
151+
$data = $result->toArray(DebugFlag::RETHROW_UNSAFE_EXCEPTIONS)['data'];
158152
$this->assertSame('[email protected]', $data['findByMail']['email']);
159153

160154
}
161155

162156
public function testException(): void
163157
{
164158
$schemaFactory = $this->getSchemaFactory();
165-
$schemaFactory->addControllerNamespace('TheCodingMachine\Graphqlite\Validator\Fixtures\InvalidControllers');
159+
$schemaFactory->addControllerNamespace('TheCodingMachine\GraphQLite\Validator\Fixtures\InvalidControllers');
166160
$schema = $schemaFactory->createSchema();
167161

168162
$this->expectException(InvalidAssertionAnnotationException::class);
169-
$this->expectExceptionMessage('In method TheCodingMachine\Graphqlite\Validator\Fixtures\InvalidControllers\InvalidController::invalid(), the @Assert annotation is targeting parameter "$resolveInfo". You cannot target this parameter because it is not part of the GraphQL Input type. You can only assert parameters coming from the end user.');
163+
$this->expectExceptionMessage('In method TheCodingMachine\GraphQLite\Validator\Fixtures\InvalidControllers\InvalidController::invalid(), the @Assert annotation is targeting parameter "$resolveInfo". You cannot target this parameter because it is not part of the GraphQL Input type. You can only assert parameters coming from the end user.');
170164
$schema->validate();
171165
}
172166
}

tests/ValidationFailedExceptionTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace TheCodingMachine\Graphqlite\Validator;
3+
namespace TheCodingMachine\GraphQLite\Validator;
44

55
use PHPUnit\Framework\TestCase;
66
use Symfony\Component\Validator\ConstraintViolation;

0 commit comments

Comments
 (0)