Ive started coding for WordPress and the coding standards recommend using Yoda conditions.
if ( true == $the_force ) {
$victorious = you_will( $be );
}
But I also do some Android development, Javascript and have plans for robotics programming and some languages don’t like Yoda style.
Im planning NOT to use Yoda conditions for WP for the sake of consistency, I dont know if its going to cause any problems.
7
Coding standards are there to make it easy to visually parse the code. They are often different for each language, and rightly so.
If someone else is going to read this code, then keep to the WordPress conventions when programming for WordPress. If you are the only person who will read the code, then do what makes it easiest for you.
Personally, I wouldn’t bother trying to keep the coding conventions for all of your projects consistent. I would keep the coding conventions for your projects in a particular language consistent.
The primary reason for this is that it will make it easier to get used to switching between coding standards, as it is almost certain that the various projects you will work on during your career will not use identical styles.
Unless you are an extremely error-prone programmer with no code reviewers or automated linters to back you up, this particular choice is unlikely to be anything other than a stylistic preference with potentially minor benefits, so go right ahead.
It’s worth noting that coding styles shouldn’t necessarily be similar across languages. The most important rules in a coding style are generally motivated by how the language actually works (eg, in Javascript use === not ==), so they won’t apply to other languages. However, there are rules that can be sanely applied to multiple languages, and those are usually the “cosmetic” choices like indentation, brace style, or whether or not to use yoda conditions.