1 | <?php |
||
7 | class AboutMeService implements AboutMeServiceInterface |
||
8 | { |
||
9 | /** @var string */ |
||
10 | protected $content = ''; |
||
11 | |||
12 | public function __construct() |
||
16 | |||
17 | /** |
||
18 | * Check if there's content to show. |
||
19 | * |
||
20 | * @return bool |
||
21 | */ |
||
22 | public function hasContent() |
||
26 | |||
27 | /** |
||
28 | * Get the content parsed into html. |
||
29 | * |
||
30 | * @return string |
||
31 | */ |
||
32 | public function getHtml() |
||
36 | |||
37 | /** |
||
38 | * Get the text from the specified resource. |
||
39 | * |
||
40 | * @return bool|string |
||
41 | */ |
||
42 | public function getContent() |
||
46 | } |
||
47 |
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.