mirror of
https://github.com/danog/psalm.git
synced 2025-01-22 05:41:20 +01:00
Ensure that strict empty handling always happens
This commit is contained in:
parent
5a200ca442
commit
7bd4d969a4
@ -555,7 +555,7 @@ class SimpleNegatedAssertionReconciler extends Reconciler
|
||||
|| $existing_var_type->possibly_undefined_from_try
|
||||
|| $existing_var_type->hasType('iterable');
|
||||
|
||||
if ($is_strict_equality && $assertion === 'empty') {
|
||||
if ($assertion === 'empty') {
|
||||
$existing_var_type->removeType('null');
|
||||
$existing_var_type->removeType('false');
|
||||
|
||||
|
@ -375,6 +375,20 @@ class EmptyTest extends \Psalm\Tests\TestCase
|
||||
|
||||
if (empty($d[0])) {}'
|
||||
],
|
||||
'reconcileNonEmptyArrayKey' => [
|
||||
'<?php
|
||||
/**
|
||||
* @param array{a?: string, b: string} $arr
|
||||
*/
|
||||
function createFromString(array $arr): void
|
||||
{
|
||||
if (empty($arr["a"])) {
|
||||
return;
|
||||
}
|
||||
|
||||
echo $arr["a"];
|
||||
}'
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user