PHP & ZF2 / Comparison: expected == actual
coding-style, comparison, php, zend-framework2
Solution
What you are seeing is Yoda conditions. There is no standard defining these (at least not to my knowledge). They are merely a way to protect yourself against a common coding error (assignment in your conditions).
Example:
if( number = 4 ) // Works perfectly
if( 4 = number ) // Throws an exception
Problem
does anyone know why some developers (especially seen in the sources of Zend Framework 2) write the expected value before the actual value in comparisons? Example: ``` if (true === $actualValue) { ... } ``` instead of ``` if ($actualValue === true) { ... } ``` This case is not defined in the PSR coding standard. Note: There is a similar topic for c++ but without really helpful answers.