From f54ed8b9b60abfee28f3fc6a0ef549df10b209cf Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 22 Jul 2022 17:31:54 +0200 Subject: [PATCH] [Mime] Simplify code --- src/Symfony/Component/Mime/Email.php | 9 ++------- src/Symfony/Component/Mime/Part/TextPart.php | 7 ++++++- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Symfony/Component/Mime/Email.php b/src/Symfony/Component/Mime/Email.php index 2aa63f7d01ab8..85ee77130f53b 100644 --- a/src/Symfony/Component/Mime/Email.php +++ b/src/Symfony/Component/Mime/Email.php @@ -501,16 +501,11 @@ private function prepareParts(): ?array $names = array_filter(array_unique($names)); } - // usage of reflection is a temporary workaround for missing getters that will be added in 6.2 - $dispositionRef = new \ReflectionProperty(TextPart::class, 'disposition'); - $dispositionRef->setAccessible(true); - $nameRef = new \ReflectionProperty(TextPart::class, 'name'); - $nameRef->setAccessible(true); $attachmentParts = $inlineParts = []; foreach ($this->attachments as $attachment) { $part = $this->createDataPart($attachment); if (isset($attachment['part'])) { - $attachment['name'] = $nameRef->getValue($part); + $attachment['name'] = $part->getName(); } foreach ($names as $name) { @@ -527,7 +522,7 @@ private function prepareParts(): ?array break; } - if ('inline' === $dispositionRef->getValue($part)) { + if ('inline' === $part->getDisposition()) { $inlineParts[$attachment['name']] = $part; } else { $attachmentParts[] = $part; diff --git a/src/Symfony/Component/Mime/Part/TextPart.php b/src/Symfony/Component/Mime/Part/TextPart.php index f5477c4b14dab..fc177497d4d48 100644 --- a/src/Symfony/Component/Mime/Part/TextPart.php +++ b/src/Symfony/Component/Mime/Part/TextPart.php @@ -89,6 +89,11 @@ public function setDisposition(string $disposition): static return $this; } + public function getDisposition(): ?string + { + return $this->disposition; + } + /** * Sets the name of the file (used by FormDataPart). * @@ -102,7 +107,7 @@ public function setName(string $name): static } /** - * Gets the name of the file (used by FormDataPart). + * Gets the name of the file. */ public function getName(): ?string {