Showing 68 of 68 total issues
Avoid using static access to class '\Doctrine\ORM\EntityManager' in method 'create'. Open
$entityManager = EntityManager::create($config['connection'], $configuration);
- Read upRead up
- 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 static access to class '\Doctrine\DBAL\Types\Type' in method 'create'. Open
if (! Type::hasType($type)) {
- Read upRead up
- 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 unused local variables such as '$idle'. Open
$this->channel->wait(null, false, $idle = 30); // Only wait 30 seconds
- Read upRead up
- Exclude checks
UnusedLocalVariable
Since: 0.2
Detects when a local variable is declared and/or assigned, but not used.
Example
class Foo {
public function doSomething()
{
$i = 5; // Unused
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable
Avoid unused parameters such as '$platform'. Open
public function convertToPHPValue($value, AbstractPlatform $platform): ?Identifier
- Read upRead up
- Exclude checks
UnusedFormalParameter
Since: 0.2
Avoid passing parameters to methods or constructors and then not using those parameters.
Example
class Foo
{
private function bar($howdy)
{
// $howdy is not used
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter
Avoid unused parameters such as '$visitor'. Open
fn ($visitor, CarbonImmutable $dateTime, array $type): string => $dateTime->format('Y-m-d H:i:s')
- Read upRead up
- Exclude checks
UnusedFormalParameter
Since: 0.2
Avoid passing parameters to methods or constructors and then not using those parameters.
Example
class Foo
{
private function bar($howdy)
{
// $howdy is not used
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter
Avoid using static access to class 'Adapters\Symfony\Application\DependencyInjection\ContainerDescriptor' in method 'create'. Open
$descriptor = ContainerDescriptor::forEnvironment($environment);
- Read upRead up
- 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 static access to class '\Webmozart\Assert\Assert' in method 'setPath'. Open
Assert::true($path->isDir(), 'Application base path must be a directory. Got %s');
- Read upRead up
- 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 publishTo uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$this->allEvents();
}
- Read upRead up
- 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 '\Webmozart\Assert\Assert' in method 'setId'. Open
Assert::notEmpty($value);
- Read upRead up
- 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 unused parameters such as '$request'. Open
public function handle(ServerRequestInterface $request): ResponseInterface
- Read upRead up
- Exclude checks
UnusedFormalParameter
Since: 0.2
Avoid passing parameters to methods or constructors and then not using those parameters.
Example
class Foo
{
private function bar($howdy)
{
// $howdy is not used
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter
Avoid unused parameters such as '$event'. Open
public function isSubscribedTo(DomainEvent $event): bool
- Read upRead up
- Exclude checks
UnusedFormalParameter
Since: 0.2
Avoid passing parameters to methods or constructors and then not using those parameters.
Example
class Foo
{
private function bar($howdy)
{
// $howdy is not used
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter
Avoid using static access to class '\Webmozart\Assert\Assert' in method 'setName'. Open
Assert::oneOf(
$name,
['local', 'test', 'dev', 'prod'],
'Expected one of the valid application environments: %2$s. Got %s'
);
- Read upRead up
- 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 static access to class '\Carbon\CarbonImmutable' in method 'now'. Open
return CarbonImmutable::now('UTC');
- Read upRead up
- 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
fromGlobals accesses the super-global variable $_ENV. Open
public static function fromGlobals(BasePath $basePath): Environment
{
self::load($basePath);
$name = trim($_ENV['APP_ENV'] ?? 'local');
$envDebug = trim($_ENV['APP_DEBUG'] ?? 'false');
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
fromGlobals accesses the super-global variable $_ENV. Open
public static function fromGlobals(BasePath $basePath): Environment
{
self::load($basePath);
$name = trim($_ENV['APP_ENV'] ?? 'local');
$envDebug = trim($_ENV['APP_DEBUG'] ?? 'false');
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
load accesses the super-global variable $_ENV. Open
private static function load(BasePath $basePath): void
{
if (! isset($_ENV['APP_ENV'])) {
$environment = Dotenv::createImmutable($basePath->absolutePath());
$environment->load();
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
Avoid using Adapters\RabbitMq\Application\Messaging\count() function in while loops. Open
while (count($this->channel->callbacks)) {
if ($this->consumed) {
break;
}
$this->channel->wait(null, false, $idle = 30); // Only wait 30 seconds
- Read upRead up
- 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
Only one argument is allowed per line in a multi-line function call Open
fn (string $routeName, array $arguments = []): string => $this->urlFor($routeName, $arguments)
- Exclude checks
Line exceeds 120 characters; contains 127 characters Open
$this->consumer->consume($this->exchangeName, Closure::fromCallable(function (stdClass $message, string $event): void {
- Exclude checks
Space before opening parenthesis of function call prohibited Open
fn (string $routeName, array $arguments = []): string => $this->urlFor($routeName, $arguments)
- Exclude checks