File tree Expand file tree Collapse file tree
src/JMS/Serializer/Metadata Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -268,20 +268,22 @@ public function unserialize($str)
268268
269269 private function handleDiscriminatorProperty ()
270270 {
271- if (
272- $ this ->discriminatorMap
273- && !$ this ->reflection ->isAbstract ()
274- && !$ this ->reflection ->isInterface ()
275- ) {
276- if (
277- false === ($ typeValue = array_search ($ this ->name , $ this ->discriminatorMap , true ))
278- && $ this ->discriminatorBaseClass !== $ this ->name
279- ) {
280- throw new \LogicException (sprintf (
281- 'The sub-class "%s" is not listed in the discriminator of the base class "%s". ' ,
282- $ this ->name ,
283- $ this ->discriminatorBaseClass
284- ));
271+ if ($ this ->discriminatorMap && !$ this ->reflection ->isAbstract () && !$ this ->reflection ->isInterface ()) {
272+ if (false === $ typeValue = array_search ($ this ->name , $ this ->discriminatorMap , true )) {
273+ if ($ this ->discriminatorBaseClass === $ this ->name ) {
274+ @trigger_error (
275+ 'Discriminator map was configured on non-abstract parent class but parent class '
276+ .' was not included into discriminator map. It will throw exception in next major version. '
277+ .' Either declare parent as abstract class or add it into discriminator map. ' ,
278+ E_USER_DEPRECATED
279+ );
280+ } else {
281+ throw new \LogicException (sprintf (
282+ 'The sub-class "%s" is not listed in the discriminator of the base class "%s". ' ,
283+ $ this ->name ,
284+ $ this ->discriminatorBaseClass
285+ ));
286+ }
285287 }
286288
287289 $ this ->discriminatorValue = $ typeValue ;
You can’t perform that action at this time.
0 commit comments