Skip to content

Commit 0c7061f

Browse files
committed
TASK: Solve #7 rudimentary
This might be error-prone but why not ^^
1 parent 492e05c commit 0c7061f

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

src/Target/Php/Transpiler/TypeReference/TypeReferenceTranspiler.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,9 @@ private function transpileNonUnionType(TypeInterface $type, TypeReferenceNode $t
7777
};
7878
}
7979

80-
private function transpileNullableType(TypeInterface $type, TypeReferenceNode $typeReferenceNode): string
80+
private function transpileNullableType(TypeInterface $typeWithoutNull, TypeReferenceNode $typeReferenceNode): string
8181
{
82-
if ($type->is(NumberType::get())) {
83-
return 'null|int|float';
84-
}
85-
return '?' . $this->transpileNonUnionType($type, $typeReferenceNode);
82+
$phpTypeWithoutNull = $this->transpileNonUnionType($typeWithoutNull, $typeReferenceNode);
83+
return (str_contains($phpTypeWithoutNull, '|') ? 'null|' : '?') . $phpTypeWithoutNull;
8684
}
8785
}

0 commit comments

Comments
 (0)