Skip to content

Commit a3e644a

Browse files
committed
Detect nonexistent/wrong scanFiles and scanDirectories
1 parent 35341d0 commit a3e644a

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/Command/CommandHelper.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,26 @@ public static function begin(
356356
self::executeBootstrapFile($bootstrapFileFromArray, $container, $errorOutput, $debugEnabled);
357357
}
358358

359+
foreach ($container->getParameter('scanFiles') as $scannedFile) {
360+
if (is_file($scannedFile)) {
361+
continue;
362+
}
363+
364+
$errorOutput->writeLineFormatted(sprintf('Scanned file %s does not exist.', $scannedFile));
365+
366+
throw new \PHPStan\Command\InceptionNotSuccessfulException();
367+
}
368+
369+
foreach ($container->getParameter('scanDirectories') as $scannedDirectory) {
370+
if (is_dir($scannedDirectory)) {
371+
continue;
372+
}
373+
374+
$errorOutput->writeLineFormatted(sprintf('Scanned directory %s does not exist.', $scannedDirectory));
375+
376+
throw new \PHPStan\Command\InceptionNotSuccessfulException();
377+
}
378+
359379
/** @var FileFinder $fileFinder */
360380
$fileFinder = $container->getByType(FileFinder::class);
361381

0 commit comments

Comments
 (0)