Skip to content

Commit

Permalink
Specify result type of ConstraintSchemaInterface::getTableIndexes()
Browse files Browse the repository at this point in the history
… method to `IndexConstraint[]`
  • Loading branch information
vjik committed Nov 24, 2023
1 parent 8a3d81f commit 6b7b639
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
`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)

## 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
5 changes: 3 additions & 2 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 @@ -261,7 +262,7 @@ public function getTableForeignKeys(string $name, bool $refresh = false): array
*/
public function getTableIndexes(string $name, bool $refresh = false): array
{
/** @psalm-var mixed $tableIndexes */
/** @var IndexConstraint[]|null $tableIndexes */
$tableIndexes = $this->getTableMetadata($name, SchemaInterface::INDEXES, $refresh);
return is_array($tableIndexes) ? $tableIndexes : [];
}
Expand Down

0 comments on commit 6b7b639

Please sign in to comment.