Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade phpunit/php-code-coverage to version 9.0+ #10

Merged
merged 22 commits into from
Oct 4, 2020

Conversation

thekid
Copy link
Member

@thekid thekid commented Oct 3, 2020

...achieving PHP 8 compatibility, see issue #9

@thekid
Copy link
Member Author

thekid commented Oct 3, 2020

Hrm, this breaks PHP 7.0, 7.1 and 7.2 builds: phpunit/php-code-coverage 9.2.0 requires php >=7.3, see https://travis-ci.org/github/xp-forge/coverage/jobs/732487095

@thekid
Copy link
Member Author

thekid commented Oct 3, 2020

Code Coverage BC breaks

Version 9 contains quite a bit of BC breaks, see https://github.com/sebastianbergmann/php-code-coverage/blob/master/ChangeLog.md#900---2020-08-07

The call to construct a CodeCoverage can be made compatible with versions 5, 6, 7 and 8 as well as version 9:

$filter= new Filter();

// Version 9, can be detected via class_exists(Selector::class)
$driver= (new Selector())->forLineCoverage($filter);

// Version 6, 7, 8: makes CodeCoverage use its private selectDriver() method
$driver= null;

$coverage= new CodeCoverage($driver, $filter);

Report method names have changed away from a get... style:

// Before
$report->getNumExecutedLines();
$report->getNumExecutableLines();
$report->getClasses();

// After
$report->numberOfExecutedLines();
$report->numberOfExecutableLines();
$report->classes();

For filters, the verbs have changed completely:

// Before
$filter->addDirectoryToWhitelist($folder);
$filter->hasWhitelist();

// After
$filter->includeDirectory($folder);
$filter->isEmpty();

@thekid thekid merged commit 557c910 into master Oct 4, 2020
@thekid thekid deleted the refactor/upgrade-php-code-coverage branch October 4, 2020 10:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant