Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecation warning about return type declaration for JMSHandlerRegistryV2 in Symfony 5.4 #2353

Open
DevMcC opened this issue Dec 9, 2021 · 2 comments

Comments

@DevMcC
Copy link

DevMcC commented Dec 9, 2021

I recently upgraded to Symfony 5.4 and now I am receiving a deprecration warning about JMSHandlerRegistryV2:

[2021-12-09T11:52:40.460108+01:00] php.INFO: User Deprecated: Method "JMS\Serializer\Handler\HandlerRegistryInterface::getHandler()" might add "callable|object" as a native return type declaration in the future. Do the same in implementation "FOS\RestBundle\Serializer\JMSHandlerRegistryV2" now to avoid errors or add an explicit @return annotation to suppress this message. {"exception":"[object] (ErrorException(code: 0): User Deprecated: Method \"JMS\\Serializer\\Handler\\HandlerRegistryInterface::getHandler()\" might add \"callable|object\" as a native return type declaration in the future. Do the same in implementation \"FOS\\RestBundle\\Serializer\\JMSHandlerRegistryV2\" now to avoid errors or add an explicit @return annotation to suppress this message. at /app/vendor/symfony/error-handler/DebugClassLoader.php:325)"} []

I can't seem to fix this deprecration in my project, so I think it can only be fixed in here instead.
If wanted, I can create a PR to fix this.

I fixed the deprecation in the vendor folder by adding @return to the getHandler method:

    /**
     * {@inheritdoc}
+     *
+     * @return callable|object
     */
    public function getHandler(int $direction, string $typeName, string $format)

Reproduction path:

  • Install Symfony 5.4
  • Install FOS RestBundle 3.1
  • Run bin/console
  • See deprecration warning
@ko4a
Copy link

ko4a commented Feb 7, 2022

Hi
are there any updates ? :)

@pburggraf
Copy link

Suppressing the deprecation messages here in this project is probably the wrong way as the "problem" is based on the external interface "HandlerRegistryInterface".

These message should be considered as a hint for the developer to use native return types instead of just rely on doctypes.
For reference and better explaination see the following links:
symfony/symfony#44802 (comment)
sebastianbergmann/php-file-iterator#74

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants