src/Exception.php
Missing class import via use statement (line '46', column '40'). Open
Open
$traceReflectionProperty = new \ReflectionProperty(parent::class, 'trace');
- Read upRead up
- Create a ticketCreate a ticket
- 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
Avoid using static access to class '\Atk4\Core\ExceptionRenderer\RendererAbstract' in method 'toString'. Open
Open
$valueStr = RendererAbstract::toSafeString($value, true);
- Read upRead up
- Create a ticketCreate a ticket
- 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
Avoid using Atk4\Core\count() function in for loops. Open
Open
for ($i = 0; $i < count($trace); ++$i) {
$frame = $trace[$i];
if (isset($frame['object']) && $frame['object'] === $this && $frame['function'] === '__construct') {
array_shift($trace);
}
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
CountInLoopExpression
Since: 2.7.0
Using count/sizeof in loops expressions is considered bad practice and is a potential source of many bugs, especially when the loop manipulates an array, as count happens on each iteration.
Example
class Foo {
public function bar()
{
$array = array();
for ($i = 0; count($array); $i++) {
// ...
}
}
}
Source https://phpmd.org/rules/design.html#countinloopexpression
Avoid excessively long variable names like $traceReflectionProperty. Keep variable name length under 20. Open
Open
$traceReflectionProperty = new \ReflectionProperty(parent::class, 'trace');
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
LongVariable
Since: 0.2
Detects when a field, formal or local variable is declared with a long name.
Example
class Something {
protected $reallyLongIntName = -3; // VIOLATION - Field
public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
$otherReallyLongName = -5; // VIOLATION - Local
for ($interestingIntIndex = 0; // VIOLATION - For
$interestingIntIndex < 10;
$interestingIntIndex++ ) {
}
}
}
Source https://phpmd.org/rules/naming.html#longvariable
A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line 18 and the first side effect is on line 12. Open
Open
<?php
- Create a ticketCreate a ticket
- Exclude checks