Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 903a94a

Browse filesBrowse files
BafSfabpot
authored andcommitted
[Serializer] Save missing arguments in MissingConstructorArgumentsException
1 parent 75a52d0 commit 903a94a
Copy full SHA for 903a94a

File tree

3 files changed

+21
-1
lines changed
Filter options

3 files changed

+21
-1
lines changed

‎src/Symfony/Component/Serializer/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ CHANGELOG
88
* Add support for serializing empty array as object
99
* Return empty collections as `ArrayObject` from `Serializer::normalize()` when `PRESERVE_EMPTY_OBJECTS` is set
1010
* Add support for collecting type errors during denormalization
11+
* Add missing arguments in `MissingConstructorArgumentsException`
1112

1213
5.3
1314
---

‎src/Symfony/Component/Serializer/Exception/MissingConstructorArgumentsException.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Exception/MissingConstructorArgumentsException.php
+19Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,23 @@
1616
*/
1717
class MissingConstructorArgumentsException extends RuntimeException
1818
{
19+
/**
20+
* @var string[]
21+
*/
22+
private $missingArguments;
23+
24+
public function __construct(string $message, int $code = 0, \Throwable $previous = null, array $missingArguments = [])
25+
{
26+
$this->missingArguments = $missingArguments;
27+
28+
parent::__construct($message, $code, $previous);
29+
}
30+
31+
/**
32+
* @return string[]
33+
*/
34+
public function getMissingConstructorArguments(): array
35+
{
36+
return $this->missingArguments;
37+
}
1938
}

‎src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ protected function instantiateObject(array &$data, string $class, array &$contex
401401
$params[] = null;
402402
} else {
403403
if (!isset($context['not_normalizable_value_exceptions'])) {
404-
throw new MissingConstructorArgumentsException(sprintf('Cannot create an instance of "%s" from serialized data because its constructor requires parameter "%s" to be present.', $class, $constructorParameter->name));
404+
throw new MissingConstructorArgumentsException(sprintf('Cannot create an instance of "%s" from serialized data because its constructor requires parameter "%s" to be present.', $class, $constructorParameter->name), 0, null, [$constructorParameter->name]);
405405
}
406406

407407
$exception = NotNormalizableValueException::createForUnexpectedDataType(

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.