From 46ff440648e62617df86aa74ba905ffa99897737 Mon Sep 17 00:00:00 2001 From: Ondrej Mirtes Date: Thu, 8 Jun 2023 11:50:16 +0200 Subject: [PATCH] Bleeding edge - analysis with zero files results in non-zero exit code --- conf/bleedingEdge.neon | 1 + conf/config.neon | 2 ++ src/Command/AnalyseCommand.php | 13 ++++++++++--- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/conf/bleedingEdge.neon b/conf/bleedingEdge.neon index 6f9c5d35bf..bef64b6480 100644 --- a/conf/bleedingEdge.neon +++ b/conf/bleedingEdge.neon @@ -39,3 +39,4 @@ parameters: stricterFunctionMap: true invalidPhpDocTagLine: true detectDeadTypeInMultiCatch: true + zeroFiles: true diff --git a/conf/config.neon b/conf/config.neon index 8419ee2d55..1466a8c2e2 100644 --- a/conf/config.neon +++ b/conf/config.neon @@ -69,6 +69,7 @@ parameters: stricterFunctionMap: false invalidPhpDocTagLine: false detectDeadTypeInMultiCatch: false + zeroFiles: false fileExtensions: - php checkAdvancedIsset: false @@ -308,6 +309,7 @@ parametersSchema: stricterFunctionMap: bool() invalidPhpDocTagLine: bool() detectDeadTypeInMultiCatch: bool() + zeroFiles: bool() ]) fileExtensions: listOf(string()) checkAdvancedIsset: bool() diff --git a/src/Command/AnalyseCommand.php b/src/Command/AnalyseCommand.php index 8ea2c1002b..e1985934a9 100644 --- a/src/Command/AnalyseCommand.php +++ b/src/Command/AnalyseCommand.php @@ -223,10 +223,17 @@ protected function execute(InputInterface $input, OutputInterface $output): int } if (count($files) === 0) { - $inceptionResult->getErrorOutput()->getStyle()->note('No files found to analyse.'); - $inceptionResult->getErrorOutput()->getStyle()->warning('This will cause a non-zero exit code in PHPStan 2.0.'); + $bleedingEdge = (bool) $container->getParameter('featureToggles')['zeroFiles']; + if (!$bleedingEdge) { + $inceptionResult->getErrorOutput()->getStyle()->note('No files found to analyse.'); + $inceptionResult->getErrorOutput()->getStyle()->warning('This will cause a non-zero exit code in PHPStan 2.0.'); - return $inceptionResult->handleReturn(0, null); + return $inceptionResult->handleReturn(0, null); + } + + $inceptionResult->getErrorOutput()->getStyle()->error('No files found to analyse.'); + + return $inceptionResult->handleReturn(1, null); } $analysedConfigFiles = array_intersect($files, $container->getParameter('allConfigFiles'));