Completed
Push — master ( e0017c...6b1304 )
by Tom
14s queued 11s
created

Validator/Service/ObjectExistsFactory.php (2 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
declare(strict_types=1);
4
5
namespace DoctrineModule\Validator\Service;
6
7
use DoctrineModule\Validator\ObjectExists;
8
use Interop\Container\ContainerInterface;
9
10
/**
11
 * Factory for creating ObjectExists instances
12
 *
13
 * @link    http://www.doctrine-project.org/
14
 */
15
class ObjectExistsFactory extends AbstractValidatorFactory
16
{
17
    /** @var string */
18
    protected $validatorClass = ObjectExists::class;
19
20
    /**
21
     * {@inheritDoc}
22
     */
23 1
    public function __invoke(ContainerInterface $container, $requestedName, ?array $options = null)
24
    {
25 1
        $container = $this->container($container);
26
27 1
        $repository = $this->getRepository($container, $options);
0 ignored issues
show
It seems like $options defined by parameter $options on line 23 can also be of type array; however, DoctrineModule\Validator...actory::getRepository() does only seem to accept array<integer,*>|null, maybe add an additional type check?

This check looks at variables that have been passed in as parameters and are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
28
29 1
        return new ObjectExists($this->merge($options, [
30 1
            'object_repository' => $repository,
31 1
            'fields'            => $this->getFields($options),
0 ignored issues
show
$options is of type null|array, but the function expects a array<integer,*>.

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...
32
        ]));
33
    }
34
}
35