Hi Thomas,
On 16 March 2015 at 20:51, Thomas Punt <[email protected]> wrote:
>
>> No, your example would blow up regardless of the caller being in strict mode
>> or weak mode.
>
> That was the point in my hypothetical example - the library can decide
> what mode it wants the user to use (strict or weak) if it wants to.
Sticking with that as a theory...
function foo ($i) {
if(!is_int($i)) {
throw ToysOutOfPramException('I need an integer!');
}
}
We can already do this. Indeed, we do do this. Yes, it *might* be seen
as a dick move employing any sort of trick to push strict type hints
specifically, but being explicit is quite acceptable. I have code
stuffed full of those gems and deployed === checks. So while I
appreciate it looks bad, it's nothing all that new to find people
taking steps to enforce a strict view of acceptable values. There's a
reason why type hints, in some form, have support from the community.
Paddy
--
Pádraic Brady
http://blog.astrumfutura.com
http://www.survivethedeepend.com
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php