From 801cca2aa3e3ea747d4f76a09f678530572b58ca Mon Sep 17 00:00:00 2001 From: kkmuffme <11071985+kkmuffme@users.noreply.github.com> Date: Tue, 8 Aug 2023 22:22:48 +0200 Subject: [PATCH] argv and argc were inconsistent in Context with VariableFetchAnalyzer Not sure why argv/argc are declared in context independently in the first place though --- src/Psalm/Context.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/Psalm/Context.php b/src/Psalm/Context.php index fea57cf9f..bf7322956 100644 --- a/src/Psalm/Context.php +++ b/src/Psalm/Context.php @@ -12,7 +12,8 @@ use Psalm\Internal\Scope\LoopScope; use Psalm\Internal\Type\AssertionReconciler; use Psalm\Storage\FunctionLikeStorage; use Psalm\Type\Atomic\DependentType; -use Psalm\Type\Atomic\TArray; +use Psalm\Type\Atomic\TIntRange; +use Psalm\Type\Atomic\TNull; use Psalm\Type\Union; use RuntimeException; @@ -868,10 +869,19 @@ final class Context public function defineGlobals(): void { $globals = [ + // not sure why this is declared here again, see VariableFetchAnalyzer '$argv' => new Union([ - new TArray([Type::getInt(), Type::getString()]), + Type::getNonEmptyListAtomic(Type::getString()), + new TNull(), + ], [ + 'ignore_nullable_issues' => true, + ]), + '$argc' => new Union([ + new TIntRange(1, null), + new TNull(), + ], [ + 'ignore_nullable_issues' => true, ]), - '$argc' => Type::getInt(), ]; $config = Config::getInstance();