-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[Serializer] Throw NotNormalizableException instead of InvalidArgumentException in ArrayDenormalizer #46652
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
Closed
NorthBlue333
wants to merge
1
commit into
symfony:6.2
from
NorthBlue333:fix/array_denormalizer_exceptions_ticket_46649
Closed
[Serializer] Throw NotNormalizableException instead of InvalidArgumentException in ArrayDenormalizer #46652
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[Serializer] Throw NotNormalizableException instead of InvalidArgumen…
…tException in ArrayDenormalizer
- Loading branch information
commit d549f5507ab0f1cd2d46e8124bd4ff11bb673763
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ | |
use Symfony\Component\Serializer\Exception\LogicException; | ||
use Symfony\Component\Serializer\Exception\RuntimeException; | ||
use Symfony\Component\Serializer\Exception\UnexpectedValueException; | ||
use Symfony\Component\Serializer\Exception\NotNormalizableValueException; | ||
|
||
/** | ||
* @author Jordi Boggiano <[email protected]> | ||
|
@@ -36,13 +37,14 @@ interface DenormalizerInterface | |
* | ||
* @return mixed | ||
* | ||
* @throws BadMethodCallException Occurs when the normalizer is not called in an expected context | ||
* @throws InvalidArgumentException Occurs when the arguments are not coherent or not supported | ||
* @throws UnexpectedValueException Occurs when the item cannot be hydrated with the given data | ||
* @throws ExtraAttributesException Occurs when the item doesn't have attribute to receive given data | ||
* @throws LogicException Occurs when the normalizer is not supposed to denormalize | ||
* @throws RuntimeException Occurs if the class cannot be instantiated | ||
* @throws ExceptionInterface Occurs for all the other cases of errors | ||
* @throws BadMethodCallException Occurs when the normalizer is not called in an expected context | ||
* @throws InvalidArgumentException Occurs when the arguments are not coherent or not supported | ||
* @throws UnexpectedValueException Occurs when the item cannot be hydrated with the given data | ||
* @throws NotNormalizableValueException Occurs when the item cannot be hydrated with the given data and the error can be collected | ||
* @throws ExtraAttributesException Occurs when the item doesn't have attribute to receive given data | ||
* @throws LogicException Occurs when the normalizer is not supposed to denormalize | ||
* @throws RuntimeException Occurs if the class cannot be instantiated | ||
* @throws ExceptionInterface Occurs for all the other cases of errors | ||
*/ | ||
public function denormalize(mixed $data, string $type, string $format = null, array $context = []); | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Why inverting the order with the check on the type? Calling
is_array()
is cheaper than callingstr_ends_with()
, so it should be done first (especially because this method is ok the hot path and can be called hundreds of times).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.
@NorthBlue333 Can you answer this question please?
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.
Indeed, IHMO, there is no need to change the order of checks there.
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.
Hi, sorry did not have much time for those PRs. I will take a look during the end of the week.