r/lolphp • u/i_make_snow_flakes • Nov 15 '14
new safe casting function RFC. casting "-10" to string is valid but casting "+10" is not..
here the comment where one user asked the author of RFC about this. I am not able to follow his reasoning. What do you think?
22
Upvotes
View all comments
Show parent comment
8
u/[deleted] Nov 15 '14
So you agree that its explicitly a positive number, but you'll treat it as a string. Smart.
Loosely typed languages are all about supporting redundencies though. PHP supports all kinds of crap, e.g 0 == false. The fact that you're not treating +100 as being a number is not only mathematically incorrect, it also breaks PHP's own shitty conventions, as well as the principle of least surprise.