updated-packages

This commit is contained in:
RafficMohammed
2023-01-08 00:13:22 +05:30
parent 3ff7df7487
commit da241bacb6
12659 changed files with 563377 additions and 510538 deletions

View File

@@ -11,6 +11,7 @@ use Doctrine\DBAL\Event\ConnectionEventArgs;
use Doctrine\DBAL\Events;
use Doctrine\DBAL\Sharding\ShardChoser\ShardChoser;
use InvalidArgumentException;
use function array_merge;
use function is_numeric;
use function is_string;
@@ -26,12 +27,14 @@ use function is_string;
* - By default, the global shard is selected. If no global shard is configured
* an exception is thrown on access.
* - Selecting a shard by distribution value delegates the mapping
* "distributionValue" => "client" to the ShardChooser interface.
* "distributionValue" => "client" to the ShardChoser interface.
* - An exception is thrown if trying to switch shards during an open
* transaction.
*
* Instantiation through the DriverManager looks like:
*
* @deprecated
*
* @example
*
* $conn = DriverManager::getConnection(array(
@@ -53,7 +56,7 @@ class PoolingShardConnection extends Connection
/** @var DriverConnection[] */
private $activeConnections = [];
/** @var int|null */
/** @var string|int|null */
private $activeShardId;
/** @var mixed[] */
@@ -62,10 +65,16 @@ class PoolingShardConnection extends Connection
/**
* {@inheritDoc}
*
* @internal The connection can be only instantiated by the driver manager.
*
* @throws InvalidArgumentException
*/
public function __construct(array $params, Driver $driver, ?Configuration $config = null, ?EventManager $eventManager = null)
{
public function __construct(
array $params,
Driver $driver,
?Configuration $config = null,
?EventManager $eventManager = null
) {
if (! isset($params['global'], $params['shards'])) {
throw new InvalidArgumentException("Connection Parameters require 'global' and 'shards' configurations.");
}
@@ -79,14 +88,18 @@ class PoolingShardConnection extends Connection
}
if (! ($params['shardChoser'] instanceof ShardChoser)) {
throw new InvalidArgumentException("The 'shardChoser' configuration is not a valid instance of Doctrine\DBAL\Sharding\ShardChoser\ShardChoser");
throw new InvalidArgumentException(
"The 'shardChoser' configuration is not a valid instance of " . ShardChoser::class
);
}
$this->connectionParameters[0] = array_merge($params, $params['global']);
foreach ($params['shards'] as $shard) {
if (! isset($shard['id'])) {
throw new InvalidArgumentException("Missing 'id' for one configured shard. Please specify a unique shard-id.");
throw new InvalidArgumentException(
"Missing 'id' for one configured shard. Please specify a unique shard-id."
);
}
if (! is_numeric($shard['id']) || $shard['id'] < 1) {
@@ -106,7 +119,7 @@ class PoolingShardConnection extends Connection
/**
* Get active shard id.
*
* @return int
* @return string|int|null
*/
public function getActiveShardId()
{
@@ -118,7 +131,9 @@ class PoolingShardConnection extends Connection
*/
public function getParams()
{
return $this->activeShardId ? $this->connectionParameters[$this->activeShardId] : $this->connectionParameters[0];
return $this->activeShardId
? $this->connectionParameters[$this->activeShardId]
: $this->connectionParameters[0];
}
/**
@@ -164,7 +179,7 @@ class PoolingShardConnection extends Connection
/**
* Connects to a given shard.
*
* @param mixed $shardId
* @param string|int|null $shardId
*
* @return bool
*
@@ -184,15 +199,15 @@ class PoolingShardConnection extends Connection
throw new ShardingException('Cannot switch shard when transaction is active.');
}
$this->activeShardId = (int) $shardId;
$activeShardId = $this->activeShardId = (int) $shardId;
if (isset($this->activeConnections[$this->activeShardId])) {
$this->_conn = $this->activeConnections[$this->activeShardId];
if (isset($this->activeConnections[$activeShardId])) {
$this->_conn = $this->activeConnections[$activeShardId];
return false;
}
$this->_conn = $this->activeConnections[$this->activeShardId] = $this->connectTo($this->activeShardId);
$this->_conn = $this->activeConnections[$activeShardId] = $this->connectTo($activeShardId);
if ($this->_eventManager->hasListeners(Events::postConnect)) {
$eventArgs = new ConnectionEventArgs($this);
@@ -205,7 +220,7 @@ class PoolingShardConnection extends Connection
/**
* Connects to a specific connection.
*
* @param string $shardId
* @param string|int $shardId
*
* @return \Doctrine\DBAL\Driver\Connection
*/
@@ -224,7 +239,7 @@ class PoolingShardConnection extends Connection
}
/**
* @param string|null $shardId
* @param string|int|null $shardId
*
* @return bool
*/