Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncovered line with array_merge() and require() in PHP 7.4 #719

Closed
BluePsyduck opened this issue Jan 9, 2020 · 2 comments
Closed

Uncovered line with array_merge() and require() in PHP 7.4 #719

BluePsyduck opened this issue Jan 9, 2020 · 2 comments
Labels

Comments

@BluePsyduck
Copy link

@BluePsyduck BluePsyduck commented Jan 9, 2020

Q A
php-code-coverage version 7.0.10
PHP version 7.4.1
Driver Xdebug
Xdebug version (if used) 2.9.0
Installation Method Composer
Usage Method PHPUnit
PHPUnit version (if used) 8.5.2

I found an issue with the coverage reports when array_merging some configuration files.

<?php
declare(strict_types=1);
namespace FancyNamespace;

class ConfigProvider
{
    public function __invoke(): array
    {
        return array_merge(
            require(__DIR__ . '/foo.php'), 
            require(__DIR__ . '/bar.php'),
        );
    }
}

Note that the files included have simple contents like <?php return ['foo' => 'bar']; each, i.e. the array_merge() can properly do its work.

The coverage report shows that the line with require(foo) is not covered:
coverage

Some observations of the issue:

  • There must be at least two files included. A single file is correctly covered, more files have only the last require line covered respectively.
  • This issue started appearing with PHP 7.4, reports under PHP 7.3 do not show this problem.

It would be nice if you could look into it.

@sebastianbergmann

This comment has been minimized.

Copy link
Owner

@sebastianbergmann sebastianbergmann commented Jan 10, 2020

@derickr

This comment has been minimized.

Copy link

@derickr derickr commented Jan 10, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.