File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -77,6 +77,31 @@ must be used instead (where ``XXX`` is the name of the related thing):
77
77
"replaceXXX", on the other hand, cannot add new elements. If an unrecognized
78
78
key is passed to "replaceXXX" it must throw an exception.
79
79
80
+ .. _contributing-code-conventions-conditions :
81
+
82
+ Conditions
83
+ ----------
84
+
85
+ Use `Yoda condition `_ when you need to check a variable against a value.
86
+ The main goal with this syntax is to avoid an accidental assignment inside the
87
+ condition statements:
88
+
89
+ instead of:
90
+
91
+ .. code-block :: php
92
+
93
+ if ($someVar === 'some string' && $otherVar === someFunction()) {
94
+ // ...
95
+ }
96
+
97
+ it should be:
98
+
99
+ .. code-block :: php
100
+
101
+ if ('some string' === $someVar && someFunction() === $otherVar) {
102
+ // ...
103
+ }
104
+
80
105
.. _contributing-code-conventions-deprecations :
81
106
82
107
Deprecations
@@ -104,3 +129,5 @@ the migration starting one or two minor versions before the version where the
104
129
feature will be removed (depending on the criticality of the removal)::
105
130
106
131
trigger_error('XXX() is deprecated since version 2.X and will be removed in 2.Y. Use XXX instead.', E_USER_DEPRECATED);
132
+
133
+ .. _`Yoda condition` : https://en.wikipedia.org/wiki/Yoda_conditions
You can’t perform that action at this time.
0 commit comments