8000 [Mime] Replace ternary by get_debug_type function · symfony/symfony@d8a0ee1 · GitHub
[go: up one dir, main page]

Skip to content

Commit d8a0ee1

Browse files
committed
[Mime] Replace ternary by get_debug_type function
1 parent 7c28d59 commit d8a0ee1

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/Symfony/Component/Mime/Email.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ public function getPriority(): int
279279
public function text($body, string $charset = 'utf-8')
280280
{
281281
if (null !== $body && !\is_string($body) && !\is_resource($body)) {
282-
throw new \TypeError(sprintf('The body must be a string, a resource or null (got "%s").', \is_object($body) ? \get_class($body) : \gettype($body)));
282+
throw new \TypeError(sprintf('The body must be a string, a resource or null (got "%s").', get_debug_type($body)));
283283
}
284284

285285
$this->text = $body;
@@ -309,7 +309,7 @@ public function getTextCharset(): ?string
309309
public function html($body, string $charset = 'utf-8')
310310
{
311311
if (null !== $body && !\is_string($body) && !\is_resource($body)) {
312-
throw new \TypeError(sprintf('The body must be a string, a resource or null (got "%s").', \is_object($body) ? \get_class($body) : \gettype($body)));
312+
throw new \TypeError(sprintf('The body must be a string, a resource or null (got "%s").', get_debug_type($body)));
313313
}
314314

315315
$this->html = $body;
@@ -339,7 +339,7 @@ public function getHtmlCharset(): ?string
339339
public function attach($body, string $name = null, string $contentType = null)
340340
{
341341
if (!\is_string($body) && !\is_resource($body)) {
342-
throw new \TypeError(sprintf('The body must be a string or a resource (got "%s").', \is_object($body) ? \get_class($body) : \gettype($body)));
342+
throw new \TypeError(sprintf('The body must be a string or a resource (got "%s").', get_debug_type($body)));
343343
}
344344

345345
$this->attachments[] = ['body' => $body, 'name' => $name, 'content-type' => $contentType, 'inline' => false];
@@ -365,7 +365,7 @@ public function attachFromPath(string $path, string $name = null, string $conten
365365
public function embed($body, string $name = null, string $contentType = null)
366366
{
367367
if (!\is_string($body) && !\is_resource($body)) {
368-
throw new \TypeError(sprintf('The body must be a string or a resource (got "%s").', \is_object($body) ? \get_class($body) : \gettype($body)));
368+
throw new \TypeError(sprintf('The body must be a string or a resource (got "%s").', get_debug_type($body)));
369369
}
370370

371371
$this->attachments[] = ['body' => $body, 'name' => $name, 'content-type' => $contentType, 'inline' => true];

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -400,23 +400,23 @@ public function testMissingHeaderDoesNotThrowError()
400400
public function testAttachBodyExpectStringOrResource()
401401
{
402402
$this->expectException(\TypeError::class);
403-
$this->expectExceptionMessage('The body must be a string or a resource (got "boolean").');
403+
$this->expectExceptionMessage('The body must be a string or a resource (got "bool").');
404404

405405
(new Email())->attach(false);
406406
}
407407

408408
public function testEmbedBodyExpectStringOrResource()
409409
{
410410
$this->expectException(\TypeError::class);
411-
$this->expectExceptionMessage('The body must be a string or a resource (got "boolean").');
411+
$this->expectExceptionMessage('The body must be a string or a resource (got "bool").');
412412

413413
(new Email())->embed(false);
414414
}
415415

416416
public function testHtmlBodyExpectStringOrResourceOrNull()
417417
{
418418
$this->expectException(\TypeError::class);
419-
$this->expectExceptionMessage('The body must be a string, a resource or null (got "boolean").');
419+
$this->expectExceptionMessage('The body must be a string, a resource or null (got "bool").');
420420

421421
(new Email())->html(false);
422422
}
@@ -439,7 +439,7 @@ public function testHtmlBodyAcceptedTypes()
439439
public function testTextBodyExpectStringOrResourceOrNull()
440440
{
441441
$this->expectException(\TypeError::class);
442-
$this->expectExceptionMessage('The body must be a string, a resource or null (got "boolean").');
442+
$this->expectExceptionMessage('The body must be a string, a resource or null (got "bool").');
443443

444444
(new Email())->text(false);
445445
}

0 commit comments

Comments
 (0)
0