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

Remove unused code in Command class + Cleanup psalm annotations #281

Merged
merged 2 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## 1.1.1 under development

- no changes in this release.
- Enh #281: Remove unused code in `Command` class (@vjik)

## 1.1.0 November 12, 2023

Expand Down
1 change: 0 additions & 1 deletion src/AbstractTokenizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,8 @@
$token[] = (new SqlToken())->type(SqlToken::TYPE_STATEMENT);

$this->tokenStack->push($token[0]);
/** @psalm-var SqlToken */
$this->currentToken = $this->tokenStack->top();
$length = 0;

Check warning on line 105 in src/AbstractTokenizer.php

View workflow job for this annotation

GitHub Actions / PHP 8-sqlite-ubuntu-latest

Escaped Mutant for Mutator "DecrementInteger": --- Original +++ New @@ @@ $token[] = (new SqlToken())->type(SqlToken::TYPE_STATEMENT); $this->tokenStack->push($token[0]); $this->currentToken = $this->tokenStack->top(); - $length = 0; + $length = -1; while (!$this->isEof()) { if ($this->isWhitespace($length) || $this->isComment($length)) { $this->addTokenFromBuffer();

Check warning on line 105 in src/AbstractTokenizer.php

View workflow job for this annotation

GitHub Actions / PHP 8.1-sqlite-ubuntu-latest

Escaped Mutant for Mutator "DecrementInteger": --- Original +++ New @@ @@ $token[] = (new SqlToken())->type(SqlToken::TYPE_STATEMENT); $this->tokenStack->push($token[0]); $this->currentToken = $this->tokenStack->top(); - $length = 0; + $length = -1; while (!$this->isEof()) { if ($this->isWhitespace($length) || $this->isComment($length)) { $this->addTokenFromBuffer();

while (!$this->isEof()) {
if ($this->isWhitespace($length) || $this->isComment($length)) {
Expand All @@ -124,7 +123,7 @@
$this->advance(1);
}

$this->addTokenFromBuffer();

Check warning on line 126 in src/AbstractTokenizer.php

View workflow job for this annotation

GitHub Actions / PHP 8-sqlite-ubuntu-latest

Escaped Mutant for Mutator "MethodCallRemoval": --- Original +++ New @@ @@ $this->buffer .= $this->substring(1); $this->advance(1); } - $this->addTokenFromBuffer(); + if ($token->getHasChildren() && $token[-1] instanceof SqlToken && !$token[-1]->getHasChildren()) { unset($token[-1]); }

Check warning on line 126 in src/AbstractTokenizer.php

View workflow job for this annotation

GitHub Actions / PHP 8.1-sqlite-ubuntu-latest

Escaped Mutant for Mutator "MethodCallRemoval": --- Original +++ New @@ @@ $this->buffer .= $this->substring(1); $this->advance(1); } - $this->addTokenFromBuffer(); + if ($token->getHasChildren() && $token[-1] instanceof SqlToken && !$token[-1]->getHasChildren()) { unset($token[-1]); }

if (
$token->getHasChildren() &&
Expand Down Expand Up @@ -282,7 +281,7 @@
$this->substrings[$cacheKey . ',1'] = mb_substr($this->sql, $offset, $length, 'UTF-8');
}

if (!$caseSensitive && !isset($this->substrings[$cacheKey . ',0'])) {

Check warning on line 284 in src/AbstractTokenizer.php

View workflow job for this annotation

GitHub Actions / PHP 8-sqlite-ubuntu-latest

Escaped Mutant for Mutator "ConcatOperandRemoval": --- Original +++ New @@ @@ if (!isset($this->substrings[$cacheKey . ',1'])) { $this->substrings[$cacheKey . ',1'] = mb_substr($this->sql, $offset, $length, 'UTF-8'); } - if (!$caseSensitive && !isset($this->substrings[$cacheKey . ',0'])) { + if (!$caseSensitive && !isset($this->substrings[$cacheKey])) { $this->substrings[$cacheKey . ',0'] = mb_strtoupper($this->substrings[$cacheKey . ',1'], 'UTF-8'); } return $this->substrings[$cacheKey . ',' . (int) $caseSensitive];
$this->substrings[$cacheKey . ',0'] = mb_strtoupper($this->substrings[$cacheKey . ',1'], 'UTF-8');
}

Expand All @@ -303,16 +302,16 @@
$offset = $this->offset;
}

if ($offset + mb_strlen($string, 'UTF-8') > $this->length) {

Check warning on line 305 in src/AbstractTokenizer.php

View workflow job for this annotation

GitHub Actions / PHP 8.1-sqlite-ubuntu-latest

Escaped Mutant for Mutator "Plus": --- Original +++ New @@ @@ if ($offset === null) { $offset = $this->offset; } - if ($offset + mb_strlen($string, 'UTF-8') > $this->length) { + if ($offset - mb_strlen($string, 'UTF-8') > $this->length) { return $this->length; } $afterIndexOf = mb_strpos($this->sql, $string, $offset, 'UTF-8');

Check warning on line 305 in src/AbstractTokenizer.php

View workflow job for this annotation

GitHub Actions / PHP 8.1-sqlite-ubuntu-latest

Escaped Mutant for Mutator "GreaterThan": --- Original +++ New @@ @@ if ($offset === null) { $offset = $this->offset; } - if ($offset + mb_strlen($string, 'UTF-8') > $this->length) { + if ($offset + mb_strlen($string, 'UTF-8') >= $this->length) { return $this->length; } $afterIndexOf = mb_strpos($this->sql, $string, $offset, 'UTF-8');
return $this->length;
}

$afterIndexOf = mb_strpos($this->sql, $string, $offset, 'UTF-8');

Check warning on line 309 in src/AbstractTokenizer.php

View workflow job for this annotation

GitHub Actions / PHP 8.1-sqlite-ubuntu-latest

Escaped Mutant for Mutator "MBString": --- Original +++ New @@ @@ if ($offset + mb_strlen($string, 'UTF-8') > $this->length) { return $this->length; } - $afterIndexOf = mb_strpos($this->sql, $string, $offset, 'UTF-8'); + $afterIndexOf = strpos($this->sql, $string, $offset); if ($afterIndexOf === false) { $afterIndexOf = $this->length; } else {

if ($afterIndexOf === false) {
$afterIndexOf = $this->length;
} else {
$afterIndexOf += mb_strlen($string, 'UTF-8');

Check warning on line 314 in src/AbstractTokenizer.php

View workflow job for this annotation

GitHub Actions / PHP 8.1-sqlite-ubuntu-latest

Escaped Mutant for Mutator "MBString": --- Original +++ New @@ @@ if ($afterIndexOf === false) { $afterIndexOf = $this->length; } else { - $afterIndexOf += mb_strlen($string, 'UTF-8'); + $afterIndexOf += strlen($string); } return $afterIndexOf; }
}

return $afterIndexOf;
Expand All @@ -330,15 +329,15 @@
return false;
}

$this->addTokenFromBuffer();

Check warning on line 332 in src/AbstractTokenizer.php

View workflow job for this annotation

GitHub Actions / PHP 8-sqlite-ubuntu-latest

Escaped Mutant for Mutator "MethodCallRemoval": --- Original +++ New @@ @@ if (!$isIdentifier && !$isStringLiteral) { return false; } - $this->addTokenFromBuffer(); + $this->currentToken[] = (new SqlToken())->type($isIdentifier ? SqlToken::TYPE_IDENTIFIER : SqlToken::TYPE_STRING_LITERAL)->content(is_string($content) ? $content : $this->substring($length))->startOffset($this->offset)->endOffset($this->offset + $length); return true; }

Check warning on line 332 in src/AbstractTokenizer.php

View workflow job for this annotation

GitHub Actions / PHP 8.1-sqlite-ubuntu-latest

Escaped Mutant for Mutator "MethodCallRemoval": --- Original +++ New @@ @@ if (!$isIdentifier && !$isStringLiteral) { return false; } - $this->addTokenFromBuffer(); + $this->currentToken[] = (new SqlToken())->type($isIdentifier ? SqlToken::TYPE_IDENTIFIER : SqlToken::TYPE_STRING_LITERAL)->content(is_string($content) ? $content : $this->substring($length))->startOffset($this->offset)->endOffset($this->offset + $length); return true; }

$this->currentToken[] = (new SqlToken())
->type($isIdentifier ? SqlToken::TYPE_IDENTIFIER : SqlToken::TYPE_STRING_LITERAL)

Check warning on line 335 in src/AbstractTokenizer.php

View workflow job for this annotation

GitHub Actions / PHP 8-sqlite-ubuntu-latest

Escaped Mutant for Mutator "Ternary": --- Original +++ New @@ @@ return false; } $this->addTokenFromBuffer(); - $this->currentToken[] = (new SqlToken())->type($isIdentifier ? SqlToken::TYPE_IDENTIFIER : SqlToken::TYPE_STRING_LITERAL)->content(is_string($content) ? $content : $this->substring($length))->startOffset($this->offset)->endOffset($this->offset + $length); + $this->currentToken[] = (new SqlToken())->type($isIdentifier ? SqlToken::TYPE_STRING_LITERAL : SqlToken::TYPE_IDENTIFIER)->content(is_string($content) ? $content : $this->substring($length))->startOffset($this->offset)->endOffset($this->offset + $length); return true; } /**

Check warning on line 335 in src/AbstractTokenizer.php

View workflow job for this annotation

GitHub Actions / PHP 8.1-sqlite-ubuntu-latest

Escaped Mutant for Mutator "Ternary": --- Original +++ New @@ @@ return false; } $this->addTokenFromBuffer(); - $this->currentToken[] = (new SqlToken())->type($isIdentifier ? SqlToken::TYPE_IDENTIFIER : SqlToken::TYPE_STRING_LITERAL)->content(is_string($content) ? $content : $this->substring($length))->startOffset($this->offset)->endOffset($this->offset + $length); + $this->currentToken[] = (new SqlToken())->type($isIdentifier ? SqlToken::TYPE_STRING_LITERAL : SqlToken::TYPE_IDENTIFIER)->content(is_string($content) ? $content : $this->substring($length))->startOffset($this->offset)->endOffset($this->offset + $length); return true; } /**
->content(is_string($content) ? $content : $this->substring($length))

Check warning on line 336 in src/AbstractTokenizer.php

View workflow job for this annotation

GitHub Actions / PHP 8-sqlite-ubuntu-latest

Escaped Mutant for Mutator "Ternary": --- Original +++ New @@ @@ return false; } $this->addTokenFromBuffer(); - $this->currentToken[] = (new SqlToken())->type($isIdentifier ? SqlToken::TYPE_IDENTIFIER : SqlToken::TYPE_STRING_LITERAL)->content(is_string($content) ? $content : $this->substring($length))->startOffset($this->offset)->endOffset($this->offset + $length); + $this->currentToken[] = (new SqlToken())->type($isIdentifier ? SqlToken::TYPE_IDENTIFIER : SqlToken::TYPE_STRING_LITERAL)->content(is_string($content) ? $this->substring($length) : $content)->startOffset($this->offset)->endOffset($this->offset + $length); return true; } /**

Check warning on line 336 in src/AbstractTokenizer.php

View workflow job for this annotation

GitHub Actions / PHP 8.1-sqlite-ubuntu-latest

Escaped Mutant for Mutator "Ternary": --- Original +++ New @@ @@ return false; } $this->addTokenFromBuffer(); - $this->currentToken[] = (new SqlToken())->type($isIdentifier ? SqlToken::TYPE_IDENTIFIER : SqlToken::TYPE_STRING_LITERAL)->content(is_string($content) ? $content : $this->substring($length))->startOffset($this->offset)->endOffset($this->offset + $length); + $this->currentToken[] = (new SqlToken())->type($isIdentifier ? SqlToken::TYPE_IDENTIFIER : SqlToken::TYPE_STRING_LITERAL)->content(is_string($content) ? $this->substring($length) : $content)->startOffset($this->offset)->endOffset($this->offset + $length); return true; } /**
->startOffset($this->offset)
->endOffset($this->offset + $length);

return true;

Check warning on line 340 in src/AbstractTokenizer.php

View workflow job for this annotation

GitHub Actions / PHP 8-sqlite-ubuntu-latest

Escaped Mutant for Mutator "TrueValue": --- Original +++ New @@ @@ } $this->addTokenFromBuffer(); $this->currentToken[] = (new SqlToken())->type($isIdentifier ? SqlToken::TYPE_IDENTIFIER : SqlToken::TYPE_STRING_LITERAL)->content(is_string($content) ? $content : $this->substring($length))->startOffset($this->offset)->endOffset($this->offset + $length); - return true; + return false; } /** * Determines whether there is an operator at the current offset and adds it to the token children.

Check warning on line 340 in src/AbstractTokenizer.php

View workflow job for this annotation

GitHub Actions / PHP 8.1-sqlite-ubuntu-latest

Escaped Mutant for Mutator "TrueValue": --- Original +++ New @@ @@ } $this->addTokenFromBuffer(); $this->currentToken[] = (new SqlToken())->type($isIdentifier ? SqlToken::TYPE_IDENTIFIER : SqlToken::TYPE_STRING_LITERAL)->content(is_string($content) ? $content : $this->substring($length))->startOffset($this->offset)->endOffset($this->offset + $length); - return true; + return false; } /** * Determines whether there is an operator at the current offset and adds it to the token children.
}

/**
Expand All @@ -356,9 +355,9 @@
case '(':
$this->currentToken[] = (new SqlToken())
->type(SqlToken::TYPE_OPERATOR)
->content(is_string($content) ? $content : $this->substring($length))

Check warning on line 358 in src/AbstractTokenizer.php

View workflow job for this annotation

GitHub Actions / PHP 8-sqlite-ubuntu-latest

Escaped Mutant for Mutator "Ternary": --- Original +++ New @@ @@ $this->addTokenFromBuffer(); switch ($this->substring($length)) { case '(': - $this->currentToken[] = (new SqlToken())->type(SqlToken::TYPE_OPERATOR)->content(is_string($content) ? $content : $this->substring($length))->startOffset($this->offset)->endOffset($this->offset + $length); + $this->currentToken[] = (new SqlToken())->type(SqlToken::TYPE_OPERATOR)->content(is_string($content) ? $this->substring($length) : $content)->startOffset($this->offset)->endOffset($this->offset + $length); $this->currentToken[] = (new SqlToken())->type(SqlToken::TYPE_PARENTHESIS); if ($this->currentToken[-1] !== null) { $this->tokenStack->push($this->currentToken[-1]);
->startOffset($this->offset)
->endOffset($this->offset + $length);

Check warning on line 360 in src/AbstractTokenizer.php

View workflow job for this annotation

GitHub Actions / PHP 8-sqlite-ubuntu-latest

Escaped Mutant for Mutator "Plus": --- Original +++ New @@ @@ $this->addTokenFromBuffer(); switch ($this->substring($length)) { case '(': - $this->currentToken[] = (new SqlToken())->type(SqlToken::TYPE_OPERATOR)->content(is_string($content) ? $content : $this->substring($length))->startOffset($this->offset)->endOffset($this->offset + $length); + $this->currentToken[] = (new SqlToken())->type(SqlToken::TYPE_OPERATOR)->content(is_string($content) ? $content : $this->substring($length))->startOffset($this->offset)->endOffset($this->offset - $length); $this->currentToken[] = (new SqlToken())->type(SqlToken::TYPE_PARENTHESIS); if ($this->currentToken[-1] !== null) { $this->tokenStack->push($this->currentToken[-1]);
$this->currentToken[] = (new SqlToken())->type(SqlToken::TYPE_PARENTHESIS);

if ($this->currentToken[-1] !== null) {
Expand Down Expand Up @@ -403,7 +402,7 @@
default:
$this->currentToken[] = (new SqlToken())
->type(SqlToken::TYPE_OPERATOR)
->content(is_string($content) ? $content : $this->substring($length))

Check warning on line 405 in src/AbstractTokenizer.php

View workflow job for this annotation

GitHub Actions / PHP 8-sqlite-ubuntu-latest

Escaped Mutant for Mutator "Ternary": --- Original +++ New @@ @@ $this->currentToken = $this->tokenStack->top(); break; default: - $this->currentToken[] = (new SqlToken())->type(SqlToken::TYPE_OPERATOR)->content(is_string($content) ? $content : $this->substring($length))->startOffset($this->offset)->endOffset($this->offset + $length); + $this->currentToken[] = (new SqlToken())->type(SqlToken::TYPE_OPERATOR)->content(is_string($content) ? $this->substring($length) : $content)->startOffset($this->offset)->endOffset($this->offset + $length); break; } return true;
->startOffset($this->offset)
->endOffset($this->offset + $length);

Expand Down
1 change: 0 additions & 1 deletion src/Builder/JsonExpressionBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ public function __construct(private QueryBuilderInterface $queryBuilder)
*/
public function build(ExpressionInterface $expression, array &$params = []): string
{
/** @psalm-var mixed $value */
$value = $expression->getValue();

if ($value instanceof QueryInterface) {
Expand Down
18 changes: 0 additions & 18 deletions src/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ public function insertWithReturningPks(string $table, array $columns): bool|arra
continue;
}

/** @psalm-var mixed */
$result[$name] = $columns[$name] ?? $tableSchema?->getColumn($name)?->getDefaultValue();
}

Expand Down Expand Up @@ -72,7 +71,6 @@ public function execute(): int
{
$sql = $this->getSql();

/** @psalm-var array<string, string> $params */
$params = $this->params;

$statements = $this->splitStatements($sql, $params);
Expand All @@ -83,11 +81,8 @@ public function execute(): int

$result = 0;

/** @psalm-var array<array-key, array<array-key, string|array>> $statements */
foreach ($statements as $statement) {
[$statementSql, $statementParams] = $statement;
$statementSql = is_string($statementSql) ? $statementSql : '';
$statementParams = is_array($statementParams) ? $statementParams : [];
$this->setSql($statementSql)->bindValues($statementParams);
$result = parent::execute();
}
Expand All @@ -111,7 +106,6 @@ protected function queryInternal(int $queryMode): mixed
{
$sql = $this->getSql();

/** @psalm-var array<string, string> $params */
$params = $this->params;

$statements = $this->splitStatements($sql, $params);
Expand All @@ -122,22 +116,14 @@ protected function queryInternal(int $queryMode): mixed

[$lastStatementSql, $lastStatementParams] = array_pop($statements);

/**
* @psalm-var array<array-key, array> $statements
*/
foreach ($statements as $statement) {
/**
* @psalm-var string $statementSql
* @psalm-var array $statementParams
*/
[$statementSql, $statementParams] = $statement;
$this->setSql($statementSql)->bindValues($statementParams);
parent::execute();
}

$this->setSql($lastStatementSql)->bindValues($lastStatementParams);

/** @psalm-var string $result */
$result = parent::queryInternal($queryMode);

$this->setSql($sql)->bindValues($params);
Expand All @@ -155,8 +141,6 @@ protected function queryInternal(int $queryMode): mixed
*
* @return array|bool List of SQL statements or `false` if there's a single statement.
*
* @psalm-param array<string, string> $params
*
* @psalm-return false|list<array{0: string, 1: array}>
*/
private function splitStatements(string $sql, array $params): bool|array
Expand Down Expand Up @@ -186,8 +170,6 @@ private function splitStatements(string $sql, array $params): bool|array

/**
* Returns named bindings used in the specified statement token.
*
* @psalm-param array<string, string> $params
*/
private function extractUsedParams(SqlToken $statement, array $params): array
{
Expand Down
2 changes: 1 addition & 1 deletion src/DMLQueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function upsert(
bool|array $updateColumns,
array &$params
): string {
/** @psalm-var Constraint[] $constraints */
/** @var Constraint[] $constraints */
$constraints = [];

[$uniqueNames, $insertNames, $updateNames] = $this->prepareUpsertColumns(
Expand Down
2 changes: 0 additions & 2 deletions src/DQLQueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ public function build(QueryInterface $query, array $params = []): array
$sql = $this->buildOrderByAndLimit($sql, $orderBy, $query->getLimit(), $query->getOffset());

if (!empty($orderBy)) {
/** @psalm-var array<string|ExpressionInterface> $orderBy */
foreach ($orderBy as $expression) {
if ($expression instanceof ExpressionInterface) {
$this->buildExpression($expression, $params);
Expand All @@ -57,7 +56,6 @@ public function build(QueryInterface $query, array $params = []): array
$groupBy = $query->getGroupBy();

if (!empty($groupBy)) {
/** @psalm-var array<string|ExpressionInterface> $groupBy */
foreach ($groupBy as $expression) {
if ($expression instanceof ExpressionInterface) {
$this->buildExpression($expression, $params);
Expand Down
4 changes: 1 addition & 3 deletions src/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
final class QueryBuilder extends AbstractQueryBuilder
{
/**
* @var array Mapping from abstract column types (keys) to physical column types (values).
*
* @psalm-var string[] $typeMap
* @var string[] Mapping from abstract column types (keys) to physical column types (values).
*/
protected array $typeMap = [
SchemaInterface::TYPE_PK => 'integer PRIMARY KEY AUTOINCREMENT NOT NULL',
Expand Down
23 changes: 11 additions & 12 deletions src/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,7 @@
final class Schema extends AbstractPdoSchema
{
/**
* @var array Mapping from physical column types (keys) to abstract column types (values).
*
* @psalm-var array<array-key, string> $typeMap
* @var string[] Mapping from physical column types (keys) to abstract column types (values).
*/
private array $typeMap = [
'tinyint' => self::TYPE_TINYINT,
Expand Down Expand Up @@ -218,7 +216,6 @@ protected function loadTableForeignKeys(string $tableName): array
$primaryKey = $this->getTablePrimaryKey($table);

if ($primaryKey !== null) {
/** @psalm-var string $primaryKeyColumnName */
foreach ((array) $primaryKey->getColumnNames() as $i => $primaryKeyColumnName) {
$foreignKey[$i]['to'] = $primaryKeyColumnName;
}
Expand Down Expand Up @@ -303,7 +300,6 @@ protected function loadTableChecks(string $tableName): array

$sql = ($sql === false || $sql === null) ? '' : (string) $sql;

/** @psalm-var SqlToken[]|SqlToken[][]|SqlToken[][][] $code */
$code = (new SqlTokenizer($sql))->tokenize();
$pattern = (new SqlTokenizer('any CREATE any TABLE any()'))->tokenize();
$result = [];
Expand Down Expand Up @@ -363,7 +359,6 @@ protected function loadTableDefaultValues(string $tableName): array
*/
protected function findColumns(TableSchemaInterface $table): bool
{
/** @psalm-var ColumnInfo[] $columns */
$columns = $this->getPragmaTableInfo($table->getName());
$jsonColumns = $this->getJsonColumns($table);

Expand Down Expand Up @@ -444,7 +439,6 @@ public function findUniqueIndexes(TableSchemaInterface $table): array

foreach ($indexList as $index) {
$indexName = $index['name'];
/** @psalm-var IndexInfo[] $indexInfo */
$indexInfo = $this->getPragmaIndexInfo($index['name']);

if ($index['unique']) {
Expand Down Expand Up @@ -551,13 +545,16 @@ private function normalizeDefaultValue(string|null $defaultValue, ColumnSchemaIn
* @throws Throwable
*
* @return array The table columns info.
*
* @psalm-return ColumnInfo[] $tableColumns;
*/
private function loadTableColumnsInfo(string $tableName): array
{
$tableColumns = $this->getPragmaTableInfo($tableName);
/** @psalm-var ColumnInfo[] $tableColumns */
$tableColumns = $this->normalizeRowKeyCase($tableColumns, true);

/** @psalm-var ColumnInfo[] */
return DbArrayHelper::index($tableColumns, 'cid');
}

Expand Down Expand Up @@ -585,7 +582,6 @@ private function loadTableConstraints(string $tableName, string $returnType): Co
];

foreach ($indexes as $index) {
/** @psalm-var IndexInfo[] $columns */
$columns = $this->getPragmaIndexInfo($index['name']);

if ($index['origin'] === 'pk') {
Expand All @@ -611,8 +607,6 @@ private function loadTableConstraints(string $tableName, string $returnType): Co
* Extra check for PK in case of `INTEGER PRIMARY KEY` with ROWID.
*
* @link https://www.sqlite.org/lang_createtable.html#primkeyconst
*
* @psalm-var ColumnInfo[] $tableColumns
*/
$tableColumns = $this->loadTableColumnsInfo($tableName);

Expand Down Expand Up @@ -659,16 +653,18 @@ private function getPragmaForeignKeyList(string $tableName): array
* @throws Exception
* @throws InvalidConfigException
* @throws Throwable
*
* @psalm-return IndexInfo[]
*/
private function getPragmaIndexInfo(string $name): array
{
$column = $this->db
->createCommand('PRAGMA INDEX_INFO(' . (string) $this->db->getQuoter()->quoteValue($name) . ')')
->queryAll();
/** @psalm-var IndexInfo[] $column */
$column = $this->normalizeRowKeyCase($column, true);
DbArrayHelper::multisort($column, 'seqno');

/** @psalm-var IndexInfo[] $column */
return $column;
}

Expand All @@ -688,9 +684,12 @@ private function getPragmaIndexList(string $tableName): array
* @throws Exception
* @throws InvalidConfigException
* @throws Throwable
*
* @psalm-return ColumnInfo[]
*/
private function getPragmaTableInfo(string $tableName): array
{
/** @psalm-var ColumnInfo[] */
return $this->db->createCommand(
'PRAGMA TABLE_INFO(' . $this->db->getQuoter()->quoteSimpleTableName($tableName) . ')'
)->queryAll();
Expand All @@ -703,7 +702,7 @@ private function getPragmaTableInfo(string $tableName): array
*/
protected function findViewNames(string $schema = ''): array
{
/** @psalm-var string[][] $views */
/** @var string[][] $views */
$views = $this->db->createCommand(
<<<SQL
SELECT name as view FROM sqlite_master WHERE type = 'view' AND name NOT LIKE 'sqlite_%'
Expand Down