Updated Rector to commit 05c4367a51af6f0d4c56a9ab466aa32a873acc83

05c4367a51 [Printer] Reduce parent attribute usage on BetterStandardPrinter on print ArrowFunction comment (#3855)
This commit is contained in:
Tomas Votruba 2023-05-15 08:40:30 +00:00
parent 7b0f60a033
commit 4fa709b27b
5 changed files with 31 additions and 38 deletions

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = 'c24338f5dc0d5ea2469f5078692b6e017f2c3641';
public const PACKAGE_VERSION = '05c4367a51af6f0d4c56a9ab466aa32a873acc83';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2023-05-14 23:32:21';
public const RELEASE_DATE = '2023-05-15 10:35:56';
/**
* @var int
*/

View File

@ -167,11 +167,27 @@ final class BetterStandardPrinter extends Standard implements NodePrinterInterfa
protected function p(Node $node, $parentFormatPreserved = \false) : string
{
$content = parent::p($node, $parentFormatPreserved);
if ($node instanceof Expr) {
$content = $this->resolveContentOnExpr($node, $content);
}
return $node->getAttribute(AttributeKey::WRAPPED_IN_PARENTHESES) === \true ? '(' . $content . ')' : $content;
}
protected function pExpr_ArrowFunction(ArrowFunction $arrowFunction) : string
{
if (!$arrowFunction->hasAttribute(AttributeKey::COMMENT_CLOSURE_RETURN_MIRRORED)) {
return parent::pExpr_ArrowFunction($arrowFunction);
}
$expr = $arrowFunction->expr;
/** @var Comment[] $comments */
$comments = $expr->getAttribute(AttributeKey::COMMENTS) ?? [];
if ($comments === []) {
return parent::pExpr_ArrowFunction($arrowFunction);
}
$indent = \str_repeat($this->tabOrSpaceIndentCharacter, $this->indentLevel) . \str_repeat($this->tabOrSpaceIndentCharacter, $this->rectorConfigProvider->getIndentSize());
$text = "\n" . $indent;
foreach ($comments as $key => $comment) {
$commentText = $key > 0 ? $indent . $comment->getText() : $comment->getText();
$text .= $commentText . "\n";
}
return $this->pAttrGroups($arrowFunction->attrGroups, \true) . ($arrowFunction->static ? 'static ' : '') . 'fn' . ($arrowFunction->byRef ? '&' : '') . '(' . $this->pCommaSeparated($arrowFunction->params) . ')' . ($arrowFunction->returnType !== null ? ': ' . $this->p($arrowFunction->returnType) : '') . ' =>' . $text . $indent . $this->p($arrowFunction->expr);
}
/**
* This allows to use both spaces and tabs vs. original space-only
*/
@ -446,29 +462,6 @@ final class BetterStandardPrinter extends Standard implements NodePrinterInterfa
{
return $lNumber->getAttribute(AttributeKey::REPRINT_RAW_VALUE) === \true;
}
private function resolveContentOnExpr(Expr $expr, string $content) : string
{
$parentNode = $expr->getAttribute(AttributeKey::PARENT_NODE);
if (!$parentNode instanceof ArrowFunction) {
return $content;
}
if ($parentNode->expr !== $expr) {
return $content;
}
if (!$parentNode->hasAttribute(AttributeKey::COMMENT_CLOSURE_RETURN_MIRRORED)) {
return $content;
}
/** @var Comment[] $comments */
$comments = $expr->getAttribute(AttributeKey::COMMENTS) ?? [];
if ($comments === []) {
return $content;
}
$text = '';
foreach ($comments as $comment) {
$text .= $comment->getText() . "\n";
}
return $content = $text . $content;
}
/**
* @param Node[] $stmts
* @return Node[]|mixed[]

2
vendor/autoload.php vendored
View File

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

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit2b5576df10ae09f58b40647c833eacd5
class ComposerAutoloaderInit28d0de0afea0c6c088f8d82439e26c4f
{
private static $loader;
@ -22,17 +22,17 @@ class ComposerAutoloaderInit2b5576df10ae09f58b40647c833eacd5
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit2b5576df10ae09f58b40647c833eacd5', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit28d0de0afea0c6c088f8d82439e26c4f', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInit2b5576df10ae09f58b40647c833eacd5', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit28d0de0afea0c6c088f8d82439e26c4f', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit2b5576df10ae09f58b40647c833eacd5::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit28d0de0afea0c6c088f8d82439e26c4f::getInitializer($loader));
$loader->setClassMapAuthoritative(true);
$loader->register(true);
$filesToLoad = \Composer\Autoload\ComposerStaticInit2b5576df10ae09f58b40647c833eacd5::$files;
$filesToLoad = \Composer\Autoload\ComposerStaticInit28d0de0afea0c6c088f8d82439e26c4f::$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 ComposerStaticInit2b5576df10ae09f58b40647c833eacd5
class ComposerStaticInit28d0de0afea0c6c088f8d82439e26c4f
{
public static $files = array (
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
@ -3106,9 +3106,9 @@ class ComposerStaticInit2b5576df10ae09f58b40647c833eacd5
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit2b5576df10ae09f58b40647c833eacd5::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit2b5576df10ae09f58b40647c833eacd5::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit2b5576df10ae09f58b40647c833eacd5::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit28d0de0afea0c6c088f8d82439e26c4f::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit28d0de0afea0c6c088f8d82439e26c4f::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit28d0de0afea0c6c088f8d82439e26c4f::$classMap;
}, null, ClassLoader::class);
}