mirror of
https://github.com/rectorphp/rector.git
synced 2025-03-14 20:39:43 +01:00
Updated Rector to commit 7e79ae201c4de45815db5d43531e38babfb82786
7e79ae201c
[Cleanup] Remove FormatPerservingPrinter as only delegate method, use BetterStandardPrinter directly (#6036)
This commit is contained in:
parent
10e64410ff
commit
8b4bf1857a
@ -3,6 +3,7 @@
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Application;
|
||||
|
||||
use RectorPrefix202406\Nette\Utils\FileSystem;
|
||||
use RectorPrefix202406\Nette\Utils\Strings;
|
||||
use PHPStan\AnalysedCodeException;
|
||||
use Rector\Caching\Detector\ChangedFilesDetector;
|
||||
@ -13,7 +14,7 @@ use Rector\FileSystem\FilePathHelper;
|
||||
use Rector\NodeTypeResolver\NodeScopeAndMetadataDecorator;
|
||||
use Rector\PhpParser\NodeTraverser\RectorNodeTraverser;
|
||||
use Rector\PhpParser\Parser\RectorParser;
|
||||
use Rector\PhpParser\Printer\FormatPerservingPrinter;
|
||||
use Rector\PhpParser\Printer\BetterStandardPrinter;
|
||||
use Rector\PostRector\Application\PostFileProcessor;
|
||||
use Rector\Testing\PHPUnit\StaticPHPUnitEnvironment;
|
||||
use Rector\ValueObject\Application\File;
|
||||
@ -27,9 +28,9 @@ final class FileProcessor
|
||||
{
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\PhpParser\Printer\FormatPerservingPrinter
|
||||
* @var \Rector\PhpParser\Printer\BetterStandardPrinter
|
||||
*/
|
||||
private $formatPerservingPrinter;
|
||||
private $betterStandardPrinter;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\PhpParser\NodeTraverser\RectorNodeTraverser
|
||||
@ -80,9 +81,9 @@ final class FileProcessor
|
||||
* @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(BetterStandardPrinter $betterStandardPrinter, RectorNodeTraverser $rectorNodeTraverser, SymfonyStyle $symfonyStyle, FileDiffFactory $fileDiffFactory, ChangedFilesDetector $changedFilesDetector, ErrorFactory $errorFactory, FilePathHelper $filePathHelper, PostFileProcessor $postFileProcessor, RectorParser $rectorParser, NodeScopeAndMetadataDecorator $nodeScopeAndMetadataDecorator)
|
||||
{
|
||||
$this->formatPerservingPrinter = $formatPerservingPrinter;
|
||||
$this->betterStandardPrinter = $betterStandardPrinter;
|
||||
$this->rectorNodeTraverser = $rectorNodeTraverser;
|
||||
$this->symfonyStyle = $symfonyStyle;
|
||||
$this->fileDiffFactory = $fileDiffFactory;
|
||||
@ -156,7 +157,7 @@ final class FileProcessor
|
||||
private function printFile(File $file, Configuration $configuration, string $filePath) : void
|
||||
{
|
||||
// only save to string first, no need to print to file when not needed
|
||||
$newContent = $this->formatPerservingPrinter->printParsedStmstAndTokensToString($file);
|
||||
$newContent = $this->betterStandardPrinter->printFormatPreserving($file->getNewStmts(), $file->getOldStmts(), $file->getOldTokens());
|
||||
/**
|
||||
* When no diff applied, the PostRector may still change the content, that's why printing still needed
|
||||
* On printing, the space may be wiped, these below check compare with original file content used to verify
|
||||
@ -186,7 +187,7 @@ final class FileProcessor
|
||||
if (!$file->hasChanged()) {
|
||||
return;
|
||||
}
|
||||
$this->formatPerservingPrinter->dumpFile($filePath, $newContent);
|
||||
FileSystem::write($filePath, $newContent, null);
|
||||
}
|
||||
private function parseFileNodes(File $file) : void
|
||||
{
|
||||
|
@ -19,12 +19,12 @@ final class VersionResolver
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = '87411545f3ddb40fef7cbefcac5b7a0d3c511242';
|
||||
public const PACKAGE_VERSION = '7e79ae201c4de45815db5d43531e38babfb82786';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2024-06-26 03:32:49';
|
||||
public const RELEASE_DATE = '2024-06-26 05:40:56';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
@ -1,44 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\PhpParser\Printer;
|
||||
|
||||
use RectorPrefix202406\Nette\Utils\FileSystem;
|
||||
use PhpParser\Node;
|
||||
use Rector\ValueObject\Application\File;
|
||||
/**
|
||||
* @see \Rector\Tests\PhpParser\Printer\FormatPerservingPrinterTest
|
||||
*/
|
||||
final class FormatPerservingPrinter
|
||||
{
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\PhpParser\Printer\BetterStandardPrinter
|
||||
*/
|
||||
private $betterStandardPrinter;
|
||||
public function __construct(\Rector\PhpParser\Printer\BetterStandardPrinter $betterStandardPrinter)
|
||||
{
|
||||
$this->betterStandardPrinter = $betterStandardPrinter;
|
||||
}
|
||||
/**
|
||||
* @api tests
|
||||
*
|
||||
* @param Node[] $newStmts
|
||||
* @param Node[] $oldStmts
|
||||
* @param Node[] $oldTokens
|
||||
*/
|
||||
public function printToFile(string $filePath, array $newStmts, array $oldStmts, array $oldTokens) : string
|
||||
{
|
||||
$newContent = $this->betterStandardPrinter->printFormatPreserving($newStmts, $oldStmts, $oldTokens);
|
||||
$this->dumpFile($filePath, $newContent);
|
||||
return $newContent;
|
||||
}
|
||||
public function printParsedStmstAndTokensToString(File $file) : string
|
||||
{
|
||||
return $this->betterStandardPrinter->printFormatPreserving($file->getNewStmts(), $file->getOldStmts(), $file->getOldTokens());
|
||||
}
|
||||
public function dumpFile(string $filePath, string $newContent) : void
|
||||
{
|
||||
FileSystem::write($filePath, $newContent, null);
|
||||
}
|
||||
}
|
1
vendor/composer/autoload_classmap.php
vendored
1
vendor/composer/autoload_classmap.php
vendored
@ -1999,7 +1999,6 @@ return array(
|
||||
'Rector\\PhpParser\\Parser\\RectorParser' => $baseDir . '/src/PhpParser/Parser/RectorParser.php',
|
||||
'Rector\\PhpParser\\Parser\\SimplePhpParser' => $baseDir . '/src/PhpParser/Parser/SimplePhpParser.php',
|
||||
'Rector\\PhpParser\\Printer\\BetterStandardPrinter' => $baseDir . '/src/PhpParser/Printer/BetterStandardPrinter.php',
|
||||
'Rector\\PhpParser\\Printer\\FormatPerservingPrinter' => $baseDir . '/src/PhpParser/Printer/FormatPerservingPrinter.php',
|
||||
'Rector\\PhpParser\\ValueObject\\StmtsAndTokens' => $baseDir . '/src/PhpParser/ValueObject/StmtsAndTokens.php',
|
||||
'Rector\\Php\\PhpVersionProvider' => $baseDir . '/src/Php/PhpVersionProvider.php',
|
||||
'Rector\\Php\\PhpVersionResolver\\ProjectComposerJsonPhpVersionResolver' => $baseDir . '/src/Php/PhpVersionResolver/ProjectComposerJsonPhpVersionResolver.php',
|
||||
|
1
vendor/composer/autoload_static.php
vendored
1
vendor/composer/autoload_static.php
vendored
@ -2218,7 +2218,6 @@ class ComposerStaticInitd98d3a989b9f99591f8f5a74c164268a
|
||||
'Rector\\PhpParser\\Parser\\RectorParser' => __DIR__ . '/../..' . '/src/PhpParser/Parser/RectorParser.php',
|
||||
'Rector\\PhpParser\\Parser\\SimplePhpParser' => __DIR__ . '/../..' . '/src/PhpParser/Parser/SimplePhpParser.php',
|
||||
'Rector\\PhpParser\\Printer\\BetterStandardPrinter' => __DIR__ . '/../..' . '/src/PhpParser/Printer/BetterStandardPrinter.php',
|
||||
'Rector\\PhpParser\\Printer\\FormatPerservingPrinter' => __DIR__ . '/../..' . '/src/PhpParser/Printer/FormatPerservingPrinter.php',
|
||||
'Rector\\PhpParser\\ValueObject\\StmtsAndTokens' => __DIR__ . '/../..' . '/src/PhpParser/ValueObject/StmtsAndTokens.php',
|
||||
'Rector\\Php\\PhpVersionProvider' => __DIR__ . '/../..' . '/src/Php/PhpVersionProvider.php',
|
||||
'Rector\\Php\\PhpVersionResolver\\ProjectComposerJsonPhpVersionResolver' => __DIR__ . '/../..' . '/src/Php/PhpVersionResolver/ProjectComposerJsonPhpVersionResolver.php',
|
||||
|
Loading…
x
Reference in New Issue
Block a user