boesing/psalm-plugin-stringf
A Psalm plugin that statically validates printf and sprintf format strings, checking that placeholders match the number and types of arguments passed. Mismatches are caught during analysis instead of at runtime, using Psalm's type inference to verify format specifiers across your codebase.
sprintf/printf/sscanf appear frequently. This plugin is the difference between "Psalm understands our format strings" and "Psalm gives up and treats them as mixed," so it directly gates how much type-safety signal we actually get from the tooling we already pay for.sprintf. This package is the cheap option in that trade-off and should be priced accordingly — small adoption cost, low strategic value, plausible abandonment.sprintf/printf with a mismatched placeholder count throws ArgumentCountError/ValueError at runtime, not at compile time. Catching this in CI moves a class of production incidents into pull-request feedback — a measurable reliability decision, not a style preference.sprintf usage in logging, i18n/translation layers, SQL fragment construction, and templating. If we decide those patterns are staying, tooling support becomes a roadmap item; if we're migrating off them, this package is a stopgap, not a commitment.sscanf-based parsers (importers, log scrapers) where a format/type drift produces wrong values rather than an exception — the most expensive failure mode to debug.Consider it when all of the following hold:
sprintf/printf/sscanf/fscanf usage — i18n catalogues, log formatters, CLI output, fixed-width or delimited parsers. Below a few dozen call sites, the payoff is negligible.Look elsewhere when:
NOASSERTION — no SPDX identifier — which will fail most dependency-approval pipelines and requires a human legal read. For a dev-only tool the blast radius is small, but the process cost is real and it should be decided explicitly, not discovered in an audit.Practical adoption note: treat it as a spike, not a rollout — one engineer, one sprint, measure findings caught versus noise generated, and decide on evidence. Budget for a possible fork.
For executives — one paragraph: This is a small, free add-on to a code-quality tool our engineers already run. It teaches that tool to understand PHP's format-string functions, so mistakes like a log line with three placeholders and two arguments — which currently crash at runtime in production — get caught in code review instead. Cost is a few hours of engineering time and no runtime dependency. The caveats are honest: the project is a 12-star community package from 2022 with an unclear license, so we should treat it as a tactical improvement we may need to maintain ourselves, not a platform investment. Recommend a one-sprint, one-engineer evaluation with a go/no-go based on defects caught, and no commitment beyond that.
For engineering leadership: Low-effort, low-risk win on correctness for format-string-heavy code, contingent on Psalm being a real part of our CI (not shelfware). It is a dev dependency — zero production footprint, zero deployment risk, trivially removable. The maintenance risk is genuine but bounded: the plugin is small enough to vendor or reimplement, and pinning the version caps the downside. Do not adopt it as a reason to keep Psalm if tooling consolidation is already on the table; adopt it because Psalm is staying and is currently blind to a defect class.
For the engineering team: Pin the version, run it on one service first, and count signal versus noise before widening. If the license question blocks the dependency pipeline, escalate early rather than working around it — that is a policy call, not an engineering one. If the package proves useful and stale, we own a fork; plan for that possibility up front instead of discovering it during a PHP upgrade.
How can I help you explore Laravel packages today?