File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed
rules/TypeDeclaration/Rector/Property Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -93,7 +93,11 @@ public function getNodeTypes(): array
9393 public function refactor (Node $ node ): ?Node
9494 {
9595 $ constructClassMethod = $ node ->getMethod (MethodName::CONSTRUCT );
96- if (! $ constructClassMethod instanceof ClassMethod || $ node ->getProperties () === []) {
96+ if (! $ constructClassMethod instanceof ClassMethod) {
97+ return null ;
98+ }
99+
100+ if (! $ this ->hasSomeUntypedProperties ($ node )) {
97101 return null ;
98102 }
99103
@@ -180,4 +184,17 @@ private function shouldSkipPropertyType(Type $propertyType): bool
180184
181185 return $ this ->doctrineTypeAnalyzer ->isInstanceOfCollectionType ($ propertyType );
182186 }
187+
188+ private function hasSomeUntypedProperties (Node |Class_ $ node ): bool
189+ {
190+ foreach ($ node ->getProperties () as $ property ) {
191+ if ($ property ->type instanceof \PhpParser \Node) {
192+ continue ;
193+ }
194+
195+ return true ;
196+ }
197+
198+ return false ;
199+ }
183200}
You can’t perform that action at this time.
0 commit comments