Skip to content

Commit

Permalink
Updated Rector to commit e37a659d4bbcdb540157a3034e8abef30e5f77bf
Browse files Browse the repository at this point in the history
rectorphp/rector-src@e37a659 [DX] Add links to open the editor to the names of processed files and the names of rules applied (#6272)
  • Loading branch information
TomasVotruba committed Oct 11, 2024
1 parent 24d2df8 commit 318d8c9
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/Application/VersionResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = '2b8cf93121045df5548684660ce7ae06b23b0e50';
public const PACKAGE_VERSION = 'e37a659d4bbcdb540157a3034e8abef30e5f77bf';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2024-10-11 22:10:47';
public const RELEASE_DATE = '2024-10-11 18:23:19';
/**
* @var int
*/
Expand Down
15 changes: 14 additions & 1 deletion src/ChangesReporting/Output/ConsoleOutputFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@

use RectorPrefix202410\Nette\Utils\Strings;
use Rector\ChangesReporting\Contract\Output\OutputFormatterInterface;
use Rector\Configuration\Option;
use Rector\Configuration\Parameter\SimpleParameterProvider;
use Rector\ValueObject\Configuration;
use Rector\ValueObject\Error\SystemError;
use Rector\ValueObject\ProcessResult;
use Rector\ValueObject\Reporting\FileDiff;
use RectorPrefix202410\Symfony\Component\Console\Formatter\OutputFormatter;
use RectorPrefix202410\Symfony\Component\Console\Style\SymfonyStyle;
final class ConsoleOutputFormatter implements OutputFormatterInterface
{
Expand Down Expand Up @@ -70,7 +73,8 @@ private function reportFileDiffs(array $fileDiffs, bool $absoluteFilePath) : voi
if ($firstLineNumber !== null) {
$filePath .= ':' . $firstLineNumber;
}
$message = \sprintf('<options=bold>%d) %s</>', ++$i, $filePath);
$filePathWithUrl = $this->addEditorUrl($filePath, $fileDiff->getAbsoluteFilePath(), $fileDiff->getRelativeFilePath(), (string) $fileDiff->getFirstLineNumber());
$message = \sprintf('<options=bold>%d) %s</>', ++$i, $filePathWithUrl);
$this->symfonyStyle->writeln($message);
$this->symfonyStyle->newLine();
$this->symfonyStyle->writeln($fileDiff->getDiffConsoleFormatted());
Expand Down Expand Up @@ -111,4 +115,13 @@ private function createSuccessMessage(ProcessResult $processResult, Configuratio
}
return \sprintf('%d file%s %s by Rector', $changeCount, $changeCount > 1 ? 's' : '', $configuration->isDryRun() ? 'would have been changed (dry-run)' : ($changeCount === 1 ? 'has' : 'have') . ' been changed');
}
private function addEditorUrl(string $filePath, ?string $absoluteFilePath, ?string $relativeFilePath, ?string $lineNumber) : string
{
$editorUrl = SimpleParameterProvider::provideStringParameter(Option::EDITOR_URL, '');
if ($editorUrl !== '') {
$editorUrl = \str_replace(['%file%', '%relFile%', '%line%'], [$absoluteFilePath, $relativeFilePath, $lineNumber], $editorUrl);
$filePath = '<href=' . OutputFormatter::escape($editorUrl) . '>' . $filePath . '</>';
}
return $filePath;
}
}
4 changes: 4 additions & 0 deletions src/Config/RectorConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,10 @@ public function reportingRealPath(bool $absolute = \true) : void
{
SimpleParameterProvider::setParameter(Option::ABSOLUTE_FILE_PATH, $absolute);
}
public function editorUrl(string $editorUrl) : void
{
SimpleParameterProvider::setParameter(Option::EDITOR_URL, $editorUrl);
}
/**
* @internal Used only for bridge
* @return array<class-string<ConfigurableRectorInterface>, mixed>
Expand Down
6 changes: 6 additions & 0 deletions src/Configuration/Option.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,4 +216,10 @@ final class Option
* @var string
*/
public const ABSOLUTE_FILE_PATH = 'absolute_file_path';
/**
* @internal To add editor links to console output
* @see \Rector\Config\RectorConfig::editorUrl()
* @var string
*/
public const EDITOR_URL = 'editor_url';
}
12 changes: 12 additions & 0 deletions src/Configuration/RectorConfigBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,10 @@ final class RectorConfigBuilder
* @var string[]
*/
private $groupLoadedSets = [];
/**
* @var string|null
*/
private $editorUrl;
/**
* @api soon to be used
* @var bool|null
Expand Down Expand Up @@ -288,6 +292,9 @@ public function __invoke(RectorConfig $rectorConfig) : void
if ($this->reportingRealPath !== null) {
$rectorConfig->reportingRealPath($this->reportingRealPath);
}
if ($this->editorUrl !== null) {
$rectorConfig->editorUrl($this->editorUrl);
}
}
/**
* @param string[] $paths
Expand Down Expand Up @@ -815,4 +822,9 @@ public function withRealPathReporting(bool $absolutePath = \true) : self
$this->reportingRealPath = $absolutePath;
return $this;
}
public function withEditorUrl(string $editorUrl) : self
{
$this->editorUrl = $editorUrl;
return $this;
}
}

0 comments on commit 318d8c9

Please sign in to comment.