Skip to content
This repository was archived by the owner on Dec 9, 2019. It is now read-only.

Global install is not working #12

Closed
soullivaneuh opened this issue Jan 23, 2018 · 9 comments
Closed

Global install is not working #12

soullivaneuh opened this issue Jan 23, 2018 · 9 comments

Comments

@soullivaneuh
Copy link

Just after a fresh install with composer global require, I have this:

phpstan analyse -c phpstan.neon -l 3 src tests

Fatal error: Uncaught Error: Class 'PHPStanVendor\Jean85\PrettyVersions' not found in phar:///home/developer/.composer/vendor/phpstan/phpstan-shim/phpstan.phar/bin/phpstan:23
Stack trace:
#0 /home/developer/.composer/vendor/phpstan/phpstan-shim/phpstan.phar(4): require()
#1 {main}
  thrown in phar:///home/developer/.composer/vendor/phpstan/phpstan-shim/phpstan.phar/bin/phpstan on line 23
@ondrejmirtes
Copy link
Member

This happens if you have both phpstan/phpstan and phpstan/phpstan-shim installed at the same time. Or if the autoloader discovery mechanism can see the unprefixed version...

@soullivaneuh
Copy link
Author

In this case, it's another very valuable argument about removing direct phpstan dependencies from plugins: phpstan/phpstan-phpunit#11 (comment)

Currently, we just can't use phpstan globally at all with extension, if I understood well.

@ondrejmirtes
Copy link
Member

You have to install phpstan extensions alongside phpstan - so both globally or both locally. Mixing globally installed PHPStan and locally installed extension will not work well...

@soullivaneuh
Copy link
Author

What about docker image in this case? BTW, the docker image works because it's not a phpstan-shim install.

There is thing to do about that for sure. It's hard to use it on CI tools if we can't use it globally with local plugins. 😕

Could this issue be re-considered? Maybe not your top priority but I could do some search to find a solution on my free-time.

@soullivaneuh
Copy link
Author

BTW, maybe #7 would fit the need? :-)

@ondrejmirtes
Copy link
Member

There's already a custom way we do namespace prefixing using https://github.com/fprochazka/phpstan-compiler.

There's also been added a way how PHPStan extensions can be used within the official Docker image to the README yesterday, see: https://github.com/phpstan/docker-image/commit/74ec0aca4900da0d56908273ad8f8dfb4550b5fd

@soullivaneuh
Copy link
Author

There's already a custom way we do namespace prefixing

In this case, I don't technically understand why I have this issue. 🤔

There's also been added a way how PHPStan extensions can be used within the official Docker image to the README yesterday, see

Well, I saw this doc part but it does not fit the need: I need to build a phpstan image, usable on any user projects which include local phpstan-extension. I'm not aware of the project content so I need to be flexible.

I'll do some search about how to solve it, thanks for your time.

@ondrejmirtes
Copy link
Member

In this case, I don't technically understand why I have this issue.

It's probably some weird Composer autoloader issue

I need to build a phpstan image, usable on any user projects which include local phpstan-extension.

I understand that you're building this for FlintCI. I'm fine with that, PHPStan is open-source so anyone is free to build anything with it, but beware: PHPStan in the current form can execute userland code because of how it works: It uses native PHP reflection so it needs to load classes at runtime. And if a file with a class contains something else besides class declaration, that code is executed. So right now it's unsafe to run PHPStan analysis of someone else's code on your own server.

More about that here: phpstan/phpstan#67

I'm also planning to launch PHPStan SaaS in 2018 with a lot of extra features but that's just in the embryo phase 😊

@soullivaneuh
Copy link
Author

And if a file with a class contains something else besides class declaration, that code is executed. So right now it's unsafe to run PHPStan analysis of someone else's code on your own server.

This is why I run it on a container. 😉

But you are right, we have to be careful.

That's indeed for FlintCI integration, I'll see what I can do!

I'm also planning to launch PHPStan SaaS in 2018 with a lot of extra features

Can't wait! Good luck! 👍

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

No branches or pull requests

2 participants