The latest PHPStan release introduces major performance optimizations, cutting analysis times by up to 40% for large codebases through reflection object caching and analyzer code improvements.
PHPStan, the widely-used static analysis tool for PHP, has received a significant performance boost in version 2.1.34. The release delivers 25-40% faster analysis times through strategic caching of reflection objects and numerous raw performance optimizations to the analyzer's core code.

The Performance Breakdown
The speed improvements aren't incremental—they're substantial enough to change development workflows for teams working with large PHP codebases. In practical testing, the new release shows approximately 30% faster analysis compared to previous versions. This translates directly to developer time saved during CI/CD pipelines and local development cycles.
The primary optimization comes from caching reflection objects. In PHP, reflection is used extensively by static analyzers to understand class structures, method signatures, and type information. Previously, PHPStan would reconstruct these reflection objects repeatedly during analysis. Now, with intelligent caching, these objects are created once and reused throughout the analysis process.
Beyond reflection caching, the development team implemented dozens of micro-optimizations across the analyzer codebase. These include:
- Reduced memory allocations in hot paths
- Optimized type resolution algorithms
- Faster AST traversal for complex expressions
- Improved caching strategies for scope analysis
Why This Matters for PHP Development
Static analysis has become essential for modern PHP development, particularly with frameworks like Laravel, Symfony, and WordPress plugins. Large enterprise codebases can contain hundreds of thousands of lines of code, where analysis times of several minutes were common. A 30-40% reduction means:
- Faster CI/CD feedback: Developers get results quicker in automated pipelines
- Improved local development: Running PHPStan locally becomes more practical
- Better tool integration: IDE plugins can provide real-time feedback more responsively
For teams using PHPStan in continuous integration, this performance gain directly impacts development velocity. A project that previously took 5 minutes to analyze might now complete in 3-3.5 minutes—a meaningful improvement when multiplied across daily runs and multiple developers.
Technical Implementation Details
The reflection caching system works by creating a centralized cache of reflection objects keyed by class names and analysis contexts. When PHPStan encounters a class during analysis, it first checks the cache before performing expensive reflection operations. This is particularly effective because:
- Type resolution patterns: Many classes are referenced multiple times during analysis
- Dependency chains: Analysis of one class often triggers reflection of its dependencies
- Cross-file analysis: The same classes appear in multiple files across the codebase
The analyzer code optimizations target specific bottlenecks identified through profiling. For example, type inference for complex expressions involving multiple inheritance layers has been streamlined. The team also optimized the way PHPStan handles large arrays and object collections, which are common in PHP applications.
Real-World Impact

In practical terms, this release benefits several use cases:
Large Monorepos: Organizations with monolithic PHP codebases will see the most dramatic improvements. A project with 500,000+ lines of code might see analysis time drop from 8 minutes to 5 minutes.
Framework Development: Teams building PHP frameworks or libraries that need to maintain strict type safety across complex inheritance hierarchies.
Legacy Code Migration: When gradually introducing type safety to legacy PHP applications, faster analysis makes the process more iterative and developer-friendly.
Plugin Ecosystems: WordPress plugin developers or package maintainers who need to ensure compatibility across multiple PHP versions and dependency combinations.
Getting Started with the Update
Upgrading to PHPStan 2.1.34 is straightforward. The release maintains backward compatibility with existing configurations, so teams can upgrade without modifying their phpstan.neon files or CI scripts.
For new users, PHPStan provides multiple rule levels (0-9), with higher levels enforcing stricter type safety. The performance improvements apply across all levels, but are most noticeable in larger projects using level 6 or higher.
The tool integrates with popular development environments:
- VS Code: PHPStan extension for real-time analysis
- PHPStorm: Native integration via the PHPStan plugin
- CI/CD: GitHub Actions, GitLab CI, Jenkins, and other platforms
Looking Ahead
This performance release demonstrates PHPStan's ongoing commitment to practical improvements rather than just feature additions. The development team has focused on making the tool more usable for day-to-day development rather than adding complexity.
For teams considering static analysis adoption, this release lowers the barrier to entry. Faster analysis means less friction in development workflows, making it easier to integrate type checking into daily practices.
The improvements also set the stage for more sophisticated analysis capabilities. With faster core performance, the team can potentially add more complex rules without sacrificing user experience.
Resources and Further Reading
- Official PHPStan Website: phpstan.org - General information and documentation
- GitHub Repository: github.com/phpstan/phpstan - Source code and release notes
- Configuration Guide: phpstan.org/user-guide/configuration - Setting up PHPStan for your project
- Rule Levels Documentation: phpstan.org/user-guide/rule-levels - Understanding different analysis strictness levels
The release notes for PHPStan 2.1.34 detail all specific changes and can be found on the project's GitHub releases page. For teams running older versions, the upgrade path is straightforward and the performance benefits make it worthwhile to update promptly.
This update reinforces PHPStan's position as the go-to static analysis tool for PHP, combining rigorous type checking with practical performance that fits into modern development workflows.

Comments
Please log in or register to join the discussion