1 | <?php |
||
7 | class Definition implements \JsonSerializable |
||
8 | { |
||
9 | /** |
||
10 | * @var string |
||
11 | */ |
||
12 | protected $name; |
||
13 | |||
14 | /** |
||
15 | * @var null|string |
||
16 | */ |
||
17 | protected $since; |
||
18 | |||
19 | /** |
||
20 | * @var null|string |
||
21 | */ |
||
22 | protected $until; |
||
23 | |||
24 | /** |
||
25 | * @param string $name |
||
26 | * @param null|string $since |
||
27 | * @param null|string $until |
||
28 | * |
||
29 | * @throws \InvalidArgumentException |
||
30 | */ |
||
31 | 10 | public function __construct(string $name, ?string $since, ?string $until) |
|
48 | |||
49 | 1 | public function __toString(): string |
|
53 | |||
54 | /** |
||
55 | * @return string |
||
56 | */ |
||
57 | 3 | public function getName(): string |
|
61 | |||
62 | /** |
||
63 | * @return null|string |
||
64 | */ |
||
65 | public function getSince(): ?string |
||
69 | |||
70 | /** |
||
71 | * @return null|string |
||
72 | */ |
||
73 | public function getUntil(): ?string |
||
77 | |||
78 | /** |
||
79 | * @param string $version |
||
80 | * |
||
81 | * @return bool |
||
82 | */ |
||
83 | 3 | public function isAvailableForVersion(string $version): bool |
|
90 | |||
91 | /** |
||
92 | * {@inheritdoc} |
||
93 | */ |
||
94 | 2 | public function jsonSerialize(): array |
|
102 | } |
||
103 |
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.
For example, imagine you have a variable
$accountId
that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to theid
property of an instance of theAccount
class. This class holds a proper account, so the id value must no longer be false.Either this assignment is in error or a type check should be added for that assignment.