Skip to main content

Glossary P

Glossary · Cross-cutting

PHPStan

Area
Both strands
Related
PHPUnit, Non-GxP, QA

PHPStan is an open-source static analysis tool for PHP that finds errors in code without running it and without the need to write tests.

The project sums up its approach as finding bugs without writing tests: it scans the whole codebase, including rarely executed parts that tests do not reach. PHPStan can run on a developer's machine and in continuous integration (CI), where checks start automatically whenever the code changes, with the aim of stopping bugs from ever reaching customers on the live system.

How strict the check is depends on the rule level. PHPStan currently has 11 levels, from 0, the loosest, to 10, the strictest. They are cumulative: a given level includes every check of the levels below it. Among other things, the lower levels look for unknown classes and methods, undefined variables, return and argument types, dead code and missing type declarations. Level 7 adds a check for values that can be of several types: it reports code that works for only some of them, such as a call to a method that not all of those types have.

Several business applications we have built for clients in the pharma sector are checked with PHPStan at level 7, and some are also screened for banned, risky functions and for consistent code style. The results of this static code analysis can go to the client's quality assurance team (QA).

Where the term appears

Sources

  1. README des Repositorys phpstan/phpstan (Branch 2.1.x) (opens in a new tab)

    PHPStan (GitHub phpstan/phpstan) accessed

  2. PHPStan: Find Bugs Without Writing Tests (opens in a new tab)

    PHPStan s.r.o. (phpstan.org) accessed

  3. User Guide: Rule Levels (opens in a new tab)

    PHPStan s.r.o. (phpstan.org) accessed

Let's talk about your project.

If this term is on your desk right now, a conversation usually helps faster than any definition.

Search the website

Popular topics

All results