Showing 8 of 8 total issues
Avoid variables with short names like $ip. Configured minimum length is 3. Open
Open
public function __construct(string $ip, array $domains, int $line)
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Avoid variables with short names like $ip. Configured minimum length is 3. Open
Open
protected $ip;
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
The method __construct has a boolean flag argument $strictSyntax, which is a certain sign of a Single Responsibility Principle violation. Open
Open
public function __construct(HostsFile $hostsFile, bool $strictSyntax = 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
The method parseAll has a boolean flag argument $forceLarge, which is a certain sign of a Single Responsibility Principle violation. Open
Open
public function parseAll(bool $forceLarge = false): array
- 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
Possibly zero references to use statement for classlike/namespace HostsFileException
(\NorthernLights\HostsFileParser\Exception\HostsFileException)
Open
Open
use NorthernLights\HostsFileParser\Exception\HostsFileException;
- Exclude checks
Rename "$splFile" which has the same name as the field declared at line 23. Open
Open
$splFile = new SplFileObject($this->filename, 'rb');
- Read upRead up
- Exclude checks
Shadowing fields with a local variable is a bad practice that reduces code readability: it makes it confusing to know whether the field or the variable is being used.
Noncompliant Code Example
class Foo { public $myField; public function doSomething() { $myField = 0; ... } }
See
- CERT, DCL51-J. - Do not shadow or obscure identifiers in subscopes
Assigning null
to property but \NorthernLights\HostsFileParser\HostsFile->splFile
is \SplFileObject
Open
Open
$this->splFile = null;
- Exclude checks
Saw an @param annotation for filename,
but it was not found in the param list of function __construct(\NorthernLights\HostsFileParser\HostsFile $hostsFile, bool|false $strictSyntax = null)
Open
Open
* @param HostsFile $filename
- Exclude checks