-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Serializer] Add COLLECT_EXTRA_ATTRIBUTES_ERRORS and full deserialization path #46654
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
base: 7.4
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,22 +16,51 @@ | |
*/ | ||
class PartialDenormalizationException extends UnexpectedValueException | ||
{ | ||
private $data; | ||
private $errors; | ||
private ?ExtraAttributesException $extraAttributesError = null; | ||
|
||
public function __construct($data, array $errors) | ||
public function __construct( | ||
private mixed $data, | ||
/** | ||
* @var NotNormalizableValueException[] | ||
*/ | ||
private array $notNormalizableErrors, | ||
array $extraAttributesErrors = [] | ||
) | ||
{ | ||
$this->data = $data; | ||
$this->errors = $errors; | ||
$this->notNormalizableErrors = $notNormalizableErrors; | ||
$extraAttributes = []; | ||
foreach ($extraAttributesErrors as $error) { | ||
$extraAttributes = \array_merge($extraAttributes, $error->getExtraAttributes()); | ||
} | ||
if ($extraAttributes) { | ||
$this->extraAttributesError = new ExtraAttributesException($extraAttributes); | ||
} | ||
} | ||
|
||
public function getData() | ||
{ | ||
return $this->data; | ||
} | ||
|
||
/** | ||
* @deprecated since Symfony 6.2, use getNotNormalizableValueErrors() instead. | ||
*/ | ||
public function getErrors(): array | ||
{ | ||
return $this->errors; | ||
return $this->getNotNormalizableValueErrors(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the method should throw a runtime deprecation There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well this was because it might be used. Should I completely remove it / throw an exception instead of deprecating it? |
||
} | ||
|
||
/** | ||
* @return NotNormalizableValueException[] | ||
*/ | ||
public function getNotNormalizableValueErrors(): array | ||
NorthBlue333 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
return $this->notNormalizableErrors; | ||
} | ||
|
||
public function getExtraAttributesError(): ?ExtraAttributesException | ||
{ | ||
return $this->extraAttributesError; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you update the
PropertyPathInterface
by adding a new@method
phpdoc attribute?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As this is a static method, I don't think it makes sense to add in in the PropertyPathInterface.