Symfony Implementing interface from another bundle fails "Fatal error: Declaration of … must be compatible …"

  implements, interface, openapi, php, symfony

I am working on a symfony 3.3 app, the app had a single bundle and I wanted to add another bundle containing our new api client generated with the OpenAPI generator with the following command :

openapi-generator generate -i swagger.json -g php-symfony -o MyOpenAPIBundle --additional-properties=composerProjectName=my-project,composerVendorName=root,invokerPackage=MyOpenAPIBundle,bundleName=MyOpenAPI,bundleAlias=my_open_api

I followed the readme produced by the generator, configured autoload, added my bundle to registerBundles() in AppKernel.php.

The problem occur when I am trying to implement one of the interfaces from the OpenAPI bundle inside the old original bundle.

What I’m trying in the original bundle ApiDataManager.php file :

  use MyOpenAPIBundleApiApiInterface;
  class ApiDataManager implements ApiInterface


    public function myFunc(InlineObject1 $param1, &$Code, array &$param2)
     return [];

The signature is exactly the same on both sides but I still have this error :

C:my-project>php bin/console server:run PHP Fatal error: Declaration
$param1, &$Code, array &$param2) must be compatible with
$param1, &$Code, array &$param2) in
C:my-projectsrcOriginalBundleManagerApiDataManager.php on line 16

Maybe I did bad at bundle install or generation ? Maybe I shouldn’t use a second bundle ? Maybe my autoloader is bad ? Thanks you very much for any hints you could share

Source: Symfony Questions