Skip to content
Permalink
Browse files

Fix #1873 - allow spread operators in inferred property types

  • Loading branch information...
muglug committed Jun 29, 2019
1 parent cba187a commit cb28c442281932356a8716faf0b80db11794f0be
Showing with 28 additions and 1 deletion.
  1. +17 −1 src/Psalm/Internal/Visitor/ReflectorVisitor.php
  2. +11 −0 tests/PropertyTypeTest.php
@@ -1870,7 +1870,23 @@ private function registerFunctionLike(PhpParser\Node\FunctionLike $stmt, $fake_m
continue;
}
$assigned_properties[$property_name] = $storage->param_types[$param_name];
$param_index = \array_search($param_name, \array_keys($storage->param_types));
if (!isset($storage->params[$param_index]->type)) {
continue;
}
$param_type = $storage->params[$param_index]->type;
$assigned_properties[$property_name] =
$storage->params[$param_index]->is_variadic
? new Type\Union([
new Type\Atomic\TArray([
Type::getInt(),
$param_type
])
])
: $param_type;
} else {
$assigned_properties = [];
break;
@@ -1651,6 +1651,17 @@ function (LogicException $e): void {},
}
}'
],
'inferSpreadParamType' => [
'<?php
class Tag {}
class EntityTags {
private $tags;
public function __construct(Tag ...$tags) {
$this->tags = $tags;
}
}'
],
];
}

0 comments on commit cb28c44

Please sign in to comment.
You can’t perform that action at this time.