MantisBT

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0000651XdebugUsage problems (Wrong Results)public2011-01-05 22:452011-01-10 21:08
Reportercbandy 
Assigned Toderick 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionfixed 
PlatformLinuxOSGentooOS Versionstable
Product Version2.1.0 
Target VersionFixed in Version 
Summary0000651: Incorrect code coverage after empty() in conditional when using XDEBUG_CC_UNUSED
DescriptionWhen `empty()` is the first and only condition on the first line of an `if` condition, the next line is not reported as covered.

In the below example, line 8 is not reported as covered.

Removing the bang has no effect.
Replacing `empty()` with `isset()` has no effect.
Swapping lines 7 and 8 shows full coverage.
Appending line 8 to line 7 shows full coverage.
Steps To ReproduceScript:

<?php

xdebug_start_code_coverage(XDEBUG_CC_UNUSED);

function repeat($x)
{
    if ( ! empty($x)
        AND $x !== 1
        AND $x !== 2
        AND $x !== 3)
    {
        $y = 'covered';
    }
}

repeat(0);
repeat(1);
repeat(2);
repeat(3);
repeat(4);

print_r(xdebug_get_code_coverage());


Actual Result:

Array
(
    [code_coverage.php] => Array
        (
            [5] => 1
            [7] => 1
            [8] => -1
            [9] => 1
            [10] => 1
            [11] => 1
            [12] => 1
            [13] => 1
            [14] => 1
            [16] => 1
            [17] => 1
            [18] => 1
            [19] => 1
            [20] => 1
            [22] => 1
        )

)


Expected Result:

Array
(
    [code_coverage.php] => Array
        (
            [5] => 1
            [7] => 1
            [8] => 1
            [9] => 1
            [10] => 1
            [11] => 1
            [12] => 1
            [13] => 1
            [14] => 1
            [16] => 1
            [17] => 1
            [18] => 1
            [19] => 1
            [20] => 1
            [22] => 1
        )

)
Additional InformationPHP 5.3.4-pl0-gentoo
TagsNo tags attached.
Operating System
PHP Version5.3.3
Attached Files

- Relationships

-  Notes
(0001635)
derick (administrator)
2011-01-07 23:52

Fixed in SVN for 2.1.1 and 2.2.0. Thanks for your report!
(0001636)
cbandy (reporter)
2011-01-09 04:40

The `! empty()` and `! isset()` cases are fixed in SVN, but `empty()` and `isset()` are still incorrect.

- Issue History
Date Modified Username Field Change
2011-01-05 22:45 cbandy New Issue
2011-01-07 23:52 derick Note Added: 0001635
2011-01-07 23:52 derick Status new => closed
2011-01-07 23:52 derick Assigned To => derick
2011-01-07 23:52 derick Resolution open => fixed
2011-01-09 04:40 cbandy Note Added: 0001636
2011-01-09 04:40 cbandy Status closed => feedback
2011-01-09 04:40 cbandy Resolution fixed => reopened
2011-01-10 21:08 derick Status feedback => closed
2011-01-10 21:08 derick Resolution reopened => fixed
2016-07-31 13:36 derick Category Usage problems => Usage problems (Crashes)
2016-07-31 13:38 derick Category Usage problems (Crashes) => Usage problems (Wrong Results)


Copyright © 2000 - 2017 MantisBT Team
Powered by Mantis Bugtracker