1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-22 05:41:20 +01:00

Complete the circle – fix remaining type algebra issue

This commit is contained in:
Matthew Brown 2017-04-01 19:04:49 -04:00
parent 5b34163d8d
commit 83edf8c4db
3 changed files with 11 additions and 10 deletions

View File

@ -124,10 +124,6 @@ class IfChecker
return false;
}
foreach ($changed_vars as $changed_var) {
//$if_context->removeVarFromClauses($changed_var);
}
$if_context->vars_in_scope = $if_vars_in_scope_reconciled;
$if_context->vars_possibly_in_scope = array_merge(
$reconcilable_if_types,

View File

@ -87,11 +87,6 @@ class AssignmentChecker
$statements_checker
);
if ($array_var_id) {
// removes dependennt vars from $context
$context->removeDescendents($array_var_id);
}
if ($doc_comment) {
$type_in_comments = CommentChecker::getTypeFromComment(
$doc_comment,
@ -105,6 +100,10 @@ class AssignmentChecker
if ($assign_value && ExpressionChecker::analyze($statements_checker, $assign_value, $context) === false) {
if ($var_id) {
if ($array_var_id) {
$context->removeDescendents($array_var_id);
}
// if we're not exiting immediately, make everything mixed
$context->vars_in_scope[$var_id] = $type_in_comments ?: Type::getMixed();
}
@ -123,6 +122,13 @@ class AssignmentChecker
}
}
if ($array_var_id && isset($context->vars_in_scope[$array_var_id])) {
if ((string)$context->vars_in_scope[$array_var_id] !== (string)$assign_value_type) {
// removes dependennt vars from $context
$context->removeDescendents($array_var_id);
}
}
if ($assign_value_type->isMixed()) {
if (IssueBuffer::accepts(
new MixedAssignment(

View File

@ -471,7 +471,6 @@ class TypeAlgebraTest extends PHPUnit_Framework_TestCase
*/
public function testTwoVarLogicNotNestedWithElseifCorrectlyReinforcedInIf()
{
$this->markTestSkipped('We dont currently support reinforcement of vars');
$stmts = self::$parser->parse('<?php
function foo(?string $a, ?string $b) : string {
if ($a) {