Updated Rector to commit bdc09071abc58550a41fdd8a4af515206e022f4c

bdc09071ab fix: Strip left spaces from opening tags when comparing output for changes (#5701)
This commit is contained in:
Tomas Votruba 2024-03-10 09:23:51 +00:00
parent 2ede0d9e01
commit 0b4029ea85
2 changed files with 15 additions and 4 deletions

View File

@ -23,6 +23,7 @@ use Rector\ValueObject\FileProcessResult;
use Rector\ValueObject\Reporting\FileDiff; use Rector\ValueObject\Reporting\FileDiff;
use RectorPrefix202403\Symfony\Component\Console\Style\SymfonyStyle; use RectorPrefix202403\Symfony\Component\Console\Style\SymfonyStyle;
use Throwable; use Throwable;
use RectorPrefix202403\Nette\Utils\Strings;
final class FileProcessor final class FileProcessor
{ {
/** /**
@ -75,6 +76,11 @@ final class FileProcessor
* @var \Rector\NodeTypeResolver\NodeScopeAndMetadataDecorator * @var \Rector\NodeTypeResolver\NodeScopeAndMetadataDecorator
*/ */
private $nodeScopeAndMetadataDecorator; private $nodeScopeAndMetadataDecorator;
/**
* @var string
* @see https://regex101.com/r/llm7XZ/1
*/
private const OPEN_TAG_SPACED_REGEX = '#^[ \\t]+<\\?php#m';
public function __construct(FormatPerservingPrinter $formatPerservingPrinter, RectorNodeTraverser $rectorNodeTraverser, SymfonyStyle $symfonyStyle, FileDiffFactory $fileDiffFactory, ChangedFilesDetector $changedFilesDetector, ErrorFactory $errorFactory, FilePathHelper $filePathHelper, PostFileProcessor $postFileProcessor, RectorParser $rectorParser, NodeScopeAndMetadataDecorator $nodeScopeAndMetadataDecorator) public function __construct(FormatPerservingPrinter $formatPerservingPrinter, RectorNodeTraverser $rectorNodeTraverser, SymfonyStyle $symfonyStyle, FileDiffFactory $fileDiffFactory, ChangedFilesDetector $changedFilesDetector, ErrorFactory $errorFactory, FilePathHelper $filePathHelper, PostFileProcessor $postFileProcessor, RectorParser $rectorParser, NodeScopeAndMetadataDecorator $nodeScopeAndMetadataDecorator)
{ {
$this->formatPerservingPrinter = $formatPerservingPrinter; $this->formatPerservingPrinter = $formatPerservingPrinter;
@ -162,11 +168,16 @@ final class FileProcessor
* Handle new line or space before <?php or InlineHTML node wiped on print format preserving * Handle new line or space before <?php or InlineHTML node wiped on print format preserving
* On very first content level * On very first content level
*/ */
$originalFileContent = $file->getOriginalFileContent(); $ltrimOriginalFileContent = \ltrim($file->getOriginalFileContent());
$ltrimOriginalFileContent = \ltrim($originalFileContent);
if ($ltrimOriginalFileContent === $newContent) { if ($ltrimOriginalFileContent === $newContent) {
return; return;
} }
// handle space before <?php
$ltrimNewContent = Strings::replace($newContent, self::OPEN_TAG_SPACED_REGEX, '<?php');
$ltrimOriginalFileContent = Strings::replace($ltrimOriginalFileContent, self::OPEN_TAG_SPACED_REGEX, '<?php');
if ($ltrimOriginalFileContent === $ltrimNewContent) {
return;
}
} }
// change file content early to make $file->hasChanged() based on new content // change file content early to make $file->hasChanged() based on new content
$file->changeFileContent($newContent); $file->changeFileContent($newContent);

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api * @api
* @var string * @var string
*/ */
public const PACKAGE_VERSION = 'e4b6ee63140c90c18f1fa51156ccffa569f1062c'; public const PACKAGE_VERSION = 'bdc09071abc58550a41fdd8a4af515206e022f4c';
/** /**
* @api * @api
* @var string * @var string
*/ */
public const RELEASE_DATE = '2024-03-10 00:27:19'; public const RELEASE_DATE = '2024-03-10 16:21:31';
/** /**
* @var int * @var int
*/ */