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

Fix return type docs for Mailer::send #51430

Closed
wants to merge 1 commit into from
Closed

Conversation

fjahn
Copy link

@fjahn fjahn commented May 16, 2024

If Mailer::send is passed a value that implements both Illuminate\Contracts\Mail\Mailable and Illuminate\Contracts\Queue\ShouldQueue, this method would return the id of the queued job (which is an int by defaut). Currently, this is not reflected in its return type. This came up in a package where Mailer was overriden with an explicit return type, which caused the method to fail under the circumstances described above.

Since Mailer::queue reports the return type being mixed, I would suggest to add that to send as well. However, I am aware that mixed would also include the other types, so it might as well just be mixed. I am not sure if \Illuminate\Mail\SentMessage|null|mixed or just mixed would be the better solution in this case.

@driesvints
Copy link
Member

This change is incorrect sorry. mixed can never be combined with something else. It's either mixed or a concrete set of types.

@driesvints driesvints closed this May 16, 2024
@driesvints
Copy link
Member

If you need int in here it's best to add just that.

@fjahn
Copy link
Author

fjahn commented May 16, 2024

mixed can never be combined with something else. It's either mixed or a concrete set of types.

In that case, the return type of Mailer::send and Mailer::sendMailable should be mixed.

If you need int in here it's best to add just that.

int would be just as wrong since there is no guarantee that the job id is an int; That is just the default type in most cases.

@driesvints
Copy link
Member

I don't feel we should use mixed. I think it's better to outline the possible types.

@fjahn
Copy link
Author

fjahn commented May 16, 2024

I don't feel we should use mixed. I think it's better to outline the possible types.

I agree, so to reiterate:

  • Mailer::queue returns mixed (which is documented correctly)
  • Mailer::send returns the result of Mailer::queue

In my opinion, this means that Mailer::send's return type must include the return types of Mailer::queue, which means that Mailer::send needs to be mixed.

@simonschaufi
Copy link

simonschaufi commented May 16, 2024

@driesvints why did you close this issue so quickly? Nothing has been fixed so far. Please reopen again.

@driesvints
Copy link
Member

Feel free to attempt a new PR with mixed only if you really want that.

@simonschaufi
Copy link

@driesvints Why a new PR? This one can easily be adjusted. That is why I kindly ask you to reopen it.

@driesvints
Copy link
Member

@simonschaufi please stop mentioning me over and over. The PR in this state is still incorrect. Feel free to send in a new one if you like.

@laravel laravel locked and limited conversation to collaborators May 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants