Skip to content

Commit

Permalink
Try to work around Roave/infection-static-analysis-plugin#465 by chan…
Browse files Browse the repository at this point in the history
…ging trait override technique
  • Loading branch information
Jean85 committed Sep 26, 2024
1 parent 1a39930 commit 720014e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Facile\DoctrineMySQLComeBack\Doctrine\DBAL;

/** @psalm-suppress PropertyNotSetInConstructor */
class Connection extends \Doctrine\DBAL\Connection
{
use ConnectionTrait;
Expand Down
12 changes: 12 additions & 0 deletions src/ConnectionTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,18 @@ public function __construct(
Driver $driver,
?Configuration $config = null
) {
$this->commonConstructor($params, $driver, $config);
}

/**
* @param array $params
* @param Driver $driver
* @param Configuration|null $config
*
* @return void
*/
private function commonConstructor(array &$params, Driver $driver, ?Configuration $config): void
{
if (isset($params['driverOptions']['x_reconnect_attempts'])) {
$this->maxReconnectAttempts = $this->validateAttemptsOption($params['driverOptions']['x_reconnect_attempts']);
unset($params['driverOptions']['x_reconnect_attempts']);
Expand Down
6 changes: 2 additions & 4 deletions src/Connections/PrimaryReadReplicaConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@

class PrimaryReadReplicaConnection extends \Doctrine\DBAL\Connections\PrimaryReadReplicaConnection
{
use ConnectionTrait {
__construct as __traitConstruct;
}
use ConnectionTrait;

public function __construct(array $params, Driver $driver, ?Configuration $config = null)
{
Expand All @@ -19,6 +17,6 @@ public function __construct(array $params, Driver $driver, ?Configuration $confi
unset($params['primary']['driverOptions']['x_reconnect_attempts']);
}

self::__traitConstruct($params, $driver, $config);
$this->commonConstructor($params, $driver, $config);
}
}

0 comments on commit 720014e

Please sign in to comment.