From 844ac8e5cdd50fd480a32ec0b56b024d2169891f Mon Sep 17 00:00:00 2001 From: Javier Spagnoletti Date: Mon, 15 Jun 2015 12:16:30 -0300 Subject: [PATCH] [Contributing] [Conventions] Added entry for Yoda conditions | Q | A | ------------- | --- | Doc fix? | yes | New docs? | no | Applies to | 2.8+ | Fixed tickets | --- contributing/code/standards.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/contributing/code/standards.rst b/contributing/code/standards.rst index 40ca8c4981d..b3a7cc37f04 100644 --- a/contributing/code/standards.rst +++ b/contributing/code/standards.rst @@ -100,6 +100,9 @@ Structure * Place unary operators (``!``, ``--``, ...) adjacent to the affected variable; +* Use `Yoda conditions`_ when checking a variable against an expression to avoid + an accidental assignment inside the condition statement; + * Add a comma after each array item in a multi-line array, even after the last one; @@ -186,3 +189,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/ +.. _`Yoda conditions`: https://en.wikipedia.org/wiki/Yoda_conditions