@@ -18,7 +18,7 @@ final class BrowserKitAssertionTraitReturnTypeExtension implements ExpressionTyp
1818{
1919
2020 private const TRAIT_NAME = 'Symfony\Bundle\FrameworkBundle\Test\BrowserKitAssertionsTrait ' ;
21- private const TRAIT_METHOD_NAME = 'getClient ' ;
21+ private const TRAIT_METHOD_NAME = 'getclient ' ;
2222
2323 public function getType (Expr $ expr , Scope $ scope ): ?Type
2424 {
@@ -45,22 +45,26 @@ public function getType(Expr $expr, Scope $scope): ?Type
4545 */
4646 private function isSupported (Expr $ expr , Scope $ scope ): bool
4747 {
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 ) {
4949 return false ;
5050 }
5151
5252 if (!$ scope ->isInClass ()) {
5353 return false ;
5454 }
5555
56- $ reflectionClass = $ scope ->getClassReflection ()->getNativeReflection ();
56+ $ methodReflection = $ scope ->getMethodReflection ($ scope ->getType ($ expr ->var ), $ expr ->name ->toString ());
57+ if ($ methodReflection === null ) {
58+ return false ;
59+ }
5760
61+ $ reflectionClass = $ methodReflection ->getDeclaringClass ()->getNativeReflection ();
5862 if (!$ reflectionClass ->hasMethod (self ::TRAIT_METHOD_NAME )) {
5963 return false ;
6064 }
6165
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 ();
6468
6569 return $ declaringClassReflection ->getName () === self ::TRAIT_NAME ;
6670 }
0 commit comments