Skip to content

Commit

Permalink
Remove section in CGL about assignments in conditions (#705)
Browse files Browse the repository at this point in the history
The recommendation to not use assignments in condition and add
extra parenthethese does not reflect current practice in core
and in newer examples in documentation.

Releases: master, 10.4, 9.5
  • Loading branch information
sypets authored and lolli42 committed Sep 1, 2020
1 parent b73058d commit 310872a
Showing 1 changed file with 0 additions and 20 deletions.
Expand Up @@ -208,26 +208,6 @@ Wrong usage of the ternary conditional operator::

$result = ($useComma ? ',' : $useDot ? '.' : ';');

Assignment in conditions should be avoided. However if it makes sense
to do an assignment in a condition, it should be surrounded by the
extra pair of brackets. Example::

if (($fields = $this->getFields())) {
// Do something
}

The following is allowed, but not recommended::

if (false !== ($fields = $this->getFields())) {
// Do something
}

The following is not allowed (missing the extra pair of brackets)::

while ($fields = $this->getFields()) {
// Do something
}


Switch
======
Expand Down

0 comments on commit 310872a

Please sign in to comment.