-
Notifications
You must be signed in to change notification settings - Fork 27
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
Binding multiple interceptors with multiple bindings in PECL AOP #225
Conversation
Ensure the apply method is not called with an empty list of interceptors by adding a conditional check. This prevents unnecessary execution and potential errors when no interceptors are bound.
Previously, method interceptors were overwritten if already set. This change ensures interceptors are merged instead, preserving existing ones and thus providing accumulated functionality when multiple matchers apply to the same method.
Corrected spacing inconsistencies before function calls and fixed typos in variable names from "mathcers" to "matchers". These changes enhance code readability and ensure accurate parameter usage within the weave method and related logic.
Renamed method 'apply' to 'interceptMethods' for better clarity. Updated associated comments to reflect changes accurately, emphasizing the use of the PECL Ray.Aop extension for method interception.
Revised the documentation to differentiate between weaving aspects into the source directory and a specific target directory. This change enhances clarity by providing explicit example paths for both use cases.
WalkthroughThe pull request includes modifications to the Changes
Possibly related PRs
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## 2.x #225 +/- ##
=======================================
Coverage ? 100.00%
Complexity ? 225
=======================================
Files ? 28
Lines ? 583
Branches ? 0
=======================================
Hits ? 583
Misses ? 0
Partials ? 0 ☔ View full report in Codecov by Sentry. |
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.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (5)
src/AspectPecl.php (2)
81-87
: Good implementation of multiple interceptor binding!The logic for handling multiple interceptors is well implemented. However, we could optimize the array merging slightly.
Consider using the spread operator for a more concise array merge:
- $bound[$className][$methodName] = array_merge($bound[$className][$methodName], $matcher['interceptors']); + $bound[$className][$methodName] = [...$bound[$className][$methodName], ...$matcher['interceptors']];
95-99
: Good method rename and documentation update!The new method name 'interceptMethods' is more descriptive than 'apply'. The documentation is clear, but could be even more specific.
Consider enhancing the PHPDoc to be more specific about what the method does:
- * Intercept methods with bounded interceptors using PECL extension + * Registers method interceptors for each bound method using the PECL extension. + * This allows intercepting method calls at runtime through the Ray.Aop extension.README.md (3)
106-110
: Consider enhancing path examples with more context.While the added examples clarify the difference between source and target directory weaving, consider:
- Adding a note about path requirements (absolute vs. relative)
- Explaining when to use source vs. target directory weaving
Line range hint
271-271
: Remove trailing characters.The "z1" at the end of the file appears to be unintentional and should be removed.
Line range hint
1-271
: Add example for multiple interceptor bindings.Given that this PR focuses on "Binding multiple interceptors with multiple bindings", consider adding an example that demonstrates:
- How to bind multiple interceptors to a single method
- How to configure different interceptors for different methods
- The execution order of multiple interceptors
This would better align the documentation with the PR's objective.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (2)
README.md
(2 hunks)src/AspectPecl.php
(3 hunks)
🔇 Additional comments (3)
src/AspectPecl.php (2)
12-12
: LGTM!
The added import statement for array_merge
is correctly placed and necessary for the new interceptor merging functionality.
39-51
: Excellent improvements to the weave method!
The changes enhance the code in several ways:
- Fixed the parameter name typo ($matchers)
- Added optimization to skip processing when no interceptors are bound
- Renamed the method call to a more descriptive name (interceptMethods)
README.md (1)
82-82
: LGTM! Helpful clarification comment.
The added comment clearly indicates where interceptors are applied in the execution flow.
Summary by CodeRabbit
Documentation
README.md
for using the Ray.Aop package, including improved examples and instructions for interceptors and aspect configuration.Refactor
AspectPecl
class by renaming parameters and methods for better clarity.weave
method to skip processing when no interceptors are bound, improving efficiency.