vimeo / psalm

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

`psalm --version` fails on Composer projects without any autoloaders #11149

Open Xophmeister opened 2 hours ago

Xophmeister commented 2 hours ago

If I run psalm --version in a directory that contains a composer.json, but without a respective vendor/autoloader.php, Psalm will spit out an error. A workaround seems to be to run psalm --version within a fresh directory. For example:

repo$ psalm --version
Could not find any composer autoloaders in /repo
Add a --root=[your/project/directory] flag to specify a particular project to run Psalm on.
repo$ cd $(mktemp -d)
tmp.YQhKg9ZiiV$ psalm --version
Psalm 5.26.1@d747f6500b38ac4f7dfc5edbcae6e4b637d7add0

I understand why Psalm can't work without autoloaders, but --version should not be subject to this restriction.

psalm-github-bot[bot] commented 2 hours ago

Hey @Xophmeister, can you reproduce the issue on https://psalm.dev? These will be used as phpunit tests when implementing the feature or fixing this bug.