Conditions | 3 |
Paths | 4 |
Total Lines | 14 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
21 | public function renderInternal() |
||
22 | { |
||
23 | $image = new Image(); |
||
24 | if (!($this->contentObject->data['imageorient'] & 24)) { |
||
25 | $lines = $image->render($this->contentObject, $this->configuration); |
||
26 | $lines[] = ''; |
||
27 | } |
||
28 | $lines[] = $this->breakContent(strip_tags($this->parseBody($this->contentObject->data['bodytext']))); |
||
|
|||
29 | if ($this->contentObject->data['imageorient'] & 24) { |
||
30 | $lines[] = ''; |
||
31 | $lines = array_merge($lines, $image->render($this->contentObject, $this->configuration)); |
||
32 | } |
||
33 | return $lines; |
||
34 | } |
||
35 | } |
||
36 |
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: