View Issue Details

IDProjectCategoryView StatusLast Update
0000872XdebugUncategorizedpublic2016-11-28 23:35
Reportersebastian Assigned Toderick  
PriorityurgentSeveritymajorReproducibilityalways
Status resolvedResolutionno change required 
PlatformIrrelevantOSIrrelevantOS VersionIrrelevant
Product Version2.2dev 
Summary0000872: xdebug_get_code_coverage() returns bogus array elements
Description

While looking at various open issues for PHP_CodeCoverage today, I noticed that for some files xdebug_get_code_coverage() returns bogus array elements: elements for lines that do not exist in a covered file. These lines are 0 and N+1 where N is the last line of the file.

This is the array I get for https://github.com/thePHPcc/bankaccount/blob/master/src/controller/BankAccount.php

array(17) {
[0] =>
int(1)
[10] =>
int(1)
[16] =>
int(1)
[17] =>
int(1)
[22] =>
int(1)
[25] =>
int(1)
[26] =>
int(-1)
[30] =>
int(1)
[33] =>
int(1)
[34] =>
int(-1)
[35] =>
int(-1)
[36] =>
int(-1)
[39] =>
int(1)
[40] =>
int(1)
[42] =>
int(1)
[43] =>
int(-2)
[45] =>
int(1)
}

As you can see in the file, lines 0 and 45 do not exist.

Additional Information

I am using PHP 5.4.5-dev and Xdebug v2.3.0dev.

TagsNo tags attached.
Operating SystemIrrelevant
PHP Version5.1.0

Activities

derick

2012-08-30 21:04

administrator   ~0002336

VLD shows that PHP thinks line 45 has some code:

44 9 ZEND_VERIFY_ABSTRACT_CLASS $0
45 10 > RETURN 1

Trying to find the 0 now...

hanshenrik

2012-10-01 17:41

reporter   ~0002354

Last edited: 2012-10-01 17:42

i suggest checking what token_get_all() returns about line 45 (if anything)

(btw, at least atm, the link to sample file is 404)

derick

2012-11-11 13:02

administrator   ~0002382

I have not found the 0 yet, but now the example script is gone... suspending for now.

sebastian

2013-11-13 10:53

reporter   ~0002615

I am seeing the issue with line number 0 in my https://github.com/sebastianbergmann/money for the src/Money.php file.

However, outside of PHPUnit and this specific test suite I cannot provide a short reproducing script other than the following:

<?php
require '/usr/local/src/money/src/autoload.php';

use SebastianBergmann\Money\Money;
use SebastianBergmann\Money\Currency;

xdebug_start_code_coverage(XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE);
new Money(0, new Currency('EUR'));
$data = xdebug_get_code_coverage();
xdebug_stop_code_coverage();
var_dump($data);
?>

This prints, among data for the other files loaded, the following:

'/home/sb/test.php' =>
array(3) {
[0] =>
int(1)
[8] =>
int(1)
[9] =>
int(1)
}

derick

2016-11-28 21:27

administrator   ~0003827

Is this specific code coverage related issue still cause a problem for you?

sebastian

2016-11-28 21:38

reporter   ~0003833

No.

derick

2016-11-28 23:35

administrator   ~0003838

Okay - let me close this then.

Issue History

Date Modified Username Field Change
2012-08-07 14:50 sebastian New Issue
2012-08-30 21:04 derick Note Added: 0002336
2012-10-01 17:41 hanshenrik Note Added: 0002354
2012-10-01 17:42 hanshenrik Note Edited: 0002354
2012-11-11 13:02 derick Note Added: 0002382
2012-11-11 13:02 derick Status new => resolved
2012-11-11 13:02 derick Resolution open => suspended
2012-11-11 13:02 derick Assigned To => derick
2013-11-13 10:53 sebastian PHP Version 5.4-dev => 5.5-dev
2013-11-13 10:53 sebastian Note Added: 0002615
2013-11-13 10:53 sebastian Status resolved => feedback
2013-11-13 10:53 sebastian Resolution suspended => reopened
2014-03-05 09:16 derick Status feedback => assigned
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)
2016-11-28 21:27 derick PHP Version 5.5-dev => 5.1.0
2016-11-28 21:27 derick Note Added: 0003827
2016-11-28 21:27 derick Status assigned => feedback
2016-11-28 21:38 sebastian Note Added: 0003833
2016-11-28 21:38 sebastian Status feedback => assigned
2016-11-28 23:35 derick Note Added: 0003838
2016-11-28 23:35 derick Status assigned => resolved
2016-11-28 23:35 derick Resolution reopened => no change required
2020-03-12 16:35 derick Category Usage problems (Wrong Results) => Variable Display
2020-03-12 16:38 derick Category Variable Display => Uncategorized