From b0055ede3cd836525359ecebe04c392f1d434230 Mon Sep 17 00:00:00 2001 From: Javier Spagnoletti Date: Mon, 15 Jun 2015 12:41:52 -0300 Subject: [PATCH 1/6] [Contributing] [Conventions] Added entry for identical comparison | Q | A | ------------- | --- | Doc fix? | yes | New docs? | no | Applies to | 2.8+ | Fixed tickets | --- contributing/code/conventions.rst | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/contributing/code/conventions.rst b/contributing/code/conventions.rst index e48eebd414e..6cdf04d17c8 100644 --- a/contributing/code/conventions.rst +++ b/contributing/code/conventions.rst @@ -77,6 +77,29 @@ must be used instead (where ``XXX`` is the name of the related thing): "replaceXXX", on the other hand, cannot add new elements. If an unrecognized key is passed to "replaceXXX" it must throw an exception. +.. _contributing-code-conventions-comparisons: + +Comparisons +----------- + +Use `identical comparison`_ when the expected value must match a specific type: + +instead of: + +.. code-block:: php + + if (1 == $integerExpected) { + // ... + } + +it should be: + +.. code-block:: php + + if (1 === $integerExpected) { + // ... + } + .. _contributing-code-conventions-deprecations: Deprecations @@ -104,3 +127,5 @@ the migration starting one or two minor versions before the version where the feature will be removed (depending on the criticality of the removal):: trigger_error('XXX() is deprecated since version 2.X and will be removed in 2.Y. Use XXX instead.', E_USER_DEPRECATED); + +.. _`identical comparison`: https://php.net/manual/en/language.operators.comparison.php From fc350ca772893530f24f9f6ef79bf504e4c54242 Mon Sep 17 00:00:00 2001 From: Javier Spagnoletti Date: Mon, 15 Jun 2015 13:05:54 -0300 Subject: [PATCH 2/6] Moved strict comparison doc from conventions to standards. --- contributing/code/conventions.rst | 25 ------------------------- contributing/code/standards.rst | 24 ++++++++++++++++++++++++ 2 files changed, 24 insertions(+), 25 deletions(-) diff --git a/contributing/code/conventions.rst b/contributing/code/conventions.rst index 6cdf04d17c8..e48eebd414e 100644 --- a/contributing/code/conventions.rst +++ b/contributing/code/conventions.rst @@ -77,29 +77,6 @@ must be used instead (where ``XXX`` is the name of the related thing): "replaceXXX", on the other hand, cannot add new elements. If an unrecognized key is passed to "replaceXXX" it must throw an exception. -.. _contributing-code-conventions-comparisons: - -Comparisons ------------ - -Use `identical comparison`_ when the expected value must match a specific type: - -instead of: - -.. code-block:: php - - if (1 == $integerExpected) { - // ... - } - -it should be: - -.. code-block:: php - - if (1 === $integerExpected) { - // ... - } - .. _contributing-code-conventions-deprecations: Deprecations @@ -127,5 +104,3 @@ the migration starting one or two minor versions before the version where the feature will be removed (depending on the criticality of the removal):: trigger_error('XXX() is deprecated since version 2.X and will be removed in 2.Y. Use XXX instead.', E_USER_DEPRECATED); - -.. _`identical comparison`: https://php.net/manual/en/language.operators.comparison.php diff --git a/contributing/code/standards.rst b/contributing/code/standards.rst index 40ca8c4981d..0b001b0b608 100644 --- a/contributing/code/standards.rst +++ b/contributing/code/standards.rst @@ -167,6 +167,29 @@ Service Naming Conventions * A group name uses the underscore notation. +.. _contributing-code-standards-comparisons: + +Comparisons +----------- + +Use `identical comparison`_ when the expected value must match a specific type: + +instead of: + +.. code-block:: php + + if (1 == $integerExpected) { + // ... + } + +it should be: + +.. code-block:: php + + if (1 === $integerExpected) { + // ... + } + Documentation ------------- @@ -186,3 +209,4 @@ License .. _`PSR-1`: http://www.php-fig.org/psr/psr-1/ .. _`PSR-2`: http://www.php-fig.org/psr/psr-2/ .. _`PSR-4`: http://www.php-fig.org/psr/psr-4/ +.. _`identical comparison`: https://php.net/manual/en/language.operators.comparison.php From ef30569fb832088d4d01525fc750d0884fab52b1 Mon Sep 17 00:00:00 2001 From: Javier Spagnoletti Date: Tue, 16 Jun 2015 16:19:35 -0300 Subject: [PATCH 3/6] Updated message enforcing always to use strict comparison. --- contributing/code/standards.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contributing/code/standards.rst b/contributing/code/standards.rst index 0b001b0b608..338a5abe24c 100644 --- a/contributing/code/standards.rst +++ b/contributing/code/standards.rst @@ -172,7 +172,7 @@ Service Naming Conventions Comparisons ----------- -Use `identical comparison`_ when the expected value must match a specific type: +Always use `identical comparison`_ unless you need type juggling: instead of: From b0a441fd48d9274f8b8d499822c8759e11bdc8dc Mon Sep 17 00:00:00 2001 From: Javier Spagnoletti Date: Tue, 16 Jun 2015 17:17:57 -0300 Subject: [PATCH 4/6] Mixed both snippets in just one. --- contributing/code/standards.rst | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/contributing/code/standards.rst b/contributing/code/standards.rst index 338a5abe24c..c6eeb7c0c0a 100644 --- a/contributing/code/standards.rst +++ b/contributing/code/standards.rst @@ -174,19 +174,15 @@ Comparisons Always use `identical comparison`_ unless you need type juggling: -instead of: - .. code-block:: php - if (1 == $integerExpected) { + // use + if (1 === $integerExpected) { // ... } -it should be: - -.. code-block:: php - - if (1 === $integerExpected) { + // instead of + if (1 == $integerExpected) { // ... } From b648da8b0b2afd34268982ccb484a6a2a455a4cb Mon Sep 17 00:00:00 2001 From: Javier Spagnoletti Date: Tue, 16 Jun 2015 18:25:52 -0300 Subject: [PATCH 5/6] Updated markdown delimiter for code snippet. --- contributing/code/standards.rst | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/contributing/code/standards.rst b/contributing/code/standards.rst index c6eeb7c0c0a..51f8bb60ac7 100644 --- a/contributing/code/standards.rst +++ b/contributing/code/standards.rst @@ -172,9 +172,7 @@ Service Naming Conventions Comparisons ----------- -Always use `identical comparison`_ unless you need type juggling: - -.. code-block:: php +Always use `identical comparison`_ unless you need type juggling:: // use if (1 === $integerExpected) { From c073821513da6b790cbf6c1eca0eba6e550dd3b7 Mon Sep 17 00:00:00 2001 From: Javier Spagnoletti Date: Fri, 26 Jun 2015 12:00:34 -0300 Subject: [PATCH 6/6] Moved "comparisons" inside "structure". --- contributing/code/standards.rst | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/contributing/code/standards.rst b/contributing/code/standards.rst index 51f8bb60ac7..48864f6992b 100644 --- a/contributing/code/standards.rst +++ b/contributing/code/standards.rst @@ -100,6 +100,8 @@ Structure * Place unary operators (``!``, ``--``, ...) adjacent to the affected variable; +* Always use `identical comparison`_ unless you need type juggling; + * Add a comma after each array item in a multi-line array, even after the last one; @@ -167,23 +169,6 @@ Service Naming Conventions * A group name uses the underscore notation. -.. _contributing-code-standards-comparisons: - -Comparisons ------------ - -Always use `identical comparison`_ unless you need type juggling:: - - // use - if (1 === $integerExpected) { - // ... - } - - // instead of - if (1 == $integerExpected) { - // ... - } - Documentation ------------- pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy