Skip to content

Commit

Permalink
Add try catch
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentLanglet authored and ondrejmirtes committed Apr 17, 2024
1 parent c71d936 commit 849b856
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/Stubs/Doctrine/StubFilesExtensionLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
namespace PHPStan\Stubs\Doctrine;

use Composer\InstalledVersions;
use OutOfBoundsException;
use PHPStan\BetterReflection\Reflector\Exception\IdentifierNotFound;
use PHPStan\BetterReflection\Reflector\Reflector;
use PHPStan\PhpDoc\StubFilesExtension;
use function class_exists;
use function dirname;
use function strpos;

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

$collectionVersion = class_exists(InstalledVersions::class)
? InstalledVersions::getVersion('doctrine/collections')
: null;
try {
$collectionVersion = class_exists(InstalledVersions::class)
? InstalledVersions::getVersion('doctrine/collections')
: null;
} catch (OutOfBoundsException $e) {
$collectionVersion = null;
}
if ($collectionVersion !== null && strpos($collectionVersion, '1.') === 0) {
$files[] = $stubsDir . '/Collections/Collection1.stub';
} else {
Expand Down

0 comments on commit 849b856

Please sign in to comment.