Skip to content

Commit

Permalink
Only use composed php version if using constant throws exception
Browse files Browse the repository at this point in the history
  • Loading branch information
eclipxe13 committed May 9, 2018
1 parent 8703b31 commit 43f3838
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/services/phar/CompatibilityService.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,16 @@ public function canRun(Phar $phar) {

case $requirement instanceof PhpVersionRequirement: {
$php = $requirement->getVersionConstraint();
$phpversion = PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION . '.' . PHP_RELEASE_VERSION;
if (!$php->complies(new Version($phpversion))) {
try {
$phpversion = new Version(PHP_VERSION);
} catch (InvalidVersionException $ex) {
$phpversion = new Version(PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION . '.' . PHP_RELEASE_VERSION);
}
if (!$php->complies($phpversion)) {
$issues[] = sprintf(
'PHP Version %s required, but %s in use',
$php,
$phpversion
PHP_VERSION
);
}
continue 2;
Expand Down

0 comments on commit 43f3838

Please sign in to comment.