Passed
Push — main ( 0b1f45...3b8d3e )
by Chema
02:32 queued 12s
created

ConsoleFactory   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 8
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 8
ccs 0
cts 2
cp 0
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A getConsoleCommands() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PhpLightning\Console;
6
7
use Gacela\Console\ConsoleConfig;
8
use Gacela\Console\ConsoleDependencyProvider;
0 ignored issues
show
Bug introduced by
This use statement conflicts with another class in this namespace, PhpLightning\Console\ConsoleDependencyProvider. Consider defining an alias.

Let?s assume that you have a directory layout like this:

.
|-- OtherDir
|   |-- Bar.php
|   `-- Foo.php
`-- SomeDir
    `-- Foo.php

and let?s assume the following content of Bar.php:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/Foo.php are loaded in the same runtime, you will see a PHP error such as the following:

PHP Fatal error:  Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php

However, as OtherDir/Foo.php does not necessarily have to be loaded and the error is only triggered if it is loaded before OtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
9
use Gacela\Framework\AbstractFactory;
10
use Symfony\Component\Console\Command\Command;
11
12
/**
13
 * @method ConsoleConfig getConfig()
14
 */
15
final class ConsoleFactory extends AbstractFactory
16
{
17
    /**
18
     * @return list<Command>
0 ignored issues
show
Bug introduced by
The type PhpLightning\Console\list was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
19
     */
20
    public function getConsoleCommands(): array
21
    {
22
        return (array)$this->getProvidedDependency(ConsoleDependencyProvider::COMMANDS);
0 ignored issues
show
Bug Best Practice introduced by
The expression return (array)$this->get...encyProvider::COMMANDS) returns the type array which is incompatible with the documented return type PhpLightning\Console\list.
Loading history...
23
    }
24
}
25