View Issue Details

IDProjectCategoryView StatusLast Update
0000829XdebugCode Coveragepublic2020-03-12 17:13
Reporterphon Assigned Toderick  
PrioritynormalSeverityfeatureReproducibilityalways
Status resolvedResolutionnot fixable 
Product Version2.2.0 
Target Version2.2.1Fixed in Version2.2.1 
Summary0000829: Code coverage is wrong when using dim assign
Description

Description:

<?php
xdebug_start_code_coverage();

$result = array(
"ret" => 0,
"msg" => 'test'
);

var_dump(xdebug_get_code_coverage());

?>

Expected result:

array(1) {
'/data/xdebug/test.php' =>
array(3) {
[4] =>
int(1)
[9] =>
int(1)
}
}

Actual result:

array(1) {
'/data/xdebug/test.php' =>
array(3) {
[5] =>
int(1)
[7] =>
int(1)
[9] =>
int(1)
}
}

TagsNo tags attached.
Operating System
PHP Version5.2.10

Activities

derick

2012-05-28 12:10

administrator   ~0002210

Last edited: 2012-05-28 12:14

Sadly, this is not something I can fix. PHP is a bit weird with array assignments. Internally, the code that PHP sees is:


compiled vars: !0 = $result
line # * op fetch ext return operands

2 0 > EXT_STMT
1 EXT_FCALL_BEGIN
2 DO_FCALL 0 'xdebug_start_code_coverage'

     3      EXT_FCALL_END                                            

5 4 EXT_STMT
5 INIT_ARRAY 0000002:0000001 0, 'ret'
7 6 ADD_ARRAY_ELEMENT 0000002:0000001 'test', 'msg'
7 ASSIGN !0, 0000002:0000001
9 8 EXT_STMT
9 EXT_FCALL_BEGIN
10 EXT_FCALL_BEGIN
11 DO_FCALL 0 $3 'xdebug_get_code_coverage'

    12      EXT_FCALL_END                                            
    13      SEND_VAR_NO_REF                               6          $3
    14      DO_FCALL                                      1          'var_dump'
    15      EXT_FCALL_END                                            

12 16 EXT_STMT
17 > RETURN 1

With the array init and assignment on line 5 and 7:


5 4 EXT_STMT
5 INIT_ARRAY 0000002:0000001 0, 'ret'
7 6 ADD_ARRAY_ELEMENT 0000002:0000001 'test', 'msg'
7 ASSIGN !0, 0000002:0000001

Issue History

Date Modified Username Field Change
2012-05-10 09:02 phon New Issue
2012-05-28 08:25 derick Target Version => 2.2.1
2012-05-28 12:10 derick Note Added: 0002210
2012-05-28 12:10 derick Status new => resolved
2012-05-28 12:10 derick Resolution open => not fixable
2012-05-28 12:10 derick Assigned To => derick
2012-05-28 12:12 derick Note Edited: 0002210
2012-05-28 12:13 derick Note Edited: 0002210
2012-05-28 12:13 derick Note Edited: 0002210
2012-05-28 12:14 derick Note Edited: 0002210
2012-07-14 19:38 derick Fixed in Version => 2.2.1
2020-03-12 16:55 derick Severity minor => feature
2020-03-12 17:13 derick Category Feature/Change request => Code Coverage