Skip to content

Commit 844ac8e

Browse files
committed
[Contributing] [Conventions] Added entry for Yoda conditions
| Q | A | ------------- | --- | Doc fix? | yes | New docs? | no | Applies to | 2.8+ | Fixed tickets |
1 parent 59569c0 commit 844ac8e

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
@@ -100,6 +100,9 @@ Structure
100100

101101
* Place unary operators (``!``, ``--``, ...) adjacent to the affected variable;
102102

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

@@ -186,3 +189,4 @@ License
186189
.. _`PSR-1`: http://www.php-fig.org/psr/psr-1/
187190
.. _`PSR-2`: http://www.php-fig.org/psr/psr-2/
188191
.. _`PSR-4`: http://www.php-fig.org/psr/psr-4/
192+
.. _`Yoda conditions`: https://en.wikipedia.org/wiki/Yoda_conditions

0 commit comments

Comments
 (0)