@@ -18,7 +18,7 @@ final class BrowserKitAssertionTraitReturnTypeExtension implements ExpressionTyp
18
18
{
19
19
20
20
private const TRAIT_NAME = 'Symfony\Bundle\FrameworkBundle\Test\BrowserKitAssertionsTrait ' ;
21
- private const TRAIT_METHOD_NAME = 'getClient ' ;
21
+ private const TRAIT_METHOD_NAME = 'getclient ' ;
22
22
23
23
public function getType (Expr $ expr , Scope $ scope ): ?Type
24
24
{
@@ -45,22 +45,26 @@ public function getType(Expr $expr, Scope $scope): ?Type
45
45
*/
46
46
private function isSupported (Expr $ expr , Scope $ scope ): bool
47
47
{
48
- if (!($ expr instanceof MethodCall) || !($ expr ->name instanceof Identifier) || $ expr ->name ->name !== self ::TRAIT_METHOD_NAME ) {
48
+ if (!($ expr instanceof MethodCall) || !($ expr ->name instanceof Identifier) || $ expr ->name ->toLowerString () !== self ::TRAIT_METHOD_NAME ) {
49
49
return false ;
50
50
}
51
51
52
52
if (!$ scope ->isInClass ()) {
53
53
return false ;
54
54
}
55
55
56
- $ reflectionClass = $ scope ->getClassReflection ()->getNativeReflection ();
56
+ $ methodReflection = $ scope ->getMethodReflection ($ scope ->getType ($ expr ->var ), $ expr ->name ->toString ());
57
+ if ($ methodReflection === null ) {
58
+ return false ;
59
+ }
57
60
61
+ $ reflectionClass = $ methodReflection ->getDeclaringClass ()->getNativeReflection ();
58
62
if (!$ reflectionClass ->hasMethod (self ::TRAIT_METHOD_NAME )) {
59
63
return false ;
60
64
}
61
65
62
- $ methodReflection = $ reflectionClass ->getMethod (self ::TRAIT_METHOD_NAME );
63
- $ declaringClassReflection = $ methodReflection ->getBetterReflection ()->getDeclaringClass ();
66
+ $ traitMethodReflection = $ reflectionClass ->getMethod (self ::TRAIT_METHOD_NAME );
67
+ $ declaringClassReflection = $ traitMethodReflection ->getBetterReflection ()->getDeclaringClass ();
64
68
65
69
return $ declaringClassReflection ->getName () === self ::TRAIT_NAME ;
66
70
}
0 commit comments