Skip to content

Commit 917cdb1

Browse files
committed
Fix native union type parameter with false
1 parent 552d4cf commit 917cdb1

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/Analyser/MutatingScope.php

+2
Original file line numberDiff line numberDiff line change
@@ -2736,6 +2736,8 @@ public function getFunctionType($type, bool $isNullable, bool $isVariadic): Type
27362736
return new VoidType();
27372737
} elseif ($type === 'object') {
27382738
return new ObjectWithoutClassType();
2739+
} elseif ($type === 'false') {
2740+
return new ConstantBooleanType(false);
27392741
} elseif ($type === 'mixed') {
27402742
return new MixedType(true);
27412743
}

tests/PHPStan/Reflection/data/unionTypes.php

+17
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,20 @@ function (): void {
4343

4444
assertType('NativeUnionTypes\\Bar|NativeUnionTypes\\Foo', $f(1));
4545
};
46+
47+
class Baz
48+
{
49+
50+
public function doFoo(array|false $foo): void
51+
{
52+
assertType('array|false', $foo);
53+
assertNativeType('array|false', $foo);
54+
assertType('array|false', $this->doBar());
55+
}
56+
57+
public function doBar(): array|false
58+
{
59+
60+
}
61+
62+
}

0 commit comments

Comments
 (0)