Completed
Push — master ( 383891...6e1745 )
by Oleg
02:15
created

app/configs/index.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
// read components
4
$components = [];
5
foreach (scandir(__DIR__ . '/components') AS $fileName) {
6
    if ($fileName !== '.' AND $fileName !== '..') {
0 ignored issues
show
Comprehensibility Best Practice introduced by
Using logical operators such as and instead of && is generally not recommended.

PHP has two types of connecting operators (logical operators, and boolean operators):

  Logical Operators Boolean Operator
AND - meaning and &&
OR - meaning or ||

The difference between these is the order in which they are executed. In most cases, you would want to use a boolean operator like &&, or ||.

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-Flow

One 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 die introduces problems of its own, f.e. it makes our code hardly testable, and prevents any kind of more sophisticated error handling; you probably do not want to use this in real-world code. Unfortunately, logical operators cannot be combined with throw at this point:

// 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...
7
        /** @noinspection PhpIncludeInspection */
8
        $components[substr($fileName, 0, -4)] = require __DIR__ . '/components/' . $fileName;
9
    }
10
}
11
12
return [
13
    // Site name
14
    'company' => 'Sample',
15
    'slogan' => 'Demo blog written on MicroPHP framework',
16
17
    // Language
18
    'lang' => 'en',
19
20
    // Errors
21
    'errorController' => '\App\Controllers\DefaultController',
22
    'errorAction' => 'error',
23
24
    // Setup components
25
    'components' => $components
26
];
27