Skip to content

Commit

Permalink
chore: set Symfony compatibility to 5.4, 6.4 and 7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
PedroTroller committed Feb 22, 2024
1 parent 0d60ea3 commit 5d77b53
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 107 deletions.
22 changes: 18 additions & 4 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,29 @@ jobs:
- '8.3'
symfony:
- '5.4'
- '6.2'
- '6.3'
# - '6.4'
# - '7.0'
- '6.4'
minimumStability:
- 'stable'
composerOptions:
- '--prefer-stable --prefer-lowest'
- '--prefer-stable'
include:
- symfony: '7.0'
php: '8.2'
minimumStability: 'stable'
composerOptions: '--prefer-stable --prefer-lowest'
- symfony: '7.0'
php: '8.2'
minimumStability: 'stable'
composerOptions: '--prefer-stable'
- symfony: '7.0'
php: '8.3'
minimumStability: 'stable'
composerOptions: '--prefer-stable --prefer-lowest'
- symfony: '7.0'
php: '8.3'
minimumStability: 'stable'
composerOptions: '--prefer-stable'
steps:
- uses: shivammathur/setup-php@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Are you often tired to repeat static choices like gender or civility in your app
## Requirements

- PHP >= 8.0
- Symfony 5.4 or 6.*
- Symfony 5.4, 6.4 or 7.*

## Installation

Expand Down
16 changes: 8 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
],
"require": {
"php": ">=8.0",
"symfony/config": "^5.4 || ^6.2@dev",
"symfony/dependency-injection": "^5.4 || ^6.2@dev",
"symfony/form": "^5.4 || ^6.2@dev",
"symfony/http-foundation": "^5.4 || ^6.2@dev",
"symfony/http-kernel": "^5.4 || ^6.2@dev",
"symfony/validator": "^5.4 || ^6.2@dev",
"symfony/config": "^5.4 || ^6.4 || ^7.0@dev",
"symfony/dependency-injection": "^5.4 || ^6.4 || ^7.0@dev",
"symfony/form": "^5.4 || ^6.4 || ^7.0@dev",
"symfony/http-foundation": "^5.4 || ^6.4 || ^7.0@dev",
"symfony/http-kernel": "^5.4 || ^6.4 || ^7.0@dev",
"symfony/validator": "^5.4 || ^6.4 || ^7.0@dev",
"twig/twig": "^2.15.3 || ^3.4.3"
},
"require-dev": {
Expand All @@ -35,8 +35,8 @@
"phpspec/prophecy": "1.18.0",
"phpstan/phpstan": "1.10.59",
"rector/rector": "1.0.1",
"symfony/twig-bridge": "^5.4 || ^6.2@dev",
"symfony/var-dumper": "^5.4 || ^6.2@dev",
"symfony/twig-bridge": "^5.4 || ^6.4 || ^7.0@dev",
"symfony/var-dumper": "^5.4 || ^6.4 || ^7.0@dev",
"webmozart/assert": "1.11.0"
},
"minimum-stability": "stable",
Expand Down
14 changes: 0 additions & 14 deletions src/Knp/DictionaryBundle/Symfony/SupportedVersion.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,38 @@

use Exception;
use Knp\DictionaryBundle\Dictionary\Collection;
use Symfony\Component\Form\Exception\UnexpectedTypeException;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintValidator;

final class DictionaryValidator extends ConstraintValidator
{
use DictionaryValidator\SymfonyCompatibilityTrait;

public function __construct(private Collection $dictionaries) {}

public function validate(mixed $value, Constraint $constraint): void
{
if (!$constraint instanceof Dictionary) {
throw new UnexpectedTypeException($constraint, Dictionary::class);
}

if (null === $value || '' === $value) {
return;
}

$dictionary = $this->dictionaries[$constraint->name];
$values = $dictionary->getKeys();

if (!\in_array($value, $values, true)) {
$this->context->addViolation(
$constraint->message,
[
'{{ key }}' => $this->varToString($value),
'{{ keys }}' => implode(', ', array_map([$this, 'varToString'], $values)),
]
);
}
}

private function varToString(mixed $var): string
{
if (null === $var) {
Expand Down

This file was deleted.

0 comments on commit 5d77b53

Please sign in to comment.