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

Update to allow version check to work with php 8 #75

Closed
wants to merge 5 commits into from
Closed

Update to allow version check to work with php 8 #75

wants to merge 5 commits into from

Conversation

timhaak
Copy link

@timhaak timhaak commented Oct 23, 2020

Trying to start getting things to work with PHP 8.0

Also fixed the PHPUnit deprecation warning.

Deprecation Notice: usort(): Returning bool from comparison function is deprecated, return an integer less than, equal to, or greater than zero in .../vendor/sllh/composer-versions-check/src/VersionsCheck.php:54
…cated, use PHPUnit_Framework_TestCase::createMock() or PHPUnit_Framework_TestCase::getMockBuilder() instead"
@soullivaneuh
Copy link
Owner

@timhaak Thanks for this contribution! The CI is failing, could you please take a look?

@soullivaneuh
Copy link
Owner

Is this PR whiling to resolve #74?

@timhaak
Copy link
Author

timhaak commented Nov 28, 2020

Just a bit to busy to sort this out now.

Will do a new pull request with fixes when/if I catch up a bit :)

@timhaak timhaak closed this Nov 28, 2020
Comment on lines +52 to +58
if (Comparator::compare($p1->getVersion(), '=', $p2->getVersion())) {
return 0;
}
if (Comparator::compare($p1->getVersion(), '<', $p2->getVersion())) {
return 1;
}
return -1;
Copy link

@pelmered pelmered Nov 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would replace with ternary:
return Comparator::compare($p1->getVersion(), '<', $p2->getVersion()) ? 1 : -1;
There shouldn't be any versions that are equal, right?

kohenkatz added a commit to kohenkatz/composer-versions-check that referenced this pull request Oct 1, 2021
According to the documentation, all versions of PHP support the `usort` callable parameter returning an `integer`. While earlier versions silently accepted a `boolean`, PHP 8.x throws a deprecation notice:

```
Deprecation Notice: usort(): Returning bool from comparison function is deprecated, return an integer less than, equal to, or greater than zero in C:\Users\MY_USER\AppData\Roaming\Composer\vendor\sllh\composer-versions-check\src\VersionsCheck.php:54
```

This fix (based on [this comment](soullivaneuh#75 (comment))) eliminates this notice.

fixes soullivaneuh#74
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.

3 participants