Hi Pavel, > On 15 Jan 2015, at 15:25, Pavel Kouřil <pajou...@gmail.com> wrote: > > On Thu, Jan 15, 2015 at 4:11 PM, Jordi Boggiano <j.boggi...@seld.be> wrote: >> >> Reading the thread at this point shows so much confusion, it seems half the >> people reading the spec misunderstood that the declare() line affects >> function calls only and not the API/implementation level. > > Yeah, while the confusion is definitely still there, I would > personally argue that definitely some people who oppose the declare() > get that it's only for calls in the file - and still don't find it > clever. > > The potential issues with this are pretty real, to be honest. Simple > things like moving a method from one class to another (let's say to > parent or descendant) and getting to another typing context may cause > unpredictable behavior if the user forgets to have declare() in both > files.
This is true, you would sometimes have problems if you’re mixing the strict and weak type checking modes in your codebase. The intention is that you’d use one or the other exclusively, perhaps with some minor exceptions as and where necessary. The fact it’s weak by default means you could add scalar type hints gradually without breaking things, because the weak mode is quite permissive. Then, if you wanted to, you could gradually migrate each file in your codebase over to strict mode. Essentially, you get “gradual typing” like Hack, but without Hack’s approach which I don’t particularly like. Hack’s approach is to simply not enforce type hints if they’re a problem. On the other hand, this RFC would alway enforces them, but the weak mode is less strict. So, I anticipate that while it would cause problems during a transition, I think codebases would end up using one mode or the other exclusively and wouldn’t have problems once they had done so. Thanks. -- Andrea Faulds http://ajf.me/ -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php