Skip to content

Commit

Permalink
Fix broken output with composer/semver 2+ and vimeo/psalm:dev-master
Browse files Browse the repository at this point in the history
  • Loading branch information
weirdan committed Jun 21, 2020
1 parent 11d5faa commit a55ac7b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
},
"require-dev": {
"squizlabs/php_codesniffer": "^3.4",
"vimeo/psalm": "^3.7.0",
"vimeo/psalm": "^3.7.0 || dev-master",
"phpunit/phpunit": "^6.0.0 || ^7.0.0 || ^8.0.0 || ^9.0"
},
"scripts": {
Expand All @@ -37,5 +37,8 @@
"cs-check": "phpcs --colors",
"static-analysis": "psalm",
"test": "codecept run -v"
},
"config": {
"optimize-autoloader": true
}
}
7 changes: 6 additions & 1 deletion src/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,13 @@ public function seePsalmVersionIs(string $operator, string $version): bool

// todo: move to init/construct/before?
$parser = new VersionParser();

$currentVersion = $parser->normalize($currentVersion);

// restore pre-composer/semver:2.0 behaviour for comparison purposes
if (preg_match('/^dev-/', $currentVersion)) {
$currentVersion = '9999999-dev';
}

$version = $parser->normalize($version);

$result = Comparator::compare($currentVersion, $operator, $version);
Expand Down
7 changes: 5 additions & 2 deletions tests/acceptance/PsalmModule.feature
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,13 @@ Feature: Psalm module
Given I have Psalm older than "999.99" (because of "me wanting to see if it runs")
And I have the following code
"""
atan(1.);
atan("zz");
"""
When I run Psalm
Then I see no errors
Then I see these errors
| Type | Message |
| InvalidScalarArgument | /./ |
And I see no other errors

Scenario: Running Psalm with dead code detection
Given I have the following code
Expand Down

0 comments on commit a55ac7b

Please sign in to comment.