phpdoc-parser
phpdoc-parser copied to clipboard
Fix global variables wrongly parsed
Fixes issue #230 by checking if the variable is global before assigning it to the $this->last_doc.
We also need to reset the last doc to null, when we declare a function/method, as otherwise it will apply the tags in cases like:
/**
* @deprecated some text
*/
add_filter( 'foo', 'bar' );
/**
* @deprecated other text
*/
function hello() {
return apply_filters( 'my_filter', '' );
}
"my_filter" will suddenly have the @deprecated some text comment added, even though it's completely irrelevant
Just add $this->last_doc = null; before this line https://github.com/WordPress/phpdoc-parser/blob/6540706a2a08648aad1e8a0d5ba0bc50c3ea4f45/lib/class-file-reflector.php#L74