Skip to content

Commit

Permalink
fix $_FILES
Browse files Browse the repository at this point in the history
  • Loading branch information
kkmuffme committed Oct 10, 2022
1 parent b5f6da7 commit fa53050
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Psalm\Internal\Codebase\TaintFlowGraph;
use Psalm\Internal\DataFlow\DataFlowNode;
use Psalm\Internal\DataFlow\TaintSource;
use Psalm\Internal\Type\TypeCombiner;
use Psalm\Issue\ImpureVariable;
use Psalm\Issue\InvalidScope;
use Psalm\Issue\PossiblyUndefinedGlobalVariable;
Expand Down Expand Up @@ -767,7 +768,14 @@ public static function getGlobalType(string $var_id, int $codebase_analysis_php_

$type = new TKeyedArray($values);

return new Union([$type]);
// $_FILES['userfile']['...'] case
$named_type = new TArray([Type::getNonEmptyString(), new Union([$type])]);

// by default $_FILES is an empty array
$default_type = new TArray([Type::getNever(), Type::getNever()]);

// ideally we would have 3 separate arrays with distinct types, but that isn't possible with psalm atm
return TypeCombiner::combine([$default_type, $type, $named_type]);
}

if ($var_id === '$_SESSION') {
Expand Down

0 comments on commit fa53050

Please sign in to comment.