Skip to content

Commit

Permalink
ignore nullable issues for $argv/$argc
Browse files Browse the repository at this point in the history
  • Loading branch information
kkmuffme committed Sep 15, 2022
1 parent b701c70 commit 661c7b3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
Expand Up @@ -29,7 +29,6 @@
use Psalm\Type\Atomic\TNonEmptyArray;
use Psalm\Type\Atomic\TNonEmptyList;
use Psalm\Type\Atomic\TNonEmptyString;
use Psalm\Type\Atomic\TNull;
use Psalm\Type\Atomic\TString;
use Psalm\Type\TaintKindGroup;
use Psalm\Type\Union;
Expand Down Expand Up @@ -541,18 +540,24 @@ public static function getGlobalType(string $var_id, int $codebase_analysis_php_

if ($var_id === '$argv') {
// only in CLI, null otherwise
return new Union([
$argv_nullable = new Union([
new TNonEmptyList(Type::getString()),
new TNull()
// new TNull()
]);
$argv_nullable->possibly_undefined = true;
$argv_nullable->ignore_nullable_issues = true;
return $argv_nullable;
}

if ($var_id === '$argc') {
// only in CLI, null otherwise
return new Union([
$argc_nullable = new Union([
new TIntRange(1, null),
new TNull()
// new TNull()
]);
$argc_nullable->possibly_undefined = true;
$argc_nullable->ignore_nullable_issues = true;
return $argc_nullable;
}

if (!self::isSuperGlobal($var_id)) {
Expand Down
2 changes: 1 addition & 1 deletion tests/Internal/CliUtilsTest.php
Expand Up @@ -19,7 +19,7 @@ class CliUtilsTest extends TestCase
protected function setUp(): void
{
global $argv;
$this->argv = $argv ?? [];
$this->argv = $argv;
}

protected function tearDown(): void
Expand Down

0 comments on commit 661c7b3

Please sign in to comment.