From 7b1ee6e6743c35502135315d2d4d7a54014cf71d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Nguyen?= Date: Mon, 20 Mar 2023 12:17:20 +0100 Subject: [PATCH] fix CI --- .travis.yml | 17 +++-------------- composer.json | 4 ++-- phpstan.neon | 5 +++++ src/Annotations/Assertion.php | 8 ++------ src/ConstraintViolationException.php | 1 + .../Parameters/AssertParameterMiddleware.php | 2 +- src/Mappers/Parameters/ParameterValidator.php | 10 +++------- src/ValidationFailedException.php | 9 +++------ 8 files changed, 20 insertions(+), 36 deletions(-) diff --git a/.travis.yml b/.travis.yml index 182f716..b565bac 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,24 +13,13 @@ env: matrix: fast_finish: true include: - # Test the latest stable release - - php: 7.2 - - php: 8.0 - env: COVERAGE=true PHPUNIT_FLAGS="-v --coverage-text" - # Test LTS versions. - - php: 8.0 - env: DEPENDENCIES="symfony/lts:^4" - - # Latest commit to master - - php: 8.0 - env: STABILITY="dev" + - php: 8.1 + env: DEPENDENCIES="symfony/^6" allow_failures: # Minimum supported dependencies with the latest and oldest PHP version - - php: 8.0 - env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" SYMFONY_DEPRECATIONS_HELPER="weak_vendors" - - php: 7.2 + - php: 8.1 env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" SYMFONY_DEPRECATIONS_HELPER="weak_vendors" # Dev-master is allowed to fail. - env: STABILITY="dev" diff --git a/composer.json b/composer.json index 83c5fc3..d38a045 100644 --- a/composer.json +++ b/composer.json @@ -23,9 +23,9 @@ "doctrine/annotations": "^1.13" }, "require-dev": { - "phpunit/phpunit": "^8.4.1", + "phpunit/phpunit": "^9.6.5", "mouf/picotainer": "^1.1", - "phpstan/phpstan": "^0.12.14", + "phpstan/phpstan": "^1.8", "php-coveralls/php-coveralls": "^2.1.0", "symfony/translation": "^6", "doctrine/coding-standard": "^11.1" diff --git a/phpstan.neon b/phpstan.neon index 0c6832a..cb5b24e 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,5 +1,10 @@ parameters: ignoreErrors: + excludePaths: + - vendor + - cache + - .phpstan-cache + #includes: # - vendor/thecodingmachine/phpstan-strict-rules/phpstan-strict-rules.neon \ No newline at end of file diff --git a/src/Annotations/Assertion.php b/src/Annotations/Assertion.php index 6d1f87d..c0810da 100644 --- a/src/Annotations/Assertion.php +++ b/src/Annotations/Assertion.php @@ -28,9 +28,7 @@ class Assertion implements ParameterAnnotationInterface /** @var Constraint[] */ private $constraint; - /** - * @param array $values - */ + /** @param array $values */ public function __construct(array $values) { if (! isset($values['for'])) { @@ -50,9 +48,7 @@ public function getTarget(): string return $this->for; } - /** - * @return Constraint[] - */ + /** @return Constraint[] */ public function getConstraint(): array { return $this->constraint; diff --git a/src/ConstraintViolationException.php b/src/ConstraintViolationException.php index e2e1b84..b5a0c5d 100644 --- a/src/ConstraintViolationException.php +++ b/src/ConstraintViolationException.php @@ -16,6 +16,7 @@ class ConstraintViolationException extends Exception implements GraphQLException public function __construct(ConstraintViolationInterface $violation) { parent::__construct((string) $violation->getMessage(), 400); + $this->violation = $violation; } diff --git a/src/Mappers/Parameters/AssertParameterMiddleware.php b/src/Mappers/Parameters/AssertParameterMiddleware.php index 75150b0..d22397d 100644 --- a/src/Mappers/Parameters/AssertParameterMiddleware.php +++ b/src/Mappers/Parameters/AssertParameterMiddleware.php @@ -39,7 +39,7 @@ public function __construct(ConstraintValidatorFactoryInterface $constraintValid $this->translator = $translator; } - public function mapParameter(ReflectionParameter $refParameter, DocBlock $docBlock, ?Type $paramTagType, ParameterAnnotations $parameterAnnotations, ParameterHandlerInterface $next): ParameterInterface + public function mapParameter(ReflectionParameter $refParameter, DocBlock $docBlock, Type|null $paramTagType, ParameterAnnotations $parameterAnnotations, ParameterHandlerInterface $next): ParameterInterface { /** @var Assertion[] $assertionAnnotations */ $assertionAnnotations = $parameterAnnotations->getAnnotationsByType(Assertion::class); diff --git a/src/Mappers/Parameters/ParameterValidator.php b/src/Mappers/Parameters/ParameterValidator.php index b893a6f..39d8a2f 100644 --- a/src/Mappers/Parameters/ParameterValidator.php +++ b/src/Mappers/Parameters/ParameterValidator.php @@ -29,9 +29,7 @@ class ParameterValidator implements InputTypeParameterInterface /** @var TranslatorInterface */ private $translator; - /** - * @param Constraint[] $constraints - */ + /** @param Constraint[] $constraints */ public function __construct(InputTypeParameterInterface $parameter, string $parameterName, array $constraints, ConstraintValidatorFactoryInterface $constraintValidatorFactory, ValidatorInterface $validator, TranslatorInterface $translator) { $this->parameter = $parameter; @@ -48,7 +46,7 @@ public function __construct(InputTypeParameterInterface $parameter, string $para * * @return mixed */ - public function resolve(?object $source, array $args, $context, ResolveInfo $info) + public function resolve(object|null $source, array $args, $context, ResolveInfo $info) { $value = $this->parameter->resolve($source, $args, $context, $info); @@ -79,9 +77,7 @@ public function hasDefaultValue(): bool return $this->parameter->hasDefaultValue(); } - /** - * @return mixed - */ + /** @return mixed */ public function getDefaultValue() { return $this->parameter->getDefaultValue(); diff --git a/src/ValidationFailedException.php b/src/ValidationFailedException.php index 4c123af..39e39f7 100644 --- a/src/ValidationFailedException.php +++ b/src/ValidationFailedException.php @@ -16,12 +16,11 @@ class ValidationFailedException extends InvalidArgumentException implements Grap /** @var ConstraintViolationException[] */ private $exceptions = []; - /** - * @param ConstraintViolationListInterface $constraintViolationList - */ + /** @param ConstraintViolationListInterface $constraintViolationList */ public function __construct(ConstraintViolationListInterface $constraintViolationList) { parent::__construct('Validation failed:', 400); + foreach ($constraintViolationList as $constraintViolation) { $this->add($constraintViolation); } @@ -33,9 +32,7 @@ private function add(ConstraintViolationInterface $violation): void $this->message .= "\n" . $violation->getMessage(); } - /** - * @return (ClientAware&Throwable)[] - */ + /** @return (ClientAware&Throwable)[] */ public function getExceptions(): array { return $this->exceptions;