Issues (1)

src/Service/ProxyDriverFactory.php (1 issue)

1
<?php
2
3
declare(strict_types=1);
4
5
namespace Fabiang\DoctrineDynamic\Service;
6
7
use Doctrine\ORM\EntityManager;
8
use Fabiang\DoctrineDynamic\Configuration;
9
use Fabiang\DoctrineDynamic\ProxyDriver;
10
use Fabiang\DoctrineDynamic\ProxyDriverFactory as BaseProxyDriverFactory;
11
use Laminas\ServiceManager\Factory\FactoryInterface;
12
use Psr\Container\ContainerInterface;
13
14
final class ProxyDriverFactory extends BaseProxyDriverFactory implements
15
    FactoryInterface
16
{
17
    /**
18
     * @param string $requestedName
19
     * @return ProxyDriver[]
20
     */
21 1
    public function __invoke(ContainerInterface $container, $requestedName, ?array $options = null): array
22
    {
23 1
        $entityManager = $container->get(EntityManager::class);
24 1
        $configuration = $container->get(Configuration::class);
25 1
        return $this->factory($entityManager, $configuration);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->factory($e...anager, $configuration) returns the type array which is incompatible with the return type mandated by Laminas\ServiceManager\F...ryInterface::__invoke() of object.

In the issue above, the returned value is violating the contract defined by the mentioned interface.

Let's take a look at an example:

interface HasName {
    /** @return string */
    public function getName();
}

class Name {
    public $name;
}

class User implements HasName {
    /** @return string|Name */
    public function getName() {
        return new Name('foo'); // This is a violation of the ``HasName`` interface
                                // which only allows a string value to be returned.
    }
}
Loading history...
26
    }
27
}
28