Skip to content

Commit d88381d

Browse files
committed
make context builders internal
1 parent 2389abb commit d88381d

File tree

12 files changed

+70
-154
lines changed

12 files changed

+70
-154
lines changed

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,6 @@ class UnusedTagsPass implements CompilerPassInterface
8989
'security.remember_me_handler',
9090
'security.voter',
9191
'ser_des.context_builder',
92-
'ser_des.context_builder.deserialize',
93-
'ser_des.context_builder.serialize',
94-
'ser_des.hook.deserialize',
95-
'ser_des.hook.serialize',
9692
'serializer.encoder',
9793
'serializer.normalizer',
9894
'texter.transport_factory',

src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@
5656
use Symfony\Component\HttpKernel\DependencyInjection\RemoveEmptyControllerArgumentLocatorsPass;
5757
use Symfony\Component\HttpKernel\DependencyInjection\ResettableServicePass;
5858
use Symfony\Component\HttpKernel\KernelEvents;
59-
use Symfony\Component\SerDes\DependencyInjection\SerDesPass;
6059
use Symfony\Component\Messenger\DependencyInjection\MessengerPass;
6160
use Symfony\Component\Mime\DependencyInjection\AddMimeTypeGuesserPass;
6261
use Symfony\Component\PropertyInfo\DependencyInjection\PropertyInfoPass;
@@ -171,7 +170,6 @@ public function build(ContainerBuilder $container)
171170
$this->addCompilerPassIfExists($container, MessengerPass::class);
172171
$this->addCompilerPassIfExists($container, HttpClientPass::class);
173172
$this->addCompilerPassIfExists($container, AddAutoMappingConfigurationPass::class);
174-
$this->addCompilerPassIfExists($container, SerDesPass::class);
175173
$container->addCompilerPass(new RegisterReverseContainerPass(true));
176174
$container->addCompilerPass(new RegisterReverseContainerPass(false), PassConfig::TYPE_AFTER_REMOVING);
177175
$container->addCompilerPass(new RemoveUnusedSessionMarshallingHandlerPass());

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

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,19 @@
4141
// Serializer
4242
->set('ser_des.serializer', Serializer::class)
4343
->args([
44-
abstract_arg('serialize context builders'),
45-
abstract_arg('deserialize context builders'),
4644
param('.ser_des.cache_dir.template'),
4745
])
46+
->call('setSerializeContextBuilders', [[
47+
service('.ser_des.context_builder.serialize.hook'),
48+
service('.ser_des.context_builder.serialize.name_attribute'),
49+
service('.ser_des.context_builder.serialize.formatter_attribute'),
50+
]])
51+
->call('setDeserializeContextBuilders', [[
52+
service('.ser_des.context_builder.deserialize.hook'),
53+
service('.ser_des.context_builder.deserialize.name_attribute'),
54+
service('.ser_des.context_builder.deserialize.formatter_attribute'),
55+
service('.ser_des.context_builder.deserialize.instantiator'),
56+
]])
4857

4958
->alias(SerializerInterface::class, 'ser_des.serializer')
5059

@@ -64,72 +73,63 @@
6473
->alias('ser_des.type_extractor', 'ser_des.type_extractor.reflection')
6574

6675
// Context builders
67-
->set('ser_des.context_builder.serialize.hook', SerializeHookContextBuilder::class)
68-
->args([
69-
abstract_arg('serialize hooks'),
70-
])
71-
->tag('ser_des.context_builder.serialize', ['priority' => -1024])
76+
->set('.ser_des.context_builder.serialize.hook', SerializeHookContextBuilder::class)
77+
->args([[
78+
'object' => service('ser_des.hook.serialize.object'),
79+
'property' => service('ser_des.hook.serialize.property'),
80+
]])
7281

73-
->set('ser_des.context_builder.serialize.name_attribute', SerializeNameAttributeContextBuilder::class)
82+
->set('.ser_des.context_builder.serialize.name_attribute', SerializeNameAttributeContextBuilder::class)
7483
->args([
7584
service('ser_des.serializable_resolver'),
7685
])
77-
->tag('ser_des.context_builder.serialize', ['priority' => -1024])
7886

79-
->set('ser_des.context_builder.serialize.formatter_attribute', SerializeFormatterAttributeContextBuilder::class)
87+
->set('.ser_des.context_builder.serialize.formatter_attribute', SerializeFormatterAttributeContextBuilder::class)
8088
->args([
8189
service('ser_des.serializable_resolver'),
8290
])
83-
->tag('ser_des.context_builder.serialize', ['priority' => -1024])
8491

85-
->set('ser_des.context_builder.deserialize.hook', DeserializeHookContextBuilder::class)
86-
->args([
87-
abstract_arg('deserialize hooks'),
88-
])
89-
->tag('ser_des.context_builder.deserialize', ['priority' => -1024])
92+
->set('.ser_des.context_builder.deserialize.hook', DeserializeHookContextBuilder::class)
93+
->args([[
94+
'object' => service('ser_des.hook.deserialize.object'),
95+
'property' => service('ser_des.hook.deserialize.property'),
96+
]])
9097

91-
->set('ser_des.context_builder.deserialize.name_attribute', DeserializeNameAttributeContextBuilder::class)
98+
->set('.ser_des.context_builder.deserialize.name_attribute', DeserializeNameAttributeContextBuilder::class)
9299
->args([
93100
service('ser_des.serializable_resolver'),
94101
])
95-
->tag('ser_des.context_builder.deserialize', ['priority' => -1024])
96102

97-
->set('ser_des.context_builder.deserialize.formatter_attribute', DeserializeFormatterAttributeContextBuilder::class)
103+
->set('.ser_des.context_builder.deserialize.formatter_attribute', DeserializeFormatterAttributeContextBuilder::class)
98104
->args([
99105
service('ser_des.serializable_resolver'),
100106
])
101-
->tag('ser_des.context_builder.deserialize', ['priority' => -1024])
102107

103-
->set('ser_des.context_builder.deserialize.instantiator', DeserializeInstantiatorContextBuilder::class)
108+
->set('.ser_des.context_builder.deserialize.instantiator', DeserializeInstantiatorContextBuilder::class)
104109
->args([
105110
service('ser_des.instantiator.lazy'),
106111
])
107-
->tag('ser_des.context_builder.deserialize', ['priority' => -1024])
108112

109113
// Hooks
110114
->set('ser_des.hook.serialize.object', SerializeHook\ObjectHook::class)
111115
->args([
112116
service('ser_des.type_extractor'),
113117
])
114-
->tag('ser_des.hook.serialize', ['name' => 'object'])
115118

116119
->set('ser_des.hook.serialize.property', SerializeHook\PropertyHook::class)
117120
->args([
118121
service('ser_des.type_extractor'),
119122
])
120-
->tag('ser_des.hook.serialize', ['name' => 'property'])
121123

122124
->set('ser_des.hook.deserialize.object', DeserializeHook\ObjectHook::class)
123125
->args([
124126
service('ser_des.type_extractor'),
125127
])
126-
->tag('ser_des.hook.deserialize', ['name' => 'object'])
127128

128129
->set('ser_des.hook.deserialize.property', DeserializeHook\PropertyHook::class)
129130
->args([
130131
service('ser_des.type_extractor'),
131132
])
132-
->tag('ser_des.hook.deserialize', ['name' => 'property'])
133133

134134
// Serializable resolvers
135135
->set('ser_des.serializable_resolver', PathSerializableResolver::class)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
/**
1919
* @author Mathias Arlaud <[email protected]>
2020
*
21-
* @experimental in 7.0
21+
* @internal
2222
*/
2323
final class DeserializeNameAttributeContextBuilder implements DeserializeContextBuilderInterface
2424
{

src/Symfony/Component/SerDes/DependencyInjection/SerDesPass.php

Lines changed: 0 additions & 44 deletions
This file was deleted.

src/Symfony/Component/SerDes/Hook/Deserialize/ObjectHook.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ public function __construct(
4040
public function __invoke(string $type, array $context): array
4141
{
4242
return [
43-
'type' => $type,
4443
'context' => $this->addGenericParameterTypes($type, $context),
4544
];
4645
}

src/Symfony/Component/SerDes/Hook/Serialize/ObjectHook.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ public function __construct(
3333
public function __invoke(string $type, string $accessor, array $context): array
3434
{
3535
return [
36-
'type' => $type,
37-
'accessor' => $accessor,
3836
'context' => $this->addGenericParameterTypes($type, $context),
3937
];
4038
}

src/Symfony/Component/SerDes/Hook/Serialize/PropertyHook.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ public function __invoke(\ReflectionProperty $property, string $accessor, array
3939
'name' => $this->name($property, $className, $name, $context),
4040
'type' => $this->type($property, $propertyFormatter, $context),
4141
'accessor' => $this->accessor($className, $name, $propertyFormatter, $accessor, $context),
42-
'context' => $context,
4342
];
4443
}
4544

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,8 @@ private function computePropertiesInfo(string $className, string $objectAccessor
212212
{
213213
$class = new \ReflectionClass($className);
214214

215+
$propertiesInfo = [];
216+
215217
foreach ($class->getProperties() as $property) {
216218
if (!$property->isPublic()) {
217219
throw new LogicException(sprintf('"%s::$%s" must be public.', $class->getName(), $property->getName()));

src/Symfony/Component/SerDes/Serializer.php

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

1212
namespace Symfony\Component\SerDes;
1313

14-
use Symfony\Component\SerDes\Context\ContextBuilder\DeserializeContextBuilderInterface;
15-
use Symfony\Component\SerDes\Context\ContextBuilder\SerializeContextBuilderInterface;
14+
use Symfony\Component\SerDes\Context\ContextBuilder\ContextBuilderInterface;
1615
use Symfony\Component\SerDes\Context\ContextInterface;
1716
use Symfony\Component\SerDes\Stream\StreamInterface;
1817

@@ -24,12 +23,16 @@
2423
final class Serializer implements SerializerInterface
2524
{
2625
/**
27-
* @param iterable<SerializeContextBuilderInterface> $serializeContextBuilders
28-
* @param iterable<DeserializeContextBuilderInterface> $deserializeContextBuilders
26+
* @var iterable<ContextBuilderInterface>
2927
*/
28+
private iterable $serializeContextBuilders = [];
29+
30+
/**
31+
* @var iterable<ContextBuilderInterface>
32+
*/
33+
private iterable $deserializeContextBuilders = [];
34+
3035
public function __construct(
31-
private readonly iterable $serializeContextBuilders,
32-
private readonly iterable $deserializeContextBuilders,
3336
private readonly string $templateCacheDir,
3437
) {
3538
}
@@ -71,4 +74,24 @@ public function deserialize(mixed $input, string $type, string $format, ContextI
7174

7275
return deserialize($input, $type, $format, $context);
7376
}
77+
78+
/**
79+
* @param iterable<ContextBuilderInterface> $serializeContextBuilders
80+
*
81+
* @internal
82+
*/
83+
public function setSerializeContextBuilders(iterable $serializeContextBuilders): void
84+
{
85+
$this->serializeContextBuilders = $serializeContextBuilders;
86+
}
87+
88+
/**
89+
* @param iterable<ContextBuilderInterface> $deserializeContextBuilders
90+
*
91+
* @internal
92+
*/
93+
public function setDeserializeContextBuilders(iterable $deserializeContextBuilders): void
94+
{
95+
$this->deserializeContextBuilders = $deserializeContextBuilders;
96+
}
7497
}

src/Symfony/Component/SerDes/Tests/DependencyInjection/SerDesPassTest.php

Lines changed: 0 additions & 60 deletions
This file was deleted.

0 commit comments

Comments
 (0)