Showing 35 of 43 total issues
Avoid variables with short names like $fn. Configured minimum length is 3. Open
public function map(Closure $fn)
- 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 $fn. Configured minimum length is 3. Open
public function filter(Closure $fn)
- 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 $fn. Configured minimum length is 3. Open
public function reduce(Closure $fn, $initial = null)
- 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 parameter $street_1 is not named in camelCase. Open
public function __construct(string $street_1, string $street_2 = null, string $city, string $state, string $zipcode)
{
parent::__construct(compact('street_1', 'street_2', 'city', 'state', 'zipcode'));
}
- Read upRead up
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}
Source
The parameter $street_2 is not named in camelCase. Open
public function __construct(string $street_1, string $street_2 = null, string $city, string $state, string $zipcode)
{
parent::__construct(compact('street_1', 'street_2', 'city', 'state', 'zipcode'));
}
- Read upRead up
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}
Source
There must be one USE keyword per declaration Open
use ArrayAccess, Countable, Closure, Iterator;
- Exclude checks
There must be one blank line after the last USE statement; 2 found; Open
use JsonSchema\Validator as JsonSchemaValidator;
- Exclude checks
The closing brace for the trait must go on the next line after the body Open
}
- Exclude checks
TRUE, FALSE and NULL must be lowercase; expected "true" but found "TRUE" Open
public function __construct($input = [], $observe = TRUE)
- Exclude checks
TRUE, FALSE and NULL must be lowercase; expected "true" but found "TRUE" Open
public function __construct($input = [], $observe = TRUE)
- Exclude checks
Missing class import via use statement (line '26', column '19'). Open
throw new \InvalidArgumentException("$value is not observable");
- 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 __construct has a boolean flag argument $observe, which is a certain sign of a Single Responsibility Principle violation. Open
public function __construct($input = [], $observe = TRUE)
- 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 __construct has a boolean flag argument $observe, which is a certain sign of a Single Responsibility Principle violation. Open
public function __construct($input = [], $observe = TRUE)
- 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 using static access to class '\PhpSchema\Models\Validator' in method '__construct'. Open
$this->validator = Validator::create();
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Inline control structures are not allowed Open
if (array() === $this->container) return false;
- Exclude checks
Arguments with default values must be at the end of the argument list Open
public function __construct($input = [], Observable $subscriber)
- Exclude checks
Expected 1 space after IF keyword; 0 found Open
if($isAssoc === false){
- Exclude checks
Expected 1 newline at end of file; 0 found Open
}
- Exclude checks
Expected 1 space after closing parenthesis; found 0 Open
if($isAssoc === false){
- Exclude checks
Expected 1 space after closing parenthesis; found 0 Open
if($this->isAssociative()){
- Exclude checks