View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0000948 | Xdebug | Uncategorized | public | 2013-05-13 20:49 | 2013-05-18 22:30 |
Reporter | ashnazg | Assigned To | derick | ||
Priority | normal | Severity | minor | Reproducibility | always |
Status | resolved | Resolution | no change required | ||
Product Version | 2.2.2 | ||||
Summary | 0000948: Unused+DeadCode not returning (-2) because of nested IF | ||||
Description | Having an inner IF inside an outer IF results in two lines being returned as (-1) rather than (-2) in the xdebug_get_code_coverage() return array. In my fooGood() method coverage, the regular behavior return of (-2) for the "} else {" line and the function end line "}", as expected. In my fooBad() method coverage, the equivalent lines (ELSE and function close brace) get return values of (-1) instead. The expectation is that (-2) would be returned for both lines. | ||||
Steps To Reproduce |
| ||||
Additional Information | I discovered this behavior while trying to figure out why PHP_CodeCoverage (1.2 branch on github) was showing these lines as red unexecuted code rather than as white ignored lines. CodeCoverage uses both the UNUSED and DEAD_CODE flags and appears to expect (-2) values to be returned for the lines in question. (https://github.com/sebastianbergmann/php-code-coverage/issues/160) This behavior is evident in all 2.2 versions (2.2.2, 2.2.1, 2.2.0, 2.2.0rc2, 2.2.0rc1). | ||||
Tags | No tags attached. | ||||
Attached Files | |||||
Operating System | Windows7 | ||||
PHP Version | 5.4.7 | ||||
|
There is no bug here. In the case without the nested "if", the code can never reach the closing function bracket if you do statical analysis of code paths. However, in the case with the nested if it is possible to hit this. Xdebug doesn't know that the two if ($args) do the same thing, as it does not do evaluation of "if" statements during its analysis. Therefore, the "} else {" on line 12 and the "}" on line 15 can theoretically (but not logically) be reached. |
Date Modified | Username | Field | Change |
---|---|---|---|
2013-05-13 20:49 | ashnazg | New Issue | |
2013-05-13 20:49 | ashnazg | File Added: xdebugTest.php | |
2013-05-18 22:30 | derick | Note Added: 0002475 | |
2013-05-18 22:30 | derick | Status | new => resolved |
2013-05-18 22:30 | derick | Resolution | open => no change required |
2013-05-18 22:30 | derick | Assigned To | => derick |
2016-07-31 12:36 | derick | Category | Usage problems => Usage problems (Crashes) |
2016-07-31 12:38 | derick | Category | Usage problems (Crashes) => Usage problems (Wrong Results) |
2020-03-12 16:35 | derick | Category | Usage problems (Wrong Results) => Variable Display |
2020-03-12 16:38 | derick | Category | Variable Display => Uncategorized |