Skip to content

Commit ab45e12

Browse files
committed
Add Symfony 8.0 support, remove Symfony 7.3 support
1 parent f030a8e commit ab45e12

File tree

9 files changed

+130
-124
lines changed

9 files changed

+130
-124
lines changed

.github/workflows/tests.yml

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ jobs:
1818
symfony-version: '6.4.*'
1919
composer-flags: '--prefer-stable --prefer-lowest'
2020
description: 'with SF 6.4.* lowest'
21-
- php-version: '8.2'
22-
symfony-version: '7.3.*'
23-
composer-flags: '--prefer-stable --prefer-lowest'
24-
description: 'with SF 7.3.* lowest'
2521
- php-version: '8.2'
2622
symfony-version: '7.4.*'
2723
composer-flags: '--prefer-stable --prefer-lowest'
2824
description: 'with SF 7.4.* lowest'
25+
- php-version: '8.4'
26+
symfony-version: '8.0.*'
27+
composer-flags: '--prefer-stable --prefer-lowest'
28+
description: 'with SF 8.0.* lowest'
2929

3030
#Symfony versions
3131
- php-version: '8.5'
@@ -34,18 +34,21 @@ jobs:
3434
- php-version: '8.5'
3535
symfony-version: '6.4.*@dev'
3636
description: 'with SF 6.4.* dev'
37-
- php-version: '8.5'
38-
symfony-version: '7.3.*'
39-
description: 'with SF 7.3.*'
40-
- php-version: '8.5'
41-
symfony-version: '7.3.*@dev'
42-
description: 'with SF 7.3.* dev'
4337
- php-version: '8.5'
4438
symfony-version: '7.4.*'
4539
description: 'with SF 7.4.*'
4640
- php-version: '8.5'
4741
symfony-version: '7.4.*@dev'
4842
description: 'with SF 7.4.* dev'
43+
- php-version: '8.5'
44+
symfony-version: '8.0.*'
45+
description: 'with SF 8.0.*'
46+
- php-version: '8.5'
47+
symfony-version: '8.0.*@dev'
48+
description: 'with SF 8.0.* dev'
49+
- php-version: '8.5'
50+
symfony-version: '8.1.*@dev'
51+
description: 'with SF 8.1.* dev'
4952

5053
#PHP versions
5154
- php-version: '8.1'
@@ -138,11 +141,6 @@ jobs:
138141
npm install
139142
npm run dev
140143
141-
- name: Fix Panther code
142-
if: matrix.coding-standards != true && matrix.analyze-dependencies != true && matrix.static-analysis != true
143-
run: |
144-
sed -i 's/protected function doRequest(\$request)/protected function doRequest(object $request): object/' vendor/symfony/panther/src/Client.php
145-
146144
- name: Run PHPUnit
147145
if: matrix.coding-standards != true && matrix.analyze-dependencies != true && matrix.static-analysis != true
148146
run: php vendor/bin/phpunit

composer.json

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -15,49 +15,49 @@
1515
"ext-mbstring": "*",
1616
"doctrine/collections": "^1.5|^2.0",
1717
"doctrine/dbal": "^3.2|^4.0",
18-
"doctrine/doctrine-bundle": "^2.4.5",
18+
"doctrine/doctrine-bundle": "^2.4.5|^3.0",
1919
"doctrine/orm": "^2.9|^3.0",
20-
"doctrine/persistence": "^1.3|^2.0|^3.0",
20+
"doctrine/persistence": "^2.0|^3.0|^4.0",
2121
"ecommit/doctrine-utils": "^1.0|^2.0",
2222
"ecommit/paginator": "^1.0",
2323
"ecommit/scalar-values": "^1.0",
2424
"psr/container": "^1.1|^2.0",
25-
"symfony/asset": "^6.4|^7.3",
26-
"symfony/config": "^6.4|^7.3",
27-
"symfony/dependency-injection": "^6.4|^7.3",
28-
"symfony/doctrine-bridge": "^6.4|^7.3",
29-
"symfony/form": "^6.4|^7.3",
30-
"symfony/framework-bundle": "^6.4|^7.3",
31-
"symfony/http-client": "^6.4|^7.3",
25+
"symfony/asset": "^6.4|^7.4|^8.0",
26+
"symfony/config": "^6.4|^7.4|^8.0",
27+
"symfony/dependency-injection": "^6.4|^7.4|^8.0",
28+
"symfony/doctrine-bridge": "^6.4|^7.4|^8.0",
29+
"symfony/form": "^6.4|^7.4|^8.0",
30+
"symfony/framework-bundle": "^6.4|^7.4|^8.0",
31+
"symfony/http-client": "^6.4|^7.4|^8.0",
3232
"symfony/http-client-contracts": "^2.4|^3.0",
33-
"symfony/http-foundation": "^6.4|^7.3",
34-
"symfony/http-kernel": "^6.4|^7.3",
35-
"symfony/intl": "^6.4|^7.3",
36-
"symfony/options-resolver": "^6.4|^7.3",
37-
"symfony/property-access": "^6.4|^7.3",
38-
"symfony/routing": "^6.4|^7.3",
39-
"symfony/security-bundle": "^6.4|^7.3",
40-
"symfony/security-core": "^6.4|^7.3",
41-
"symfony/security-csrf": "^6.4|^7.3",
33+
"symfony/http-foundation": "^6.4|^7.4|^8.0",
34+
"symfony/http-kernel": "^6.4|^7.4|^8.0",
35+
"symfony/intl": "^6.4|^7.4|^8.0",
36+
"symfony/options-resolver": "^6.4|^7.4|^8.0",
37+
"symfony/property-access": "^6.4|^7.4|^8.0",
38+
"symfony/routing": "^6.4|^7.4|^8.0",
39+
"symfony/security-bundle": "^6.4|^7.4|^8.0",
40+
"symfony/security-core": "^6.4|^7.4|^8.0",
41+
"symfony/security-csrf": "^6.4|^7.4|^8.0",
4242
"symfony/service-contracts": "^1.1.6|^2|^3",
43-
"symfony/translation": "^6.4|^7.3",
43+
"symfony/translation": "^6.4|^7.4|^8.0",
4444
"symfony/translation-contracts": "^2.3|^3.0",
45-
"symfony/twig-bridge": "^6.4|^7.3",
46-
"symfony/twig-bundle": "^6.4|^7.3",
47-
"symfony/validator": "^6.4|^7.3",
45+
"symfony/twig-bridge": "^6.4|^7.4|^8.0",
46+
"symfony/twig-bundle": "^6.4|^7.4|^8.0",
47+
"symfony/validator": "^6.4|^7.4|^8.0",
4848
"twig/twig": "^2.12.0|^3.0"
4949
},
5050
"require-dev": {
5151
"dbrekelmans/bdi": "^1.0",
5252
"dg/bypass-finals": "^1.3",
53-
"doctrine/data-fixtures": "^1.5.3",
54-
"doctrine/doctrine-fixtures-bundle": "^3.4.2",
53+
"doctrine/data-fixtures": "^1.5.3|^2.0",
54+
"doctrine/doctrine-fixtures-bundle": "^3.4.2|^4.0",
5555
"friendsofphp/php-cs-fixer": "^3.0",
5656
"phpunit/phpunit": "^9.0",
57-
"symfony/dom-crawler": "^6.4|^7.3",
57+
"symfony/dom-crawler": "^6.4|^7.4|^8.0",
5858
"symfony/panther": "^2.0.1",
59-
"symfony/webpack-encore-bundle": "^1.7.3|^2.1.1",
60-
"symfony/yaml": "^6.4|^7.3",
59+
"symfony/webpack-encore-bundle": "^1.7.3|^2.4",
60+
"symfony/yaml": "^6.4|^7.4|^8.0",
6161
"vimeo/psalm": "^5.0"
6262
},
6363
"autoload": {

src/Form/Filter/CollectionFilterTrait.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ protected function getCollectionTypeOptions(array $options): array
2525
$constraints = [];
2626
if ($options['multiple']) {
2727
$constraints = [
28-
new Assert\Count([
29-
'min' => $options['min'],
30-
'max' => $options['max'],
31-
]),
28+
new Assert\Count(
29+
min: $options['min'],
30+
max: $options['max'],
31+
),
3232
];
3333
}
3434

src/Form/Filter/TextFilter.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ public function buildForm(SearchFormBuilder $builder, string $property, array $o
2424
{
2525
$typeOptions = $this->getTypeOptions($options, [
2626
'constraints' => [
27-
new Assert\Length([
28-
'min' => $options['min_length'],
29-
'max' => $options['max_length'],
30-
]),
27+
new Assert\Length(
28+
min: $options['min_length'],
29+
max: $options['max_length'],
30+
),
3131
],
3232
]);
3333
$builder->addField($property, $options['type'], $typeOptions);

src/Form/Type/DisplaySettingsType.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
5050
'label' => 'display_settings.displayed_columns',
5151
'translation_domain' => 'EcommitCrudBundle',
5252
'choice_translation_domain' => 'messages',
53-
'constraints' => [new NotBlank(), new Count(['min' => 1])],
53+
'constraints' => [new NotBlank(), new Count(min: 1)],
5454
]);
5555

5656
$builder->add('reset', ButtonType::class, [
@@ -81,7 +81,7 @@ public function configureOptions(OptionsResolver $resolver): void
8181
]);
8282
}
8383

84-
public function getBlockPrefix()
84+
public function getBlockPrefix(): string
8585
{
8686
return 'crud_display_settings';
8787
}

src/Form/Type/EntityAjaxType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public function configureOptions(OptionsResolver $resolver): void
135135
$resolver->setNormalizer('identifier', $identifierNormalizer);
136136
}
137137

138-
public function getBlockPrefix()
138+
public function getBlockPrefix(): string
139139
{
140140
return 'ecommit_crud_entity_ajax';
141141
}

src/Form/Type/FormSearchType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function configureOptions(OptionsResolver $resolver): void
3131
]);
3232
}
3333

34-
public function getBlockPrefix()
34+
public function getBlockPrefix(): string
3535
{
3636
return 'crud_search';
3737
}

src/Twig/CrudExtension.php

Lines changed: 78 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -159,47 +159,47 @@ public function paginatorLinks(Environment $environment, PaginatorInterface $pag
159159
'max_pages_after' => 3,
160160
'nav_attr' => [],
161161
'ul_attr' => [],
162-
'li_attr' => static function (OptionsResolver $liResolver): void {
163-
$liResolver->setDefaults([
164-
'first_page' => [],
165-
'previous_page' => [],
166-
'current_page' => [],
167-
'next_page' => [],
168-
'last_page' => [],
169-
'other_page' => [],
170-
]);
171-
foreach (['first_page', 'previous_page', 'current_page', 'next_page', 'last_page', 'other_page'] as $option) {
172-
$liResolver->setAllowedTypes($option, 'array');
173-
}
174-
},
175-
'a_attr' => function (OptionsResolver $aResolver, Options $parent): void {
176-
$aResolver->setDefaults([
177-
'first_page' => [],
178-
'previous_page' => [],
179-
'current_page' => [],
180-
'next_page' => [],
181-
'last_page' => [],
182-
'other_page' => [],
183-
]);
184-
foreach (['first_page', 'previous_page', 'current_page', 'next_page', 'last_page', 'other_page'] as $option) {
185-
$aResolver->setAllowedTypes($option, 'array');
186-
$aResolver->addNormalizer($option, function (Options $options, mixed $value) use ($parent): array {
187-
if (null !== $parent['ajax_options']) {
188-
return array_merge(
189-
$value,
190-
['data-ec-crud-toggle' => 'ajax-link'],
191-
$this->getAjaxAttributes($this->validateAjaxOptions($parent['ajax_options'])),
192-
);
193-
}
194-
195-
return $value;
196-
});
197-
}
198-
},
199162
'render' => null,
200163
'theme' => $this->theme,
201164
'block' => 'paginator_links',
202165
]);
166+
$this->nestedOptions($resolver, 'li_attr', static function (OptionsResolver $liResolver): void {
167+
$liResolver->setDefaults([
168+
'first_page' => [],
169+
'previous_page' => [],
170+
'current_page' => [],
171+
'next_page' => [],
172+
'last_page' => [],
173+
'other_page' => [],
174+
]);
175+
foreach (['first_page', 'previous_page', 'current_page', 'next_page', 'last_page', 'other_page'] as $option) {
176+
$liResolver->setAllowedTypes($option, 'array');
177+
}
178+
});
179+
$this->nestedOptions($resolver, 'a_attr', function (OptionsResolver $aResolver, Options $parent): void {
180+
$aResolver->setDefaults([
181+
'first_page' => [],
182+
'previous_page' => [],
183+
'current_page' => [],
184+
'next_page' => [],
185+
'last_page' => [],
186+
'other_page' => [],
187+
]);
188+
foreach (['first_page', 'previous_page', 'current_page', 'next_page', 'last_page', 'other_page'] as $option) {
189+
$aResolver->setAllowedTypes($option, 'array');
190+
$aResolver->addNormalizer($option, function (Options $options, mixed $value) use ($parent): array {
191+
if (null !== $parent['ajax_options']) {
192+
return array_merge(
193+
$value,
194+
['data-ec-crud-toggle' => 'ajax-link'],
195+
$this->getAjaxAttributes($this->validateAjaxOptions($parent['ajax_options'])),
196+
);
197+
}
198+
199+
return $value;
200+
});
201+
}
202+
});
203203
$resolver->setAllowedTypes('ajax_options', ['null', 'array']);
204204
$resolver->setAllowedTypes('max_pages_before', 'int');
205205
$resolver->setAllowedTypes('max_pages_after', 'int');
@@ -288,42 +288,42 @@ public function th(Environment $environment, string $columnId, Crud $crud, array
288288
$resolver->setDefaults([
289289
'ajax_options' => null,
290290
'label' => null,
291-
'th_attr' => static function (OptionsResolver $thResolver): void {
292-
$thResolver->setDefaults([
293-
'not_sortable' => [],
294-
'sortable_active_asc' => [],
295-
'sortable_active_desc' => [],
296-
'sortable_not_active' => [],
297-
]);
298-
foreach (['not_sortable', 'sortable_active_asc', 'sortable_active_desc', 'sortable_not_active'] as $option) {
299-
$thResolver->setAllowedTypes($option, 'array');
300-
}
301-
},
302-
'a_attr' => function (OptionsResolver $aResolver, Options $parent): void {
303-
$aResolver->setDefaults([
304-
'sortable_active_asc' => [],
305-
'sortable_active_desc' => [],
306-
'sortable_not_active' => [],
307-
]);
308-
foreach (['sortable_active_asc', 'sortable_active_desc', 'sortable_not_active'] as $option) {
309-
$aResolver->setAllowedTypes($option, 'array');
310-
$aResolver->addNormalizer($option, function (Options $options, mixed $value) use ($parent): array {
311-
if (null !== $parent['ajax_options']) {
312-
return array_merge(
313-
$value,
314-
['data-ec-crud-toggle' => 'ajax-link'],
315-
$this->getAjaxAttributes($this->validateAjaxOptions($parent['ajax_options'])),
316-
);
317-
}
318-
319-
return $value;
320-
});
321-
}
322-
},
323291
'render' => null,
324292
'theme' => $this->theme,
325293
'block' => 'th',
326294
]);
295+
$this->nestedOptions($resolver, 'th_attr', static function (OptionsResolver $thResolver): void {
296+
$thResolver->setDefaults([
297+
'not_sortable' => [],
298+
'sortable_active_asc' => [],
299+
'sortable_active_desc' => [],
300+
'sortable_not_active' => [],
301+
]);
302+
foreach (['not_sortable', 'sortable_active_asc', 'sortable_active_desc', 'sortable_not_active'] as $option) {
303+
$thResolver->setAllowedTypes($option, 'array');
304+
}
305+
});
306+
$this->nestedOptions($resolver, 'a_attr', function (OptionsResolver $aResolver, Options $parent): void {
307+
$aResolver->setDefaults([
308+
'sortable_active_asc' => [],
309+
'sortable_active_desc' => [],
310+
'sortable_not_active' => [],
311+
]);
312+
foreach (['sortable_active_asc', 'sortable_active_desc', 'sortable_not_active'] as $option) {
313+
$aResolver->setAllowedTypes($option, 'array');
314+
$aResolver->addNormalizer($option, function (Options $options, mixed $value) use ($parent): array {
315+
if (null !== $parent['ajax_options']) {
316+
return array_merge(
317+
$value,
318+
['data-ec-crud-toggle' => 'ajax-link'],
319+
$this->getAjaxAttributes($this->validateAjaxOptions($parent['ajax_options'])),
320+
);
321+
}
322+
323+
return $value;
324+
});
325+
}
326+
});
327327
$resolver->setAllowedTypes('ajax_options', ['null', 'array']);
328328
$resolver->addNormalizer('ajax_options', static function (Options $options, mixed $value) use ($crud): array {
329329
if (!isset($value['update'])) {
@@ -740,4 +740,13 @@ protected function buildOptions(string $function, array $inlineOptions, ?Crud $c
740740

741741
return array_merge($options, $inlineOptions);
742742
}
743+
744+
private function nestedOptions(OptionsResolver $optionsResolver, string $option, \Closure $nested): void
745+
{
746+
if (method_exists($optionsResolver, 'setOptions')) {
747+
$optionsResolver->setOptions($option, $nested);
748+
} else { // @legacy Symfony < 7.3
749+
$optionsResolver->setDefault($option, $nested);
750+
}
751+
}
743752
}

tests/Functional/App/config/doctrine.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ doctrine:
66
logging: false
77

88
orm:
9-
auto_generate_proxy_classes: false
109
entity_managers:
1110
default:
1211
connection: default

0 commit comments

Comments
 (0)