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

Service/Authentication/AdapterFactory.php (1 issue)

Severity

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\Service\Authentication;
6
7
use DoctrineModule\Authentication\Adapter\ObjectRepository;
8
use DoctrineModule\Service\AbstractFactory;
9
use Interop\Container\ContainerInterface;
10
use Laminas\ServiceManager\ServiceLocatorInterface;
11
use function is_string;
12
13
/**
14
 * Factory to create authentication adapter object.
15
 *
16
 * @link    http://www.doctrine-project.org/
17
 */
18
class AdapterFactory extends AbstractFactory
19
{
20
    /**
21
     * {@inheritDoc}
22
     */
23 2
    public function __invoke(ContainerInterface $container, $requestedName, ?array $options = null)
24
    {
25 2
        $options = $this->getOptions($container, 'authentication');
26
27 2
        $objectManager = $options->getObjectManager();
28 2
        if (is_string($objectManager)) {
29
            $options->setObjectManager($container->get($objectManager));
30
        }
31
32 2
        return new ObjectRepository($options);
0 ignored issues
show
$options is of type object<Laminas\Stdlib\AbstractOptions>, but the function expects a array<integer,*>|object<...Options\Authentication>.

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...
33
    }
34
35
    /**
36
     * {@inheritDoc}
37
     *
38
     * @return ObjectRepository
39
     */
40 1
    public function createService(ServiceLocatorInterface $serviceLocator)
41
    {
42 1
        return $this($serviceLocator, ObjectRepository::class);
43
    }
44
45 2
    public function getOptionsClass() : string
46
    {
47 2
        return 'DoctrineModule\Options\Authentication';
48
    }
49
}
50