File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed
rules-tests/DowngradePhp80/Rector/Class_/DowngradeAttributeToAnnotationRector/Fixture
rules/DowngradePhp80/Rector/Class_ Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ namespace Rector\Tests\DowngradePhp80\Rector\Class_\DowngradeAttributeToAnnotati
1717use AllowDynamicProperties ;
1818
1919#[AllowDynamicProperties]
20- class User
20+ class ReprintSameLine
2121{
2222}
2323
Original file line number Diff line number Diff line change 1919use Rector \Contract \Rector \ConfigurableRectorInterface ;
2020use Rector \DowngradePhp80 \ValueObject \DowngradeAttributeToAnnotation ;
2121use Rector \NodeFactory \DoctrineAnnotationFactory ;
22+ use Rector \NodeTypeResolver \Node \AttributeKey ;
2223use Rector \Rector \AbstractRector ;
2324use Symplify \RuleDocGenerator \ValueObject \CodeSample \ConfiguredCodeSample ;
2425use Symplify \RuleDocGenerator \ValueObject \RuleDefinition ;
@@ -105,9 +106,11 @@ public function refactor(Node $node): ?Node
105106 $ this ->isDowngraded = false ;
106107
107108 $ phpDocInfo = $ this ->phpDocInfoFactory ->createFromNodeOrEmpty ($ node );
109+ $ requireReprint = false ;
108110 foreach ($ node ->attrGroups as $ attrGroup ) {
109111 foreach ($ attrGroup ->attrs as $ key => $ attribute ) {
110112 if ($ this ->shouldSkipAttribute ($ attribute )) {
113+ $ requireReprint = true ;
111114 continue ;
112115 }
113116
@@ -145,6 +148,11 @@ public function refactor(Node $node): ?Node
145148 $ this ->cleanupEmptyAttrGroups ($ node );
146149
147150 if (! $ this ->isDowngraded ) {
151+ if ($ requireReprint ) {
152+ $ node ->setAttribute (AttributeKey::ORIGINAL_NODE , null );
153+ return $ node ;
154+ }
155+
148156 return null ;
149157 }
150158
You can’t perform that action at this time.
0 commit comments