Developer Tools

Psalm: Static Analysis for PHP

Psalm analyzes PHP code to find type errors and other issues before they become runtime defects.

Overview

Psalm is a static analysis tool for PHP. It inspects source code without executing the application and reports potential problems involving types, control flow and program structure.

Why developers use it

Static analysis can reveal invalid arguments, unsafe nullable values, unreachable code and mismatches between declared and actual types. This is particularly useful when refactoring a codebase or maintaining shared libraries.

Getting started

Psalm is commonly installed as a development dependency through Composer. Initialize a configuration for the project, choose the source directories to analyze and run the analyzer as part of the development workflow.

Adoption advice

Introduce analysis gradually in an existing application. Resolve high-confidence findings first, keep suppressions narrow and review them periodically. Run analysis in continuous integration so new issues are detected before changes are merged.

Official resource

Psalm documentation: https://psalm.dev/docs/

Additional notes consolidated from the previous entry

Overview

Psalm performs static analysis with a focus on types, taint analysis and potential defects.

Example

composer require --dev vimeo/psalm
vendor/bin/psalm --init
vendor/bin/psalm

Run analysis regularly and review its findings as part of code review.

Official website: Psalm

Evaluation checklist

  • Prefer official documentation and repositories.
  • Check supported PHP versions and release history.
  • Review installation instructions and license terms.
  • Keep dependencies updated and run security checks.
Share this page Help other developers discover this resource.