2525use PHPStan \File \FileExcluder ;
2626use PHPStan \File \FileFinder ;
2727use PHPStan \File \FileHelper ;
28+ use PHPStan \File \ParentDirectoryRelativePathHelper ;
2829use PHPStan \File \SimpleRelativePathHelper ;
2930use PHPStan \Internal \ComposerHelper ;
3031use 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