🔧
This commit is contained in:
20
vendor/symfony/mailer/Transport/Dsn.php
vendored
20
vendor/symfony/mailer/Transport/Dsn.php
vendored
@@ -25,7 +25,7 @@ final class Dsn
|
||||
private ?int $port;
|
||||
private array $options;
|
||||
|
||||
public function __construct(string $scheme, string $host, string $user = null, #[\SensitiveParameter] string $password = null, int $port = null, array $options = [])
|
||||
public function __construct(string $scheme, string $host, ?string $user = null, #[\SensitiveParameter] ?string $password = null, ?int $port = null, array $options = [])
|
||||
{
|
||||
$this->scheme = $scheme;
|
||||
$this->host = $host;
|
||||
@@ -37,24 +37,24 @@ final class Dsn
|
||||
|
||||
public static function fromString(#[\SensitiveParameter] string $dsn): self
|
||||
{
|
||||
if (false === $parsedDsn = parse_url($dsn)) {
|
||||
if (false === $params = parse_url($dsn)) {
|
||||
throw new InvalidArgumentException('The mailer DSN is invalid.');
|
||||
}
|
||||
|
||||
if (!isset($parsedDsn['scheme'])) {
|
||||
if (!isset($params['scheme'])) {
|
||||
throw new InvalidArgumentException('The mailer DSN must contain a scheme.');
|
||||
}
|
||||
|
||||
if (!isset($parsedDsn['host'])) {
|
||||
if (!isset($params['host'])) {
|
||||
throw new InvalidArgumentException('The mailer DSN must contain a host (use "default" by default).');
|
||||
}
|
||||
|
||||
$user = '' !== ($parsedDsn['user'] ?? '') ? urldecode($parsedDsn['user']) : null;
|
||||
$password = '' !== ($parsedDsn['pass'] ?? '') ? urldecode($parsedDsn['pass']) : null;
|
||||
$port = $parsedDsn['port'] ?? null;
|
||||
parse_str($parsedDsn['query'] ?? '', $query);
|
||||
$user = '' !== ($params['user'] ?? '') ? rawurldecode($params['user']) : null;
|
||||
$password = '' !== ($params['pass'] ?? '') ? rawurldecode($params['pass']) : null;
|
||||
$port = $params['port'] ?? null;
|
||||
parse_str($params['query'] ?? '', $query);
|
||||
|
||||
return new self($parsedDsn['scheme'], $parsedDsn['host'], $user, $password, $port, $query);
|
||||
return new self($params['scheme'], $params['host'], $user, $password, $port, $query);
|
||||
}
|
||||
|
||||
public function getScheme(): string
|
||||
@@ -77,7 +77,7 @@ final class Dsn
|
||||
return $this->password;
|
||||
}
|
||||
|
||||
public function getPort(int $default = null): ?int
|
||||
public function getPort(?int $default = null): ?int
|
||||
{
|
||||
return $this->port ?? $default;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user