LibreNMS/Util/Laravel.php
isCli accesses the super-global variable $_SERVER. Open
Open
public static function isCli(): bool
{
return Laravel::isBooted()
? App::runningInConsole()
: (php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR']));
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
The method bootWeb has a boolean flag argument $authenticate, which is a certain sign of a Single Responsibility Principle violation. Open
Open
public static function bootWeb($authenticate = false)
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
Avoid unused local variables such as '$response'. Open
Open
$response = $kernel->handle($request);
- Read upRead up
- Exclude checks
UnusedLocalVariable
Since: 0.2
Detects when a local variable is declared and/or assigned, but not used.
Example
class Foo {
public function doSomething()
{
$i = 5; // Unused
}
}