Add fnmatch() wildcard support to allowInInstanceOf and friends#399
Merged
Conversation
Patterns are matched against the class itself and its full parent and interface hierarchy transitively, giving the same semantics as `instanceof`. All exact-name entries now go through the same traversal, removing a separate code path.
There was a problem hiding this comment.
Pull request overview
Adds fnmatch()-style wildcard matching to allowInInstanceOf, allowExceptInInstanceOf, and disallowInInstanceOf, applying patterns to the current class plus all parent classes and implemented interfaces (transitively), aligning the behavior with instanceof semantics.
Changes:
- Updated
allowInInstanceOfmatching to supportfnmatch()patterns across class + ancestor class/interface names. - Added PHPUnit coverage for wildcard instance-of matching (including case-insensitive matching).
- Documented wildcard pattern support and provided a configuration example.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| tests/src/BarWildcard.php | Adds fixture classes/interfaces to exercise wildcard matching across inheritance and interfaces. |
| tests/Calls/FunctionCallsTest.php | Adds configuration + assertions validating wildcard allowInInstanceOf / disallowInInstanceOf behavior. |
| src/Allowed/Allowed.php | Implements wildcard-aware matching against class name, parent classes, and interfaces. |
| docs/allow-in-instance-of.md | Documents wildcard support and adds an example using namespace patterns. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
spaze
added a commit
that referenced
this pull request
Apr 26, 2026
…ern` Both features were added separately - wildcard support for `allowInInstanceOf`/`disallowInInstanceOf` in #399, and the `classPattern` parameter directive in #412 - but they compose into a pattern that neither covers alone: disallow a general-purpose method within a whole namespace, but only when the argument also comes from that namespace. The new example in `allow-in-instance-of.md` illustrates this with a module-scoped processor where same-module items should be handled directly rather than routed through the general processor.
spaze
added a commit
that referenced
this pull request
Apr 27, 2026
…ern` Both features were added separately - wildcard support for `allowInInstanceOf`/`disallowInInstanceOf` in #399, and the `classPattern` parameter directive in #412 - but they compose into a pattern that neither covers alone: disallow a general-purpose method within a whole namespace, but only when the argument also comes from that namespace. The new example in `allow-in-instance-of.md` illustrates this with a module-scoped processor where same-module items should be handled directly rather than routed through the general processor.
spaze
added a commit
that referenced
this pull request
Apr 27, 2026
…ern` (#417) Both features were added separately - wildcard support for `allowInInstanceOf`/`disallowInInstanceOf` in #399, and the `classPattern` parameter directive in #412 - but they compose into a pattern that neither covers alone: disallow a general-purpose method within a whole namespace, but only when the argument also comes from that namespace. The new example in `allow-in-instance-of.md` illustrates this with a module-scoped processor where same-module items should be handled directly rather than routed through the general processor.
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.
allowInInstanceOf,allowExceptInInstanceOf, anddisallowInInstanceOfnow accept fnmatch() patterns (e.g.App\Wrappers\*). Pattern is matched against the class name and all parent classes and interfaces transitively, consistent withinstanceofsemantics