1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-26 20:34:47 +01:00

If we’re checking $_SESSION for existence return an array

Fixes #1335
This commit is contained in:
Matthew Brown 2019-02-15 15:58:36 -05:00
parent dca8bf9d36
commit 0ea22e8d82
2 changed files with 8 additions and 0 deletions

View File

@ -339,6 +339,10 @@ class Reconciler
if (($new_var_type === 'isset' && !$is_negation)
|| ($new_var_type === 'empty' && $is_negation)
) {
if ($key === '$_SESSION') {
return Type::getArray();
}
return Type::getMixed($inside_loop);
}

View File

@ -511,6 +511,10 @@ class IssetTest extends TestCase
'assertions' => [],
'error_levels' => ['MixedAssignment', 'MixedArrayOffset', 'InvalidArrayOffset'],
],
'sessionNullCoalesce' => [
'<?php
$a = $_SESSION ?? [];'
],
];
}