Skip to content

Commit 60a3fae

Browse files
authored
Merge pull request #162 from clue-labs/sensitiveparameter
Mark passwords and URIs as `#[\SensitiveParameter]` (PHP 8.2+)
2 parents e375aee + 583e1e1 commit 60a3fae

File tree

3 files changed

+21
-8
lines changed

3 files changed

+21
-8
lines changed

src/Commands/AuthenticateCommand.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,13 @@ class AuthenticateCommand extends AbstractCommand
5151
* @param string $charset
5252
* @throws \InvalidArgumentException for invalid/unknown charset name
5353
*/
54-
public function __construct($user, $passwd, $dbname, $charset)
55-
{
54+
public function __construct(
55+
$user,
56+
#[\SensitiveParameter]
57+
$passwd,
58+
$dbname,
59+
$charset
60+
) {
5661
if (!isset(self::$charsetMap[$charset])) {
5762
throw new \InvalidArgumentException('Unsupported charset selected');
5863
}

src/Factory.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,10 @@ public function __construct(LoopInterface $loop = null, ConnectorInterface $conn
156156
* @param string $uri
157157
* @return PromiseInterface Promise<ConnectionInterface, Exception>
158158
*/
159-
public function createConnection($uri)
160-
{
159+
public function createConnection(
160+
#[\SensitiveParameter]
161+
$uri
162+
) {
161163
if (strpos($uri, '://') === false) {
162164
$uri = 'mysql://' . $uri;
163165
}
@@ -374,8 +376,10 @@ public function createConnection($uri)
374376
* @param string $uri
375377
* @return ConnectionInterface
376378
*/
377-
public function createLazyConnection($uri)
378-
{
379+
public function createLazyConnection(
380+
#[\SensitiveParameter]
381+
$uri
382+
) {
379383
return new LazyConnection($this, $uri, $this->loop);
380384
}
381385
}

src/Io/LazyConnection.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,12 @@ class LazyConnection extends EventEmitter implements ConnectionInterface
3131
private $idleTimer;
3232
private $pending = 0;
3333

34-
public function __construct(Factory $factory, $uri, LoopInterface $loop)
35-
{
34+
public function __construct(
35+
Factory $factory,
36+
#[\SensitiveParameter]
37+
$uri,
38+
LoopInterface $loop
39+
) {
3640
$args = [];
3741
\parse_str((string) \parse_url($uri, \PHP_URL_QUERY), $args);
3842
if (isset($args['idle'])) {

0 commit comments

Comments
 (0)