@@ -26,22 +26,52 @@ public function isMethodSupported(MethodReflection $methodReflection): bool
2626 return $ methodReflection ->getName () === 'getValues ' ;
2727 }
2828
29- public function getTypeFromMethodCall (MethodReflection $ methodReflection , MethodCall $ methodCall , Scope $ scope ): ? Type
29+ public function getTypeFromMethodCall (MethodReflection $ methodReflection , MethodCall $ methodCall , Scope $ scope ): Type
3030 {
31- if (count ($ methodCall ->getArgs ()) === 0 ) {
31+ $ args = $ methodCall ->getArgs ();
32+
33+ // No argument => default object
34+ if (count ($ args ) === 0 ) {
3235 return new ObjectType ('Nette\Utils\ArrayHash ' );
3336 }
3437
35- $ arg = $ methodCall -> getArgs () [0 ]->value ;
38+ $ arg = $ args [0 ]->value ;
3639 $ 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 ' ) {
3867 return new ArrayType (new StringType (), new MixedType ());
3968 }
40- if ($ scopedType ->isFalse ()->yes ()) {
69+
70+ if ($ value === 'object ' ) {
4171 return new ObjectType ('Nette\Utils\ArrayHash ' );
4272 }
4373
44- return null ;
74+ return new ObjectType ( ' Nette\Utils\ArrayHash ' ) ;
4575 }
4676
4777}
0 commit comments