Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update PHP.rst #1125

Merged
merged 1 commit into from Nov 29, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -824,16 +824,16 @@ PHP in General

if ($template) // BAD
if (isset($template)) // GOOD
if ($template !== NULL)) // GOOD
if ($template !== '')) // GOOD
if ($template !== NULL) // GOOD
if ($template !== '') // GOOD

if (strlen($template) > 0) // BAD! strlen("-1") is greater than 0
if (is_string($template) && strlen($template) > 0) // BETTER

if ($foo == $bar) // BAD, avoid truthy comparisons
if ($foo != $bar) // BAD, avoid falsy comparisons
if ($foo === $bar)) // GOOD
if ($foo !== $bar)) // GOOD
if ($foo === $bar) // GOOD
if ($foo !== $bar) // GOOD

.. figure:: Images/PHP_TrueFalse.jpg
:alt: Truthy and falsy are fuzzy...
Expand Down Expand Up @@ -876,7 +876,7 @@ naming. [#]_ As an example, consider the example for a coding smell::
This is a perfect case for the refactoring technique "extract method": In order to avoid
the comment, create a new method which is as explanatory as the comment::

if ($this->isValidPerson($person) {
if ($this->isValidPerson($person)) {
$xmM = $thd;
}

Expand Down