vimeo / psalm

A static analysis tool for finding errors in PHP applications
https://psalm.dev
MIT License
5.55k stars 659 forks source link

Add a way to specify that the scan phase should be single threaded? #1872

Open TysonAndre opened 5 years ago

TysonAndre commented 5 years ago

Either via the CLI (--no-parallel-scan?), or via an API that plugins can use.

The scan phase is usually fast for full program analysis

Use case: I'm writing a plugin that scans information about class constant declarations during the scan phase, to make Psalm treat a method as if a parameter has a certain array shape. A simplified version of the plugin is https://github.com/TysonAndre/psalm/blob/master/examples/plugins/APIFilterPlugin.php (it doesn't scan the codebase, though)

E.g. it might need to know that SomeFilterClass::some_method returns int to affect the inferred array shape for the parameters for SomeAPIClass::other_method

muglug commented 5 years ago

Happy to accept a PR - I think it's just a matter of changing the calls to Codebase::scanFiles in ProjectAnalyzer.

Alternatively there could be some way of a plugin specifying that it should run scanning in a single process, which would probably make a bit more sense thinking about it.