Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1a5d40e

Browse filesBrowse files
[Mime] rename Part/BodyFile to Part/File
1 parent 929d5f4 commit 1a5d40e
Copy full SHA for 1a5d40e

File tree

8 files changed

+25
-25
lines changed
Filter options

8 files changed

+25
-25
lines changed

‎src/Symfony/Bridge/Twig/Mime/WrappedTemplatedEmail.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Mime/WrappedTemplatedEmail.php
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
namespace Symfony\Bridge\Twig\Mime;
1313

1414
use Symfony\Component\Mime\Address;
15-
use Symfony\Component\Mime\Part\BodyFile;
15+
use Symfony\Component\Mime\Part\File;
1616
use Symfony\Component\Mime\Part\DataPart;
1717
use Twig\Environment;
1818

@@ -40,7 +40,7 @@ public function toName(): string
4040
public function image(string $image, string $contentType = null): string
4141
{
4242
$file = $this->twig->getLoader()->getSourceContext($image);
43-
$body = $file->getPath() ? new BodyFile($file->getPath()) : $file->getCode();
43+
$body = $file->getPath() ? new File($file->getPath()) : $file->getCode();
4444
$this->message->addPart((new DataPart($body, $image, $contentType))->asInline());
4545

4646
return 'cid:'.$image;
@@ -49,7 +49,7 @@ public function image(string $image, string $contentType = null): string
4949
public function attach(string $file, string $name = null, string $contentType = null): void
5050
{
5151
$file = $this->twig->getLoader()->getSourceContext($file);
52-
$body = $file->getPath() ? new BodyFile($file->getPath()) : $file->getCode();
52+
$body = $file->getPath() ? new File($file->getPath()) : $file->getCode();
5353
$this->message->addPart(new DataPart($body, $name, $contentType));
5454
}
5555

‎src/Symfony/Component/Mailer/Tests/Transport/Smtp/SmtpTransportTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Mailer/Tests/Transport/Smtp/SmtpTransportTest.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
use Symfony\Component\Mime\Address;
2222
use Symfony\Component\Mime\Email;
2323
use Symfony\Component\Mime\Exception\InvalidArgumentException;
24-
use Symfony\Component\Mime\Part\BodyFile;
24+
use Symfony\Component\Mime\Part\File;
2525
use Symfony\Component\Mime\Part\DataPart;
2626
use Symfony\Component\Mime\RawMessage;
2727

@@ -105,7 +105,7 @@ public function testSendInvalidMessage()
105105
$message = new Email();
106106
$message->to('recipient@example.org');
107107
$message->from('sender@example.org');
108-
$message->addPart(new DataPart(new BodyFile('/does_not_exists')));
108+
$message->addPart(new DataPart(new File('/does_not_exists')));
109109

110110
try {
111111
$transport->send($message);

‎src/Symfony/Component/Mime/Email.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Mime/Email.php
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
use Symfony\Component\Mime\Exception\LogicException;
1515
use Symfony\Component\Mime\Part\AbstractPart;
16-
use Symfony\Component\Mime\Part\BodyFile;
16+
use Symfony\Component\Mime\Part\File;
1717
use Symfony\Component\Mime\Part\DataPart;
1818
use Symfony\Component\Mime\Part\Multipart\AlternativePart;
1919
use Symfony\Component\Mime\Part\Multipart\MixedPart;
@@ -335,7 +335,7 @@ public function attach($body, string $name = null, string $contentType = null):
335335
*/
336336
public function attachFromPath(string $path, string $name = null, string $contentType = null): static
337337
{
338-
return $this->addPart(new DataPart(new BodyFile($path), $name, $contentType));
338+
return $this->addPart(new DataPart(new File($path), $name, $contentType));
339339
}
340340

341341
/**
@@ -353,7 +353,7 @@ public function embed($body, string $name = null, string $contentType = null): s
353353
*/
354354
public function embedFromPath(string $path, string $name = null, string $contentType = null): static
355355
{
356-
return $this->addPart((new DataPart(new BodyFile($path), $name, $contentType))->asInline());
356+
return $this->addPart((new DataPart(new File($path), $name, $contentType))->asInline());
357357
}
358358

359359
/**

‎src/Symfony/Component/Mime/Part/DataPart.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Mime/Part/DataPart.php
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,18 @@ class DataPart extends TextPart
2727
private $cid;
2828

2929
/**
30-
* @param resource|string|BodyFile $body Use a BodyFile instance to defer loading the file until rendering
30+
* @param resource|string|File $body Use a File instance to defer loading the file until rendering
3131
*/
3232
public function __construct($body, string $filename = null, string $contentType = null, string $encoding = null)
3333
{
3434
unset($this->_parent);
3535

36-
if ($body instanceof BodyFile && !$filename) {
36+
if ($body instanceof File && !$filename) {
3737
$filename = basename($body->getPath());
3838
}
3939

4040
if (null === $contentType) {
41-
$contentType = $body instanceof BodyFile ? $body->getContentType() : 'application/octet-stream';
41+
$contentType = $body instanceof File ? $body->getContentType() : 'application/octet-stream';
4242
}
4343
[$this->mediaType, $subtype] = explode('/', $contentType);
4444

@@ -53,7 +53,7 @@ public function __construct($body, string $filename = null, string $contentType
5353

5454
public static function fromPath(string $path, string $name = null, string $contentType = null): self
5555
{
56-
return new self(new BodyFile($path), $name, $contentType);
56+
return new self(new File($path), $name, $contentType);
5757
}
5858

5959
/**

‎src/Symfony/Component/Mime/Part/BodyFile.php renamed to ‎src/Symfony/Component/Mime/Part/File.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Mime/Part/File.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
/**
1717
* @author Fabien Potencier <fabien@symfony.com>
1818
*/
19-
class BodyFile
19+
class File
2020
{
2121
private static $mimeTypes;
2222

‎src/Symfony/Component/Mime/Part/TextPart.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Mime/Part/TextPart.php
+6-6Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,19 @@ class TextPart extends AbstractPart
4040
private $seekable;
4141

4242
/**
43-
* @param resource|string|BodyFile $body Use a BodyFile instance to defer loading the file until rendering
43+
* @param resource|string|File $body Use a File instance to defer loading the file until rendering
4444
*/
4545
public function __construct($body, ?string $charset = 'utf-8', string $subtype = 'plain', string $encoding = null)
4646
{
4747
unset($this->_headers);
4848

4949
parent::__construct();
5050

51-
if (!\is_string($body) && !\is_resource($body) && !$body instanceof BodyFile) {
52-
throw new \TypeError(sprintf('The body of "%s" must be a string, a resource, or an instance of "%s" (got "%s").', self::class, BodyFile::class, get_debug_type($body)));
51+
if (!\is_string($body) && !\is_resource($body) && !$body instanceof File) {
52+
throw new \TypeError(sprintf('The body of "%s" must be a string, a resource, or an instance of "%s" (got "%s").', self::class, File::class, get_debug_type($body)));
5353
}
5454

55-
if ($body instanceof BodyFile) {
55+
if ($body instanceof File) {
5656
$path = $body->getPath();
5757
if ((is_file($path) && !is_readable($path)) || is_dir($path)) {
5858
throw new InvalidArgumentException(sprintf('Path "%s" is not readable.', $path));
@@ -118,7 +118,7 @@ public function getName(): ?string
118118

119119
public function getBody(): string
120120
{
121-
if ($this->body instanceof BodyFile) {
121+
if ($this->body instanceof File) {
122122
return file_get_contents($this->body->getPath());
123123
}
124124

@@ -140,7 +140,7 @@ public function bodyToString(): string
140140

141141
public function bodyToIterable(): iterable
142142
{
143-
if ($this->body instanceof BodyFile) {
143+
if ($this->body instanceof File) {
144144
$path = $this->body->getPath();
145145
if (false === $handle = @fopen($path, 'r', false)) {
146146
throw new InvalidArgumentException(sprintf('Unable to open path "%s".', $path));

‎src/Symfony/Component/Mime/Tests/EmailTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Mime/Tests/EmailTest.php
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
use PHPUnit\Framework\TestCase;
1616
use Symfony\Component\Mime\Address;
1717
use Symfony\Component\Mime\Email;
18-
use Symfony\Component\Mime\Part\BodyFile;
18+
use Symfony\Component\Mime\Part\File;
1919
use Symfony\Component\Mime\Part\DataPart;
2020
use Symfony\Component\Mime\Part\Multipart\AlternativePart;
2121
use Symfony\Component\Mime\Part\Multipart\MixedPart;
@@ -463,8 +463,8 @@ public function testAttachments()
463463
$att = DataPart::fromPath($name, 'test');
464464
$inline = DataPart::fromPath($name, 'test')->asInline();
465465
$e = new Email();
466-
$e->addPart(new DataPart(new BodyFile($name)));
467-
$e->addPart((new DataPart(new BodyFile($name)))->asInline());
466+
$e->addPart(new DataPart(new File($name)));
467+
$e->addPart((new DataPart(new File($name)))->asInline());
468468
$this->assertEquals([$att->bodyToString(), $inline->bodyToString()], array_map(function (DataPart $a) { return $a->bodyToString(); }, $e->getAttachments()));
469469
$this->assertEquals([$att->getPreparedHeaders(), $inline->getPreparedHeaders()], array_map(function (DataPart $a) { return $a->getPreparedHeaders(); }, $e->getAttachments()));
470470
}

‎src/Symfony/Component/Mime/Tests/Part/TextPartTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Mime/Tests/Part/TextPartTest.php
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
use Symfony\Component\Mime\Header\Headers;
1616
use Symfony\Component\Mime\Header\ParameterizedHeader;
1717
use Symfony\Component\Mime\Header\UnstructuredHeader;
18-
use Symfony\Component\Mime\Part\BodyFile;
18+
use Symfony\Component\Mime\Part\File;
1919
use Symfony\Component\Mime\Part\TextPart;
2020

2121
class TextPartTest extends TestCase
@@ -47,9 +47,9 @@ public function testConstructorWithResource()
4747
fclose($f);
4848
}
4949

50-
public function testConstructorWithBodyFile()
50+
public function testConstructorWithFile()
5151
{
52-
$p = new TextPart(new BodyFile(\dirname(__DIR__).'/Fixtures/content.txt'));
52+
$p = new TextPart(new File(\dirname(__DIR__).'/Fixtures/content.txt'));
5353
$this->assertSame('content', $p->getBody());
5454
$this->assertSame('content', $p->bodyToString());
5555
$this->assertSame('content', implode('', iterator_to_array($p->bodyToIterable())));

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.