Skip to content

Commit

Permalink
Merge pull request #419 from franmomu/dbal
Browse files Browse the repository at this point in the history
remove DBAL deprecations
  • Loading branch information
craue committed Jan 11, 2024
2 parents 0e34cf9 + 70b3a3f commit 4f1c7d5
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 19 deletions.
8 changes: 2 additions & 6 deletions Storage/DoctrineStorage.php
Expand Up @@ -150,13 +150,9 @@ private function tableExists() {
}

private function createTable() {
// TODO remove as soon as Doctrine DBAL >= 3.0 is required
$stringType = defined('Doctrine\DBAL\Types\Types::STRING') ? Types::STRING : Type::STRING;
$arrayType = defined('Doctrine\DBAL\Types\Types::ARRAY') ? Types::ARRAY : Type::TARRAY;

$table = new Table(self::TABLE, [
new Column($this->keyColumn, Type::getType($stringType)),
new Column($this->valueColumn, Type::getType($arrayType)),
new Column($this->keyColumn, Type::getType(Types::STRING), ['length' => 255]),
new Column($this->valueColumn, Type::getType(Types::TEXT)),
]);

$table->setPrimaryKey([$this->keyColumn]);
Expand Down
15 changes: 12 additions & 3 deletions Tests/Storage/DoctrineStorageTest.php
Expand Up @@ -8,6 +8,7 @@
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\DriverManager;
use Doctrine\DBAL\Schema\DefaultSchemaManagerFactory;
use Doctrine\DBAL\Tools\DsnParser;

/**
* @group unit
Expand Down Expand Up @@ -40,9 +41,17 @@ protected function getStorageImplementation() {
$this->markTestSkipped('Environment variable DB_DSN is not set.');
}

$this->conn = DriverManager::getConnection([
'url' => $_ENV['DB_DSN'],
], $configuration);
$dsn = $_ENV['DB_DSN'];
// TODO use DsnParser as soon as DBAL >= 3.6 is required
$params = class_exists(DsnParser::class)
? (new DsnParser([
'mysql' => 'pdo_mysql',
'pgsql' => 'pdo_pgsql',
'sqlite' => 'pdo_sqlite',
]))->parse($dsn)
: ['url' => $dsn];

$this->conn = DriverManager::getConnection($params, $configuration);

$generator = $this->createMock(StorageKeyGeneratorInterface::class);

Expand Down
4 changes: 4 additions & 0 deletions composer.json
Expand Up @@ -38,6 +38,7 @@
"craue/translations-tests": "^1.1",
"doctrine/collections": "^1.8 || ^2.1",
"doctrine/common": "^2.9 || ^3.0",
"doctrine/dbal": "^2.10 || ^3.0",
"doctrine/doctrine-bundle": "^1.10 || ^2.0",
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan": "^1.10",
Expand All @@ -52,6 +53,9 @@
"symfony/security-bundle": "^4.4 || ^5.4 || ^6.3",
"symfony/twig-bundle": "^4.4 || ^5.4 || ^6.3"
},
"conflict": {
"doctrine/dbal": "<2.10"
},
"minimum-stability": "stable",
"autoload": {
"psr-4": {
Expand Down
10 changes: 0 additions & 10 deletions phpstan-config.neon
Expand Up @@ -63,10 +63,6 @@ parameters:
-
message: '#^Cannot call method fetchColumn\(\) on Doctrine\\DBAL\\Result\|int\|string\.$#'
path: Storage/DoctrineStorage.php
# TODO remove as soon as Doctrine DBAL >= 3.0 is required
-
message: '#^Access to undefined constant Doctrine\\DBAL\\Types\\Type::(STRING|TARRAY)\.$#'
path: Storage/DoctrineStorage.php
# TODO remove as soon as Doctrine DBAL >= 3.1 is required
-
message: "#^Call to function method_exists\\(\\) with Doctrine\\\\DBAL\\\\Connection and 'createSchemaManager' will always evaluate to true\\.$#"
Expand All @@ -78,9 +74,3 @@ parameters:
Use \\{@see createSchemaManager\\(\\)\\} instead\\.$#
"""
path: Storage/DoctrineStorage.php
-
message: """
#^Fetching deprecated class constant ARRAY of class Doctrine\\\\DBAL\\\\Types\\\\Types:
Use \\{@link Types::JSON} instead\\.$#
"""
path: Storage/DoctrineStorage.php

0 comments on commit 4f1c7d5

Please sign in to comment.