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

Closes #7119 #7132

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from
Open

Closes #7119 #7132

wants to merge 8 commits into from

Conversation

Khadreal
Copy link
Contributor

@Khadreal Khadreal commented Nov 22, 2024

Description

Fixes #7119
Nothing impacts users.

Type of change

  • Enhancement (non-breaking change which improves an existing functionality).

Detailed scenario

n/a

Technical description

Documentation

This pull request introduces several changes to enhance PHPStan integration and adds a new custom rule for validating @param tags in docblocks. The most important changes include adding a new script to reset the PHPStan baseline, updating the PHPStan configuration files, and implementing a custom PHPStan rule.

Enhancements to PHPStan integration:

  • composer.json: Added a new script run-stan-reset-baseline to reset the PHPStan baseline.
  • phpstan-baseline.neon: Added baseline configurations to ignore specific errors in certain files.
  • phpstan.neon.dist: Updated the parameters section to include a new directory and added the custom rule WP_Rocket\Tests\phpstan\Rules\ApplyFiltersTypedDynamicFunctionReturnTypeExtension. [1] [2]

Implementation of a custom PHPStan rule:

Mandatory Checklist

Code validation

  • I validated all the Acceptance Criteria. If possible, provide screenshots or videos.
  • I triggered all changed lines of code at least once without new errors/warnings/notices.
  • I implemented built-in tests to cover the new/changed code.

Code style

  • I wrote a self-explanatory code about what it does.
  • I protected entry points against unexpected inputs.
  • I did not introduce unnecessary complexity.

Copy link

codacy-production bot commented Nov 22, 2024

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
Report missing for dd33f7b1 (target: 50.00%)
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (dd33f7b) Report Missing Report Missing Report Missing
Head commit (97c1c8d) 38228 16731 43.77%

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#7132) 0 0 ∅ (not applicable)

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

Codacy stopped sending the deprecated coverage status on June 5th, 2024. Learn more

Footnotes

  1. Codacy didn't receive coverage data for the commit, or there was an error processing the received data. Check your integration for errors and validate that your coverage setup is correct.

@Miraeld Miraeld self-assigned this Nov 26, 2024
@Miraeld
Copy link
Contributor

Miraeld commented Nov 28, 2024

As we are getting some complexities in the test of this rules, we've decided to seperate the rule and the test in two issues.

This is why I'm deleting the beginning of test implementation from this PR, to create a new issue for it.

To make it short, the problem that is happening in here is that the custom rules is able to parse docblocks while running for real code. But in the tests, it's detecting the docblock but considering them empty, and we can't explain it at the moment.

As we don't want to block any development made, we've decided to proceed with manual test at first, and implement tests in a second step.

@Miraeld Miraeld force-pushed the enhancement/7119-docblock-wpm-filters branch from fb69320 to c29054a Compare November 28, 2024 09:39
@Miraeld Miraeld marked this pull request as ready for review November 28, 2024 09:40
@Miraeld Miraeld requested review from CrochetFeve0251 and a team November 28, 2024 09:42
@Miraeld Miraeld added noQA type: enhancement Improvements that slightly enhance existing functionality and are fast to implement labels Nov 28, 2024
@remyperona
Copy link
Contributor

Did we validate that all possible errors are correctly covered?

@Miraeld
Copy link
Contributor

Miraeld commented Nov 28, 2024

@remyperona as I said in the comment, unit tests are a bit tricky with the docblock.
If you feel like you could add them please feel free. Otherwise I will wait @CrochetFeve0251 to be available to take a look at them. That's why I originated created another issue.
I tried to manually test everything I could think off, and it was working tho.

@remyperona
Copy link
Contributor

If we did manual testing for the possible cases, sounds good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
noQA type: enhancement Improvements that slightly enhance existing functionality and are fast to implement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PHPStan - Ensure Docblock presence for wpm_apply_filters_typed()
4 participants