Skip to content

Commit 9cd53c4

Browse files
committed
[Removing] Add RemoveAttributeRector
1 parent e2c8fc0 commit 9cd53c4

27 files changed

+1091
-1
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?php
2+
3+
namespace Rector\Tests\Removing\Rector\Attribute\RemoveAttributeRector\Fixture;
4+
5+
use Rector\Tests\Removing\Rector\Attribute\RemoveAttributeRector\Source\Attribute\RemoveEverywhereAttribute;
6+
7+
#[RemoveEverywhereAttribute]
8+
class RemoveEverywhereAttribute
9+
{
10+
#[RemoveEverywhereAttribute]
11+
private array $property;
12+
#[RemoveEverywhereAttribute]
13+
private const CONSTANT = 1;
14+
#[RemoveEverywhereAttribute]
15+
public function __construct(
16+
#[RemoveEverywhereAttribute]
17+
public array $promotedProperty
18+
) {
19+
}
20+
#[RemoveEverywhereAttribute]
21+
public function doSomething()
22+
{
23+
}
24+
#[RemoveEverywhereAttribute]
25+
public function doSomething2(
26+
#[RemoveEverywhereAttribute]
27+
string $parameter,
28+
) {
29+
}
30+
}
31+
32+
#[RemoveEverywhereAttribute]
33+
function doSomething3()
34+
{
35+
}
36+
37+
?>
38+
-----
39+
<?php
40+
41+
namespace Rector\Tests\Removing\Rector\Attribute\RemoveAttributeRector\Fixture;
42+
43+
use Rector\Tests\Removing\Rector\Attribute\RemoveAttributeRector\Source\Attribute\RemoveEverywhereAttribute;
44+
45+
class RemoveEverywhereAttribute
46+
{
47+
private array $property;
48+
private const CONSTANT = 1;
49+
public function __construct(public array $promotedProperty)
50+
{
51+
}
52+
public function doSomething()
53+
{
54+
}
55+
public function doSomething2(string $parameter)
56+
{
57+
}
58+
}
59+
60+
function doSomething3()
61+
{
62+
}
63+
64+
?>
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<?php
2+
3+
namespace Rector\Tests\Removing\Rector\Attribute\RemoveAttributeRector\Fixture;
4+
5+
use Rector\Tests\Removing\Rector\Attribute\RemoveAttributeRector\Source\Attribute\RemoveFromClassConstantAttribute;
6+
7+
#[RemoveFromClassConstantAttribute]
8+
class RemoveAttributeFromClassOnly
9+
{
10+
#[RemoveFromClassConstantAttribute]
11+
private array $property;
12+
#[RemoveFromClassConstantAttribute]
13+
private const CONSTANT = 1;
14+
#[RemoveFromClassConstantAttribute]
15+
public function __construct(
16+
#[RemoveFromClassConstantAttribute]
17+
public array $promotedProperty
18+
) {}
19+
#[RemoveFromClassConstantAttribute]
20+
public function doSomething() {
21+
}
22+
#[RemoveFromClassConstantAttribute]
23+
public function doSomething2(
24+
#[RemoveFromClassConstantAttribute]
25+
string $parameter,
26+
) {
27+
}
28+
}
29+
30+
#[RemoveFromClassConstantAttribute]
31+
function doSomething3()
32+
{
33+
}
34+
35+
?>
36+
-----
37+
<?php
38+
39+
namespace Rector\Tests\Removing\Rector\Attribute\RemoveAttributeRector\Fixture;
40+
41+
use Rector\Tests\Removing\Rector\Attribute\RemoveAttributeRector\Source\Attribute\RemoveFromClassConstantAttribute;
42+
43+
#[RemoveFromClassConstantAttribute]
44+
class RemoveAttributeFromClassOnly
45+
{
46+
#[RemoveFromClassConstantAttribute]
47+
private array $property;
48+
private const CONSTANT = 1;
49+
#[RemoveFromClassConstantAttribute]
50+
public function __construct(
51+
#[RemoveFromClassConstantAttribute]
52+
public array $promotedProperty
53+
) {}
54+
#[RemoveFromClassConstantAttribute]
55+
public function doSomething() {
56+
}
57+
#[RemoveFromClassConstantAttribute]
58+
public function doSomething2(
59+
#[RemoveFromClassConstantAttribute]
60+
string $parameter,
61+
) {
62+
}
63+
}
64+
65+
#[RemoveFromClassConstantAttribute]
66+
function doSomething3()
67+
{
68+
}
69+
70+
?>
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<?php
2+
3+
namespace Rector\Tests\Removing\Rector\Attribute\RemoveAttributeRector\Fixture;
4+
5+
use Rector\Tests\Removing\Rector\Attribute\RemoveAttributeRector\Source\Attribute\RemoveFromClassMethodAttribute;
6+
7+
#[RemoveFromClassMethodAttribute]
8+
class RemoveAttributeFromClassOnly
9+
{
10+
#[RemoveFromClassMethodAttribute]
11+
private array $property;
12+
#[RemoveFromClassMethodAttribute]
13+
private const CONSTANT = 1;
14+
#[RemoveFromClassMethodAttribute]
15+
public function __construct(
16+
#[RemoveFromClassMethodAttribute]
17+
public array $promotedProperty
18+
)
19+
{
20+
}
21+
#[RemoveFromClassMethodAttribute]
22+
public function doSomething()
23+
{
24+
}
25+
#[RemoveFromClassMethodAttribute]
26+
public function doSomething2(
27+
#[RemoveFromClassMethodAttribute]
28+
string $parameter
29+
)
30+
{
31+
}
32+
}
33+
34+
#[RemoveFromClassMethodAttribute]
35+
function doSomething3()
36+
{
37+
}
38+
39+
?>
40+
-----
41+
<?php
42+
43+
namespace Rector\Tests\Removing\Rector\Attribute\RemoveAttributeRector\Fixture;
44+
45+
use Rector\Tests\Removing\Rector\Attribute\RemoveAttributeRector\Source\Attribute\RemoveFromClassMethodAttribute;
46+
47+
#[RemoveFromClassMethodAttribute]
48+
class RemoveAttributeFromClassOnly
49+
{
50+
#[RemoveFromClassMethodAttribute]
51+
private array $property;
52+
#[RemoveFromClassMethodAttribute]
53+
private const CONSTANT = 1;
54+
public function __construct(
55+
#[RemoveFromClassMethodAttribute]
56+
public array $promotedProperty
57+
)
58+
{
59+
}
60+
public function doSomething()
61+
{
62+
}
63+
public function doSomething2(
64+
#[RemoveFromClassMethodAttribute]
65+
string $parameter
66+
)
67+
{
68+
}
69+
}
70+
71+
#[RemoveFromClassMethodAttribute]
72+
function doSomething3()
73+
{
74+
}
75+
76+
?>
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<?php
2+
3+
namespace Rector\Tests\Removing\Rector\Attribute\RemoveAttributeRector\Fixture;
4+
5+
use Rector\Tests\Removing\Rector\Attribute\RemoveAttributeRector\Source\Attribute\RemoveFromClassAttribute;
6+
7+
#[RemoveFromClassAttribute]
8+
class RemoveAttributeFromClassOnly
9+
{
10+
#[RemoveFromClassAttribute]
11+
private array $property;
12+
#[RemoveFromClassAttribute]
13+
private const CONSTANT = 1;
14+
#[RemoveFromClassAttribute]
15+
public function __construct(
16+
#[RemoveFromClassAttribute]
17+
public array $promotedProperty
18+
) {}
19+
#[RemoveFromClassAttribute]
20+
public function doSomething() {
21+
}
22+
#[RemoveFromClassAttribute]
23+
public function doSomething2(
24+
#[RemoveFromClassAttribute]
25+
string $parameter,
26+
) {
27+
}
28+
}
29+
30+
#[RemoveFromClassAttribute]
31+
function doSomething3()
32+
{
33+
}
34+
35+
?>
36+
-----
37+
<?php
38+
39+
namespace Rector\Tests\Removing\Rector\Attribute\RemoveAttributeRector\Fixture;
40+
41+
use Rector\Tests\Removing\Rector\Attribute\RemoveAttributeRector\Source\Attribute\RemoveFromClassAttribute;
42+
43+
class RemoveAttributeFromClassOnly
44+
{
45+
#[RemoveFromClassAttribute]
46+
private array $property;
47+
#[RemoveFromClassAttribute]
48+
private const CONSTANT = 1;
49+
#[RemoveFromClassAttribute]
50+
public function __construct(
51+
#[RemoveFromClassAttribute]
52+
public array $promotedProperty
53+
) {}
54+
#[RemoveFromClassAttribute]
55+
public function doSomething() {
56+
}
57+
#[RemoveFromClassAttribute]
58+
public function doSomething2(
59+
#[RemoveFromClassAttribute]
60+
string $parameter,
61+
) {
62+
}
63+
}
64+
65+
#[RemoveFromClassAttribute]
66+
function doSomething3()
67+
{
68+
}
69+
70+
?>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
namespace Rector\Tests\Removing\Rector\Attribute\RemoveAttributeRector\Fixture;
4+
5+
use Rector\Tests\Removing\Rector\Attribute\RemoveAttributeRector\Source\Attribute\RemoveFromEnumCaseAttribute;
6+
7+
#[RemoveFromEnumCaseAttribute]
8+
enum RemoveAttributeFromEnumOnly
9+
{
10+
#[RemoveFromEnumCaseAttribute]
11+
case Foo;
12+
}
13+
14+
?>
15+
-----
16+
<?php
17+
18+
namespace Rector\Tests\Removing\Rector\Attribute\RemoveAttributeRector\Fixture;
19+
20+
use Rector\Tests\Removing\Rector\Attribute\RemoveAttributeRector\Source\Attribute\RemoveFromEnumCaseAttribute;
21+
22+
#[RemoveFromEnumCaseAttribute]
23+
enum RemoveAttributeFromEnumOnly
24+
{
25+
case Foo;
26+
}
27+
28+
?>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
namespace Rector\Tests\Removing\Rector\Attribute\RemoveAttributeRector\Fixture;
4+
5+
use Rector\Tests\Removing\Rector\Attribute\RemoveAttributeRector\Source\Attribute\RemoveFromEnumAttribute;
6+
7+
#[RemoveFromEnumAttribute]
8+
enum RemoveAttributeFromEnumOnly
9+
{
10+
#[RemoveFromEnumAttribute]
11+
case Foo;
12+
}
13+
14+
?>
15+
-----
16+
<?php
17+
18+
namespace Rector\Tests\Removing\Rector\Attribute\RemoveAttributeRector\Fixture;
19+
20+
use Rector\Tests\Removing\Rector\Attribute\RemoveAttributeRector\Source\Attribute\RemoveFromEnumAttribute;
21+
22+
enum RemoveAttributeFromEnumOnly
23+
{
24+
#[RemoveFromEnumAttribute]
25+
case Foo;
26+
}
27+
28+
?>

0 commit comments

Comments
 (0)