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

Service/Authentication/StorageFactory.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\Storage\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 storage object.
15
 *
16
 * @link    http://www.doctrine-project.org/
17
 */
18
class StorageFactory extends AbstractFactory
19
{
20
    /**
21
     * {@inheritDoc}
22
     */
23 3
    public function __invoke(ContainerInterface $container, $requestedName, ?array $options = null)
24
    {
25 3
        $options = $this->getOptions($container, 'authentication');
26
27 3
        $objectManager = $options->getObjectManager();
28 3
        if (is_string($objectManager)) {
29
            $options->setObjectManager($container->get($objectManager));
30
        }
31
32 3
        $storage = $options->getStorage();
33 3
        if (is_string($storage)) {
34 3
            $options->setStorage($container->get($storage));
35
        }
36
37 3
        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...
38
    }
39
40
    /**
41
     * {@inheritDoc}
42
     *
43
     * @return ObjectRepository
44
     */
45 2
    public function createService(ServiceLocatorInterface $container)
46
    {
47 2
        return $this($container, ObjectRepository::class);
48
    }
49
50 3
    public function getOptionsClass() : string
51
    {
52 3
        return 'DoctrineModule\Options\Authentication';
53
    }
54
}
55