From 48151d0190f2d82b2684ec8c18c44df4062180e1 Mon Sep 17 00:00:00 2001 From: Matthew Brown Date: Wed, 28 Dec 2016 14:53:49 -0500 Subject: [PATCH] Fix repeated assertion after unreconcilable clause --- src/Psalm/Checker/TypeChecker.php | 2 +- tests/ScopeTest.php | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/Psalm/Checker/TypeChecker.php b/src/Psalm/Checker/TypeChecker.php index 8c59540f6..9d2e5c12b 100644 --- a/src/Psalm/Checker/TypeChecker.php +++ b/src/Psalm/Checker/TypeChecker.php @@ -264,7 +264,7 @@ class TypeChecker $is_redundant = false; foreach ($cloned_clauses as $clause_b) { - if ($clause_a === $clause_b) { + if ($clause_a === $clause_b || !$clause_b->reconcilable || $clause_b->wedge) { continue; } diff --git a/tests/ScopeTest.php b/tests/ScopeTest.php index 57eb58bc6..c5f2bed7c 100644 --- a/tests/ScopeTest.php +++ b/tests/ScopeTest.php @@ -890,6 +890,24 @@ class ScopeTest extends PHPUnit_Framework_TestCase $this->assertEquals('string|null', (string) $context->vars_in_scope['$a']); } + public function testRepeatAssertionWithOther() + { + $stmts = self::$parser->parse(' 1 || is_string($a)) { + if (is_string($a)) { + echo strpos("e", $a); + } + } + '); + + $file_checker = new FileChecker('somefile.php', $stmts); + $context = new Context('somefile.php'); + $file_checker->check(true, true, $context); + $this->assertEquals('string|null', (string) $context->vars_in_scope['$a']); + } + public function testRefineORedType() { $stmts = self::$parser->parse('