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

Importing classes named after common phpdoc annotations #317

Closed
j6s opened this issue Apr 2, 2020 · 11 comments · Fixed by #318
Closed

Importing classes named after common phpdoc annotations #317

j6s opened this issue Apr 2, 2020 · 11 comments · Fixed by #318
Assignees
Labels
Milestone

Comments

@j6s
Copy link

j6s commented Apr 2, 2020

Since upgrading to the new doctrine/annotations 1.10.0 release it fails to analyze classes that use phpdocumentor/reflection-docblock:

[Semantical Error] The class "phpDocumentor\Reflection\DocBlock\Tags\Param" is not annotated with @Annotation.
Are you sure this class can be used as annotation? [...]

At first I thought the following in the Param class itself would be the issue:

/**
 * Reflection class for the {@}param tag in a Docblock.
 */

but the longer I read the error message the more I am convinced, that my class that imports phpDocumentor\Reflection\DocBlock\Tags\Param and then uses @param in docblocks is at fault: Seems like the @param is being interpreted as a reference to the Param class which is not an annotation.

I will report back to this ticket after having conducted a couple of tests.

@j6s j6s changed the title doctrine/annotations 1.10.0 <> phpdocumentor/reflection-docblock issues Importing classes named after common phpdoc annotations Apr 2, 2020
@bwaidelich
Copy link

Yes, 1.9 => 1.10 seemed to introduce a breaking change here.
We also see

[Semantical Error] The class "PHPUnit\Framework\Error\Deprecated" is not annotated with @Annotation.

in our CI

@albe
Copy link
Contributor

albe commented Apr 2, 2020

I can confirm there is some breaking change in the new release, leading to wrong classes be autoloaded for annotations.

For example here:
https://travis-ci.org/github/neos/flow-development-collection/jobs/670069940#L996
The @deprecated tag in a PHPUnit test suddenly tries to load PHPUnit\Framework\Error\Deprecated as an annotation class, which is obviously wrong.

@j6s
Copy link
Author

j6s commented Apr 2, 2020

Confirming my suspicion: Changing

use phpDocumentor\Reflection\DocBlock\Tags\Param;

to

phpDocumentor\Reflection\DocBlock\Tags\Param as DocumentorParam;

Fixes the issue in my specific case

@param in docblocks is being resolved to the Param class reference

@stof
Copy link
Member

stof commented Apr 2, 2020

@alcaeus could it be caused by #316 ?

@albe
Copy link
Contributor

albe commented Apr 2, 2020

Either that or #271 - which I think is more likely, as it adds the autoloading fallback, which in turn sounds like a good explanation for loading @param as the class that was imported.

@alcaeus
Copy link
Member

alcaeus commented Apr 2, 2020

@alcaeus could it be caused by #316 ?

@j6s @albe @bwaidelich could you please test 1.9.0 and see if that fixes the issue? The PR mentioned by @stof was not included in that release, so this would help me figure out where this goes wrong.

I'll see if I can cook up a test case in the meantime.

@j6s
Copy link
Author

j6s commented Apr 2, 2020

I can confirm, that 1.9.0 does not have this issue - the issue was introduced with 1.10.0

@alcaeus
Copy link
Member

alcaeus commented Apr 2, 2020

Thanks! That narrows it down to two potential PRs and I've got a good suspicion that neither is responsible by itself. Please sit tight for a few minutes and use a release < 1.10 in the meantime. Sorry for the disruption.

@alcaeus
Copy link
Member

alcaeus commented Apr 2, 2020

Can you please check the changes from #318 to see if it fixes this for you or breaks anything else? Thanks!

@alcaeus alcaeus self-assigned this Apr 2, 2020
@alcaeus alcaeus added the bug label Apr 2, 2020
@alcaeus alcaeus added this to the 1.10.1 milestone Apr 2, 2020
@bwaidelich
Copy link

@alcaeus Yes, I can confirm that #318 fixes the issue for us. Thanks for the swift reaction!

@alcaeus alcaeus closed this as completed Apr 2, 2020
@alcaeus
Copy link
Member

alcaeus commented Apr 2, 2020

1.10.1 is released. Thanks for bringing this to our attention and confirming the fix! 🎉

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

Successfully merging a pull request may close this issue.

5 participants