Skip to content

Commit

Permalink
Make AbstractSchemaManager covariant to its template argument
Browse files Browse the repository at this point in the history
  • Loading branch information
zerkms authored and Ivan Kurnosov committed Aug 1, 2024
1 parent 98c5b03 commit f5d3777
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Schema/AbstractSchemaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
* Base class for schema managers. Schema managers are used to inspect and/or
* modify the database schema/structure.
*
* @template T of AbstractPlatform
* @template-covariant T of AbstractPlatform
*/
abstract class AbstractSchemaManager
{
Expand Down
18 changes: 18 additions & 0 deletions static-analysis/abstract-schema-manager-covariant-template.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

declare(strict_types=1);

namespace Doctrine\StaticAnalysis\DBAL;

use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver\PDO\PgSQL\Driver;
use Doctrine\DBAL\Schema\DefaultSchemaManagerFactory;
use Doctrine\DBAL\Schema\PostgreSQLSchemaManager;
use Exception;

$smf = new DefaultSchemaManagerFactory();
$schemaManager = $smf->createSchemaManager(new Connection([], new Driver()));

if (!$schemaManager instanceof PostgreSQLSchemaManager) {
throw new Exception('should not happen');
}

0 comments on commit f5d3777

Please sign in to comment.