diff --git a/src/model/parts/TypePart.php b/src/model/parts/TypePart.php index 881221a..84159c9 100644 --- a/src/model/parts/TypePart.php +++ b/src/model/parts/TypePart.php @@ -71,7 +71,7 @@ public function getTypeDescription(): ?string { * * @return bool */ - public function getNullable(): bool { + public function getNullable(): ?bool { return $this->typeNullable; } diff --git a/tests/generator/ParameterGeneratorTest.php b/tests/generator/ParameterGeneratorTest.php index ab7bb0d..3b69c84 100644 --- a/tests/generator/ParameterGeneratorTest.php +++ b/tests/generator/ParameterGeneratorTest.php @@ -103,6 +103,13 @@ public function testPhp73Nullable() { $this->assertEquals('?float $foo', $generator->generate($param)); } + public function testPhp73NullableDefaultsToFalseWhenUnset() { + $generator = new ModelGenerator(['generateScalarTypeHints' => true, 'generateNullableTypes' => true]); + + $param = PhpParameter::create('foo')->setType('float'); + $this->assertEquals('float $foo', $generator->generate($param)); + } + public function testValues() { $generator = new ModelGenerator();