Skip to content

Commit 46ff440

Browse files
committed
Bleeding edge - analysis with zero files results in non-zero exit code
1 parent 94a1d21 commit 46ff440

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

conf/bleedingEdge.neon

+1
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,4 @@ parameters:
3939
stricterFunctionMap: true
4040
invalidPhpDocTagLine: true
4141
detectDeadTypeInMultiCatch: true
42+
zeroFiles: true

conf/config.neon

+2
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ parameters:
6969
stricterFunctionMap: false
7070
invalidPhpDocTagLine: false
7171
detectDeadTypeInMultiCatch: false
72+
zeroFiles: false
7273
fileExtensions:
7374
- php
7475
checkAdvancedIsset: false
@@ -308,6 +309,7 @@ parametersSchema:
308309
stricterFunctionMap: bool()
309310
invalidPhpDocTagLine: bool()
310311
detectDeadTypeInMultiCatch: bool()
312+
zeroFiles: bool()
311313
])
312314
fileExtensions: listOf(string())
313315
checkAdvancedIsset: bool()

src/Command/AnalyseCommand.php

+10-3
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,17 @@ protected function execute(InputInterface $input, OutputInterface $output): int
223223
}
224224

225225
if (count($files) === 0) {
226-
$inceptionResult->getErrorOutput()->getStyle()->note('No files found to analyse.');
227-
$inceptionResult->getErrorOutput()->getStyle()->warning('This will cause a non-zero exit code in PHPStan 2.0.');
226+
$bleedingEdge = (bool) $container->getParameter('featureToggles')['zeroFiles'];
227+
if (!$bleedingEdge) {
228+
$inceptionResult->getErrorOutput()->getStyle()->note('No files found to analyse.');
229+
$inceptionResult->getErrorOutput()->getStyle()->warning('This will cause a non-zero exit code in PHPStan 2.0.');
228230

229-
return $inceptionResult->handleReturn(0, null);
231+
return $inceptionResult->handleReturn(0, null);
232+
}
233+
234+
$inceptionResult->getErrorOutput()->getStyle()->error('No files found to analyse.');
235+
236+
return $inceptionResult->handleReturn(1, null);
230237
}
231238

232239
$analysedConfigFiles = array_intersect($files, $container->getParameter('allConfigFiles'));

0 commit comments

Comments
 (0)