Updated Rector to commit 7a6531d32db4db72241628feb6f8257e2df3720e

7a6531d32d [Core][Printer] Re-use resolveNewStmts() from BetterStandardPrinter on FormatPerservingPrinter (#3411)
This commit is contained in:
Tomas Votruba 2023-02-25 02:42:36 +00:00
parent 949980905b
commit 105747beb9
6 changed files with 15 additions and 36 deletions

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = '2cca234e54b88d14b9017ec343b3a9804d90a348';
public const PACKAGE_VERSION = '7a6531d32db4db72241628feb6f8257e2df3720e';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2023-02-24 15:30:52';
public const RELEASE_DATE = '2023-02-25 02:38:08';
/**
* @var int
*/

View File

@ -123,7 +123,7 @@ final class BetterStandardPrinter extends Standard implements NodePrinterInterfa
$newStmts = $this->resolveNewStmts($stmts);
$content = parent::printFormatPreserving($newStmts, $origStmts, $origTokens);
// add new line in case of added stmts
if (\count($stmts) !== \count($origStmts) && !StringUtils::isMatch($content, self::NEWLINE_END_REGEX)) {
if (\count($newStmts) !== \count($origStmts) && !StringUtils::isMatch($content, self::NEWLINE_END_REGEX)) {
$content .= $this->nl;
}
if (!$this->mixPhpHtmlDecorator->isRequireReprintInlineHTML()) {

View File

@ -4,9 +4,6 @@ declare (strict_types=1);
namespace Rector\Core\PhpParser\Printer;
use PhpParser\Node;
use PhpParser\Node\Stmt;
use PhpParser\Node\Stmt\Namespace_;
use Rector\Core\PhpParser\Node\CustomNode\FileWithoutNamespace;
use Rector\Core\ValueObject\Application\File;
use RectorPrefix202302\Symfony\Component\Filesystem\Filesystem;
/**
@ -46,28 +43,10 @@ final class FormatPerservingPrinter
}
public function printParsedStmstAndTokensToString(File $file) : string
{
$newStmts = $this->resolveNewStmts($file);
return $this->betterStandardPrinter->printFormatPreserving($newStmts, $file->getOldStmts(), $file->getOldTokens());
return $this->betterStandardPrinter->printFormatPreserving($file->getNewStmts(), $file->getOldStmts(), $file->getOldTokens());
}
public function printParsedStmstAndTokens(File $file) : string
{
$newStmts = $this->resolveNewStmts($file);
return $this->printToFile($file->getFilePath(), $newStmts, $file->getOldStmts(), $file->getOldTokens());
}
/**
* @return Stmt[]|mixed[]
*/
private function resolveNewStmts(File $file) : array
{
$newStmts = $file->getNewStmts();
if (\count($newStmts) !== 1) {
return $newStmts;
}
/** @var Namespace_|FileWithoutNamespace $onlyStmt */
$onlyStmt = $newStmts[0];
if (!$onlyStmt instanceof FileWithoutNamespace) {
return $newStmts;
}
return $onlyStmt->stmts;
return $this->printToFile($file->getFilePath(), $file->getNewStmts(), $file->getOldStmts(), $file->getOldTokens());
}
}

2
vendor/autoload.php vendored
View File

@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) {
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInit916c90a106fbfd244faef021e7e06d3e::getLoader();
return ComposerAutoloaderInit679bd58aa1f6675bcf4835931cf4d324::getLoader();

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit916c90a106fbfd244faef021e7e06d3e
class ComposerAutoloaderInit679bd58aa1f6675bcf4835931cf4d324
{
private static $loader;
@ -22,17 +22,17 @@ class ComposerAutoloaderInit916c90a106fbfd244faef021e7e06d3e
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit916c90a106fbfd244faef021e7e06d3e', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit679bd58aa1f6675bcf4835931cf4d324', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInit916c90a106fbfd244faef021e7e06d3e', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit679bd58aa1f6675bcf4835931cf4d324', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit916c90a106fbfd244faef021e7e06d3e::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit679bd58aa1f6675bcf4835931cf4d324::getInitializer($loader));
$loader->setClassMapAuthoritative(true);
$loader->register(true);
$filesToLoad = \Composer\Autoload\ComposerStaticInit916c90a106fbfd244faef021e7e06d3e::$files;
$filesToLoad = \Composer\Autoload\ComposerStaticInit679bd58aa1f6675bcf4835931cf4d324::$files;
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;

View File

@ -4,7 +4,7 @@
namespace Composer\Autoload;
class ComposerStaticInit916c90a106fbfd244faef021e7e06d3e
class ComposerStaticInit679bd58aa1f6675bcf4835931cf4d324
{
public static $files = array (
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
@ -3125,9 +3125,9 @@ class ComposerStaticInit916c90a106fbfd244faef021e7e06d3e
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit916c90a106fbfd244faef021e7e06d3e::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit916c90a106fbfd244faef021e7e06d3e::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit916c90a106fbfd244faef021e7e06d3e::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit679bd58aa1f6675bcf4835931cf4d324::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit679bd58aa1f6675bcf4835931cf4d324::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit679bd58aa1f6675bcf4835931cf4d324::$classMap;
}, null, ClassLoader::class);
}