MantisBT - Xdebug
View Issue Details
0001540XdebugCode Coveragepublic2018-03-26 15:312018-12-17 09:54
theoboldt 
 
normalmajoralways
newopen 
LinuxUbuntu16.04.1
2.6.0 
 
ubuntu0.16.04.1
7.0.25-7.0.29
0001540: Multiline class instantiate within method call is not covered when using php-fpm
When instantiating a class within a method call and the variables for the new object are passed in separate lines, the lines containing the parameters are not marked as covered when php is executed by FPM. The lines are marked as covered as expected when the same file is executed via CLI using same php/xdebug version.

{code}
//TEST
class A {
    public function b($a, $b, $c, $d) {
        return new B(
            $a,
            $b,
            $c,
            $d
        );
    }
}

class B {
    public function __construct($a, $b, $c, bool $d) { }
}

xdebug_start_code_coverage(XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE);
$a = new A();
$b = $a->b(
    'a',
    'b',
    'c',
    'd'
);
$coverage = xdebug_get_code_coverage();
xdebug_stop_code_coverage();


//EVALUATE (not part of proof)
echo "
\n";
print_r(
    [
        'phpversion(\'xdebug\')' => phpversion('xdebug'),
        'phpversion()' => phpversion(),
        'php_sapi_name()' => php_sapi_name()
    ]
);
print_r($coverage);
{code}

When executing above code via CLI, following output is generated:
{code}

Array
(
    [phpversion('xdebug')] => 2.6.0
    [phpversion()] => 7.0.28-0ubuntu0.16.04.1
    [php_sapi_name()] => cli
)
Array
(
    [/intproj/users/erik/xdebug_coverage_issues/multiline_class_instantiate.php] => Array
        (
            [11] => 1
            [12] => 1
            [13] => 1
            [14] => 1
            [15] => 1
            [21] => 1
            [25] => 1
            [26] => 1
            [27] => 1
            [28] => 1
            [29] => 1
            [30] => 1
            [32] => 1
        )
)
{code}

When executing above code via Apache 2 (Server API: FPM/FastCGI, PHP API: 20151012, PHP Extension: 20151012) the output differs significantly for line 12, 13, 14, 15:
{code}
Array
(
    [phpversion('xdebug')] => 2.6.0
    [phpversion()] => 7.0.28-0ubuntu0.16.04.1
    [php_sapi_name()] => fpm-fcgi
)
Array
(
    [/intproj/users/erik/xdebug_coverage_issues/multiline_class_instantiate.php] => Array
        (
            [11] => 1
            [12] => -1
            [13] => -1
            [14] => -1
            [15] => -1
            [21] => 1
            [25] => 1
            [26] => 1
            [30] => 1
            [32] => 1
        )
)
{code}
Execute provided snipped via php-fpm and via cli as well, compare results
PHP7
? multiline_class_instantiate.php (838) 2018-03-26 15:31
https://bugs.xdebug.org/file_download.php?file_id=429&type=bug
pdf 512.pdf (21,186) 2018-12-03 13:18
https://bugs.xdebug.org/file_download.php?file_id=444&type=bug
gz 514.gz (10,334) 2018-12-07 08:46
https://bugs.xdebug.org/file_download.php?file_id=445&type=bug
gz 515.gz (9,903) 2018-12-07 08:57
https://bugs.xdebug.org/file_download.php?file_id=446&type=bug
Issue History
2018-03-26 15:31theoboldtNew Issue
2018-03-26 15:31theoboldtFile Added: multiline_class_instantiate.php
2018-03-26 15:48theoboldtTag Attached: PHP7
2018-11-15 10:54theoboldtNote Added: 0004723
2018-12-03 13:18Markus34File Added: 512.pdf
2018-12-06 15:27theoboldtNote Added: 0004751
2018-12-06 15:33theoboldtNote Added: 0004752
2018-12-06 15:33theoboldtNote Edited: 0004752bug_revision_view_page.php?bugnote_id=4752#r463
2018-12-07 08:46Markus34File Added: 514.gz
2018-12-07 08:57Markus34File Added: 515.gz
2018-12-17 09:40Markus34Note Added: 0004771
2018-12-17 09:40Markus34Note Edited: 0004771bug_revision_view_page.php?bugnote_id=4771#r469
2018-12-17 09:54Markus34Note Edited: 0004771bug_revision_view_page.php?bugnote_id=4771#r470

Notes
(0004723)
theoboldt   
2018-11-15 10:54   
Still reproducible using xdebug 2.6.1.
(0004751)
theoboldt   
2018-12-06 15:27   
Reproducible also having opcache disabled:
{code}
Array
(
    [phpversion('xdebug')] => 2.6.0
    [phpversion()] => 7.0.32-0ubuntu0.16.04.1
    [php_sapi_name()] => fpm-fcgi
)
Array
(
    [/intproj/users/erik/multiline_class_instantiate.php] => Array
        (
            [11] => 1
            [12] => -1
            [13] => -1
            [14] => -1
            [15] => -1
            [17] => -2
            [21] => 1
            [25] => 1
            [26] => 1
            [30] => 1
            [32] => 1
        )
)
{code}
(0004752)
theoboldt   
2018-12-06 15:33   
Also reproducible using php 7.2:

opcache enabled:
{code}
Array
(
    [phpversion('xdebug')] => 2.6.0
    [phpversion()] => 7.2.10-0ubuntu0.18.04.1
    [php_sapi_name()] => fpm-fcgi
)
Array
(
    [/intproj/users/erik/multiline_class_instantiate.php] => Array
        (
            [11] => 1
            [12] => -1
            [13] => -1
            [14] => -1
            [15] => -1
            [21] => 1
            [25] => 1
            [26] => 1
            [30] => 1
            [32] => 1
        )
)
{code}

opcache disabled:
{code}
Array
(
    [phpversion('xdebug')] => 2.6.0
    [phpversion()] => 7.2.10-0ubuntu0.18.04.1
    [php_sapi_name()] => fpm-fcgi
)
Array
(
    [/intproj/users/erik/multiline_class_instantiate.php] => Array
        (
            [11] => 1
            [12] => -1
            [13] => -1
            [14] => -1
            [15] => -1
            [17] => -2
            [21] => 1
            [25] => 1
            [26] => 1
            [30] => 1
            [32] => 1
        )
)
{code}

(0004771)
Markus34   
2018-12-17 09:40   
(edited on: 2018-12-17 09:54)
Reproducible also having opcache disabled:
{code}
Array
(
    [phpversion('xdebug')] => 2.6.0
    [phpversion()] => 7.0.32-0ubuntu0.16.04.1
    [php_sapi_name()] => fpm-fcgi
)
Array
(
    [/intproj/users/erik/multiline_class_instantiate.php] => Array
        (
            [11] => 1
            [12] => -1
            [13] => -1
            [14] => -1
            [15] => -1
            [17] => -2
            [21] => 1
            [25] => 1
            [26] => 1
            [30] => 1
            [32] => 1
        )
)
{code}

------------
0001540 https://goo.gl/b7GTEb [^]