Setting up a NoSuchPropertyException in Symfony Serializer

时间:2015-07-28 15:38:58

标签: php json symfony serialization

When deserializing json to objects I want an exception thrown if a property exists in the json but not in the class I deserialize to.

In Symfony\Component\Serializer\Normalizer\ObjectNormalizer.php

there is only

if ($allowed && !$ignored) {
            try {
                $this->propertyAccessor->setValue($object, $attribute, $value);
            } catch (NoSuchPropertyException $exception) {
                // Properties not found are ignored
            }
}

How to override or circumvene that?

1 个答案:

答案 0 :(得分:0)

Ok, got it. I copied the class over to my own code and implemented the exception at the mentioned location.

It's not really update safe, but I guess it is all what I can get.

Thanks anybody who thought about the question.