Completed
Push — master ( aedaa6...d154ad )
by Valentin
06:14
created

LocatorFactory::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Cycle\ORM\Promise\Materizalizer\ClassLocator;
5
6
use Spiral\Tokenizer\TokenizerInterface;
7
use Symfony\Component\Finder\Finder;
8
9
class LocatorFactory
10
{
11
    /** @var TokenizerInterface */
12
    private $tokenizer;
13
14
    public function __construct(TokenizerInterface $tokenizer)
15
    {
16
        $this->tokenizer = $tokenizer;
17
    }
18
19
    public function create(string $directory): Locator
20
    {
21
        $finder = new Finder();
22
        $finder->in($directory);
23
24
        return new Locator($this->tokenizer, $finder);
0 ignored issues
show
Documentation introduced by
$this->tokenizer is of type object<Spiral\Tokenizer\TokenizerInterface>, but the function expects a object<Spiral\Tokenizer\ClassLocator>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
Unused Code introduced by
The call to Locator::__construct() has too many arguments starting with $finder.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
25
    }
26
}