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

Pro mode in docker #3897

Closed
stanislav-janu opened this issue Sep 30, 2020 · 15 comments
Closed

Pro mode in docker #3897

stanislav-janu opened this issue Sep 30, 2020 · 15 comments

Comments

@stanislav-janu
Copy link

Hi, I'm trying run new PRO in docker, but there is problem and PHPStan writes me a strange bug.

What am I doing wrong?

docker run --rm -p 11111:11111 -v $PWD:/app phpstan/phpstan analyse app --memory-limit=1G --ansi --pro
Note: Using configuration file /app/phpstan.neon.
 352/352 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%


                                                                                
 [ERROR] PHPStan Pro can't be launched because of these errors:                 
                                                                                

                                                                                
 [OK] No errors                                                                 
                                                                                

Please fix them first and then re-run PHPStan.

Thanks.

@stanislav-janu
Copy link
Author

phpstan.neon

parameters:
	level: 'max'
	checkMissingIterableValueType: false
	checkGenericClassInNonGenericObjectType: false
	ignoreErrors:
		- '#^Class SoapClient not found\.(.*)$#'
		- '#^Construct empty\(\) is not allowed\. Use more strict comparison\.$#'
		- '#Call to an undefined method [a-zA-Z0-9\\_]+::addReCaptcha\(\)#'
		- '#^Short ternary operator is not allowed\.#'

includes:
	- vendor/phpstan/phpstan-nette/rules.neon
	- vendor/phpstan/phpstan-nette/extension.neon
	- vendor/phpstan/phpstan-strict-rules/rules.neon
	- vendor/phpstan/phpstan-deprecation-rules/rules.neon
	- vendor/thecodingmachine/phpstan-safe-rule/phpstan-safe-rule.neon

@ondrejmirtes
Copy link
Member

What do you see when you run PHPStan in Docker without --pro? Does it pass?

@stanislav-janu
Copy link
Author

stanislav-janu commented Sep 30, 2020

What do you see when you run PHPStan in Docker without --pro? Does it pass?

Without --pro is everything ok.

docker run --rm -p 11111:11111 -v $PWD:/app phpstan/phpstan analyse app --memory-limit=1G --ansi
Note: Using configuration file /app/phpstan.neon.
 352/352 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%


                                                                                
 [OK] No errors                                                                 
                                                                                

ondrejmirtes added a commit to phpstan/phpstan-src that referenced this issue Oct 1, 2020
@ondrejmirtes
Copy link
Member

Hi, can you please pull phpstan/phpstan:nightly image and try it by running --pro -vvv? It should output some debugging messages.

Please note that the phpstan/phpstan:nightly is quite big (as opposed to the stable images) so don't be surprised :)

@ondrejmirtes
Copy link
Member

I just made the nightly image much smaller :)

@stanislav-janu
Copy link
Author

docker run --rm -p 11111:11111 -v $PWD:/app phpstan/phpstan:nightly analyse app --memory-limit=1G --ansi --pro -vvv
Note: Using configuration file /app/phpstan.neon.
Result cache not used because the cache file does not exist.
 352/352 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100% 22 secs/22 secs 64.0 MiB


                                                                                
 [ERROR] PHPStan Pro can't be launched because of these errors:                 
                                                                                

                                                                                
 [OK] No errors                                                                 
                                                                                

Please fix them first and then re-run PHPStan.
Result cache was not saved.
Used memory: 64 MB

@ondrejmirtes
Copy link
Member

Please try to pull phpstan/phpstan:nightly and run it again, there should be more messages.

@stanislav-janu
Copy link
Author

stanislav-janu commented Oct 1, 2020

Some error is there, but I expected it after colon.

> docker run --rm -p 11111:11111 -v $PWD:/app phpstan/phpstan:nightly analyse app --memory-limit=1G --ansi --pro -vvv
Note: Using configuration file /app/phpstan.neon.
Result cache not used because the cache file does not exist.
 352/352 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100% 20 secs/20 secs 64.0 MiB

Result cache was not saved because of non-ignorable exception.

                                                                                
 [ERROR] PHPStan Pro can't be launched because of these errors:                 
                                                                                

                                                                                
 [OK] No errors                                                                 
                                                                                

Please fix them first and then re-run PHPStan.
Result cache was not saved.
Used memory: 64 MB
Script docker run --rm -p 11111:11111 -v $PWD:/app phpstan/phpstan:nightly analyse app --memory-limit=1G --ansi --pro -vvv handling the sa event returned with error code 1

@ondrejmirtes
Copy link
Member

Oh, I think I figured it out (phpstan/phpstan-src@2af17d9). You should now see that some error you're ignoring is actually non-ignorable and you should fix it instead. It's probably going to be the SoapClient one.

Once you fix this error, you'll be able to run PHPStan Pro as well :)

Let me know how it works for you, thanks.

@stanislav-janu
Copy link
Author

Everything is ok if I use standard command vendor/bin/phpstan.phar analyse app --ansi --pro. There I can install extensions to php.

But in Docker I can not. I would have to make another Dockerfile with command docker-php-ext-install soap.

Thank you so much Ondřej for your help!

@ondrejmirtes
Copy link
Member

Interesting, since the static reflection (https://phpstan.org/blog/zero-config-analysis-with-static-reflection) it shouldn't be necessary to install PHP extensions. Can you share the piece of code that crashes without the extension installed? Thank you!

ondrejmirtes added a commit that referenced this issue Oct 1, 2020
phpstan/phpstan-src@b2b305e DefinedVariableRule - more metadata
phpstan/phpstan-src@d7c5996 Fix
phpstan/phpstan-src@5fc3f7d Fix Redis::lPush(), Redis::lPushx(), Redis::rPush() and Redis::rPushx() signature
phpstan/phpstan-src@8965dd8 Codespaces
phpstan/phpstan-src@6d1441a Codespaces - install dependencies
phpstan/phpstan-src@ac641c8 Codespaces - Composer v2
phpstan/phpstan-src@a319449 Codespaces - memory limit
phpstan/phpstan-src@93d79f8 Codespaces: memory limit and Composer v2
phpstan/phpstan-src@17bde93 Pass around parent scope of anonymous functions
phpstan/phpstan-src@385819c DefinedVariableRule - defined variables in metadata
phpstan/phpstan-src@ff092a0 Updated nikic/php-parser
phpstan/phpstan-src@4f152b2 Bump deps
phpstan/phpstan-src@2dc11d6 AnalyserRunner::runAnalyser() - $allowParallel
phpstan/phpstan-src@1be28f3 preg_split sometimes returns array of arrays
phpstan/phpstan-src@253b9e6 PHPStan Pro 🚀
phpstan/phpstan-src@4636999 Fix
phpstan/phpstan-src@d2cf845 Fix AutoloadFilesTest (see also 1885415)
phpstan/phpstan-src@6603bb8 Revert "Fix AutoloadFilesTest (see also 1885415)"
phpstan/phpstan-src@90bda81 Replace Guzzle with react/http
phpstan/phpstan-src@6a7dbde Some renaming
phpstan/phpstan-src@db779ee Fix build
phpstan/phpstan-src@f3e53ce More accurate comment
phpstan/phpstan-src@5dc562c Fix AutoloadFilesTest (see also 667df3a)
phpstan/phpstan-src@b6f90be Updated nikic/php-parser to v4.10.1
phpstan/phpstan-src@b4299be regression test for assign empty array to array of array of generic
phpstan/phpstan-src@9f43f3b Update functionMap.php
phpstan/phpstan-src@3405e43 Pass current memory limit to PHPStan Pro process
phpstan/phpstan-src@2d8dcd1 Mitigation of some problems
phpstan/phpstan-src@8a7ae4f Fix downloading on Windows
phpstan/phpstan-src@e6103f3 Fix build
phpstan/phpstan-src@717ca73 Fix build
phpstan/phpstan-src@ec01a65 Show the reason for the download failure
phpstan/phpstan-src@ccd9e10 openssl_seal has up to 6 parameter
phpstan/phpstan-src@36e4e39 specified rw for the iv parameter
phpstan/phpstan-src@06b5a54 Bump deps
phpstan/phpstan-src@e7203bc Update nikic/php-parser
phpstan/phpstan-src@cec7a55 Allow to set PHPStan Pro web port via environment variable (for Docker)
phpstan/phpstan-src@2933aa5 Docker tips
phpstan/phpstan-src@452d081 Fix the advertised port
phpstan/phpstan-src@6865227 This is safer
phpstan/phpstan-src@6fb9cf5 This is safer
phpstan/phpstan-src@6f5bf69 Hidden directory
phpstan/phpstan-src@078ebaf Make last parameter of openssl_seal optional
phpstan/phpstan-src@d2f443c SignatureMapParser - test required parameter after optional
phpstan/phpstan-src@d77bd87 Debug issue #3897
phpstan/phpstan-src@6e67bad Return `false` for hash_hmac/hash_hmac_file on invalid algorithm
phpstan/phpstan-src@4c59353 More debugging
phpstan/phpstan-src@29cbe83 More debugging
phpstan/phpstan-src@6b11018 More debugging
phpstan/phpstan-src@2af17d9 Fix Error::canBeIgnored()
@stanislav-janu
Copy link
Author

 ------ -------------------------------------------------------------------- 
  Line   model/Google/Ads/Manager.php                                        
 ------ -------------------------------------------------------------------- 
         Class SoapClient not found.                                         
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols  
  30     Class SoapClient not found.                                         
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols  
  39     Class SoapClient not found.                                         
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols  
  40     Class SoapClient not found.                                         
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols  
  160    Class SoapClient not found.                                         
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols  
  160    Class SoapClient not found.                                         
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols  
 ------ -------------------------------------------------------------------- 

On line 30 is use Google\AdsApi\AdWords\v201809\cm\CampaignService;
There is implemented googleads/googleads-php-lib package.

This starts on line 152

	public function getGoogleAdsDistinctCampaigns(AdWordsSession $session): ?array
	{
		$campaigns = [];

		try {
			$adWordsServices = new AdWordsServices();

			/** @var CampaignService $campaignService */
			$campaignService = $adWordsServices->get($session, CampaignService::class);
...

Line 160 is $campaignService = $adWordsServices->get($session, CampaignService::class);

@hopeseekr
Copy link

My PHPExpertsInc/docker-phpstan project supports –pro…

I believe in supporting this project so much that I made sure of it as soon as --pro was released!!

I am not sure why there is such hostility with other PHP projects to me dockerizing their stacks to make them independent of even having PHP installed on the system, but… all you ahve to do install PHPStan with my system is this:

composer require phpexperts/docker-phpstan

That’s it! Done!

You can do this IN PHP 5.3, if you want, and it will JUST WORK (!!)

This is by far and away the easiest way to get phpstan on eveyr single project, no matter if you even have php on your system or not.

If you want to test your app on PHP 8.0?

composer require phpexperts/dockerize-php8

DONE! Now everything in your local PWD will be executed using PHP v8.0 beta 4!

phpexperts/docker-phpstan:

  • Doesn’t pollute your vendor deps.
  • Independent of any system/project PHP (runs 7.4)
  • Super fast to install: composer require –dev phpexperts/docker-phpstan
  • Integrates great with Travis-CI!

30 second installation demo: https://youtu.be/rpby2nz2iEI

image

OR just do:

wget https://raw.githubusercontent.com/PHPExpertsInc/docker-phpstan/master/bin/phpstan
sudo mv phpstan /usr/local/bin

@hopeseekr
Copy link

The maintainer of this project is totally encouraged to fork phpexpertsinc/docker-phpstan and integrate it into their own project.

Doing composer require --dev phpstan/docker-phpstan and having it load regardless of PHP or project-specific dependency issues is -amazing-!! Esp on PHP 8 and PHP 7.1 and below that PHPStan doesn’t natively support!!

This is how I have analyzed 100,000+ packagist.org projects using phpstan via my Bettergist Collective project!!

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 11, 2021
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

3 participants