symfony psalm integration

Symfony framework development team are adding Psalm into github action, this will help them check errors in Pull Requests. Psalm is a static analysis tool for PHP created by Vimeo, that helps you identify problems in your code, so your team can sleep a little better.

In a pull request by Tobias Nyholm, Symfony Core team developer, suggested to add psalm to check every PR for some errors that can be found with a static analyser. This is to help/automate the PR review process. All psalm errors found should be reviewed and discussed. The maintainers can decide to ignore some warnings if they want to.

Could Psalm really help Symfony ?

Alexander M. Turek, Core team developer, explained that errors reported by the starter levels (8 in Psalm, 0 in PHPStan) are mainly problems that need to be fixed so that the tool is able to understand the codebase. The tool won’t be helpful at that level.

Symfony Psalm integration

So basically for large codebase, Psalm need to get started with starter level first to “understand” the code base, then the level could be adjusted later. However there is another issue with Psalm running on large codebase which is the false positive which will make life much harder for developer.

Nicolas Grekas reported that running Psalm on the String component of Symfony return only false positive. So overall it’s an interesting experience to see how Static analysis tools for PHP can help large codebases making PHP applications maintenance better and easier.

In a recent Psalm blog post, Matt Brown explained how to avoid false-positives with flow-sensitive conditional analysis. Psalm is also improving since its first release three years ago, this solution will help avoiding false positive in large codebase but also adds roughly 6% to the average runtime of Psalm.

More information about symfony at https://symfony.com/

More information about Psalm at https://psalm.dev/

LEAVE A REPLY

Please enter your comment!
Please enter your name here