Skip to content

Commit c5b817b

Browse files
zerkmsIvan Kurnosov
authored and
Ivan Kurnosov
committed
Make AbstractSchemaManager covariant to its template argument
1 parent cbc2e57 commit c5b817b

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

src/Schema/AbstractSchemaManager.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
* Base class for schema managers. Schema managers are used to inspect and/or
2424
* modify the database schema/structure.
2525
*
26-
* @template T of AbstractPlatform
26+
* @template-covariant T of AbstractPlatform
2727
*/
2828
abstract class AbstractSchemaManager
2929
{
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Doctrine\StaticAnalysis\DBAL;
6+
7+
use Doctrine\DBAL\Connection;
8+
use Doctrine\DBAL\Driver\PDO\PgSQL\Driver;
9+
use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
10+
use Doctrine\DBAL\Schema\AbstractSchemaManager;
11+
use Doctrine\DBAL\Schema\PostgreSQLSchemaManager;
12+
use Exception;
13+
14+
function createSchemaManager(): AbstractSchemaManager
15+
{
16+
return new PostgreSQLSchemaManager(new Connection([], new Driver()), new PostgreSQLPlatform());
17+
}
18+
19+
$schemaManager = createSchemaManager();
20+
21+
if (!$schemaManager instanceof PostgreSQLSchemaManager) {
22+
throw new Exception('should not happen');
23+
}

0 commit comments

Comments
 (0)