View Issue Details

IDProjectCategoryView StatusLast Update
0000535Xdebug(No Category)public2010-03-20 18:43
ReportergimlerAssigned Toderick 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionno change required 
Product Version 
Target VersionFixed in Version 
Summary0000535: code coverage and return before function|class ending
Descriptionwhen you have a sample like this
<?php
xdebug_start_code_coverage();

class test
{
    function a() {
        return true;
    }
}

$a = new test();
$a->a();

var_dump(xdebug_get_code_coverage());

you get this output:
array(1) {
  ["/home/gfranke/Desktop/100_percent.php"]=>
  array(5) {
    [5]=>
    int(1)
    [7]=>
    int(1)
    [11]=>
    int(1)
    [12]=>
    int(1)
    [14]=>
    int(1)
  }
}

it doesn't detect the function declaration line (6) and the closing lines (8) also the line with the class definition is missing (4)

i think it must check if the return line is the last line and than mark the line "" with the } as coveraged
Additional InformationPHP 5.2.10-2ubuntu6.4 with Suhosin-Patch 0.9.7 (cli) (built: Jan 6 2010 22:56:44)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies
    with Xdebug v2.0.5, Copyright (c) 2002-2008, by Derick Rethans

xdebug 2.0.5
TagsNo tags attached.
Operating Systemubuntu 9.10
PHP Version5.2.10

Activities

derick

2010-03-20 18:43

administrator   ~0001392

This is not a bug. A "return" statement breaks straight out of the function and it doesn't hit the implicit "return NULL;" which is located at the closing brace:

filename: /home/derick/dev/php/xdebug/tests/bug00535.phpt
function name: a
number of ops: 5
compiled vars: none
line # * op fetch ext return operands
---------------------------------------------------------------------------------
   6 0 > EXT_NOP
   7 1 EXT_STMT
         2 > RETURN true
   8 3* EXT_STMT
         4* > RETURN null

* = code can not be reached.

The function and class declarations aren't hit because there is no executable code there. Accepting an argument into the function, or adding "extends" or "implements" to the class declaration would make them have code.

Issue History

Date Modified Username Field Change
2010-02-11 15:57 gimler New Issue
2010-02-11 15:57 gimler Operating System => ubuntu 9.10
2010-02-11 15:57 gimler PHP Version => 5.2.10
2010-02-11 15:57 gimler Xdebug Version => 2.0.5
2010-03-20 18:43 derick Note Added: 0001392
2010-03-20 18:43 derick Status new => resolved
2010-03-20 18:43 derick Resolution open => no change required
2010-03-20 18:43 derick Assigned To => derick
2016-07-31 12:35 derick Category Debug client (console) => debugclient (debugging tool)
2016-07-31 12:35 derick Category debugclient (debugging tool) => (No Category)