Problem/Motivation
Bump PHPStan to 2.1.34 as
Projects typically see 25 % to 40 % faster analysis times. Please test this release and report back, we're looking forward to your numbers as well!
See https://github.com/phpstan/phpstan/releases/tag/2.1.34
Proposed resolution
composer update mglaman/phpstan-drupal phpstan/extension-installer phpstan/phpstan phpstan/phpstan-deprecation-rules phpstan/phpstan-phpunit
Remaining tasks
User interface changes
Introduced terminology
API changes
Data model changes
Release notes snippet
Issue fork drupal-3568370
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3568370-main
changes, plain diff MR !14422
- 3568370-update-phpstan-to
changes, plain diff MR !14411
Comments
Comment #3
mondrakeIndeed PHPStan job execution looks much faster.
Comment #4
longwaveLet's do it.
Comment #5
dwwI tried locally and get the identical
composer.lockchanges. Pipeline is green. Changes are small and mostly make sense. Not entirely clear why the new version causes us to need to update the baseline, but the original pipeline shows the failure, so it's clearly needed.😅This is not a fair comparison, but the latest passing phpstan job in this MR took 3 minutes 47 seconds, including:
vs. the phpstan job in the latest daily main test pipeline I could find took 2 minutes 26 seconds, including:
How can we compare apples to apples and see the performance gain on consecutive runs where the results are not cached?
Don't want to hold up RTBC for this, probably good to upgrade anyway, but curious to actually see the benefits in action.
Thanks,
-Derek
Comment #6
mondrakeCheck a MR where the PHPStan cache is invalidated. Any one that updates a dependency will.
Comment #7
catchIt would be great if they've also improved performance when caches are warm - sometimes see it taking 30s or more to restore the cache. Some of the commit log suggested this might be the case.
The MR doesn't apply to
main, but rather than moving to needs work I went ahead and ran the commands in the issue summary, then compared against the 11.x diff, and committed that directly (after nearly forgetting to update the phpstan baseline too).Committed/pushed to main and 11.x, thanks!
Comment #12
mondrakeThe main commit lacks the version update in composer.json (main and the Drupal PHPStan rules one) and the metapackages.
Apart from the steps in the IS, we need manual update of the composer.json files and then
composer update --lockto update the metapackages.Comment #14
catchOof. Reverted the commit on main, let's do it via MR after all.
Comment #16
mondrake14422 targets main.
Comment #17
mondrakeOne thing that I find inconvenient and a waste of resources is that we need to run PHPStan 2 o 4 times for every run, even if cached:
once to get output in gitlab format
once to get output in junit format
and if there are errors,
once again to report to humans
php vendor/bin/phpstan analyze --configuration=$_PHPSTAN_NEON --no-progress || trueand once more get a new baseline generated for storing in artifacts
php vendor/bin/phpstan analyze --configuration=$_PHPSTAN_NEON --no-progress --generate-baseline=$_PHPSTAN_BASELINE || trueI wonder whether it would make sense to file an issue upstream to ask if it would be possible to run analysis only once and produce the 4 outputs at the same time
Comment #18
dwwRe #17 that mākea a ton of sense. It’d be great to run once and get 4 different outputs simultaneously.
Comment #19
catchI found a feature request for this from 2020, and it recommended creating your own error formatter https://github.com/phpstan/phpstan/issues/3177
The challenge with doing it in phpstan would be it would also need to support a file destination per error format too.
Comment #20
mondrakeFiled #3568641: [CI] Introduce our own PHPStan ErrorFormatter to avoid multiple PHPStan executions as a possible follow up to optimize PHPStan execution time.
Comment #21
godotislateDiff in MR 14422 against is essentially the same as 0ae7c91c on 11.x, so this lgtm.
Comment #23
catchCommitted/pushed to main, thanks!
Comment #26
andypostFor support 8.5 it need bumo to 2.1.36 minimum #3570713: Bump PHPStan to 2.1.38
EDIT: for 2.1.36 https://github.com/JetBrains/phpstorm-stubs/commit/d955c006e300377c12aba...