Re: Type hinting

From: Date: Fri, 28 May 2010 10:14:01 +0000
Subject: Re: Type hinting
References: 1 2 3 4 5 6 7 8  Groups: php.internals 
Request: Send a blank email to internals+get-48549@lists.php.net to get a copy of this message
Am 27.05.2010 12:59, schrieb Ilia Alshanetsky:
As far as your example goes consider a function that expects a boolean, but instead gets an int/string/float, which in nearly all cases will result in TRUE. Which is not the desired outcome.
Which is why, for instance, PHPUnit today is full of code like this public function foo($flag) {
       if (!is_bool($flag)) {
           throw new InvalidArgumentException(/* ... */);
       }
} This is the type of code that I want to get rid off using scalar type hints. -- Sebastian Bergmann Co-Founder and Principal Consultant http://sebastian-bergmann.de/ http://thePHP.cc/

« previous php.internals (#48549) next »