Updated Rector to commit defd4e28f80c0d022fe83a820d7f0d9057305d41

defd4e28f8 [DX] Avoid supporting edge-case multi-layered comments, must be covered in php-parser itself (#4743)
This commit is contained in:
Tomas Votruba 2023-08-09 15:06:44 +00:00
parent b8ff28ebbf
commit ce7b821341
7 changed files with 13 additions and 70 deletions

View File

@ -3,7 +3,6 @@
declare (strict_types=1);
namespace Rector\BetterPhpDocParser\PhpDocInfo;
use PhpParser\Comment;
use PhpParser\Comment\Doc;
use PhpParser\Node;
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode;
@ -106,15 +105,7 @@ final class PhpDocInfoFactory
$tokenIterator = new BetterTokenIterator([]);
$phpDocNode = new PhpDocNode([]);
} else {
$comments = $node->getComments();
$docs = \array_filter($comments, static function (Comment $comment) : bool {
return $comment instanceof Doc;
});
if (\count($docs) > 1) {
$this->storePreviousDocs($node, $comments, $docComment);
}
$text = $docComment->getText();
$tokens = $this->lexer->tokenize($text);
$tokens = $this->lexer->tokenize($docComment->getText());
$tokenIterator = new BetterTokenIterator($tokens);
$phpDocNode = $this->betterPhpDocParser->parse($tokenIterator);
$this->setPositionOfLastToken($phpDocNode);
@ -136,34 +127,6 @@ final class PhpDocInfoFactory
$phpDocInfo->makeMultiLined();
return $phpDocInfo;
}
/**
* @param Comment[]|Doc[] $comments
*/
private function storePreviousDocs(Node $node, array $comments, Doc $doc) : void
{
$previousDocsAsComments = [];
$newMainDoc = null;
foreach ($comments as $comment) {
// On last Doc, stop
if ($comment === $doc) {
break;
}
// pure comment
if (!$comment instanceof Doc) {
$previousDocsAsComments[] = $comment;
continue;
}
// make Doc as comment Doc that not last
$previousDocsAsComments[] = new Comment($comment->getText(), $comment->getStartLine(), $comment->getStartFilePos(), $comment->getStartTokenPos(), $comment->getEndLine(), $comment->getEndFilePos(), $comment->getEndTokenPos());
/**
* Make last Doc before main Doc to candidate main Doc
* so it can immediatelly be used as replacement of Main doc when main doc removed
*/
$newMainDoc = $comment;
}
$node->setAttribute(AttributeKey::PREVIOUS_DOCS_AS_COMMENTS, $previousDocsAsComments);
$node->setAttribute(AttributeKey::NEW_MAIN_DOC, $newMainDoc);
}
/**
* Needed for printing
*/

View File

@ -52,16 +52,6 @@ final class DocBlockUpdater
}
private function setCommentsAttribute(Node $node) : void
{
if ($node->hasAttribute(AttributeKey::PREVIOUS_DOCS_AS_COMMENTS)) {
/** @var Comment[] $previousDocsAsComments */
$previousDocsAsComments = $node->getAttribute(AttributeKey::PREVIOUS_DOCS_AS_COMMENTS);
$node->setAttribute(AttributeKey::COMMENTS, $previousDocsAsComments);
}
if ($node->hasAttribute(AttributeKey::NEW_MAIN_DOC)) {
/** @var Doc $newMainDoc */
$newMainDoc = $node->getAttribute(AttributeKey::NEW_MAIN_DOC);
$node->setDocComment($newMainDoc);
}
$comments = \array_filter($node->getComments(), static function (Comment $comment) : bool {
return !$comment instanceof Doc;
});

View File

@ -37,16 +37,6 @@ final class AttributeKey
* @var string
*/
public const COMMENTS = 'comments';
/**
* Cover multi docs
* @var string
*/
public const PREVIOUS_DOCS_AS_COMMENTS = 'previous_docs_as_comments';
/**
* Cover multi docs
* @var string
*/
public const NEW_MAIN_DOC = 'new_main_doc';
/**
* Internal php-parser name.
* Do not change this even if you want!

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = '484a38bf6276567f6810338d2974b43533da199d';
public const PACKAGE_VERSION = 'defd4e28f80c0d022fe83a820d7f0d9057305d41';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2023-08-09 15:37:21';
public const RELEASE_DATE = '2023-08-09 16:02:06';
/**
* @var int
*/

2
vendor/autoload.php vendored
View File

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

View File

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