Skip to content

Commit 2370e44

Browse files
committed
Config path relative to projectConfigFile
1 parent 4b9ee02 commit 2370e44

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/Command/CommandHelper.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
use PHPStan\File\FileExcluder;
2626
use PHPStan\File\FileFinder;
2727
use PHPStan\File\FileHelper;
28+
use PHPStan\File\ParentDirectoryRelativePathHelper;
2829
use PHPStan\File\SimpleRelativePathHelper;
2930
use PHPStan\Internal\ComposerHelper;
3031
use PHPStan\Internal\DirectoryCreator;
@@ -381,6 +382,10 @@ public static function begin(
381382

382383
$suggestOptional = $e->getSuggestOptional();
383384
if (count($suggestOptional) > 0) {
385+
$baselinePathHelper = null;
386+
if ($projectConfigFile !== null) {
387+
$baselinePathHelper = new ParentDirectoryRelativePathHelper(dirname($projectConfigFile));
388+
}
384389
$errorOutput->writeLineFormatted('If the excluded path can sometimes exist, append <fg=cyan>(?)</>');
385390
$errorOutput->writeLineFormatted('to its config entry to mark it as optional. Example:');
386391
$errorOutput->writeLineFormatted('');
@@ -389,7 +394,12 @@ public static function begin(
389394
foreach ($suggestOptional as $key => $suggestOptionalPaths) {
390395
$errorOutput->writeLineFormatted(sprintf("\t\t<fg=cyan>%s:</>", $key));
391396
foreach ($suggestOptionalPaths as $suggestOptionalPath) {
392-
$errorOutput->writeLineFormatted(sprintf("\t\t\t- <fg=cyan>%s (?)</>", $suggestOptionalPath));
397+
if ($baselinePathHelper === null) {
398+
$errorOutput->writeLineFormatted(sprintf("\t\t\t- <fg=cyan>%s (?)</>", $suggestOptionalPath));
399+
continue;
400+
}
401+
402+
$errorOutput->writeLineFormatted(sprintf("\t\t\t- <fg=cyan>%s (?)</>", $baselinePathHelper->getRelativePath($suggestOptionalPath)));
393403
}
394404
}
395405
$errorOutput->writeLineFormatted('');

0 commit comments

Comments
 (0)