Skip to content

Commit 7366fc5

Browse files
committed
test: Prove bug in AnnotationToAttributeRector with mixed content
If a file already contains a mix of annotations and attributes, the current AnnotationToAttributeRector implementation drops the annotation value when generating the new Attribute tag. This could happen, for example, with a Behat context in a legacy project that has a mix of old and new step definitions.
1 parent 9e7f77d commit 7366fc5

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
namespace Rector\Tests\Php80\Rector\Class_\AnnotationToAttributeRector\Fixture\Behat;
4+
5+
use Behat\Step\When;
6+
7+
final class WithMixedAttributeAndAnnotations
8+
{
9+
/**
10+
* @When /^I have a step using annotations$/
11+
*/
12+
public function hadAnnotations(): void
13+
{
14+
}
15+
16+
#[When('/^I have a step using attributes$/')]
17+
public function hadAttributes(): void
18+
{
19+
}
20+
}
21+
22+
?>
23+
-----
24+
<?php
25+
26+
namespace Rector\Tests\Php80\Rector\Class_\AnnotationToAttributeRector\Fixture\Behat;
27+
28+
use Behat\Step\When;
29+
30+
final class WithMixedAttributeAndAnnotations
31+
{
32+
#[\Behat\Step\When('/^I have a step using annotations$/')]
33+
public function hadAnnotations(): void
34+
{
35+
}
36+
37+
#[When('/^I have a step using attributes$/')]
38+
public function hadAttributes(): void
39+
{
40+
}
41+
}
42+
43+
?>

0 commit comments

Comments
 (0)