Skip to content

Commit

Permalink
Fix native union type parameter with false
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Oct 7, 2020
1 parent 552d4cf commit 917cdb1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Analyser/MutatingScope.php
Original file line number Diff line number Diff line change
Expand Up @@ -2736,6 +2736,8 @@ public function getFunctionType($type, bool $isNullable, bool $isVariadic): Type
return new VoidType();
} elseif ($type === 'object') {
return new ObjectWithoutClassType();
} elseif ($type === 'false') {
return new ConstantBooleanType(false);
} elseif ($type === 'mixed') {
return new MixedType(true);
}
Expand Down
17 changes: 17 additions & 0 deletions tests/PHPStan/Reflection/data/unionTypes.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,20 @@ function (): void {

assertType('NativeUnionTypes\\Bar|NativeUnionTypes\\Foo', $f(1));
};

class Baz
{

public function doFoo(array|false $foo): void
{
assertType('array|false', $foo);
assertNativeType('array|false', $foo);
assertType('array|false', $this->doBar());
}

public function doBar(): array|false
{

}

}

0 comments on commit 917cdb1

Please sign in to comment.