| 1 | <?php |
||
| 9 | class RenewCommand extends Command |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * The name and signature of the console command. |
||
| 13 | * |
||
| 14 | * @var string |
||
| 15 | */ |
||
| 16 | protected $signature = 'signere:renew |
||
| 17 | {--key= : Specify the key to be renewed} |
||
| 18 | {--all}'; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * The console command description. |
||
| 22 | * |
||
| 23 | * @var string |
||
| 24 | */ |
||
| 25 | protected $description = 'Renews your primary or secondary signere key'; |
||
| 26 | |||
| 27 | /** |
||
| 28 | * The ApiKey instance. |
||
| 29 | * |
||
| 30 | * @var ApiKey |
||
| 31 | */ |
||
| 32 | protected $apiKey; |
||
| 33 | |||
| 34 | /** |
||
| 35 | * Create a new command instance. |
||
| 36 | * |
||
| 37 | * @param ApiKey $apiKey |
||
| 38 | */ |
||
| 39 | 5 | public function __construct(ApiKey $apiKey) |
|
| 45 | |||
| 46 | /** |
||
| 47 | * Execute the console command. |
||
| 48 | * |
||
| 49 | * @return void |
||
| 50 | */ |
||
| 51 | 5 | public function handle() |
|
| 83 | } |
||
| 84 |
If you define a variable conditionally, it can happen that it is not defined for all execution paths.
Let’s take a look at an example:
In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.
Available Fixes
Check for existence of the variable explicitly:
Define a default value for the variable:
Add a value for the missing path: