From 20a5366712afb68602eb367dde8d03c05f01d899 Mon Sep 17 00:00:00 2001 From: barbosa89 Date: Wed, 25 Mar 2026 22:25:00 +0000 Subject: [PATCH] refactor: change self by static for better class resolution --- src/Mail/Contracts/Mailable.php | 8 ++++---- src/Mail/Mailable.php | 26 +++++++++++++------------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/Mail/Contracts/Mailable.php b/src/Mail/Contracts/Mailable.php index 8c6a7897..f221b078 100644 --- a/src/Mail/Contracts/Mailable.php +++ b/src/Mail/Contracts/Mailable.php @@ -9,13 +9,13 @@ interface Mailable { - public function from(Address|array|string $from): self; + public function from(Address|array|string $from): static; - public function to(array|string $to): self; + public function to(array|string $to): static; - public function cc(array|string $cc): self; + public function cc(array|string $cc): static; - public function bcc(array|string $bcc): self; + public function bcc(array|string $bcc): static; public function build(): self; diff --git a/src/Mail/Mailable.php b/src/Mail/Mailable.php index d4f4eea7..47ea4483 100644 --- a/src/Mail/Mailable.php +++ b/src/Mail/Mailable.php @@ -48,49 +48,49 @@ abstract class Mailable implements MailableContract abstract public function build(): self; - public function to(array|string $to): self + public function to(array|string $to): static { $this->to = array_merge($this->to, (array) $to); return $this; } - public function cc(array|string $cc): self + public function cc(array|string $cc): static { $this->cc = (array) $cc; return $this; } - public function bcc(array|string $bcc): self + public function bcc(array|string $bcc): static { $this->bcc = (array) $bcc; return $this; } - public function tagHeader(string $value): self + public function tagHeader(string $value): static { $this->headers[] = new TagHeader($value); return $this; } - public function metadataHeader(string $key, string $value): self + public function metadataHeader(string $key, string $value): static { $this->headers[] = new MetadataHeader($key, $value); return $this; } - public function textHeader(string $name, string $value): self + public function textHeader(string $name, string $value): static { $this->headers[] = new UnstructuredHeader($name, $value); return $this; } - public function idHeader(string $name, array|string $value): self + public function idHeader(string $name, array|string $value): static { $this->headers[] = new IdentificationHeader($name, $value); @@ -130,28 +130,28 @@ public function toMail(): Email return $email; } - public function from(Address|array|string $from): self + public function from(Address|array|string $from): static { $this->from = $from instanceof Address ? [$from] : (array) $from; return $this; } - protected function replyTo(array|string $replyTo): self + protected function replyTo(array|string $replyTo): static { $this->replyTo = (array) $replyTo; return $this; } - protected function subject(string $subject): self + protected function subject(string $subject): static { $this->subject = $subject; return $this; } - protected function view(string $view, array $viewData = []): self + protected function view(string $view, array $viewData = []): static { $this->view = $view; $this->viewData = $viewData; @@ -159,7 +159,7 @@ protected function view(string $view, array $viewData = []): self return $this; } - protected function attachment(string $path, string|null $name = null, string|null $mime = null): self + protected function attachment(string $path, string|null $name = null, string|null $mime = null): static { if (File::exists($path) === false) { throw new InvalidArgumentException("File {$path} does not exist."); @@ -174,7 +174,7 @@ protected function attachment(string $path, string|null $name = null, string|nul return $this; } - protected function attachments(array $attachments): self + protected function attachments(array $attachments): static { foreach ($attachments as $attachment) { if (is_string($attachment)) {