Global install is not working
soullivaneuh opened this issue ยท 9 comments
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
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...
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.
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...
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.
BTW, maybe #7 would fit the need? :-)
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
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.
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
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!