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 #7123: Rules about get_subscribed_events #7124

Merged
merged 6 commits into from
Nov 28, 2024

Conversation

Miraeld
Copy link
Contributor

@Miraeld Miraeld commented Nov 21, 2024

Description

Fixes #7123

This won't impact users.

Type of change

Detailed scenario

Just run PHPStan

Technical description

Documentation

This pull request introduces several changes related to PHPStan integration and testing in the project. The most significant updates include adding new PHPStan rules and tests, modifying the configuration files, and ensuring callback methods exist in subscribed events.

PHPStan Integration and Configuration:

  • composer.json: Added new scripts to run PHPStan with specific options (run-stan-reset-baseline, run-stan-test).
  • phpstan.neon.dist: Updated parameters to include new paths and rules, and modified reporting settings. [1] [2]

New PHPStan Rule:

Tests for New Rule:

  • tests/phpstan/tests/Rules/EnsureCallbackMethodsExistsInSubscribedEventsTest.php: Added tests to validate the new PHPStan rule, including tests for valid subscribers, non-existing methods, and complex syntax.
  • Added supporting test data files for the new rule:
    • tests/phpstan/tests/data/EnsureCallbackMethodsExistsInSubscribedEventsTest/complex-syntax.php
    • tests/phpstan/tests/data/EnsureCallbackMethodsExistsInSubscribedEventsTest/not-existing.php
    • tests/phpstan/tests/data/EnsureCallbackMethodsExistsInSubscribedEventsTest/valid.php

PHPUnit Configuration:

New dependencies

None

Risks

None

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.
  • Output messages (errors, notices, logs) are explicit enough for users to understand the issue and are actionnable.

@Miraeld Miraeld self-assigned this Nov 21, 2024
@Miraeld Miraeld added the type: enhancement Improvements that slightly enhance existing functionality and are fast to implement label Nov 21, 2024
Copy link

codacy-production bot commented Nov 21, 2024

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
Report missing for 90ca3181 (target: 50.00%)
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (90ca318) Report Missing Report Missing Report Missing
Head commit (3fb06c7) 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 (#7124) 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
Copy link
Contributor Author

Miraeld commented Nov 25, 2024

I've treated your feedback @CrochetFeve0251 ,
Also, modified the way it was working a bit to comply with your tests.

Also, you'll notice I've added some // @php-stan-ignore-[next]-line
That's because when phpstan run within this class, it kinda gets messed up with some type, even tho it's explicit, and due to this it thinks some part of the code are unreachable while in real they are.

I add a screenshot of your test passing as it isn't part of the CI in here.

Screenshot 2024-11-25 at 02 44 29

@Miraeld Miraeld requested review from CrochetFeve0251 and a team November 25, 2024 02:01
@Miraeld Miraeld added the noQA label Nov 25, 2024
wordpressfan and others added 2 commits November 25, 2024 11:53
@Miraeld Miraeld added this pull request to the merge queue Nov 28, 2024
Merged via the queue into develop with commit a8a5876 Nov 28, 2024
13 checks passed
@Miraeld Miraeld deleted the enhancement/7123-add-rule-for-get-subscribed-events branch November 28, 2024 17:58
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 - Add Rule to ensure get_subscribed_events use one of the three possible syntax
4 participants