1 | <?php |
||
14 | class SRFTime extends SMWResultPrinter { |
||
15 | |||
16 | /** |
||
17 | * (non-PHPdoc) |
||
18 | * @see SMWResultPrinter::getName() |
||
19 | */ |
||
20 | public function getName() { |
||
25 | |||
26 | /** |
||
27 | * (non-PHPdoc) |
||
28 | * @see SMWResultPrinter::getResultText() |
||
29 | */ |
||
30 | 2 | protected function getResultText( SMWQueryResult $res, $outputmode ) { |
|
51 | |||
52 | /** |
||
53 | * Returns an array with sortkeys for dates pointing to their source DataItems. |
||
54 | * |
||
55 | * @param SMWQueryResult $res |
||
56 | * |
||
57 | * @return array |
||
58 | */ |
||
59 | 2 | protected function getSortKeys( SMWQueryResult $res ) { |
|
74 | |||
75 | /** |
||
76 | * @see SMWResultPrinter::getParamDefinitions |
||
77 | * |
||
78 | * @since 1.8 |
||
79 | * |
||
80 | * @param $definitions array of IParamDefinition |
||
81 | * |
||
82 | * @return array of IParamDefinition|array |
||
83 | */ |
||
84 | 2 | public function getParamDefinitions( array $definitions ) { |
|
95 | |||
96 | } |
||
97 |
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: