Suppose an object has this method
public function __construct($path, $callable)
And, I want the $callable a closure or invokable object.
Should I just validate it like this : if(!method_exists($callable, '__invoke')
?
Or using double check : if (!is_object($callable) || !method_exists($callable, '__invoke'))
?
In my thought, one has a method so it must be an object (no need to check whether it’s object or not)
But, sometimes I see developers use the second approach.
P.S. I know that I can use type hinting, but I want my app support PHP 5.3