the problem is that lines with the switch case are not covered, the switch cases themselves are being executed.
Tested on windows
The output is technically correct, as PHP 7.2 is now clever and no longer needs to run the case statements. I wrote about these optimisations at https://derickrethans.nl/php7.2-switch.html
Nevertheless, this is unwanted behaviour, and hence Xdebug has this "bug" fixed with https://github.com/xdebug/xdebug/commit/0690bf83109228a67dfe14a9a312045435b7b774 — this is part of Xdebug's code on GitHub, but has not made it yet into a release. It will make it into Xdebug 2.6.0beta2.
This is more faster than XDebug. More info https://github.com/krakjoe/pcov.
XDebuyg will always be the best option as it is the one with the most community and time. The bad thing is that it is usually very slow compared to other roads. Dont forget update to last version ;).
Option 1. Use CONSTANTS instead of magic strings. For example:
class SectionTypes
{
public const APP = 'app';
public const SHARE = 'share';
}
/* ... */
case ($type) {
case SectionTypes::APP:
/* do something */
break;
}
Option 2. Use concatenations. For example:
case ($type) {
case 'app'.'':
/* do something */
break;
}
Off course, the last option is ugly and not very recommended, but it can help you quickly.
This was (probably) answered in https://github.com/sebastianbergmann/phpunit/issues/2953.