diff --git a/src/NodeTypeResolver/DependencyInjection/PHPStanServicesFactory.php b/src/NodeTypeResolver/DependencyInjection/PHPStanServicesFactory.php index e45ee8aa72a..130ad4e86a6 100644 --- a/src/NodeTypeResolver/DependencyInjection/PHPStanServicesFactory.php +++ b/src/NodeTypeResolver/DependencyInjection/PHPStanServicesFactory.php @@ -4,6 +4,7 @@ namespace Rector\NodeTypeResolver\DependencyInjection; +use Throwable; use PhpParser\Lexer; use PHPStan\Analyser\NodeScopeResolver; use PHPStan\Analyser\ScopeFactory; @@ -16,6 +17,9 @@ use Rector\Configuration\Option; use Rector\Configuration\Parameter\SimpleParameterProvider; use Rector\NodeTypeResolver\Reflection\BetterReflection\SourceLocatorProvider\DynamicSourceLocatorProvider; +use Symfony\Component\Console\Input\ArrayInput; +use Symfony\Component\Console\Output\ConsoleOutput; +use Symfony\Component\Console\Style\SymfonyStyle; use Webmozart\Assert\Assert; /** @@ -27,16 +31,41 @@ { private Container $container; + /** + * @var string + */ + private const INVALID_BLEEDING_EDGE_PATH_MESSAGE = <<resolveAdditionalConfigFiles(); - $this->container = $containerFactory->create( - SimpleParameterProvider::provideStringParameter(Option::CONTAINER_CACHE_DIRECTORY), - $additionalConfigFiles, - [] - ); + try { + $this->container = $containerFactory->create( + SimpleParameterProvider::provideStringParameter(Option::CONTAINER_CACHE_DIRECTORY), + $additionalConfigFiles, + [] + ); + } catch (Throwable $throwable) { + if ($throwable->getMessage() === "File 'phar://phpstan.phar/conf/bleedingEdge.neon' is missing or is not readable.") { + + $symfonyStyle = new SymfonyStyle(new ArrayInput([]), new ConsoleOutput()); + $symfonyStyle->error(sprintf(self::INVALID_BLEEDING_EDGE_PATH_MESSAGE, $throwable->getMessage())); + + exit(-1); + } + + throw $throwable; + } } /**