Skip to content

Commit 67a21fa

Browse files
Tigrovvjik
andauthored
Resolve deprecated methods (#253)
* Resolve deprecated methods * Add line to CHANGELOG.md [skip ci] * Fix test * Fix psalm issues --------- Co-authored-by: Sergei Predvoditelev <[email protected]>
1 parent 1ef61ef commit 67a21fa

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- Enh #251: Allow to use `DMLQueryBuilderInterface::batchInsert()` method with empty columns (@Tigrov)
88
- Bug #238: Fix execution `Query` without table(s) to select from (@Tigrov)
99
- Bug #254: Fix, table sequence name should be null if sequence name not found (@Tigrov)
10+
- Enh #253: Resolve deprecated methods (@Tigrov)
1011

1112
## 1.2.0 November 12, 2023
1213

src/Schema.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
use Yiisoft\Db\Schema\ColumnSchemaInterface;
2222
use Yiisoft\Db\Schema\TableSchemaInterface;
2323

24+
use function array_change_key_case;
25+
use function array_map;
2426
use function array_merge;
2527
use function array_reverse;
2628
use function implode;
@@ -208,7 +210,7 @@ protected function findTableNames(string $schema = ''): array
208210
/** @psalm-var string[][] $rows */
209211
foreach ($rows as $row) {
210212
/** @psalm-var string[] $row */
211-
$row = $this->normalizeRowKeyCase($row, false);
213+
$row = array_change_key_case($row);
212214
$names[] = $row['table_name'];
213215
}
214216

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

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

293295
$result = [];
@@ -406,7 +408,7 @@ protected function findColumns(TableSchemaInterface $table): bool
406408
/** @psalm-var string[][] $columns */
407409
foreach ($columns as $column) {
408410
/** @psalm-var ColumnInfoArray $column */
409-
$column = $this->normalizeRowKeyCase($column, false);
411+
$column = array_change_key_case($column);
410412

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

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

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

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

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

721723
$result = [
@@ -805,6 +807,8 @@ protected function findViewNames(string $schema = ''): array
805807
* @param string $name The table name.
806808
*
807809
* @return array The cache key.
810+
*
811+
* @psalm-suppress DeprecatedMethod
808812
*/
809813
protected function getCacheKey(string $name): array
810814
{

tests/SchemaTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,6 @@ public function testNotConnectionPDO(): void
293293
$this->expectException(NotSupportedException::class);
294294
$this->expectExceptionMessage('Only PDO connections are supported.');
295295

296-
$schema->refreshTableSchema('customer');
296+
$schema->refresh();
297297
}
298298
}

0 commit comments

Comments
 (0)