@@ -57,6 +57,7 @@ public function getTypeFromMethodCall(MethodReflection $methodReflection, Method
57
57
$ argName = $ argStrings [0 ]->getValue ();
58
58
59
59
$ argTypes = [];
60
+ $ canBeNullInInteract = false ;
60
61
foreach ($ this ->consoleApplicationResolver ->findCommands ($ classReflection ) as $ command ) {
61
62
try {
62
63
$ command ->mergeApplicationDefinition ();
@@ -70,6 +71,8 @@ public function getTypeFromMethodCall(MethodReflection $methodReflection, Method
70
71
$ argType = new StringType ();
71
72
if (!$ argument ->isRequired ()) {
72
73
$ argType = TypeCombinator::union ($ argType , $ scope ->getTypeFromValue ($ argument ->getDefault ()));
74
+ } else {
75
+ $ canBeNullInInteract = true ;
73
76
}
74
77
}
75
78
$ argTypes [] = $ argType ;
@@ -78,16 +81,21 @@ public function getTypeFromMethodCall(MethodReflection $methodReflection, Method
78
81
}
79
82
}
80
83
84
+ if (count ($ argTypes ) === 0 ) {
85
+ return null ;
86
+ }
87
+
81
88
$ method = $ scope ->getFunction ();
82
89
if (
83
- $ method instanceof MethodReflection
90
+ $ canBeNullInInteract
91
+ && $ method instanceof MethodReflection
84
92
&& $ method ->getName () === 'interact '
85
93
&& in_array ('Symfony\Component\Console\Command\Command ' , $ method ->getDeclaringClass ()->getParentClassesNames (), true )
86
94
) {
87
95
$ argTypes [] = new NullType ();
88
96
}
89
97
90
- return count ( $ argTypes ) > 0 ? TypeCombinator::union (...$ argTypes ) : null ;
98
+ return TypeCombinator::union (...$ argTypes );
91
99
}
92
100
93
101
}
0 commit comments