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

PHPUnit\Framework\TestCase / PHPUnit\Framework\Test interface contradiction [PHPUnit 6.5] #3209

Closed
weirdan opened this issue Jul 12, 2018 · 0 comments · Fixed by elecena/nano#2

Comments

@weirdan
Copy link

weirdan commented Jul 12, 2018

Version: PHPUnit 6.5

PHPUnit\Framework\TestCase::run() is defined as returning nullable TestResult, however PHPUnit\Framework\Test::run() (which TestCase::run() should be compatible to) declares non-nullable return type, both in docblocks.

* @return TestResult|null
*
* @throws Exception
*/
public function run(TestResult $result = null)

interface Test extends Countable
{
/**
* Runs a test and collects its result in a TestResult instance.
*
* @param TestResult $result
*
* @return TestResult
*/
public function run(TestResult $result = null);

This results in the static analyzers complaining (which, of course, could be suppressed, but I think it'd be better fixed in PHPUnit).

For the reference, PHPUnit 7 has non-nullable returns on the corresponding class and interface methods.

image

@weirdan weirdan changed the title PHPUnit\Framework\TestCase / PHPUnit\Framework\Test interface contradiction PHPUnit\Framework\TestCase / PHPUnit\Framework\Test interface contradiction [PHPUnit 6.5] Jul 12, 2018
sebastianbergmann added a commit that referenced this issue Jul 13, 2018
muglug pushed a commit to vimeo/psalm that referenced this issue Jul 13, 2018
* upgrade phpunit, test with low and high deps

* work around possibly-anonymous test cases introduced by newer PHPUnit

* Alternative TestCase::getName() nullability workaround

Previous workaround was failing due to PHP warnings on 7.1 or 7.2
(depending on specific signature). There's just no signature that would
be working for all 4 variants of (ver / dep) matrix.

* don't disable xdebug if it's not enabled

* allowed 7.0/high to fail until PHPUnit 6.5.10 is released

see sebastianbergmann/phpunit#3209
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 a pull request may close this issue.

2 participants