|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2006-06-23 21:31 UTC] skettler@php.net
Description:
------------
Using xdebug CVS as of 2006-06-24 00:00 UTC, but having the same problem using the latest beta.
When using if-statements that do not contain curly braces on their true/false-blocks, code coverage information is inaccurate.
When using the same if-statements using curly braces, code coverage information is just fine.
Reproduce code:
---------------
<?php
xdebug_start_code_coverage();
if (false) // wrongly marked not executed
$a = 1; // wrongly marked executed
else
$a = 2; // wrongly marked not executed
if (true) // wrongly marked not executed
$a = 1; // correctly marked executed
else
$a = 2; // correctly marked not executed
if (false) { // correctly marked executed
$a = 1; // correctly marked not executed
}
else {
$a = 2; // correctly marked executed
}
if (true) { // correctly marked executed
$a = 1; // correctly marked executed
}
else {
$a = 2; // correctly marked not executed
}
var_dump(xdebug_get_code_coverage());
?>
Expected result:
----------------
array
'.../coverage.php' =>
array
5 => 1
8 => 1
10 => 1
11 => 1
15 => 1
19 => 1
22 => 1
23 => 1
24 => 1
29 => 1
Actual result:
--------------
array
'.../coverage.php' =>
array
6 => 1
11 => 1
15 => 1
19 => 1
22 => 1
23 => 1
24 => 1
29 => 1
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 16:00:01 2025 UTC |
I've narrowed it down a bit: <?php if (true) $a = 1; ?> produces the following opcodes: ZEND_EXT_STMT ZEND_JMPZ ZEND_ASSIGN ZEND_JMP whereas <?php if (true) { $a = 1; } ?> produces: ZEND_EXT_STMT ZEND_JMPZ ZEND_EXT_STMT ZEND_ASSIGN ZEND_JMP Looks like PHP inconsistently omits ZEND_EXT_STMT in certain constellations (as you already noted in your ChangeLog). Do we really have to override all possible opcodes or is there another way to correctly get full code coverage information?