Skip to content

Commit 849b856

Browse files
VincentLangletondrejmirtes
authored andcommitted
Add try catch
1 parent c71d936 commit 849b856

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/Stubs/Doctrine/StubFilesExtensionLoader.php

+9-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
namespace PHPStan\Stubs\Doctrine;
44

55
use Composer\InstalledVersions;
6+
use OutOfBoundsException;
67
use PHPStan\BetterReflection\Reflector\Exception\IdentifierNotFound;
78
use PHPStan\BetterReflection\Reflector\Reflector;
89
use PHPStan\PhpDoc\StubFilesExtension;
10+
use function class_exists;
911
use function dirname;
1012
use function strpos;
1113

@@ -61,9 +63,13 @@ public function getFiles(): array
6163
$files[] = $stubsDir . '/ServiceEntityRepository.stub';
6264
}
6365

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

0 commit comments

Comments
 (0)