From 1a90f52cb6ac0c7f233625350db5e7dee181284a Mon Sep 17 00:00:00 2001 From: Tigrov Date: Mon, 29 Jan 2024 11:32:09 +0700 Subject: [PATCH 1/4] Resolve deprecated methods --- src/Schema.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Schema.php b/src/Schema.php index cfdd883..98a0941 100644 --- a/src/Schema.php +++ b/src/Schema.php @@ -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; @@ -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']; } @@ -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 = []; @@ -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); @@ -553,7 +555,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); @@ -714,7 +716,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 = [ @@ -807,7 +809,7 @@ protected function findViewNames(string $schema = ''): array */ protected function getCacheKey(string $name): array { - return array_merge([self::class], $this->generateCacheKey(), [$this->getRawTableName($name)]); + return array_merge([self::class], $this->generateCacheKey(), [$this->db->getQuoter()->getRawTableName($name)]); } /** From b722b74dd4b6da5e7e98783c67fd6f677ae5933d Mon Sep 17 00:00:00 2001 From: Tigrov Date: Tue, 30 Jan 2024 15:43:18 +0700 Subject: [PATCH 2/4] Add line to CHANGELOG.md [skip ci] --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b8321f5..ba53eac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - Bug #250: Fix `Command::insertWithReturningPks()` method for table without primary keys (@Tigrov) - Enh #251: Allow to use `DMLQueryBuilderInterface::batchInsert()` method with empty columns (@Tigrov) - Bug #238: Fix execution `Query` without table(s) to select from (@Tigrov) +- Enh #253: Resolve deprecated methods (@Tigrov) ## 1.2.0 November 12, 2023 From 522b0c6dad225a3fde23dcb50e3a44cb315f4faf Mon Sep 17 00:00:00 2001 From: Tigrov Date: Thu, 1 Feb 2024 18:11:15 +0700 Subject: [PATCH 3/4] Fix test --- tests/SchemaTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/SchemaTest.php b/tests/SchemaTest.php index b29ef24..2fb6f0f 100644 --- a/tests/SchemaTest.php +++ b/tests/SchemaTest.php @@ -293,6 +293,6 @@ public function testNotConnectionPDO(): void $this->expectException(NotSupportedException::class); $this->expectExceptionMessage('Only PDO connections are supported.'); - $schema->refreshTableSchema('customer'); + $schema->refresh(); } } From e7f78c810c8e790e8986d6edf0ff13951de18930 Mon Sep 17 00:00:00 2001 From: Sergei Tigrov Date: Mon, 5 Feb 2024 01:17:41 +0700 Subject: [PATCH 4/4] Fix psalm issues --- src/Schema.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Schema.php b/src/Schema.php index bc3142a..14b9664 100644 --- a/src/Schema.php +++ b/src/Schema.php @@ -807,10 +807,12 @@ 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 { - return array_merge([self::class], $this->generateCacheKey(), [$this->db->getQuoter()->getRawTableName($name)]); + return array_merge([self::class], $this->generateCacheKey(), [$this->getRawTableName($name)]); } /**