diff --git a/CHANGELOG.md b/CHANGELOG.md index bc6c2a8fc..43bd6d535 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ - Enh #330: Create instance of `ArrayParser` directly (@Tigrov) - Bug #331: Exclude from index column names fields specified in `INCLUDE` clause (@Tigrov) - Enh #334: Minor `DDLQueryBuilder` refactoring (@Tigrov) +- Enh #333: Resolve deprecated methods (@Tigrov) ## 1.2.0 November 12, 2023 diff --git a/src/Schema.php b/src/Schema.php index dedffdfb9..8a39802cd 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_unique; use function array_values; @@ -393,7 +395,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 = []; @@ -551,7 +553,7 @@ protected function findConstraints(TableSchemaInterface $table): void foreach ($rows as $constraint) { /** @psalm-var FindConstraintArray $constraint */ - $constraint = $this->normalizeRowKeyCase($constraint, false); + $constraint = array_change_key_case($constraint); if ($constraint['foreign_table_schema'] !== $this->defaultSchema) { $foreignTable = $constraint['foreign_table_schema'] . '.' . $constraint['foreign_table_name']; @@ -645,7 +647,7 @@ public function findUniqueIndexes(TableSchemaInterface $table): array /** @psalm-var array{indexname: string, columnname: string} $row */ foreach ($this->getUniqueIndexInformation($table) as $row) { /** @psalm-var array{indexname: string, columnname: string} $row */ - $row = $this->normalizeRowKeyCase($row, false); + $row = array_change_key_case($row); $column = $row['columnname']; @@ -759,7 +761,7 @@ protected function findColumns(TableSchemaInterface $table): bool /** @psalm-var ColumnArray $info */ foreach ($columns as $info) { /** @psalm-var ColumnArray $info */ - $info = $this->normalizeRowKeyCase($info, false); + $info = array_change_key_case($info); /** @psalm-var ColumnSchema $column */ $column = $this->loadColumnSchema($info); @@ -975,7 +977,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 = [ @@ -1060,6 +1062,8 @@ private function createColumnSchema(string $name): ColumnSchema * @param string $name The table name. * * @return array The cache key. + * + * @psalm-suppress DeprecatedMethod */ protected function getCacheKey(string $name): array { diff --git a/tests/SchemaTest.php b/tests/SchemaTest.php index 2d852a14b..e68ab4c36 100644 --- a/tests/SchemaTest.php +++ b/tests/SchemaTest.php @@ -520,12 +520,12 @@ public function testCustomTypeInNonDefaultSchema() public function testNotConnectionPDO(): void { $db = $this->createMock(ConnectionInterface::class); - $schema = new Schema($db, DbHelper::getSchemaCache(), 'system'); + $schema = new Schema($db, DbHelper::getSchemaCache()); $this->expectException(NotSupportedException::class); $this->expectExceptionMessage('Only PDO connections are supported.'); - $schema->refreshTableSchema('customer'); + $schema->refresh(); } public function testDomainType(): void