Skip to content

Commit

Permalink
Merge branch 'master' into refactor-getDataType
Browse files Browse the repository at this point in the history
  • Loading branch information
vjik authored Nov 26, 2023
2 parents dbb35ec + f655cb7 commit 5854fb7
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
- Enh #779: Specify populate closure type in `BatchQueryResultInterface` (@vjik)
- Enh #778: Deprecate unnecessary argument `$rawSql` of `AbstractCommand::internalExecute()` (@Tigrov)
- Enh #786: Refactor `AbstractSchema::getDataType()` (@Tigrov)
- Enh #784: Specify result type of `ConstraintSchemaInterface::getTableIndexes()` method to `IndexConstraint[]` (@vjik)
- Enh #784: Remove unused code in `AbstractSchema::getTableIndexes()` (@vjik)

## 1.2.0 November 12, 2023

Expand Down
2 changes: 1 addition & 1 deletion src/Constraint/ConstraintSchemaInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public function getTableForeignKeys(string $name, bool $refresh = false): array;
* @param string $name Table name. The table name may contain a schema name if any. Don't quote the table name.
* @param bool $refresh Whether to reload the information, even if it's found in the cache.
*
* @return array The information metadata for the indexes of the named table.
* @return IndexConstraint[] The information metadata for the indexes of the named table.
*/
public function getTableIndexes(string $name, bool $refresh = false): array;

Expand Down
2 changes: 0 additions & 2 deletions src/QueryBuilder/AbstractDMLQueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

use JsonException;
use Yiisoft\Db\Constraint\Constraint;
use Yiisoft\Db\Constraint\IndexConstraint;
use Yiisoft\Db\Exception\Exception;
use Yiisoft\Db\Exception\InvalidArgumentException;
use Yiisoft\Db\Exception\InvalidConfigException;
Expand Down Expand Up @@ -335,7 +334,6 @@ private function getTableUniqueColumnNames(string $name, array $columns, array &
$constraints[] = $primaryKey;
}

/** @psalm-var IndexConstraint[] $tableIndexes */
$tableIndexes = $this->schema->getTableIndexes($name);

foreach ($tableIndexes as $constraint) {
Expand Down
8 changes: 4 additions & 4 deletions src/Schema/AbstractSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Yiisoft\Db\Command\DataType;
use Yiisoft\Db\Connection\ConnectionInterface;
use Yiisoft\Db\Constraint\Constraint;
use Yiisoft\Db\Constraint\IndexConstraint;
use Yiisoft\Db\Exception\NotSupportedException;

use function array_change_key_case;
Expand Down Expand Up @@ -95,7 +96,7 @@ abstract protected function loadTableForeignKeys(string $tableName): array;
*
* @param string $tableName The table name.
*
* @return array The indexes for the given table.
* @return IndexConstraint[] The indexes for the given table.
*/
abstract protected function loadTableIndexes(string $tableName): array;

Expand Down Expand Up @@ -256,9 +257,8 @@ public function getTableForeignKeys(string $name, bool $refresh = false): array
*/
public function getTableIndexes(string $name, bool $refresh = false): array
{
/** @psalm-var mixed $tableIndexes */
$tableIndexes = $this->getTableMetadata($name, SchemaInterface::INDEXES, $refresh);
return is_array($tableIndexes) ? $tableIndexes : [];
/** @var IndexConstraint[] */
return $this->getTableMetadata($name, SchemaInterface::INDEXES, $refresh);
}

/**
Expand Down

0 comments on commit 5854fb7

Please sign in to comment.