Skip to content

Commit b0055ed

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

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

contributing/code/conventions.rst

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,29 @@ 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-comparisons:
81+
82+
Comparisons
83+
-----------
84+
85+
Use `identical comparison`_ when the expected value must match a specific type:
86+
87+
instead of:
88+
89+
.. code-block:: php
90+
91+
if (1 == $integerExpected) {
92+
// ...
93+
}
94+
95+
it should be:
96+
97+
.. code-block:: php
98+
99+
if (1 === $integerExpected) {
100+
// ...
101+
}
102+
80103
.. _contributing-code-conventions-deprecations:
81104

82105
Deprecations
@@ -104,3 +127,5 @@ the migration starting one or two minor versions before the version where the
104127
feature will be removed (depending on the criticality of the removal)::
105128

106129
trigger_error('XXX() is deprecated since version 2.X and will be removed in 2.Y. Use XXX instead.', E_USER_DEPRECATED);
130+
131+
.. _`identical comparison`: https://php.net/manual/en/language.operators.comparison.php

0 commit comments

Comments
 (0)