diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml
index d3130033e1b..8e3a68229fa 100644
--- a/.github/workflows/continuous-integration.yml
+++ b/.github/workflows/continuous-integration.yml
@@ -40,14 +40,14 @@ jobs:
- name: "Run PHPUnit"
continue-on-error: true
- run: "vendor/bin/phpunit -c ci/github/phpunit/sqlite.xml --coverage-clover=coverage-no-cache.xml"
+ run: "vendor/bin/phpunit -c ci/github/phpunit/sqlite.xml --coverage-clover=coverage-no-cache.xml --exclude-group performance,locking_functional,dbal2"
env:
ENABLE_SECOND_LEVEL_CACHE: 0
- name: "Run PHPUnit with Second Level Cache"
id: "phpunit-run-slc"
continue-on-error: true
- run: "vendor/bin/phpunit -c ci/github/phpunit/sqlite.xml --exclude-group performance,non-cacheable,locking_functional --coverage-clover=coverage-cache.xml"
+ run: "vendor/bin/phpunit -c ci/github/phpunit/sqlite.xml --exclude-group performance,non-cacheable,locking_functional,dbal2 --coverage-clover=coverage-cache.xml"
env:
ENABLE_SECOND_LEVEL_CACHE: 1
@@ -93,7 +93,7 @@ jobs:
ENABLE_SECOND_LEVEL_CACHE: 0
- name: "Run PHPUnit with Second Level Cache"
- run: "vendor/bin/phpunit -c ci/github/phpunit/sqlite.xml --exclude-group performance,non-cacheable,locking_functional --coverage-clover=coverage-cache.xml"
+ run: "vendor/bin/phpunit -c ci/github/phpunit/sqlite.xml --exclude-group performance,non-cacheable,locking_functional,dbal3 --coverage-clover=coverage-cache.xml"
env:
ENABLE_SECOND_LEVEL_CACHE: 1
@@ -261,7 +261,7 @@ jobs:
ENABLE_SECOND_LEVEL_CACHE: 0
- name: "Run PHPUnit with Second Level Cache"
- run: "vendor/bin/phpunit -c ci/github/phpunit/${{ matrix.extension }}.xml --exclude-group performance,non-cacheable,locking_functional --coverage-clover=coverage-no-cache.xml"
+ run: "vendor/bin/phpunit -c ci/github/phpunit/${{ matrix.extension }}.xml --exclude-group performance,non-cacheable,locking_functional,dbal3 --coverage-clover=coverage-no-cache.xml"
env:
ENABLE_SECOND_LEVEL_CACHE: 1
diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml
index 691e4820dca..01780c3c3ff 100644
--- a/.github/workflows/static-analysis.yml
+++ b/.github/workflows/static-analysis.yml
@@ -51,6 +51,12 @@ jobs:
- name: "Run a static analysis with phpstan/phpstan"
continue-on-error: "${{ matrix.status == 'experimental' }}"
run: "vendor/bin/phpstan analyse"
+ if: "${{ matrix.dbal-version == 'default' }}"
+
+ - name: "Run a static analysis with phpstan/phpstan"
+ continue-on-error: "${{ matrix.status == 'experimental' }}"
+ run: "vendor/bin/phpstan analyse -c phpstan-dbal3.neon"
+ if: "${{ matrix.dbal-version != 'default' }}"
static-analysis-psalm:
name: "Static Analysis with Psalm"
diff --git a/ci/github/phpunit/mysqli.xml b/ci/github/phpunit/mysqli.xml
index 916e43397ff..9a72c0e89fb 100644
--- a/ci/github/phpunit/mysqli.xml
+++ b/ci/github/phpunit/mysqli.xml
@@ -33,6 +33,7 @@
performance
locking_functional
+ dbal3
diff --git a/ci/github/phpunit/pdo_mysql.xml b/ci/github/phpunit/pdo_mysql.xml
index 9469d9af0f8..aca2cce75aa 100644
--- a/ci/github/phpunit/pdo_mysql.xml
+++ b/ci/github/phpunit/pdo_mysql.xml
@@ -34,6 +34,7 @@
performance
locking_functional
+ dbal3
diff --git a/ci/github/phpunit/pdo_pgsql.xml b/ci/github/phpunit/pdo_pgsql.xml
index 570042dbf40..01f2a6f885b 100644
--- a/ci/github/phpunit/pdo_pgsql.xml
+++ b/ci/github/phpunit/pdo_pgsql.xml
@@ -33,6 +33,7 @@
performance
locking_functional
+ dbal3
diff --git a/ci/github/phpunit/sqlite.xml b/ci/github/phpunit/sqlite.xml
index 4639aa3a1b2..ce26cbc4e0e 100644
--- a/ci/github/phpunit/sqlite.xml
+++ b/ci/github/phpunit/sqlite.xml
@@ -31,6 +31,7 @@
performance
locking_functional
+ dbal3
diff --git a/lib/Doctrine/ORM/Exception/NotSupported.php b/lib/Doctrine/ORM/Exception/NotSupported.php
index 852826b6f6e..8669aa17a9d 100644
--- a/lib/Doctrine/ORM/Exception/NotSupported.php
+++ b/lib/Doctrine/ORM/Exception/NotSupported.php
@@ -10,4 +10,9 @@ public static function create(): self
{
return new self('This behaviour is (currently) not supported by Doctrine 2');
}
+
+ public static function createForDbal3(): self
+ {
+ return new self('Feature was deprecated in doctrine/dbal 2.x and is not supported by installed doctrine/dbal:3.x, please see the doctrine/deprecations logs for new alternative approaches.');
+ }
}
diff --git a/lib/Doctrine/ORM/Id/UuidGenerator.php b/lib/Doctrine/ORM/Id/UuidGenerator.php
index be12ba617a6..f6b87589378 100644
--- a/lib/Doctrine/ORM/Id/UuidGenerator.php
+++ b/lib/Doctrine/ORM/Id/UuidGenerator.php
@@ -4,8 +4,12 @@
namespace Doctrine\ORM\Id;
+use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\Deprecations\Deprecation;
use Doctrine\ORM\EntityManager;
+use Doctrine\ORM\Exception\NotSupported;
+
+use function method_exists;
/**
* Represents an ID generator that uses the database UUID expression
@@ -22,10 +26,16 @@ public function __construct()
'%s is deprecated with no replacement, use an application-side generator instead',
self::class
);
+
+ if (! method_exists(AbstractPlatform::class, 'getGuidExpression')) {
+ throw NotSupported::createForDbal3();
+ }
}
/**
* {@inheritDoc}
+ *
+ * @throws NotSupported
*/
public function generate(EntityManager $em, $entity)
{
diff --git a/phpstan-dbal3.neon b/phpstan-dbal3.neon
new file mode 100644
index 00000000000..f03bc653b2c
--- /dev/null
+++ b/phpstan-dbal3.neon
@@ -0,0 +1,8 @@
+includes:
+ - phpstan.neon
+
+parameters:
+ ignoreErrors:
+ # deprecations from doctrine/dbal:3.x
+ - '/^Call to an undefined method Doctrine\\DBAL\\Platforms\\AbstractPlatform::getGuidExpression\(\).$/'
+
diff --git a/phpstan.neon b/phpstan.neon
index fbe0fb36d3b..9f3f9bb3bd8 100644
--- a/phpstan.neon
+++ b/phpstan.neon
@@ -16,6 +16,5 @@ parameters:
ignoreErrors:
# The class was added in PHP 8.1
- '/^Attribute class ReturnTypeWillChange does not exist.$/'
-
# https://github.com/doctrine/collections/pull/282
- '/Variable \$offset in isset\(\) always exists and is not nullable\./'
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index ed380a73685..6b01886eaf7 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -28,6 +28,7 @@
performance
locking_functional
+ dbal3
diff --git a/psalm.xml b/psalm.xml
index a236e670f74..13a3d928783 100644
--- a/psalm.xml
+++ b/psalm.xml
@@ -47,5 +47,11 @@
+
+
+
+
+
+
diff --git a/tests/Doctrine/Tests/ORM/Functional/UUIDGeneratorTest.php b/tests/Doctrine/Tests/ORM/Functional/UUIDGeneratorTest.php
index 00d262b526f..fb72ce37f1d 100644
--- a/tests/Doctrine/Tests/ORM/Functional/UUIDGeneratorTest.php
+++ b/tests/Doctrine/Tests/ORM/Functional/UUIDGeneratorTest.php
@@ -4,13 +4,16 @@
namespace Doctrine\Tests\ORM\Functional;
+use Doctrine\DBAL\Connection;
use Doctrine\Deprecations\PHPUnit\VerifyDeprecations;
+use Doctrine\ORM\Exception\NotSupported;
use Doctrine\ORM\Mapping\Column;
use Doctrine\ORM\Mapping\Entity;
use Doctrine\ORM\Mapping\GeneratedValue;
use Doctrine\ORM\Mapping\Id;
use Doctrine\Tests\OrmFunctionalTestCase;
+use function method_exists;
use function strlen;
/**
@@ -20,18 +23,28 @@ class UUIDGeneratorTest extends OrmFunctionalTestCase
{
use VerifyDeprecations;
+ /**
+ * @group dbal2
+ */
public function testItIsDeprecated(): void
{
$this->expectDeprecationWithIdentifier('https://github.com/doctrine/orm/issues/7312');
$this->_em->getClassMetadata(UUIDEntity::class);
}
+ /**
+ * @group dbal2
+ */
public function testGenerateUUID(): void
{
if ($this->_em->getConnection()->getDatabasePlatform()->getName() !== 'mysql') {
self::markTestSkipped('Currently restricted to MySQL platform.');
}
+ if (! method_exists(Connection::class, 'getGuidExpression')) {
+ self::markTestSkipped('Test valid for doctrine/dbal:2.x only.');
+ }
+
$this->_schemaTool->createSchema([
$this->_em->getClassMetadata(UUIDEntity::class),
]);
@@ -41,6 +54,15 @@ public function testGenerateUUID(): void
self::assertNotNull($entity->getId());
self::assertGreaterThan(0, strlen($entity->getId()));
}
+
+ /**
+ * @group dbal3
+ */
+ public function testItCannotBeInitialised(): void
+ {
+ $this->expectException(NotSupported::class);
+ $this->_em->getClassMetadata(UUIDEntity::class);
+ }
}
/**