diff --git a/packages/StaticTypeMapper/ValueObject/Type/AliasedObjectType.php b/packages/StaticTypeMapper/ValueObject/Type/AliasedObjectType.php index 85e24b9c0a0..9440b82bf63 100644 --- a/packages/StaticTypeMapper/ValueObject/Type/AliasedObjectType.php +++ b/packages/StaticTypeMapper/ValueObject/Type/AliasedObjectType.php @@ -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 diff --git a/packages/StaticTypeMapper/ValueObject/Type/FullyQualifiedObjectType.php b/packages/StaticTypeMapper/ValueObject/Type/FullyQualifiedObjectType.php index 391b5383ce2..7716a0c9304 100644 --- a/packages/StaticTypeMapper/ValueObject/Type/FullyQualifiedObjectType.php +++ b/packages/StaticTypeMapper/ValueObject/Type/FullyQualifiedObjectType.php @@ -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()); - } } diff --git a/rules/CodingStyle/Application/UseImportsAdder.php b/rules/CodingStyle/Application/UseImportsAdder.php index e40dca6e245..47b218b76c2 100644 --- a/rules/CodingStyle/Application/UseImportsAdder.php +++ b/rules/CodingStyle/Application/UseImportsAdder.php @@ -142,8 +142,10 @@ final class UseImportsAdder private function createUses(array $useImportTypes, array $constantUseImportTypes, array $functionUseImportTypes, ?string $namespaceName) : array { $newUses = []; + /** @var array> $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; diff --git a/rules/CodingStyle/ClassNameImport/AliasUsesResolver.php b/rules/CodingStyle/ClassNameImport/AliasUsesResolver.php index 54a3e1da44e..c40a51bbef0 100644 --- a/rules/CodingStyle/ClassNameImport/AliasUsesResolver.php +++ b/rules/CodingStyle/ClassNameImport/AliasUsesResolver.php @@ -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 { diff --git a/rules/CodingStyle/ClassNameImport/UsedImportsResolver.php b/rules/CodingStyle/ClassNameImport/UsedImportsResolver.php index f750838afb9..07a0cd3ea47 100644 --- a/rules/CodingStyle/ClassNameImport/UsedImportsResolver.php +++ b/rules/CodingStyle/ClassNameImport/UsedImportsResolver.php @@ -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; diff --git a/rules/Naming/PropertyRenamer/PropertyPromotionRenamer.php b/rules/Naming/PropertyRenamer/PropertyPromotionRenamer.php index 1c7512cd020..b20e034a86a 100644 --- a/rules/Naming/PropertyRenamer/PropertyPromotionRenamer.php +++ b/rules/Naming/PropertyRenamer/PropertyPromotionRenamer.php @@ -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" diff --git a/rules/Php80/Rector/Class_/ClassPropertyAssignToConstructorPromotionRector.php b/rules/Php80/Rector/Class_/ClassPropertyAssignToConstructorPromotionRector.php index 72142c15a57..ee90857ea72 100644 --- a/rules/Php80/Rector/Class_/ClassPropertyAssignToConstructorPromotionRector.php +++ b/rules/Php80/Rector/Class_/ClassPropertyAssignToConstructorPromotionRector.php @@ -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; diff --git a/src/Application/VersionResolver.php b/src/Application/VersionResolver.php index 9356b7f6c5b..57f7c369918 100644 --- a/src/Application/VersionResolver.php +++ b/src/Application/VersionResolver.php @@ -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 */ diff --git a/vendor/autoload.php b/vendor/autoload.php index f295e928978..d93d2db37f3 100644 --- a/vendor/autoload.php +++ b/vendor/autoload.php @@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) { require_once __DIR__ . '/composer/autoload_real.php'; -return ComposerAutoloaderInit58a534feecfce33060675e220147da1f::getLoader(); +return ComposerAutoloaderInit5796d065fa503f4ab640bd4c553315f5::getLoader(); diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php index 17ca00f5b83..c317678f6a2 100644 --- a/vendor/composer/autoload_real.php +++ b/vendor/composer/autoload_real.php @@ -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; diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index 4ce603c2897..933a3539925 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -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); }