Development Workflow

Static Analysis with PHPStan

Introduce PHPStan to find type and correctness problems before code reaches runtime.

Overview

PHPStan analyzes PHP source without executing the application. It can identify type mismatches, invalid calls, unsafe nullable access and other defects that ordinary tests may not encounter.

Adopt incrementally

Install PHPStan through Composer, define the paths to analyze and start at a level appropriate to the codebase. Existing applications can begin with a baseline and raise strictness as findings are resolved.

Keep the baseline honest

A baseline records existing findings; it should not become a permanent hiding place. Review new suppressions, remove obsolete entries and raise the analysis level deliberately.

Add framework knowledge carefully

Frameworks and dynamic APIs may require extensions or stubs. Use maintained integrations compatible with the installed PHPStan version.

CI usage

Run analysis on pull requests and fail on new findings. Pin tool versions through the lock file so local and CI results remain consistent.

Share this page Help other developers discover this resource.