File tree Expand file tree Collapse file tree 1 file changed +19
-2
lines changed
rules/Php82/Rector/Class_ Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Original file line number Diff line number Diff line change 6
6
7
7
use PhpParser \Node ;
8
8
use PhpParser \Node \Stmt \Class_ ;
9
+ use PhpParser \Node \Stmt \ClassMethod ;
9
10
use Rector \Core \NodeAnalyzer \ClassAnalyzer ;
10
11
use Rector \Core \Rector \AbstractRector ;
12
+ use Rector \Core \ValueObject \MethodName ;
11
13
use Rector \Core \ValueObject \PhpVersionFeature ;
12
14
use Rector \Core \ValueObject \Visibility ;
13
15
use Rector \Php80 \NodeAnalyzer \PhpAttributeAnalyzer ;
@@ -100,13 +102,28 @@ private function shouldSkip(Class_ $class): bool
100
102
return true ;
101
103
}
102
104
105
+ if ($ this ->phpAttributeAnalyzer ->hasPhpAttribute ($ class , self ::ATTRIBUTE )) {
106
+ return true ;
107
+ }
108
+
103
109
$ properties = $ class ->getProperties ();
104
110
foreach ($ properties as $ property ) {
105
111
if (! $ property ->isReadonly ()) {
106
112
return true ;
107
113
}
108
114
}
109
- // property promotion
110
- return $ this ->phpAttributeAnalyzer ->hasPhpAttribute ($ class , self ::ATTRIBUTE );
115
+
116
+ $ constructClassMethod = $ class ->getMethod (MethodName::CONSTRUCT );
117
+ if (! $ constructClassMethod instanceof ClassMethod) {
118
+ return false ;
119
+ }
120
+
121
+ foreach ($ constructClassMethod ->getParams () as $ param ) {
122
+ if ($ param ->flags !== 0 ) {
123
+ return true ;
124
+ }
125
+ }
126
+
127
+ return false ;
111
128
}
112
129
}
You can’t perform that action at this time.
0 commit comments