File tree Expand file tree Collapse file tree
rules-tests/TypeDeclarationDocblocks/Rector/Class_/DocblockVarArrayFromPropertyDefaultsRector/Fixture
rules/TypeDeclarationDocblocks/Rector/Class_ Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Rector \Tests \TypeDeclarationDocblocks \Rector \Class_ \DocblockVarArrayFromPropertyDefaultsRector \Fixture ;
4+
5+ final class OverrideDummyArrayVar
6+ {
7+ private array $ names = ['Jim ' , 'Rohn ' ];
8+ }
9+
10+ ?>
11+ -----
12+ <?php
13+
14+ namespace Rector \Tests \TypeDeclarationDocblocks \Rector \Class_ \DocblockVarArrayFromPropertyDefaultsRector \Fixture ;
15+
16+ final class OverrideDummyArrayVar
17+ {
18+ /**
19+ * @var string[]
20+ */
21+ private array $ names = ['Jim ' , 'Rohn ' ];
22+ }
23+
24+ ?>
Original file line number Diff line number Diff line change 1212use Rector \BetterPhpDocParser \PhpDocInfo \PhpDocInfoFactory ;
1313use Rector \Rector \AbstractRector ;
1414use Rector \TypeDeclarationDocblocks \NodeDocblockTypeDecorator ;
15+ use Rector \TypeDeclarationDocblocks \TagNodeAnalyzer \UsefulArrayTagNodeAnalyzer ;
1516use Symplify \RuleDocGenerator \ValueObject \CodeSample \CodeSample ;
1617use Symplify \RuleDocGenerator \ValueObject \RuleDefinition ;
1718
@@ -23,6 +24,7 @@ final class DocblockVarArrayFromPropertyDefaultsRector extends AbstractRector
2324 public function __construct (
2425 private readonly PhpDocInfoFactory $ phpDocInfoFactory ,
2526 private readonly NodeDocblockTypeDecorator $ nodeDocblockTypeDecorator ,
27+ private readonly UsefulArrayTagNodeAnalyzer $ usefulArrayTagNodeAnalyzer
2628 ) {
2729 }
2830
@@ -85,7 +87,7 @@ public function refactor(Node $node): ?Node
8587 $ propertyPhpDocInfo = $ this ->phpDocInfoFactory ->createFromNodeOrEmpty ($ property );
8688
8789 // type is already known
88- if ($ propertyPhpDocInfo ->getVarTagValueNode () instanceof VarTagValueNode ) {
90+ if ($ this -> usefulArrayTagNodeAnalyzer -> isUsefulArrayTag ( $ propertyPhpDocInfo ->getVarTagValueNode ()) ) {
8991 continue ;
9092 }
9193
You can’t perform that action at this time.
0 commit comments