Anonymous | Login | Signup for a new account | 2018-04-25 05:39 BST | ![]() |
My View | View Issues | Change Log | Roadmap |
View Issue Details [ Jump to Notes ] | [ Issue History ] [ Print ] | ||||||||||||
ID | Project | Category | View Status | Date Submitted | Last Update | ||||||||
0001541 | Xdebug | Code Coverage | public | 2018-03-26 15:42 | 2018-03-26 15:48 | ||||||||
Reporter | theoboldt | ||||||||||||
Assigned To | |||||||||||||
Priority | normal | Severity | major | Reproducibility | always | ||||||||
Status | new | Resolution | open | ||||||||||
Platform | Linux | OS | Ubuntu | OS Version | 16.04.1 | ||||||||
Product Version | 2.6.0 | ||||||||||||
Target Version | Fixed in Version | ||||||||||||
Summary | 0001541: switch/case case is not covered when using php-fpm php 7.0 | ||||||||||||
Description | When executing switch/case within a function, no case line of executed cases is marked as covered, except the following: * The first line is marked as covered as expected * The "default" case is marked as covered as expected The lines are marked as covered as expected when the same file is executed via CLI using same php/xdebug version. {code} <?php function a($option) { switch ($option) { case 'first': $option .= '_covered'; break; case 'second': $option .= '_covered'; break; case 'third': $option .= '_covered'; break; default: $option .= '_covered'; break; } return $option; } xdebug_start_code_coverage(XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE); a('first'); a('second'); a('third'); a('default'); $coverage = xdebug_get_code_coverage(); xdebug_stop_code_coverage(); //EVALUATE (not part of proof) print_r( [ 'phpversion(\'xdebug\')' => phpversion('xdebug'), 'phpversion()' => phpversion(), 'php_sapi_name()' => php_sapi_name() ] ); print_r($coverage); ?> {code} When executing above code via CLI, following output is generated: {code} Array ( [phpversion('xdebug')] => 2.6.0 [phpversion()] => 7.0.28-0ubuntu0.16.04.1 [php_sapi_name()] => cli ) Array ( [/intproj/users/erik/xdebug_coverage_issues/switch_case.php] => Array ( [5] => 1 [6] => 1 [7] => 1 [8] => 1 [9] => 1 [10] => 1 [11] => 1 [12] => 1 [13] => 1 [15] => 1 [16] => 1 [18] => 1 [23] => 1 [24] => 1 [25] => 1 [26] => 1 [28] => 1 ) ) {code} When executing above code via Apache 2 (Server API: FPM/FastCGI, PHP API: 20151012, PHP Extension: 20151012) the output differs significantly for line 8 and 11: {code} Array ( [phpversion('xdebug')] => 2.6.0 [phpversion()] => 7.0.28-0ubuntu0.16.04.1 [php_sapi_name()] => fpm-fcgi ) Array ( [/intproj/users/erik/xdebug_coverage_issues/switch_case.php] => Array ( [5] => 1 [6] => 1 [7] => 1 [8] => -1 [9] => 1 [10] => 1 [11] => -1 [12] => 1 [13] => 1 [15] => 1 [16] => 1 [18] => 1 [23] => 1 [24] => 1 [25] => 1 [26] => 1 [28] => 1 ) ) {code} | ||||||||||||
Steps To Reproduce | Execute provided using php 7.0.28 snipped via php-fpm and via cli as well, compare results | ||||||||||||
Tags | PHP7 | ||||||||||||
Operating System | |||||||||||||
PHP Version | 7.0.25-7.0.29 | ||||||||||||
Attached Files | ![]() | ||||||||||||
![]() |
|||
Date Modified | Username | Field | Change |
2018-03-26 15:42 | theoboldt | New Issue | |
2018-03-26 15:42 | theoboldt | File Added: switch_case.php | |
2018-03-26 15:48 | theoboldt | Tag Attached: PHP7 |
Copyright © 2000 - 2018 MantisBT Team |