Skip to content

Commit

Permalink
Merge pull request doctrine#8957 from derrabus/remove/connection-helper
Browse files Browse the repository at this point in the history
Only wire ConnectionHelper if it's available
  • Loading branch information
greg0ire authored Aug 25, 2021
2 parents b345488 + dc6ed87 commit a06bbaf
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 11 deletions.
13 changes: 7 additions & 6 deletions lib/Doctrine/ORM/Tools/Console/ConsoleRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,13 @@ final class ConsoleRunner
*/
public static function createHelperSet(EntityManagerInterface $entityManager): HelperSet
{
return new HelperSet(
[
'db' => new DBALConsole\Helper\ConnectionHelper($entityManager->getConnection()),
'em' => new EntityManagerHelper($entityManager),
]
);
$helpers = ['em' => new EntityManagerHelper($entityManager)];

if (class_exists(DBALConsole\Helper\ConnectionHelper::class)) {
$helpers['db'] = new DBALConsole\Helper\ConnectionHelper($entityManager->getConnection());
}

return new HelperSet($helpers);
}

/**
Expand Down
8 changes: 8 additions & 0 deletions phpstan-dbal3.neon
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,11 @@ parameters:
ignoreErrors:
# deprecations from doctrine/dbal:3.x
- '/^Call to an undefined method Doctrine\\DBAL\\Platforms\\AbstractPlatform::getGuidExpression\(\).$/'

# Fallback logic for DBAL 2
-
message: '/HelperSet constructor expects/'
path: lib/Doctrine/ORM/Tools/Console/ConsoleRunner.php
-
message: '/Application::add\(\) expects Symfony\\Component\\Console\\Command\\Command/'
path: lib/Doctrine/ORM/Tools/Console/ConsoleRunner.php
6 changes: 1 addition & 5 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,6 @@
</DeprecatedClass>
<PropertyTypeCoercion occurrences="1">
<code>$resultSetMapping</code>
<code>$resultSetMapping</code>
</PropertyTypeCoercion>
<ReferenceConstraintViolation occurrences="1">
<code>return $rowData;</code>
Expand Down Expand Up @@ -3560,14 +3559,11 @@
</MissingReturnType>
</file>
<file src="lib/Doctrine/ORM/Tools/Console/ConsoleRunner.php">
<DeprecatedClass occurrences="7">
<code>DBALConsole\Command\ImportCommand::class</code>
<DeprecatedClass occurrences="4">
<code>Versions::getVersion('doctrine/orm')</code>
<code>new Command\ConvertDoctrine1SchemaCommand()</code>
<code>new Command\GenerateEntitiesCommand($entityManagerProvider)</code>
<code>new Command\GenerateRepositoriesCommand($entityManagerProvider)</code>
<code>new DBALConsole\Command\ImportCommand()</code>
<code>new DBALConsole\Helper\ConnectionHelper($entityManager-&gt;getConnection())</code>
</DeprecatedClass>
</file>
<file src="lib/Doctrine/ORM/Tools/DebugUnitOfWorkListener.php">
Expand Down
7 changes: 7 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@
</ignoreFiles>
</projectFiles>
<issueHandlers>
<DeprecatedClass>
<errorLevel type="suppress">
<!-- DBAL 2 compatibility -->
<referencedClass name="Doctrine\DBAL\Tools\Console\Command\ImportCommand"/>
<referencedClass name="Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper"/>
</errorLevel>
</DeprecatedClass>
<DeprecatedMethod>
<errorLevel type="suppress">
<!-- We're calling the deprecated method for BC here. -->
Expand Down

0 comments on commit a06bbaf

Please sign in to comment.