-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #83 from weirdan/fix-issues
Fix issues introduced/detected in recent Psalm versions
- Loading branch information
Showing
3 changed files
with
94 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
namespace Psalm\PhpUnitPlugin; | ||
|
||
use Composer\Semver\Comparator; | ||
use Composer\Semver\VersionParser; | ||
use PackageVersions\Versions; | ||
|
||
abstract class VersionUtils | ||
{ | ||
public static function packageVersionIs(string $package, string $op, string $ref): bool | ||
{ | ||
/** | ||
* @psalm-suppress DeprecatedClass | ||
* @psalm-suppress ArgumentTypeCoercion | ||
*/ | ||
$currentVersion = (string) explode('@', Versions::getVersion($package))[0]; | ||
|
||
$parser = new VersionParser(); | ||
|
||
$currentVersion = $parser->normalize($currentVersion); | ||
$ref = $parser->normalize($ref); | ||
|
||
return Comparator::compare($currentVersion, $op, $ref); | ||
} | ||
} |