4 ms·
I used to advocate for Yoda in PHP for the same reason that it's useful in C: if ($var = 1) ... will always evaluate true. But since you should be using =
by Arnor 13y ago
I used to advocate for Yoda in PHP for the same reason that it's useful in C:
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...