Skip to content

Commit fefbdcd

Browse files
mdeboerogizanagi
authored andcommitted
[Serializer] Getter for extra attributes in ExtraAttributesException
1 parent 5699d40 commit fefbdcd

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ CHANGELOG
77
* added `AbstractObjectNormalizer::DISABLE_TYPE_ENFORCEMENT` context option
88
to disable throwing an `UnexpectedValueException` on a type mismatch
99
* added support for serializing `DateInterval` objects
10+
* added getter for extra attributes in `ExtraAttributesException`
1011

1112
3.3.0
1213
-----

Exception/ExtraAttributesException.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,24 @@
1818
*/
1919
class ExtraAttributesException extends RuntimeException
2020
{
21+
private $extraAttributes;
22+
2123
public function __construct(array $extraAttributes, \Exception $previous = null)
2224
{
2325
$msg = sprintf('Extra attributes are not allowed ("%s" are unknown).', implode('", "', $extraAttributes));
2426

27+
$this->extraAttributes = $extraAttributes;
28+
2529
parent::__construct($msg, 0, $previous);
2630
}
31+
32+
/**
33+
* Get the extra attributes that are not allowed.
34+
*
35+
* @return array
36+
*/
37+
public function getExtraAttributes()
38+
{
39+
return $this->extraAttributes;
40+
}
2741
}

0 commit comments

Comments
 (0)