Skip to content

Commit c90948d

Browse files
authored
[DowngradePhp80] Register Override and SensitiveParameter to skipped attributes on DowngradeAttributeToAnnotationRector (#318)
1 parent 8ab1dce commit c90948d

File tree

2 files changed

+47
-1
lines changed

2 files changed

+47
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
final class OverrideAndSensitiveParameter extends Foo
4+
{
5+
#[\Override]
6+
public function run(#[\SensitiveParameter] bool $param) {
7+
if ($this->isTrue($param)) {
8+
return 5;
9+
}
10+
11+
return '10';
12+
}
13+
14+
private function isTrue($value) {
15+
return $value === true;
16+
}
17+
}
18+
19+
?>
20+
-----
21+
<?php
22+
23+
final class OverrideAndSensitiveParameter extends Foo
24+
{
25+
#[\Override]
26+
public function run(#[\SensitiveParameter]
27+
bool $param) {
28+
if ($this->isTrue($param)) {
29+
return 5;
30+
}
31+
32+
return '10';
33+
}
34+
35+
private function isTrue($value) {
36+
return $value === true;
37+
}
38+
}
39+
40+
?>

rules/DowngradePhp80/Rector/Class_/DowngradeAttributeToAnnotationRector.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,13 @@ final class DowngradeAttributeToAnnotationRector extends AbstractRector implemen
3434
/**
3535
* @var string[]
3636
*/
37-
private const SKIPPED_ATTRIBUTES = ['Attribute', 'ReturnTypeWillChange', 'AllowDynamicProperties'];
37+
private const SKIPPED_ATTRIBUTES = [
38+
'Attribute',
39+
'ReturnTypeWillChange',
40+
'AllowDynamicProperties',
41+
'Override',
42+
'SensitiveParameter',
43+
];
3844

3945
/**
4046
* @var DowngradeAttributeToAnnotation[]

0 commit comments

Comments
 (0)