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

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
of
OriginalBundleManagerApiDataManager::myFunc(OriginalBundleManagerMyOpenAPIBundleModelInlineObject1
$param1, &$Code, array &$param2) must be compatible with
MyOpenAPIBundleApiApiInterface::myFunc(MyOpenAPIBundleModelInlineObject1
$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

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *