Skip to content

With 3.2.4 I can't inject AnnotationReader anymore #21648

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

Closed
lbayerl opened this issue Feb 17, 2017 · 4 comments
Closed

With 3.2.4 I can't inject AnnotationReader anymore #21648

lbayerl opened this issue Feb 17, 2017 · 4 comments

Comments

@lbayerl
Copy link

lbayerl commented Feb 17, 2017

Q A
Bug report? yes
Feature request? no
BC Break report? yes
RFC? no
Symfony version 3.2.4

Trying to inject AnnotationReader $reader in a service with `arguments: ['@annotation_reader'] worked fine in Symfony 3.2.3 but since upgrading to 3.2.4 it fails with:

construct() must be an instance of Doctrine\Common\Annotations\AnnotationReader, instance of Doctrine\Common\Annotations\CachedReader given

Might be worth mentioning that I am trying to inject it in an EventListener:

    request_cache_listener:
        class: MyCompany\MyBundle\EventListener\MyRequestListener
        arguments: ['@annotation_reader']
        tags:
            - { name: kernel.event_listener, event: kernel.controller, method: onKernelController }
            - { name: kernel.event_listener, event: kernel.response, method: onKernelResponse }

This is probably caused by: #21556

@nicolas-grekas
Copy link
Member

That's a bug in your type hints: you should type hint against the interface, not against the implementation.
Reader is the interface - and there are two implemetations: AnnotationReader and CachedReader.

@stof
Copy link
Member

stof commented Feb 17, 2017

you should typehint the Doctrine interface (i.e. \Doctrine\Common\Annotations\Reader), not the Doctrine implementation. Otherwise, you forbid using the cached implementation.

Btw, 3.2.2 and older were also using the cached version. Using the uncached implementation is a bug introduced in 3.2.3 (and with a huge impact on performance)

@stof
Copy link
Member

stof commented Feb 17, 2017

closing this issue because the actual issue is not in Symfony (and we will not reintroduce the performance regression for people starting to rely on the bug introduced in a single release)

@stof stof closed this as completed Feb 17, 2017
@lbayerl
Copy link
Author

lbayerl commented Feb 17, 2017

thanks, got it.

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