libs/compiler/src/Grammar/PP2Grammar.php
Method reducers
has 94 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private function reducers(): array
{
return [
20 => static function (array $delegates): Node {
if ($delegates === []) {
Method grammar
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private function grammar(): array
{
return [
0 => new Repetition(11, 0),
1 => new Concatenation([30, 2]),
The method reducers() has 109 lines of code. Current threshold is set to 100. Avoid really long methods. Open
Open
private function reducers(): array
{
return [
20 => static function (array $delegates): Node {
if ($delegates === []) {
- Exclude checks
The class PP2Grammar has a coupling between objects value of 28. Consider to reduce the number of dependencies under 13. Open
Open
class PP2Grammar implements GrammarInterface, BuilderInterface
{
private Parser $runtime;
/**
- Read upRead up
- 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
Avoid variables with short names like $to. Configured minimum length is 3. Open
Open
[$from, $to] = [$value[0]->getValue(), $value[1]->getValue()];
- 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 $q. Configured minimum length is 3. Open
Open
[$stmt, $q] = $payload;
- 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;
}
}
}