Closes #7125: PHPStan: Ensure no hooks are present inside the ORM logic #7152
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Fixes #7125
Nothing impacts the user.
Type of change
Detailed scenario
N/a
Technical description
Documentation
This pull request introduces a new PHPStan rule to ensure hooks are not used in ORM classes. It includes updates to the
phpstan-baseline.neon
andphpstan.neon.dist
configuration files, as well as new test cases to verify the rule's functionality.New PHPStan Rule:
tests/phpstan/Rules/NoHooksInORM.php
: Added a new ruleNoHooksInORM
to prevent the use of hooks in ORM classes.Configuration Updates:
phpstan-baseline.neon
: Updated to include new error messages related to theNoHooksInORM
rule. [1] [2] [3]phpstan.neon.dist
: Added theNoHooksInORM
rule to the list of PHPStan rules.Test Cases:
tests/phpstan/tests/Rules/NoHooksInORMTest.php
: Added tests to verify that theNoHooksInORM
rule correctly identifies the use of hooks in ORM classes.tests/phpstan/tests/data/NoHooksInORMTest/orm-class-with-hooks.php
: Added a test class that includes hooks to ensure the rule triggers an error.tests/phpstan/tests/data/NoHooksInORMTest/orm-class-without-hooks.php
: Added a test class without hooks to ensure the rule does not trigger an error.Additional Changes:
tests/phpstan/tests/bootstrap.php
: Added a bootstrap file for the tests.tests/phpstan/tests/phpunit.xml
: Added a PHPUnit configuration file for running the tests.New dependencies
N/a
Risks
N/a
Mandatory Checklist
Code validation
Code style