1 | <?php |
||
25 | class GraphPrinter extends ResultPrinter { |
||
26 | |||
27 | //@see https://github.com/SemanticMediaWiki/SemanticMediaWiki/pull/4273 |
||
28 | // Implement `ResultPrinterDependency` once SMW 3.1 becomes mandatory |
||
29 | |||
30 | const NODELABEL_DISPLAYTITLE = 'displaytitle'; |
||
31 | public static $NODE_LABELS = [ |
||
32 | self::NODELABEL_DISPLAYTITLE, |
||
33 | ]; |
||
34 | |||
35 | public static $NODE_SHAPES = [ |
||
36 | 'box', |
||
37 | 'box3d', |
||
38 | 'circle', |
||
39 | 'component', |
||
40 | 'diamond', |
||
41 | 'doublecircle', |
||
42 | 'doubleoctagon', |
||
43 | 'egg', |
||
44 | 'ellipse', |
||
45 | 'folder', |
||
46 | 'hexagon', |
||
47 | 'house', |
||
48 | 'invhouse', |
||
49 | 'invtrapezium', |
||
50 | 'invtriangle', |
||
51 | 'Mcircle', |
||
52 | 'Mdiamond', |
||
53 | 'Msquare', |
||
54 | 'none', |
||
55 | 'note', |
||
56 | 'octagon', |
||
57 | 'parallelogram', |
||
58 | 'pentagon ', |
||
59 | 'plaintext', |
||
60 | 'point', |
||
61 | 'polygon', |
||
62 | 'rect', |
||
63 | 'rectangle', |
||
64 | 'septagon', |
||
65 | 'square', |
||
66 | 'tab', |
||
67 | 'trapezium', |
||
68 | 'triangle', |
||
69 | 'tripleoctagon', |
||
70 | ]; |
||
71 | private $nodes = []; |
||
72 | private $options; |
||
73 | |||
74 | public function getName() { |
||
77 | |||
78 | /** |
||
79 | * @see SMWResultPrinter::handleParameters() |
||
80 | */ |
||
81 | protected function handleParameters( array $params, $outputmode ) { |
||
86 | |||
87 | /** |
||
88 | * @see ResultPrinterDependency::hasMissingDependency |
||
89 | * |
||
90 | * {@inheritDoc} |
||
91 | */ |
||
92 | public function hasMissingDependency() { |
||
95 | |||
96 | /** |
||
97 | * @see ResultPrinterDependency::getDependencyError |
||
98 | * |
||
99 | * {@inheritDoc} |
||
100 | */ |
||
101 | public function getDependencyError() { |
||
110 | |||
111 | /** |
||
112 | * @param SMWQueryResult $res |
||
113 | * @param $outputmode |
||
114 | * |
||
115 | * @return string |
||
116 | */ |
||
117 | protected function getResultText( SMWQueryResult $res, $outputmode ) { |
||
142 | |||
143 | /** |
||
144 | * Process a result row and create SRF\GraphNodes |
||
145 | * |
||
146 | * @since 3.1 |
||
147 | * |
||
148 | * @param array $row |
||
149 | * |
||
150 | */ |
||
151 | protected function processResultRow( array /* of SMWResultArray */ $row ) { |
||
171 | |||
172 | /** |
||
173 | * @see SMWResultPrinter::getParamDefinitions |
||
174 | * |
||
175 | * @since 1.8 |
||
176 | * |
||
177 | * @param $definitions array of IParamDefinition |
||
178 | * |
||
179 | * @return array of IParamDefinition|array |
||
180 | */ |
||
181 | public function getParamDefinitions( array $definitions ) { |
||
256 | } |
||
257 |
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: