These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | /** |
||
4 | * Abstract class to hold common functionality for the jqPlot result printers. |
||
5 | * |
||
6 | * @since 1.8 |
||
7 | * |
||
8 | * @licence GNU GPL v2+ |
||
9 | * @author mwjames |
||
10 | * @author Jeroen De Dauw < [email protected] > |
||
11 | * @author Yaron Koren |
||
12 | * @author Sanyam Goyal |
||
13 | */ |
||
14 | abstract class SRFjqPlot extends SMWAggregatablePrinter { |
||
15 | |||
16 | public static function getCommonParams() { |
||
17 | |||
18 | $params = []; |
||
19 | |||
20 | $params['min'] = [ |
||
21 | 'type' => 'integer', |
||
22 | 'message' => 'srf-paramdesc-minvalue', |
||
23 | 'default' => false, |
||
24 | 'manipulatedefault' => false, |
||
25 | ]; |
||
26 | |||
27 | $params['direction'] = [ |
||
28 | 'message' => 'srf-paramdesc-direction', |
||
29 | 'default' => 'vertical', |
||
30 | 'values' => [ 'horizontal', 'vertical' ], |
||
31 | ]; |
||
32 | |||
33 | $params['charttitle'] = [ |
||
34 | 'message' => 'srf_paramdesc_charttitle', |
||
35 | 'default' => '', |
||
36 | ]; |
||
37 | |||
38 | $params['charttext'] = [ |
||
39 | 'message' => 'srf-paramdesc-charttext', |
||
40 | 'default' => '', |
||
41 | ]; |
||
42 | |||
43 | $params['numbersaxislabel'] = [ |
||
44 | 'message' => 'srf_paramdesc_barnumbersaxislabel', |
||
45 | 'default' => '', |
||
46 | ]; |
||
47 | |||
48 | $params['labelaxislabel'] = [ |
||
49 | 'message' => 'srf-paramdesc-labelaxislabel', |
||
50 | 'default' => '', |
||
51 | ]; |
||
52 | |||
53 | $params['height'] = [ |
||
54 | 'type' => 'integer', |
||
55 | 'message' => 'srf_paramdesc_chartheight', |
||
56 | 'default' => 400, |
||
57 | 'lowerbound' => 1, |
||
58 | ]; |
||
59 | |||
60 | // TODO: this is a string to allow for %, but better handling would be nice |
||
61 | $params['width'] = [ |
||
62 | 'message' => 'srf_paramdesc_chartwidth', |
||
63 | 'default' => '100%', |
||
64 | ]; |
||
65 | |||
66 | $params['smoothlines'] = [ |
||
67 | 'type' => 'boolean', |
||
68 | 'message' => 'srf-paramdesc-smoothlines', |
||
69 | 'default' => false, |
||
70 | ]; |
||
71 | |||
72 | // %.2f round number to 2 digits after decimal point e.g. EUR %.2f, $ %.2f |
||
73 | // %d a signed integer, in decimal |
||
74 | $params['valueformat'] = [ |
||
75 | 'message' => 'srf-paramdesc-valueformat', |
||
76 | 'default' => '%d', |
||
77 | ]; |
||
78 | |||
79 | $params['ticklabels'] = [ |
||
80 | 'type' => 'boolean', |
||
81 | 'message' => 'srf-paramdesc-ticklabels', |
||
82 | 'default' => true, |
||
83 | ]; |
||
84 | |||
85 | $params['highlighter'] = [ |
||
86 | 'type' => 'boolean', |
||
87 | 'message' => 'srf-paramdesc-highlighter', |
||
88 | 'default' => false, |
||
89 | ]; |
||
90 | |||
91 | $params['theme'] = [ |
||
92 | 'message' => 'srf-paramdesc-theme', |
||
93 | 'default' => '', |
||
94 | 'values' => [ '', 'vector', 'simple' ], |
||
95 | ]; |
||
96 | |||
97 | $params['filling'] = [ |
||
98 | 'type' => 'boolean', |
||
99 | 'message' => 'srf-paramdesc-filling', |
||
100 | 'default' => true, |
||
101 | ]; |
||
102 | |||
103 | $params['chartlegend'] = [ |
||
104 | 'message' => 'srf-paramdesc-chartlegend', |
||
105 | 'default' => 'none', |
||
106 | 'values' => [ 'none', 'nw', 'n', 'ne', 'e', 'se', 's', 'sw', 'w' ], |
||
107 | ]; |
||
108 | |||
109 | $params['datalabels'] = [ |
||
110 | 'message' => 'srf-paramdesc-datalabels', |
||
111 | 'default' => 'none', |
||
112 | 'values' => [ 'none', 'value', 'label', 'percent' ], |
||
113 | ]; |
||
114 | |||
115 | $params['colorscheme'] = [ |
||
116 | 'message' => 'srf-paramdesc-colorscheme', |
||
117 | 'default' => '', |
||
118 | 'values' => $GLOBALS['srfgColorScheme'], |
||
119 | ]; |
||
120 | |||
121 | $params['chartcolor'] = [ |
||
122 | 'message' => 'srf-paramdesc-chartcolor', |
||
123 | 'default' => '', |
||
124 | ]; |
||
125 | |||
126 | $params['class'] = [ |
||
127 | 'message' => 'srf-paramdesc-class', |
||
128 | 'default' => '', |
||
129 | ]; |
||
130 | |||
131 | return $params; |
||
132 | } |
||
133 | |||
134 | /** |
||
135 | * Prepare jqplot specific numbers ticks |
||
136 | * |
||
137 | * @since 1.8 |
||
138 | * |
||
139 | * @param array $data |
||
0 ignored issues
–
show
|
|||
140 | * @param $minValue |
||
141 | * @param $maxValue |
||
142 | * |
||
143 | * @return array |
||
144 | */ |
||
145 | public static function getNumbersTicks( $minValue, $maxValue ) { |
||
146 | $numbersticks = []; |
||
147 | |||
148 | // Calculate the tick values for the numbers, based on the |
||
149 | // lowest and highest number. jqPlot has its own option for |
||
150 | // calculating ticks automatically - "autoscale" - but it |
||
151 | // currently (September 2010, it also fails with the jpPlot 1.00b 2012) |
||
152 | // fails for numbers less than 1, and negative numbers. |
||
153 | // If both max and min are 0, just escape now. |
||
154 | if ( $maxValue == 0 && $minValue == 0 ) { |
||
155 | return null; |
||
156 | } |
||
157 | |||
158 | // Make the max and min slightly larger and bigger than the |
||
159 | // actual max and min, so that the bars don't directly touch |
||
160 | // the top and bottom of the graph |
||
161 | if ( $maxValue > 0 ) { |
||
162 | $maxValue += .001; |
||
163 | } |
||
164 | |||
165 | if ( $minValue < 0 ) { |
||
166 | $minValue -= .001; |
||
167 | } |
||
168 | |||
169 | if ( $maxValue == 0 ) { |
||
170 | $multipleOf10 = 0; |
||
171 | $maxAxis = 0; |
||
172 | } else { |
||
173 | $multipleOf10 = pow( 10, floor( log( $maxValue, 10 ) ) ); |
||
174 | $maxAxis = ceil( $maxValue / $multipleOf10 ) * $multipleOf10; |
||
175 | } |
||
176 | |||
177 | if ( $minValue == 0 ) { |
||
178 | $negativeMultipleOf10 = 0; |
||
179 | $minAxis = 0; |
||
180 | } else { |
||
181 | $negativeMultipleOf10 = -1 * pow( 10, floor( log( ( abs( $minValue ) ), 10 ) ) ); |
||
182 | $minAxis = ceil( $minValue / $negativeMultipleOf10 ) * $negativeMultipleOf10; |
||
183 | } |
||
184 | |||
185 | $biggerMultipleOf10 = max( $multipleOf10, -1 * $negativeMultipleOf10 ); |
||
186 | $lowestTick = floor( $minAxis / $biggerMultipleOf10 + .001 ); |
||
187 | $highestTick = ceil( $maxAxis / $biggerMultipleOf10 - .001 ); |
||
188 | |||
189 | for ( $i = $lowestTick; $i <= $highestTick; $i++ ) { |
||
190 | $numbersticks[] = ( $i * $biggerMultipleOf10 ); |
||
191 | } |
||
192 | |||
193 | return $numbersticks; |
||
194 | } |
||
195 | } |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.