Skip to content

Commit 0487bed

Browse files
mmollxalopp
authored andcommitted
Add XDebug 3.x workaround
1 parent 33cc228 commit 0487bed

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

.travis.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,12 @@ script:
3838
- vendor/bin/phpstan analyse --no-progress # Run PHPStan
3939
- vendor/bin/psalm --show-info=false # run psalm
4040
- if [ "${DEPENDENCIES}" = "highest" ]; then vendor/bin/phan; fi; # Run phan
41-
- if [ "${TRAVIS_PHP_VERSION}" != "7.3" ]; then php -d zend_extension=xdebug.so vendor/bin/phpunit --coverage-clover=coverage.xml; fi; # Generate Code coverage report
41+
# Generate Code coverage report
42+
- |
43+
if [ "${TRAVIS_PHP_VERSION}" == "7.4" ] && [ "${DEPENDENCIES}" = "highest" ]; then
44+
echo 'xdebug.mode = "coverage"' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
45+
php -d zend_extension=xdebug.so vendor/bin/phpunit --coverage-clover=coverage.xml
46+
fi
4247
4348
jobs:
4449
include:

tests/bootstrap.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,20 @@ static function ($v) use ($myStandardName): bool {
3737
);
3838

3939
putenv("PHPCS_IGNORE_TESTS={$ignoredStandardsStr}");
40+
41+
/*
42+
* PHPUnit 9.3 is the first version which supports Xdebug 3, but we're using older versions.
43+
*
44+
* For now, until a fix is pulled into the whole stack, this will allow older PHPUnit
45+
* versions to run with Xdebug 3 for code coverage.
46+
*/
47+
48+
if ((\extension_loaded('xdebug') === true) && (\version_compare((string) \phpversion('xdebug'), '3', '>=') === true)) {
49+
if (defined('XDEBUG_CC_UNUSED') === false) {
50+
define('XDEBUG_CC_UNUSED', null);
51+
}
52+
53+
if (defined('XDEBUG_CC_DEAD_CODE') === false) {
54+
define('XDEBUG_CC_DEAD_CODE', null);
55+
}
56+
}

0 commit comments

Comments
 (0)