-
-
Notifications
You must be signed in to change notification settings - Fork 34
Add function hasRelationQuery(string $name): bool for ActiveRecordInt… #436
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
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #436 +/- ##
============================================
- Coverage 89.40% 89.20% -0.21%
- Complexity 575 576 +1
============================================
Files 17 17
Lines 1387 1389 +2
============================================
- Hits 1240 1239 -1
- Misses 147 150 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds a new method hasRelationQuery(string $name): bool to the ActiveRecordInterface and its implementation to check if a relation query method exists for a given name. This enhances the magic property handling by replacing direct method_exists calls with a more explicit and overridable method.
- Adds
hasRelationQuery()method to interface and abstract implementation - Updates magic property getter to use the new method instead of direct
method_existscheck - Includes comprehensive test coverage for the new functionality
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/ActiveRecordInterface.php | Adds the interface declaration for hasRelationQuery() method |
| src/AbstractActiveRecord.php | Implements the hasRelationQuery() method with default behavior |
| src/Trait/MagicPropertiesTrait.php | Updates magic property getter to use new method and adds PHPDoc annotation |
| tests/ActiveRecordTest.php | Adds comprehensive test coverage for the new method functionality |
| } | ||
|
|
||
| if (method_exists($this, "get{$name}Query")) { | ||
| if ($this->hasRelationQuery($name)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Worth checking performance after this change.
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
|
Could you move the test to https://github.com/yiisoft/active-record/blob/master/tests/MagicActiveRecordTest.php |
|
👍 |
…erface