@@ -39,29 +39,21 @@ public function getTypeFromMethodCall(
3939 $ varType = $ scope ->getType ($ methodCall ->var );
4040 $ methodName = $ methodReflection ->getName ();
4141
42- if ($ methodName === 'count ' ) {
43- if ($ varType instanceof EntityQueryType) {
44- $ returnType = new EntityQueryCountType (
45- $ varType ->getClassName (),
46- $ varType ->getSubtractedType (),
47- $ varType ->getClassReflection ()
48- );
49-
50- if ($ varType ->hasAccessCheck ()) {
51- return $ returnType ->withAccessCheck ();
52- }
42+ if (!$ varType instanceof ObjectType) {
43+ return $ defaultReturnType ;
44+ }
5345
54- return $ returnType ;
46+ if ($ methodName === 'count ' ) {
47+ $ returnType = new EntityQueryCountType (
48+ $ varType ->getClassName (),
49+ $ varType ->getSubtractedType (),
50+ $ varType ->getClassReflection ()
51+ );
52+ if ($ varType instanceof EntityQueryType && $ varType ->hasAccessCheck ()) {
53+ return $ returnType ->withAccessCheck ();
5554 }
5655
57- if ($ varType instanceof ObjectType) {
58- return new EntityQueryCountType (
59- $ varType ->getClassName (),
60- $ varType ->getSubtractedType (),
61- $ varType ->getClassReflection ()
62- );
63- }
64- return $ defaultReturnType ;
56+ return $ returnType ;
6557 }
6658
6759 if ($ methodName === 'execute ' ) {
0 commit comments