Psalm 7 release: PHP security&static analysis software
Psalm 7 has been released, featuring a 10x faster default security analysis, a new Hack-inspired capability purity model, template defaults, and PHP 8.5 and 8.6 support.
summary is enough The release notes detail major performance gains and new features like security analysis by default, but unless you actively use PHP static analysis, the summary covers everything you need.
summary
Psalm 7 introduces a massive performance overhaul for its static analysis engine, making security taint tracking up to ten times faster and enabling it by default. It replaces previous annotations with a new capabilities-based purity model inspired by Hack, adding support for higher-order pure functions and purity templates. The release also brings graph-based dead code detection, template defaults to streamline generics, and full type checking for upcoming PHP 8.5 and 8.6 features like the pipe operator. Bundled framework plugins and streamlined configuration further ease adoption for existing PHP projects.
key points
- Security taint tracking is now enabled by default and runs up to 10x faster using bitmasks and compact function summaries.
- A new capability-based purity model replaces older annotations, allowing precise tracking of side effects like I/O and time.
- Native support added for PHP 8.5 pipe operators and PHP 8.6 partial function applications with full type inference.
- Template defaults prevent breaking changes when libraries introduce generic parameters.
who should read it
PHP developers and maintainers looking to upgrade their static analysis pipeline or secure complex applications.
discussion positive
consensus
Commenters discuss the state of PHP's type system, noting that while native types have improved, tools like Psalm remain essential for handling generics and array types. Some also mention upcoming Rust-based alternatives like Mago.
pushback
A few participants express frustration over the lack of native typed arrays in PHP core, while others debate the merits of rewriting developer tools in Rust.
For anyone not familiar with PHP, static analysis is pretty much required because the official PHP type system is minimal. The detailed types are added through phpdoc comments, and they also help IDEs to provide a sane completion. For instance, the plain "array" should be detailed with phpdoc:
/** * @param array<string, MyRecord> $input * @return list<int> */ function foo(array $input): array { foreach ($input as $string => $record) { // IDE knows $record is an instance of MyRecord
The static analysis will use both type systems, and it's the only way to check that phpdoc are consistent. …
This comment explains the practical necessity of PHPDoc-based static analysis in PHP and compares Psalm with PHPStan and newer tools like Mago.
Generated by an LLM from the article and thread. Check the sources before relying on it.