| ▲ | idoubtit 4 hours ago | ||||||||||||||||||||||||||||||||||||||||||||||||||||
For anyone not familiar with PHP, static analysis is pretty much required because the official PHP type system is minimal. The detailed types are added through phpdoc comments, and they also help IDEs to provide a sane completion. For instance, the plain "array" should be detailed with phpdoc:
The static analysis will use both type systems, and it's the only way to check that phpdoc are consistent. Psalm has various levels of strictness, and even at a very lax level, it can help detect errors or code smells.There are two major static analysis tools for PHP, Psalm and PHPstan, both written in PHP. The latter used to be much slower, but last time I tried it there was little difference (about 20 s for 100k lines + dependencies). My guess is that a new contender, Mago, written in Rust, will probably soon replace those other tools. Its commands (analyze, lint) are already almost as complete as psalm/phpstan. Though the migration won't be easy because it does not have a notion of levels. | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | bel8 4 hours ago | parent [-] | ||||||||||||||||||||||||||||||||||||||||||||||||||||
PHP type system is lacking but I wouldn't call it minimal. PHP even has union types, just like TypeScript. The major issue is the lack of array types and it's 90% of the reason I see projects using extra linting tools. | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||