Infer vs PHPStan
Which should you use? A side-by-side look at what each one does, who it suits, what it costs, how hard it is to set up, and where each falls short.
Open source · MIT
A static analyzer that scans Java, C, C++, and Objective-C code for bugs without running it.
Open source · MIT
A PHP static analysis tool that finds bugs in code without running it.
The short answer
Choose Infer if you need…
- Developers working on Java, C, C++, or Objective-C codebases
- Teams who want an automated bug check as part of their code review process
- People comfortable installing a command-line developer tool from a packaged release
Choose PHPStan if you need…
- PHP developers who want to catch bugs earlier than tests alone allow
- Teams maintaining large PHP codebases
- Developers who want stricter checks on existing PHP code
Side-by-side
| Infer | PHPStan | |
|---|---|---|
| Type | Dev tool | Dev tool |
| Price | Free and open source | Free and open source |
| Licence | MIT | MIT |
| GitHub stars | 15.7k | 14.1k |
| Setup difficulty | Intermediate | Intermediate |
| How you get it | Download the app | See the README |
| Main language | OCaml | PHP |
| Last code update | 4 days ago | 4 days ago |
What each one is
Infer
Infer is a static analysis tool, meaning it reads source code and looks for likely bugs without executing the program. It supports Java, C, C++, and Objective-C, and is written in OCaml. Developers use it to catch problems in code before it ships.
PHPStan
PHPStan is a tool that checks PHP code for errors without executing it. It reads your code and reports likely bugs, such as calls that will fail, before you run the code or write tests for it. The README says it aims to make PHP's correctness checkable line by line before running, similar in spirit to compiled languages.
Best for
Infer
- Developers working on Java, C, C++, or Objective-C codebases
- Teams who want an automated bug check as part of their code review process
- People comfortable installing a command-line developer tool from a packaged release
PHPStan
- PHP developers who want to catch bugs earlier than tests alone allow
- Teams maintaining large PHP codebases
- Developers who want stricter checks on existing PHP code
Strengths
Infer
- Covers four widely used languages in one tool
- MIT-licensed core, with an active public repository
- Installable from packaged releases, so you do not have to build it from source
PHPStan
- Finds whole classes of bugs without needing to run the code
- Open source under the MIT license with an active project history
- Official documentation, config reference, and an online playground are available
Not ideal for
Infer
- Beginners looking for a point-and-click tool, since the README points to packaged installs and a source build rather than a graphical interface
- Projects in languages outside the four listed, since the README only names Java, C, C++, and Objective-C
- Anyone needing Java support without checking licensing, because the README notes Java support may require GPL-licensed components
PHPStan
- Non-PHP developers, since it only analyzes PHP code
- People looking for a runtime testing framework; PHPStan does not run your code, so it complements tests rather than replacing them
- Those who need a graphical interface without paying, since the web UI is part of the paid PHPStan Pro add-on
Trade-offs
Infer
- Java support may pull in GPL-licensed components, which can matter for some projects
- The README is short and defers most setup detail to external documentation
- Analysis specifics such as which bug types it finds are not described in the README excerpt
PHPStan
- The README does not detail setup steps, so you must follow the linked documentation to get started
- Its most convenient interface (web UI and watch mode) is a paid add-on, PHPStan Pro
- Static analysis can only judge what it can infer from the code, so results depend on the code's type information
Getting started
Infer
Clone the repository
git clone https://github.com/meta/inferPHPStan
Clone the repository
git clone https://github.com/phpstan/phpstanFrequently asked questions
What is the difference between Infer and PHPStan?
Infer: A static analyzer that scans Java, C, C++, and Objective-C code for bugs without running it. PHPStan: A PHP static analysis tool that finds bugs in code without running it. Infer suits developers working on java, c, c++, or objective-c codebases, while PHPStan suits php developers who want to catch bugs earlier than tests alone allow.
Are Infer and PHPStan free?
Infer: Free and open source. PHPStan: Free and open source.
Is Infer or PHPStan more popular?
Infer has more GitHub stars (15.7k) than PHPStan (14.1k). Popularity isn't the same as fit — check which one matches your use case above.
What are other alternatives to Infer and PHPStan?
Other options people compare them with include SwiftLint, Super-Linter.
Keep comparing
Built from our catalogue entries for both products: open-source details come from each project's README (AI-assisted, refreshed weekly) and GitHub data; AI-tool details are editorial. Spotted something wrong? Let us know from either product's page.