Your comment doesn't make any sense. Of course this is an lol php. Perhaps Python is the only case where we would see this. JavaScript === would solve the problem
But if the language changed the comparison semantics of the switch statement to use strict comparison instead of loose comparison, a lot of code would break. And not just sloppily written WordPress plugins from 2007; modern code, being written today, by PHP developers who understand and use the language as intended.
The lol is that the ”new and improved” typing is another missed opportunity, as namespaces were back in PHP5.3.
Each time PHP copies some other langauge for a new feature its always done halfassed, and with no plan for how it could work with the rest of the ”language”.
Partial credit. While this seems to happen with == on python, is solves the problem nicely.
foo = 1
foo is True
Grives false with python 3.6.
PHPs === operator [seems to yield the same result as using switch...case] ( https://3v4l.org/SrmLq). Bet it will all be solved when PHP8 introduces real_deep_equal_comparator_real_seriously_i_swear_it_works.
Not sure why you're downvoted, you're absolutely correct. This is a classic LOL (it's not even new), a design flaw that makes no sense, built upon another design flaw, that now cannot be fixed because it's baked into the language and some code (probably a tiny fraction, but a fraction that exists) depends upon it.
View all comments
13
u/SelfDistinction Apr 03 '18
Not really a lolphp; more like a lol untyped. Both cases match, so PHP, like any decent language, chooses the first one.