diff --git a/src/Argument/Argument.php b/src/Argument/Argument.php index b839a18..5eb7a5f 100644 --- a/src/Argument/Argument.php +++ b/src/Argument/Argument.php @@ -263,8 +263,11 @@ public function noValue() */ protected function setNoValue($noValue) { - $this->setCastTo('bool'); $this->noValue = (bool) $noValue; + + if ($this->noValue === true) { + $this->setCastTo('bool'); + } } /** diff --git a/tests/ArgumentTest.php b/tests/ArgumentTest.php index 15abbc6..59a25fe 100644 --- a/tests/ArgumentTest.php +++ b/tests/ArgumentTest.php @@ -126,6 +126,19 @@ public function it_casts_to_bool_when_defined_only() $this->assertEquals('bool', $argument->castTo()); } + /** + * @test + * @doesNotPerformAssertions + */ + public function it_casts_to_bool_when_defined_only_true() + { + $argument = Argument::createFromArray('invalid-cast-type', [ + 'noValue' => false, + ]); + + $this->assertNotEquals('bool', $argument->castTo()); + } + /** * @test * @doesNotPerformAssertions