Open main menu

Changes

no edit summary
https://phpstan.org/has a quarter of a million installs as of early 2024 (just from packagist). Written largely by Ondřej Mirtes.
PHPStan seems more polished (perhaps because it's commercial and has a 'pro' version that adds a GUI) whereas [[phan]] is the original PHP static analysis tool Rasmus Ledorf uses.
==Analyzing in depth==
For an example of best-practices, single extension usage, see [https://github.com/ProfessionalWiki/Maps/blob/ee88211fadb3573b646cce005383450e96c3054e/phpstan.neon the example of Professional Wiki's Maps extension] which illustrates configuration file includes of a 'baseline'; error message suppression; and directory exclusions of problem code.
 
==Adding Extensions to PHPStan==
The PHPStan project has built a [[Composer]] plugin for the automatic installation of PHPStan extensions, [https://github.com/phpstan/extension-installer phpstan/extension-installer].
 
All you have to do is <code>composer require --dev phpstan/extension-installer</code> in your project and then you can e.g. <code>composer require --dev phpstan/phpstan-phpunit</code> to also add the [https://github.com/phpstan/phpstan-phpunit PHPUnit extension to PHPStan] rather than having to manually edit the <code>include</code> section of your phpstan.neon configuration.
 
There are extensions for Doctrine, PHPUnit, Symfony Framework, Mockery, Nette Framework, Laravel, Drupal, WordPress etc. See [https://phpstan.org/user-guide/extension-library the extension library]
[[Category:Wiki]]