Skip to content

Commit 309f5f4

Browse files
authored
Merge pull request #1754 from doctrine/2.11.x-merge-up-into-2.12.x_anhFL93S
2 parents 99fcc69 + 4927253 commit 309f5f4

21 files changed

+41
-115
lines changed

Command/CreateDatabaseDoctrineCommand.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
use Throwable;
1111

1212
use function in_array;
13-
use function method_exists;
1413
use function sprintf;
1514

1615
/**
@@ -62,13 +61,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int
6261
}
6362

6463
// Need to get rid of _every_ occurrence of dbname from connection configuration and we have already extracted all relevant info from url
64+
/** @psalm-suppress InvalidArrayOffset Need to be compatible with DBAL < 4, which still has `$params['url']` */
6565
unset($params['dbname'], $params['path'], $params['url']);
6666

67-
$tmpConnection = DriverManager::getConnection($params, $connection->getConfiguration());
68-
69-
$schemaManager = method_exists($tmpConnection, 'createSchemaManager')
70-
? $tmpConnection->createSchemaManager()
71-
: $tmpConnection->getSchemaManager();
67+
$tmpConnection = DriverManager::getConnection($params, $connection->getConfiguration());
68+
$schemaManager = $tmpConnection->createSchemaManager();
7269
$shouldNotCreateDatabase = $ifNotExists && in_array($name, $schemaManager->listDatabases());
7370

7471
// Only quote if we don't have a path

Command/DoctrineCommand.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ public function __construct(ManagerRegistry $doctrine)
2929
* get a doctrine entity generator
3030
*
3131
* @return EntityGenerator
32+
*
33+
* @psalm-suppress UndefinedDocblockClass ORM < 3 specific
3234
*/
3335
protected function getEntityGenerator()
3436
{

Command/DropDatabaseDoctrineCommand.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace Doctrine\Bundle\DoctrineBundle\Command;
44

55
use Doctrine\DBAL\DriverManager;
6-
use Doctrine\DBAL\Schema\SqliteSchemaManager;
6+
use Doctrine\DBAL\Schema\SQLiteSchemaManager;
77
use InvalidArgumentException;
88
use Symfony\Component\Console\Input\InputInterface;
99
use Symfony\Component\Console\Input\InputOption;
@@ -12,7 +12,6 @@
1212

1313
use function file_exists;
1414
use function in_array;
15-
use function method_exists;
1615
use function sprintf;
1716
use function unlink;
1817

@@ -73,6 +72,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
7372
throw new InvalidArgumentException("Connection does not contain a 'path' or 'dbname' parameter and cannot be dropped.");
7473
}
7574

75+
/** @psalm-suppress InvalidArrayOffset Need to be compatible with DBAL < 4, which still has `$params['url']` */
7676
unset($params['dbname'], $params['url']);
7777

7878
if (! $input->getOption('force')) {
@@ -89,9 +89,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
8989
// as some vendors do not allow dropping the database connected to.
9090
$connection->close();
9191
$connection = DriverManager::getConnection($params, $connection->getConfiguration());
92-
$schemaManager = method_exists($connection, 'createSchemaManager')
93-
? $connection->createSchemaManager()
94-
: $connection->getSchemaManager();
92+
$schemaManager = $connection->createSchemaManager();
9593
$shouldDropDatabase = ! $ifExists || in_array($name, $schemaManager->listDatabases());
9694

9795
// Only quote if we don't have a path
@@ -101,7 +99,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
10199

102100
try {
103101
if ($shouldDropDatabase) {
104-
if ($schemaManager instanceof SqliteSchemaManager) {
102+
/** @psalm-suppress TypeDoesNotContainType Bogus error, Doctrine\DBAL\Schema\AbstractSchemaManager<Doctrine\DBAL\Platforms\AbstractPlatform> does contain Doctrine\DBAL\Schema\SQLiteSchemaManager */
103+
if ($schemaManager instanceof SQLiteSchemaManager) {
105104
// dropDatabase() is deprecated for Sqlite
106105
$connection->close();
107106
if (file_exists($name)) {

Command/Proxy/ConvertMappingDoctrineCommand.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
* formats.
1616
*
1717
* @deprecated use Doctrine\ORM\Tools\Console\Command\ConvertMappingCommand instead
18+
*
19+
* @psalm-suppress UndefinedClass ORM < 3
1820
*/
1921
class ConvertMappingDoctrineCommand extends ConvertMappingCommand
2022
{

Command/Proxy/DoctrineCommandHelper.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public static function setApplicationEntityManager(Application $application, $em
2828
$em = $application->getKernel()->getContainer()->get('doctrine')->getManager($emName);
2929
assert($em instanceof EntityManagerInterface);
3030
$helperSet = $application->getHelperSet();
31+
/** @psalm-suppress InvalidArgument ORM < 3 specific */
3132
$helperSet->set(new EntityManagerHelper($em), 'em');
3233

3334
trigger_deprecation(

Command/Proxy/EnsureProductionSettingsDoctrineCommand.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
* Ensure the Doctrine ORM is configured properly for a production environment.
1010
*
1111
* @deprecated use Doctrine\ORM\Tools\Console\Command\EnsureProductionSettingsCommand instead
12+
*
13+
* @psalm-suppress UndefinedClass ORM < 3 specific
1214
*/
1315
class EnsureProductionSettingsDoctrineCommand extends EnsureProductionSettingsCommand
1416
{

ConnectionFactory.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ public function createConnection(array $params, ?Configuration $config = null, ?
118118
$connection = DriverManager::getConnection(...array_merge([$params, $config], $eventManager ? [$eventManager] : []));
119119
$params = $this->addDatabaseSuffix(array_merge($connection->getParams(), $overriddenOptions));
120120
$driver = $connection->getDriver();
121-
$platform = $driver->getDatabasePlatform(
121+
/** @psalm-suppress InvalidScalarArgument Bogus error, StaticServerVersionProvider implements Doctrine\DBAL\ServerVersionProvider */
122+
$platform = $driver->getDatabasePlatform(
122123
...(class_exists(StaticServerVersionProvider::class) ? [new StaticServerVersionProvider($params['serverVersion'] ?? '')] : []),
123124
);
124125

@@ -250,6 +251,7 @@ private function addDatabaseSuffix(array $params): array
250251
*/
251252
private function parseDatabaseUrl(array $params): array
252253
{
254+
/** @psalm-suppress InvalidArrayOffset Need to be compatible with DBAL < 4, which still has `$params['url']` */
253255
if (! isset($params['url'])) {
254256
return $params;
255257
}

Controller/ProfilerController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use Doctrine\Bundle\DoctrineBundle\Registry;
66
use Doctrine\DBAL\Connection;
77
use Doctrine\DBAL\Platforms\OraclePlatform;
8-
use Doctrine\DBAL\Platforms\SqlitePlatform;
8+
use Doctrine\DBAL\Platforms\SQLitePlatform;
99
use Doctrine\DBAL\Platforms\SQLServerPlatform;
1010
use Exception;
1111
use Symfony\Bridge\Doctrine\DataCollector\DoctrineDataCollector;
@@ -64,7 +64,7 @@ public function explainAction($token, $connectionName, $query)
6464
assert($connection instanceof Connection);
6565
try {
6666
$platform = $connection->getDatabasePlatform();
67-
if ($platform instanceof SqlitePlatform) {
67+
if ($platform instanceof SQLitePlatform) {
6868
$results = $this->explainSQLitePlatform($connection, $query);
6969
} elseif ($platform instanceof SQLServerPlatform) {
7070
throw new Exception('Explain for SQLServerPlatform is currently not supported. Contributions are welcome.');

DataCollector/DoctrineDataCollector.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
use Doctrine\ORM\Cache\CacheConfiguration;
77
use Doctrine\ORM\Cache\Logging\CacheLoggerChain;
88
use Doctrine\ORM\Cache\Logging\StatisticsCacheLogger;
9-
use Doctrine\ORM\Configuration;
109
use Doctrine\ORM\EntityManagerInterface;
1110
use Doctrine\ORM\Mapping\ClassMetadata;
1211
use Doctrine\ORM\Tools\SchemaValidator;
@@ -122,8 +121,7 @@ public function collect(Request $request, Response $response, ?Throwable $except
122121
}
123122
}
124123

125-
$emConfig = $em->getConfiguration();
126-
assert($emConfig instanceof Configuration);
124+
$emConfig = $em->getConfiguration();
127125
$slcEnabled = $emConfig->isSecondLevelCacheEnabled();
128126

129127
if (! $slcEnabled) {

DependencyInjection/Compiler/DoctrineOrmMappingsPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function __construct($driver, array $namespaces, array $managerParameters
6868
public static function createXmlMappingDriver(array $namespaces, array $managerParameters = [], $enabledParameter = false, array $aliasMap = [], bool $enableXsdValidation = false)
6969
{
7070
$locator = new Definition(SymfonyFileLocator::class, [$namespaces, '.orm.xml']);
71-
$driver = new Definition(XmlDriver::class, [$locator, null, $enableXsdValidation]);
71+
$driver = new Definition(XmlDriver::class, [$locator, XmlDriver::DEFAULT_FILE_EXTENSION, $enableXsdValidation]);
7272

7373
return new DoctrineOrmMappingsPass($driver, $namespaces, $managerParameters, $enabledParameter, $aliasMap);
7474
}

0 commit comments

Comments
 (0)