Skip to content

feat: capability can apply to entire permission class#36

Merged
shavonn merged 2 commits intomainfrom
in-practice
Jan 20, 2026
Merged

feat: capability can apply to entire permission class#36
shavonn merged 2 commits intomainfrom
in-practice

Conversation

@shavonn
Copy link
Contributor

@shavonn shavonn commented Jan 20, 2026

Extends the Capability attribute so that it can be applied at the permission class level (not just constants), and updates discovery logic and fixtures accordingly. It also refines the default stubs for generating permission and capability classes to better align with the colon-delimited permission naming and common capability naming patterns.

Copilot AI review requested due to automatic review settings January 20, 2026 21:25
Copy link
Contributor

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

This PR extends the Capability attribute so that it can be applied at the permission class level (not just constants), and updates discovery logic and fixtures accordingly. It also refines the default stubs for generating permission and capability classes to better align with the colon-delimited permission naming and common capability naming patterns.

Changes:

  • Allow #[Capability] to be applied to classes, and have DefinitionDiscoverer merge class-level and constant-level capabilities when building PermissionDefinitions.
  • Add fixtures and unit tests to validate class-level capabilities and capability merging behavior.
  • Update permission and capability stubs to use colon-delimited permission names, introduce a VIEW_ANY permission, and adjust default capability naming/labels.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/Unit/CodeFirst/DefinitionDiscovererTest.php Adds tests ensuring capabilities are inherited from class-level attributes and correctly merged with constant-level capabilities.
tests/Fixtures/CodeFirst/UserPermissions.php New fixture permission class with class-level and constant-level Capability attributes used to validate the new discovery behavior.
stubs/permission.stub Updates the generated permission class stub to add VIEW_ANY, switch permission names to resource:action format, and refine descriptions.
stubs/capability.stub Adjusts the capability stub’s label text and default capability constant name pattern.
src/CodeFirst/DefinitionDiscoverer.php Extends permission discovery to read class-level Capability attributes and merge them with constant-level ones via a new helper method.
src/Attributes/Capability.php Expands the Capability attribute target to include classes and documents class-level usage and multi-capability examples.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@shavonn shavonn merged commit 7b90225 into main Jan 20, 2026
23 checks passed
@shavonn shavonn deleted the in-practice branch January 20, 2026 23:20
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.

1 participant