Skip to content

Commit 96342ae

Browse files
authored
Test on latest stable PHP 8.4 + Symfony 7.3 (#64)
* Configure symfony/phpunit-bridge to show deprecations * Fixed deprecated PHP 8.4 implicitly nullable parameters * Fixed symfony/validator 7.3 deprecated $options parameter * Test on latest stable PHP 8.4 + Symfony 7.3 * Fixed self deprecation of undefined form option * Fixed deprecated PHP 8.4 implicitly nullable parameters * Fixed deprecated PHP 8.4 implicitly nullable parameters
1 parent 17c8b5b commit 96342ae

File tree

15 files changed

+59
-58
lines changed

15 files changed

+59
-58
lines changed

.github/workflows/tests.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ jobs:
1616
include:
1717
- php-version: '8.2'
1818
symfony-version: '7.0.*'
19-
- php-version: '8.3'
20-
symfony-version: '7.1.*'
19+
- php-version: '8.4'
20+
symfony-version: '7.3.*'
2121

2222
steps:
2323
- name: "Checkout"
@@ -55,7 +55,7 @@ jobs:
5555
uses: shivammathur/setup-php@v2
5656
with:
5757
coverage: xdebug
58-
php-version: '8.3'
58+
php-version: '8.4'
5959

6060
- name: "Install dependencies with composer"
6161
run: composer update --no-interaction --no-progress
@@ -81,7 +81,7 @@ jobs:
8181
uses: shivammathur/setup-php@v2
8282
with:
8383
coverage: none
84-
php-version: '8.3'
84+
php-version: '8.4'
8585

8686
- name: "Install dependencies with composer"
8787
run: composer update --no-interaction --no-progress
@@ -101,7 +101,7 @@ jobs:
101101
uses: shivammathur/setup-php@v2
102102
with:
103103
coverage: none
104-
php-version: '8.3'
104+
php-version: '8.4'
105105

106106
- name: "Install dependencies with composer"
107107
run: composer update --no-interaction --no-progress

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"phpunit/phpunit": "^9.6",
2121
"symfony/form": "^7.0",
2222
"symfony/http-kernel": "^7.0",
23+
"symfony/phpunit-bridge": "^7.3",
2324
"symfony/translation": "^7.0",
2425
"symfony/twig-bundle": "^7.0",
2526
"symfony/validator": "^7.0",

phpunit.xml.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
bootstrap="vendor/autoload.php">
66
<php>
77
<server name="KERNEL_CLASS" value="Yokai\EnumBundle\Tests\Integration\App\Kernel"/>
8+
<server name="SYMFONY_DEPRECATIONS_HELPER" value="max[direct]=0"/>
89
</php>
910

1011
<testsuites>

src/Form/Type/EnumType.php

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -39,30 +39,16 @@ function (string $name): bool {
3939
function (Options $options): array {
4040
/** @var string $name */
4141
$name = $options['enum'];
42-
$choices = $this->enumRegistry->get($name)->getChoices();
4342

44-
if ($options['enum_choice_value'] === null) {
45-
foreach ($choices as $value) {
46-
if (!\is_scalar($value)) {
47-
@\trigger_error(
48-
'Not configuring the "enum_choice_value" option is deprecated.' .
49-
' It will default to "true" in 5.0.',
50-
\E_USER_DEPRECATED
51-
);
52-
break;
53-
}
54-
}
55-
}
56-
57-
return $choices;
43+
return $this->enumRegistry->get($name)->getChoices();
5844
}
5945
)
60-
->setAllowedTypes('enum_choice_value', ['bool', 'null'])
61-
->setDefault('enum_choice_value', null)
46+
->setAllowedTypes('enum_choice_value', ['bool'])
47+
->setDefault('enum_choice_value', true)
6248
->setDefault(
6349
'choice_value',
6450
static function (Options $options) {
65-
if ($options['enum_choice_value'] !== true) {
51+
if (!$options['enum_choice_value']) {
6652
return null;
6753
}
6854

src/MyCLabsEnum.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
*/
1313
class MyCLabsEnum extends Enum
1414
{
15-
public function __construct(string $enum, string $name = null)
15+
public function __construct(string $enum, string|null $name = null)
1616
{
1717
if (!\is_a($enum, ActualMyCLabsEnum::class, true)) {
1818
throw LogicException::invalidMyClabsEnumClass($enum);

src/MyCLabsTranslatedEnum.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public function __construct(
1818
TranslatorInterface $translator,
1919
string $transPattern,
2020
string $transDomain = 'messages',
21-
string $name = null
21+
string|null $name = null
2222
) {
2323
if (!\is_a($enum, ActualMyCLabsEnum::class, true)) {
2424
throw LogicException::invalidMyClabsEnumClass($enum);

src/NativeEnum.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
*/
1313
class NativeEnum extends Enum
1414
{
15-
public function __construct(string $enum, string $name = null)
15+
public function __construct(string $enum, string|null $name = null)
1616
{
1717
if (!\is_a($enum, UnitEnum::class, true)) {
1818
throw LogicException::invalidUnitEnum($enum);

src/NativeTranslatedEnum.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public function __construct(
1818
TranslatorInterface $translator,
1919
string $transPattern,
2020
string $transDomain = 'messages',
21-
string $name = null
21+
string|null $name = null
2222
) {
2323
if (!\is_a($enum, UnitEnum::class, true)) {
2424
throw LogicException::invalidUnitEnum($enum);

src/Validator/Constraints/Enum.php

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,33 @@ public function __construct(
2121
array $options = [],
2222
string|null $enum = null,
2323
callable|null|string $callback = null,
24-
bool $multiple = null,
25-
bool $strict = null,
26-
int $min = null,
27-
int $max = null,
28-
string $message = null,
29-
string $multipleMessage = null,
30-
string $minMessage = null,
31-
string $maxMessage = null,
24+
bool|null $multiple = null,
25+
bool|null $strict = null,
26+
int|null $min = null,
27+
int|null $max = null,
28+
string|null $message = null,
29+
string|null $multipleMessage = null,
30+
string|null $minMessage = null,
31+
string|null $maxMessage = null,
3232
array|null $groups = null,
3333
mixed $payload = null,
3434
) {
35+
if (\is_array($options) && $options !== []) {
36+
\trigger_deprecation(
37+
'symfony/validator',
38+
'7.3',
39+
'Passing an array of options to configure the "%s" constraint is deprecated, use named arguments instead.',
40+
static::class,
41+
);
42+
}
43+
3544
if (\is_string($enum)) {
3645
$this->enum = $enum;
3746
}
3847

3948
// Since Symfony 5.3, first argument of Choice is $options
4049
parent::__construct(
41-
$options,
50+
[],
4251
null,
4352
$callback,
4453
$multiple,

tests/Integration/tests/PullRequestFormTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,13 @@ public function valid(): Generator
108108
{
109109
foreach ($this->classes() as [$class]) {
110110
yield [
111-
['status' => 0, 'labels' => ['bugfix', '1.x']],
111+
['status' => 'opened', 'labels' => ['bugfix', '1.x']],
112112
self::pullRequest($class),
113113
self::pullRequest($class, 'opened', ['bugfix', '1.x']),
114114
];
115115

116116
yield [
117-
['status' => 2, 'labels' => ['bugfix', '2.x']],
117+
['status' => 'closed', 'labels' => ['bugfix', '2.x']],
118118
self::pullRequest($class, 'opened', ['bugfix', '1.x']),
119119
self::pullRequest($class, 'closed', ['bugfix', '2.x']),
120120
];
@@ -171,7 +171,7 @@ public function invalid(): Generator
171171

172172
private static function pullRequest(
173173
string $class,
174-
string $status = null,
174+
string|null $status = null,
175175
array $labels = [],
176176
): MyCLabsPullRequest|NativeEnumPullRequest {
177177
return (match ($class) {

0 commit comments

Comments
 (0)