We are developing a collection class for a specialized PHP application. In it, there are functions named map
, each
, etc.
A debate has been brought up about calling some functions with a bad argument. For example:
public function each($fn) {
// ...
}
// ...
$collection->each('not a function');
Should the call to each
throw an exception? Should it return null
? Should we ignore the bad argument and let the runtime error when an attempt is made to call the nonexistant function? I'm not sure how we should handle this case.