View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0002179 | Xdebug | Code Coverage | public | 2023-05-11 11:09 | 2023-07-18 11:11 |
Reporter | ondrej.frei@lokalise.com | Assigned To | derick | ||
Priority | normal | Severity | major | Reproducibility | sometimes |
Status | resolved | Resolution | no change required | ||
Product Version | 3.1.3 | ||||
Summary | 0002179: Bad coverage | ||||
Description | In some situations (nested ifs) lines are reported as covered even though they are not. This can heavily skew the code coverage number. | ||||
Steps To Reproduce | Please refer to https://github.com/freiondrej-lokalise/bad-coverage-reproduction with live reproduction details. | ||||
Tags | No tags attached. | ||||
Operating System | |||||
PHP Version | 8.1.10-8.1.19 | ||||
|
I have had a look at this, and although i can indeed reproduce it, I can't do anything about it. PHP seems to be not generating
In the first function 2179.php (912 bytes)
<?php function getByFilename() { if (true) { if ( false ) { $this_file_format = $file_format; // will be shown as not covered exit; // will be shown as not covered die; // will be shown as not covered throw new Exception(); // will be shown as covered because it's the last line in the block } } else { // the else is crucial even when it's not actually called. and when it's empty. When removed, the coverage bug stops happening. } } function getByFilename2() { if (true) { if ( false ) { $this_file_format = $file_format; // will be shown as covered because it's the last (=only) line in the block } } else { // the else is crucial even when it's not actually called. and when it's empty. When removed, the coverage bug stops happening. } } |
|
This is going to be fixed in PHP 8.2.9: https://github.com/php/php-src/pull/11598#pullrequestreview-1514703137 — so I'll be closing this issue. |
|
Thank you @derick! Much appreciated. |
Date Modified | Username | Field | Change |
---|---|---|---|
2023-05-11 11:09 | ondrej.frei@lokalise.com | New Issue | |
2023-07-04 16:50 | derick | Note Added: 0006580 | |
2023-07-04 16:50 | derick | File Added: 2179.php | |
2023-07-04 16:51 | derick | Assigned To | => derick |
2023-07-04 16:51 | derick | Status | new => confirmed |
2023-07-05 14:53 | derick | Status | confirmed => resolved |
2023-07-05 14:53 | derick | Resolution | open => no change required |
2023-07-05 14:53 | derick | Note Added: 0006585 | |
2023-07-18 11:11 | ondrej.frei@lokalise.com | Note Added: 0006605 |