two-factor icon indicating copy to clipboard operation
two-factor copied to clipboard

Please use PHPStan

Open szepeviktor opened this issue 1 year ago • 4 comments

Describe the bug

There are nasty things in the code, e.g. return parent::__construct();

Steps to Reproduce

The simplest way.

composer require --dev szepeviktor/phpstan-wordpress
vendor/bin/phpstan analyze -c vendor/szepeviktor/phpstan-wordpress/extension.neon includes/ providers/ class-*.php two-factor.php --level=0

szepeviktor avatar Jul 15 '24 00:07 szepeviktor

Hi!

Can you double-check the command provided?

$ composer require --dev szepeviktor/phpstan-wordpress

./composer.json has been updated
Running composer update szepeviktor/phpstan-wordpress
Loading composer repositories with package information
Updating dependencies
Lock file operations: 3 installs, 0 updates, 0 removals
  - Locking php-stubs/wordpress-stubs (v6.5.3)
  - Locking phpstan/phpstan (1.11.7)
  - Locking szepeviktor/phpstan-wordpress (v1.3.5)
Writing lock file


$ vendor/bin/phpstan analyze -c vendor/szepeviktor/phpstan-wordpress/extension.neon includes/ providers/ class-*.php two-factor.php --level=0
 14/14 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%

 [OK] No errors

$ git remote -v
origin	[email protected]:WordPress/two-factor.git (fetch)
origin	[email protected]:WordPress/two-factor.git (push)

$ git branch
* master

dd32 avatar Jul 15 '24 01:07 dd32

This is surreal. 14/14: all files are checked 😲

I cannot find the reason why there are no errors.

szepeviktor avatar Jul 15 '24 03:07 szepeviktor

I fully suspect it's related to my environment somehow :)

Thank you for the PR, it should be enough to review the changes and have them merged without issue.

(we'll need to get the GitHub actions working prior to merge however, to ensure no regressions. I'm not requesting you do that, unless you feel like it!)

dd32 avatar Jul 15 '24 03:07 dd32

I'm contributing to PHPStan for years and I have no clue what is going on!

szepeviktor avatar Jul 15 '24 03:07 szepeviktor

PHPstan reporting and internal cache is the only unreliably thing I haven't been able to solve.

kasparsd avatar Sep 18 '24 07:09 kasparsd

PHPstan reporting and internal cache

Please do report your findings. https://github.com/phpstan/phpstan/issues/new/choose I need PHPStan to get better.

szepeviktor avatar Sep 18 '24 08:09 szepeviktor

@szepeviktor I got the same results out of the box on my local PHP 7.4:

no-errors

Turns out it is running out of memory and exiting silently. Adding the --debug parameter disables the cache and it correctly reports memory issue:

PHPStan process crashed because it reached configured PHP memory limit: 128M Increase your memory limit in php.ini or run PHPStan with --memory-limit CLI option.

kasparsd avatar Sep 18 '24 12:09 kasparsd

configured PHP memory limit: 128M

@kasparsd This is shockingly low.

In Debian on PHP-CLI the default is unlimited memory for PHP.

szepeviktor avatar Sep 18 '24 12:09 szepeviktor

@szepeviktor The core issue is that doesn't fail with that memory error on the first run. It somehow thinks every is a pass and then returns that cached result.

kasparsd avatar Sep 18 '24 12:09 kasparsd

@ondrejmirtes Could you help us with an advice?

szepeviktor avatar Sep 18 '24 13:09 szepeviktor

@szepeviktor Hey, I'm not going to read the whole thread and trying to figure out what you're asking me. Please open a GitHub discussion and provide the full context. Thanks.

ondrejmirtes avatar Sep 18 '24 16:09 ondrejmirtes