diff --git a/src/Application/ChangedNodeScopeRefresher.php b/src/Application/ChangedNodeScopeRefresher.php index 81c1437ba9c..2c06ca34b11 100644 --- a/src/Application/ChangedNodeScopeRefresher.php +++ b/src/Application/ChangedNodeScopeRefresher.php @@ -149,10 +149,9 @@ private function setLineAttributesOnClass(Class_ $class, Attribute|AttributeGrou $this->simpleCallableNodeTraverser->traverseNodesWithCallable([$class], function (Node $subNode) use ( $node ): Node { - $subNode->setAttributes([ - 'startLine' => $node->getStartLine(), - 'endLine' => $node->getEndLine(), - ]); + $subNode->setAttribute('startLine', $node->getStartLine()); + $subNode->setAttribute('endLine', $node->getEndLine()); + return $subNode; }); } diff --git a/tests/Issues/PrintStringNowDocUnderAttributeTarget/Fixture/fixture.php.inc b/tests/Issues/PrintStringNowDocUnderAttributeTarget/Fixture/fixture.php.inc new file mode 100644 index 00000000000..09cae7dd7e7 --- /dev/null +++ b/tests/Issues/PrintStringNowDocUnderAttributeTarget/Fixture/fixture.php.inc @@ -0,0 +1,51 @@ + +----- + \ No newline at end of file diff --git a/tests/Issues/PrintStringNowDocUnderAttributeTarget/PrintStringNowDocUnderAttributeTargetTest.php b/tests/Issues/PrintStringNowDocUnderAttributeTarget/PrintStringNowDocUnderAttributeTargetTest.php new file mode 100644 index 00000000000..9dc43a047e6 --- /dev/null +++ b/tests/Issues/PrintStringNowDocUnderAttributeTarget/PrintStringNowDocUnderAttributeTargetTest.php @@ -0,0 +1,28 @@ +doTestFile($filePath); + } + + public static function provideData(): Iterator + { + return self::yieldFilesFromDirectory(__DIR__ . '/Fixture'); + } + + public function provideConfigFilePath(): string + { + return __DIR__ . '/config/configured_rule.php'; + } +} diff --git a/tests/Issues/PrintStringNowDocUnderAttributeTarget/Source/SomeAttributeTargetRector.php b/tests/Issues/PrintStringNowDocUnderAttributeTarget/Source/SomeAttributeTargetRector.php new file mode 100644 index 00000000000..6f89467ac4f --- /dev/null +++ b/tests/Issues/PrintStringNowDocUnderAttributeTarget/Source/SomeAttributeTargetRector.php @@ -0,0 +1,37 @@ +> + */ + public function getNodeTypes(): array + { + return [Attribute::class]; + } + + /** + * @param Attribute $node + */ + public function refactor(Node $node): Node + { + $node->name = new FullyQualified('SomeNewAttribute'); + + return $node; + } +} \ No newline at end of file diff --git a/tests/Issues/PrintStringNowDocUnderAttributeTarget/config/configured_rule.php b/tests/Issues/PrintStringNowDocUnderAttributeTarget/config/configured_rule.php new file mode 100644 index 00000000000..82b3f20e842 --- /dev/null +++ b/tests/Issues/PrintStringNowDocUnderAttributeTarget/config/configured_rule.php @@ -0,0 +1,10 @@ +rule(SomeAttributeTargetRector::class); +};