Skip to content

Commit 8805ca7

Browse files
authored
Use explicit errors for invalid object manager loader file
1 parent ea39192 commit 8805ca7

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/Type/Doctrine/ObjectMetadataResolver.php

+13-6
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use Doctrine\Persistence\ObjectManager;
66
use PHPStan\Reflection\ReflectionProvider;
7-
use function file_exists;
7+
use function is_file;
88
use function is_readable;
99

1010
final class ObjectMetadataResolver
@@ -60,11 +60,18 @@ public function getObjectManager(): ?ObjectManager
6060

6161
private function loadObjectManager(string $objectManagerLoader): ?ObjectManager
6262
{
63-
if (
64-
!file_exists($objectManagerLoader)
65-
|| !is_readable($objectManagerLoader)
66-
) {
67-
throw new \PHPStan\ShouldNotHappenException('Object manager could not be loaded');
63+
if (!is_file($objectManagerLoader)) {
64+
throw new \PHPStan\ShouldNotHappenException(sprintf(
65+
'Object manager could not be loaded: file "%s" does not exist',
66+
$objectManagerLoader
67+
));
68+
}
69+
70+
if (!is_readable($objectManagerLoader)) {
71+
throw new \PHPStan\ShouldNotHappenException(sprintf(
72+
'Object manager could not be loaded: file "%s" is not readable',
73+
$objectManagerLoader
74+
));
6875
}
6976

7077
return require $objectManagerLoader;

0 commit comments

Comments
 (0)