Skip to content

Commit

Permalink
[Serializer] Fix type for missing property
Browse files Browse the repository at this point in the history
  • Loading branch information
ElisDN committed May 13, 2024
1 parent 9186522 commit e68b236
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Normalizer/AbstractNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ protected function instantiateObject(array &$data, string $class, array &$contex

$exception = NotNormalizableValueException::createForUnexpectedDataType(
sprintf('Failed to create object because the class misses the "%s" property.', $constructorParameter->name),
$data,
null,
[$constructorParameterType],
$context['deserialization_path'],
true
Expand Down
10 changes: 5 additions & 5 deletions Tests/SerializerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1045,7 +1045,7 @@ public function testCollectDenormalizationErrors(?ClassMetadataFactory $classMet
'message' => 'The type of the "string" attribute for class "Symfony\Component\Serializer\Tests\Fixtures\Php74Full" must be one of "string" ("null" given).',
],
[
'currentType' => 'array',
'currentType' => 'null',
'expectedTypes' => [
'unknown',
],
Expand Down Expand Up @@ -1306,7 +1306,7 @@ public function testCollectDenormalizationErrorsWithConstructor(?ClassMetadataFa
'message' => 'The type of the "bool" attribute for class "Symfony\\Component\\Serializer\\Tests\\Fixtures\\Php80WithPromotedTypedConstructor" must be one of "bool" ("string" given).',
],
[
'currentType' => 'array',
'currentType' => 'null',
'expectedTypes' => [
'string',
],
Expand All @@ -1315,7 +1315,7 @@ public function testCollectDenormalizationErrorsWithConstructor(?ClassMetadataFa
'message' => 'Failed to create object because the class misses the "string" property.',
],
[
'currentType' => 'array',
'currentType' => 'null',
'expectedTypes' => [
'int',
],
Expand Down Expand Up @@ -1420,7 +1420,7 @@ public function testCollectDenormalizationErrorsWithEnumConstructor()

$expected = [
[
'currentType' => 'array',
'currentType' => 'null',
'useMessageForUser' => true,
'message' => 'Failed to create object because the class misses the "get" property.',
],
Expand Down Expand Up @@ -1546,7 +1546,7 @@ public function testPartialDenormalizationWithMissingConstructorTypes()

$expected = [
[
'currentType' => 'array',
'currentType' => 'null',
'expectedTypes' => [
'string',
],
Expand Down

0 comments on commit e68b236

Please sign in to comment.