Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specify result type of ConstraintSchemaInterface::getTableIndexes() method to IndexConstraint[] #784

Merged
merged 2 commits into from
Nov 26, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 */
Tigrov marked this conversation as resolved.
Show resolved Hide resolved
$tableIndexes = $this->getTableMetadata($name, SchemaInterface::INDEXES, $refresh);
return is_array($tableIndexes) ? $tableIndexes : [];
}
Expand Down
Loading