Sadly, I've seen them in other languages that don't have the same problem, because people have picked up the habit without really understanding why and where it should be used.
The rationale is that they make it a compiler error if you accidentally perform an assignment operation ("xyz" = $name) instead of a comparison ("xyz" === $name). The thing is, this is only a significant risk if you adopt the bad habit of performing assignment operations within conditional statements, like this:
if (null !== ($charset = $env->getCharset())) {
The above style has been popularised in PHP by the Symfony project. I think it's hideous, and that the idea of adopting one ugly style choice (Yoda Expressions) to mitigate the risk introduced by another ugly style choice (assignment in conditional operations) is reminiscent of the children's song about the old lady who swallowed a fly. if ($var = 1) ...
will always evaluate true.But since you should be using === in this context, there's really no excuse for using a single...
if ($var === 1) ...
Also, can PHP devs please do me the favor of splitting if (null !== ($charset = $env->getCharset())) {
into two lines: $charset = $env->getCharset();
if ($charset !== null) {
...
Isn't that prettier? The line that the first one saves doesn't really make anyone's life easier...