Showing 252 of 252 total issues
Avoid using undefined variables such as '$runtimeConfiguration' which will lead to PHP notices. Open
if (\in_array('*', $runtimeConfiguration['trustedProxies'], true)) {
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$this' which will lead to PHP notices. Open
$this->$propertyName = $newValue;
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$runtimeConfiguration' which will lead to PHP notices. Open
$runtimeConfiguration['trustedProxies'] = $this->decodeSet($trustedProxies);
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$runtimeConfiguration' which will lead to PHP notices. Open
Assertion::isArray($runtimeConfiguration['trustedProxies']);
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$runtimeConfiguration' which will lead to PHP notices. Open
return $runtimeConfiguration;
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Method process
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function process(ContainerBuilder $container, Proxifier $proxifier): void
{
/** @var array<string,string> $bundles */
$bundles = $container->getParameter('kernel.bundles');
Method ensureXdebugDisabled
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function ensureXdebugDisabled(SymfonyStyle $io): void
{
$xdebugHandler = new XdebugHandler();
if (!$xdebugHandler->shouldRestart()) {
return;
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 14. Open
<?php
- Exclude checks
Method __construct
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
private string $wrappedServiceId,
private Container $container,
Mutex $mutex,
int $instancesLimit = 50,
?Resetter $resetter = null,
The class ServerStatusCommand has a coupling between objects value of 14. Consider to reduce the number of dependencies under 13. Open
final class ServerStatusCommand extends Command
{
public function __construct(
private Sockets $sockets,
private ApiServerClientFactory $apiServerClientFactory,
- 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
The class ContextualAccessForwarderGenerator has a coupling between objects value of 17. Consider to reduce the number of dependencies under 13. Open
class ContextualAccessForwarderGenerator implements ProxyGeneratorInterface
{
public function __construct(private MethodForwarderBuilder $forwarderBuilder)
{
}
- 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
The class AbstractServerStartCommand has a coupling between objects value of 20. Consider to reduce the number of dependencies under 13. Open
abstract class AbstractServerStartCommand extends Command
{
use ParametersHelperTrait;
private bool $testing = false;
- 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
Method __construct
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
private HttpServer $server,
private HttpServerConfiguration $serverConfiguration,
private ConfiguratorInterface $serverConfigurator,
protected ParameterBagInterface $parameterBag,
private BootableInterface $bootManager
Method __construct
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
private AccessInterceptorValueHolderFactory $proxyFactory,
private Instantiator $instantiator,
private ServicePoolContainer $servicePoolContainer,
private MutexFactory $limitLocking,
private MutexFactory $newInstanceLocking
Method generateOverriddenDoInExtension
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Filesystem $fs,
string $containerDir,
string $fileToLoad,
string $class,
string $namespace
Method overrideCachedEntrypoint
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
private static function overrideCachedEntrypoint(Filesystem $fs, string $cacheDir, string $containerClass, string $overriddenFqcn, bool $isDebug): void
Possible parse error: class missing opening or closing brace Open
final class ContainerModifier
- Exclude checks
Multi-line use declarations must define one parameter per line Open
) use ($servicePoolContainer, $instantiator, $factoryConfig, $mutex, $globalInstancesLimit) {
- Exclude checks
Function overrideGeneratedContainer
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private static function overrideGeneratedContainer(ReflectionClass $reflContainer, string $cacheDir, bool $isDebug): void
{
$fs = new Filesystem();
$containerFqcn = $reflContainer->getName();
$overriddenFqcn = $containerFqcn.'_Overridden';
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function prepareConnectionsForProxification
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private function prepareConnectionsForProxification(ContainerBuilder $container, array $connectionSvcIds): void
{
$dbalAliveKeeperDef = $container->findDefinition(DBALPlatformAliveKeeper::class);
$aliveKeepers = $dbalAliveKeeperDef->getArgument(1);
$dbalAliveKeeperDef->setArgument(1, []);
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"