-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathReflectionClosureBracedNamespaceTest.php
50 lines (39 loc) · 1.33 KB
/
ReflectionClosureBracedNamespaceTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
namespace Space {
test('relative namespace (braced)', function () {
$f1 = fn (Foo $foo): Foo => new Foo();
$e1 = 'fn (\Space\Foo $foo): \Space\Foo => new \Space\Foo()';
$f2 = fn (Foo\Bar $fooBar): Foo\Bar => new Foo\Bar();
$e2 = 'fn (\Space\Foo\Bar $fooBar): \Space\Foo\Bar => new \Space\Foo\Bar()';
expect($f1)->toBeCode($e1);
expect($f2)->toBeCode($e2);
});
}
namespace Irrelevant {}
namespace Sub\Space {
test('relative other namespace (braced)', function () {
$f1 = fn (Foo $foo): Foo => new Foo();
$e1 = 'fn (\Sub\Space\Foo $foo): \Sub\Space\Foo => new \Sub\Space\Foo()';
expect($f1)->toBeCode($e1);
});
}
namespace {
test('back to global namespace (braced)', function () {
$f1 = fn (Foo $foo): Foo => new Foo();
$e1 = 'fn (\Foo $foo): \Foo => new \Foo()';
expect($f1)->toBeCode($e1);
});
}
namespace Irrelevant {
// Shouldn't be used below, as not in the same namespace
use Wrong as Qux;
}
namespace Space {
test('no using use from other namespace', function () {
$f1 = fn (Qux $qux) => true;
$e1 = 'fn (\Space\Qux $qux) => true';
expect($f1)->toBeCode($e1);
});
// Shouldn't be used above, as declared after usage. Not currently supported though.
// use AlsoWrong as Qux;
}