1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-30 04:39:00 +01:00

Allow bracketing as part of union type

Ref #854
This commit is contained in:
Matthew Brown 2018-06-30 13:09:05 -04:00
parent bca3b1797c
commit 745acaea71
2 changed files with 13 additions and 0 deletions

View File

@ -221,6 +221,14 @@ abstract class Type
$atomic_type = self::getTypeFromTree($child_tree, false, $template_type_names);
}
if ($atomic_type instanceof Union) {
foreach ($atomic_type->getTypes() as $type) {
$atomic_types[] = $type;
}
continue;
}
if (!$atomic_type instanceof Atomic) {
throw new \UnexpectedValueException(
'Was expecting an atomic type, got ' . get_class($atomic_type)

View File

@ -249,6 +249,11 @@ class TypeParseTest extends TestCase
Type::parseString('(A|B)&C');
}
public function testBracketInUnion()
{
Type::parseString('null|(scalar|array|object)');
}
/**
* @return void
*/