Showing 12 of 12 total issues
Avoid variables with short names like $to. Configured minimum length is 3. Open
Open
public function send($to, $from, $message, $params = [ ])
- 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
Missing class import via use statement (line '53', column '26'). Open
Open
$this->dom = new \DOMDocument();
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
The method checkCoupon has a boolean flag argument $markAsUsed, which is a certain sign of a Single Responsibility Principle violation. Open
Open
public function checkCoupon($coupon, $markAsUsed = true, $phone = null)
- 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
Spaces must be used to indent lines; tabs are not allowed Open
Open
new GuzzleHttpClient(new Client()),
- Exclude checks
Closing brace must be on a line by itself Open
Open
private function __construct(){}
- Exclude checks
Expected 1 space after IF keyword; 0 found Open
Open
if(in_array($action, $actions)) {
- Exclude checks
Opening brace should be on a new line Open
Open
private function __clone(){}
- Exclude checks
Closing brace must be on a line by itself Open
Open
private function __clone(){}
- Exclude checks
Multi-line function call not indented correctly; expected 8 spaces but found 12 Open
Open
]);
- Exclude checks
Opening parenthesis of a multi-line function call must be the last content on the line Open
Open
return $this->exec('reportNumber',
- Exclude checks
Opening brace should be on a new line Open
Open
private function __construct(){}
- Exclude checks
Closing parenthesis of a multi-line function call must be on a line by itself Open
Open
]);
- Exclude checks