File tree 2 files changed +9
-1
lines changed
src/Symfony/Component/Console
2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -92,7 +92,7 @@ public function isArray()
92
92
*/
93
93
public function setDefault ($ default = null )
94
94
{
95
- if (self :: REQUIRED === $ this ->mode && null !== $ default ) {
95
+ if ($ this ->isRequired () && null !== $ default ) {
96
96
throw new LogicException ('Cannot set a default value except for InputArgument::OPTIONAL mode. ' );
97
97
}
98
98
Original file line number Diff line number Diff line change @@ -88,6 +88,14 @@ public function testSetDefaultWithRequiredArgument()
88
88
$ argument ->setDefault ('default ' );
89
89
}
90
90
91
+ public function testSetDefaultWithRequiredArrayArgument ()
92
+ {
93
+ $ this ->expectException (\LogicException::class);
94
+ $ this ->expectExceptionMessage ('Cannot set a default value except for InputArgument::OPTIONAL mode. ' );
95
+ $ argument = new InputArgument ('foo ' , InputArgument::REQUIRED | InputArgument::IS_ARRAY );
96
+ $ argument ->setDefault ([]);
97
+ }
98
+
91
99
public function testSetDefaultWithArrayArgument ()
92
100
{
93
101
$ this ->expectException (\LogicException::class);
You can’t perform that action at this time.
0 commit comments