diff --git a/composer.json b/composer.json index 80659a4..55d8c96 100644 --- a/composer.json +++ b/composer.json @@ -22,8 +22,8 @@ "roave/security-advisories": "dev-latest", "phpunit/phpunit": "^8.5 || ^9.0", "doctrine/annotations": "^1.2", - "symfony/framework-bundle": "^5.0 || ^6.0", - "symfony/yaml": "^5.0 || ^6.0" + "symfony/framework-bundle": "^5.0 || ^6.0 || ^7.0", + "symfony/yaml": "^5.0 || ^6.0 || ^7.0" }, "autoload": { "psr-4": { diff --git a/src/DependencyInjection/DdeboerVatinExtension.php b/src/DependencyInjection/DdeboerVatinExtension.php index 033478f..cb2de8d 100644 --- a/src/DependencyInjection/DdeboerVatinExtension.php +++ b/src/DependencyInjection/DdeboerVatinExtension.php @@ -17,7 +17,7 @@ class DdeboerVatinExtension extends Extension /** * {@inheritDoc} */ - public function load(array $configs, ContainerBuilder $container) + public function load(array $configs, ContainerBuilder $container): void { $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); $loader->load('services.xml'); diff --git a/src/Validator/Constraints/VatinValidator.php b/src/Validator/Constraints/VatinValidator.php index 45516ae..1e7df4a 100644 --- a/src/Validator/Constraints/VatinValidator.php +++ b/src/Validator/Constraints/VatinValidator.php @@ -34,7 +34,7 @@ public function __construct(Validator $validator) /** * {@inheritdoc} */ - public function validate($value, Constraint $constraint) + public function validate($value, Constraint $constraint): void { if (null === $value || '' === $value) { return; @@ -56,7 +56,7 @@ public function validate($value, Constraint $constraint) * * @return bool */ - private function isValidVatin($value, $checkExistence) + private function isValidVatin($value, $checkExistence): bool { try { return $this->validator->isValid($value, $checkExistence); diff --git a/tests/Functional/Model.php b/tests/Functional/Model.php index b82cc1f..b22b64c 100644 --- a/tests/Functional/Model.php +++ b/tests/Functional/Model.php @@ -9,10 +9,12 @@ class Model /** * @Vatin */ + #[Vatin] public $vat; /** * @Vatin(checkExistence=true) */ + #[Vatin(checkExistence: true)] public $vatCheckExistence; } diff --git a/tests/Functional/app/AppKernel.php b/tests/Functional/app/AppKernel.php index dfb3328..f246373 100644 --- a/tests/Functional/app/AppKernel.php +++ b/tests/Functional/app/AppKernel.php @@ -15,6 +15,10 @@ public function registerBundles(): iterable public function registerContainerConfiguration(LoaderInterface $loader) { - $loader->load(__DIR__.'/config/config.yml'); + if (self::MAJOR_VERSION >= 7) { + $loader->load(__DIR__ . '/config/config_7.yml'); + } else { + $loader->load(__DIR__ . '/config/config.yml'); + } } } diff --git a/tests/Functional/app/config/config_7.yml b/tests/Functional/app/config/config_7.yml new file mode 100644 index 0000000..d033f8f --- /dev/null +++ b/tests/Functional/app/config/config_7.yml @@ -0,0 +1,10 @@ +framework: + secret: ddeboer + test: ~ + validation: + enable_attributes: true + +services: + test.validator: + alias: validator + public: true diff --git a/tests/Validator/Constraints/ValidatorTest.php b/tests/Validator/Constraints/ValidatorTest.php index f6761ca..9231e81 100644 --- a/tests/Validator/Constraints/ValidatorTest.php +++ b/tests/Validator/Constraints/ValidatorTest.php @@ -5,11 +5,12 @@ use Ddeboer\Vatin\Validator; use Ddeboer\VatinBundle\Validator\Constraints\Vatin; use Ddeboer\VatinBundle\Validator\Constraints\VatinValidator; +use Symfony\Component\Validator\ConstraintValidatorInterface; use Symfony\Component\Validator\Test\ConstraintValidatorTestCase; class ValidatorTest extends ConstraintValidatorTestCase { - protected function createValidator() + protected function createValidator(): ConstraintValidatorInterface { return new VatinValidator(new Validator()); }