Skip to content

Commit c5b99eb

Browse files
committed
x
1 parent d9aaf9d commit c5b99eb

File tree

1 file changed

+9
-19
lines changed

1 file changed

+9
-19
lines changed

tests/Utils/Type.with.phpt

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@ class Foo
1616
{
1717
}
1818

19-
class Bar
20-
{
21-
}
22-
2319
class FooChild extends Foo
2420
{
2521
}
@@ -28,7 +24,6 @@ class FooChild extends Foo
2824
function 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'));
4439
testTypeHint('(Foo&Bar)|(Foo&FooChild)', Type::fromString('Foo&Bar')->with('Foo&FooChild'));
4540
testTypeHint('(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
4846
testTypeHint('mixed', Type::fromString('string')->with('mixed'));
4947
testTypeHint('mixed', Type::fromString('mixed')->with('null'));
@@ -52,26 +50,18 @@ testTypeHint('mixed', Type::fromString('mixed')->with('null'));
5250
$type = Type::fromString('string');
5351
Assert::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');
5957
Assert::same($type, $type->with('string'));
6058
Assert::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');
7064
Assert::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

Comments
 (0)