phpdoc-parser icon indicating copy to clipboard operation
phpdoc-parser copied to clipboard

Method tag is missing return by reference

Open jaapio opened this issue 3 years ago • 2 comments

The MethodTagValue doesn't contain an property returnsReference. This is not a very common option to use but we found a few of them in the wild.

Full blown example will look like this:

/** @method static Type &myMethod() description here */

I will provide a PR later when ready with other things.

jaapio avatar Oct 28 '22 19:10 jaapio

Looks like this is much harder than I thought... the type parser consumes the tokens as types. so in my example, the return type will be Type & myMethod which is obviously wrong...

This requires some more time from my side to figure out how to do this. @rvanvelzen any suggestions? Should I use a rollback point to restore and make the type parser consume less in this case? Some look ahead is required here I think.

For reference: https://github.com/phpDocumentor/ReflectionDocBlock/blob/master/src/DocBlock/Tags/Method.php#L125

jaapio avatar Nov 15 '22 22:11 jaapio

It's probably best to leave the type parser alone, and with a little bit of hacking I came up with something that should work: https://gist.github.com/rvanvelzen/ff2d187490aa3a810902a4731e350995

Feel free to use it :)

rvanvelzen avatar Nov 17 '22 12:11 rvanvelzen