php - How to tell PhpStorm inspector about exit()? -
i've next case
switch ($var) { case 'a': $model = 'x'; break; case 'b': $model = 'y'; break; // others cases ... default: // actions , calls exit(), // don't have put return/break after call // because unreachable, phpstorm don't know myfunc(); } // here inspector says me "variable $model might not defined" // have $model here anotherfunc($model);
best way defined $module right before switch or using following comment:
/** @var string $model */
this comment tell php-storm $model set , string. may use mixed instead of string says set.
i recomment using comment since has no performance-impact on script. using is_set solve problem using performance of script.
anyway may use such comments if there no way else , definitly set.
Comments
Post a Comment