diff --git a/src/Application/FileProcessor.php b/src/Application/FileProcessor.php index 95591a25c6e..427e912ffb3 100644 --- a/src/Application/FileProcessor.php +++ b/src/Application/FileProcessor.php @@ -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 getOriginalFileContent(); - $ltrimOriginalFileContent = \ltrim($originalFileContent); + $ltrimOriginalFileContent = \ltrim($file->getOriginalFileContent()); if ($ltrimOriginalFileContent === $newContent) { return; } + // handle space before hasChanged() based on new content $file->changeFileContent($newContent); diff --git a/src/Application/VersionResolver.php b/src/Application/VersionResolver.php index ae359e0af7c..26ea034af26 100644 --- a/src/Application/VersionResolver.php +++ b/src/Application/VersionResolver.php @@ -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 */