Skip to content

Commit c79f7ba

Browse files
Mark DSNs as #[SensitiveParameter]
1 parent 2e2ac75 commit c79f7ba

File tree

3 files changed

+8
-18
lines changed

3 files changed

+8
-18
lines changed

Transport.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,14 @@ final class Transport
5858

5959
private iterable $factories;
6060

61-
public static function fromDsn(string $dsn, EventDispatcherInterface $dispatcher = null, HttpClientInterface $client = null, LoggerInterface $logger = null): TransportInterface
61+
public static function fromDsn(#[\SensitiveParameter] string $dsn, EventDispatcherInterface $dispatcher = null, HttpClientInterface $client = null, LoggerInterface $logger = null): TransportInterface
6262
{
6363
$factory = new self(iterator_to_array(self::getDefaultFactories($dispatcher, $client, $logger)));
6464

6565
return $factory->fromString($dsn);
6666
}
6767

68-
public static function fromDsns(array $dsns, EventDispatcherInterface $dispatcher = null, HttpClientInterface $client = null, LoggerInterface $logger = null): TransportInterface
68+
public static function fromDsns(#[\SensitiveParameter] array $dsns, EventDispatcherInterface $dispatcher = null, HttpClientInterface $client = null, LoggerInterface $logger = null): TransportInterface
6969
{
7070
$factory = new self(iterator_to_array(self::getDefaultFactories($dispatcher, $client, $logger)));
7171

@@ -80,7 +80,7 @@ public function __construct(iterable $factories)
8080
$this->factories = $factories;
8181
}
8282

83-
public function fromStrings(array $dsns): Transports
83+
public function fromStrings(#[\SensitiveParameter] array $dsns): Transports
8484
{
8585
$transports = [];
8686
foreach ($dsns as $name => $dsn) {
@@ -90,7 +90,7 @@ public function fromStrings(array $dsns): Transports
9090
return new Transports($transports);
9191
}
9292

93-
public function fromString(string $dsn): TransportInterface
93+
public function fromString(#[\SensitiveParameter] string $dsn): TransportInterface
9494
{
9595
[$transport, $offset] = $this->parseDsn($dsn);
9696
if ($offset !== \strlen($dsn)) {
@@ -100,7 +100,7 @@ public function fromString(string $dsn): TransportInterface
100100
return $transport;
101101
}
102102

103-
private function parseDsn(string $dsn, int $offset = 0): array
103+
private function parseDsn(#[\SensitiveParameter] string $dsn, int $offset = 0): array
104104
{
105105
static $keywords = [
106106
'failover' => FailoverTransport::class,

Transport/AbstractTransportFactory.php

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,11 @@ abstract protected function getSupportedSchemes(): array;
4141

4242
protected function getUser(Dsn $dsn): string
4343
{
44-
$user = $dsn->getUser();
45-
if (null === $user) {
46-
throw new IncompleteDsnException('User is not set.');
47-
}
48-
49-
return $user;
44+
return $dsn->getUser() ?? throw new IncompleteDsnException('User is not set.');
5045
}
5146

5247
protected function getPassword(Dsn $dsn): string
5348
{
54-
$password = $dsn->getPassword();
55-
if (null === $password) {
56-
throw new IncompleteDsnException('Password is not set.');
57-
}
58-
59-
return $password;
49+
return $dsn->getPassword() ?? throw new IncompleteDsnException('Password is not set.');
6050
}
6151
}

Transport/Dsn.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function __construct(string $scheme, string $host, string $user = null, #
3535
$this->options = $options;
3636
}
3737

38-
public static function fromString(string $dsn): self
38+
public static function fromString(#[\SensitiveParameter] string $dsn): self
3939
{
4040
if (false === $parsedDsn = parse_url($dsn)) {
4141
throw new InvalidArgumentException(sprintf('The "%s" mailer DSN is invalid.', $dsn));

0 commit comments

Comments
 (0)