Skip to content

Commit

Permalink
Fix deprecation notice in PHP 8.x
Browse files Browse the repository at this point in the history
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
  • Loading branch information
kohenkatz authored Oct 1, 2021
1 parent f86f69b commit 3b06672
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/VersionsCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function checkPackages(ArrayRepository $distRepository, WritableRepositor
if (\count($higherPackages) > 0) {
// Sort packages by highest version to lowest
usort($higherPackages, function (PackageInterface $p1, PackageInterface $p2) {
return Comparator::compare($p1->getVersion(), '<', $p2->getVersion());
return Comparator::compare($p1->getVersion(), '<', $p2->getVersion()) ? 1 : -1;
});

// Push actual and last package on outdated array
Expand Down

0 comments on commit 3b06672

Please sign in to comment.