Repository navigation
fix(pointcut): follow the documented name wildcard and alternation rules - #775
Merged
Merged
Conversation
Two name matching rules contradicted the "Names and wildcards" table of docs/pointcuts.md: - `*` was translated to "one or more characters", so `Sensor*` skipped the class `Sensor` itself, `get*` a method named `get` and an `Exc*` return type pattern the type `Exc`. It now stands for any characters of one name part, including none, and still never crosses a namespace separator. NamePointcut and ReturnTypePointcut agree on it. - `|` was applied to the whole qualified name, so `Ns\Sensor|SensorValue` meant `Ns\Sensor` or the global class `SensorValue` and skipped `Ns\SensorValue`. The grammar already limits `|` to one name part; NamePointcut now translates the pattern part by part and groups the alternatives of each part, which also keeps the anchors strict (#115). Both are listed as BC breaks in the changelog and the upgrade guide. Fixes #774 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018dKKrvU4XVsKSfKRXPpwUS
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #775 +/- ##
=========================================
Coverage 98.19% 98.20%
- Complexity 1910 1913 +3
=========================================
Files 113 113
Lines 4995 5000 +5
=========================================
+ Hits 4905 4910 +5
Misses 90 90 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What and why
Fixes #774, found while re-checking #327. Two name matching rules contradicted the "Names and wildcards" table in
docs/pointcuts.md:*needed at least one character.Sensor*skipped the classSensoritself,get*skipped a method namedget, and anExc*return type pattern skipped the typeExc.*now stands for any characters of one name part, including none, and still never crosses a\.NamePointcutandReturnTypePointcutagree on it.|spanned the whole qualified name.Ns\Sensor|SensorValuemeantNs\Sensoror the global classSensorValue, and skippedNs\SensorValue. The grammar already limits|to one name part, soNamePointcutnow translates the pattern part by part and groups the alternatives of each part (which also keeps the anchors strict, see When i use the pattern that selects multiple values, all method are starting by one of values are matched #115).Changes:
src/Aop/Pointcut/NamePointcut.php: newcompilePattern(), one regex group per name part with alternatives.src/Aop/Pointcut/ReturnTypePointcut.php:*is zero or more characters.NamePointcutTest, end-to-end cases through the parser inPointcutSemanticsTest(class and member names, global class, strict alternatives), two return type cases. Nine of them fail on the old code.docs/pointcuts.mdstates both rules explicitly;CHANGELOG.mdandUPGRADE-4.0.mdlist the behaviour change.Behaviour change for existing pointcuts, listed as a BC break (4.0 is unreleased):
set*now also matches a method calledset(),Foo*also matchesFoo.Foo\A|Bar\B) must be written asexecution(public Foo\A->*(*)) || execution(public Bar\B->*(*)). No pointcut in the repository, demos or docs relied on either old rule.The wildcard
**is unchanged.Checklist
type(scope): summary)composer checkpassesGenerated by Claude Code