forked from phpstan/phpstan-src
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbug-12490-call.php
More file actions
75 lines (65 loc) · 1.21 KB
/
bug-12490-call.php
File metadata and controls
75 lines (65 loc) · 1.21 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php declare(strict_types = 1);
namespace Bug12490Call;
/**
* @template T
*/
class Container
{
/** @var T */
public $value;
/**
* @param T $value
*/
public function __construct($value)
{
$this->value = $value;
}
}
class Foo
{
/**
* @param Container<string|null> $container
*/
public function acceptsNullableString(Container $container): void
{
}
/**
* @param Container<int|null> $container
*/
public function acceptsNullableInt(Container $container): void
{
}
/**
* @param Container<float|null> $container
*/
public function acceptsNullableFloat(Container $container): void
{
}
/**
* @return Container<string|null>
*/
public function createNullableString(): Container
{
return new Container(null);
}
/**
* @return Container<int|null>
*/
public function createNullableInt(): Container
{
return new Container(null);
}
/**
* @return Container<float|null>
*/
public function createNullableFloat(): Container
{
return new Container(null);
}
public function test(): void
{
$this->acceptsNullableString($this->createNullableString());
$this->acceptsNullableInt($this->createNullableInt());
$this->acceptsNullableFloat($this->createNullableFloat());
}
}