[xdebug-general] Code coverage of if statements

From: Mike Richardson <mike[@]quaking.demon.co.uk>
Date: Mon, 22 Dec 2008 10:08:22 +0000

If I run the following (line numbers added)

1 <?php
2 function f($a)
3 {
4 if ($a)
5
6 return 1 ;
7
8 else return 2 ;
9 }
10
11 xdebug_start_code_coverage();
12 f(0) ;
13 var_dump(xdebug_get_code_coverage());
14 ?>

I get :

array(1) {
  ["/tmp/p.php"]=>
  array(4) {
    [6]=>
    int(1)
    [8]=>
    int(1)
    [12]=>
    int(1)
    [13]=>
    int(1)
  }
}

which seems wrong since line 6 is *not* executing (but line 5 is)? If I call
f(1) instead I get lines 6, 12 and 13 executed, which is right; if I call
f(0) and have braces on lines 5 and 7 then line 6 is not reported as
executed. If this an Xdebug bug or a PHP limitation?

I'm on Ubuntu 8.04, PHP 5.2.4, xdebug 2.0.3.

-- 
Regards
Mike
Received on Mon Dec 22 2008 - 11:30:19 GMT

This archive was generated by hypermail 2.2.0 : Mon Jun 25 2018 - 06:00:04 BST