1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
|
--TEST--
Test for bug #1192: Dead code analysis does not work for generators with 'return;'
--INI--
xdebug.mode=coverage
--FILE--
<?php
function gen(&$output, $branch = false)
{
yield;
if($branch) {
$output = 'branched';
return;
} // This line is never covered.
$output = 'did not branch';
}
function testGen()
{
$output = '';
$gen = gen($output, true);
while($gen->valid()) {
$gen->next();
}
}
xdebug_start_code_coverage (XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE);
testGen();
$c = xdebug_get_code_coverage();
ksort($c);
var_dump($c);
xdebug_stop_code_coverage();
?>
--EXPECTF--
array(1) {
["%sbug01192.php"]=>
array(14) {
[2]=>
int(1)
[4]=>
int(1)
[6]=>
int(1)
[7]=>
int(1)
[8]=>
int(1)
[10]=>
int(-1)
[12]=>
int(-1)
[16]=>
int(1)
[17]=>
int(1)
[19]=>
int(1)
[20]=>
int(1)
[22]=>
int(1)
[26]=>
int(1)
[28]=>
int(1)
}
}
|