Skip to content

Conversation

@m-jahanzeb6
Copy link

No description provided.

{
// 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