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 Business application In general terms, a business application is software used to perform or support business functions. Read in the glossary → 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 QA is short for quality assurance; in the EU, both good manufacturing practice (GMP) and good distribution practice (GDP) are defined as part of it. Read in the glossary → (QA).
Where the term appears
See also
-
PHPUnit
PHPUnit is an open-source testing framework for PHP that developers use to write automated tests comparing actual results with expected ones.
Cross-cutting
-
Non-GxP
Non-GxP describes a system that its operator does not classify as GxP-relevant; PIC/S guidance uses the term without defining it formally.
Pharma
-
QA
QA is short for quality assurance; in the EU, both good manufacturing practice (GMP) and good distribution practice (GDP) are defined as part of it.
Pharma
Sources
-
README des Repositorys phpstan/phpstan (Branch 2.1.x) (opens in a new tab)
PHPStan (GitHub phpstan/phpstan) accessed
-
PHPStan: Find Bugs Without Writing Tests (opens in a new tab)
PHPStan s.r.o. (phpstan.org) accessed
-
User Guide: Rule Levels (opens in a new tab)
PHPStan s.r.o. (phpstan.org) accessed