Skip to content

Commit f70fe9b

Browse files
authored
Merge pull request #24 from imatic/symfony-8.1
update pro Symfony 8.1
2 parents 336c410 + aa9349c commit f70fe9b

44 files changed

Lines changed: 3372 additions & 2421 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: CI
2+
3+
on: [push]
4+
5+
jobs:
6+
test:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v4
10+
11+
- name: Setup PHP
12+
uses: shivammathur/setup-php@v2
13+
with:
14+
php-version: '8.5'
15+
coverage: none
16+
17+
- name: Install dependencies
18+
uses: ramsey/composer-install@v3
19+
20+
- name: Run tests
21+
run: make test

.php-cs-fixer.dist.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585
'vendor',
8686
'Tests/Fixtures/TestProject/var',
8787
])
88+
->notPath('Tests/Fixtures/TestProject/config/reference.php')
8889
->in(__DIR__)
8990
)
9091
;

DependencyInjection/Compiler/FormPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
class FormPass implements CompilerPassInterface
88
{
9-
public function process(ContainerBuilder $container)
9+
public function process(ContainerBuilder $container): void
1010
{
1111
$resources = $container->getParameter('twig.form.resources');
1212

DependencyInjection/Configuration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*/
1212
class Configuration implements ConfigurationInterface
1313
{
14-
public function getConfigTreeBuilder()
14+
public function getConfigTreeBuilder(): TreeBuilder
1515
{
1616
$treeBuilder = new TreeBuilder('imatic_form');
1717
$rootNode = $treeBuilder->getRootNode();

DependencyInjection/ImaticFormExtension.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
use Symfony\Component\Config\FileLocator;
55
use Symfony\Component\DependencyInjection\ContainerBuilder;
6+
use Symfony\Component\DependencyInjection\Extension\Extension;
67
use Symfony\Component\DependencyInjection\Loader;
7-
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
88

99
/**
1010
* This is the class that loads and manages your bundle configuration.
@@ -13,15 +13,15 @@
1313
*/
1414
class ImaticFormExtension extends Extension
1515
{
16-
public function load(array $configs, ContainerBuilder $container)
16+
public function load(array $configs, ContainerBuilder $container): void
1717
{
1818
$configuration = new Configuration();
1919
$config = $this->processConfiguration($configuration, $configs);
2020

2121
$container->setParameter('imatic_form.default_theme', $config['default_theme']);
2222
$container->setParameter('imatic_form.select2', $config['select2']);
2323

24-
$loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
25-
$loader->load('services.xml');
24+
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
25+
$loader->load('services.yaml');
2626
}
2727
}

Form/DataTransformer/ArrayToStringTransformer.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,24 @@
55

66
class ArrayToStringTransformer implements DataTransformerInterface
77
{
8-
public function transform($array)
8+
public function transform(mixed $value): mixed
99
{
10-
if (null === $array || !\is_array($array)) {
10+
if (null === $value || !\is_array($value)) {
1111
return '';
1212
}
1313

14-
return \implode(',', $array);
14+
return \implode(',', $value);
1515
}
1616

17-
public function reverseTransform($string)
17+
public function reverseTransform(mixed $value): mixed
1818
{
19-
if ('' === $string) {
19+
if ('' === $value) {
2020
return null;
2121
}
22-
if (\is_array($string)) {
23-
return $string;
22+
if (\is_array($value)) {
23+
return $value;
2424
}
2525

26-
return \explode(',', $string);
26+
return \explode(',', $value);
2727
}
2828
}

Form/DataTransformer/CollectionToScalarTransformer.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,19 @@ public function __construct(QueryBuilder $qb, callable $idProvider)
2424
$this->idProvider = $idProvider;
2525
}
2626

27-
public function transform($collection)
27+
public function transform(mixed $value): mixed
2828
{
2929
// handle value
30-
if (null === $collection) {
30+
if (null === $value) {
3131
return '';
3232
}
33-
if (!$collection instanceof \Traversable && !\is_array($collection)) {
34-
throw new UnexpectedTypeException($collection, 'Traversable, array or null');
33+
if (!$value instanceof \Traversable && !\is_array($value)) {
34+
throw new UnexpectedTypeException($value, 'Traversable, array or null');
3535
}
3636

3737
// fetch collection members
3838
$output = null;
39-
foreach ($collection as $entity) {
39+
foreach ($value as $entity) {
4040
if (null === $output) {
4141
$output = '';
4242
} else {
@@ -51,7 +51,7 @@ public function transform($collection)
5151
return $output;
5252
}
5353

54-
public function reverseTransform($value)
54+
public function reverseTransform(mixed $value): mixed
5555
{
5656
if (null === $value || '' === $value) {
5757
return new ArrayCollection();

Form/DataTransformer/EmptyEntityToNullTransformer.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function __construct(array $properties, $strict = false)
2525
$this->strict = $strict;
2626
}
2727

28-
public function reverseTransform($value)
28+
public function reverseTransform(mixed $value): mixed
2929
{
3030
if (!\is_object($value)) {
3131
return $value;
@@ -34,7 +34,6 @@ public function reverseTransform($value)
3434
$hasNonEmptyValue = false;
3535
foreach ($this->properties as $property) {
3636
$reflProperty = new \ReflectionProperty($value, $property);
37-
$reflProperty->setAccessible(true);
3837
$reflPropertyValue = $reflProperty->getValue($value);
3938

4039
if (
@@ -50,7 +49,7 @@ public function reverseTransform($value)
5049
return $hasNonEmptyValue ? $value : null;
5150
}
5251

53-
public function transform($value)
52+
public function transform(mixed $value): mixed
5453
{
5554
return $value;
5655
}

Form/DataTransformer/EntityToScalarTransformer.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,19 @@ public function __construct(QueryBuilder $qb, callable $idProvider)
2323
$this->idProvider = $idProvider;
2424
}
2525

26-
public function transform($entity)
26+
public function transform(mixed $value): mixed
2727
{
28-
if (!\is_object($entity)) {
29-
if (null === $entity) {
28+
if (!\is_object($value)) {
29+
if (null === $value) {
3030
return '';
3131
}
32-
throw new UnexpectedTypeException($entity, 'object or null');
32+
throw new UnexpectedTypeException($value, 'object or null');
3333
}
3434

35-
return (string) \call_user_func($this->idProvider, $entity);
35+
return (string) \call_user_func($this->idProvider, $value);
3636
}
3737

38-
public function reverseTransform($value)
38+
public function reverseTransform(mixed $value): mixed
3939
{
4040
if (null !== $value && '' !== $value) {
4141
$qb = clone $this->qb;

Form/EventListener/RemoveUnsentFieldsSubscriber.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*/
1111
class RemoveUnsentFieldsSubscriber implements EventSubscriberInterface
1212
{
13-
public static function getSubscribedEvents()
13+
public static function getSubscribedEvents(): array
1414
{
1515
return [
1616
FormEvents::PRE_SUBMIT => 'preSubmit',

0 commit comments

Comments
 (0)