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

[Serializer] Save missing arguments in MissingConstructorArgumentsException #42712

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions 1 src/Symfony/Component/Serializer/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ CHANGELOG
* Add support for serializing empty array as object
* Return empty collections as `ArrayObject` from `Serializer::normalize()` when `PRESERVE_EMPTY_OBJECTS` is set
* Add support for collecting type errors during denormalization
* Add missing arguments in `MissingConstructorArgumentsException`

5.3
---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,23 @@
*/
class MissingConstructorArgumentsException extends RuntimeException
{
/**
* @var string[]
*/
private $missingArguments;

public function __construct(string $message, int $code = 0, \Throwable $previous = null, array $missingArguments = [])
{
$this->missingArguments = $missingArguments;

parent::__construct($message, $code, $previous);
}

/**
* @return string[]
*/
public function getMissingConstructorArguments(): array
{
return $this->missingArguments;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ protected function instantiateObject(array &$data, string $class, array &$contex
$params[] = null;
} else {
if (!isset($context['not_normalizable_value_exceptions'])) {
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));
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]);
}

$exception = NotNormalizableValueException::createForUnexpectedDataType(
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.