Psalm: switch from Phive to Composer - #42
Merged
Merged
Conversation
This switches the installation method for Psalm from Phive to Composer, while still using a Phar file for running Psalm.
Includes:
* Removing Psalm from the Phive configuration.
* Adding Psalm to the Composer configuration. Includes upgrading from version `3.11.2` to version `4.8.1`.
* Adjusting the script used in the `Makefile`.
👉 Please verify and test this as things work differently on different OS-es and this should work for you.
* Adjusting the GH Actions script to use the Composer installed version of Psalm.
Note: due to the committed `composer.lock` file, Psalm will not automatically upgrade when newer versions are available.
Refs:
* https://github.com/vimeo/psalm/releases
* https://github.com/psalm/phar/releases
The `$matches` array returned by `explode()` can be an empty array. In that case, `end()` would return `false`, which due to the string cast would become an empty string. Psalm flags the string cast though with: ``` ERROR: RedundantCast - src/Fqsen.php:66:21 - Redundant cast to string (see https://psalm.dev/262) $name = (string) end($matches); ``` ... which in my opinion is incorrect. I tried various options to get round this, but most ended up being flagged by Psalm again, even though IMO this flagging is incorrect. Either way, the current change fixes the Psalm violation and does not trigger new violation flags.
jaapio
approved these changes
Aug 6, 2021
jaapio
left a comment
Member
There was a problem hiding this comment.
Thanks, I think the fix for psalm is ok. Since a cast from false to string is odd, anyway. I think that's the reason psalm is complaining about this.
Regarding the lock-file, we are using dependabot in all repo's. Having a locked version of psalm makes sense, because like you experienced, new versions might introduce new violations.
Contributor
Author
Fair enough, though you can also manage that via the version constraint in |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Psalm: switch from Phive to Composer
This switches the installation method for Psalm from Phive to Composer, while still using a Phar file for running Psalm.
Includes:
3.11.2to version4.8.1.Makefile.👉 Please verify and test this as things work differently on different OS-es and this should work for you.
Note: due to the committed
composer.lockfile, Psalm will not automatically upgrade when newer versions are available.Refs:
Defensive coding fix
The
$matchesarray returned byexplode()can be an empty array. In that case,end()would returnfalse, which due to the string cast would become an empty string.Psalm flags the string cast though with:
... which in my opinion is incorrect.
I tried various options to get round this, but most ended up being flagged by Psalm again, even though IMO this flagging is incorrect.
Either way, the current change fixes the Psalm violation and does not trigger new violation flags.