Skip to content

Commit d35bc14

Browse files
committed
Remove usage of methods from DBAL < 3.1
1 parent ab2f2a1 commit d35bc14

1 file changed

Lines changed: 7 additions & 12 deletions

File tree

Storage/DoctrineStorage.php

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,17 @@ class DoctrineStorage implements StorageInterface {
5151
public function __construct(Connection $conn, StorageKeyGeneratorInterface $storageKeyGenerator) {
5252
$this->conn = $conn;
5353
$this->storageKeyGenerator = $storageKeyGenerator;
54-
// TODO just call `createSchemaManager()` as soon as DBAL >= 3.1 is required
55-
$this->schemaManager = \method_exists($this->conn, 'createSchemaManager') ? $this->conn->createSchemaManager() : $this->conn->getSchemaManager();
54+
$this->schemaManager = $this->conn->createSchemaManager();
5655

5756
// BC for doctrine/dbal < 4
57+
/* @phpstan-ignore function.alreadyNarrowedType */
5858
if(method_exists($this->conn, 'quoteSingleIdentifier')) {
5959
$this->keyColumn = $this->conn->quoteSingleIdentifier(self::KEY_COLUMN);
6060
$this->valueColumn = $this->conn->quoteSingleIdentifier(self::VALUE_COLUMN);
6161
} else {
62+
/* @phpstan-ignore method.deprecated */
6263
$this->keyColumn = $this->conn->quoteIdentifier(self::KEY_COLUMN);
64+
/* @phpstan-ignore method.deprecated */
6365
$this->valueColumn = $this->conn->quoteIdentifier(self::VALUE_COLUMN);
6466
}
6567
}
@@ -142,15 +144,7 @@ private function getRawValueForKey($key) {
142144
->setParameter('key', $this->generateKey($key))
143145
;
144146

145-
// TODO just call `executeQuery()` as soon as DBAL >= 2.13.1 is required
146-
$result = \method_exists($qb, 'executeQuery') ? $qb->executeQuery() : $qb->execute();
147-
148-
// TODO remove as soon as Doctrine DBAL >= 3.0 is required
149-
if (!\method_exists($result, 'fetchOne')) {
150-
return $result->fetchColumn();
151-
}
152-
153-
return $result->fetchOne();
147+
return $qb->executeQuery()->fetchOne();
154148
}
155149

156150
private function tableExists() {
@@ -164,13 +158,15 @@ private function createTable() {
164158
]);
165159

166160
// BC for doctrine/dbal < 4
161+
/* @phpstan-ignore function.alreadyNarrowedType */
167162
if (method_exists($table, 'addPrimaryKeyConstraint')) {
168163
$table->addPrimaryKeyConstraint(
169164
PrimaryKeyConstraint::editor()
170165
->setUnquotedColumnNames($this->keyColumn)
171166
->create()
172167
);
173168
} else {
169+
/* @phpstan-ignore method.deprecated */
174170
$table->setPrimaryKey([$this->keyColumn]);
175171
}
176172

@@ -180,5 +176,4 @@ private function createTable() {
180176
private function generateKey($key) {
181177
return $this->storageKeyGenerator->generate($key);
182178
}
183-
184179
}

0 commit comments

Comments
 (0)