Conditions | 3 |
Paths | 3 |
Total Lines | 35 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
7 | public function display($callback = null) |
||
8 | { |
||
9 | if (func_num_args() == 2) { |
||
10 | list($title, $callback) = func_get_args(); |
||
11 | } elseif (func_num_args() == 1) { |
||
12 | $title = $this->trans('title'); |
||
13 | } |
||
14 | |||
15 | $callback = $callback->bindTo($this->row); |
||
16 | |||
17 | $html = call_user_func_array($callback, [$this->row]); |
||
18 | |||
19 | $key = $this->getKey(); |
||
20 | |||
21 | return <<<EOT |
||
22 | <span class="grid-expand" data-toggle="modal" data-target="#grid-modal-{$key}"> |
||
23 | <a href="javascript:void(0)"><i class="fa fa-angle-double-down"></i> {$this->value}</a> |
||
24 | </span> |
||
25 | |||
26 | <div class="modal fade" id="grid-modal-{$key}" tabindex="-1" role="dialog"> |
||
27 | <div class="modal-dialog modal-lg" role="document"> |
||
28 | <div class="modal-content"> |
||
29 | <div class="modal-header"> |
||
30 | <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> |
||
31 | <h4 class="modal-title">{$title}</h4> |
||
|
|||
32 | </div> |
||
33 | <div class="modal-body"> |
||
34 | {$html} |
||
35 | </div> |
||
36 | </div> |
||
37 | </div> |
||
38 | </div> |
||
39 | |||
40 | EOT; |
||
41 | } |
||
42 | } |
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: