3 class MyContainer
<Tv
> {
4 public function setPair(Pair
<string, Tv
> $_): void
{}
5 public function setTuple((string, Tv
) $_): void
{}
6 public function setVector(Vector
<Tv
> $_): void
{}
7 public function setMap(Map
<string, Tv
> $_): void
{}
8 public function setMapArray(array<string, Tv
> $_): void
{}
9 public function setVectorArray(array<Tv
> $_): void
{}
10 public function setShape(shape('x' => Tv
) $_): void
{}
13 function take_int(int $_): void
{}
15 function testPair(): void
{
19 $m = new MyContainer();
21 // $x[0] and $y[0] are type variables that contain inferred types of elements
22 // in $x and $y - Pair constructor must remove (unbind) them, because in next
23 // two lines they would be unified with Tv type variable of $m, and
24 // transitively with each other. Putting element inside a container should
25 // not affect it's type.
26 $m->setPair(Pair
{'x', $x[0]});
27 $m->setPair(Pair
{'x', $y[0]});
32 function testTuple(): void
{
36 $m = new MyContainer();
38 $m->setTuple(tuple('x', $x[0]));
39 $m->setTuple(tuple('x', $y[0]));
44 function testVector(): void
{
48 $m = new MyContainer();
50 $m->setVector(Vector
{$x[0]});
51 $m->setVector(Vector
{$y[0]});
56 function testMap(): void
{
60 $m = new MyContainer();
62 $m->setMap(Map
{'x' => $x[0]});
63 $m->setMap(Map
{'x' => $y[0]});
68 function testMapArray(string $key): void
{
72 $m = new MyContainer();
74 $m->setMapArray(array($key => $x[0]));
75 $m->setMapArray(array($key => $y[0]));
80 function testVectorArray(): void
{
84 $m = new MyContainer();
86 $m->setVectorArray(array($x[0]));
87 $m->setVectorArray(array($y[0]));
92 function testShape(): void
{
96 $m = new MyContainer();
98 $m->setShape(shape('x' => $x[0]));
99 $m->setShape(shape('x' => $y[0]));
104 function testShapeLikeArray(): void
{
108 $m = new MyContainer();
110 $m->setMapArray(array('x' => $x[0]));
111 $m->setMapArray(array('x' => $y[0]));