Re: STH and the 3 RFCs
| From: | Pádraic Brady | Date: | Mon, 16 Mar 2015 22:01:52 +0000 |
| Subject: | Re: STH and the 3 RFCs | ||
| References: | 1 2 3 4 5 6 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-85096@lists.php.net to get a copy of this message | ||
Hi Thomas,
On 16 March 2015 at 20:51, Thomas Punt <tpunt@hotmail.co.uk> 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