Skip to content

Commit 889ce48

Browse files
committed
get rid of instanceof Mixed
1 parent 5215e5e commit 889ce48

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

src/Type/Php/ArrayKeyExistsFunctionTypeSpecifyingExtension.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,9 @@ public function specifyTypes(
119119
);
120120
} elseif (
121121
$this->phpVersion->throwsValueErrorForInternalFunctions()
122-
&& $arrayType instanceof MixedType
122+
&& !$arrayType->isArray()->yes()
123123
) {
124-
$type = TypeCombinator::intersect(
125-
new ArrayType(new MixedType(), new MixedType()),
126-
);
124+
$type = new ArrayType(new MixedType(), new MixedType());
127125
$context = $context->negate();
128126
} else {
129127
$type = new HasOffsetType($keyType);

tests/PHPStan/Analyser/nsrt/bug-2001.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,21 @@ public function parseUrl(string $url): string
1616
throw new \RuntimeException('Absolute URLs are prohibited for the redirectTo parameter.');
1717
}
1818

19-
assertType('array{scheme?: string, port?: int<0, 65535>, user?: string, pass?: string, path?: string, query?: string, fragment?: string}|false', $parsedUrl);
19+
assertType('array{scheme?: string, host?: string, port?: int<0, 65535>, user?: string, pass?: string, path?: string, query?: string, fragment?: string}', $parsedUrl);
2020

2121
$redirectUrl = $parsedUrl['path'];
2222

2323
if (array_key_exists('query', $parsedUrl)) {
24-
assertType('array{scheme?: string, port?: int<0, 65535>, user?: string, pass?: string, path?: string, query: string, fragment?: string}', $parsedUrl);
24+
assertType('array{scheme?: string, host?: string, port?: int<0, 65535>, user?: string, pass?: string, path?: string, query: string, fragment?: string}', $parsedUrl);
2525
$redirectUrl .= '?' . $parsedUrl['query'];
2626
}
2727

2828
if (array_key_exists('fragment', $parsedUrl)) {
29-
assertType('array{scheme?: string, port?: int<0, 65535>, user?: string, pass?: string, path?: string, query?: string, fragment: string}', $parsedUrl);
29+
assertType('array{scheme?: string, host?: string, port?: int<0, 65535>, user?: string, pass?: string, path?: string, query?: string, fragment: string}', $parsedUrl);
3030
$redirectUrl .= '#' . $parsedUrl['query'];
3131
}
3232

33-
assertType('array{scheme?: string, port?: int<0, 65535>, user?: string, pass?: string, path?: string, query?: string, fragment?: string}|false', $parsedUrl);
33+
assertType('array{scheme?: string, host?: string, port?: int<0, 65535>, user?: string, pass?: string, path?: string, query?: string, fragment?: string}', $parsedUrl);
3434

3535
return $redirectUrl;
3636
}

0 commit comments

Comments
 (0)