Skip to content

Commit 34a3af9

Browse files
ddebinondrejmirtes
authored andcommitted
Adjusts GetOption return type if no default value.
1 parent 86bb993 commit 34a3af9

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/Type/Symfony/InputInterfaceGetOptionDynamicReturnTypeExtension.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,12 @@ public function getTypeFromMethodCall(MethodReflection $methodReflection, Method
6767
if (!$option->acceptValue()) {
6868
$optType = new BooleanType();
6969
} else {
70-
$optType = TypeCombinator::union(new StringType(), new IntegerType(), new NullType());
70+
$optType = TypeCombinator::union(new StringType(), new NullType());
7171
if ($option->isValueRequired() && ($option->isArray() || $option->getDefault() !== null)) {
7272
$optType = TypeCombinator::removeNull($optType);
7373
}
7474
if ($option->isArray()) {
75-
$optType = new ArrayType(new IntegerType(), TypeCombinator::remove($optType, new IntegerType()));
75+
$optType = new ArrayType(new IntegerType(), $optType);
7676
}
7777
$optType = TypeCombinator::union($optType, $scope->getTypeFromValue($option->getDefault()));
7878
}

tests/Type/Symfony/InputInterfaceGetOptionDynamicReturnTypeExtensionTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ public function testArgumentTypes(string $expression, string $type): void
2727
public function argumentTypesProvider(): Iterator
2828
{
2929
yield ['$a', 'bool'];
30-
yield ['$b', 'int|string|null'];
31-
yield ['$c', 'int|string|null'];
30+
yield ['$b', 'string|null'];
31+
yield ['$c', 'string|null'];
3232
yield ['$d', 'array<int, string|null>'];
3333
yield ['$e', 'array<int, string>'];
3434

0 commit comments

Comments
 (0)