@@ -16,10 +16,6 @@ class Foo
1616{
1717}
1818
19- class Bar
20- {
21- }
22-
2319class FooChild extends Foo
2420{
2521}
@@ -28,7 +24,6 @@ class FooChild extends Foo
2824function testTypeHint (string $ expected , Type $ type ): void
2925{
3026 Assert::same ($ expected , (string ) $ type );
31- eval ("function( $ expected \$_) {}; " );
3227}
3328
3429
@@ -44,6 +39,9 @@ testTypeHint('string|(Foo&Bar)', Type::fromString('string')->with('Foo&Bar'));
4439testTypeHint ('(Foo&Bar)|(Foo&FooChild) ' , Type::fromString ('Foo&Bar ' )->with ('Foo&FooChild ' ));
4540testTypeHint ('(Foo&Bar)|string|int ' , Type::fromString ('(Foo&Bar)|string ' )->with ('int ' ));
4641
42+ // with Type object
43+ testTypeHint ('string|int ' , Type::fromString ('string ' )->with (Type::fromString ('int ' )));
44+
4745// mixed
4846testTypeHint ('mixed ' , Type::fromString ('string ' )->with ('mixed ' ));
4947testTypeHint ('mixed ' , Type::fromString ('mixed ' )->with ('null ' ));
@@ -52,26 +50,18 @@ testTypeHint('mixed', Type::fromString('mixed')->with('null'));
5250$ type = Type::fromString ('string ' );
5351Assert::same ($ type , $ type ->with ('string ' ));
5452
55- $ type = Type::fromString ('string|int ' );
56- Assert::same ($ type , $ type ->with ('string ' ));
53+ $ type = Type::fromString ('string|int|bool ' );
54+ Assert::same ($ type , $ type ->with ('int ' ));
5755
5856$ type = Type::fromString ('?string ' );
5957Assert::same ($ type , $ type ->with ('string ' ));
6058Assert::same ($ type , $ type ->with ('null ' ));
6159
62- $ type = Type::fromString ('mixed ' );
63- Assert::same ($ type , $ type ->with ('string ' ));
64- Assert::same ($ type , $ type ->with ('Foo ' ));
65-
66- $ type = Type::fromString ('Foo ' );
67- Assert::same ($ type , $ type ->with ('FooChild ' ));
60+ $ with = Type::fromString ('mixed ' );
61+ Assert::same ($ with , Type::fromString ('string ' )->with ($ with ));
6862
6963$ type = Type::fromString ('Foo|Bar ' );
7064Assert::same ($ type , $ type ->with ('FooChild ' ));
7165
72- $ type = Type::fromString ('string|int|bool ' );
73- Assert::same ($ type , $ type ->with ('int ' ));
74-
75-
76- // with Type object
77- testTypeHint ('string|int ' , Type::fromString ('string ' )->with (Type::fromString ('int ' )));
66+ $ with = Type::fromString ('Foo ' );
67+ Assert::same ($ with , Type::fromString ('Foo&Bar ' )->with ($ with ));
0 commit comments