Skip to content

Commit aa6c413

Browse files
committed
Form::getValues(true) returns array<string, mixed>
1 parent 90ed4f1 commit aa6c413

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/Type/Nette/FormContainerValuesDynamicReturnTypeExtension.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ public function getTypeFromMethodCall(MethodReflection $methodReflection, Method
3737
$arg = $args[0]->value;
3838
$scopedType = $scope->getType($arg);
3939

40+
if ($scopedType->isTrue()->yes()) {
41+
return new ArrayType(new StringType(), new MixedType());
42+
}
43+
4044
$constantStrings = $scopedType->getConstantStrings();
4145

4246
if (count($constantStrings) === 0) {

tests/Type/Nette/data/FormContainerModel.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace PHPStan\Type\Nette\Data\FormContainerModel;
44

55
use Nette\Forms\Form;
6+
use Nette\Utils\ArrayHash;
67
use function PHPStan\Testing\assertType;
78

89
class Dto
@@ -33,5 +34,9 @@ public function test()
3334

3435
assertType(Dto::class, $dto);
3536
assertType('array<string, mixed>', $array);
37+
38+
assertType('array<string, mixed>', $form->getValues(true));
39+
assertType(ArrayHash::class, $form->getValues());
40+
assertType(ArrayHash::class, $form->getValues(null));
3641
}
3742
}

0 commit comments

Comments
 (0)