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:
parent
034799773d
commit
1586cb249d
@ -1316,6 +1316,10 @@ class AssertionReconciler extends \Psalm\Type\Reconciler
|
||||
$code_location,
|
||||
$suppressed_issues
|
||||
);
|
||||
|
||||
if (!$did_remove_type) {
|
||||
$failed_reconciliation = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -283,6 +283,8 @@ class Reconciler
|
||||
$code_location,
|
||||
$suppressed_issues
|
||||
);
|
||||
} elseif (!$has_negation) {
|
||||
$changed_var_ids[] = $key;
|
||||
}
|
||||
|
||||
if ($failed_reconciliation === 2) {
|
||||
|
@ -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) {}
|
||||
}'
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user