From c553da1f2ef91a936bb28f8c2f53270b2227852b Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Sun, 9 Jan 2022 14:45:03 +0000 Subject: [PATCH] Updated Rector to commit 3fd890bd89401bfe84259501a2b6e6ae90539399 https://github.com/rectorphp/rector-src/commit/3fd890bd89401bfe84259501a2b6e6ae90539399 [Core] Reduce getNewStmts() call on FormatPerservingPrinter (#1652) --- src/Application/VersionResolver.php | 4 ++-- .../Printer/FormatPerservingPrinter.php | 16 ++++++++++------ vendor/autoload.php | 2 +- vendor/composer/autoload_real.php | 14 +++++++------- vendor/composer/autoload_static.php | 8 ++++---- vendor/scoper-autoload.php | 10 +++++----- 6 files changed, 29 insertions(+), 25 deletions(-) diff --git a/src/Application/VersionResolver.php b/src/Application/VersionResolver.php index 46815822c25..8e2a3a18d0c 100644 --- a/src/Application/VersionResolver.php +++ b/src/Application/VersionResolver.php @@ -16,11 +16,11 @@ final class VersionResolver /** * @var string */ - public const PACKAGE_VERSION = '6cc687059719ed962c18b08ea173b71714f215cf'; + public const PACKAGE_VERSION = '3fd890bd89401bfe84259501a2b6e6ae90539399'; /** * @var string */ - public const RELEASE_DATE = '2022-01-09 14:23:45'; + public const RELEASE_DATE = '2022-01-09 14:38:49'; public static function resolvePackageVersion() : string { $process = new \RectorPrefix20220109\Symfony\Component\Process\Process(['git', 'log', '--pretty="%H"', '-n1', 'HEAD'], __DIR__); diff --git a/src/PhpParser/Printer/FormatPerservingPrinter.php b/src/PhpParser/Printer/FormatPerservingPrinter.php index f2a06105fc1..c8648533c77 100644 --- a/src/PhpParser/Printer/FormatPerservingPrinter.php +++ b/src/PhpParser/Printer/FormatPerservingPrinter.php @@ -5,6 +5,7 @@ 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 Symplify\SmartFileSystem\SmartFileInfo; @@ -56,12 +57,15 @@ final class FormatPerservingPrinter */ private function resolveNewStmts(\Rector\Core\ValueObject\Application\File $file) : array { - if (\count($file->getNewStmts()) === 1) { - $onlyStmt = $file->getNewStmts()[0]; - if ($onlyStmt instanceof \Rector\Core\PhpParser\Node\CustomNode\FileWithoutNamespace) { - return $onlyStmt->stmts; - } + $newStmts = $file->getNewStmts(); + if (\count($newStmts) !== 1) { + return $newStmts; } - return $file->getNewStmts(); + /** @var Namespace_|FileWithoutNamespace $onlyStmt */ + $onlyStmt = $newStmts[0]; + if (!$onlyStmt instanceof \Rector\Core\PhpParser\Node\CustomNode\FileWithoutNamespace) { + return $newStmts; + } + return $onlyStmt->stmts; } } diff --git a/vendor/autoload.php b/vendor/autoload.php index 60ed0006b0c..2b83e9978bb 100644 --- a/vendor/autoload.php +++ b/vendor/autoload.php @@ -4,4 +4,4 @@ require_once __DIR__ . '/composer/autoload_real.php'; -return ComposerAutoloaderInit3a0b39f3a8637b74e3b7a9b05527d3c4::getLoader(); +return ComposerAutoloaderInit4f7b69cbb5796824b7fcf242a658864b::getLoader(); diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php index 00e8e14e60c..d0dc241f553 100644 --- a/vendor/composer/autoload_real.php +++ b/vendor/composer/autoload_real.php @@ -2,7 +2,7 @@ // autoload_real.php @generated by Composer -class ComposerAutoloaderInit3a0b39f3a8637b74e3b7a9b05527d3c4 +class ComposerAutoloaderInit4f7b69cbb5796824b7fcf242a658864b { private static $loader; @@ -22,15 +22,15 @@ class ComposerAutoloaderInit3a0b39f3a8637b74e3b7a9b05527d3c4 return self::$loader; } - spl_autoload_register(array('ComposerAutoloaderInit3a0b39f3a8637b74e3b7a9b05527d3c4', 'loadClassLoader'), true, true); + spl_autoload_register(array('ComposerAutoloaderInit4f7b69cbb5796824b7fcf242a658864b', 'loadClassLoader'), true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__))); - spl_autoload_unregister(array('ComposerAutoloaderInit3a0b39f3a8637b74e3b7a9b05527d3c4', 'loadClassLoader')); + spl_autoload_unregister(array('ComposerAutoloaderInit4f7b69cbb5796824b7fcf242a658864b', 'loadClassLoader')); $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); if ($useStaticLoader) { require __DIR__ . '/autoload_static.php'; - call_user_func(\Composer\Autoload\ComposerStaticInit3a0b39f3a8637b74e3b7a9b05527d3c4::getInitializer($loader)); + call_user_func(\Composer\Autoload\ComposerStaticInit4f7b69cbb5796824b7fcf242a658864b::getInitializer($loader)); } else { $classMap = require __DIR__ . '/autoload_classmap.php'; if ($classMap) { @@ -42,12 +42,12 @@ class ComposerAutoloaderInit3a0b39f3a8637b74e3b7a9b05527d3c4 $loader->register(true); if ($useStaticLoader) { - $includeFiles = Composer\Autoload\ComposerStaticInit3a0b39f3a8637b74e3b7a9b05527d3c4::$files; + $includeFiles = Composer\Autoload\ComposerStaticInit4f7b69cbb5796824b7fcf242a658864b::$files; } else { $includeFiles = require __DIR__ . '/autoload_files.php'; } foreach ($includeFiles as $fileIdentifier => $file) { - composerRequire3a0b39f3a8637b74e3b7a9b05527d3c4($fileIdentifier, $file); + composerRequire4f7b69cbb5796824b7fcf242a658864b($fileIdentifier, $file); } return $loader; @@ -59,7 +59,7 @@ class ComposerAutoloaderInit3a0b39f3a8637b74e3b7a9b05527d3c4 * @param string $file * @return void */ -function composerRequire3a0b39f3a8637b74e3b7a9b05527d3c4($fileIdentifier, $file) +function composerRequire4f7b69cbb5796824b7fcf242a658864b($fileIdentifier, $file) { if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true; diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index 28c29dcdb8a..03e1694e91d 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -4,7 +4,7 @@ namespace Composer\Autoload; -class ComposerStaticInit3a0b39f3a8637b74e3b7a9b05527d3c4 +class ComposerStaticInit4f7b69cbb5796824b7fcf242a658864b { public static $files = array ( '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php', @@ -3853,9 +3853,9 @@ class ComposerStaticInit3a0b39f3a8637b74e3b7a9b05527d3c4 public static function getInitializer(ClassLoader $loader) { return \Closure::bind(function () use ($loader) { - $loader->prefixLengthsPsr4 = ComposerStaticInit3a0b39f3a8637b74e3b7a9b05527d3c4::$prefixLengthsPsr4; - $loader->prefixDirsPsr4 = ComposerStaticInit3a0b39f3a8637b74e3b7a9b05527d3c4::$prefixDirsPsr4; - $loader->classMap = ComposerStaticInit3a0b39f3a8637b74e3b7a9b05527d3c4::$classMap; + $loader->prefixLengthsPsr4 = ComposerStaticInit4f7b69cbb5796824b7fcf242a658864b::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInit4f7b69cbb5796824b7fcf242a658864b::$prefixDirsPsr4; + $loader->classMap = ComposerStaticInit4f7b69cbb5796824b7fcf242a658864b::$classMap; }, null, ClassLoader::class); } diff --git a/vendor/scoper-autoload.php b/vendor/scoper-autoload.php index 4e7fd6414ab..3928506df27 100644 --- a/vendor/scoper-autoload.php +++ b/vendor/scoper-autoload.php @@ -9,8 +9,8 @@ $loader = require_once __DIR__.'/autoload.php'; if (!class_exists('AutoloadIncluder', false) && !interface_exists('AutoloadIncluder', false) && !trait_exists('AutoloadIncluder', false)) { spl_autoload_call('RectorPrefix20220109\AutoloadIncluder'); } -if (!class_exists('ComposerAutoloaderInit3a0b39f3a8637b74e3b7a9b05527d3c4', false) && !interface_exists('ComposerAutoloaderInit3a0b39f3a8637b74e3b7a9b05527d3c4', false) && !trait_exists('ComposerAutoloaderInit3a0b39f3a8637b74e3b7a9b05527d3c4', false)) { - spl_autoload_call('RectorPrefix20220109\ComposerAutoloaderInit3a0b39f3a8637b74e3b7a9b05527d3c4'); +if (!class_exists('ComposerAutoloaderInit4f7b69cbb5796824b7fcf242a658864b', false) && !interface_exists('ComposerAutoloaderInit4f7b69cbb5796824b7fcf242a658864b', false) && !trait_exists('ComposerAutoloaderInit4f7b69cbb5796824b7fcf242a658864b', false)) { + spl_autoload_call('RectorPrefix20220109\ComposerAutoloaderInit4f7b69cbb5796824b7fcf242a658864b'); } if (!class_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false) && !interface_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false) && !trait_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false)) { spl_autoload_call('RectorPrefix20220109\Helmich\TypoScriptParser\Parser\AST\Statement'); @@ -71,9 +71,9 @@ if (!function_exists('print_node')) { return \RectorPrefix20220109\print_node(...func_get_args()); } } -if (!function_exists('composerRequire3a0b39f3a8637b74e3b7a9b05527d3c4')) { - function composerRequire3a0b39f3a8637b74e3b7a9b05527d3c4() { - return \RectorPrefix20220109\composerRequire3a0b39f3a8637b74e3b7a9b05527d3c4(...func_get_args()); +if (!function_exists('composerRequire4f7b69cbb5796824b7fcf242a658864b')) { + function composerRequire4f7b69cbb5796824b7fcf242a658864b() { + return \RectorPrefix20220109\composerRequire4f7b69cbb5796824b7fcf242a658864b(...func_get_args()); } } if (!function_exists('scanPath')) {