src/Pug/PugSymfonyEngine.php
The class PugSymfonyEngine has a coupling between objects value of 18. Consider to reduce the number of dependencies under 13. Open
Open
class PugSymfonyEngine implements EngineInterface, InstallerInterface
{
use Installer;
use HelpersHandler;
use Filters;
- 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 assigning values to variables in if clauses and the like (line '121', column '17'). Open
Open
protected function getFileFromName(string $name, string $directory = null): string
{
$parts = explode(':', $name);
if (count($parts) > 1) {
- Read upRead up
- Exclude checks
IfStatementAssignment
Since: 2.7.0
Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.
Example
class Foo
{
public function bar($flag)
{
if ($foo = 'bar') { // possible typo
// ...
}
if ($baz = 0) { // always false
// ...
}
}
}
Source http://phpmd.org/rules/cleancode.html#ifstatementassignment
syntax error, unexpected 'protected' (T_PROTECTED), expecting variable (T_VARIABLE)
Open
Open
protected readonly KernelInterface $kernel,
- Exclude checks
Avoid excessively long variable names like $defaultTemplateDirectory. Keep variable name length under 20. Open
Open
protected $defaultTemplateDirectory;
- Read upRead up
- 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
Line exceeds 120 characters; contains 122 characters Open
Open
$this->userOptions = ($this->container->hasParameter('pug') ? $this->container->getParameter('pug') : null) ?: [];
- Exclude checks
Line indented incorrectly; expected 12 spaces, found 16 Open
Open
static fn (string $interceptorClass) => $container->get($interceptorClass),
- Exclude checks
Space before opening parenthesis of function call prohibited Open
Open
static fn (string $interceptorClass) => $container->get($interceptorClass),
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 8 Open
Open
protected readonly KernelInterface $kernel,
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 8 Open
Open
private readonly ?RequestStack $stack = null,
- Exclude checks
Space before opening parenthesis of function call prohibited Open
Open
return array_unique(array_map(static fn ($path) => realpath($path) ?: $path, $paths));
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 8 Open
Open
private readonly ?RequestContext $context = null,
- Exclude checks