diff --git a/lib/Doctrine/DBAL/Sharding/PoolingShardManager.php b/lib/Doctrine/DBAL/Sharding/PoolingShardManager.php index d0efce31ab2..5a21944d303 100644 --- a/lib/Doctrine/DBAL/Sharding/PoolingShardManager.php +++ b/lib/Doctrine/DBAL/Sharding/PoolingShardManager.php @@ -18,7 +18,7 @@ class PoolingShardManager implements ShardManager /** @var ShardChoser */ private $choser; - /** @var string|null */ + /** @var mixed */ private $currentDistributionValue; public function __construct(PoolingShardConnection $conn) @@ -31,7 +31,7 @@ public function __construct(PoolingShardConnection $conn) /** * {@inheritDoc} */ - public function selectGlobal() + public function selectGlobal() : void { $this->conn->connect(0); $this->currentDistributionValue = null; @@ -40,7 +40,7 @@ public function selectGlobal() /** * {@inheritDoc} */ - public function selectShard($distributionValue) + public function selectShard($distributionValue) : void { $shardId = $this->choser->pickShard($distributionValue, $this->conn); $this->conn->connect($shardId); @@ -58,7 +58,7 @@ public function getCurrentDistributionValue() /** * {@inheritDoc} */ - public function getShards() + public function getShards() : array { $params = $this->conn->getParams(); $shards = []; @@ -75,7 +75,7 @@ public function getShards() * * @throws RuntimeException */ - public function queryAll($sql, array $params, array $types) + public function queryAll(string $sql, array $params, array $types) : array { $shards = $this->getShards(); if (! $shards) { diff --git a/lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureFederationsSynchronizer.php b/lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureFederationsSynchronizer.php index c372f416fca..343b941a6ec 100644 --- a/lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureFederationsSynchronizer.php +++ b/lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureFederationsSynchronizer.php @@ -158,7 +158,7 @@ public function dropAllSchema() : void /** * @return Schema[] */ - private function partitionSchema(Schema $schema) + private function partitionSchema(Schema $schema) : array { return [ $this->extractSchemaFederation($schema, false), @@ -167,13 +167,9 @@ private function partitionSchema(Schema $schema) } /** - * @param bool $isFederation - * - * @return Schema - * * @throws RuntimeException */ - private function extractSchemaFederation(Schema $schema, $isFederation) + private function extractSchemaFederation(Schema $schema, bool $isFederation) : Schema { $partitionedSchema = clone $schema; @@ -204,7 +200,7 @@ private function extractSchemaFederation(Schema $schema, $isFederation) * * @return string[] */ - private function work(Schema $schema, Closure $operation) + private function work(Schema $schema, Closure $operation) : array { [$global, $federation] = $this->partitionSchema($schema); $sql = []; @@ -235,10 +231,7 @@ private function work(Schema $schema, Closure $operation) return $sql; } - /** - * @return string - */ - private function getFederationTypeDefaultValue() + private function getFederationTypeDefaultValue() : string { $federationType = Type::getType($this->shardManager->getDistributionType()); @@ -259,10 +252,7 @@ private function getFederationTypeDefaultValue() return $defaultValue; } - /** - * @return string - */ - private function getCreateFederationStatement() + private function getCreateFederationStatement() : string { $federationType = Type::getType($this->shardManager->getDistributionType()); $federationTypeSql = $federationType->getSQLDeclaration([], $this->conn->getDatabasePlatform()); diff --git a/lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureShardManager.php b/lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureShardManager.php index ad5964a66e9..3463f4f09ba 100644 --- a/lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureShardManager.php +++ b/lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureShardManager.php @@ -35,7 +35,7 @@ class SQLAzureShardManager implements ShardManager /** @var Connection */ private $conn; - /** @var string|null */ + /** @var mixed */ private $currentDistributionValue; /** @@ -66,50 +66,40 @@ public function __construct(Connection $conn) /** * Gets the name of the federation. - * - * @return string */ - public function getFederationName() + public function getFederationName() : string { return $this->federationName; } /** * Gets the distribution key. - * - * @return string */ - public function getDistributionKey() + public function getDistributionKey() : string { return $this->distributionKey; } /** * Gets the Doctrine Type name used for the distribution. - * - * @return string */ - public function getDistributionType() + public function getDistributionType() : string { return $this->distributionType; } /** * Sets Enabled/Disable filtering on the fly. - * - * @param bool $flag - * - * @return void */ - public function setFilteringEnabled($flag) + public function setFilteringEnabled(bool $flag) : void { - $this->filteringEnabled = (bool) $flag; + $this->filteringEnabled = $flag; } /** * {@inheritDoc} */ - public function selectGlobal() + public function selectGlobal() : void { if ($this->conn->isTransactionActive()) { throw ActiveTransaction::new(); @@ -123,7 +113,7 @@ public function selectGlobal() /** * {@inheritDoc} */ - public function selectShard($distributionValue) + public function selectShard($distributionValue) : void { if ($this->conn->isTransactionActive()) { throw ActiveTransaction::new(); @@ -153,7 +143,7 @@ public function getCurrentDistributionValue() /** * {@inheritDoc} */ - public function getShards() + public function getShards() : array { $sql = 'SELECT member_id as id, distribution_name as distribution_key, @@ -169,7 +159,7 @@ public function getShards() /** * {@inheritDoc} */ - public function queryAll($sql, array $params = [], array $types = []) + public function queryAll(string $sql, array $params = [], array $types = []) : array { $shards = $this->getShards(); if (! $shards) { @@ -199,10 +189,8 @@ public function queryAll($sql, array $params = [], array $types = []) * Splits Federation at a given distribution value. * * @param mixed $splitDistributionValue - * - * @return void */ - public function splitFederation($splitDistributionValue) + public function splitFederation($splitDistributionValue) : void { $type = Type::getType($this->distributionType); diff --git a/lib/Doctrine/DBAL/Sharding/SQLAzure/Schema/MultiTenantVisitor.php b/lib/Doctrine/DBAL/Sharding/SQLAzure/Schema/MultiTenantVisitor.php index da5328aed8f..a14f26c2418 100644 --- a/lib/Doctrine/DBAL/Sharding/SQLAzure/Schema/MultiTenantVisitor.php +++ b/lib/Doctrine/DBAL/Sharding/SQLAzure/Schema/MultiTenantVisitor.php @@ -54,11 +54,9 @@ class MultiTenantVisitor implements Visitor private $distributionName; /** - * @param string[] $excludedTables - * @param string $tenantColumnName - * @param string|null $distributionName + * @param string[] $excludedTables */ - public function __construct(array $excludedTables = [], $tenantColumnName = 'tenant_id', $distributionName = null) + public function __construct(array $excludedTables = [], string $tenantColumnName = 'tenant_id', ?string $distributionName = null) { $this->excludedTables = $excludedTables; $this->tenantColumnName = $tenantColumnName; @@ -94,13 +92,9 @@ public function acceptTable(Table $table) : void } /** - * @param Table $table - * - * @return Index - * * @throws RuntimeException */ - private function getClusteredIndex($table) + private function getClusteredIndex(Table $table) : Index { foreach ($table->getIndexes() as $index) { if ($index->isPrimary() && ! $index->hasFlag('nonclustered')) { diff --git a/lib/Doctrine/DBAL/Sharding/ShardManager.php b/lib/Doctrine/DBAL/Sharding/ShardManager.php index 793b0bb9340..d06f08ec331 100644 --- a/lib/Doctrine/DBAL/Sharding/ShardManager.php +++ b/lib/Doctrine/DBAL/Sharding/ShardManager.php @@ -27,26 +27,22 @@ interface ShardManager * * This is the default database that is connected when no shard is * selected. - * - * @return void */ - public function selectGlobal(); + public function selectGlobal() : void; /** * Selects the shard against which the queries after this statement will be issued. * - * @param string $distributionValue - * - * @return void + * @param mixed $distributionValue * * @throws ShardingException If no value is passed as shard identifier. */ - public function selectShard($distributionValue); + public function selectShard($distributionValue) : void; /** * Gets the distribution value currently used for sharding. * - * @return string|null + * @return mixed */ public function getCurrentDistributionValue(); @@ -58,7 +54,7 @@ public function getCurrentDistributionValue(); * * @return mixed[][] */ - public function getShards(); + public function getShards() : array; /** * Queries all shards in undefined order and return the results appended to @@ -66,11 +62,10 @@ public function getShards(); * * Using {@link \Doctrine\DBAL\Connection::fetchAll} to retrieve rows internally. * - * @param string $sql * @param mixed[] $params * @param int[]|string[] $types * * @return mixed[] */ - public function queryAll($sql, array $params, array $types); + public function queryAll(string $sql, array $params, array $types) : array; }