View Issue Details

IDProjectCategoryView StatusLast Update
0000401XdebugCode Coveragepublic2020-03-12 17:13
Reportersebastian Assigned To 
PrioritynormalSeverityfeatureReproducibilityalways
Status closedResolutionnot fixable 
Summary0000401: Code Coverage is wrong for if statement
Description
1 <?php
2 xdebug_start_code_coverage(XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE);
3
4 if (false)
5     print '*';
6
7 $codeCoverage = xdebug_get_code_coverage();
8 xdebug_stop_code_coverage();
9

10 print_r($codeCoverage);

This results in

Array
(
[/home/sb/test.php] => Array
(
[5] => 1
[7] => 1
)
)

which is wrong as line 5 is not executed.

Adding braces for the if() block changes things a bit:

1 <?php
2 xdebug_start_code_coverage(XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE);
3
4 if (false) {
5     print '*';
6 }
7
8 $codeCoverage = xdebug_get_code_coverage();
9 xdebug_stop_code_coverage();

10
11 print_r($codeCoverage);

results in

Array
(
[/home/sb/test.php] => Array
(
[4] => 1
[8] => 1
)
)

TagsNo tags attached.
Operating System
PHP Version5.2-dev

Activities

derick

2009-03-28 20:09

administrator   ~0000937

Unfortunately, this one is not fixable. PHP simply reports no code on line 4:

line # op fetch ext return operands

2 0 EXT_STMT
1 EXT_FCALL_BEGIN
2 BW_OR ~0 1, 2
3 SEND_VAL ~0
4 DO_FCALL 1 'xdebug_start_code_coverage'
5 EXT_FCALL_END
5 6 EXT_STMT
7 JMPZ false, ->11
8 PRINT 0000002:0000002 '%2A'
9 FREE 0000002:0000002
10 JMP ->11
7 11 EXT_STMT

Issue History

Date Modified Username Field Change
2008-08-22 09:05 sebastian New Issue
2009-03-28 20:09 derick Note Added: 0000937
2009-03-28 20:09 derick Status new => closed
2009-03-28 20:09 derick Resolution open => not fixable
2020-03-12 16:55 derick Severity minor => feature
2020-03-12 17:13 derick Category Feature/Change request => Code Coverage