Hi Leigh,
> On 14 Jan 2015, at 09:17, Leigh <[email protected]> wrote:
>
> I really don't like this behaviour being changed at the call site. If
> I design a function that I _know_ should only take a string, then I
> want it to be an error if the user supplies anything else, so that
> they know they messed up.
I don’t like the idea of being forced to use strict (or weak) type checking because the API author
decided as much.
More importantly, having the function and not its caller decide makes the addition of type hints to
existing code difficult, because it will (possibly unintentionally) rely on PHP’s weak typing and
thus error when faced with a strict type check. On the other hand, having the callee decide means
that you can relatively safely add type hints to existing code and its consumers will not error. You
can then gradually migrate that consuming code over to strict type-checking, if you so wish.
> Also, there's this, that you might be able to re-purpose.
> https://github.com/php/php-src/blob/d5dd29/Zend/zend_compile.c#L7199
I don’t want to get rid of that easter egg, and I prefer the declare() syntax since it’s more
obviously some sort of directive (use strict; looks like an innocuous use statement) and supports
the block syntax.
--
Andrea Faulds
http://ajf.me/