File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -92,7 +92,7 @@ public function isArray()
9292 */
9393 public function setDefault ($ default = null )
9494 {
95- if (self :: REQUIRED === $ this ->mode && null !== $ default ) {
95+ if ($ this ->isRequired () && null !== $ default ) {
9696 throw new LogicException ('Cannot set a default value except for InputArgument::OPTIONAL mode. ' );
9797 }
9898
Original file line number Diff line number Diff line change @@ -88,6 +88,14 @@ public function testSetDefaultWithRequiredArgument()
8888 $ argument ->setDefault ('default ' );
8989 }
9090
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+
9199 public function testSetDefaultWithArrayArgument ()
92100 {
93101 $ this ->expectException (\LogicException::class);
You can’t perform that action at this time.
0 commit comments