Closed micaherne closed 4 months ago
This is with the latest dev-main 85e9e0a.
Hi @micaherne ,
thanks for reporting the problem, it looks really ugly! I'll give a try to it now, looking forward an acceptable solution, thanks!
Ok, tracing down the problem it seems that the troubles are caused by Docblocks::getDocBlockPointer()
that, when invoked for an arbitrary pointer (for example, the <php
open tag, that uses to be pointer = 0) it's returning the FIRST phpdoc block in the file (in your case corresponding to the $plugins
type-hinting block). And that's a bug.
In the mean time, and as a workaround, I think that if you add the file or class phpdoc block (the later is preferred in modern code), then you won't face the problem (it only happens when both phpdoc blocks are missing). If any of the blocks exist... then the fixer works ok, so far.
I'm creating a test and, hopefully, a fix... ciao :-)
I've created #173 that, hopefully, fixes this edge case (it's really edge!). In any case, if accepted, it will also save a few iterations when looking for those file phpdoc blocks. 🤞
Ciao :-)
@micaherne , if you've any other case, different (structurally), from the above, it would be great to know about it. With the proposed patch, I think we are covered for any other combination.
Ciao :-)
Brilliant, thanks @stronk7! I haven't spotted any other issues with it so hopefully that'll be it.
I'm seeing multiple issues with PackageSniff with code similar to this:
PHPCS is correctly identifying that there is no package tag:
But running the fix gives these two issues:
It tries to add the tag to the inline docblock where it's clearly not appropriate.
In the first pass it adds the tag to the end of the inline comment on the same line:
This is then detected as still violating the sniff, so it runs a second pass and adds it again on the line with the closing tag.
So the final diff is this: