Skip to content

[Serializer] Getter for extra attributes in ExtraAttributesException #24277

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
wants to merge 4 commits into from
Closed
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 src/Symfony/Component/Serializer/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ CHANGELOG
* added `AbstractObjectNormalizer::DISABLE_TYPE_ENFORCEMENT` context option
to disable throwing an `UnexpectedValueException` on a type mismatch
* added support for serializing `DateInterval` objects
* added getter for extra attributes in `ExtraAttributesException`

3.3.0
-----
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,24 @@
*/
class ExtraAttributesException extends RuntimeException
{
private $extraAttributes;

public function __construct(array $extraAttributes, \Exception $previous = null)
{
$msg = sprintf('Extra attributes are not allowed ("%s" are unknown).', implode('", "', $extraAttributes));

$this->extraAttributes = $extraAttributes;

parent::__construct($msg, 0, $previous);
}

/**
* Get the extra attributes that are not allowed.
*
* @return array
*/
public function getExtraAttributes()
{
return $this->extraAttributes;
}
}