Re: Make strict mode more strict?
| From: | François Laupretre | Date: | Wed, 16 Sep 2015 23:14:05 +0000 |
| Subject: | Re: Make strict mode more strict? | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-88271@lists.php.net to get a copy of this message | ||
Hi Yasuo,
Le 17/09/2015 00:10, Yasuo Ohgaki a écrit :
Hi all, Assigning different type to already initialized variable is a bug most likely. There may be cases that variable should have several types, e.g. return INT for success and FALSE for failure, but programmers can use different variable or return value directly or make BOOL/NULL exception.While I don't like the idea of 'auto-typing' a variable (assign it an immutable type depending on the first assignment), the idea is quite similar to one I proposed when we were discussing scalar type hinting : the possibility to assign a type hint to every variable/property. In order to be really usable, it requires compound types but that's a detail because, anyway, we will need compound types. The problem is that, AFAIK, it implies a mechanism to attach an optional type hint to a zval, and check it each time a value is assigned. While this would be extremely powerful and could dramatically change the way PHP types are considered and handled, this is a huge and complex work, especially in terms of performance. IMO, this may be an idea for 8.0, not before. Anyway, I may be wrong, if you see a simpler way to implement your concept, I'm interested. Regards François