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

PHAR file for each release #110

Closed
markwatney2016 opened this issue Jan 30, 2017 · 12 comments
Closed

PHAR file for each release #110

markwatney2016 opened this issue Jan 30, 2017 · 12 comments

Comments

@markwatney2016
Copy link

markwatney2016 commented Jan 30, 2017

Would be very handy if there was a PHAR file for every release especially if you want to analyze projects that run on PHP < 7 because in those projects you can not require phpstan/phpstan in the root composer.json of the project you would like to analyze.

@markwatney2016 markwatney2016 changed the title PHAR files for each release PHAR file for each release Jan 30, 2017
@ondrejmirtes
Copy link
Member

You can currently solve this by installing and using PHPStan globally in your system. This is supported and even with a nice autoloader autodiscovery feature: https://github.com/phpstan/phpstan#autoloading-for-global-installation

I plan to release PHARs regularly once this known issue is solved:

If you install PHPStan globally on your system, you can experience errors resulting from using different versions of dependencies than PHPStan uses. For example if PHPStan's version of Symfony Console has a method with different arguments than your version of Symfony Console and you use this method in the analysed code, PHPStan can mark that as error. This will be solved in the future by prefixing the namespaces of PHPStan's dependencies.

@soullivaneuh
Copy link
Contributor

You can also use this for class conflict: https://github.com/webmozart/php-scoper

Related PHPUnit issue: sebastianbergmann/phpunit#2015

@tommy-muehle
Copy link

tommy-muehle commented Jan 31, 2017

@markwatney2016
I had the same problem. In case you familiar with Docker you can use this image: https://github.com/phpstan/docker-image

@agarzon
Copy link

agarzon commented Feb 28, 2017

👍 for phar files.

@fprochazka
Copy link
Contributor

fprochazka commented Mar 6, 2017

@ondrejmirtes I'd like to add phpstan to CI of all my packages, but the conflicting dependencies with Nette are a problem for me. As you know, we spoke about generating phar and prefixing phpstan dependencies earlier.

Do you have in mind a specific way of generating the phar? I need this solved in the following two or three weeks, so I'm open to suggestions and willing to send a PR.

@ondrejmirtes
Copy link
Member

@fprochazka Which dependencies exactly cause you to conflict? I can loosen the version constraints if it helps you.

What I'd need to be able to create PHAR files is to have a tool similar to https://github.com/webmozart/php-scoper. I need to prefix all 3rd party dependencies (all used namespaces except for PHPStan) before building the PHAR file. I don't want to prefix PHPStan's own classes in order for the config files to still work. PHP-Scoper prefixes everything.

I can create a PHAR package without prefixing the namespaces, but that doesn't solve the issue of conflicting dependencies versions - if there's something different in a used library when compared to the PHPStan's version, it will likely report some false positives because PHPStan will use the reflection of the version it uses, not of the analyzed project. That's why I want to prefix the dependencies.

@glensc
Copy link

glensc commented May 4, 2017

not sure that is the exact problem, but i tried to use via docker, and the fact that this tool seems to load vendor/ from project causes issues because i have different symfony version installed (and can't change that). can the tool not load vendor/autoload? because if it does, it doesn't matter how phpstan is installed (phar or docker or composer global) the symbol errors will occour.

➔ docker run -v $PWD:/app --rm phpstan/phpstan:0.6 analyze src

Fatal error: Interface 'Symfony\Component\EventDispatcher\EventSubscriberInterface' not found in /app/src/EventListener/LegacyWorkflowListener.php on line 26
➔ docker run -v $PWD:/app --rm phpstan/phpstan analyze src

Fatal error: Interface 'Symfony\Component\EventDispatcher\EventSubscriberInterface' not found in /app/src/EventListener/LegacyWorkflowListener.php on line 26
➔ 

ps: for building .phar itself, i recommend box: https://github.com/box-project/box2

@fprochazka
Copy link
Contributor

fprochazka commented May 5, 2017

I've started working on https://github.com/fprochazka/phpstan-compiler. It solves both creating a phar and vendor conflicts. For those interested, can you please test the following?

phpstan-0.6.4.phar

  • build from 0.6.4-fixed
  • command php -dphar.readonly=0 bin/compile --repository "https://github.com/fprochazka/phpstan.git" 0.6.4-fixed

You should be able to load extenion configs using phar://phpstan.phar/vendor/phpstan/phpstan-doctrine/extension.neon.

phpstan-master.phar

The extensions are not compatible with master, so there are none at the moment in this build.

@ondrejmirtes
Copy link
Member

I just released PHPStan 0.7 which includes a PHAR archive :) See the release notes for details.

@teohhanhui
Copy link
Contributor

teohhanhui commented May 17, 2017

What is the extension story when using the PHAR or phpstan-shim? What about when installing locally vs globally? Maybe there can be better clarification in the README with examples...

@fprochazka
Copy link
Contributor

@teohhanhui the compiler should be ready for the extensions, but - phpstan/phpstan-shim#2 (comment)

If you wanna, you might be able to compile the 0.7 PHAR yourself, but be aware, it's marked experimental at this point.

@teohhanhui
Copy link
Contributor

Okay, back to the old way of installing locally it is then.

@lock lock bot locked as resolved and limited conversation to collaborators Dec 20, 2019
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

8 participants