Skip to content

Commit 09625b6

Browse files
authored
Merge pull request #5280 from morozov/schema-manager-abstract
Declare abstract AbstractSchemaManager methods as such
2 parents bf171dd + 3b759ec commit 09625b6

8 files changed

+15
-130
lines changed

UPGRADE.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,17 @@ awareness about deprecated code.
88

99
# Upgrade to 4.0
1010

11+
## Abstract methods in the `AbstractSchemaManager` class have been declared as `abstract`
12+
13+
The following abstract methods in the `AbstractSchemaManager` class have been declared as `abstract`:
14+
15+
- `selectDatabaseColumns()`,
16+
- `selectDatabaseIndexes()`,
17+
- `selectDatabaseForeignKeys()`,
18+
- `getDatabaseTableOptions()`.
19+
20+
Every non-abstract schema manager class must implement them in order to satisfy the API.
21+
1122
# BC Break: The number of affected rows is returned as `int|string`
1223

1324
The signatures of the methods returning the number of affected rows changed as returning `int|string` instead of `int`.

src/Schema/AbstractSchemaManager.php

Lines changed: 4 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -219,23 +219,6 @@ protected function filterAssetNames(array $assetNames): array
219219
* @throws Exception
220220
*/
221221
public function listTables(): array
222-
{
223-
$tableNames = $this->listTableNames();
224-
225-
$tables = [];
226-
foreach ($tableNames as $tableName) {
227-
$tables[] = $this->listTableDetails($tableName);
228-
}
229-
230-
return $tables;
231-
}
232-
233-
/**
234-
* @return list<Table>
235-
*
236-
* @throws Exception
237-
*/
238-
protected function doListTables(): array
239222
{
240223
$currentDatabase = $this->_conn->getDatabase();
241224

@@ -282,23 +265,6 @@ protected function doListTables(): array
282265
* @throws Exception
283266
*/
284267
public function listTableDetails(string $name): Table
285-
{
286-
$columns = $this->listTableColumns($name);
287-
$foreignKeys = [];
288-
289-
if ($this->_platform->supportsForeignKeyConstraints()) {
290-
$foreignKeys = $this->listTableForeignKeys($name);
291-
}
292-
293-
$indexes = $this->listTableIndexes($name);
294-
295-
return new Table($name, $columns, $indexes, [], $foreignKeys, []);
296-
}
297-
298-
/**
299-
* @throws Exception
300-
*/
301-
protected function doListTableDetails(string $name): Table
302268
{
303269
$currentDatabase = $this->_conn->getDatabase();
304270

@@ -353,35 +319,24 @@ protected function normalizeName(string $name): string
353319
* the selection to this table.
354320
*
355321
* @throws Exception
356-
*
357-
* @abstract
358322
*/
359-
protected function selectDatabaseColumns(string $databaseName, ?string $tableName = null): Result
360-
{
361-
throw NotSupported::new(__METHOD__);
362-
}
323+
abstract protected function selectDatabaseColumns(string $databaseName, ?string $tableName = null): Result;
363324

364325
/**
365326
* Selects index definitions of the tables in the specified database. If the table name is specified, narrows down
366327
* the selection to this table.
367328
*
368329
* @throws Exception
369330
*/
370-
protected function selectDatabaseIndexes(string $databaseName, ?string $tableName = null): Result
371-
{
372-
throw NotSupported::new(__METHOD__);
373-
}
331+
abstract protected function selectDatabaseIndexes(string $databaseName, ?string $tableName = null): Result;
374332

375333
/**
376334
* Selects foreign key definitions of the tables in the specified database. If the table name is specified,
377335
* narrows down the selection to this table.
378336
*
379337
* @throws Exception
380338
*/
381-
protected function selectDatabaseForeignKeys(string $databaseName, ?string $tableName = null): Result
382-
{
383-
throw NotSupported::new(__METHOD__);
384-
}
339+
abstract protected function selectDatabaseForeignKeys(string $databaseName, ?string $tableName = null): Result;
385340

386341
/**
387342
* Returns table options for the tables in the specified database. If the table name is specified, narrows down
@@ -391,10 +346,7 @@ protected function selectDatabaseForeignKeys(string $databaseName, ?string $tabl
391346
*
392347
* @throws Exception
393348
*/
394-
protected function getDatabaseTableOptions(string $databaseName, ?string $tableName = null): array
395-
{
396-
throw NotSupported::new(__METHOD__);
397-
}
349+
abstract protected function getDatabaseTableOptions(string $databaseName, ?string $tableName = null): array;
398350

399351
/**
400352
* Lists the views this connection has.

src/Schema/DB2SchemaManager.php

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,6 @@ public function listTableNames(): array
4343
return $this->filterAssetNames($this->_getPortableTablesList($tables));
4444
}
4545

46-
/**
47-
* {@inheritDoc}
48-
*/
49-
public function listTables(): array
50-
{
51-
return $this->doListTables();
52-
}
53-
54-
public function listTableDetails(string $name): Table
55-
{
56-
return $this->doListTableDetails($name);
57-
}
58-
5946
/**
6047
* {@inheritdoc}
6148
*

src/Schema/MySQLSchemaManager.php

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,6 @@ class MySQLSchemaManager extends AbstractSchemaManager
5050
"''" => "'",
5151
];
5252

53-
/**
54-
* {@inheritDoc}
55-
*/
56-
public function listTables(): array
57-
{
58-
return $this->doListTables();
59-
}
60-
61-
public function listTableDetails(string $name): Table
62-
{
63-
return $this->doListTableDetails($name);
64-
}
65-
6653
/**
6754
* {@inheritdoc}
6855
*/

src/Schema/OracleSchemaManager.php

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,6 @@
3131
*/
3232
class OracleSchemaManager extends AbstractSchemaManager
3333
{
34-
/**
35-
* {@inheritDoc}
36-
*/
37-
public function listTables(): array
38-
{
39-
return $this->doListTables();
40-
}
41-
42-
public function listTableDetails(string $name): Table
43-
{
44-
return $this->doListTableDetails($name);
45-
}
46-
4734
/**
4835
* {@inheritdoc}
4936
*/

src/Schema/PostgreSQLSchemaManager.php

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,6 @@ class PostgreSQLSchemaManager extends AbstractSchemaManager
3636
{
3737
private ?string $currentSchema = null;
3838

39-
/**
40-
* {@inheritDoc}
41-
*/
42-
public function listTables(): array
43-
{
44-
return $this->doListTables();
45-
}
46-
47-
public function listTableDetails(string $name): Table
48-
{
49-
return $this->doListTableDetails($name);
50-
}
51-
5239
/**
5340
* {@inheritDoc}
5441
*/

src/Schema/SQLServerSchemaManager.php

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,6 @@ class SQLServerSchemaManager extends AbstractSchemaManager
3434
{
3535
private ?string $databaseCollation = null;
3636

37-
/**
38-
* {@inheritDoc}
39-
*/
40-
public function listTables(): array
41-
{
42-
return $this->doListTables();
43-
}
44-
45-
public function listTableDetails(string $name): Table
46-
{
47-
return $this->doListTableDetails($name);
48-
}
49-
5037
/**
5138
* {@inheritDoc}
5239
*/

src/Schema/SqliteSchemaManager.php

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,6 @@
4141
*/
4242
class SqliteSchemaManager extends AbstractSchemaManager
4343
{
44-
/**
45-
* {@inheritDoc}
46-
*/
47-
public function listTables(): array
48-
{
49-
return $this->doListTables();
50-
}
51-
52-
public function listTableDetails(string $name): Table
53-
{
54-
return $this->doListTableDetails($name);
55-
}
56-
5744
public function renameTable(string $name, string $newName): void
5845
{
5946
$tableDiff = new TableDiff($name);

0 commit comments

Comments
 (0)