View Issue Details

IDProjectCategoryView StatusLast Update
0001601XdebugCode Coveragepublic2019-01-23 10:45
ReporterexussumAssigned Toderick 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionno change required 
PlatformLinuxOSUbuntu 18.04OS Version
Product Version2.6.1 
Target VersionFixed in Version 
Summary0001601: Line shown as covered when not been run
DescriptionLine shown as covered when not been run
Steps To Reproduce<?php

function test() {
    foreach([1,2] as $a) {
        if (false) {
            try {
                echo "Try";
            } catch (Exception $e) {
                echo "Catch";
            }
        }
    }
}

xdebug_start_code_coverage(XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE);
test();
var_dump(xdebug_get_code_coverage());
xdebug_stop_code_coverage();



The catch line (line 9) is shown as covered, when its not.
Additional InformationRunning the above script line 9 should show as -1, its showing as 1

I get the following.

/tmp/test.php:17:
array(1) {
  '/tmp/test.php' =>
  array(8) {
    [4] =>
    int(1)
    [5] =>
    int(1)
    [7] =>
    int(-1)
    [8] =>
    int(-1)
    [9] =>
    int(1)
    [13] =>
    int(1)
    [16] =>
    int(1)
    [17] =>
    int(1)
  }
}

xdebug 2.6.1 on php 5.6 works as expected,m it seems 7.0+ has this error
TagsNo tags attached.
Operating System
PHP Version7.2.5-7.2.9

Activities

exussum

2019-01-03 13:49

reporter  

test.php (364 bytes)

exussum

2019-01-03 13:50

reporter   ~0004794

Done some more checking, the if can be removed, its the loop and the catch which causes this

exussum

2019-01-05 08:52

reporter   ~0004795

Sorry can be closed just found the fix in PHP

derick

2019-01-22 22:20

administrator   ~0004830

Ah, great, as I could not reproduce this with PHP 7.2.14 and Xdebug 2.6.1 (or 2.7.0dev). Could you be so kind to link to the PHP issue perhaps?

exussum

2019-01-23 06:40

reporter   ~0004838

Sorry I never attached as it was you who reported. https://bugs.php.net/bug.php?id=76046 after an update of PHP all works

Thanks

derick

2019-01-23 10:45

administrator   ~0004840

Ah, okay :-) Thanks for confirming that. I'll close this report then.

Issue History

Date Modified Username Field Change
2019-01-03 13:49 exussum New Issue
2019-01-03 13:49 exussum File Added: test.php
2019-01-03 13:50 exussum Note Added: 0004794
2019-01-05 08:52 exussum Note Added: 0004795
2019-01-22 22:20 derick Note Added: 0004830
2019-01-22 22:20 derick Assigned To => derick
2019-01-22 22:20 derick Status new => feedback
2019-01-23 06:40 exussum Note Added: 0004838
2019-01-23 06:40 exussum Status feedback => assigned
2019-01-23 10:45 derick Note Added: 0004840
2019-01-23 10:45 derick Status assigned => resolved
2019-01-23 10:45 derick Resolution open => no change required