View Issue Details

IDProjectCategoryView StatusLast Update
0002095XdebugCode Coveragepublic2022-05-25 15:34
Reporterbradkent Assigned Toderick  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionno change required 
Product Version3.1.3 
Summary0002095: code coverage misses } elseif (\in_array()) {
Description

combinations of "elseif" vs "else if" and "in_array" vs "\in_array" produce different results

Steps To Reproduce

hit:
} elseif (in_array($foo, array('bar','baz'))) {

hit:
} else if (\in_array($foo, array('bar','baz'))) {

not hit
} elseif (\in_array($foo, array('bar','baz'))) {

TagsNo tags attached.
Operating Systemosx 10.14.6
PHP Version8.1.0-8.1.4

Activities

derick

2022-05-17 13:37

administrator   ~0006304

Can you provide a full parseable file please?

bradkent

2022-05-17 13:39

reporter   ~0006305

Also a hit :
$vals = array('foo','bar');
...
} elseif (\in_array($foo, $vals)) {

so it's only when the array is defined "inline"

bradkent

2022-05-17 13:41

reporter   ~0006306

<?php
$foo = 'bar'; // hit
if (false) { // not hit
echo 'hello 1'; // not hit
} elseif (\in_array($foo, array('foo','bar'))) { // not hit
echo 'hello 2'; // hit
}

derick

2022-05-18 10:10

administrator   ~0006309

This is turning out to be a "bug" in PHP itself, where it does not generate appropriate EXT_STMT hook points for elseif clauses. I have made a patch for PHP itself: https://github.com/php/php-src/pull/8574

derick

2022-05-25 15:15

administrator   ~0006318

As there is nothing for me to do here on the Xdebug side, now the fix has made it into PHP RCs, and will make it into the upcoming releases (php-8.1.7 and php-8.0.20), I am closing this out.

Thanks for the report.

bradkent

2022-05-25 15:34

reporter   ~0006319

thanks derick!

Issue History

Date Modified Username Field Change
2022-05-17 13:22 bradkent New Issue
2022-05-17 13:37 derick Assigned To => derick
2022-05-17 13:37 derick Status new => feedback
2022-05-17 13:37 derick Note Added: 0006304
2022-05-17 13:39 bradkent Note Added: 0006305
2022-05-17 13:39 bradkent Status feedback => assigned
2022-05-17 13:41 bradkent Note Added: 0006306
2022-05-18 10:10 derick Status assigned => confirmed
2022-05-18 10:10 derick Note Added: 0006309
2022-05-25 15:15 derick Status confirmed => resolved
2022-05-25 15:15 derick Resolution open => no change required
2022-05-25 15:15 derick Note Added: 0006318
2022-05-25 15:34 bradkent Note Added: 0006319