Skip to content

Commit 56177e4

Browse files
committed
Add fatal error protection
1 parent a84ba4d commit 56177e4

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/Generator.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,17 @@ public static function get(array $containers, array $options = [])
2424
return new $iteratorClass($container);
2525
}, $containers);
2626

27-
$metadata = new Metadata(...$iterators);
28-
29-
return $metadata->render($options['overrides']);
27+
$tmpAutoload = function ($className) {
28+
throw new \RuntimeException('Metadata Export fallback autoloader: Cannot load class ' . $className);
29+
};
30+
31+
try {
32+
spl_autoload_register($tmpAutoload); // so non existing class is not a fatal error but an exception
33+
$metadata = new Metadata(...$iterators);
34+
return $metadata->render($options['overrides']);
35+
} finally {
36+
spl_autoload_unregister($tmpAutoload);
37+
}
3038
}
3139

3240
/**

0 commit comments

Comments
 (0)