These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
2 | /** |
|||||||||||
3 | * HiSite Yii2 base project |
|||||||||||
4 | * |
|||||||||||
5 | * @link https://github.com/hiqdev/hisite |
|||||||||||
6 | * @package hisite |
|||||||||||
7 | * @license BSD-3-Clause |
|||||||||||
8 | * @copyright Copyright (c) 2016-2017, HiQDev (http://hiqdev.com/) |
|||||||||||
9 | */ |
|||||||||||
10 | ||||||||||||
11 | $_ENV['ENV'] = !empty($_ENV['ENV']) ? $_ENV['ENV'] : 'prod'; |
|||||||||||
12 | $_ENV['DEBUG'] = isset($_ENV['DEBUG']) ? $_ENV['DEBUG'] : $_ENV['ENV'] === 'dev'; |
|||||||||||
13 | ||||||||||||
14 | defined('YII_DEBUG') or define('YII_DEBUG', $_ENV['DEBUG']); |
|||||||||||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
Using logical operators such as
or instead of || is generally not recommended.
PHP has two types of connecting operators (logical operators, and boolean operators):
The difference between these is the order in which they are executed. In most cases,
you would want to use a boolean operator like Let’s take a look at a few examples: // Logical operators have lower precedence:
$f = false or true;
// is executed like this:
($f = false) or true;
// Boolean operators have higher precedence:
$f = false || true;
// is executed like this:
$f = (false || true);
Logical Operators are used for Control-FlowOne case where you explicitly want to use logical operators is for control-flow such as this: $x === 5
or die('$x must be 5.');
// Instead of
if ($x !== 5) {
die('$x must be 5.');
}
Since // The following is currently a parse error.
$x === 5
or throw new RuntimeException('$x must be 5.');
These limitations lead to logical operators rarely being of use in current PHP code.
Loading history...
|
||||||||||||
15 | defined('YII_ENV') or define('YII_ENV', $_ENV['ENV']); |
|||||||||||
16 |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.