Skip to content

Commit d11ff6e

Browse files
committed
minor #43584 [Cache]  Remove deprecated support of DBAL by PdoAdapter (GromNaN)
This PR was merged into the 6.0 branch. Discussion ---------- [Cache]  Remove deprecated support of DBAL by PdoAdapter | Q | A | ------------- | --- | Branch? | 6.0 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | Fix #42962 | License | MIT | Doc PR | no Commits ------- e578c49 [Cache] Remove deprecated support of DBAL by PdoAdapter
2 parents 3060255 + e578c49 commit d11ff6e

File tree

6 files changed

+18
-488
lines changed

6 files changed

+18
-488
lines changed

src/Symfony/Bridge/Doctrine/SchemaListener/PdoCacheAdapterDoctrineSchemaSubscriber.php

Lines changed: 0 additions & 58 deletions
This file was deleted.

src/Symfony/Bridge/Doctrine/Tests/SchemaListener/PdoCacheAdapterDoctrineSchemaSubscriberTest.php

Lines changed: 0 additions & 45 deletions
This file was deleted.

src/Symfony/Component/Cache/Adapter/DoctrineDbalAdapter.php

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,16 @@ final class DoctrineDbalAdapter extends AbstractAdapter implements PruneableInte
2727
{
2828
protected $maxIdLength = 255;
2929

30-
private $marshaller;
31-
private $conn;
32-
private $platformName;
33-
private $serverVersion;
34-
private $table = 'cache_items';
35-
private $idCol = 'item_id';
36-
private $dataCol = 'item_data';
37-
private $lifetimeCol = 'item_lifetime';
38-
private $timeCol = 'item_time';
39-
private $namespace;
30+
private MarshallerInterface $marshaller;
31+
private Connection $conn;
32+
private string $platformName;
33+
private string $serverVersion;
34+
private string $table = 'cache_items';
35+
private string $idCol = 'item_id';
36+
private string $dataCol = 'item_data';
37+
private string $lifetimeCol = 'item_lifetime';
38+
private string $timeCol = 'item_time';
39+
private string $namespace;
4040

4141
/**
4242
* You can either pass an existing database Doctrine DBAL Connection or
@@ -52,25 +52,21 @@ final class DoctrineDbalAdapter extends AbstractAdapter implements PruneableInte
5252
* * db_lifetime_col: The column where to store the lifetime [default: item_lifetime]
5353
* * db_time_col: The column where to store the timestamp [default: item_time]
5454
*
55-
* @param Connection|string $connOrDsn
56-
*
5755
* @throws InvalidArgumentException When namespace contains invalid characters
5856
*/
59-
public function __construct($connOrDsn, string $namespace = '', int $defaultLifetime = 0, array $options = [], MarshallerInterface $marshaller = null)
57+
public function __construct(Connection|string $connOrDsn, string $namespace = '', int $defaultLifetime = 0, array $options = [], MarshallerInterface $marshaller = null)
6058
{
6159
if (isset($namespace[0]) && preg_match('#[^-+.A-Za-z0-9]#', $namespace, $match)) {
6260
throw new InvalidArgumentException(sprintf('Namespace contains "%s" but only characters in [-+.A-Za-z0-9] are allowed.', $match[0]));
6361
}
6462

6563
if ($connOrDsn instanceof Connection) {
6664
$this->conn = $connOrDsn;
67-
} elseif (\is_string($connOrDsn)) {
65+
} else {
6866
if (!class_exists(DriverManager::class)) {
6967
throw new InvalidArgumentException(sprintf('Failed to parse the DSN "%s". Try running "composer require doctrine/dbal".', $connOrDsn));
7068
}
7169
$this->conn = DriverManager::getConnection(['url' => $connOrDsn]);
72-
} else {
73-
throw new \TypeError(sprintf('Argument 1 passed to "%s()" must be "%s" or string, "%s" given.', Connection::class, __METHOD__, get_debug_type($connOrDsn)));
7470
}
7571

7672
$this->table = $options['db_table'] ?? $this->table;
@@ -92,7 +88,7 @@ public function __construct($connOrDsn, string $namespace = '', int $defaultLife
9288
*
9389
* @throws DBALException When the table already exists
9490
*/
95-
public function createTable()
91+
public function createTable(): void
9692
{
9793
$schema = new Schema();
9894
$this->addTableToSchema($schema);

0 commit comments

Comments
 (0)