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 Mar 9, 2024
1 parent d631fb9 commit ac21488
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 @@ -39,6 +39,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 ac21488

Please sign in to comment.