Page MenuHomePhabricator

PHPUnit 7.3 on master fails with "Declaration of MediaWikiPHPUnitCommand::createRunner() must be compatible with PHPUnit\TextUI\Command::createRunner()"
Closed, DuplicatePublic

Description

We tried to run PHPUnit 7.3 with MW master but it failed [0] due to:

Using PHP 7.2.10
PHP Fatal error:  Declaration of MediaWikiPHPUnitCommand::createRunner() must be compatible with PHPUnit\TextUI\Command::createRunner(): PHPUnit\TextUI\TestRunner in /home/travis/build/SemanticMediaWiki/mw/tests/phpunit/MediaWikiPHPUnitCommand.php on line 3
PHP Stack trace:
PHP   1. {main}() /home/travis/build/SemanticMediaWiki/mw/tests/phpunit/phpunit.php:0
PHP   2. require() /home/travis/build/SemanticMediaWiki/mw/tests/phpunit/phpunit.php:129
PHP   3. PHPUnitMaintClass->execute() /home/travis/build/SemanticMediaWiki/mw/maintenance/doMaintenance.php:94
PHP   4. spl_autoload_call() /home/travis/build/SemanticMediaWiki/mw/tests/phpunit/phpunit.php:89
PHP   5. AutoLoader::autoload() /home/travis/build/SemanticMediaWiki/mw/tests/phpunit/phpunit.php:89
PHP   6. require() /home/travis/build/SemanticMediaWiki/mw/includes/AutoLoader.php:109
Fatal error: Declaration of MediaWikiPHPUnitCommand::createRunner() must be compatible with PHPUnit\TextUI\Command::createRunner(): PHPUnit\TextUI\TestRunner in /home/travis/build/SemanticMediaWiki/mw/tests/phpunit/MediaWikiPHPUnitCommand.php on line 3
Call Stack:
    0.0002     428320   1. {main}() /home/travis/build/SemanticMediaWiki/mw/tests/phpunit/phpunit.php:0
    0.0025     726592   2. require('/home/travis/build/SemanticMediaWiki/mw/maintenance/doMaintenance.php') /home/travis/build/SemanticMediaWiki/mw/tests/phpunit/phpunit.php:129
    0.1168   15180920   3. PHPUnitMaintClass->execute() /home/travis/build/SemanticMediaWiki/mw/maintenance/doMaintenance.php:94
    0.1210   15782296   4. spl_autoload_call() /home/travis/build/SemanticMediaWiki/mw/tests/phpunit/phpunit.php:89
    0.1210   15782344   5. AutoLoader::autoload() /home/travis/build/SemanticMediaWiki/mw/tests/phpunit/phpunit.php:89
    0.1211   15787496   6. require('/home/travis/build/SemanticMediaWiki/mw/tests/phpunit/MediaWikiPHPUnitCommand.php') /home/travis/build/SemanticMediaWiki/mw/includes/AutoLoader.php:109

[0] https://travis-ci.org/SemanticMediaWiki/SemanticBreadcrumbLinks/jobs/429044204

Details

Event Timeline

Reedy added a subscriber: Reedy.

https://github.com/sebastianbergmann/phpunit/blob/master/src/TextUI/Command.php#L229

I guess it's the return type...

Why are you using PHPUnit 7.3? MW core has "phpunit/phpunit": "4.8.36 || ^6.5", in composer.json... Which probably makes 7.3 currently unsupported

I investigated this during the PHPUnit 6 upgrade, and the addition of return types in PHPUnit 7 makes it (as far as I could tell) impossible to support both 6 and 7 in a dual fashion like we currently are with 4 and 6. (I'd love to be proven wrong though!) Once we drop PHPUnit 4 support (...blocked on dropping HHVM support), I was thinking that we could plan a potential PHPUnit 7 upgrade as a breaking change.

Why are you using PHPUnit 7.3? MW core has "phpunit/phpunit": "4.8.36 || ^6.5", in composer.json... Which probably makes 7.3 currently unsupported

This was just a one off test to see what will happen. SBL is now indeed using 6.5.x for best experience. See this report of an issue to come with 7.3.x ...

Krinkle closed this task as Declined.EditedSep 16 2018, 4:08 PM
Krinkle added a subscriber: Krinkle.

I'm gonna close this for now. I don't think it's useful to keep open reports for all possible hypothetical problems with intentionally incompatible versions of code.

If this were a defect that is currently hidden to become visible, it'd be useful to still address now, but we can't. The interface is required to match, and right now it matches PHPUnit 4/6. When we drop support for PHPUnit 4 and begin upgrading to PHPUnit 7, the interface will match that instead.

Change 464614 had a related patch set uploaded (by simetrical; owner: simetrical):
[mediawiki/core@master] Support PHPUnit 7.3

https://gerrit.wikimedia.org/r/464614

We currently use PHPUnit 6 which supports PHP 7.0 - 7.2. We don't currently use PHPUnit 7 and won't have to until we need to support PHP 7.3, per https://phpunit.de/.

Legoktm changed the task status from Open to Stalled.Oct 16 2018, 4:48 PM

Per Gerrit discussion and maybe a little on IRC, we're going to wait to drop HHVM / PHPUnit 4 support before adding a third PHPUnit runtime.

Change 464614 abandoned by simetrical:
Support PHPUnit 7.3

Reason:
This doesn't seem worth it until we require a newer PHP version.

https://gerrit.wikimedia.org/r/464614