mirror of https://github.com/rectorphp/rector.git
Updated Rector to commit 848c2ad9415b0e536b7864872f895f64104ecb50
848c2ad941
Improve Use_ const types in docblocks (#5005)
This commit is contained in:
parent
57dc6f91d6
commit
4d86ccbb88
|
@ -29,15 +29,16 @@ final class AliasedObjectType extends ObjectType
|
|||
{
|
||||
return $this->fullyQualifiedClass;
|
||||
}
|
||||
public function getUseNode(?int $useType = null) : Use_
|
||||
/**
|
||||
* @param Use_::TYPE_* $useType
|
||||
*/
|
||||
public function getUseNode(int $useType) : Use_
|
||||
{
|
||||
$name = new Name($this->fullyQualifiedClass);
|
||||
$name->setAttribute(AttributeKey::IS_USEUSE_NAME, \true);
|
||||
$useUse = new UseUse($name, $this->getClassName());
|
||||
$use = new Use_([$useUse]);
|
||||
if ($useType !== null) {
|
||||
$use->type = $useType;
|
||||
}
|
||||
$use->type = $useType;
|
||||
return $use;
|
||||
}
|
||||
public function getShortName() : string
|
||||
|
|
|
@ -42,23 +42,20 @@ final class FullyQualifiedObjectType extends ObjectType
|
|||
$name->setAttribute(AttributeKey::NAMESPACED_NAME, $this->getClassName());
|
||||
return $name;
|
||||
}
|
||||
public function getUseNode(?int $useType = null) : Use_
|
||||
/**
|
||||
* @param Use_::TYPE_* $useType
|
||||
*/
|
||||
public function getUseNode(int $useType) : Use_
|
||||
{
|
||||
$name = new Name($this->getClassName());
|
||||
$name->setAttribute(AttributeKey::IS_USEUSE_NAME, \true);
|
||||
$useUse = new UseUse($name);
|
||||
$use = new Use_([$useUse]);
|
||||
if ($useType !== null) {
|
||||
$use->type = $useType;
|
||||
}
|
||||
$use->type = $useType;
|
||||
return $use;
|
||||
}
|
||||
public function getShortNameLowered() : string
|
||||
{
|
||||
return \strtolower($this->getShortName());
|
||||
}
|
||||
public function getClassNameLowered() : string
|
||||
{
|
||||
return \strtolower($this->getClassName());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -142,8 +142,10 @@ final class UseImportsAdder
|
|||
private function createUses(array $useImportTypes, array $constantUseImportTypes, array $functionUseImportTypes, ?string $namespaceName) : array
|
||||
{
|
||||
$newUses = [];
|
||||
/** @var array<Use_::TYPE_*, array<AliasedObjectType|FullyQualifiedObjectType>> $importsMapping */
|
||||
$importsMapping = [Use_::TYPE_NORMAL => $useImportTypes, Use_::TYPE_CONSTANT => $constantUseImportTypes, Use_::TYPE_FUNCTION => $functionUseImportTypes];
|
||||
foreach ($importsMapping as $type => $importTypes) {
|
||||
/** @var AliasedObjectType|FullyQualifiedObjectType $importType */
|
||||
foreach ($importTypes as $importType) {
|
||||
if ($namespaceName !== null && $this->isCurrentNamespace($namespaceName, $importType)) {
|
||||
continue;
|
||||
|
|
|
@ -3,11 +3,11 @@
|
|||
declare (strict_types=1);
|
||||
namespace Rector\CodingStyle\ClassNameImport;
|
||||
|
||||
use PhpParser\Node\Stmt\Use_;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Identifier;
|
||||
use PhpParser\Node\Stmt;
|
||||
use PhpParser\Node\Stmt\Namespace_;
|
||||
use PhpParser\Node\Stmt\Use_;
|
||||
use PhpParser\Node\Stmt\UseUse;
|
||||
final class AliasUsesResolver
|
||||
{
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
declare (strict_types=1);
|
||||
namespace Rector\CodingStyle\ClassNameImport;
|
||||
|
||||
use PhpParser\Node\Stmt\Use_;
|
||||
use PhpParser\Node\Identifier;
|
||||
use PhpParser\Node\Stmt;
|
||||
use PhpParser\Node\Stmt\Class_;
|
||||
use PhpParser\Node\Stmt\Use_;
|
||||
use PhpParser\Node\Stmt\UseUse;
|
||||
use Rector\CodingStyle\ClassNameImport\ValueObject\UsedImports;
|
||||
use Rector\Core\PhpParser\Node\BetterNodeFinder;
|
||||
|
|
|
@ -118,6 +118,19 @@ final class PropertyPromotionRenamer
|
|||
}
|
||||
return $hasChanged;
|
||||
}
|
||||
public function renameParamDoc(PhpDocInfo $phpDocInfo, ClassMethod $classMethod, Param $param, string $paramVarName, string $desiredPropertyName) : void
|
||||
{
|
||||
$paramTagValueNode = $phpDocInfo->getParamTagValueByName($paramVarName);
|
||||
if (!$paramTagValueNode instanceof ParamTagValueNode) {
|
||||
return;
|
||||
}
|
||||
$paramRename = $this->paramRenameFactory->createFromResolvedExpectedName($classMethod, $param, $desiredPropertyName);
|
||||
if (!$paramRename instanceof ParamRename) {
|
||||
return;
|
||||
}
|
||||
$this->paramRenamer->rename($paramRename);
|
||||
$this->docBlockUpdater->updateRefactoredNodeWithPhpDocInfo($classMethod);
|
||||
}
|
||||
private function renameParamVarNameAndVariableUsage(ClassLike $classLike, ClassMethod $classMethod, string $desiredPropertyName, Param $param) : void
|
||||
{
|
||||
if ($param->var instanceof Error) {
|
||||
|
@ -132,19 +145,6 @@ final class PropertyPromotionRenamer
|
|||
$param->var = new Variable($desiredPropertyName);
|
||||
$this->variableRenamer->renameVariableInFunctionLike($classMethod, $paramVarName, $desiredPropertyName);
|
||||
}
|
||||
public function renameParamDoc(PhpDocInfo $phpDocInfo, ClassMethod $classMethod, Param $param, string $paramVarName, string $desiredPropertyName) : void
|
||||
{
|
||||
$paramTagValueNode = $phpDocInfo->getParamTagValueByName($paramVarName);
|
||||
if (!$paramTagValueNode instanceof ParamTagValueNode) {
|
||||
return;
|
||||
}
|
||||
$paramRename = $this->paramRenameFactory->createFromResolvedExpectedName($classMethod, $param, $desiredPropertyName);
|
||||
if (!$paramRename instanceof ParamRename) {
|
||||
return;
|
||||
}
|
||||
$this->paramRenamer->rename($paramRename);
|
||||
$this->docBlockUpdater->updateRefactoredNodeWithPhpDocInfo($classMethod);
|
||||
}
|
||||
/**
|
||||
* Sometimes the bare type is not enough.
|
||||
* This allows prefixing type in variable names, e.g. "Type $firstType"
|
||||
|
|
|
@ -17,7 +17,6 @@ use PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode;
|
|||
use PHPStan\Reflection\ClassReflection;
|
||||
use PHPStan\Type\MixedType;
|
||||
use PHPStan\Type\TypeCombinator;
|
||||
use Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey;
|
||||
use Rector\Core\Contract\Rector\ConfigurableRectorInterface;
|
||||
use Rector\Core\NodeAnalyzer\ParamAnalyzer;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
|
|
|
@ -19,12 +19,12 @@ final class VersionResolver
|
|||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = '7e2bc1414f8567c55934a32d856e8d92a6e31d0f';
|
||||
public const PACKAGE_VERSION = '0.18.3';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2023-09-13 02:02:52';
|
||||
public const RELEASE_DATE = '2023-09-12 22:14:26';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
|
|
@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) {
|
|||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInit58a534feecfce33060675e220147da1f::getLoader();
|
||||
return ComposerAutoloaderInit5796d065fa503f4ab640bd4c553315f5::getLoader();
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInit58a534feecfce33060675e220147da1f
|
||||
class ComposerAutoloaderInit5796d065fa503f4ab640bd4c553315f5
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
|
@ -22,17 +22,17 @@ class ComposerAutoloaderInit58a534feecfce33060675e220147da1f
|
|||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit58a534feecfce33060675e220147da1f', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInit5796d065fa503f4ab640bd4c553315f5', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit58a534feecfce33060675e220147da1f', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit5796d065fa503f4ab640bd4c553315f5', 'loadClassLoader'));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit58a534feecfce33060675e220147da1f::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit5796d065fa503f4ab640bd4c553315f5::getInitializer($loader));
|
||||
|
||||
$loader->setClassMapAuthoritative(true);
|
||||
$loader->register(true);
|
||||
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInit58a534feecfce33060675e220147da1f::$files;
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInit5796d065fa503f4ab640bd4c553315f5::$files;
|
||||
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInit58a534feecfce33060675e220147da1f
|
||||
class ComposerStaticInit5796d065fa503f4ab640bd4c553315f5
|
||||
{
|
||||
public static $files = array (
|
||||
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
|
||||
|
@ -2593,9 +2593,9 @@ class ComposerStaticInit58a534feecfce33060675e220147da1f
|
|||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit58a534feecfce33060675e220147da1f::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit58a534feecfce33060675e220147da1f::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit58a534feecfce33060675e220147da1f::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit5796d065fa503f4ab640bd4c553315f5::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit5796d065fa503f4ab640bd4c553315f5::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit5796d065fa503f4ab640bd4c553315f5::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue