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

Add protection for leaky assertions

This commit is contained in:
Matthew Brown 2019-08-10 16:58:57 -04:00
parent 034799773d
commit 1586cb249d
3 changed files with 18 additions and 1 deletions

View File

@ -1316,6 +1316,10 @@ class AssertionReconciler extends \Psalm\Type\Reconciler
$code_location,
$suppressed_issues
);
if (!$did_remove_type) {
$failed_reconciliation = 1;
}
}
}

View File

@ -283,6 +283,8 @@ class Reconciler
$code_location,
$suppressed_issues
);
} elseif (!$has_negation) {
$changed_var_ids[] = $key;
}
if ($failed_reconciliation === 2) {

View File

@ -1406,7 +1406,18 @@ class TypeReconciliationTest extends TestCase
$x = null;
assert($x instanceof Traversable);
takesTraversable($x);',
]
],
'dontReconcileArrayOffset' => [
'<?php
/** @psalm-suppress TypeDoesNotContainType */
function foo(array $a) : void {
if (!is_array($a)) {
return;
}
if ($a[0] === 5) {}
}'
],
];
}