Skip to content

[BUG][PHP][Symfony] Warning OpenAPIServerBundle::build() should explicitely say it returns void #15959

@gturri

Description

@gturri

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

When I use a Symfony bundle generated by openApiGenerator, Symfony display this warning:

Method "Symfony\Component\HttpKernel\Bundle\Bundle::build()" might add "void" as a native return type declaration in the future. Do the same in child class "OpenAPI\Server\OpenAPIServerBundle" now to avoid errors or add an explicit @return annotation to suppress this message

openapi-generator version

I've observed this behavior with openapi-generator 6.6.0. I've also reproduced it with a version built from source with today's master branch (d5c53b9)

OpenAPI declaration file content or url

It can be observed with any OpenAPI file. Let's take for instance this simple one:

openapi: 3.0.1
info:
  title: Test
  version: 0.0.1
paths:
  /my-route:
    get:
      summary: Get stuff
      responses:
        "200":
          description: OK
Generation Details
java -jar openapi.jar generate --git-user-id "userid" --git-repo-id "repoid" -i "openapi.yaml" -g php-symfony -o "out"
Steps to reproduce

Plus the generated Symfony bundle into a Symfony app (following the steps in the auto-generated README). Then launch the Symfony server (symfony server:start --no-tls) and perform a query against this route curl http://localhost:8000/my-route

Expected behavior: Symfony handle this query without outputting warning because of the generated code.
Actual behavior: Symfony output this warning (on the server stdout):
Method "Symfony\Component\HttpKernel\Bundle\Bundle::build()" might add "void" as a native return type declaration in the future. Do the same in child class "OpenAPI\Server\OpenAPIServerBundle" now to avoid errors or add an explicit @return annotation to suppress this message

(nb: there is another similar warning, related to a method in the jms/serializer-bundle package. I'm leaving it out of the scope of this bug report because I think it would deserve its own bug report (because the fix would not really be the same since that other warning would rather imply a bump of that jms package))

Related issues/PRs

I searched for related issues and PRs, but did not found any.

Suggest a fix

The fix is easy: we just need to declare a void return type for that method, by editing modules/openapi-generator/src/main/resources/php-symfony/Bundle.mustache . This is fixed by PR #15960

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions