diff --git a/src/PhpParser/Printer/NodesWithFileDestinationPrinter.php b/src/PhpParser/Printer/NodesWithFileDestinationPrinter.php index 07b65b7dca4..7312b88d8e0 100644 --- a/src/PhpParser/Printer/NodesWithFileDestinationPrinter.php +++ b/src/PhpParser/Printer/NodesWithFileDestinationPrinter.php @@ -3,8 +3,6 @@ declare (strict_types=1); namespace Rector\Core\PhpParser\Printer; -use RectorPrefix20210511\Nette\Utils\Strings; -use PhpParser\Lexer; use Rector\FileSystemRector\Contract\FileWithNodesInterface; use Rector\PostRector\Application\PostFileProcessor; final class NodesWithFileDestinationPrinter @@ -13,36 +11,18 @@ final class NodesWithFileDestinationPrinter * @var \Rector\Core\PhpParser\Printer\BetterStandardPrinter */ private $betterStandardPrinter; - /** - * @var \PhpParser\Lexer - */ - private $lexer; /** * @var \Rector\PostRector\Application\PostFileProcessor */ private $postFileProcessor; - public function __construct(\Rector\Core\PhpParser\Printer\BetterStandardPrinter $betterStandardPrinter, \PhpParser\Lexer $lexer, \Rector\PostRector\Application\PostFileProcessor $postFileProcessor) + public function __construct(\Rector\Core\PhpParser\Printer\BetterStandardPrinter $betterStandardPrinter, \Rector\PostRector\Application\PostFileProcessor $postFileProcessor) { $this->betterStandardPrinter = $betterStandardPrinter; - $this->lexer = $lexer; $this->postFileProcessor = $postFileProcessor; } public function printNodesWithFileDestination(\Rector\FileSystemRector\Contract\FileWithNodesInterface $fileWithNodes) : string { $nodes = $this->postFileProcessor->traverse($fileWithNodes->getNodes()); - $prettyPrintContent = $this->betterStandardPrinter->prettyPrintFile($nodes); - return $this->resolveLastEmptyLine($prettyPrintContent); - } - /** - * Add empty line in the end, if it is in the original tokens - */ - private function resolveLastEmptyLine(string $prettyPrintContent) : string - { - $tokens = $this->lexer->getTokens(); - $lastToken = \array_pop($tokens); - if ($lastToken && isset($lastToken[1]) && \RectorPrefix20210511\Nette\Utils\Strings::contains($lastToken[1], "\n")) { - $prettyPrintContent = \trim($prettyPrintContent) . \PHP_EOL; - } - return $prettyPrintContent; + return $this->betterStandardPrinter->prettyPrintFile($nodes); } } diff --git a/vendor/autoload.php b/vendor/autoload.php index 9cfaa8ecff8..b1a0c4fd666 100644 --- a/vendor/autoload.php +++ b/vendor/autoload.php @@ -4,4 +4,4 @@ require_once __DIR__ . '/composer/autoload_real.php'; -return ComposerAutoloaderInit8e0c521d0267706f8265fce5c8f6726f::getLoader(); +return ComposerAutoloaderInit2640128c56620c7437d13afa595f94d5::getLoader(); diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php index 337640cf461..1373c310e61 100644 --- a/vendor/composer/autoload_real.php +++ b/vendor/composer/autoload_real.php @@ -2,7 +2,7 @@ // autoload_real.php @generated by Composer -class ComposerAutoloaderInit8e0c521d0267706f8265fce5c8f6726f +class ComposerAutoloaderInit2640128c56620c7437d13afa595f94d5 { private static $loader; @@ -22,15 +22,15 @@ class ComposerAutoloaderInit8e0c521d0267706f8265fce5c8f6726f return self::$loader; } - spl_autoload_register(array('ComposerAutoloaderInit8e0c521d0267706f8265fce5c8f6726f', 'loadClassLoader'), true, true); + spl_autoload_register(array('ComposerAutoloaderInit2640128c56620c7437d13afa595f94d5', 'loadClassLoader'), true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__))); - spl_autoload_unregister(array('ComposerAutoloaderInit8e0c521d0267706f8265fce5c8f6726f', 'loadClassLoader')); + spl_autoload_unregister(array('ComposerAutoloaderInit2640128c56620c7437d13afa595f94d5', '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\ComposerStaticInit8e0c521d0267706f8265fce5c8f6726f::getInitializer($loader)); + call_user_func(\Composer\Autoload\ComposerStaticInit2640128c56620c7437d13afa595f94d5::getInitializer($loader)); } else { $classMap = require __DIR__ . '/autoload_classmap.php'; if ($classMap) { @@ -42,19 +42,19 @@ class ComposerAutoloaderInit8e0c521d0267706f8265fce5c8f6726f $loader->register(true); if ($useStaticLoader) { - $includeFiles = Composer\Autoload\ComposerStaticInit8e0c521d0267706f8265fce5c8f6726f::$files; + $includeFiles = Composer\Autoload\ComposerStaticInit2640128c56620c7437d13afa595f94d5::$files; } else { $includeFiles = require __DIR__ . '/autoload_files.php'; } foreach ($includeFiles as $fileIdentifier => $file) { - composerRequire8e0c521d0267706f8265fce5c8f6726f($fileIdentifier, $file); + composerRequire2640128c56620c7437d13afa595f94d5($fileIdentifier, $file); } return $loader; } } -function composerRequire8e0c521d0267706f8265fce5c8f6726f($fileIdentifier, $file) +function composerRequire2640128c56620c7437d13afa595f94d5($fileIdentifier, $file) { if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { require $file; diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index f64bae46bd3..28da1c08d96 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -4,7 +4,7 @@ namespace Composer\Autoload; -class ComposerStaticInit8e0c521d0267706f8265fce5c8f6726f +class ComposerStaticInit2640128c56620c7437d13afa595f94d5 { public static $files = array ( 'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php', @@ -3465,9 +3465,9 @@ class ComposerStaticInit8e0c521d0267706f8265fce5c8f6726f public static function getInitializer(ClassLoader $loader) { return \Closure::bind(function () use ($loader) { - $loader->prefixLengthsPsr4 = ComposerStaticInit8e0c521d0267706f8265fce5c8f6726f::$prefixLengthsPsr4; - $loader->prefixDirsPsr4 = ComposerStaticInit8e0c521d0267706f8265fce5c8f6726f::$prefixDirsPsr4; - $loader->classMap = ComposerStaticInit8e0c521d0267706f8265fce5c8f6726f::$classMap; + $loader->prefixLengthsPsr4 = ComposerStaticInit2640128c56620c7437d13afa595f94d5::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInit2640128c56620c7437d13afa595f94d5::$prefixDirsPsr4; + $loader->classMap = ComposerStaticInit2640128c56620c7437d13afa595f94d5::$classMap; }, null, ClassLoader::class); } diff --git a/vendor/scoper-autoload.php b/vendor/scoper-autoload.php index 1302722e2ad..cdc2f05063d 100644 --- a/vendor/scoper-autoload.php +++ b/vendor/scoper-autoload.php @@ -21,8 +21,8 @@ if (!class_exists('SomeTestCase', false) && !interface_exists('SomeTestCase', fa if (!class_exists('CheckoutEntityFactory', false) && !interface_exists('CheckoutEntityFactory', false) && !trait_exists('CheckoutEntityFactory', false)) { spl_autoload_call('RectorPrefix20210511\CheckoutEntityFactory'); } -if (!class_exists('ComposerAutoloaderInit8e0c521d0267706f8265fce5c8f6726f', false) && !interface_exists('ComposerAutoloaderInit8e0c521d0267706f8265fce5c8f6726f', false) && !trait_exists('ComposerAutoloaderInit8e0c521d0267706f8265fce5c8f6726f', false)) { - spl_autoload_call('RectorPrefix20210511\ComposerAutoloaderInit8e0c521d0267706f8265fce5c8f6726f'); +if (!class_exists('ComposerAutoloaderInit2640128c56620c7437d13afa595f94d5', false) && !interface_exists('ComposerAutoloaderInit2640128c56620c7437d13afa595f94d5', false) && !trait_exists('ComposerAutoloaderInit2640128c56620c7437d13afa595f94d5', false)) { + spl_autoload_call('RectorPrefix20210511\ComposerAutoloaderInit2640128c56620c7437d13afa595f94d5'); } if (!class_exists('Doctrine\Inflector\Inflector', false) && !interface_exists('Doctrine\Inflector\Inflector', false) && !trait_exists('Doctrine\Inflector\Inflector', false)) { spl_autoload_call('RectorPrefix20210511\Doctrine\Inflector\Inflector'); @@ -92,9 +92,9 @@ if (!function_exists('print_node')) { return \RectorPrefix20210511\print_node(...func_get_args()); } } -if (!function_exists('composerRequire8e0c521d0267706f8265fce5c8f6726f')) { - function composerRequire8e0c521d0267706f8265fce5c8f6726f() { - return \RectorPrefix20210511\composerRequire8e0c521d0267706f8265fce5c8f6726f(...func_get_args()); +if (!function_exists('composerRequire2640128c56620c7437d13afa595f94d5')) { + function composerRequire2640128c56620c7437d13afa595f94d5() { + return \RectorPrefix20210511\composerRequire2640128c56620c7437d13afa595f94d5(...func_get_args()); } } if (!function_exists('parseArgs')) {