The class View has 22 public methods. Consider refactoring View to keep number of public methods under 10. Open
class View extends AbstractView
{
/**
* When you call renderAll() this will be populated with JavaScript chains.
*
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
TooManyPublicMethods
Since: 0.1
A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.
By default it ignores methods starting with 'get' or 'set'.
Example
Source https://phpmd.org/rules/codesize.html#toomanypublicmethods
The class View has an overall complexity of 152 which is very high. The configured complexity threshold is 50. Open
class View extends AbstractView
{
/**
* When you call renderAll() this will be populated with JavaScript chains.
*
- Create a ticketCreate a ticket
- Exclude checks
The class View has 27 non-getter- and setter-methods. Consider refactoring View to keep number of methods under 25. Open
class View extends AbstractView
{
/**
* When you call renderAll() this will be populated with JavaScript chains.
*
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
TooManyMethods
Since: 0.1
A class with too many methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.
By default it ignores methods starting with 'get' or 'set'.
The default was changed from 10 to 25 in PHPMD 2.3.
Example
Source https://phpmd.org/rules/codesize.html#toomanymethods
The class View has 46 public methods and attributes. Consider reducing the number of public items to less than 45. Open
class View extends AbstractView
{
/**
* When you call renderAll() this will be populated with JavaScript chains.
*
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
ExcessivePublicCount
Since: 0.1
A large number of public methods and attributes declared in a class can indicate the class may need to be broken up as increased effort will be required to thoroughly test it.
Example
public class Foo {
public $value;
public $something;
public $var;
// [... more more public attributes ...]
public function doWork() {}
public function doMoreWork() {}
public function doWorkAgain() {}
// [... more more public methods ...]
}
Source https://phpmd.org/rules/codesize.html#excessivepubliccount
The class View has 1093 lines of code. Current threshold is 1000. Avoid really long classes. Open
class View extends AbstractView
{
/**
* When you call renderAll() this will be populated with JavaScript chains.
*
- Create a ticketCreate a ticket
- Exclude checks
The method renderView() has an NPath complexity of 10368. The configured NPath complexity threshold is 200. Open
protected function renderView(): void
{
if ($this->element !== 'div') {
$this->template->set('_element', $this->element);
} else {
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
NPathComplexity
Since: 0.1
The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.
Example
class Foo {
function bar() {
// lots of complicated code
}
}
Source https://phpmd.org/rules/codesize.html#npathcomplexity
The method on() has 153 lines of code. Current threshold is set to 100. Avoid really long methods. Open
public function on(string $event, $selector = null, $action = null, array $defaults = [])
{
// second argument may be omitted
if ($selector !== null && !is_string($selector) && ($action === null || is_array($action)) && $defaults === []) {
$defaults = $action ?? [];
- Create a ticketCreate a ticket
- Exclude checks
The method on() has an NPath complexity of 79488. The configured NPath complexity threshold is 200. Open
public function on(string $event, $selector = null, $action = null, array $defaults = [])
{
// second argument may be omitted
if ($selector !== null && !is_string($selector) && ($action === null || is_array($action)) && $defaults === []) {
$defaults = $action ?? [];
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
NPathComplexity
Since: 0.1
The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.
Example
class Foo {
function bar() {
// lots of complicated code
}
}
Source https://phpmd.org/rules/codesize.html#npathcomplexity
The method renderView() has a Cyclomatic Complexity of 17. The configured cyclomatic complexity threshold is 10. Open
protected function renderView(): void
{
if ($this->element !== 'div') {
$this->template->set('_element', $this->element);
} else {
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
CyclomaticComplexity
Since: 0.1
Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
Example
// Cyclomatic Complexity = 11
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } elseif ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } elseif ($e == $f) {
8 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
switch ($z) {
9 case 1:
fiddle();
break;
10 case 2:
fiddle();
break;
11 case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}
Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity
The method on() has a Cyclomatic Complexity of 34. The configured cyclomatic complexity threshold is 10. Open
public function on(string $event, $selector = null, $action = null, array $defaults = [])
{
// second argument may be omitted
if ($selector !== null && !is_string($selector) && ($action === null || is_array($action)) && $defaults === []) {
$defaults = $action ?? [];
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
CyclomaticComplexity
Since: 0.1
Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
Example
// Cyclomatic Complexity = 11
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } elseif ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } elseif ($e == $f) {
8 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
switch ($z) {
9 case 1:
fiddle();
break;
10 case 2:
fiddle();
break;
11 case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}
Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity
The class View has a coupling between objects value of 22. Consider to reduce the number of dependencies under 13. Open
class View extends AbstractView
{
/**
* When you call renderAll() this will be populated with JavaScript chains.
*
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
CouplingBetweenObjects
Since: 1.1.0
A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability
Example
class Foo {
/**
* @var \foo\bar\X
*/
private $x = null;
/**
* @var \foo\bar\Y
*/
private $y = null;
/**
* @var \foo\bar\Z
*/
private $z = null;
public function setFoo(\Foo $foo) {}
public function setBar(\Bar $bar) {}
public function setBaz(\Baz $baz) {}
/**
* @return \SplObjectStorage
* @throws \OutOfRangeException
* @throws \InvalidArgumentException
* @throws \ErrorException
*/
public function process(\Iterator $it) {}
// ...
}
Source https://phpmd.org/rules/design.html#couplingbetweenobjects
Missing class import via use statement (line '128', column '23'). Open
if (((new \ReflectionProperty(self::class, 'model'))->isInitialized($this) ? $this->model : $this->entity) === $model) {
- 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
Missing class import via use statement (line '127', column '19'). Open
if (((new \ReflectionProperty(self::class, 'model'))->isInitialized($this) ? $this->model : $this->entity) !== null) {
- 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
The method js has a boolean flag argument $when, which is a certain sign of a Single Responsibility Principle violation. Open
public function js($when = false, $action = null, $selector = null): ?JsExpressionable
- Read upRead up
- Create a ticketCreate a ticket
- 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 jsAddStoreData has a boolean flag argument $useSession, which is a certain sign of a Single Responsibility Principle violation. Open
public function jsAddStoreData(array $data, bool $useSession = false): JsExpressionable
- Read upRead up
- Create a ticketCreate a ticket
- 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
Missing class import via use statement (line '111', column '40'). Open
if ($name === 'model' && !(new \ReflectionProperty(self::class, 'model'))->isInitialized($this) && $this->entity !== null) {
- 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
The method jsClearStoreData has a boolean flag argument $useSession, which is a certain sign of a Single Responsibility Principle violation. Open
public function jsClearStoreData(bool $useSession = false): JsExpressionable
- Read upRead up
- Create a ticketCreate a ticket
- 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 setAttr uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$this->attr[$name] = $value;
}
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method setSource uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
throw new Exception('Source data contains unsupported zero key');
}
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid using static access to class 'Atk4\Ui\JsCallback' in method 'on'. Open
$cb = JsCallback::addTo($this, [], [['desired_name' => $event]]);
- 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
The method on uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$eventChain->on($event, $eventFunction);
}
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method add uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$args = [];
}
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method removeAttr uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
unset($this->attr[$name]);
}
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method _getStickyArgs uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$stickyArgs = $this->stickyArgs;
}
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method renderView uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$this->template->trySet('_element', $this->element);
}
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method init uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
if ($this->region !== 'Content' && $this->issetOwner() && $this->getOwner()->template) {
$this->template = $this->getOwner()->template->cloneRegion($this->region);
$this->getOwner()->template->del($this->region);
}
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method setModel uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
unset($this->{'entity'});
$this->model = $model;
}
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method on uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$actions = [$action];
}
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method setMissingProperty uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$this->removeClass($class);
}
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid using static access to class 'Atk4\Ui\AbstractView' in method 'add'. Open
$object = AbstractView::fromSeed($object);
- 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
The method js uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$action = new Jquery($this);
if ($selector) {
$action->find($selector);
}
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method on uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
throw new Exception('Executor must be of type UserAction\JsCallbackExecutor or UserAction\JsExecutorInterface');
}
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method on uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$eventStatements = array_merge($eventStatements, $actions);
}
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method vue uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$chain = (new JsVueService())->createAtkVue($selector, $component, $initData);
}
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method on uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$action = new Jquery();
$res = $action;
}
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method setStyle uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$this->style[$property] = $value;
}
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method link uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$this->setAttr('href', $this->url($url));
}
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid excessively long variable names like $setupNonSharedExecutorFx. Keep variable name length under 20. Open
$setupNonSharedExecutorFx = function (UserAction\ExecutorInterface $ex) use (&$defaults, &$arguments): void {
- 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
Avoid using short method names like View::on(). The configured minimum method name length is 3. Open
public function on(string $event, $selector = null, $action = null, array $defaults = [])
{
// second argument may be omitted
if ($selector !== null && !is_string($selector) && ($action === null || is_array($action)) && $defaults === []) {
$defaults = $action ?? [];
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
ShortMethodName
Since: 0.2
Detects when very short method names are used.
Example
class ShortMethod {
public function a( $index ) { // Violation
}
}
Source https://phpmd.org/rules/naming.html#shortmethodname
Avoid using short method names like View::js(). The configured minimum method name length is 3. Open
public function js($when = false, $action = null, $selector = null): ?JsExpressionable
{
// binding on a specific event
// TODO allow only boolean $when, otherwise user should use self::on() method
if (!is_bool($when)) {
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
ShortMethodName
Since: 0.2
Detects when very short method names are used.
Example
class ShortMethod {
public function a( $index ) { // Violation
}
}
Source https://phpmd.org/rules/naming.html#shortmethodname
The property $_jsActions is not named in camelCase. Open
class View extends AbstractView
{
/**
* When you call renderAll() this will be populated with JavaScript chains.
*
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
Avoid variables with short names like $fx. Configured minimum length is 3. Open
public \Closure $fx;
- Read upRead up
- Create a ticketCreate a ticket
- 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 $cb. Configured minimum length is 3. Open
$cb = JsCallback::addTo($this, [], [['desired_name' => $event]]);
- Read upRead up
- Create a ticketCreate a ticket
- 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 $js. Configured minimum length is 3. Open
$js = $this->getJs()->jsRender();
- Read upRead up
- Create a ticketCreate a ticket
- 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 $ex. Configured minimum length is 3. Open
$setupNonSharedExecutorFx = function (UserAction\ExecutorInterface $ex) use (&$defaults, &$arguments): void {
- Read upRead up
- Create a ticketCreate a ticket
- 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 $ui. Configured minimum length is 3. Open
public $ui = false;
- Read upRead up
- Create a ticketCreate a ticket
- 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 $fx. Configured minimum length is 3. Open
$lazyJsRenderFx = function (\Closure $fx): JsExpressionable {
- Read upRead up
- Create a ticketCreate a ticket
- 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
Property name "$_jsActions" should not be prefixed with an underscore to indicate visibility Open
protected array $_jsActions = [];
- Create a ticketCreate a ticket
- Exclude checks
Method name "_getStickyArgs" should not be prefixed with an underscore to indicate visibility Open
protected function _getStickyArgs(): array
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 173 characters Open
$this->getApp()->tryGetRequestQueryParam($this->name . '_session_store') ?? $this->getApp()->tryGetRequestPostParam($this->name . '_session_store') ?? 'null'
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 121 characters Open
$setupNonSharedExecutorFx = function (UserAction\ExecutorInterface $ex) use (&$defaults, &$arguments): void {
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 139 characters Open
* @param string|array<0|string, string|int|false> $page URL as string or array with page path as first element and other GET arguments
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 121 characters Open
if ($selector !== null && !is_string($selector) && ($action === null || is_array($action)) && $defaults === []) {
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 126 characters Open
if (((new \ReflectionProperty(self::class, 'model'))->isInitialized($this) ? $this->model : $this->entity) !== null) {
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 123 characters Open
if ($this->template->hasTag('AfterBeforeInput') && str_contains($this->template->renderToHtml(), ' type="file"')) {
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 132 characters Open
if ($name === 'model' && !(new \ReflectionProperty(self::class, 'model'))->isInitialized($this) && $this->entity !== null) {
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 151 characters Open
if ($this->getApp()->hasRequestQueryParam('__atk_reload') && $this->getApp()->getRequestQueryParam('__atk_reload') === ($this->name ?? null)) {
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 139 characters Open
* @param string|array<0|string, string|int|false> $page URL as string or array with page path as first element and other GET arguments
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 140 characters Open
* This is the initial data pass to your main component via the initData bind property
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 150 characters Open
$arguments[$ex->name] = $this->getApp()->uiPersistence->typecastAttributeSaveField($exModel->getIdField(), $arguments[$ex->name]);
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 169 characters Open
$this->getApp()->tryGetRequestQueryParam($this->name . '_local_store') ?? $this->getApp()->tryGetRequestPostParam($this->name . '_local_store') ?? 'null'
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 128 characters Open
throw new Exception('Executor must be of type UserAction\JsCallbackExecutor or UserAction\JsExecutorInterface');
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 212 characters Open
* @param array<int|string, mixed> $defaults
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 191 characters Open
array_unshift($eventStatements, new JsExpression('$.atkConfirm({ message: [confirm], onApprove: [action], options: { button: { ok: [ok], cancel: [cancel] } }, context: this })', [
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 228 characters Open
* @param ($selector is string|null ? JsExpressionable|JsCallback|JsCallbackSetClosure|array{JsCallbackSetClosure}|UserAction\ExecutorInterface|Model\UserAction : array<int|string, mixed>) $action code to execute
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 126 characters Open
$ex = $action instanceof Model\UserAction ? $this->getExecutorFactory()->createExecutor($action, $this) : $action;
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 161 characters Open
* @phpstan-type JsCallbackSetClosure \Closure(Jquery, mixed, mixed, mixed, mixed, mixed, mixed, mixed, mixed, mixed, mixed): (JsExpressionable|View|string|void)
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 155 characters Open
} elseif ($action instanceof UserAction\ExecutorInterface || $action instanceof UserAction\SharedExecutor || $action instanceof Model\UserAction) {
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 132 characters Open
if (((new \ReflectionProperty(self::class, 'model'))->isInitialized($this) ? $this->model : $this->entity) === $model) {
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 124 characters Open
$this->stickyArgs[$name] = $newValue ?? $this->stickyArgs[$name] ?? $this->getApp()->tryGetRequestQueryParam($name);
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 229 characters Open
* @param string $event JavaScript event
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 243 characters Open
* @param ($action is object ? string : ($action is null ? string : never)|JsExpressionable|JsCallback|JsCallbackSetClosure|array{JsCallbackSetClosure}|UserAction\ExecutorInterface|Model\UserAction) $selector Optional jQuery-style selector
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 153 characters Open
if (!is_string($content) && $content !== null) { // @phpstan-ignore function.alreadyNarrowedType, notIdentical.alwaysTrue, booleanAnd.alwaysFalse
- Create a ticketCreate a ticket
- Exclude checks
Space before opening parenthesis of function call prohibited Open
? $lazyJsRenderFx(static fn () => $ex->jsExecute($arguments))
- Create a ticketCreate a ticket
- Exclude checks
Space before opening parenthesis of function call prohibited Open
$actions[] = $lazyJsRenderFx(static fn () => $cb->jsExecute());
- Create a ticketCreate a ticket
- Exclude checks
Space before opening parenthesis of function call prohibited Open
$actions = [$lazyJsRenderFx(static fn () => $ex->jsExecute($arguments))];
- Create a ticketCreate a ticket
- Exclude checks
Space before opening parenthesis of function call prohibited Open
$actions = [$lazyJsRenderFx(static fn () => $action->jsExecute())];
- Create a ticketCreate a ticket
- Exclude checks
The method _getStickyArgs is not named in camelCase. Open
protected function _getStickyArgs(): array
{
if ($this->issetOwner()) {
$stickyArgs = array_merge($this->getOwner()->_getStickyArgs(), $this->stickyArgs);
} else {
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}