Skip to content

Commit 56e5036

Browse files
committed
Updated Rector to commit 8971177f378f71f6d986c57b3bc665b6957e7b18
rectorphp/rector-src@8971177 [TypeDeclaration] Keep Generic type docblock on TypedPropertyFromDocblockSetUpDefinedRector (#7140)
1 parent 71280b6 commit 56e5036

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

rules/TypeDeclaration/Rector/Class_/TypedPropertyFromDocblockSetUpDefinedRector.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo;
1313
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory;
1414
use Rector\Comments\NodeDocBlock\DocBlockUpdater;
15+
use Rector\DeadCode\PhpDoc\DeadVarTagValueNodeAnalyzer;
1516
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
1617
use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer;
1718
use Rector\Rector\AbstractRector;
@@ -47,13 +48,18 @@ final class TypedPropertyFromDocblockSetUpDefinedRector extends AbstractRector i
4748
* @readonly
4849
*/
4950
private DocBlockUpdater $docBlockUpdater;
50-
public function __construct(TestsNodeAnalyzer $testsNodeAnalyzer, ConstructorAssignDetector $constructorAssignDetector, PhpDocInfoFactory $phpDocInfoFactory, StaticTypeMapper $staticTypeMapper, DocBlockUpdater $docBlockUpdater)
51+
/**
52+
* @readonly
53+
*/
54+
private DeadVarTagValueNodeAnalyzer $deadVarTagValueNodeAnalyzer;
55+
public function __construct(TestsNodeAnalyzer $testsNodeAnalyzer, ConstructorAssignDetector $constructorAssignDetector, PhpDocInfoFactory $phpDocInfoFactory, StaticTypeMapper $staticTypeMapper, DocBlockUpdater $docBlockUpdater, DeadVarTagValueNodeAnalyzer $deadVarTagValueNodeAnalyzer)
5156
{
5257
$this->testsNodeAnalyzer = $testsNodeAnalyzer;
5358
$this->constructorAssignDetector = $constructorAssignDetector;
5459
$this->phpDocInfoFactory = $phpDocInfoFactory;
5560
$this->staticTypeMapper = $staticTypeMapper;
5661
$this->docBlockUpdater = $docBlockUpdater;
62+
$this->deadVarTagValueNodeAnalyzer = $deadVarTagValueNodeAnalyzer;
5763
}
5864
public function getRuleDefinition() : RuleDefinition
5965
{
@@ -141,9 +147,9 @@ public function refactor(Node $node) : ?Node
141147
if (!$nativePropertyTypeNode instanceof Node) {
142148
continue;
143149
}
150+
$property->type = $nativePropertyTypeNode;
144151
// remove var tag
145152
$this->removeVarTag($propertyPhpDocInfo, $property);
146-
$property->type = $nativePropertyTypeNode;
147153
$hasChanged = \true;
148154
}
149155
if ($hasChanged) {
@@ -157,6 +163,13 @@ public function provideMinPhpVersion() : int
157163
}
158164
private function removeVarTag(PhpDocInfo $propertyPhpDocInfo, Property $property) : void
159165
{
166+
$varTagValueNode = $propertyPhpDocInfo->getVarTagValueNode();
167+
if (!$varTagValueNode instanceof VarTagValueNode) {
168+
return;
169+
}
170+
if (!$this->deadVarTagValueNodeAnalyzer->isDead($varTagValueNode, $property)) {
171+
return;
172+
}
160173
$propertyPhpDocInfo->removeByType(VarTagValueNode::class);
161174
$this->docBlockUpdater->updateRefactoredNodeWithPhpDocInfo($property);
162175
}

src/Application/VersionResolver.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ final class VersionResolver
1919
* @api
2020
* @var string
2121
*/
22-
public const PACKAGE_VERSION = 'e29863909630baae19805dc2d784a34b8f8e2ab7';
22+
public const PACKAGE_VERSION = '8971177f378f71f6d986c57b3bc665b6957e7b18';
2323
/**
2424
* @api
2525
* @var string
2626
*/
27-
public const RELEASE_DATE = '2025-08-11 12:34:04';
27+
public const RELEASE_DATE = '2025-08-11 20:07:39';
2828
/**
2929
* @var int
3030
*/

0 commit comments

Comments
 (0)