1 | <?php |
||
10 | class SRFTime extends SMWResultPrinter { |
||
11 | |||
12 | /** |
||
13 | * (non-PHPdoc) |
||
14 | * @see SMWResultPrinter::getName() |
||
15 | */ |
||
16 | public function getName() { |
||
21 | |||
22 | /** |
||
23 | * (non-PHPdoc) |
||
24 | * @see SMWResultPrinter::getResultText() |
||
25 | */ |
||
26 | protected function getResultText( SMWQueryResult $res, $outputmode ) { |
||
47 | |||
48 | 2 | /** |
|
49 | 2 | * Returns an array with sortkeys for dates pointing to their source DataItems. |
|
50 | * |
||
51 | * @param SMWQueryResult $res |
||
52 | * |
||
53 | * @return array |
||
54 | */ |
||
55 | protected function getSortKeys( SMWQueryResult $res ) { |
||
70 | |||
71 | /** |
||
72 | 2 | * @see SMWResultPrinter::getParamDefinitions |
|
73 | * |
||
74 | * @since 1.8 |
||
75 | * |
||
76 | * @param $definitions array of IParamDefinition |
||
77 | * |
||
78 | * @return array of IParamDefinition|array |
||
79 | */ |
||
80 | public function getParamDefinitions( array $definitions ) { |
||
91 | |||
92 | } |
||
93 |
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: