Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Psalm analysis via Phar can break if custom autoloader is used in config #565

Closed
muglug opened this issue Mar 9, 2018 · 5 comments
Closed
Labels

Comments

@muglug
Copy link
Collaborator

muglug commented Mar 9, 2018

To reproduce:

  • create a project with its own autoload="myautoloader.php" configured in psalm.xml which requires vendor/autoload.php
  • install an old version of Psalm (e.g. composer require --dev vimeo/psalm:0.3) for that project
  • analyse that project using the phar and --root=[project root] where the Phar has a different version of Psalm
  • observe hijinks

This is also seen when just running Psalm on a different project with --root (not using phar)

cc @weirdan

@muglug muglug added the bug label Mar 9, 2018
@muglug
Copy link
Collaborator Author

muglug commented Mar 9, 2018

Possible solutions are to have Psalm scan that file and remove autoloaders that are already in use before requireing

@weirdan
Copy link
Collaborator

weirdan commented Mar 9, 2018

I can't reproduce it, probably something is missing from your description.

But I suppose it's the reversal of the #551 ? Now psalm loads it's classes from the project vendor dir?
If so, it could be solved with the namespace prefix hack you mentioned there. There's a new box compactor available that does just that.

Alternatively, psalm could see that it's own copy is available in project vendors, and run that instead (supposedly developers have a reason to not update).

Interestingly enough, PHPUnit seems to work mostly fine in the similar scenario (7.x installed globally, 6.x installed locally). I think that's the consequence of very stable code base.

@muglug
Copy link
Collaborator Author

muglug commented Mar 9, 2018

There's a new box compactor available that does just that.

That would be incredibly ideal. Again, it would just need to ignore the stubs directory.

@muglug
Copy link
Collaborator Author

muglug commented Mar 9, 2018

I'll investigate that - thanks

@weirdan
Copy link
Collaborator

weirdan commented Mar 9, 2018

box-project/box#31 - this is where it was introduced.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants