Skip to content

Commit

Permalink
Merge branch '5.4' into 6.4
Browse files Browse the repository at this point in the history
* 5.4:
  [DependencyInjection] Fix computing error messages involving service locators
  [Serializer] Fix unknown types normalization type when know type
  [ErrorHandler] Fix parsing messages that contain anonymous classes on PHP >= 8.3.3
  [Validator] Review Romanian (ro) translations
  [Console] Fix display of Table on Windows OS
  [FrameworkBundle] Fix config builder with extensions extended in `build()`
  [WebProfilerBundle] disable turbo in web profiler toolbar to avoid link prefetching
  explicitly cast boolean SSL stream options
  return the unchanged text if preg_replace_callback() fails
  the 'use_notify' option is on the factory, not on the postgres connection class
  review translations
  • Loading branch information
nicolas-grekas committed Feb 22, 2024
2 parents 51a06ee + 05137a5 commit 88da7f8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
8 changes: 7 additions & 1 deletion Normalizer/AbstractNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -399,10 +399,16 @@ protected function instantiateObject(array &$data, string $class, array &$contex
continue;
}

$constructorParameterType = 'unknown';
$reflectionType = $constructorParameter->getType();
if ($reflectionType instanceof \ReflectionNamedType) {
$constructorParameterType = $reflectionType->getName();
}

$exception = NotNormalizableValueException::createForUnexpectedDataType(
sprintf('Failed to create object because the class misses the "%s" property.', $constructorParameter->name),
$data,
['unknown'],
[$constructorParameterType],
$attributeContext['deserialization_path'] ?? null,
true
);
Expand Down
6 changes: 3 additions & 3 deletions Tests/SerializerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1309,7 +1309,7 @@ public function testCollectDenormalizationErrorsWithConstructor(?ClassMetadataFa
[
'currentType' => 'array',
'expectedTypes' => [
'unknown',
'string',
],
'path' => 'string',
'useMessageForUser' => true,
Expand All @@ -1318,7 +1318,7 @@ public function testCollectDenormalizationErrorsWithConstructor(?ClassMetadataFa
[
'currentType' => 'array',
'expectedTypes' => [
'unknown',
'int',
],
'path' => 'int',
'useMessageForUser' => true,
Expand Down Expand Up @@ -1627,7 +1627,7 @@ public function testPartialDenormalizationWithMissingConstructorTypes()
[
'currentType' => 'array',
'expectedTypes' => [
'unknown',
'string',
],
'path' => 'two',
'useMessageForUser' => true,
Expand Down

0 comments on commit 88da7f8

Please sign in to comment.