Skip to content

Commit 91d1bb9

Browse files
authored
dropped annotation support (#13)
1 parent 74ae886 commit 91d1bb9

File tree

6 files changed

+5
-91
lines changed

6 files changed

+5
-91
lines changed

.scrutinizer.yml

Lines changed: 0 additions & 30 deletions
This file was deleted.

README.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# Command-Bus-Validator
22

33
[![Build Status](https://travis-ci.org/dmt-software/command-bus-validator.svg?branch=master)](https://travis-ci.org/dmt-software/command-bus-validator)
4-
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/dmt-software/command-bus-validator/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/dmt-software/command-bus-validator/?branch=master)
5-
[![Code Coverage](https://scrutinizer-ci.com/g/dmt-software/command-bus-validator/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/dmt-software/command-bus-validator/?branch=master)
64

75
## Install
86
`composer require dmt-software/command-bus-validator`
@@ -11,9 +9,6 @@
119

1210
### Default usage
1311

14-
By default this middleware uses the StaticMethodLoader of the [Symfony Validator](https://symfony.com/doc/current/components/validator.html) component.
15-
If you have installed both `doctrine/annotations` and `doctrine/cache`, this default behaviour is extended with the AnnotationLoader.
16-
1712
Configure and adding this middleware to the commandBus:
1813
```php
1914
<?php // src/CommandBus/builder.php

composer.json

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,17 @@
1111
}
1212
],
1313
"require": {
14-
"php": ">=8.0",
14+
"php": ">=8.3",
1515
"league/tactician": "^1.0",
16-
"symfony/validator": "^5.1|^6.0"
16+
"symfony/validator": "^7.0"
1717
},
1818
"autoload": {
1919
"psr-4": {
2020
"DMT\\CommandBus\\": "src/"
2121
}
2222
},
23-
"suggest": {
24-
"doctrine/annotations": "Enables adding constraints using annotations",
25-
"doctrine/cache": "Enables adding constraints using annotations"
26-
},
2723
"require-dev": {
28-
"phpunit/phpunit": "^12.0",
29-
"doctrine/annotations": "^1.6"
24+
"phpunit/phpunit": "^12.0"
3025
},
3126
"autoload-dev": {
3227
"psr-4": {

src/Validator/ValidationMiddleware.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22

33
namespace DMT\CommandBus\Validator;
44

5-
use Doctrine\Common\Annotations\AnnotationReader;
65
use League\Tactician\Middleware;
76
use Symfony\Component\Validator\Mapping\Factory\LazyLoadingMetadataFactory;
8-
use Symfony\Component\Validator\Mapping\Loader\AnnotationLoader;
7+
use Symfony\Component\Validator\Mapping\Loader\AttributeLoader;
98
use Symfony\Component\Validator\Mapping\Loader\LoaderChain;
109
use Symfony\Component\Validator\Mapping\Loader\StaticMethodLoader;
1110
use Symfony\Component\Validator\Validator\RecursiveValidator;
@@ -55,11 +54,7 @@ public function execute($command, callable $next): mixed
5554

5655
protected function getDefaultValidator(): ValidatorInterface
5756
{
58-
$loaders = [new StaticMethodLoader()];
59-
60-
if (class_exists(AnnotationReader::class)) {
61-
$loaders[] = new AnnotationLoader(new AnnotationReader());
62-
}
57+
$loaders = [new StaticMethodLoader(), new AttributeLoader()];
6358

6459
return (new ValidatorBuilder())
6560
->setMetadataFactory(

tests/Fixtures/AnnotationReaderCommand.php

Lines changed: 0 additions & 31 deletions
This file was deleted.

tests/Validator/ValidationMiddlewareTest.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use DMT\CommandBus\Validator\ValidationException;
66
use DMT\CommandBus\Validator\ValidationMiddleware;
7-
use DMT\Test\CommandBus\Fixtures\AnnotationReaderCommand;
87
use DMT\Test\CommandBus\Fixtures\AttributeReaderCommand;
98
use DMT\Test\CommandBus\Fixtures\ClassMetadataCommand;
109
use PHPUnit\Framework\Attributes\DataProvider;
@@ -51,15 +50,6 @@ public function testLoadClassMetadataValidator(): void
5150
$middleware->execute(new ClassMetadataCommand(), 'gettype');
5251
}
5352

54-
public function testAnnotationReaderValidator(): void
55-
{
56-
$this->expectException(ValidationException::class);
57-
$this->expectExceptionMessageMatches("~Invalid command .* given~");
58-
59-
$middleware = new ValidationMiddleware();
60-
$middleware->execute(new AnnotationReaderCommand(), 'gettype');
61-
}
62-
6353
public function testAttributeReaderValidator(): void
6454
{
6555
$this->expectException(ValidationException::class);

0 commit comments

Comments
 (0)