sebastianbergmann/phpunit-documentation

Code Coverage edge case - Multiline use statments

Garbee opened this issue · 5 comments

I think I've found a new edge-case for the code coverage that should get documented in case others hit it.

Example Code
<?php
use PHPUnit\Framework\TestCase;

// Because it is "line based" and not statement base coverage
// the variables for "use" are shown as not covered.
$someObject->reduce(function () use (
    $outerItem,
    $anotherOuterItem
) {
   return false;
});

// You either need to reduce it to a single-line statement
// Or add @codeCoverageIgnore[Start|End] comments
//@codeCoverageIgnoreStart
$someObject->reduce(function () use (
    $outerItem,
    $anotherOuterItem
) {
    //@codeCoverageIgnoreEnd
    return false;
});
?>

If there is a way to fix this without compressing into a single-line I'd love to hear it. Otherwise I feel this warrants documenting since it does seem quirky.

Thank you,
Garbee

@derickr What do you think?

And fixed for Xdebug 2.5.2: xdebug/xdebug#332

Oh fantastic!

Thank you so much, I didn't look into filing an issue upstream. Figured it would have been a known issue.

Have a great day.