Skip to content

Commit e1bcab0

Browse files
committed
Moved Yoda condition doc from conventions to standards.
1 parent 8eaf033 commit e1bcab0

File tree

2 files changed

+26
-27
lines changed

2 files changed

+26
-27
lines changed

contributing/code/conventions.rst

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -77,31 +77,6 @@ must be used instead (where ``XXX`` is the name of the related thing):
7777
"replaceXXX", on the other hand, cannot add new elements. If an unrecognized
7878
key is passed to "replaceXXX" it must throw an exception.
7979

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-
10580
.. _contributing-code-conventions-deprecations:
10681

10782
Deprecations
@@ -129,5 +104,3 @@ the migration starting one or two minor versions before the version where the
129104
feature will be removed (depending on the criticality of the removal)::
130105

131106
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

contributing/code/standards.rst

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,31 @@ Service Naming Conventions
167167

168168
* A group name uses the underscore notation.
169169

170+
.. _contributing-code-standards-conditions:
171+
172+
Conditions
173+
----------
174+
175+
Use `Yoda condition`_ when you need to check a variable against a value.
176+
The main goal with this syntax is to avoid an accidental assignment inside the
177+
condition statements:
178+
179+
instead of:
180+
181+
.. code-block:: php
182+
183+
if ($someVar === 'some string' && $otherVar === someFunction()) {
184+
// ...
185+
}
186+
187+
it should be:
188+
189+
.. code-block:: php
190+
191+
if ('some string' === $someVar && someFunction() === $otherVar) {
192+
// ...
193+
}
194+
170195
Documentation
171196
-------------
172197

@@ -186,3 +211,4 @@ License
186211
.. _`PSR-1`: http://www.php-fig.org/psr/psr-1/
187212
.. _`PSR-2`: http://www.php-fig.org/psr/psr-2/
188213
.. _`PSR-4`: http://www.php-fig.org/psr/psr-4/
214+
.. _`Yoda condition`: https://en.wikipedia.org/wiki/Yoda_conditions

0 commit comments

Comments
 (0)