nullable interface

Posted by BlackScorp 8 months ago

Hello Fellow PHP Developers, since we have Countable interface where we can call count($instance) i would like to have a Nullable interface so i will get true for is_null($instance). With this interface i can implement Null Object Pattern. Here an example ```php class NullObject implements Nullable{} $object = new NullObject(); if(is_null($object)){ //do nothing with it } ``` There are some cases where i actually want to check if my object is a null object and for now i have to do it with instanceof. Or maybe this is a terrible idea? let me know
BlackScorp ยท 8 months ago