Skip to content

Add fnmatch() wildcard support to allowInInstanceOf and friends#399

Merged
spaze merged 1 commit into
mainfrom
spaze/fnmatch-allowinstanceof
Apr 23, 2026
Merged

Add fnmatch() wildcard support to allowInInstanceOf and friends#399
spaze merged 1 commit into
mainfrom
spaze/fnmatch-allowinstanceof

Conversation

@spaze
Copy link
Copy Markdown
Owner

@spaze spaze commented Apr 23, 2026

allowInInstanceOf, allowExceptInInstanceOf, and disallowInInstanceOf now accept fnmatch() patterns (e.g. App\Wrappers\*). Pattern is matched against the class name and all parent classes and interfaces transitively, consistent with instanceof semantics

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.
@spaze spaze self-assigned this Apr 23, 2026
Copilot AI review requested due to automatic review settings April 23, 2026 18:34
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 allowInInstanceOf matching to support fnmatch() 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 spaze merged commit 725b0fa into main Apr 23, 2026
154 checks passed
@spaze spaze deleted the spaze/fnmatch-allowinstanceof branch April 23, 2026 18:58
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.
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.

2 participants