1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-30 04:39:00 +01:00

Fix repeated assertion after unreconcilable clause

This commit is contained in:
Matthew Brown 2016-12-28 14:53:49 -05:00
parent 4919252260
commit 48151d0190
2 changed files with 19 additions and 1 deletions

View File

@ -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;
}

View File

@ -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('<?php
$a = rand(0, 10) ? "hello" : null;
if (rand(0, 10) > 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('<?php