mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-01 00:40:52 +00:00
Updated Rector to commit 8c439cffaee2124388b4fd03db951f43f10a5359
8c439cffae
[TypeDeclaration] Do not remove multiple docblocks with comment on TypedPropertyFromAssignsRector (#3263)
This commit is contained in:
parent
a8b92bef9a
commit
80b6ffce36
|
@ -3,6 +3,7 @@
|
|||
declare (strict_types=1);
|
||||
namespace Rector\BetterPhpDocParser\PhpDocInfo;
|
||||
|
||||
use PhpParser\Comment;
|
||||
use PhpParser\Comment\Doc;
|
||||
use PhpParser\Node;
|
||||
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode;
|
||||
|
@ -105,6 +106,13 @@ 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);
|
||||
$tokenIterator = new BetterTokenIterator($tokens);
|
||||
|
@ -128,6 +136,34 @@ 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
|
||||
*/
|
||||
|
|
|
@ -52,6 +52,16 @@ 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;
|
||||
});
|
||||
|
|
|
@ -35,6 +35,16 @@ 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!
|
||||
|
|
|
@ -19,12 +19,12 @@ final class VersionResolver
|
|||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = '27d57142d9581209db7809c3e1f50e77140574cb';
|
||||
public const PACKAGE_VERSION = '8c439cffaee2124388b4fd03db951f43f10a5359';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2023-01-03 15:33:12';
|
||||
public const RELEASE_DATE = '2023-01-03 22:09:04';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
|
2
vendor/autoload.php
vendored
2
vendor/autoload.php
vendored
|
@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) {
|
|||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInit481e8c1e1d1a7e59e0ae97967141693f::getLoader();
|
||||
return ComposerAutoloaderInit231b95631e073120e9298da6f3cb60ee::getLoader();
|
||||
|
|
10
vendor/composer/autoload_real.php
vendored
10
vendor/composer/autoload_real.php
vendored
|
@ -2,7 +2,7 @@
|
|||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInit481e8c1e1d1a7e59e0ae97967141693f
|
||||
class ComposerAutoloaderInit231b95631e073120e9298da6f3cb60ee
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
|
@ -22,17 +22,17 @@ class ComposerAutoloaderInit481e8c1e1d1a7e59e0ae97967141693f
|
|||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit481e8c1e1d1a7e59e0ae97967141693f', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInit231b95631e073120e9298da6f3cb60ee', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit481e8c1e1d1a7e59e0ae97967141693f', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit231b95631e073120e9298da6f3cb60ee', 'loadClassLoader'));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit481e8c1e1d1a7e59e0ae97967141693f::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit231b95631e073120e9298da6f3cb60ee::getInitializer($loader));
|
||||
|
||||
$loader->setClassMapAuthoritative(true);
|
||||
$loader->register(true);
|
||||
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInit481e8c1e1d1a7e59e0ae97967141693f::$files;
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInit231b95631e073120e9298da6f3cb60ee::$files;
|
||||
$requireFile = static function ($fileIdentifier, $file) {
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
||||
|
|
8
vendor/composer/autoload_static.php
vendored
8
vendor/composer/autoload_static.php
vendored
|
@ -4,7 +4,7 @@
|
|||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInit481e8c1e1d1a7e59e0ae97967141693f
|
||||
class ComposerStaticInit231b95631e073120e9298da6f3cb60ee
|
||||
{
|
||||
public static $files = array (
|
||||
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
|
||||
|
@ -3063,9 +3063,9 @@ class ComposerStaticInit481e8c1e1d1a7e59e0ae97967141693f
|
|||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit481e8c1e1d1a7e59e0ae97967141693f::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit481e8c1e1d1a7e59e0ae97967141693f::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit481e8c1e1d1a7e59e0ae97967141693f::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit231b95631e073120e9298da6f3cb60ee::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit231b95631e073120e9298da6f3cb60ee::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit231b95631e073120e9298da6f3cb60ee::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user