| 1 | <?php |
||
| 19 | class Segment implements SegmentInterface |
||
| 20 | { |
||
| 21 | /** |
||
| 22 | * |
||
| 23 | * The name of the $_SESSION segment, typically a class name. |
||
| 24 | * |
||
| 25 | * @var string |
||
| 26 | * |
||
| 27 | */ |
||
| 28 | protected $name; |
||
| 29 | |||
| 30 | /** |
||
| 31 | * |
||
| 32 | * Constructor. |
||
| 33 | * |
||
| 34 | * @param bool $name The name of the $_SESSION segment. |
||
| 35 | * |
||
| 36 | */ |
||
| 37 | 14 | public function __construct($name = 'Aura\Auth\Auth') |
|
| 41 | |||
| 42 | /** |
||
| 43 | * |
||
| 44 | * Gets a value from the segment. |
||
| 45 | * |
||
| 46 | * @param mixed $key A key for the segment value. |
||
| 47 | * |
||
| 48 | * @param mixed $alt Return this value if the segment key does not exist. |
||
| 49 | * |
||
| 50 | * @return mixed |
||
| 51 | * |
||
| 52 | */ |
||
| 53 | 2 | public function get($key, $alt = null) |
|
| 61 | |||
| 62 | /** |
||
| 63 | * |
||
| 64 | * Sets a value in the segment. |
||
| 65 | * |
||
| 66 | * @param mixed $key The key in the segment. |
||
| 67 | * |
||
| 68 | * @param mixed $val The value to set. |
||
| 69 | * |
||
| 70 | */ |
||
| 71 | 2 | public function set($key, $val) |
|
| 79 | } |
||
| 80 |
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.