FriendsOfSymfony / FOSRestBundle

This Bundle provides various tools to rapidly develop RESTful API's with Symfony
http://symfony.com/doc/master/bundles/FOSRestBundle/index.html
MIT License
2.79k stars 703 forks source link

PHP8 incompatibility #2250

Closed michaljusiega closed 4 years ago

michaljusiega commented 4 years ago

PHP Version: PHP8.0.0-alpha1

First issue: method_exists(): Argument #1 ($object_or_class) must be of type object|string, array given stack trace:

TypeError:
method_exists(): Argument #1 ($object_or_class) must be of type object|string, array given

  at vendor/friendsofsymfony/rest-bundle/EventListener/ParamFetcherListener.php:50
  at method_exists(array(object(LogowanieController), 'logowanieZaloguj'), '__invoke')
     (vendor/friendsofsymfony/rest-bundle/EventListener/ParamFetcherListener.php:50)
  at FOS\RestBundle\EventListener\ParamFetcherListener->onKernelController(object(ControllerEvent), 'kernel.controller', object(TraceableEventDispatcher))
     (vendor/symfony/event-dispatcher/Debug/WrappedListener.php:117)
  at Symfony\Component\EventDispatcher\Debug\WrappedListener->__invoke(object(ControllerEvent), 'kernel.controller', object(TraceableEventDispatcher))
     (vendor/symfony/event-dispatcher/EventDispatcher.php:230)
  at Symfony\Component\EventDispatcher\EventDispatcher->callListeners(array(object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener)), 'kernel.controller', object(ControllerEvent))
     (vendor/symfony/event-dispatcher/EventDispatcher.php:59)
  at Symfony\Component\EventDispatcher\EventDispatcher->dispatch(object(ControllerEvent), 'kernel.controller')
     (vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php:151)
  at Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher->dispatch(object(ControllerEvent), 'kernel.controller')
     (vendor/symfony/http-kernel/HttpKernel.php:145)
  at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), 1)
     (vendor/symfony/http-kernel/HttpKernel.php:79)
  at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), 1, true)
     (vendor/symfony/http-kernel/Kernel.php:196)
  at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
     (src/Kernel.php:1153)
  at Luxmed\Intranet\Kernel->handleSendTerminate()
     (src/Kernel.php:379)
  at Luxmed\Intranet\Kernel->__construct('dev', true, true)
     (src/KernelFactory.php:56)
  at Luxmed\Intranet\KernelFactory::runDevKernel()
     (public/app_dev.php:31)  

https://github.com/FriendsOfSymfony/FOSRestBundle/blob/3.x/EventListener/ParamFetcherListener.php#L49

Change L49: if (is_callable($controller) && method_exists($controller, '__invoke')) {

to

if (is_callable($controller) && (is_object($controller) || is_string($controller)) && method_exists($controller, '__invoke')) {

xabbuh commented 4 years ago

Thank you for reporting. This will be fixed by #2251.