laminas / laminas-mvc

Laminas's event-driven MVC layer, including MVC Applications, Controllers, and Plugins
https://docs.laminas.dev/laminas-mvc/
BSD 3-Clause "New" or "Revised" License
141 stars 51 forks source link

PHP Fatal error: Declaration of Laminas\Mvc\Service\ModuleManagerFactory::__invoke not compatible with the interface signature #64

Closed nafassait closed 4 years ago

nafassait commented 4 years ago

Bug Report

This issue noticed with an existing running project with a recent composer install as part of the build process. The old build is working fine but any new build throwing fatal error during ModuleManager invoke

Q A
Version(s) x.y.z

Summary

When the service manager tries to load modules ModuleManagerFactory invoke fails due to incompatible function parameter

error: PHP Fatal error: Declaration of Laminas\Mvc\Service\ModuleManagerFactory::invoke(Interop\Container\ContainerInterface $container, $name, ?array $options = NULL) must be compatible with Laminas\ServiceManager\Factory\FactoryInterface::invoke(Psr\Container\ContainerInterface $container, $requestedName, ?array $options = NULL) in vendor\laminas\laminas-mvc\src\Service\ModuleManagerFactory.php on line 36

Current behavior

The code is failing during the bootstrap where the Module Manager tries to load modules. This was working until last week. and from today with new composer install application started breaking

How to reproduce

Try to load a module during bootstrap $serviceManagerConfig = new ServiceManagerConfig(); $serviceManager = new ServiceManager(); $serviceManagerConfig->configureServiceManager($serviceManager); $serviceManager->setService('ApplicationConfig', $config); $serviceManager->get('ModuleManager')->loadModules(); static::$serviceManager = $serviceManager;

Then run any code which triggers this ModuleManager factory and it will provide the below fatal error PHP Fatal error: Declaration of Laminas\Mvc\Service\ModuleManagerFactory::invoke(Interop\Container\ContainerInterface $container, $name, ?array $options = NULL) must be compatible with Laminas\ServiceManager\Factory\FactoryInterface::invoke(Psr\Container\ContainerInterface $container, $requestedName, ?array $options = NULL) in vendor\laminas\laminas-mvc\src\Service\ModuleManagerFactory.php on line 36

Expected behavior

The code should load the Module Manager without error.

Xerkus commented 4 years ago

You are using development version of service manager from 3.5.x branch that currently contains BC break. You must not use development branches for your dependencies unless it is done as a temporary measure in exceptional circumstances.

My guess is it was unintentional and you specify in your composer file "minimum-stability": "dev" in which case you should also use "prefer-stable": true