8000 Merge branch '5.3' into 5.4 · symfony/symfony@d81705f · GitHub
[go: up one dir, main page]

Skip to content

Commit d81705f

Browse files
Merge branch '5.3' into 5.4
* 5.3: [Serializer] fix support for lazy properties remove FlattenExceptionNormalizer definition if serializer not available
2 parents 2b410e9 + 3bd4f57 commit d81705f

File tree

4 files changed

+47
-1
lines changed

4 files changed

+47
-1
lines changed

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1936,6 +1936,10 @@ private function registerMessengerConfiguration(array $config, ContainerBuilder
19361936

19371937
$loader->load('messenger.php');
19381938

1939+
if (!interface_exists(DenormalizerInterface::class)) {
1940+
$container->removeDefinition('serializer.normalizer.flatten_exception');
1941+
}
1942+
19391943
if (ContainerBuilder::willBeAvailable('symfony/amqp-messenger', AmqpTransportFactory::class, ['symfony/framework-bundle', 'symfony/messenger'], true)) {
19401944
$container->getDefinition('messenger.transport.amqp.factory')->addTag('messenger.transport_factory');
19411945
}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@
5959

6060
return static function (ContainerConfigurator $container) {
6161
$container->services()
62+
->alias('notifier.transport_factory.allmysms', 'notifier.transport_factory.all-my-sms')
63+
->deprecate('symfony/framework-bundle', '5.4', 'The "%alias_id% service is deprecated, use "notifier.transport_factory.all-my-sms" instead.')
6264
->alias('notifier.transport_factory.fakechat', 'notifier.transport_factory.fake-chat')
6365
->deprecate('symfony/framework-bundle', '5.4', 'The "%alias_id% service is deprecated, use "notifier.transport_factory.fake-chat" instead.')
6466
->alias('notifier.transport_factory.fakesms', 'notifier.transport_factory.fake-sms')
@@ -118,7 +120,7 @@
118120
->parent('notifier.transport_factory.abstract')
119121
->tag('texter.transport_factory')
120122

121-
->set('notifier.transport_factory.allmysms', AllMySmsTransportFactory::class)
123+
->set('notifier.transport_factory.all-my-sms', AllMySmsTransportFactory::class)
122124
->parent('notifier.transport_factory.abstract')
123125
->tag('texter.transport_factory')
124126

src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,16 @@ public function testNormalizeObjectWithUnsetProperties()
147147
);
148148
}
149149

150+
public function testNormalizeObjectWithLazyProperties()
151+
{
152+
$obj = new LazyObjectInner();
153+
unset($obj->foo);
154+
$this->assertEquals(
155+
['foo' => 123, 'bar' => null],
156+
$this->normalizer->normalize($obj, 'any')
157+
);
158+
}
159+
150160
/**
151161
* @requires PHP 7.4
152162
*/
@@ -982,6 +992,16 @@ class ObjectInner
982992
public $bar;
983993
}
984994

995+
class LazyObjectInner extends ObjectInner
996+
{
997+
public function __get($name)
998+
{
999+
if ('foo' === $name) {
1000+
return $this->foo = 123;
1001+
}
1002+
}
1003+
}
1004+
9851005
class FormatAndContextAwareNormalizer extends ObjectNormalizer
9861006
{
9871007
protected function isAllowedAttribute($classOrObject, string $attribute, string $format = null, array $context = []): bool

src/Symfony/Component/Serializer/Tests/Normalizer/PropertyNormalizerTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,16 @@ public function testNormalizeObjectWithUnsetProperties()
115115
);
116116
}
117117

118+
public function testNormalizeObjectWithLazyProperties()
119+
{
120+
$obj = new LazyPropertyDummy();
121+
unset($obj->foo);
122+
$this->assertEquals(
123+
['foo' => 123, 'bar' => null, 'camelCase' => null],
124+
$this->normalizer->normalize($obj, 'any')
125+
);
126+
}
127+
118128
public function testDenormalize()
119129
{
120130
$obj = $this->normalizer->denormalize(
@@ -472,6 +482,16 @@ public function setCamelCase($camelCase)
472482
}
473483
}
474484

485+
class LazyPropertyDummy extends PropertyDummy
486+
{
487+
public function __get($name)
488+
{
489+
if ('foo' === $name) {
490+
return $this->foo = 123;
491+
}
492+
}
493+
}
494+
475495
class PropertyConstructorDummy
476496
{
477497
protected $foo;

0 commit comments

Comments
 (0)
0