mirror of https://github.com/rectorphp/rector.git
Updated Rector to commit bdc09071abc58550a41fdd8a4af515206e022f4c
bdc09071ab
fix: Strip left spaces from opening tags when comparing output for changes (#5701)
This commit is contained in:
parent
2ede0d9e01
commit
0b4029ea85
|
@ -23,6 +23,7 @@ use Rector\ValueObject\FileProcessResult;
|
|||
use Rector\ValueObject\Reporting\FileDiff;
|
||||
use RectorPrefix202403\Symfony\Component\Console\Style\SymfonyStyle;
|
||||
use Throwable;
|
||||
use RectorPrefix202403\Nette\Utils\Strings;
|
||||
final class FileProcessor
|
||||
{
|
||||
/**
|
||||
|
@ -75,6 +76,11 @@ final class FileProcessor
|
|||
* @var \Rector\NodeTypeResolver\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)
|
||||
{
|
||||
$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
|
||||
* On very first content level
|
||||
*/
|
||||
$originalFileContent = $file->getOriginalFileContent();
|
||||
$ltrimOriginalFileContent = \ltrim($originalFileContent);
|
||||
$ltrimOriginalFileContent = \ltrim($file->getOriginalFileContent());
|
||||
if ($ltrimOriginalFileContent === $newContent) {
|
||||
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
|
||||
$file->changeFileContent($newContent);
|
||||
|
|
|
@ -19,12 +19,12 @@ final class VersionResolver
|
|||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = 'e4b6ee63140c90c18f1fa51156ccffa569f1062c';
|
||||
public const PACKAGE_VERSION = 'bdc09071abc58550a41fdd8a4af515206e022f4c';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2024-03-10 00:27:19';
|
||||
public const RELEASE_DATE = '2024-03-10 16:21:31';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue