Skip to content

Commit de33963

Browse files
committed
Updated array keys for arrays and iterables
1 parent b0ace52 commit de33963

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/Type/Nette/FormContainerValuesDynamicReturnTypeExtension.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use PHPStan\Type\FalseBooleanType;
1111
use PHPStan\Type\MixedType;
1212
use PHPStan\Type\ObjectType;
13+
use PHPStan\Type\StringType;
1314
use PHPStan\Type\TrueBooleanType;
1415
use PHPStan\Type\Type;
1516

@@ -40,7 +41,7 @@ public function getTypeFromMethodCall(MethodReflection $methodReflection, Method
4041
}
4142

4243
if ($scopedType instanceof TrueBooleanType) {
43-
return new ArrayType(new MixedType());
44+
return new ArrayType(new StringType(), new MixedType());
4445
}
4546

4647
return $methodReflection->getReturnType();

tests/Type/Nette/FormContainerValuesDynamicReturnTypeExtensionTest.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function testParameterAsArray()
3131
$methodReflection = $this->createMock(MethodReflection::class);
3232
$methodReflection
3333
->method('getReturnType')
34-
->willReturn(new UnionType([new ArrayType(new MixedType()), new IterableIterableType(new ObjectType(\Nette\Utils\ArrayHash::class))]));
34+
->willReturn(new UnionType([new ArrayType(new MixedType(), new MixedType()), new IterableIterableType(new MixedType(), new ObjectType(\Nette\Utils\ArrayHash::class))]));
3535

3636
$scope = $this->createMock(Scope::class);
3737
$scope->method('getType')->willReturn(new TrueBooleanType());
@@ -57,7 +57,7 @@ public function testParameterAsArrayHash()
5757
$methodReflection = $this->createMock(MethodReflection::class);
5858
$methodReflection
5959
->method('getReturnType')
60-
->willReturn(new UnionType([new ArrayType(new MixedType()), new IterableIterableType(new ObjectType(\Nette\Utils\ArrayHash::class))]));
60+
->willReturn(new UnionType([new ArrayType(new MixedType(), new MixedType()), new IterableIterableType(new MixedType(), new ObjectType(\Nette\Utils\ArrayHash::class))]));
6161

6262
$scope = $this->createMock(Scope::class);
6363
$scope->method('getType')->willReturn(new FalseBooleanType());
@@ -84,7 +84,7 @@ public function testDefaultParameterIsArrayHash()
8484
$methodReflection = $this->createMock(MethodReflection::class);
8585
$methodReflection
8686
->method('getReturnType')
87-
->willReturn(new UnionType([new ArrayType(new MixedType()), new IterableIterableType(new ObjectType(\Nette\Utils\ArrayHash::class))]));
87+
->willReturn(new UnionType([new ArrayType(new MixedType(), new MixedType()), new IterableIterableType(new MixedType(), new ObjectType(\Nette\Utils\ArrayHash::class))]));
8888

8989
$scope = $this->createMock(Scope::class);
9090
$scope->method('getType')->willReturn(new FalseBooleanType());

0 commit comments

Comments
 (0)