Re: [VOTE] Scalar Type Hints
| From: | Rasmus Lerdorf | Date: | Sun, 08 Feb 2015 03:52:30 +0000 |
| Subject: | Re: [VOTE] Scalar Type Hints | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-82111@lists.php.net to get a copy of this message | ||
On 02/07/2015 09:51 PM, Andrea Faulds wrote:
>> tan(1);
>> echo strstr("test", "est", 1);
>
> Banning int->float and float->int is both a pain point and sometimes a life-saver. It’s
> annoying that tan(1) doesn’t work. On the other hand, you discover if your ints floats would be
> silently truncated (as I did with PictoSwap).
>
> I wouldn’t say that int->string not working is a problem, though. Seeing something like
> strstr(“test”, “est”, 1); is rather confusing. Looking at it, I’d think the third
> parameter is some sort of number for you to want to pass an integer to it. If I want a string,
> I’ll use one.
This isn't int->string. This is int->boolean. The 3rd arg to strstr() is
a boolean and passing 1 instead of true makes it blow up. It is very
very common for people to pass 0 or 1 in place of true/false to all
sorts of things in PHP.
> Yes, the RFC is somewhat inaccurate in that respect. It is per-file in one sense (like
> encoding, but unlike ticks, it has no effect on the including or included files). However, it
> technically affects the remainder of the file, not the whole file.
Well, no, not the remainder of the file either since it can be switched
again. It only affects the part of the file between declares if there is
a second one.
-Rasmus
Attachment: [application/pgp-signature] OpenPGP digital signature signature.asc
Attachment: [application/pgp-signature] OpenPGP digital signature signature.asc