Skip to content

Commit

Permalink
Bleeding edge - analysis with zero files results in non-zero exit code
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Jun 8, 2023
1 parent 94a1d21 commit 46ff440
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions conf/bleedingEdge.neon
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,4 @@ parameters:
stricterFunctionMap: true
invalidPhpDocTagLine: true
detectDeadTypeInMultiCatch: true
zeroFiles: true
2 changes: 2 additions & 0 deletions conf/config.neon
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ parameters:
stricterFunctionMap: false
invalidPhpDocTagLine: false
detectDeadTypeInMultiCatch: false
zeroFiles: false
fileExtensions:
- php
checkAdvancedIsset: false
Expand Down Expand Up @@ -308,6 +309,7 @@ parametersSchema:
stricterFunctionMap: bool()
invalidPhpDocTagLine: bool()
detectDeadTypeInMultiCatch: bool()
zeroFiles: bool()
])
fileExtensions: listOf(string())
checkAdvancedIsset: bool()
Expand Down
13 changes: 10 additions & 3 deletions src/Command/AnalyseCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down

0 comments on commit 46ff440

Please sign in to comment.