php type checking for method parameters - is it worth it?

Viewed 5316

I'm wondering what you think the best practice is here-- does it buy you very much to type-check parameters in PHP? I.e have you actually seen noticeably fewer bugs on projects where you've implemented parameter type-checking vs. those that don't? I'm thinking about stuff like this:

public function __construct($screenName, $createdAt) {  
        if (!is_string($screenName) || !is_string($createdAt) {
            return FALSE;
        }
}
4 Answers
Related