Skip to content

Commit 3e4e55d

Browse files
authored
chore: set Symfony compatibility to 5.4, 6.4 and 7.0 (#260)
1 parent f7b609b commit 3e4e55d

File tree

6 files changed

+53
-107
lines changed

6 files changed

+53
-107
lines changed

Diff for: .github/workflows/test.yaml

+18-4
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,29 @@ jobs:
1313
- '8.3'
1414
symfony:
1515
- '5.4'
16-
- '6.2'
17-
- '6.3'
18-
# - '6.4'
19-
# - '7.0'
16+
- '6.4'
2017
minimumStability:
2118
- 'stable'
2219
composerOptions:
2320
- '--prefer-stable --prefer-lowest'
2421
- '--prefer-stable'
22+
include:
23+
- symfony: '7.0'
24+
php: '8.2'
25+
minimumStability: 'stable'
26+
composerOptions: '--prefer-stable --prefer-lowest'
27+
- symfony: '7.0'
28+
php: '8.2'
29+
minimumStability: 'stable'
30+
composerOptions: '--prefer-stable'
31+
- symfony: '7.0'
32+
php: '8.3'
33+
minimumStability: 'stable'
34+
composerOptions: '--prefer-stable --prefer-lowest'
35+
- symfony: '7.0'
36+
php: '8.3'
37+
minimumStability: 'stable'
38+
composerOptions: '--prefer-stable'
2539
steps:
2640
- uses: shivammathur/setup-php@v2
2741
with:

Diff for: README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Are you often tired to repeat static choices like gender or civility in your app
88
## Requirements
99

1010
- PHP >= 8.0
11-
- Symfony 5.4 or 6.*
11+
- Symfony 5.4, 6.4 or 7.*
1212

1313
## Installation
1414

Diff for: composer.json

+8-8
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818
],
1919
"require": {
2020
"php": ">=8.0",
21-
"symfony/config": "^5.4 || ^6.2@dev",
22-
"symfony/dependency-injection": "^5.4 || ^6.2@dev",
23-
"symfony/form": "^5.4 || ^6.2@dev",
24-
"symfony/http-foundation": "^5.4 || ^6.2@dev",
25-
"symfony/http-kernel": "^5.4 || ^6.2@dev",
26-
"symfony/validator": "^5.4 || ^6.2@dev",
21+
"symfony/config": "^5.4 || ^6.4 || ^7.0@dev",
22+
"symfony/dependency-injection": "^5.4 || ^6.4 || ^7.0@dev",
23+
"symfony/form": "^5.4 || ^6.4 || ^7.0@dev",
24+
"symfony/http-foundation": "^5.4 || ^6.4 || ^7.0@dev",
25+
"symfony/http-kernel": "^5.4 || ^6.4 || ^7.0@dev",
26+
"symfony/validator": "^5.4 || ^6.4 || ^7.0@dev",
2727
"twig/twig": "^2.15.3 || ^3.4.3"
2828
},
2929
"require-dev": {
@@ -35,8 +35,8 @@
3535
"phpspec/prophecy": "1.18.0",
3636
"phpstan/phpstan": "1.10.59",
3737
"rector/rector": "1.0.1",
38-
"symfony/twig-bridge": "^5.4 || ^6.2@dev",
39-
"symfony/var-dumper": "^5.4 || ^6.2@dev",
38+
"symfony/twig-bridge": "^5.4 || ^6.4 || ^7.0@dev",
39+
"symfony/var-dumper": "^5.4 || ^6.4 || ^7.0@dev",
4040
"webmozart/assert": "1.11.0"
4141
},
4242
"minimum-stability": "stable",

Diff for: src/Knp/DictionaryBundle/Symfony/SupportedVersion.php

-14
This file was deleted.

Diff for: src/Knp/DictionaryBundle/Validator/Constraints/DictionaryValidator.php

+26-2
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,38 @@
66

77
use Exception;
88
use Knp\DictionaryBundle\Dictionary\Collection;
9+
use Symfony\Component\Form\Exception\UnexpectedTypeException;
10+
use Symfony\Component\Validator\Constraint;
911
use Symfony\Component\Validator\ConstraintValidator;
1012

1113
final class DictionaryValidator extends ConstraintValidator
1214
{
13-
use DictionaryValidator\SymfonyCompatibilityTrait;
14-
1515
public function __construct(private Collection $dictionaries) {}
1616

17+
public function validate(mixed $value, Constraint $constraint): void
18+
{
19+
if (!$constraint instanceof Dictionary) {
20+
throw new UnexpectedTypeException($constraint, Dictionary::class);
21+
}
22+
23+
if (null === $value || '' === $value) {
24+
return;
25+
}
26+
27+
$dictionary = $this->dictionaries[$constraint->name];
28+
$values = $dictionary->getKeys();
29+
30+
if (!\in_array($value, $values, true)) {
31+
$this->context->addViolation(
32+
$constraint->message,
33+
[
34+
'{{ key }}' => $this->varToString($value),
35+
'{{ keys }}' => implode(', ', array_map([$this, 'varToString'], $values)),
36+
]
37+
);
38+
}
39+
}
40+
1741
private function varToString(mixed $var): string
1842
{
1943
if (null === $var) {

Diff for: src/Knp/DictionaryBundle/Validator/Constraints/DictionaryValidator/SymfonyCompatibilityTrait.php

-78
This file was deleted.

0 commit comments

Comments
 (0)