Add param conditions support to allowInInstanceOf and disallowInInstanceOf#401
Merged
Merged
Conversation
…ceOf` Combining instanceof-based directives with `allowParamsInAllowed` or `allowExceptParamsInAllowed` makes it possible to narrow which calls within a class hierarchy are reported, without introducing new config keys.
There was a problem hiding this comment.
Pull request overview
This PR extends the “instance-of scoped” allow/disallow directives so they can be combined with existing parameter-based conditions, enabling conditional allowances/blocks within a class hierarchy without introducing new config keys.
Changes:
- Apply
allowParamsInAllowed/allowExceptParamsInAllowedwhen evaluatingallowInInstanceOfanddisallowInInstanceOf(alias ofallowExceptInInstanceOf). - Add a dedicated test fixture + assertions covering all four directive combinations.
- Document the new combinations in
allow-in-instance-of.mdand cross-reference them fromallow-with-parameters.md.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
src/Allowed/Allowed.php |
Extends instance-of allow/disallow checks to optionally incorporate *ParamsInAllowed conditions. |
tests/src/BarInstanceOfWithParams.php |
New test fixture exercising hierarchy-scoped parameter conditions. |
tests/Calls/FunctionCallsTest.php |
Adds configuration and a new test validating the new behavior. |
docs/allow-with-parameters.md |
Mentions that allowParamsInAllowed/allowExceptParamsInAllowed can also scope via allowInInstanceOf. |
docs/allow-in-instance-of.md |
Documents all combinations of instance-of scoping with parameter conditions. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
allowInInstanceOfanddisallowInInstanceOfcan now be combined withallowParamsInAllowedandallowExceptParamsInAllowedto add parameter-based conditions within the class hierarchy scope.No new config keys - reuses the existing
*InAlloweddirectives.Documents all four combinations in
allow-in-instance-of.mdand updatesallow-with-parameters.mdto mentionallowInInstanceOf.