Skip to content

Commit 7e6b931

Browse files
committed
Fixed code for symfony 7
1 parent 9eb825f commit 7e6b931

File tree

6 files changed

+20
-19
lines changed

6 files changed

+20
-19
lines changed

composer.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Form/SelectTypeOrderExtension.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public static function getExtendedTypes(): iterable
4141
];
4242
}
4343

44-
public function configureOptions(OptionsResolver $resolver)
44+
public function configureOptions(OptionsResolver $resolver): void
4545
{
4646
$resolver->setDefault('ordered', false);
4747
$resolver->setDefault('by_reference', function (Options $options) {
@@ -50,7 +50,7 @@ public function configureOptions(OptionsResolver $resolver)
5050
});
5151
}
5252

53-
public function buildView(FormView $view, FormInterface $form, array $options)
53+
public function buildView(FormView $view, FormInterface $form, array $options): void
5454
{
5555
//Pass the data in ordered form to the frontend controller, so it can make the items appear in the correct order.
5656
if ($options['ordered']) {

src/Form/Type/TriStateCheckboxType.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public function buildView(FormView $view, FormInterface $form, array $options):
100100
* @return mixed The value in the transformed representation
101101
*
102102
*/
103-
public function transform(mixed $value)
103+
public function transform(mixed $value): mixed
104104
{
105105
if (true === $value) {
106106
return 'true';
@@ -142,7 +142,7 @@ public function transform(mixed $value)
142142
*
143143
* @return mixed The value in the original representation
144144
*/
145-
public function reverseTransform(mixed $value)
145+
public function reverseTransform(mixed $value): mixed
146146
{
147147
return match ($value) {
148148
'true' => true,

src/Serializer/StructuralElementDenormalizer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public function denormalize($data, string $type, ?string $format = null, array $
122122
return $deserialized_entity;
123123
}
124124

125-
public function getSupportedTypes(): array
125+
public function getSupportedTypes(?string $format): array
126126
{
127127
//Must be false, because we use in_array in supportsDenormalization
128128
return [

src/Serializer/StructuralElementNormalizer.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,17 @@
2424

2525
use App\Entity\Base\AbstractStructuralDBElement;
2626
use Symfony\Component\DependencyInjection\Attribute\Autowire;
27+
use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface;
28+
use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait;
2729
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
2830
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
2931

3032
/**
3133
* @see \App\Tests\Serializer\StructuralElementNormalizerTest
3234
*/
33-
class StructuralElementNormalizer implements NormalizerInterface
35+
class StructuralElementNormalizer implements NormalizerInterface, NormalizerAwareInterface
3436
{
35-
public function __construct(
36-
#[Autowire(service: ObjectNormalizer::class)]private readonly NormalizerInterface $normalizer
37-
)
38-
{
39-
}
37+
use NormalizerAwareTrait;
4038

4139
public function supportsNormalization($data, ?string $format = null, array $context = []): bool
4240
{
@@ -48,7 +46,7 @@ public function supportsNormalization($data, ?string $format = null, array $cont
4846
return $data instanceof AbstractStructuralDBElement;
4947
}
5048

51-
public function normalize($object, ?string $format = null, array $context = []): mixed
49+
public function normalize($object, ?string $format = null, array $context = []): \ArrayObject|bool|float|int|string
5250
{
5351
if (!$object instanceof AbstractStructuralDBElement) {
5452
throw new \InvalidArgumentException('This normalizer only supports AbstractStructural objects!');

src/Twig/TwigCoreExtension.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,11 @@
3434
*/
3535
final class TwigCoreExtension extends AbstractExtension
3636
{
37-
public function __construct(protected ObjectNormalizer $objectNormalizer)
37+
private readonly ObjectNormalizer $objectNormalizer;
38+
39+
public function __construct()
3840
{
41+
$this->objectNormalizer = new ObjectNormalizer();
3942
}
4043

4144
public function getFunctions(): array

0 commit comments

Comments
 (0)