From fbc4775be78ecbf2e0ee3065a80345907ba4c15d Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Sat, 5 Sep 2026 00:23:56 +0200 Subject: [PATCH] Make JSON output always report absolute paths, deprecate real path reporting Absolute paths are only useful for machine-consumed output, so the JSON formatter now always reports them. The other formatters stay relative. withRealPathReporting() and ECSConfig::reportingRealPath() are kept as deprecation warnings pointing to the JSON output format; the underlying reporting-realpath option and its plumbing are removed. Claude-Session: https://claude.ai/code/session_01A8hvNrf4ZxWkiEjWxecSAa --- config/config.php | 3 +-- src/Config/ECSConfig.php | 8 ++++++-- src/Configuration/ConfigurationFactory.php | 4 +--- src/Configuration/ECSConfigBuilder.php | 17 ++++++++--------- .../Output/CheckstyleOutputFormatter.php | 2 +- src/Console/Output/ConsoleOutputFormatter.php | 2 +- src/Console/Output/GitlabOutputFormatter.php | 6 +++--- src/Console/Output/JUnitOutputFormatter.php | 2 +- src/Console/Output/JsonOutputFormatter.php | 2 +- src/ValueObject/Configuration.php | 8 +------- src/ValueObject/Option.php | 5 ----- 11 files changed, 24 insertions(+), 35 deletions(-) diff --git a/config/config.php b/config/config.php index 396ad37c155..d02e34e0a9d 100644 --- a/config/config.php +++ b/config/config.php @@ -20,5 +20,4 @@ ->withCache(directory: $cacheDirectory, namespace: $cacheNamespace) ->withFileExtensions(['php']) ->withSkip([]) - ->withPaths([]) - ->withRealPathReporting(false); + ->withPaths([]); diff --git a/src/Config/ECSConfig.php b/src/Config/ECSConfig.php index 22b0f041142..39865b75aab 100644 --- a/src/Config/ECSConfig.php +++ b/src/Config/ECSConfig.php @@ -194,10 +194,14 @@ public function disableParallel(): void /** * @api + * @deprecated Real path reporting is deprecated. Use the JSON output format ("--output-format json"), which always reports absolute paths. */ - public function reportingRealPath(bool $absolute = true): void + public function reportingRealPath(): void { - SimpleParameterProvider::setParameter(Option::REPORTING_REALPATH, $absolute); + $outputPrinter = new OutputPrinter(new OutputColorizer()); + $outputPrinter->warning( + 'The "reportingRealPath()" method is deprecated. Use the JSON output format ("--output-format json") to get absolute paths.' + ); } /** diff --git a/src/Configuration/ConfigurationFactory.php b/src/Configuration/ConfigurationFactory.php index 86580802195..031c9cc0a59 100644 --- a/src/Configuration/ConfigurationFactory.php +++ b/src/Configuration/ConfigurationFactory.php @@ -43,7 +43,6 @@ public function create( $showDiffs = ! $noDiffs; $isParallel = SimpleParameterProvider::getBoolParameter(Option::PARALLEL); - $isReportingWithRealPath = SimpleParameterProvider::getBoolParameter(Option::REPORTING_REALPATH); return new Configuration( $isFixer, @@ -57,8 +56,7 @@ public function create( $parallelPort, $parallelIdentifier, $memoryLimit, - $showDiffs, - $isReportingWithRealPath + $showDiffs ); } diff --git a/src/Configuration/ECSConfigBuilder.php b/src/Configuration/ECSConfigBuilder.php index 5695e957cd9..3713e88535a 100644 --- a/src/Configuration/ECSConfigBuilder.php +++ b/src/Configuration/ECSConfigBuilder.php @@ -74,8 +74,6 @@ final class ECSConfigBuilder private int $parallelJobSize = 20; - private ?bool $reportingRealPath = null; - /** * To make sure each common set and its corresponding level are not * duplicated, as both contain the same rules. @@ -159,10 +157,6 @@ public function __invoke(ECSConfig $ecsConfig): void $ecsConfig->disableParallel(); } } - - if ($this->reportingRealPath !== null) { - $ecsConfig->reportingRealPath($this->reportingRealPath); - } } /** @@ -428,10 +422,15 @@ public function withoutParallel(): self return $this; } - public function withRealPathReporting(bool $absolutePath = true): self + /** + * @deprecated Real path reporting is deprecated. Use the JSON output format ("--output-format json"), which always reports absolute paths. + */ + public function withRealPathReporting(): self { - $this->reportingRealPath = $absolutePath; - + $outputPrinter = new OutputPrinter(new OutputColorizer()); + $outputPrinter->warning( + 'The "withRealPathReporting()" method is deprecated. Use the JSON output format ("--output-format json") to get absolute paths.' + ); return $this; } diff --git a/src/Console/Output/CheckstyleOutputFormatter.php b/src/Console/Output/CheckstyleOutputFormatter.php index 59f8a104029..a19f4321bb0 100644 --- a/src/Console/Output/CheckstyleOutputFormatter.php +++ b/src/Console/Output/CheckstyleOutputFormatter.php @@ -31,7 +31,7 @@ public function report(ErrorAndDiffResult $errorAndDiffResult, Configuration $co { $checkstyleContent = $this->createCheckstyleContent( $errorAndDiffResult, - $configuration->isReportingWithRealPath() + false ); $this->easyCodingStandardStyle->writeln($checkstyleContent); diff --git a/src/Console/Output/ConsoleOutputFormatter.php b/src/Console/Output/ConsoleOutputFormatter.php index c29a4e02a00..978943459bb 100644 --- a/src/Console/Output/ConsoleOutputFormatter.php +++ b/src/Console/Output/ConsoleOutputFormatter.php @@ -28,7 +28,7 @@ public function __construct( public function report(ErrorAndDiffResult $errorAndDiffResult, Configuration $configuration): int { if ($configuration->shouldShowDiffs()) { - $this->reportFileDiffs($errorAndDiffResult->getFileDiffs(), $configuration->isReportingWithRealPath()); + $this->reportFileDiffs($errorAndDiffResult->getFileDiffs()); } $this->easyCodingStandardStyle->newLine(1); diff --git a/src/Console/Output/GitlabOutputFormatter.php b/src/Console/Output/GitlabOutputFormatter.php index d8fa34fb59a..877bb49b112 100644 --- a/src/Console/Output/GitlabOutputFormatter.php +++ b/src/Console/Output/GitlabOutputFormatter.php @@ -97,16 +97,16 @@ public function generateReport(ErrorAndDiffResult $errorAndDiffResult, Configura ? merge( $this->generateIssuesForErrors( $errorAndDiffResult->getErrors(), - $configuration->isReportingWithRealPath() + false ), $this->generateIssuesForFixes( $errorAndDiffResult->getFileDiffs(), - $configuration->isReportingWithRealPath() + false ), ) : $this->generateIssuesForErrors( $errorAndDiffResult->getErrors(), - $configuration->isReportingWithRealPath() + false ); return $this->encode($reportedQualityIssues); diff --git a/src/Console/Output/JUnitOutputFormatter.php b/src/Console/Output/JUnitOutputFormatter.php index 95c7b427a1e..5dd065ede41 100644 --- a/src/Console/Output/JUnitOutputFormatter.php +++ b/src/Console/Output/JUnitOutputFormatter.php @@ -27,7 +27,7 @@ public function __construct( */ public function report(ErrorAndDiffResult $errorAndDiffResult, Configuration $configuration): int { - $xml = $this->createXmlOutput($errorAndDiffResult, $configuration->isReportingWithRealPath()); + $xml = $this->createXmlOutput($errorAndDiffResult, false); $this->easyCodingStandardStyle->writeln($xml); return $this->exitCodeResolver->resolve($errorAndDiffResult, $configuration); diff --git a/src/Console/Output/JsonOutputFormatter.php b/src/Console/Output/JsonOutputFormatter.php index 24f3df9a84c..60a221b7b6e 100644 --- a/src/Console/Output/JsonOutputFormatter.php +++ b/src/Console/Output/JsonOutputFormatter.php @@ -29,7 +29,7 @@ public function __construct( */ public function report(ErrorAndDiffResult $errorAndDiffResult, Configuration $configuration): int { - $json = $this->createJsonContent($errorAndDiffResult, $configuration->isReportingWithRealPath()); + $json = $this->createJsonContent($errorAndDiffResult, true); $this->easyCodingStandardStyle->writeln($json); return $this->exitCodeResolver->resolve($errorAndDiffResult, $configuration); diff --git a/src/ValueObject/Configuration.php b/src/ValueObject/Configuration.php index 1536eec2e4e..91d5329eb4d 100644 --- a/src/ValueObject/Configuration.php +++ b/src/ValueObject/Configuration.php @@ -23,8 +23,7 @@ public function __construct( private string|null $parallelPort = null, private string|null $parallelIdentifier = null, private string|null $memoryLimit = null, - private bool $showDiffs = true, - private bool $reportingWithRealPath = false + private bool $showDiffs = true ) { } @@ -90,9 +89,4 @@ public function getMemoryLimit(): ?string { return $this->memoryLimit; } - - public function isReportingWithRealPath(): bool - { - return $this->reportingWithRealPath; - } } diff --git a/src/ValueObject/Option.php b/src/ValueObject/Option.php index d7cfa9022db..1084346da3b 100644 --- a/src/ValueObject/Option.php +++ b/src/ValueObject/Option.php @@ -92,9 +92,4 @@ final class Option * @see \Symplify\EasyCodingStandard\Config\ECSConfig::parallel() */ public const string PARALLEL_TIMEOUT_IN_SECONDS = 'parallel-timeout-in-seconds'; - - /** - * @see \Symplify\EasyCodingStandard\Config\ECSConfig::reportingRealPath() - */ - public const string REPORTING_REALPATH = 'reporting-realpath'; }