Skip to content

Commit 6ff7fcc

Browse files
Add try catch
1 parent 6da1a65 commit 6ff7fcc

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/Stubs/Doctrine/StubFilesExtensionLoader.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use PHPStan\BetterReflection\Reflector\Exception\IdentifierNotFound;
77
use PHPStan\BetterReflection\Reflector\Reflector;
88
use PHPStan\PhpDoc\StubFilesExtension;
9+
use function class_exists;
910
use function dirname;
1011
use function strpos;
1112

@@ -61,9 +62,13 @@ public function getFiles(): array
6162
$files[] = $stubsDir . '/ServiceEntityRepository.stub';
6263
}
6364

64-
$collectionVersion = class_exists(InstalledVersions::class)
65-
? InstalledVersions::getVersion('doctrine/collections')
66-
: null;
65+
try {
66+
$collectionVersion = class_exists(InstalledVersions::class)
67+
? InstalledVersions::getVersion('doctrine/collections')
68+
: null;
69+
} catch (\OutOfBoundsException $e) {
70+
$collectionVersion = null;
71+
}
6772
if ($collectionVersion !== null && strpos($collectionVersion, '1.') === 0) {
6873
$files[] = $stubsDir . '/Collections/Collection1.stub';
6974
} else {

0 commit comments

Comments
 (0)