Closed mvorisek closed 1 year ago
CC @Slamdunk
Looking at here:
It seems to me that the CC is correctly reported both times:
public
, init()
is not called so it's redprotected
, init()
is called so it's greenThe #[\Override]
attribute has nothing to do with this.
I see no bug here :shrug:
@Slamdunk Thank you!
Looking at here:
It seems to me that the CC is correctly reported both times:
1. when the method is `public`, `init()` is **not** called so it's red 2. when the method is `protected`, `init()` **is** called so it's green
The
#[\Override]
attribute has nothing to do with this.I see no bug here 🤷
No, this is not what the issue is about.
see https://app.codecov.io/gh/atk4/core/blob/develop/tests%2FInitializerTraitTest.php#L50 and https://app.codecov.io/gh/atk4/core/blob/develop/tests%2FInitializerTraitTest.php#L72
when the method is defined as:
protected function init(): void {}
there is simply no red/green coverage at all, ie. coverage is not measured
when the method is reformatted to:
protected function init(): void
{
}
the coverage is then measured as expected, but the first format should be used per https://www.php-fig.org/per/coding-style/#4-classes-properties-and-methods
@mvorisek now it makes sense: fix proposed in https://github.com/sebastianbergmann/php-code-coverage/pull/1021
repro code:
(full source code: https://github.com/atk4/core/blob/5.0.0/tests/InitializerTraitTest.php#L72)
when the code above is modified like:
then the coverage is collected. It seems this lib does not account for single line methods (methods starting and ending at the same line, even a method attribute on another line is enough to enable coverage).