Skip to content

Commit

Permalink
Resolve deprecated methods (#253)
Browse files Browse the repository at this point in the history
* Resolve deprecated methods

* Add line to CHANGELOG.md [skip ci]

* Fix test

* Fix psalm issues

---------

Co-authored-by: Sergei Predvoditelev <[email protected]>
  • Loading branch information
Tigrov and vjik authored Feb 10, 2024
1 parent 1ef61ef commit 67a21fa
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- Enh #251: Allow to use `DMLQueryBuilderInterface::batchInsert()` method with empty columns (@Tigrov)
- Bug #238: Fix execution `Query` without table(s) to select from (@Tigrov)
- Bug #254: Fix, table sequence name should be null if sequence name not found (@Tigrov)
- Enh #253: Resolve deprecated methods (@Tigrov)

## 1.2.0 November 12, 2023

Expand Down
14 changes: 9 additions & 5 deletions src/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
use Yiisoft\Db\Schema\ColumnSchemaInterface;
use Yiisoft\Db\Schema\TableSchemaInterface;

use function array_change_key_case;
use function array_map;
use function array_merge;
use function array_reverse;
use function implode;
Expand Down Expand Up @@ -208,7 +210,7 @@ protected function findTableNames(string $schema = ''): array
/** @psalm-var string[][] $rows */
foreach ($rows as $row) {
/** @psalm-var string[] $row */
$row = $this->normalizeRowKeyCase($row, false);
$row = array_change_key_case($row);
$names[] = $row['table_name'];
}

Expand Down Expand Up @@ -287,7 +289,7 @@ protected function loadTableIndexes(string $tableName): array
])->queryAll();

/** @psalm-var array[] $indexes */
$indexes = $this->normalizeRowKeyCase($indexes, true);
$indexes = array_map('array_change_key_case', $indexes);
$indexes = DbArrayHelper::index($indexes, null, ['name']);

$result = [];
Expand Down Expand Up @@ -406,7 +408,7 @@ protected function findColumns(TableSchemaInterface $table): bool
/** @psalm-var string[][] $columns */
foreach ($columns as $column) {
/** @psalm-var ColumnInfoArray $column */
$column = $this->normalizeRowKeyCase($column, false);
$column = array_change_key_case($column);

$c = $this->createColumnSchema($column);

Expand Down Expand Up @@ -554,7 +556,7 @@ protected function findConstraints(TableSchemaInterface $table): void

foreach ($rows as $row) {
/** @psalm-var string[] $row */
$row = $this->normalizeRowKeyCase($row, false);
$row = array_change_key_case($row);

if ($row['constraint_type'] === 'P') {
$table->getColumns()[$row['column_name']]->primaryKey(true);
Expand Down Expand Up @@ -715,7 +717,7 @@ private function loadTableConstraints(string $tableName, string $returnType): mi
])->queryAll();

/** @psalm-var array[] $constraints */
$constraints = $this->normalizeRowKeyCase($constraints, true);
$constraints = array_map('array_change_key_case', $constraints);
$constraints = DbArrayHelper::index($constraints, null, ['type', 'name']);

$result = [
Expand Down Expand Up @@ -805,6 +807,8 @@ protected function findViewNames(string $schema = ''): array
* @param string $name The table name.
*
* @return array The cache key.
*
* @psalm-suppress DeprecatedMethod
*/
protected function getCacheKey(string $name): array
{
Expand Down
2 changes: 1 addition & 1 deletion tests/SchemaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,6 @@ public function testNotConnectionPDO(): void
$this->expectException(NotSupportedException::class);
$this->expectExceptionMessage('Only PDO connections are supported.');

$schema->refreshTableSchema('customer');
$schema->refresh();
}
}

0 comments on commit 67a21fa

Please sign in to comment.