Skip to content

Commit 9832113

Browse files
committed
test(gen_stub): cover namespaced composite property types
1 parent f2b0e9a commit 9832113

1 file changed

Lines changed: 62 additions & 0 deletions

File tree

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
--TEST--
2+
Namespaced union and intersection properties generate valid arginfo identifiers
3+
--FILE--
4+
<?php
5+
6+
namespace NamespacedArginfo {
7+
interface Left
8+
{
9+
}
10+
11+
interface Right
12+
{
13+
}
14+
15+
final class Both implements Left, Right
16+
{
17+
}
18+
19+
final class Alternative
20+
{
21+
}
22+
23+
final class Holder
24+
{
25+
public Left|Alternative $union;
26+
public Left&Right $intersection;
27+
28+
public function __construct(Left|Alternative $union, Left&Right $intersection)
29+
{
30+
$this->union = $union;
31+
$this->intersection = $intersection;
32+
}
33+
}
34+
35+
function run(): void
36+
{
37+
$both = new Both();
38+
$holder = new Holder(new Alternative(), $both);
39+
40+
echo (new \ReflectionProperty(Holder::class, 'union'))->getType(), "\n";
41+
echo (new \ReflectionProperty(Holder::class, 'intersection'))->getType(), "\n";
42+
var_dump($holder->union instanceof Alternative);
43+
var_dump($holder->intersection instanceof Both);
44+
45+
$holder->union = $both;
46+
var_dump($holder->union instanceof Both);
47+
}
48+
}
49+
50+
namespace {
51+
function main(): void
52+
{
53+
\NamespacedArginfo\run();
54+
}
55+
}
56+
?>
57+
--EXPECT--
58+
NamespacedArginfo\Left|NamespacedArginfo\Alternative
59+
NamespacedArginfo\Left&NamespacedArginfo\Right
60+
bool(true)
61+
bool(true)
62+
bool(true)

0 commit comments

Comments
 (0)