Psalm 7 release: PHP security&static analysis software psalm.dev · 8 points · 3 ...

@best

Psalm 7 release: PHP security&static analysis software psalm.dev · 8 points · 3 comments · HN thread

TL;DR Psalm 7.0.0 is released, the static analyser for PHP. Its main changes are security (taint) analysis enabled by default and up to 10x faster, deeper taint tracking, a new capability-based purity model with purity templates, graph-based dead code detection, template defaults, and PHP 8.5/8.6 support. The Hacker News thread is tiny (3 comments) and mostly a side argument about PHP's type declarations.

  • Security analysis is on by default and runs in the same pass as type checking and dead code detection; taints are stored as bitmasks, which the article says makes it up to 10x faster.
  • Taint tracking adds NoSQL, LLM prompt and URL injection kinds, and new sources such as php://input, STDIN, $_FILES and getopt(), with flows through closures, generators, traits and by-reference parameters.
  • Purity annotations @psalm-pure and friends are replaced by capabilities such as io, time and write-props, plus purity templates that let higher-order functions and subclasses inherit purity from what they are given.
  • Dead code detection now works on a reference graph, so unused cycles of classes and methods are reported.
  • Template defaults let libraries add generic parameters without breaking users; PHP 8.5 pipe operator and PHP 8.6 partial function application are typed.
  • Psalm 7 runs on 64-bit PHP 8.2 to 8.6, is installed with composer require --dev vimeo/psalm:^7.0 -W, and bundles framework plugins that enable themselves.

Discussion The thread is very small, with only three comments and eight points, so there is little to summarise. The one substantive exchange is a commenter reacting to PHP's lack of built-in return type documentation, which another commenter answers by pointing out that PHP has had native return type declarations since version 7. The mood is mildly sceptical and off-topic relative to the Psalm release itself, and none of the comments discuss the new features.

  • PHP's typing is weaker than it should be, despite its progress (a few): One commenter complains that basic return typing still seems missing from PHP itself and calls the language's shortcomings numerous. This is a general gripe rather than a view on Psalm.
  • Native return types already exist since PHP 7 (a few): A reply points out that PHP has supported return type declarations since version 7, with intersection and literal types added later, and suggests a quick search would have answered the question.

#php #staticAnalysis #security #typeSystem #release