-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Start line of class is reported to be start line of attribute when class has attribute #886
Comments
Probably connected to #762
|
Sounds reasonable (that it's connected to #762). I now worked around this like so: https://github.com/sebastianbergmann/php-code-coverage/blob/9.2/src/StaticAnalysis/IgnoredLinesFindingVisitor.php#L75 |
|
Just to be sure - if unmitigated, this completely destroys the format-preserving pretty printer for affected code, right? |
@rulatir It should work fine. In fact, the current behavior of considering attributes part of the class is a requirement for making formatting preservation work. Are you seeing any issues with this? |
No, I am diving into using this library for the first time in ~4y, so I took a look at the open issues list and it just happens that the 2nd from the top seems to affect my use case. Glad the format preserving prettyprint can be hoped to work. |
This is working as intended as far as I'm concerned. Taking the line of the name seems like a reasonably low effort workaround if you don't want to count the attributes. |
I ran into the following situation while implementing support for PHPUnit 10's
PHPUnit\Framework\Attributes\CodeCoverageIgnore
attribute tophpunit/php-code-coverage
(which uses PHP-Parser for static analysis):Reproducing example
Actual output
Expected output
The fact that PHP-Parser considers the line with
#[Bar]
to be the starting line of the class declaration ofFoo
is, at least to me, unexpected.I am not sure whether this is the correct behaviour or if I stumbled upon a bug.
The text was updated successfully, but these errors were encountered: