@@ -46,7 +46,7 @@ public function getRuleDefinition(): RuleDefinition
46
46
47
47
,
48
48
<<<'CODE_SAMPLE'
49
- $name = SomeEnum::VALUE;
49
+ $name = SomeEnum::VALUE->name ;
50
50
CODE_SAMPLE
51
51
),
52
52
]);
@@ -110,7 +110,7 @@ private function isEnumConstant(string $className, string $constant): bool
110
110
return $ classReflection ->hasConstant ($ constant );
111
111
}
112
112
113
- private function refactorGetKeyMethodCall (MethodCall $ methodCall ): ?ClassConstFetch
113
+ private function refactorGetKeyMethodCall (MethodCall $ methodCall ): ?PropertyFetch
114
114
{
115
115
if (! $ methodCall ->var instanceof StaticCall) {
116
116
return null ;
@@ -131,7 +131,9 @@ private function refactorGetKeyMethodCall(MethodCall $methodCall): ?ClassConstFe
131
131
return null ;
132
132
}
133
133
134
- return $ this ->nodeFactory ->createClassConstFetch ($ className , $ enumCaseName );
134
+ $ classConstFetch = $ this ->nodeFactory ->createClassConstFetch ($ className , $ enumCaseName );
135
+
136
+ return new PropertyFetch ($ classConstFetch , 'name ' );
135
137
}
136
138
137
139
private function refactorGetValueMethodCall (MethodCall $ methodCall ): ?PropertyFetch
@@ -266,10 +268,8 @@ private function getEnumConstFetch(StaticCall $staticCall): null|ClassConstFetch
266
268
return $ this ->nodeFactory ->createClassConstFetch ($ className , $ enumCaseName );
267
269
}
268
270
269
- private function refactorMethodCall (
270
- MethodCall $ methodCall ,
271
- string $ methodName
272
- ): null |ClassConstFetch |PropertyFetch |Identical {
271
+ private function refactorMethodCall (MethodCall $ methodCall , string $ methodName ): null |PropertyFetch |Identical
272
+ {
273
273
if (! $ this ->isObjectType ($ methodCall ->var , new ObjectType ('MyCLabs\Enum\Enum ' ))) {
274
274
return null ;
275
275
}
0 commit comments