SanderRonde / phpstan-vscode

PHPStan plugin for VSCode
https://marketplace.visualstudio.com/items?itemName=SanderRonde.phpstan-vscode
MIT License
37 stars 7 forks source link

Wrong phpstan configuration in multi workspace environment #44

Closed cyl3x closed 8 months ago

cyl3x commented 8 months ago

If you have more than one workspace open, the configuration of the first workspace will always be selected, not the configuration of the active document workspace. This means that only the first workspace will work correctly, and any others will not.

My unprofessional guess would be that the selected workspace is only the first, not the active workspace.

SanderRonde commented 8 months ago

Ahh yes your guess is correct. I didn't really build this with multi-workspace support in mind since that's also pretty hard to implement when working with PHPStan (and even worse when things like Docker come into play). I don't think I'll be adding multi-workspace support any time soon since it's a lot of work and adds a lot of complexity for (I think) a relatively small group of users. I'm considering add a "hey multi-workspaces are not supported" warning but I'm not actually sure if that's worth it, what do you think? Would that help at all or is the error obvious enough anyways?

cyl3x commented 8 months ago

It would be nice to have a warning somewhere, as it took me some time to figure out the cause of my PHPStan errors - the wrong config/working directory :smile: and probably to avoid the creation of additional issues

As for complexity, isn't it enough to set the workspace to the active one, rather than the first one? At least that would solve all my problems with it (finding the right config/working directory) :thinking:

SanderRonde commented 8 months ago

Ah I'll add a warning then :)

I don't think there is such a thing as an active workspace. All are active at the same time and the only way to really infer this is to get the current workspace from the currently opened file. This then adds the complexity of needing to possibly change this workspace every time the active file changes. And then a lot of things depend on that such as workspace configuration, ${workspaceFolder} in arguments etc. These are all instantiated once from the workspace but will then need to be re-checked every time a file is opened. That's kind of the complexity of multi-workspace setups. I'd love to implement this if it were relatively easy but unfortunately it's kind of hard to.