Skip to content

Commit

Permalink
Allow older composer/semver cc @xurizaemon
Browse files Browse the repository at this point in the history
  • Loading branch information
muglug committed Mar 29, 2021
1 parent ec7de89 commit 2d197e3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"amphp/amp": "^2.4.2",
"amphp/byte-stream": "^1.5",
"composer/package-versions-deprecated": "^1.8.0",
"composer/semver": "^2.0 || ^3.0",
"composer/semver": "^1.4 || ^2.0 || ^3.0",
"composer/xdebug-handler": "^1.1",
"dnoegel/php-xdg-base-dir": "^0.1.1",
"felixfbecker/advanced-json-rpc": "^3.0.3",
Expand Down
7 changes: 5 additions & 2 deletions src/Psalm/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -2064,14 +2064,17 @@ private function getPHPVersionFromComposerJson(): ?string

if (\is_string($php_version)) {
$version_parser = new VersionParser();
$min_php_version = $version_parser->parseConstraints($php_version)->getLowerBound()->getVersion();

$constraint = $version_parser->parseConstraints($php_version);

foreach (['5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0'] as $candidate) {
if (Semver::satisfies($min_php_version, "~$candidate.0")) {
if ($constraint->matches(new \Composer\Semver\Constraint\Constraint('<=', "$candidate.0.0-dev"))) {
return $candidate;
}
}
}
}

return null;
}

Expand Down

0 comments on commit 2d197e3

Please sign in to comment.