View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update | 
|---|---|---|---|---|---|
| 0001287 | Xdebug | Uncategorized | public | 2016-03-18 17:58 | 2016-05-10 19:45 | 
| Reporter | eZH | Assigned To | derick | ||
| Priority | normal | Severity | major | Reproducibility | always | 
| Status | resolved | Resolution | not fixable | ||
| Product Version | 2.4.0 | ||||
| Summary | 0001287: Code coverage: foreach next cycle is reported as wrong line under PHP7 | ||||
| Description | See attached script. | ||||
| Tags | No tags attached. | ||||
| Attached Files |  b.php (525 bytes)   
 <?php
xdebug_start_code_coverage();
foreach (['a', 'b'] as $item) {
    if ($item == 'c') {
        echo "c";
    }
    if ($item == 'd') {
        echo "d";
    }
}
$cc = xdebug_get_code_coverage()[__FILE__];
xdebug_stop_code_coverage();
$expected = [
    3 => 1,//foreach {
    4 => 1,//if ($item == 'c') {
    7 => 1,//if ($item == 'd') {
    10 => 1,//} endforeach
    11 => 1,//$cc = xdebug_get_code_coverage()[__FILE__];
];
assert($cc == $expected, print_r($cc, true) . ' is not equal to ' . print_r($expected, true));
 | ||||
| Operating System | |||||
| PHP Version | 7.0.0-7.0.4 | ||||
|  | You are right that Code Coverage shows the wrong line. Unfortunately, this is PHP generates for this code: 1 <?php The following opcodes: line #* E I O op fetch ext return operands2     0  E >   EXT_STMT Opcode 19 (FE_FREE) is the end of the foreach, but as you can see PHP still I recommend you file a bug report at http://bugs.php.net - and feel free to | 
| Date Modified | Username | Field | Change | 
|---|---|---|---|
| 2016-03-18 17:58 | eZH | New Issue | |
| 2016-03-18 17:58 | eZH | File Added: b.php | |
| 2016-05-10 19:45 | derick | Note Added: 0003591 | |
| 2016-05-10 19:45 | derick | Status | new => resolved | 
| 2016-05-10 19:45 | derick | Resolution | open => not fixable | 
| 2016-05-10 19:45 | derick | Assigned To | => derick | 
| 2016-07-31 12:36 | derick | Category | Usage problems => Usage problems (Crashes) | 
| 2016-07-31 12:38 | derick | Category | Usage problems (Crashes) => Usage problems (Wrong Results) | 
| 2020-03-12 16:35 | derick | Category | Usage problems (Wrong Results) => Variable Display | 
| 2020-03-12 16:38 | derick | Category | Variable Display => Uncategorized | 
