Skip to content

Commit

Permalink
Merge pull request #6824 from orklah/session
Browse files Browse the repository at this point in the history
Makes $_SESSION possibly undefined at the source
  • Loading branch information
orklah committed Nov 5, 2021
2 parents 603fa65 + 6e5f3db commit b783468
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,6 @@ public static function scrapeAssertions(
&& !$var_type->isMixed()
&& !$var_type->possibly_undefined
&& !$var_type->possibly_undefined_from_try
&& $var_name !== '$_SESSION'
) {
$if_types[$var_name] = [['!null']];
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,11 @@ public static function getGlobalType(string $var_id) : Type\Union
}

if (self::isSuperGlobal($var_id)) {
return Type::getArray();
$type = Type::getArray();
if ($var_id === '$_SESSION') {
$type->possibly_undefined = true;
}
return $type;
}

return Type::getMixed();
Expand Down
1 change: 0 additions & 1 deletion src/Psalm/Internal/Type/NegatedAssertionReconciler.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ public static function reconcile(
if (!$existing_var_type->isNullable()
&& $key
&& strpos($key, '[') === false
&& $key !== '$_SESSION'
) {
foreach ($existing_var_type->getAtomicTypes() as $atomic) {
if (!$existing_var_type->hasMixed()
Expand Down
1 change: 0 additions & 1 deletion src/Psalm/Internal/Type/SimpleAssertionReconciler.php
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,6 @@ private static function reconcileIsset(
$did_remove_type = ($key && strpos($key, '['))
|| !$existing_var_type->initialized
|| $existing_var_type->possibly_undefined
|| $key === '$_SESSION'
|| $existing_var_type->ignore_isset;

if ($existing_var_type->isNullable()) {
Expand Down

0 comments on commit b783468

Please sign in to comment.