| Total Complexity | 7 |
| Total Lines | 50 |
| Duplicated Lines | 0 % |
| Changes | 4 | ||
| Bugs | 0 | Features | 4 |
| 1 | <?php |
||
| 22 | class Reader |
||
| 23 | { |
||
| 24 | /** @var resource Input file handle */ |
||
| 25 | protected $stream; |
||
| 26 | |||
| 27 | /** |
||
| 28 | * Constructor. |
||
| 29 | * |
||
| 30 | * @param string|null $path Read path. Defaults to STDIN. |
||
| 31 | */ |
||
| 32 | public function __construct(string $path = null) |
||
| 33 | { |
||
| 34 | $this->stream = $path ? \fopen($path, 'r') : \STDIN; |
||
|
|
|||
| 35 | } |
||
| 36 | |||
| 37 | /** |
||
| 38 | * Read a line from configured stream (or terminal). |
||
| 39 | * |
||
| 40 | * @param mixed $default The default value. |
||
| 41 | * @param callable|null $fn The validator/sanitizer callback. |
||
| 42 | * |
||
| 43 | * @return mixed |
||
| 44 | */ |
||
| 45 | public function read($default = null, callable $fn = null) |
||
| 54 | } |
||
| 55 | |||
| 56 | /** |
||
| 57 | * Read a line from configured stream (or terminal) but don't echo it back. |
||
| 58 | * |
||
| 59 | * @param callable|null $fn The validator/sanitizer callback. |
||
| 60 | * |
||
| 61 | * @return mixed |
||
| 62 | */ |
||
| 63 | public function readHidden($default = null, callable $fn = null) |
||
| 72 | } |
||
| 73 | } |
||
| 74 |
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
$accountIdthat can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to theidproperty of an instance of theAccountclass. 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.