Skip to content

fix roles #2848

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

fix roles #2848

wants to merge 1 commit into from

Conversation

m-jahanzeb6
Copy link

No description provided.

*/
public function hasRole($roles, ?string $guard = null): bool
{
// Detect incorrect usage: more than one argument passed (e.g. hasRole('admin', 'super'))
if (func_num_args() > 2) {
throw new \TypeError('hasRole() expects a single argument (string, array, Role, Collection, or BackedEnum). For multiple roles, pass an array.');
Copy link
Contributor

Choose a reason for hiding this comment

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

It wouldn't work very well either, because it's not just one argument, it's two,
and if you send just two, and they're both role names, it would fail silently.

@drbyte drbyte linked an issue May 28, 2025 that may be closed by this pull request
@drbyte drbyte added the invalid label May 28, 2025
@drbyte
Copy link
Collaborator

drbyte commented May 28, 2025

Thanks, but the problem is not in the package, but in the userland code which isn't following the correct usage as documented both in docs and in code.

@drbyte drbyte closed this May 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

HasRole Function Argument
3 participants