Skip to content

Conversation

@webard
Copy link
Contributor

@webard webard commented Jan 7, 2026

Since the Gate::define() method allows the $ability argument to be an Enum, the Gate::has() method should also accept an Enum.

This PR aligns both methods for consistency.

Copilot AI review requested due to automatic review settings January 7, 2026 13:11
Copy link

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 adds support for UnitEnum as a parameter type to the Gate::has() method, aligning it with the Gate::define() method which already accepts UnitEnum. This change ensures consistency across the Gate API when working with enum-based abilities.

Key Changes:

  • Updated the Gate::has() method to accept UnitEnum in addition to string and array
  • Added enum_value() function call in the implementation to properly handle enum values
  • Updated PHPDoc annotations across the facade, contract interface, and implementation

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/Illuminate/Support/Facades/Gate.php Updated PHPDoc to include \UnitEnum type for the has() method
src/Illuminate/Contracts/Auth/Access/Gate.php Updated interface PHPDoc to include \UnitEnum type for the has() method parameter
src/Illuminate/Auth/Access/Gate.php Updated implementation PHPDoc and added enum_value() call to properly handle enum values in the abilities check
Comments suppressed due to low confidence (1)

src/Illuminate/Auth/Access/Gate.php:21

  • This extra blank line should be removed to maintain code formatting consistency.
class Gate implements GateContract

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

@webard webard changed the title Feature: allow UnitEnum in has() method of Gate class [12.x] Feature: allow UnitEnum in has() method of Gate class Jan 7, 2026
@taylorotwell taylorotwell merged commit c6962e0 into laravel:12.x Jan 7, 2026
70 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.

2 participants