@@ -6,12 +6,27 @@ use Nette\PhpGenerator\Type;
6
6
use Tester \Assert ;
7
7
require __DIR__ . '/../bootstrap.php ' ;
8
8
9
+ // Nullable
10
+ Assert::same ('?int ' , Type::nullable (Type::Int));
11
+ Assert::same ('int ' , Type::nullable (Type::Int, nullable: false ));
9
12
10
- Assert::same ('A|string ' , Type::union (A::class, Type::String));
13
+ Assert::same ('?int ' , Type::nullable ('?int ' ));
14
+ Assert::same ('int ' , Type::nullable ('?int ' , nullable: false ));
15
+
16
+ Assert::same ('int|float|string|null ' , Type::nullable ('int|float|string ' ));
17
+ Assert::same ('int|float|string ' , Type::nullable ('int|float|string ' , nullable: false ));
18
+
19
+ Assert::same ('null|int|float|string ' , Type::nullable ('null|int|float|string ' ));
20
+ Assert::same ('int|float|string ' , Type::nullable ('null|int|float|string ' , nullable: false ));
11
21
12
- Assert::same ('?A ' , Type::nullable (A::class));
13
- Assert::same ('?A ' , Type::nullable (A::class));
14
- Assert::same ('A ' , Type::nullable (A::class, nullable: false ));
22
+ Assert::same ('int|float|string|null ' , Type::nullable ('int|float|string|null ' ));
23
+ Assert::same ('int|float|string ' , Type::nullable ('int|float|string|null ' , nullable: false ));
24
+
25
+ Assert::same ('int|float|null|string ' , Type::nullable ('int|float|null|string ' ));
26
+ Assert::same ('int|float|string ' , Type::nullable ('int|float|null|string ' , nullable: false ));
27
+
28
+ // Union
29
+ Assert::same ('A|string ' , Type::union (A::class, Type::String));
15
30
16
- Assert:: same ( ' ?A ' , Type:: nullable ( ' ?A ' ));
17
- Assert::same ('A ' , Type::nullable ( ' ?A ' , nullable: false ));
31
+ // Intersection
32
+ Assert::same ('A&string ' , Type::intersection (A::class, Type::String ));
0 commit comments