Skip to content

Commit

Permalink
Merge branch '3.4' into 4.4
Browse files Browse the repository at this point in the history
* 3.4:
  [PropertyAccess] fix tests
  [WebProfilerBundle] fix test
  remove assertions that can never be reached
  [PropertyAccess] Improve message of unitialized property in php 7.4
  [HttpFoundation] Fixed session migration with custom cookie lifetime
  [Serializer] Remove unused variable
  Allow URL-encoded special characters in basic auth part of URLs
  [Serializer] Fix unitialized properties (from PHP 7.4.2) when serializing context for the cache key
  [Validator] Add missing Ukrainian and Russian translations
  No need to reconnect the bags to the session
  Support for Content Security Policy style-src-elem and script-src-elem in WebProfiler
  [PropertyInfo][ReflectionExtractor] Check the array mutator prefixes last when the property is singular
  • Loading branch information
nicolas-grekas committed Apr 6, 2020
2 parents 2a508a5 + 8e02b98 commit b1098f8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Normalizer/AbstractObjectNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ private function validateAndDenormalize(string $currentClass, string $attribute,
*/
protected function denormalizeParameter(\ReflectionClass $class, \ReflectionParameter $parameter, $parameterName, $parameterData, array $context, $format = null)
{
if (null === $this->propertyTypeExtractor || null === $types = $this->propertyTypeExtractor->getTypes($class->getName(), $parameterName)) {
if (null === $this->propertyTypeExtractor || null === $this->propertyTypeExtractor->getTypes($class->getName(), $parameterName)) {
return parent::denormalizeParameter($class, $parameter, $parameterName, $parameterData, $context, $format);
}

Expand Down Expand Up @@ -617,6 +617,7 @@ private function getCacheKey(?string $format, array $context)
unset($context[$key]);
}
unset($context[self::EXCLUDE_FROM_CACHE_KEY]);
unset($context[self::OBJECT_TO_POPULATE]);
unset($context['cache_key']); // avoid artificially different keys

try {
Expand Down
20 changes: 20 additions & 0 deletions Tests/Normalizer/AbstractObjectNormalizerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,14 @@ public function testDenormalizeStringCollectionDecodedFromXmlWithTwoChildren()
$this->assertEquals('bar', $stringCollection->children[1]);
}

public function testDenormalizeNotSerializableObjectToPopulate()
{
$normalizer = new AbstractObjectNormalizerDummy();
$normalizedData = $normalizer->denormalize(['foo' => 'foo'], Dummy::class, null, [AbstractObjectNormalizer::OBJECT_TO_POPULATE => new NotSerializable()]);

$this->assertSame('foo', $normalizedData->foo);
}

private function getDenormalizerForStringCollection()
{
$extractor = $this->getMockBuilder(PhpDocExtractor::class)->getMock();
Expand Down Expand Up @@ -448,3 +456,15 @@ public function setSerializer(SerializerInterface $serializer)
$this->serializer = $serializer;
}
}

class NotSerializable
{
public function __sleep()
{
if (class_exists(\Error::class)) {
throw new \Error('not serializable');
}

throw new \Exception('not serializable');
}
}

0 comments on commit b1098f8

Please sign in to comment.