doctrine / annotations

Annotations Docblock Parser
https://www.doctrine-project.org/projects/annotations.html
MIT License
6.74k stars 235 forks source link

Bug with PhpParser when instantiating the Tokenizer #490

Open odahcam opened 1 year ago

odahcam commented 1 year ago

Reference:

https://github.com/doctrine/annotations/blame/6d4929214d8593ed80364267d6665edd70c2ecbe/lib/Doctrine/Common/Annotations/PhpParser.php#L60

This piece of code prepends a "<?php " string to the original content, but if the content already has the "<?php " opening tag, it errors and breaks the runtime.

odahcam commented 1 year ago

It has something to do with an anonymous class, the reflection class returns no namespace for it, even though it is on a namespaced file. To be honest I don't know if it should return a namespace or not, I also don't remember how anonymous functions behave in that scenario. Anyhow I think there could be a condition for this kind of class: https://github.com/doctrine/annotations/pull/491/files