In your examples I am not seeing the issue? Am I missing something here? Your examples work exactly as I would have expected them to, as they would in other similar languages like Java and C++. Lets stop the hate for the sake of hating PHP, it definitely has its quirks in relation to methods and order of parameters in particular, but things are getting better and they're not deal-breakers for getting things done.
If you want to see how great things are in PHP, I would checkout the Laravel PHP framework. It is a very well built and robust framework that uses the best parts of PHP and abstracts some of the worse parts to make the experience of developing in PHP fun again.
PHP and JavaScript, however, have unjustifiable quirks with some of their most basic functionality. We're talking about stuff as basic as their comparison operators being quite broken, for example. That's where the problem is. Furthermore, the fact that these issues have been around for well over a decade or more without being properly addressed just makes the situation even worse.
Compared to other mainstream languages like C, C++, Java, C#, Python, Ruby and even Perl, both PHP and JavaScript are quite inferior in many critical ways. Perhaps things will improve over time, but we really haven't seen that happen so far.
So let's not pretend that they're "good" just to be politically correct or to try to avoid offending anyone. PHP and JavaScript aren't good languages, and they won't really improve until their communities admit that there are some very serious issues, and then commit to getting them resolved properly and rapidly.
It is a very weird argument that often comes up when discussing programming languages - "Lang X is weird/stupid in some ways, but no language is perfect, so it's fine and there is no reason to call it out."
So, because nothing is perfect (almost by definition), it apparently isn't a big deal that some things are weird/dumb/broken. And let's also just muddy the waters by implying that, since all languages have imperfections, talking about some other language's imperfections is just being pointlessly selective (even though one of the languages imperfections are much more horrible).
It's just overall a non-argument. Maybe the point is to come off as being "above" the opposite camp (which are: mindless language bashers). But it's about as intellectually stimulating as mindless language bashing: it doesn't take much intellectual curiosity or rigour to bash a language, and neither does being perfectly neutral and non-offensive by throwing around platitudes like "no language is perfect", "choose the right tool for the job", etc.
Agreed. These are just a few quirks in PHP I find amusing.
Last I checked, it wasn't quite as good as wtfjs, but it looks like quite a few new surprises have been added rather recently.
Edit: Correction, there's only one new entry as of this year, which is a shame. :)
The other thing to consider (looking at it again, particularly at the second example) is that there are some surprising side effects that can snag newcomers, depending on their background and whatever other languages they know.
Perhaps one of the drawbacks with programming PHP is that you become so desensitized to weirdly inconsistent/surprising behavior that there's almost nothing left to be surprised about.
Most other entries involve doing something bizarre with obviously undefined consequences and then marveling that PHP does it different than they expect. Or failing to understand PHP's basic rules and then again, on edge cases, marveling at weirdness of the perfectly logical result.
The "PHP protected and an assault" entry just fails to comprehend how access modifiers actually work with the classes.
There are real PHP WTF's but honestly they were all discovered 10 years ago. Probably 50% of all entries on the site are people misunderstanding how references work over and over and over.
On the other hand, had you written "perfectly logical result (within the confines of PHP's idea of what's logical)," then I might be inclined to agree.
But yes, I made the mistake of linking the site without re-examining it. I recall seeing it first from HN some time ago (probably 2010ish) and thought it might have improved. I do believe I may have indicated its quality isn't on par with wtfjs.org, however. Take it as you will.
We don't actually pass objects to reference in PHP, we pass them by "object reference." But don't worry, you can still null objects that get passed to you:
Sure it's not as bad as it used to be. Yes, a disciplined developer can make good software with it, but it's still a pretty quirky.