Skip to content

Commit

Permalink
Resolve deprecated methods (#318)
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 9fae32a commit 72531d4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- Enh #312: Change property `Schema::$typeMap` to constant `Schema::TYPE_MAP` (@Tigrov)
- Bug #314: Fix `Command::insertWithReturningPks()` method for empty values (@Tigrov)
- Enh #319: Minor refactoring of `DDLQueryBuilder` and `Schema` (@Tigrov)
- Enh #318: Resolve deprecated methods (@Tigrov)

## 1.1.0 November 12, 2023

Expand Down
9 changes: 6 additions & 3 deletions src/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
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_values;
Expand Down Expand Up @@ -230,7 +231,7 @@ protected function findColumns(TableSchemaInterface $table): bool

/** @psalm-var ColumnInfoArray $info */
foreach ($columns as $info) {
$info = $this->normalizeRowKeyCase($info, false);
$info = array_change_key_case($info);

$info['extra_default_value'] = $columnsExtra[(string) $info['field']] ?? '';

Expand Down Expand Up @@ -409,6 +410,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 Expand Up @@ -675,7 +678,7 @@ private function loadTableConstraints(string $tableName, string $returnType): ar
])->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 @@ -790,7 +793,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
2 changes: 1 addition & 1 deletion tests/SchemaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ public function testNotConnectionPDO(): void
$this->expectException(NotSupportedException::class);
$this->expectExceptionMessage('Only PDO connections are supported.');

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

public function testInsertDefaultValues()
Expand Down

0 comments on commit 72531d4

Please sign in to comment.