8000 resolve conversations · symfony/symfony@fe55720 · GitHub
[go: up one dir, main page]

Skip to content

Commit fe55720

Browse files
committed
resolve conversations
1 parent f81533b commit fe55720

File tree

1 file changed

+11
-22
lines changed

1 file changed

+11
-22
lines changed

src/Symfony/Component/Serializer/Normalizer/UnwrappingDenormalizer.php

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,43 +12,40 @@
1212
namespace Symfony\Component\Serializer\Normalizer;
1313

1414
use Symfony\Component\PropertyAccess\PropertyAccess;
15-
use Symfony\Component\PropertyAccess\PropertyAccessor;
15+
use Symfony\Component\PropertyAccess\PropertyAccessorInterface;
1616
use Symfony\Component\Serializer\SerializerAwareInterface;
17-
use Symfony\Component\Serializer\SerializerInterface;
17+
use Symfony\Component\Serializer\SerializerAwareTrait;
1818

1919
final class UnwrappingDenormalizer implements DenormalizerInterface, SerializerAwareInterface, CacheableSupportsMethodInterface
2020
{
21-
const UNWRAP_PATH = 'unwrap_path';
21+
use SerializerAwareTrait;
2222

23-
/**
24-
* @var SerializerInterface|DenormalizerInterface
25-
*/
26-
private $serializer;
23+
const UNWRAP_PATH = 'unwrap_path';
2724

2825
/**
2926
* @var PropertyAccess
3027
*/
31-
private $propertyAccess;
28+
private $propertyAccessor;
3229

33-
public function __construct(PropertyAccessor $propertyAccess)
30+
public function __construct(PropertyAccessorInterface $propertyAccessor = null)
3431
{
35-
$this->propertyAccess = $propertyAccess;
32+
$this->propertyAccessor = $propertyAccessor ?? PropertyAccess::createPropertyAccessor();
3633
}
3734

3835
/**
3936
* {@inheritdoc}
4037
*/
41-
public function denormalize($data, $class, $format = null, array $context = [])
38+
public function denormalize($data, $class, string $format = null, array $context = [])
4239
{
4340
$propertyPath = $context[self::UNWRAP_PATH];
4441
$context['unwrapped'] = true;
4542

4643
if ($propertyPath) {
47-
if (!$this->propertyAccess->isReadable($data, $propertyPath)) {
44+
if (!$this->propertyAccessor->isReadable($data, $propertyPath)) {
4845
return null;
4946
}
5047

51-
$data = $this->propertyAccess->getValue($data, $propertyPath);
48+
$data = $this->propertyAccessor->getValue($data, $propertyPath);
5249
}
5350

5451
return $this->serializer->denormalize($data, $class, $format, $context);
@@ -57,19 +54,11 @@ public function denormalize($data, $class, $format = null, array $context = [])
5754
/**
5855
* {@inheritdoc}
5956
*/
60-
public function supportsDenormalization($data, $type, $format = null, array $context = [])
57+
public function supportsDenormalization($data, $type, string $format = null, array $context = [])
6158
{
6259
return \array_key_exists(self::UNWRAP_PATH, $context) && !isset($context['unwrapped']);
6360
}
6461

65-
/**
66-
* {@inheritdoc}
67-
*/
68-
public function setSerializer(SerializerInterface $serializer)
69-
{
70-
$this->serializer = $serializer;
71-
}
72-
7362
/**
7463
* {@inheritdoc}
7564
*/

0 commit comments

Comments
 (0)
0