Skip to content

Commit 95a9f24

Browse files
Merge branch '5.3' into 5.4
* 5.3: Backport type fixes fix annot Backport type fixes Fix CS Avoid triggering the autoloader in Deprecation::isLegacy() fix markdown markup Backport type fixes uzb translation [DependencyInjection] Fix doc blocks [DependencyInjection] Turn $defaultDeprecationTemplate into a constant [GHA] restore phpunit-bridge job rethrow caught exception [Form] better form doc types to support static analysis
2 parents ee9dc6a + 56776a9 commit 95a9f24

File tree

5 files changed

+20
-16
lines changed

5 files changed

+20
-16
lines changed

Address.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -98,19 +98,20 @@ public static function create($address): self
9898
if ($address instanceof self) {
9999
return $address;
100100
}
101-
if (\is_string($address)) {
102-
if (false === strpos($address, '<')) {
103-
return new self($address);
104-
}
105101

106-
if (!preg_match(self::FROM_STRING_PATTERN, $address, $matches)) {
107-
throw new InvalidArgumentException(sprintf('Could not parse "%s" to a "%s" instance.', $address, self::class));
108-
}
102+
if (!\is_string($address)) {
103+
throw new InvalidArgumentException(sprintf('An address can be an instance of Address or a string ("%s" given).', get_debug_type($address)));
104+
}
105+
106+
if (false === strpos($address, '<')) {
107+
return new self($address);
108+
}
109109

110-
return new self($matches['addrSpec'], trim($matches['displayName'], ' \'"'));
110+
if (!preg_match(self::FROM_STRING_PATTERN, $address, $matches)) {
111+
throw new InvalidArgumentException(sprintf('Could not parse "%s" to a "%s" instance.', $address, self::class));
111112
}
112113

113-
throw new InvalidArgumentException(sprintf('An address can be an instance of Address or a string ("%s" given).', get_debug_type($address)));
114+
return new self($matches['addrSpec'], trim($matches['displayName'], ' \'"'));
114115
}
115116

116117
/**

Header/Headers.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,10 @@ public function toArray(): array
254254
return $arr;
255255
}
256256

257-
public function getHeaderBody($name)
257+
/**
258+
* @internal
259+
*/
260+
public function getHeaderBody(string $name)
258261
{
259262
return $this->has($name) ? $this->get($name)->getBody() : null;
260263
}
@@ -288,7 +291,7 @@ public function getHeaderParameter(string $name, string $parameter): ?string
288291
/**
289292
* @internal
290293
*/
291-
public function setHeaderParameter(string $name, string $parameter, $value): void
294+
public function setHeaderParameter(string $name, string $parameter, ?string $value): void
292295
{
293296
if (!$this->has($name)) {
294297
throw new LogicException(sprintf('Unable to set parameter "%s" on header "%s" as the header is not defined.', $parameter, $name));

MimeTypeGuesserInterface.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ public function isGuesserSupported(): bool;
2626
/**
2727
* Guesses the MIME type of the file with the given path.
2828
*
29-
* @param string $path The path to the file
30-
*
3129
* @return string|null The MIME type or null, if none could be guessed
3230
*
3331
* @throws \LogicException If the guesser is not supported

Part/DataPart.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,10 @@ public function __construct($body, string $filename = null, string $contentType
3939

4040
parent::__construct($body, null, $subtype, $encoding);
4141

42-
$this->filename = $filename;
43-
$this->setName($filename);
42+
if (null !== $filename) {
43+
$this->filename = $filename;
44+
$this->setName($filename);
45+
}
4446
$this->setDisposition('attachment');
4547
}
4648

Part/TextPart.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public function setDisposition(string $disposition)
8989
*
9090
* @return $this
9191
*/
92-
public function setName($name)
92+
public function setName(string $name)
9393
{
9494
$this->name = $name;
9595

0 commit comments

Comments
 (0)