diff --git a/ChangeLog.md b/ChangeLog.md index cd95f287e..47d461e98 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -2,6 +2,12 @@ All notable changes are documented in this file using the [Keep a CHANGELOG](http://keepachangelog.com/) principles. +## [7.0.12] - 2020-11-27 + +### Added + +* [#834](https://github.com/sebastianbergmann/php-code-coverage/issues/834): Support `XDEBUG_MODE` environment variable + ## [7.0.11] - 2020-11-27 ### Added @@ -118,6 +124,7 @@ All notable changes are documented in this file using the [Keep a CHANGELOG](htt * Class names are now abbreviated (unqualified name shown, fully qualified name shown on hover) in the file view of the HTML report * Update HTML report to Bootstrap 4 +[7.0.12]: https://github.com/sebastianbergmann/php-code-coverage/compare/7.0.11...7.0.12 [7.0.11]: https://github.com/sebastianbergmann/php-code-coverage/compare/7.0.10...7.0.11 [7.0.10]: https://github.com/sebastianbergmann/php-code-coverage/compare/7.0.9...7.0.10 [7.0.9]: https://github.com/sebastianbergmann/php-code-coverage/compare/7.0.8...7.0.9 diff --git a/src/Driver/Xdebug.php b/src/Driver/Xdebug.php index 924f313e2..06779eaae 100644 --- a/src/Driver/Xdebug.php +++ b/src/Driver/Xdebug.php @@ -38,14 +38,19 @@ public function __construct(Filter $filter = null) throw new RuntimeException('This driver requires Xdebug'); } - if (\version_compare(\phpversion('xdebug'), '3', '>=') && - !\ini_get('xdebug.mode') || !\in_array('coverage', \explode(',', \ini_get('xdebug.mode')), true)) { - throw new RuntimeException('xdebug.mode=coverage has to be set in php.ini'); - } + if (\version_compare(\phpversion('xdebug'), '3', '>=')) { + $mode = \getenv('XDEBUG_MODE'); + + if ($mode === false) { + $mode = \ini_get('xdebug.mode'); + } - if (\version_compare(\phpversion('xdebug'), '3', '<') && - !\ini_get('xdebug.coverage_enable')) { - throw new RuntimeException('xdebug.coverage_enable=On has to be set in php.ini'); + if ($mode === false || + !\in_array('coverage', \explode(',', $mode), true)) { + throw new RuntimeException('XDEBUG_MODE=coverage or xdebug.mode=coverage has to be set'); + } + } elseif (!\ini_get('xdebug.coverage_enable')) { + throw new RuntimeException('xdebug.coverage_enable=On has to be set'); } if ($filter === null) { diff --git a/src/Version.php b/src/Version.php index b2ff8886d..f3978d6a1 100644 --- a/src/Version.php +++ b/src/Version.php @@ -21,7 +21,7 @@ final class Version public static function id(): string { if (self::$version === null) { - $version = new VersionId('7.0.11', \dirname(__DIR__)); + $version = new VersionId('7.0.12', \dirname(__DIR__)); self::$version = $version->getVersion(); }