-
-
Notifications
You must be signed in to change notification settings - Fork 940
Description
API Platform version(s) affected: 4.2.3
Description
PR #7486 added ObjectMapperAwareInterface to ApiPlatform\State\ObjectMapper. However this interface doesn't exist yet in symfony/object-mapper version 7.3.*, it's only about to be introduced in the (as of now unreleased) version 7.4/8.0.
Note that the use of ObjectMapperAwareInterface in the instanceof check in the constructor that already existed before the PR is fine because PHP doesn't consider it an error to check for an interface that isn't defined. However adding the interface to the implements list does require the interface to actually exist.
Possible Solution
api-platform/state should probably provide its own version of ObjectMapperAwareInterface conditionally inheriting from object-mapper's interface only if it's available. ObjectMapper should then implement this interface.
And withObjectMapper shouldn't throw an exception if the decorated object mapper doesn't implement ObjectMapperAwareInterface, instead it should just silently skip the call to $this->decorated->withObjectMapper(). I don't think there's any harm in doing that even with object-mapper 7.4, as in this case the downstream ObjectMapper clearly doesn't expect to be passed down the outer decorator in the first place (eg. because it may not have any need to call into ObjectMapper recursively).