diff --git a/CHANGELOG.md b/CHANGELOG.md index af82ceefc..f3c06c3a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ `DbArrayHelper::populate()` methods to `array[]` (@vjik) - Enh #779: Specify populate closure type in `BatchQueryResultInterface` (@vjik) - Enh #778: Deprecate unnecessary argument `$rawSql` of `AbstractCommand::internalExecute()` (@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 diff --git a/src/Constraint/ConstraintSchemaInterface.php b/src/Constraint/ConstraintSchemaInterface.php index 309bc6c5a..957ea6b3f 100644 --- a/src/Constraint/ConstraintSchemaInterface.php +++ b/src/Constraint/ConstraintSchemaInterface.php @@ -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; diff --git a/src/QueryBuilder/AbstractDMLQueryBuilder.php b/src/QueryBuilder/AbstractDMLQueryBuilder.php index 5d57d6412..b3c0a4132 100644 --- a/src/QueryBuilder/AbstractDMLQueryBuilder.php +++ b/src/QueryBuilder/AbstractDMLQueryBuilder.php @@ -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; @@ -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) { diff --git a/src/Schema/AbstractSchema.php b/src/Schema/AbstractSchema.php index cd1c89cb0..7e88d45f6 100644 --- a/src/Schema/AbstractSchema.php +++ b/src/Schema/AbstractSchema.php @@ -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; @@ -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; @@ -261,9 +262,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); } /**