Skip to content
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

Allow the Batch and Chain onQueue method to accept Backed Enums #53359

Merged
merged 1 commit into from
Oct 31, 2024

Conversation

onlime
Copy link
Contributor

@onlime onlime commented Oct 31, 2024

Continuing the journey of better enums support in L11 ...

This PR improves the PendingChain and PendingBatch's onQueue method to accept Backed Enums directly as the queue parameter.

Before:

Bus::chain($jobs)
    ->onQueue(QueueName::long->value)->dispatch();

With this PR, you can now pass the Backed Enum directly:

Bus::chain($jobs)
    ->onQueue(QueueName::long)->dispatch();

@zakariaarrid
Copy link

zakariaarrid commented Oct 31, 2024

@onlime what about UnitEnum ?
@param \UnitEnum|\BackedEnum|string|null $queue

@onlime
Copy link
Contributor Author

onlime commented Oct 31, 2024

@onlime what about UnitEnum ? @param \UnitEnum|\BackedEnum|string|null $queue

Hi @zakariaarrid I guess it's "too early" to support this now, as all the previous PRs were just about BackedEnum and there must be some reason for it (but don't ask me, I am just following Laravel's current practices...):

The enum_value() helper supports both BackedEnum and UnitEnum, so honestly I don't see any reason against adding \UnitEnum to all docblocks. But for consistency, this should be done in all the other spots as well.

So maybe someone can comment about this backed mystery.

@taylorotwell taylorotwell merged commit 01c2659 into laravel:11.x Oct 31, 2024
33 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.

3 participants