| Total Complexity | 4 |
| Total Lines | 48 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 5 | trait HasLocation |
||
| 6 | { |
||
| 7 | use HasModule; |
||
| 8 | |||
| 9 | /** |
||
| 10 | * Define the label for the module base location caption |
||
| 11 | * e.g Dashboard >> View, you should define $label = 'Dashboard' |
||
| 12 | * |
||
| 13 | * @var string |
||
| 14 | */ |
||
| 15 | protected $label = ''; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * Stores detailed labels for location caption to be displayed |
||
| 19 | * e.g Dashboard >> Edit >> Layout, you should set $location = ['Edit', 'Layout'] |
||
| 20 | * |
||
| 21 | * @var array |
||
| 22 | */ |
||
| 23 | protected $location = []; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * Get or set the location caption displayed |
||
| 27 | * |
||
| 28 | * @param string | array $location |
||
| 29 | * @return \Epesi\Core\System\Modules\ModuleView|array |
||
| 30 | */ |
||
| 31 | public function location($location = null) |
||
| 32 | { |
||
| 33 | if ($location) { |
||
| 34 | $this->location = $location; |
||
|
|
|||
| 35 | |||
| 36 | return $this; |
||
| 37 | } |
||
| 38 | |||
| 39 | $this->label = array_map('trans', (array) $this->label); |
||
| 40 | |||
| 41 | return array_merge($this->label, (array) $this->location); |
||
| 42 | } |
||
| 43 | |||
| 44 | public function label($label) |
||
| 53 | } |
||
| 54 | } |
||
| 55 |
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.