mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-20 01:52:22 +00:00
Updated Rector to commit 715a047989a3b2def0f9e62879c906da61e39cc6
715a047989
Skip description on same line, remove on next line as based on phpdoc-parser in RemoveUselessParamTagRector (#4551)
This commit is contained in:
parent
5a211089b1
commit
37853424d5
|
@ -3,19 +3,12 @@
|
|||
declare (strict_types=1);
|
||||
namespace Rector\DeadCode\PhpDoc;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\FunctionLike;
|
||||
use PhpParser\Node\Name;
|
||||
use PhpParser\Node\Name\FullyQualified;
|
||||
use PhpParser\Node\Param;
|
||||
use PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode;
|
||||
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocChildNode;
|
||||
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode;
|
||||
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode;
|
||||
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTextNode;
|
||||
use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode;
|
||||
use Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger;
|
||||
use Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey;
|
||||
use Rector\BetterPhpDocParser\ValueObject\Type\BracketsAwareUnionTypeNode;
|
||||
use Rector\DeadCode\TypeNodeAnalyzer\GenericTypeNodeAnalyzer;
|
||||
use Rector\DeadCode\TypeNodeAnalyzer\MixedArrayTypeNodeAnalyzer;
|
||||
|
@ -82,64 +75,14 @@ final class DeadParamTagValueNodeAnalyzer
|
|||
return \false;
|
||||
}
|
||||
if (!$paramTagValueNode->type instanceof BracketsAwareUnionTypeNode) {
|
||||
return $this->isEmptyDescription($paramTagValueNode, $param->type);
|
||||
return $paramTagValueNode->description === '';
|
||||
}
|
||||
if ($this->mixedArrayTypeNodeAnalyzer->hasMixedArrayType($paramTagValueNode->type)) {
|
||||
return \false;
|
||||
}
|
||||
if (!$this->genericTypeNodeAnalyzer->hasGenericType($paramTagValueNode->type)) {
|
||||
return $this->isEmptyDescription($paramTagValueNode, $param->type);
|
||||
return $paramTagValueNode->description === '';
|
||||
}
|
||||
return \false;
|
||||
}
|
||||
private function isEmptyDescription(ParamTagValueNode $paramTagValueNode, Node $node) : bool
|
||||
{
|
||||
if ($paramTagValueNode->description !== '') {
|
||||
return \false;
|
||||
}
|
||||
$parentNode = $paramTagValueNode->getAttribute(PhpDocAttributeKey::PARENT);
|
||||
if (!$parentNode instanceof PhpDocTagNode) {
|
||||
return \true;
|
||||
}
|
||||
$parentNode = $parentNode->getAttribute(PhpDocAttributeKey::PARENT);
|
||||
if (!$parentNode instanceof PhpDocNode) {
|
||||
return \true;
|
||||
}
|
||||
$children = $parentNode->children;
|
||||
foreach ($children as $key => $child) {
|
||||
if ($child instanceof PhpDocTagNode && $node instanceof FullyQualified) {
|
||||
return $this->isUnionIdentifier($child);
|
||||
}
|
||||
if (!$this->isTextNextline($key, $child)) {
|
||||
return \false;
|
||||
}
|
||||
}
|
||||
return \true;
|
||||
}
|
||||
private function isTextNextline(int $key, PhpDocChildNode $phpDocChildNode) : bool
|
||||
{
|
||||
if ($key < 1) {
|
||||
return \true;
|
||||
}
|
||||
if (!$phpDocChildNode instanceof PhpDocTextNode) {
|
||||
return \true;
|
||||
}
|
||||
return (string) $phpDocChildNode === '';
|
||||
}
|
||||
private function isUnionIdentifier(PhpDocTagNode $phpDocTagNode) : bool
|
||||
{
|
||||
if (!$phpDocTagNode->value instanceof ParamTagValueNode) {
|
||||
return \true;
|
||||
}
|
||||
if (!$phpDocTagNode->value->type instanceof BracketsAwareUnionTypeNode) {
|
||||
return \true;
|
||||
}
|
||||
$types = $phpDocTagNode->value->type->types;
|
||||
foreach ($types as $type) {
|
||||
if ($type instanceof IdentifierTypeNode) {
|
||||
return \false;
|
||||
}
|
||||
}
|
||||
return \true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ use PhpParser\Node\FunctionLike;
|
|||
use PHPStan\PhpDocParser\Ast\Node;
|
||||
use PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode;
|
||||
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode;
|
||||
use PHPStan\PhpDocParser\Ast\Type\UnionTypeNode;
|
||||
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo;
|
||||
use Rector\DeadCode\PhpDoc\DeadParamTagValueNodeAnalyzer;
|
||||
use Rector\PhpDocParser\PhpDocParser\PhpDocNodeTraverser;
|
||||
|
@ -36,6 +37,10 @@ final class ParamTagRemover
|
|||
if ($docNode->name !== '@param') {
|
||||
return null;
|
||||
}
|
||||
// skip union types
|
||||
if ($docNode->value->type instanceof UnionTypeNode) {
|
||||
return null;
|
||||
}
|
||||
if (!$this->deadParamTagValueNodeAnalyzer->isDead($docNode->value, $functionLike)) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -19,12 +19,12 @@ final class VersionResolver
|
|||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = '8c5507f3e83e70657f95ae9ccb6488732b0359f5';
|
||||
public const PACKAGE_VERSION = '715a047989a3b2def0f9e62879c906da61e39cc6';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2023-07-20 12:18:17';
|
||||
public const RELEASE_DATE = '2023-07-20 13:02:31';
|
||||
/**
|
||||
* @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 ComposerAutoloaderIniteac56325223dabb3fdf738e61e520d37::getLoader();
|
||||
return ComposerAutoloaderInitccbfa8587eb1d8ee1c4fdf9327e0157b::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 ComposerAutoloaderIniteac56325223dabb3fdf738e61e520d37
|
||||
class ComposerAutoloaderInitccbfa8587eb1d8ee1c4fdf9327e0157b
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
|
@ -22,17 +22,17 @@ class ComposerAutoloaderIniteac56325223dabb3fdf738e61e520d37
|
|||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderIniteac56325223dabb3fdf738e61e520d37', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInitccbfa8587eb1d8ee1c4fdf9327e0157b', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderIniteac56325223dabb3fdf738e61e520d37', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInitccbfa8587eb1d8ee1c4fdf9327e0157b', 'loadClassLoader'));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticIniteac56325223dabb3fdf738e61e520d37::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInitccbfa8587eb1d8ee1c4fdf9327e0157b::getInitializer($loader));
|
||||
|
||||
$loader->setClassMapAuthoritative(true);
|
||||
$loader->register(true);
|
||||
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticIniteac56325223dabb3fdf738e61e520d37::$files;
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInitccbfa8587eb1d8ee1c4fdf9327e0157b::$files;
|
||||
$requireFile = \Closure::bind(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 ComposerStaticIniteac56325223dabb3fdf738e61e520d37
|
||||
class ComposerStaticInitccbfa8587eb1d8ee1c4fdf9327e0157b
|
||||
{
|
||||
public static $files = array (
|
||||
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
|
||||
|
@ -3023,9 +3023,9 @@ class ComposerStaticIniteac56325223dabb3fdf738e61e520d37
|
|||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticIniteac56325223dabb3fdf738e61e520d37::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticIniteac56325223dabb3fdf738e61e520d37::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticIniteac56325223dabb3fdf738e61e520d37::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInitccbfa8587eb1d8ee1c4fdf9327e0157b::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInitccbfa8587eb1d8ee1c4fdf9327e0157b::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInitccbfa8587eb1d8ee1c4fdf9327e0157b::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user