Skip to content

Commit f655cb7

Browse files
authored
Specify result type of ConstraintSchemaInterface::getTableIndexes() method to IndexConstraint[] (#784)
1 parent 8a3d81f commit f655cb7

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
`DbArrayHelper::populate()` methods to `array[]` (@vjik)
99
- Enh #779: Specify populate closure type in `BatchQueryResultInterface` (@vjik)
1010
- Enh #778: Deprecate unnecessary argument `$rawSql` of `AbstractCommand::internalExecute()` (@Tigrov)
11+
- Enh #784: Specify result type of `ConstraintSchemaInterface::getTableIndexes()` method to `IndexConstraint[]` (@vjik)
12+
- Enh #784: Remove unused code in `AbstractSchema::getTableIndexes()` (@vjik)
1113

1214
## 1.2.0 November 12, 2023
1315

src/Constraint/ConstraintSchemaInterface.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public function getTableForeignKeys(string $name, bool $refresh = false): array;
131131
* @param string $name Table name. The table name may contain a schema name if any. Don't quote the table name.
132132
* @param bool $refresh Whether to reload the information, even if it's found in the cache.
133133
*
134-
* @return array The information metadata for the indexes of the named table.
134+
* @return IndexConstraint[] The information metadata for the indexes of the named table.
135135
*/
136136
public function getTableIndexes(string $name, bool $refresh = false): array;
137137

src/QueryBuilder/AbstractDMLQueryBuilder.php

-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
use JsonException;
88
use Yiisoft\Db\Constraint\Constraint;
9-
use Yiisoft\Db\Constraint\IndexConstraint;
109
use Yiisoft\Db\Exception\Exception;
1110
use Yiisoft\Db\Exception\InvalidArgumentException;
1211
use Yiisoft\Db\Exception\InvalidConfigException;
@@ -335,7 +334,6 @@ private function getTableUniqueColumnNames(string $name, array $columns, array &
335334
$constraints[] = $primaryKey;
336335
}
337336

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

341339
foreach ($tableIndexes as $constraint) {

src/Schema/AbstractSchema.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Yiisoft\Db\Command\DataType;
1111
use Yiisoft\Db\Connection\ConnectionInterface;
1212
use Yiisoft\Db\Constraint\Constraint;
13+
use Yiisoft\Db\Constraint\IndexConstraint;
1314
use Yiisoft\Db\Exception\NotSupportedException;
1415

1516
use function array_change_key_case;
@@ -95,7 +96,7 @@ abstract protected function loadTableForeignKeys(string $tableName): array;
9596
*
9697
* @param string $tableName The table name.
9798
*
98-
* @return array The indexes for the given table.
99+
* @return IndexConstraint[] The indexes for the given table.
99100
*/
100101
abstract protected function loadTableIndexes(string $tableName): array;
101102

@@ -261,9 +262,8 @@ public function getTableForeignKeys(string $name, bool $refresh = false): array
261262
*/
262263
public function getTableIndexes(string $name, bool $refresh = false): array
263264
{
264-
/** @psalm-var mixed $tableIndexes */
265-
$tableIndexes = $this->getTableMetadata($name, SchemaInterface::INDEXES, $refresh);
266-
return is_array($tableIndexes) ? $tableIndexes : [];
265+
/** @var IndexConstraint[] */
266+
return $this->getTableMetadata($name, SchemaInterface::INDEXES, $refresh);
267267
}
268268

269269
/**

0 commit comments

Comments
 (0)