@@ -26,22 +26,52 @@ public function isMethodSupported(MethodReflection $methodReflection): bool
26
26
return $ methodReflection ->getName () === 'getValues ' ;
27
27
}
28
28
29
- public function getTypeFromMethodCall (MethodReflection $ methodReflection , MethodCall $ methodCall , Scope $ scope ): ? Type
29
+ public function getTypeFromMethodCall (MethodReflection $ methodReflection , MethodCall $ methodCall , Scope $ scope ): Type
30
30
{
31
- if (count ($ methodCall ->getArgs ()) === 0 ) {
31
+ $ args = $ methodCall ->getArgs ();
32
+
33
+ // No argument => default object
34
+ if (count ($ args ) === 0 ) {
32
35
return new ObjectType ('Nette\Utils\ArrayHash ' );
33
36
}
34
37
35
- $ arg = $ methodCall -> getArgs () [0 ]->value ;
38
+ $ arg = $ args [0 ]->value ;
36
39
$ scopedType = $ scope ->getType ($ arg );
37
- if ($ scopedType ->isTrue ()->yes ()) {
40
+
41
+ if ($ scopedType ->isBoolean ()->yes ()) {
42
+ if ($ scopedType ->isTrue ()->yes ()) {
43
+ return new ArrayType (new StringType (), new MixedType ());
44
+ }
45
+
46
+ // boolean false → object
47
+ if ($ scopedType ->isFalse ()->yes ()) {
48
+ return new ObjectType ('Nette\Utils\ArrayHash ' );
49
+ }
50
+ }
51
+
52
+ $ constantStrings = $ scopedType ->getConstantStrings ();
53
+
54
+ if (count ($ constantStrings ) === 0 ) {
55
+ return new ObjectType ('Nette\Utils\ArrayHash ' );
56
+ }
57
+
58
+ $ constantString = $ constantStrings [0 ];
59
+
60
+ $ value = $ constantString ->getValue ();
61
+
62
+ if ($ scopedType ->isClassString ()->yes ()) {
63
+ return $ scopedType ->getClassStringObjectType ();
64
+ }
65
+
66
+ if ($ value === 'array ' ) {
38
67
return new ArrayType (new StringType (), new MixedType ());
39
68
}
40
- if ($ scopedType ->isFalse ()->yes ()) {
69
+
70
+ if ($ value === 'object ' ) {
41
71
return new ObjectType ('Nette\Utils\ArrayHash ' );
42
72
}
43
73
44
- return null ;
74
+ return new ObjectType ( ' Nette\Utils\ArrayHash ' ) ;
45
75
}
46
76
47
77
}
0 commit comments