Skip to content

Commit 023a96f

Browse files
phansysweaverryan
authored andcommitted
[Contributing] [Conventions] Added entry for Yoda conditions
| Q | A | ------------- | --- | Doc fix? | yes | New docs? | no | Applies to | 2.8+ | Fixed tickets |
1 parent f8dcfdf commit 023a96f

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

contributing/code/standards.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@ Structure
102102

103103
* Always use `identical comparison`_ unless you need type juggling;
104104

105+
* Use `Yoda conditions`_ when checking a variable against an expression to avoid
106+
an accidental assignment inside the condition statement;
107+
105108
* Add a comma after each array item in a multi-line array, even after the
106109
last one;
107110

@@ -189,3 +192,4 @@ License
189192
.. _`PSR-2`: http://www.php-fig.org/psr/psr-2/
190193
.. _`PSR-4`: http://www.php-fig.org/psr/psr-4/
191194
.. _`identical comparison`: https://php.net/manual/en/language.operators.comparison.php
195+
.. _`Yoda conditions`: https://en.wikipedia.org/wiki/Yoda_conditions

0 commit comments

Comments
 (0)