diff --git a/src/Schema/ViewHelperFinder.php b/src/Schema/ViewHelperFinder.php index 4f28db971..d6f8c965c 100644 --- a/src/Schema/ViewHelperFinder.php +++ b/src/Schema/ViewHelperFinder.php @@ -22,6 +22,10 @@ final class ViewHelperFinder private const FILE_SUFFIX = 'ViewHelper.php'; private ViewHelperMetadataFactory $viewHelperMetadataFactory; + /** + * @var \Throwable[] $lastErrors + */ + private array $lastErrors = []; public function __construct(?ViewHelperMetadataFactory $viewHelperMetadataFactory = null) { @@ -33,6 +37,7 @@ public function __construct(?ViewHelperMetadataFactory $viewHelperMetadataFactor */ public function findViewHelpersInComposerProject(ClassLoader $autoloader): array { + $this->lastErrors = []; $viewHelpers = []; foreach ($autoloader->getPrefixesPsr4() as $namespace => $paths) { foreach ($paths as $path) { @@ -42,6 +47,14 @@ public function findViewHelpersInComposerProject(ClassLoader $autoloader): array return $viewHelpers; } + /** + * @return \Throwable[] + */ + public function getLastErrors(): array + { + return $this->lastErrors; + } + /** * @return ViewHelperMetadata[] */ @@ -77,6 +90,10 @@ private function findViewHelperFilesInPath(string $namespace, string $path): arr $viewHelpers[] = $this->viewHelperMetadataFactory->createFromViewhelperClass($className); } catch (\InvalidArgumentException) { // Just ignore this class + } catch (\Throwable $t) { + // Catch all Throwables to mitigate technical debt of a ViewHelper + // and avoid aborting the whole generation + $this->lastErrors[] = $t; } } return $viewHelpers;