diff --git a/composer.json b/composer.json
index 6818f33d..e992ccae 100644
--- a/composer.json
+++ b/composer.json
@@ -7,7 +7,7 @@
],
"require": {
"php": "^7.2 || ^8.0",
- "phpstan/phpstan": "^1.11"
+ "phpstan/phpstan": "^1.11.7"
},
"conflict": {
"doctrine/collections": "<1.0",
diff --git a/extension.neon b/extension.neon
index 81469b91..f4d3b7ef 100644
--- a/extension.neon
+++ b/extension.neon
@@ -91,6 +91,10 @@ services:
-
class: PHPStan\Doctrine\Driver\DriverDetector
+ -
+ class: PHPStan\Doctrine\DoctrineDiagnoseExtension
+ tags:
+ - phpstan.diagnoseExtension
-
class: PHPStan\Type\Doctrine\HydrationModeReturnTypeResolver
-
diff --git a/src/Doctrine/DoctrineDiagnoseExtension.php b/src/Doctrine/DoctrineDiagnoseExtension.php
new file mode 100644
index 00000000..58fda398
--- /dev/null
+++ b/src/Doctrine/DoctrineDiagnoseExtension.php
@@ -0,0 +1,83 @@
+objectMetadataResolver = $objectMetadataResolver;
+ $this->driverDetector = $driverDetector;
+ }
+
+ public function print(Output $output): void
+ {
+ $output->writeLineFormatted(sprintf(
+ 'Doctrine\'s objectManagerLoader: %s',
+ $this->objectMetadataResolver->hasObjectManagerLoader() ? 'In use' : 'No'
+ ));
+
+ $objectManager = $this->objectMetadataResolver->getObjectManager();
+ if ($objectManager instanceof EntityManagerInterface) {
+ $connection = $objectManager->getConnection();
+ $driver = $this->driverDetector->detect($connection);
+
+ $output->writeLineFormatted(sprintf(
+ 'Detected driver: %s',
+ $driver === null ? 'None' : $driver
+ ));
+ }
+
+ $packages = [];
+ $candidates = [
+ 'doctrine/dbal',
+ 'doctrine/orm',
+ 'doctrine/common',
+ 'doctrine/collections',
+ 'doctrine/persistence',
+ ];
+ foreach ($candidates as $package) {
+ try {
+ $installedVersion = InstalledVersions::getPrettyVersion($package);
+ } catch (OutOfBoundsException $e) {
+ continue;
+ }
+
+ if ($installedVersion === null) {
+ continue;
+ }
+
+ $packages[$package] = $installedVersion;
+ }
+
+ if (count($packages) > 0) {
+ $output->writeLineFormatted('Installed Doctrine packages:');
+ foreach ($packages as $package => $version) {
+ $output->writeLineFormatted(sprintf('%s: %s', $package, $version));
+ }
+ }
+
+ $output->writeLineFormatted('');
+ }
+
+}