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

Update PHPStan to v2, improve code quality #1729

Draft
wants to merge 5 commits into
base: trunk
Choose a base branch
from
Draft

Conversation

swissspidy
Copy link
Member

@swissspidy swissspidy commented Dec 10, 2024

Summary

Fixes #776

Relevant technical choices

  • Updates PHPStan and extensions to v2
  • Moves PHPStan dependencies to a new phpstan folder, because PHPStan v2 requires PHP 7.4, whereas this repo requires PHP 7.2+
  • Requires swissspidy/phpstan-no-private
  • Moves hooks in the PL plugin to hooks.php like in the other plugins for consistency, makes it easier to separate that code from the constant definitions in load.php

@swissspidy swissspidy added the [Type] Enhancement A suggestion for improvement of an existing feature label Dec 10, 2024
@swissspidy swissspidy added this to the performance-lab n.e.x.t milestone Dec 10, 2024
@swissspidy
Copy link
Member Author

Strangely I cannot reproduce the https://github.com/WordPress/performance/actions/runs/12256447140/job/34191719008?pr=1729 error locally right now 🤔 I got it earlier but thought I had resolved it.

"phpstan": "phpstan analyse --memory-limit=2048M",
"phpstan": [
"composer --working-dir=phpstan install --no-interaction",
"phpstan/vendor/bin/phpstan analyse --memory-limit=2048M"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So there is a new phpstan root directory?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Could also be renamed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have an existing tools/phpstan directory that could be reused.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm not sure I wanna mix the config directory with that one

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we had build-cs before I could just rename it to that.

@westonruter
Copy link
Member

  • Moves PHPStan dependencies to a new phpstan folder, because PHPStan v2 requires PHP 7.4, whereas this repo requires PHP 7.2+

This is unfortunate since we previously maintained two separate composer.json files but were able to go to one, as I recall.

I wonder if we should bump the minimum PHP version to 7.4 for the entire project to facilitate maintenance and considering that core will likely bump the minimum version to 7.4 in in the middle of 2025 per Core-62622. We could still run PHPUnit on 7.2 in GHA for now if we want to.

@swissspidy
Copy link
Member Author

Ah true, there was a build-cs folder before, but I can't see where it was removed at first glance.

Bumping requirements is of course the easiest route, but I thought we just recently discussed not bumping PHP version requirements unnecessarily if we can avoid it.

@swissspidy
Copy link
Member Author

Strangely I cannot reproduce the WordPress/performance/actions/runs/12256447140/job/34191719008?pr=1729 error locally right now 🤔 I got it earlier but thought I had resolved it.

@westonruter is it passing for you locally?

@westonruter
Copy link
Member

Ah true, there was a build-cs folder before, but I can't see where it was removed at first glance.

It was removed when we bumped to PHP 7.2 in #1130.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Enhancement A suggestion for improvement of an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add phpstan-no-private to catch calls of seemingly private functions
2 participants