Skip to content

Commit a0aa7de

Browse files
committed
minor fixes
1 parent b83728d commit a0aa7de

File tree

9 files changed

+27
-38
lines changed

9 files changed

+27
-38
lines changed

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/UnusedTagsPass.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,13 @@ class UnusedTagsPass implements CompilerPassInterface
8686
'security.remember_me_aware',
8787
'security.remember_me_handler',
8888
'security.voter',
89-
'serializer.encoder',
90-
'serializer.normalizer',
9189
'ser_des.context_builder',
92-
'ser_des.hook.serialize',
90+
'ser_des.context_builder.deserialize',
91+
'ser_des.context_builder.serialize',
9392
'ser_des.hook.deserialize',
93+
'ser_des.hook.serialize',
94+
'serializer.encoder',
95+
'serializer.normalizer',
9496
'texter.transport_factory',
9597
'translation.dumper',
9698
'translation.extractor',

src/Symfony/Bundle/FrameworkBundle/Resources/config/ser_des.php

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

3434
return static function (ContainerConfigurator $container) {
3535
$container->parameters()
36-
->set('ser_des.cache_dir.template', '%kernel.cache_dir%/ser_des/template')
37-
->set('ser_des.cache_dir.lazy_object', '%kernel.cache_dir%/ser_des/lazy_object')
36+
->set('.ser_des.cache_dir.template', '%kernel.cache_dir%/ser_des/template')
37+
->set('.ser_des.cache_dir.lazy_object', '%kernel.cache_dir%/ser_des/lazy_object')
3838
;
3939

4040
$container->services()

src/Symfony/Component/SerDes/Attribute/Formatter.php

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
namespace Symfony\Component\SerDes\Attribute;
1313

14-
use Symfony\Component\SerDes\Exception\InvalidArgumentException;
15-
1614
/**
1715
* @author Mathias Arlaud <[email protected]>
1816
*
@@ -22,19 +20,12 @@
2220
final class Formatter
2321
{
2422
/**
25-
* @param callable|null $onSerialize
26-
* @param callable|null $onDeserialize
23+
* @param callable(mixed, array<string, mixed>=): mixed|null $onSerialize
24+
* @param callable(mixed, array<string, mixed>=): mixed|null $onDeserialize
2725
*/
2826
public function __construct(
2927
public readonly mixed $onSerialize = null,
3028
public readonly mixed $onDeserialize = null,
3129
) {
32-
if (null !== $onSerialize && !\is_callable($onSerialize)) {
33-
throw new InvalidArgumentException(sprintf('Parameter "$onSerialize" of attribute "%s" must be a valid callable.', self::class));
34-
}
35-
36-
if (null !== $onDeserialize && !\is_callable($onDeserialize)) {
37-
throw new InvalidArgumentException(sprintf('Parameter "$onDeserialize" of attribute "%s" must be a valid callable.', self::class));
38-
}
3930
}
4031
}

src/Symfony/Component/SerDes/CachedSerializableResolver.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,12 @@ public function resolve(): iterable
4242
}
4343

4444
if (!$item->isHit()) {
45-
$item->set(iterator_to_array($this->resolver->resolve()));
45+
$serializables = [];
46+
foreach ($this->resolver->resolve() as $class => $serializable) {
47+
$serializables[$class] = $serializable;
48+
}
49+
50+
$item->set($serializables);
4651
}
4752

4853
yield from $item->get();

src/Symfony/Component/SerDes/Context/ContextBuilder/Deserialize/DeserializeFormatterAttributeContextBuilder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
final class DeserializeFormatterAttributeContextBuilder implements DeserializeContextBuilderInterface
2424
{
2525
/**
26-
* @var array<string, callable>
26+
* @var array<string, array{deserialize: callable}>
2727
*/
2828
private static ?array $cache = null;
2929

@@ -52,7 +52,7 @@ public function build(array $context): array
5252
/**
5353
* @param class-string $className
5454
*
55-
* @return array<string, callable>
55+
* @return array<string, array{deserialize: callable}>
5656
*/
5757
private function propertyFormatters(string $className): array
5858
{

src/Symfony/Component/SerDes/Context/ContextBuilder/Serialize/SerializeFormatterAttributeContextBuilder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
final class SerializeFormatterAttributeContextBuilder implements SerializeContextBuilderInterface
2424
{
2525
/**
26-
* @var array<string, callable>
26+
* @var array<string, array{serialize: callable}>
2727
*/
2828
private static ?array $cache = null;
2929

@@ -56,7 +56,7 @@ public function build(array $context): array
5656
/**
5757
* @param class-string $className
5858
*
59-
* @return array<string, callable>
59+
* @return array<string, array{serialize: callable}>
6060
*/
6161
private function propertyFormatters(string $className): array
6262
{

src/Symfony/Component/SerDes/Internal/Deserialize/Deserializer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ private function lazyDeserializeCollectionItems(\Iterator $boundaries, mixed $re
157157
/**
158158
* @param array<string, mixed> $context
159159
*/
160-
private function deserializeEnum(bool $lazy, mixed $resourceOrData, Type $type, array $context): \BackedEnum
160+
private function deserializeEnum(bool $lazy, mixed $resourceOrData, Type $type, array $context): ?\BackedEnum
161161
{
162162
$data = $lazy ? $this->decoder->decode($resourceOrData, $context['boundary'][0], $context['boundary'][1], $context) : $resourceOrData;
163163

src/Symfony/Component/SerDes/Internal/Serialize/Optimizer.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,13 @@ private function mergeResourceStringFwrites(array $nodes): array
7272
continue;
7373
}
7474

75-
/** @var ExpressionNode<FunctionNode> $node */
76-
$stringContent = $stringContent.$node->node->parameters[1]->value;
75+
/**
76+
* @var ExpressionNode<FunctionNode> $node
77+
* @var ScalarNode $stringParameter
78+
*/
79+
$stringParameter = $node->node->parameters[1];
80+
81+
$stringContent = $stringContent.$stringParameter->value;
7782
}
7883

7984
if ('' !== $stringContent) {

src/Symfony/Component/SerDes/Tests/Attribute/FormatterTest.php

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,4 @@ public static function toUpper(string $value, array $context): string
4949

5050
$this->addToAssertionCount(4);
5151
}
52-
53-
public function testCannotCreateWithInvalidOnSerializeCallable()
54-
{
55-
$this->expectException(InvalidArgumentException::class);
56-
57-
new Formatter(onSerialize: []);
58-
}
59-
60-
public function testCannotCreateWithInvalidOnDeserializeCallable()
61-
{
62-
$this->expectException(InvalidArgumentException::class);
63-
64-
new Formatter(onDeserialize: []);
65-
}
6652
}

0 commit comments

Comments
 (0)