Current situation
Entity::isEmpty is deprecated (because Entity is). isEmpty is not part of any other interface implemented by our concrete entities (ie Item and Property), most notably EntityDocument.
We have code that is using the isEmpty method while getting an Entity or EntityDocument. That code either uses a deprecated method or one that is not guaranteed to be there. This is currently dealt with by ignoring the deprecation, ignoring the call to the method that is not guaranteed to be there, or by adding a method_exists( $entity, 'isEmpty' ) check.
There are only a handful places where the isEmpty check is needed on an entity of unknown type. (One example is here, though its not clear the problem will need to be solved there when the OCP violations in that code are fixed.)
Possible ways to improve
- Use method_exists checks everywhere (not so clean)
- Add isEmpty to EntityDocument (>99% of the users of the interface do not need the method)
- Create a new CheckableForEmptiness interface (is having an instanceof check sufficiently better than the method_exists?)
- Create a new CheckableForEmptinessEntity interface (will still need instanceof check)