1 | <?php |
||
9 | class Terminal |
||
10 | { |
||
11 | use \PHPDaemon\Traits\ClassWatchdog; |
||
12 | use \PHPDaemon\Traits\StaticObjectWatchdog; |
||
13 | |||
14 | /** |
||
15 | * @var boolean Is color allowed in terminal? |
||
16 | */ |
||
17 | protected $enableColor = false; |
||
18 | |||
19 | /** |
||
20 | * @var integer Maximum terminal width |
||
21 | */ |
||
22 | protected $columns = 80; |
||
23 | |||
24 | /** |
||
25 | * Constructor |
||
26 | */ |
||
27 | public function __construct() |
||
31 | |||
32 | /** |
||
33 | * Counting terminal char width |
||
34 | * @return integer |
||
35 | */ |
||
36 | protected function getMaxColumns() |
||
46 | |||
47 | /** |
||
48 | * Read a line from STDIN |
||
49 | * @return string Line |
||
50 | */ |
||
51 | public function readln() |
||
55 | |||
56 | /** |
||
57 | * Enables/disable color |
||
58 | * @param boolean $bool Enable? |
||
59 | * @return void |
||
60 | */ |
||
61 | public function enableColor($bool = true) |
||
65 | |||
66 | /** |
||
67 | * Clear the terminal with CLR |
||
68 | * @return void |
||
69 | */ |
||
70 | public function clearScreen() |
||
74 | |||
75 | /** |
||
76 | * Draw param (like in man) |
||
77 | * @param string $name Param name |
||
78 | * @param string $description Param description |
||
79 | * @param array $values Param allowed values |
||
80 | * @return void |
||
81 | */ |
||
82 | public function drawParam($name, $description, $values = '') |
||
152 | |||
153 | /** |
||
154 | * Draw a table |
||
155 | * @param array Array of table's rows |
||
156 | * @return void |
||
157 | */ |
||
158 | public function drawTable($rows) |
||
206 | |||
207 | /** |
||
208 | * Set text style |
||
209 | * @param string $c Style |
||
210 | * @return void |
||
211 | */ |
||
212 | public function setStyle($c) |
||
218 | |||
219 | /** |
||
220 | * Reset style to default |
||
221 | * @return void |
||
222 | */ |
||
223 | public function resetStyle() |
||
229 | } |
||
230 |
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.