Skip to content

Support explicit regex patterns in advice attributes - #96

Merged
WalterWoshid merged 1 commit into
okapi-web:masterfrom
WalterWoshid:feat/regex-advice-patterns
Sep 5, 2026
Merged

Support explicit regex patterns in advice attributes#96
WalterWoshid merged 1 commit into
okapi-web:masterfrom
WalterWoshid:feat/regex-advice-patterns

Conversation

@WalterWoshid

Copy link
Copy Markdown
Contributor

Advice attributes now accept string|Regex|null for class and method patterns. Strings retain their existing wildcard behavior; explicit Okapi\Wildcards\Regex objects are used directly, so each argument can independently use wildcard or regex syntax.

For example, method: new Regex('/^[a-z][a-z0-9_]*$/i') selects ordinary method names while excluding constructors and other magic methods. Explicit patterns retain their delimiters, modifiers, and anchoring. Invalid regex objects fail when the advice is instantiated with an InvalidArgumentException identifying the class or method argument.

Adds eight tests covering Before/Around/After, mixed pattern types, regex-looking strings, legacy absent patterns, invalid expressions, PHP attribute instantiation, and actual weaving with nonmatching classes/methods excluded. README documents the API.

Validation:

  • All Mago checks, including type-patch regressions, pass.
  • Full PHPUnit suite passes on PHP 8.1 and PHP 8.5: 88 tests. Existing skips/incomplete tests and dependency deprecations remain.
  • The new tests were observed failing before implementation and passing afterward.

Fixes #31

@WalterWoshid
WalterWoshid merged commit 58061c9 into okapi-web:master Sep 5, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Other choice than "Wildcard" for implicit Aspects

1 participant