Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 6cac146

Browse files
committed
getOption() can return int
1 parent a4d8502 commit 6cac146

File tree

4 files changed

+5
-9
lines changed

4 files changed

+5
-9
lines changed

‎src/Rules/Symfony/InvalidOptionDefaultValueRule.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function processNode(Node $node, Scope $scope): array
6666

6767
// not an array
6868
if (($mode & 8) !== 8) {
69-
$checkType = new UnionType([new StringType(), new NullType()]);
69+
$checkType = new UnionType([new StringType(), new IntegerType(), newNullType()]);
7070
if (($mode & 4) === 4) { // https://symfony.com/doc/current/console/input.html#options-with-optional-arguments
7171
$checkType = TypeCombinator::union($checkType, new ConstantBooleanType(false));
7272
}

‎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 NullType());
70+
$optType = TypeCombinator::union(new StringType(), new IntegerType(), newNullType());
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(), $optType);
75+
$optType = new ArrayType(new IntegerType(), TypeCombinator::remove($optType, newIntegerType()));
7676
}
7777
$optType = TypeCombinator::union($optType, $scope->getTypeFromValue($option->getDefault()));
7878
}

‎tests/Rules/Symfony/InvalidOptionDefaultValueRuleTest.php‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@ public function testGetArgument(): void
2424
'Parameter #5 $default of method Symfony\Component\Console\Command\Command::addOption() expects array<int, string>|null, array<int, int> given.',
2525
29,
2626
],
27-
[
28-
'Parameter #5 $default of method Symfony\Component\Console\Command\Command::addOption() expects string|false|null, int given.',
29-
30,
30-
],
3127
]
3228
);
3329
}

‎tests/Type/Symfony/InputInterfaceGetOptionDynamicReturnTypeExtensionTest.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ public function testArgumentTypes(string $expression, string $type): void
2424
public function argumentTypesProvider(): Iterator
2525
{
2626
yield ['$a', 'bool'];
27-
yield ['$b', 'string|null'];
28-
yield ['$c', 'string|null'];
27+
yield ['$b', 'int|string|null'];
28+
yield ['$c', 'int|string|null'];
2929
yield ['$d', 'array<int, string|null>'];
3030
yield ['$e', 'array<int, string>'];
3131

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /