Skip to content
Permalink
Browse files

Fix #1931 - narrow down property assignment

  • Loading branch information...
muglug committed Jul 10, 2019
1 parent 2c6854f commit e7aadee88f3dbc7e11b9016b43351c9dd064ddeb
@@ -743,6 +743,12 @@ public static function analyzeInstance(
$union_comparison_results
);
if ($type_match_found && $union_comparison_results->replacement_union_type) {
if ($var_id) {
$context->vars_in_scope[$var_id] = $union_comparison_results->replacement_union_type;
}
}
if ($union_comparison_results->type_coerced) {
if ($union_comparison_results->type_coerced_from_mixed) {
if (IssueBuffer::accepts(
@@ -2029,6 +2029,34 @@ function returnFooBase() {
function takesFooDerived($foo): void {}',
'error_message' => 'InvalidReturnStatement'
],
'specializeTypeInPropertyAssignment' => [
'<?php
/** @template T */
class Foo {
/** @var \Closure():T $closure */
private $closure;
/** @param \Closure():T $closure */
public function __construct($closure)
{
$this->closure = $closure;
}
}
class Bar {
/** @var Foo<array> */
private $FooArray;
public function __construct() {
$this->FooArray = new Foo(function(): array { return ["foo" => "bar"]; });
expectsShape($this->FooArray);
}
}
/** @param Foo<array{foo: string}> $_ */
function expectsShape($_): void {}',
'error_message' => 'MixedArgumentTypeCoercion'
],
];
}
}

0 comments on commit e7aadee

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