Slamdunk / phpstan-laminas-framework

Laminas Framework 3 extensions for PHPStan
MIT License
16 stars 10 forks source link

$options on Laminas\ServiceManager\Factory\FactoryInterface #26

Closed fezfez closed 3 years ago

fezfez commented 3 years ago

Hello,

I got this error on every class that implements Laminas\ServiceManager\Factory\FactoryInterface.

Method MyFactory::__invoke() has parameter $options with no value type specified in iterable type array.  
         💡 See: https://phpstan.org/blog/solving-phpstan-no-value-type-specified-in-iterable-type 

I think it should be resolved by this extension.

Thanks for you work !

Slamdunk commented 3 years ago

Heh, the correct place to fix this is https://github.com/laminas/laminas-servicemanager/blob/1a32d6811fcbf54fd59f7a4763acd52fca8a7c97/src/Factory/FactoryInterface.php#L26, not this library

fezfez commented 3 years ago

seem a bit duplicate because it's already declared in method ?array $options = null, no ?

Slamdunk commented 3 years ago

No, this is the diff that would fix the warning:

 interface FactoryInterface
 {
     /**
      * Create an object
      *
      * @param  string             $requestedName
-     * @param  null|array         $options
+     * @param  null|array<mixed>  $options
      * @return object
      * @throws ServiceNotFoundException If unable to resolve the service.
      * @throws ServiceNotCreatedException If an exception is raised when creating a service.
      * @throws ContainerException If any other error occurs.
      */
     public function __invoke(ContainerInterface $container, $requestedName, ?array $options = null);
 }