On 16 Jul 2014, at 22:10, Zeev Suraski <z...@zend.com> wrote: > Stricter typing does not belong in PHP. If it did, we'd have it in > internal functions, implicit casting and the rest of the language in > general. We don’t.
This proposal isn’t that much stricter than zpp, aside from booleans I suppose. It’s not like we allow literally anything as function arguments for internal functions. > And I insist that much like you said people can catch E_RECOVERABLE_ERROR > and turn ignore it, they can do the same with E_CASE - except now they > won't *have* to learn about this new behavior unless they explicitly want > to. While you think it may not be strict enough for some people, and I > think it'd be too strict for others - the consistency argument should make > the decision between the two obvious. E_CAST is problematic. Having something we encourage some people to make an error and some people not to means that in some cases your library works fine and rosy in other people’s environments and sometimes it crashes your app. This is *not good*. We must not encourage people to make things errors conditionally. It’s either an error or not. I’d veer towards error. Also, it’s worth pointing out that people will have to learn the new behaviour anyway; no matter how we do scalar type hints, we don’t currently have them, and once implemented, everyone will have to get used to their existence (and probably the fact they will raise E_RECOVERABLE_ERROR). > Also, I tend to agree with Stas that we can consider to do > E_RECOVERABLE_ERROR on the obviously 'bogus' conversions - like array or > object to int. But E_RECOVERABLE_ERROR on simple data loss is radically > inconsistent with the rest of PHP. > > Sorry, I introduced hinting into PHP; I intentionally did not add typing > for scalars as it goes against the fundamentals of the language, and I > fought this off back in 2008, 2010 and mildly also in 2012. Call me > persistent :) > > FWIW, I think the distance between where you and I stand is not that big - > and if we go in the direction of E_CAST for data loss across the board > (any implicit casts, not just in type hints), and E_RECOVERABLE_ERROR for > completely broken type conversions - this is a big win for PHP, beyond > just type hints. I really don’t like E_CAST for the reasons mentioned above. If it’s a glorified E_NOTICE, it’s pointless, if it’s a glorified E_RECOVERABLE_ERROR, you gain nothing, and if it’s an error in some environments and not in others, we’ve just completely broken our ecosystem. -- Andrea Faulds http://ajf.me/ -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php