| Total Complexity | 4 |
| Total Lines | 53 |
| Duplicated Lines | 0 % |
| Changes | 4 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 11 | class ViewsGeneratorCommand extends Base |
||
| 12 | { |
||
| 13 | /** |
||
| 14 | * The console command name. |
||
| 15 | * |
||
| 16 | * @var string |
||
| 17 | */ |
||
| 18 | protected $name = 'artomator.scaffold:views'; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * Create a new command instance. |
||
| 22 | */ |
||
| 23 | public function __construct() |
||
| 24 | { |
||
| 25 | parent::__construct(); |
||
| 26 | |||
| 27 | $this->commandData = new CommandData($this, CommandData::$COMMAND_TYPE_SCAFFOLD); |
||
| 28 | } |
||
| 29 | |||
| 30 | /** |
||
| 31 | * Execute the command. |
||
| 32 | * |
||
| 33 | * @return void |
||
| 34 | */ |
||
| 35 | public function handle() |
||
| 36 | { |
||
| 37 | $this->commandData->modelName = $this->argument('model'); |
||
|
|
|||
| 38 | |||
| 39 | $this->commandData->initCommandData(); |
||
| 40 | $this->commandData->getFields(); |
||
| 41 | |||
| 42 | if (false === $this->commandData->getOption('vue')) { |
||
| 43 | $viewGenerator = new ViewGenerator($this->commandData); |
||
| 44 | $viewGenerator->generate(); |
||
| 45 | } else { |
||
| 46 | $vueGenerator = new VueGenerator($this->commandData); |
||
| 47 | $vueGenerator->generate(); |
||
| 48 | } |
||
| 49 | |||
| 50 | $this->performPostActions(); |
||
| 51 | } |
||
| 52 | |||
| 53 | /** |
||
| 54 | * Get the console command options. |
||
| 55 | * |
||
| 56 | * @return array |
||
| 57 | */ |
||
| 58 | public function getOptions() |
||
| 64 | ] |
||
| 65 | ); |
||
| 66 | } |
||
| 68 |
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.