phpDocumentor icon indicating copy to clipboard operation
phpDocumentor copied to clipboard

referenced parameters not recognized

Open flack opened this issue 9 years ago • 6 comments

I have a docblock looking like this:

/**
 * Summary
 *
 * @param array &$args Parameter description
 */
public function test(array &$args)

This produces an error in the log to the effect that no documentation for $args was found. Also, in the rendered documentation (at least in clean and responsive themes) the & sign is not rendered in the signature, so that by reading the API doc you have no idea that this is a reference.

flack avatar Aug 26 '14 22:08 flack

Hi @flack,

You don't need to pass the ampersand (&) to the DocBlock's @param tag; phpDocumentor reads that from the signature. The Clean theme should show that it is a reference, we will have to take a look why that is not showing.

mvriel avatar Aug 30 '14 19:08 mvriel

Hi @mvriel

I just tried removing the ampersand from one of the affected docblocks, and now, the error disappeared and the ampersand is rendered correctly in the documentation (I've tried with responsive-twig). So it seems that having the ampersand present in the docblock caused the original problem.

The codebase I'm working on is quite old, and these docblocks are still from the time when the documentation was generated by phpdocumentor1, which had the opposite behavior (i.e. if you didn't have the ampersand in the docblock, then you would get an error). Would you consider adding support for the ampersand in the @param tag to provide backwards compatibility?

If not, I guess I can just do one giant global seach and replace, but at least to my taste, it seems cleaner to write @param &$args

flack avatar Aug 30 '14 19:08 flack

I think it would not hurt to add backwards compatibility to this item

mvriel avatar Aug 30 '14 19:08 mvriel

Thanks! I'm looking forward to it. Let me know if there's anything I can do to help!

flack avatar Aug 30 '14 19:08 flack

I agree with @flack - documentation should be explicit, and should allow @param array &$var (or similar).

samlev avatar Oct 19 '15 16:10 samlev

Fixed in v3 release: image

jaapio avatar Nov 30 '21 20:11 jaapio