1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-26 20:34:47 +01:00

Don’t stop reconciling types when encountering problem

This commit is contained in:
Matt Brown 2017-11-28 17:42:00 -05:00
parent 6976f48316
commit 1173dcc6a2
3 changed files with 25 additions and 30 deletions

View File

@ -160,10 +160,6 @@ class IfChecker
$statements_checker->getSuppressedIssues()
);
if ($if_vars_in_scope_reconciled === false) {
return false;
}
$if_context->vars_in_scope = $if_vars_in_scope_reconciled;
$if_context->vars_possibly_in_scope = array_merge(
$reconcilable_if_types,
@ -201,10 +197,6 @@ class IfChecker
$statements_checker->getSuppressedIssues()
);
if ($else_vars_reconciled === false) {
return false;
}
$temp_else_context->vars_in_scope = $else_vars_reconciled;
}
@ -472,10 +464,6 @@ class IfChecker
);
}
if ($outer_context_vars_reconciled === false) {
return false;
}
$outer_context->vars_in_scope = $outer_context_vars_reconciled;
$mic_drop = true;
}
@ -579,10 +567,6 @@ class IfChecker
$statements_checker->getSuppressedIssues()
);
if ($elseif_vars_reconciled === false) {
return false;
}
$elseif_context->vars_in_scope = $elseif_vars_reconciled;
if ($changed_var_ids) {
@ -674,10 +658,6 @@ class IfChecker
$statements_checker->getSuppressedIssues()
);
if ($elseif_vars_reconciled === false) {
return false;
}
$elseif_context->vars_in_scope = $elseif_vars_reconciled;
if ($changed_var_ids) {
@ -820,10 +800,6 @@ class IfChecker
$statements_checker->getSuppressedIssues()
);
if ($leaving_vars_reconciled === false) {
return false;
}
$implied_outer_context = clone $elseif_context;
$implied_outer_context->vars_in_scope = $leaving_vars_reconciled;
@ -944,10 +920,6 @@ class IfChecker
$statements_checker->getSuppressedIssues()
);
if ($else_vars_reconciled === false) {
return false;
}
$else_context->vars_in_scope = $else_vars_reconciled;
$else_context->removeReconciledClauses($changed_var_ids);

View File

@ -38,7 +38,7 @@ class TypeChecker
* @param CodeLocation $code_location
* @param array<string> $suppressed_issues
*
* @return array<string, Type\Union>|false
* @return array<string, Type\Union>
*/
public static function reconcileKeyedTypes(
array $new_types,
@ -111,7 +111,8 @@ class TypeChecker
}
if ($result_type_candidate === false) {
return false;
$failed_reconciliation = true;
$result_type_candidate = Type::getMixed();
}
$orred_type = $orred_type

View File

@ -353,6 +353,28 @@ class PropertyTypeTest extends TestCase
bar(A::$a[$b]);
}',
],
'staticPropertyArrayIssetAssertionWithVariableOffsetAndElse' => [
'<?php
function bar(string $s) : void { }
class A {
/** @var array<string, string> */
public static $a = [];
}
function foo() : void {
$b = "hello";
if (!isset(A::$a[$b])) {
$g = "bar";
} else {
bar(A::$a[$b]);
$g = "foo";
}
bar($g);
}',
],
'traitConstructor' => [
'<?php
trait T {