Skip to content
HN On Hacker News ↗

Announcing Psalm 7

▲ 81 points • 49 comments • by danogentili • 2w ago • HN discussion ↗

Pangram verdict · v3.3

We believe that this text is a mix of AI and human-written content.

23 %

AI likelihood · overall

Mixed
77% human-written 23% AI-generated
SEGMENTS · HUMAN 14 of 23
SEGMENTS · AI 7 of 23
WORD COUNT 1,275
PEAK AI % 100% · §14
Analyzed
Nov 9
backend: pangram/v3.3
Segments scanned
23 windows
avg 55 words each
Distribution
77 / 23%
human / AI fraction
Verdict
Mixed
Pangram v3.3

Article text · 1,275 words · 23 segments analyzed

Human AI-generated
§1 Human · 0%

November 2, 2026 by Daniil Gentili - 10 minute read Cross-posted from Daniil Gentili's blog ». Announcing the release of Psalm 7! Featuring a simply enormous number of new features and bug fixes, such as: security analysis on by default: fully refactored for 10x+ performance and much greater coverage, in the same run as type checking and dead code detection; much deeper security analysis taint tracking: NoSQL, LLM prompt and URL injection, new sources like php://input and uploaded file names, flows through closures, generators, traits and by-reference parameters, and ready-made stubs for Guzzle, PSR-7, Monolog, MongoDB and more. a new purity model based on Hack's capabilities: declare exactly which side effects a function may have (io, time, write-props...), with purity templates for classes, closures and automatically inferred annotations; graph-based dead code detection: If nothing reachable uses a class, function, method, constant, variable, etc, Psalm finds it, now properly handling unused cycles as well. Template defaults (@template TError of Throwable = RuntimeException) for classes, functions and methods: Result<int> just works, and libraries can add templates without breaking their users. PHP 8.5 and 8.6 support: Full support for Partial Function Application, the pipe operator, and much more!

§2 Human · 4%

Daily releases.

§3 AI · 100%

Features and fixes reach you the day they land, no more waiting on dev-master. Framework plugins in the box. The PHPUnit, Symfony, Laravel, Mockery and sabre/event plugins ship with Psalm and switch on by themselves.

§4 Mixed · 55%

Zero setup.

§5 Human · 0%

a bigger Psalm maintainer team: @alies-dev has joined the Psalm maintainer team, contributing many new useful features and bugfixes! An official Discord community! And so, so many other new features and bugfixes! Psalm 7 runs on 64-bit PHP 8.2 to 8.6.

§6 Human · 0%

Upgrading is simple for most projects: see Upgrading below. Security analysis: faster, always on, in a single run Taints are now stored as a bitmask, and the taint graph is resolved over compact summaries of each function.

§7 Human · 0%

This makes security analysis up to 10x faster. Combined analysis (#11384) runs type checking, security analysis and dead code detection together in one run, so taint analysis is now on by default (#11399). Taint issues are reported with a SECURITY severity, and with a rank in SARIF reports (#12068, #11383).

§8 Human · 0%

The results no longer change between runs or with the thread count (#11946, #11952, #11953).

§9 Human · 0%

Deeper taint tracking <?php $run = function (string $c): void { shell_exec($c); }; $run((string) $_GET['cmd']); // TaintedShell, through the closure $mongo = new MongoDB\Driver\Manager('mongodb://localhost'); $mongo->executeQuery('db.users', new MongoDB\Driver\Query(['name' => $_GET['name']])); // TaintedNosql /** @return mixed */ function body() { return json_decode((string) file_get_contents('php://input'), true); } eval((string) body()); // TaintedEval: php://input is a source Try it on psalm.dev » New taint kinds: TaintedNosql (MongoDB sinks), TaintedLlmPrompt (prompt injection), and TaintedUrlComponent / TaintedUrlPath (query and path injection).

§10 AI · 100%

curl options and CURLFile are reported by what they do: SSRF, header injection, file access, sleep or callables.

§11 Human · 0%

Every taint type is now documented (#11944, #11746, #12097, #12099, #12468).

§12 Human · 0%

New sources: php://input, STDIN, the client-sent entries of $_SERVER and $_FILES, getopt(), $argv, DNS answers, exception messages, and the files, paths and URLs builtins read (#11945, #12086, #12246, #12245, #12135, #12139).

§13 AI · 100%

Taint now flows through closures and callable parameters, generators and iterators, by-reference parameters, foreach by reference, global and static variables, trait method bodies, promoted constructor properties, __toString(), inherited methods and their overrides, exceptions, and builtin functions and objects (#12147, #12096, #12095, #12121, #12243, #12255, #12272, #12091, #12127, #12262, #12084, #12102).

§14 AI · 100%

Fewer false positives: taints a type can't carry are removed (an int has no html taint).

§15 AI · 100%

Array keys are tracked much more precisely. Inferred-pure functions are specialized per call, and @psalm-cli-only marks code whose output isn't an HTML response (#12079, #12348, #12150, #12375, #12048, #12459).

§16 Human · 0%

Library stubs: Psalm ships taint and purity stubs for Guzzle, PSR-7, PSR-18, psr/log, Monolog, mongodb/mongodb, amphp (http-client, byte-stream, file, process), phpClickHouse, PhpSpreadsheet, Archive_Tar, php-vips, webklex/php-imap and webmozart/assert. A stub is loaded only when your code uses the library (loadLibraryStubs, on by default) (#12460–#12467, #12481–#12484).

§17 Human · 0%

More expressive annotations (docs): conditional sinks: @psalm-taint-sink ($mode is 0 ? null : 'html') $content (#12458); sinks on array values only: @psalm-taint-sink sql $params[*] (#12171); sources under one key of the return value: @psalm-taint-source input return['key'] (#12455); taint complements: ~(html|has_quotes) (#12300); @psalm-flow through callables (($compute()) -> return), the receiver (($this) -> return), $this properties, and keyed stores (($value) -> Store::$data[$key]) (#12299, #12302, #12456, #12312, #12327); @psalm-taint-property-bag (#12486); custom taints declared in psalm.xml (#12330). Plugin API for taints: Codebase::getTaintNode(), getTaintPropertyNode(), addTaintPath(), getReceiverTaintPath(), and the taint nodes of a call's return value, arguments and receiver (#12454, #12414, #12489, #12535). A new purity model: capabilities @psalm-pure, @psalm-mutation-free and @psalm-external-mutation-free are replaced by capabilities, modelled on Hack's contexts and capabilities. A function-like declares exactly which side effects it may have: read-props, write-this-props, write-props, read-globals, write-globals, write-refs, io and time, with pure and impure at the two ends (#11984): <?php /** @psalm-capabilities time */ function today(): string { return date('Y-m-d'); // no issue } /** @psalm-pure */ function todayWrong(): string { return date('Y-m-d'); // ImpureFunctionCall: ... requires time } Try it on psalm.dev » Psalm infers purity across the call graph. Where an annotation could be added, it can suggest one: set <psalm suggestPurityAnnotations="true"> to get MissingPureAnnotation and MissingImmutableAnnotation (and their abstract and interface variants), and run --alter --issues=MissingPureAnnotation,MissingImmutableAnnotation to add the annotations.

§18 Human · 0%

The --alter command works without the attribute. The suggestions are opt-in.

§19 Human · 0%

Pure and read-only functions are taint-specialized automatically, so annotating your code also removes false positives from security analysis. Builtins, SPL, the Random, phpredis and MongoDB extensions and more declare what they do. clone, __toString(), __invoke(), ArrayAccess, destructors, new $class and parameter defaults are now checked too. @psalm-pure can be used on classes, and plugins can declare the capabilities of the methods they handle. The new Purity Model article explains the model in full.

§20 Human · 0%

Purity templates Many functions are only as pure as what they are given: array_map() is pure when its callback is. Purity templates are template parameters whose values are capability sets instead of types, like Hack's [ctx $f] contexts.

§21 Mixed · 44%

A function can now be both pure and higher-order, and each call costs only what its arguments do (#11984).

§22 AI · 100%

With Closure[_], a function takes its purity from the closure it is given: <?php /** * @psalm-pure * @param Closure[_](int): int $f */ function apply(Closure $f, int $x): int { return $f($x); } /** @psalm-pure */ function double(int $x): int { return apply(fn(int $y): int => $y * 2, $x); // no issue: the closure is pure } /** @psalm-pure */ function noisy(int $x): int { return apply(function (int $y): int { echo $y; return $y; }, $x); // ImpureFunctionCall: The context is pure but function call on apply requires io } /** @psalm-pure */ function lengths(array $words): array { return array_map(fn(string $w): int => strlen($w), $words); // no issue: builtins taking callbacks work the same way } On a class, a purity template lets each subclass decide what its methods may do: <?php /** @psalm-purity-template P */ abstract class Handler { /** * @psalm-pure * @psalm-purity-from-template P */ abstract public function handle(string $input): string; } /** @extends Handler[pure] */ final class Upper extends Handler { /** @psalm-pure */ #[Override] public function handle(string $input): string { return strtoupper($input); } } /** @extends Handler[io] */ final class Printer extends Handler { /** @psalm-capabilities io */ #[Override] public function handle(string $input): string { echo $input; return $input; } } /** @psalm-pure */ function viaUpper(Upper $handler): string { return $handler->handle('a'); // no issue: Upper binds P to pure } /** @psalm-pure */ function viaPrinter(Printer $handler): string { return $handler->handle('a'); // ImpureMethodCall: The context is pure but method Printer::handle requires io } Traversable, Iterator, IteratorAggregate and Generator have a purity template, for what iterating over them does.

§23 AI · 100%

iterable has one too.