Narrowing types for #static_analysis | Jordi’s Ramblings
▻https://seld.be/notes/narrowing-types-for-static-analysis
I have spent the last year moving a few big old codebases, including Composer, to PHPStan’s level 8. Here are a few lessons I think I have learned in the process.
Baseline + strict static analysis is the way to go
Fix essential types as soon as possible
Broad input types, narrow output types
Split up functions to avoid returning union types