@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | */ |
108 | 108 | private static function checkFragment(string $fragment) : void |
109 | 109 | { |
110 | - if(!stristr($fragment, '<body') && !stristr($fragment, 'doctype')) |
|
110 | + if (!stristr($fragment, '<body') && !stristr($fragment, 'doctype')) |
|
111 | 111 | { |
112 | 112 | return; |
113 | 113 | } |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | |
208 | 208 | // capture all elements except the body tag itself |
209 | 209 | $xml = ''; |
210 | - foreach($nodes as $child) |
|
210 | + foreach ($nodes as $child) |
|
211 | 211 | { |
212 | 212 | $xml .= $this->dom->saveXML($child); |
213 | 213 | } |
@@ -33,13 +33,13 @@ discard block |
||
33 | 33 | */ |
34 | 34 | public function __construct(array $libxmlErrors) |
35 | 35 | { |
36 | - foreach($libxmlErrors as $error) |
|
36 | + foreach ($libxmlErrors as $error) |
|
37 | 37 | { |
38 | - if($error instanceof XMLHelper_DOMErrors_Error) |
|
38 | + if ($error instanceof XMLHelper_DOMErrors_Error) |
|
39 | 39 | { |
40 | 40 | $this->errors[] = $error; |
41 | 41 | } |
42 | - else if($error instanceof \LibXMLError) |
|
42 | + else if ($error instanceof \LibXMLError) |
|
43 | 43 | { |
44 | 44 | $this->errors[] = new XMLHelper_DOMErrors_Error($error); |
45 | 45 | } |
@@ -117,9 +117,9 @@ discard block |
||
117 | 117 | { |
118 | 118 | $result = array(); |
119 | 119 | |
120 | - foreach($this->errors as $error) |
|
120 | + foreach ($this->errors as $error) |
|
121 | 121 | { |
122 | - if($error->isLevel($level)) |
|
122 | + if ($error->isLevel($level)) |
|
123 | 123 | { |
124 | 124 | $result[] = $error; |
125 | 125 | } |
@@ -138,9 +138,9 @@ discard block |
||
138 | 138 | { |
139 | 139 | $result = array(); |
140 | 140 | |
141 | - foreach($this->errors as $error) |
|
141 | + foreach ($this->errors as $error) |
|
142 | 142 | { |
143 | - if($error->isCode($code)) |
|
143 | + if ($error->isCode($code)) |
|
144 | 144 | { |
145 | 145 | $result[] = $error; |
146 | 146 | } |
@@ -157,9 +157,9 @@ discard block |
||
157 | 157 | */ |
158 | 158 | public function hasErrorsByLevel(int $level) : bool |
159 | 159 | { |
160 | - foreach($this->errors as $error) |
|
160 | + foreach ($this->errors as $error) |
|
161 | 161 | { |
162 | - if($error->isLevel($level)) |
|
162 | + if ($error->isLevel($level)) |
|
163 | 163 | { |
164 | 164 | return true; |
165 | 165 | } |
@@ -176,9 +176,9 @@ discard block |
||
176 | 176 | */ |
177 | 177 | public function hasErrorsByCode(int $code) : bool |
178 | 178 | { |
179 | - foreach($this->errors as $error) |
|
179 | + foreach ($this->errors as $error) |
|
180 | 180 | { |
181 | - if($error->isCode($code)) |
|
181 | + if ($error->isCode($code)) |
|
182 | 182 | { |
183 | 183 | return true; |
184 | 184 | } |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | { |
192 | 192 | $result = array(); |
193 | 193 | |
194 | - foreach($this->errors as $error) |
|
194 | + foreach ($this->errors as $error) |
|
195 | 195 | { |
196 | 196 | $result[] = $error->toArray(); |
197 | 197 | } |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | { |
211 | 211 | $data = array(); |
212 | 212 | |
213 | - foreach($this->errors as $error) |
|
213 | + foreach ($this->errors as $error) |
|
214 | 214 | { |
215 | 215 | $data[] = $error->serialize(); |
216 | 216 | } |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | $parts = explode(self::SERIALIZE_SEPARATOR, $serialized); |
232 | 232 | $list = array(); |
233 | 233 | |
234 | - foreach($parts as $part) |
|
234 | + foreach ($parts as $part) |
|
235 | 235 | { |
236 | 236 | $list[] = XMLHelper_DOMErrors_Error::fromSerialized($part); |
237 | 237 | } |
@@ -22,7 +22,7 @@ |
||
22 | 22 | $lines = explode("\n", $list); |
23 | 23 | $reverseArray = array(); |
24 | 24 | |
25 | - foreach($lines as $line) |
|
25 | + foreach ($lines as $line) |
|
26 | 26 | { |
27 | 27 | $parts = explode('=', $line); |
28 | 28 | $name = trim(str_replace('XML_ERR_', '', $parts[0])); |
@@ -29,7 +29,7 @@ |
||
29 | 29 | |
30 | 30 | public function __construct($callback) |
31 | 31 | { |
32 | - if(!is_callable($callback)) |
|
32 | + if (!is_callable($callback)) |
|
33 | 33 | { |
34 | 34 | throw new Request_Exception( |
35 | 35 | 'Invalid exclusion callback', |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | * @param bool $exclude |
49 | 49 | * @return Request_RefreshParams |
50 | 50 | */ |
51 | - public function setExcludeSessionName(bool $exclude=true) : Request_RefreshParams |
|
51 | + public function setExcludeSessionName(bool $exclude = true) : Request_RefreshParams |
|
52 | 52 | { |
53 | 53 | $this->setOption('exclude-session-name', $exclude); |
54 | 54 | return $this; |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | |
71 | 71 | public function excludeParamByName(string $paramName) : Request_RefreshParams |
72 | 72 | { |
73 | - if($paramName !== '') |
|
73 | + if ($paramName !== '') |
|
74 | 74 | { |
75 | 75 | $this->excludes[] = new Request_RefreshParams_Exclude_Name($paramName); |
76 | 76 | } |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | */ |
108 | 108 | public function excludeParamsByName(array $paramNames) : Request_RefreshParams |
109 | 109 | { |
110 | - foreach($paramNames as $name) |
|
110 | + foreach ($paramNames as $name) |
|
111 | 111 | { |
112 | 112 | $this->excludeParamByName((string)$name); |
113 | 113 | } |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | */ |
140 | 140 | public function overrideParams(array $params) : Request_RefreshParams |
141 | 141 | { |
142 | - foreach($params as $name => $value) |
|
142 | + foreach ($params as $name => $value) |
|
143 | 143 | { |
144 | 144 | $this->overrideParam((string)$name, $value); |
145 | 145 | } |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | */ |
174 | 174 | private function autoExcludeSessionName(array &$excludes) : void |
175 | 175 | { |
176 | - if($this->getBoolOption('exclude-session-name')) |
|
176 | + if ($this->getBoolOption('exclude-session-name')) |
|
177 | 177 | { |
178 | 178 | $excludes[] = new Request_RefreshParams_Exclude_Name(session_name()); |
179 | 179 | } |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | */ |
188 | 188 | private function autoExcludeQuickform(array &$excludes) : void |
189 | 189 | { |
190 | - if($this->getBoolOption('exclude-quickform-submitter')) |
|
190 | + if ($this->getBoolOption('exclude-quickform-submitter')) |
|
191 | 191 | { |
192 | 192 | $excludes[] = new Request_RefreshParams_Exclude_Callback(function(string $paramName) |
193 | 193 | { |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | // Note: using this loop instead of array_merge, |
210 | 210 | // because array_merge has weird behavior when |
211 | 211 | // using numeric keys. |
212 | - foreach($this->overrides as $name => $val) |
|
212 | + foreach ($this->overrides as $name => $val) |
|
213 | 213 | { |
214 | 214 | $params[$name] = $val; |
215 | 215 | } |
@@ -227,11 +227,11 @@ discard block |
||
227 | 227 | { |
228 | 228 | $result = array(); |
229 | 229 | |
230 | - foreach($params as $name => $value) |
|
230 | + foreach ($params as $name => $value) |
|
231 | 231 | { |
232 | 232 | $name = (string)$name; |
233 | 233 | |
234 | - if(!$this->isExcluded($name, $value)) |
|
234 | + if (!$this->isExcluded($name, $value)) |
|
235 | 235 | { |
236 | 236 | $result[$name] = $value; |
237 | 237 | } |
@@ -252,9 +252,9 @@ discard block |
||
252 | 252 | { |
253 | 253 | $excludes = $this->resolveExcludes(); |
254 | 254 | |
255 | - foreach($excludes as $exclude) |
|
255 | + foreach ($excludes as $exclude) |
|
256 | 256 | { |
257 | - if($exclude->isExcluded($paramName, $paramValue)) |
|
257 | + if ($exclude->isExcluded($paramName, $paramValue)) |
|
258 | 258 | { |
259 | 259 | return true; |
260 | 260 | } |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | |
242 | 242 | $output = curl_exec($ch); |
243 | 243 | |
244 | - if(isset($this->logfilePointer)) |
|
244 | + if (isset($this->logfilePointer)) |
|
245 | 245 | { |
246 | 246 | fclose($this->logfilePointer); |
247 | 247 | } |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | // CURL will complain about an empty response when the |
254 | 254 | // server sends a 100-continue code. That should not be |
255 | 255 | // regarded as an error. |
256 | - if($output === false && $this->response->getCode() !== 100) |
|
256 | + if ($output === false && $this->response->getCode() !== 100) |
|
257 | 257 | { |
258 | 258 | $curlCode = curl_errno($ch); |
259 | 259 | |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | { |
290 | 290 | $ch = curl_init(); |
291 | 291 | |
292 | - if(!is_resource($ch)) |
|
292 | + if (!is_resource($ch)) |
|
293 | 293 | { |
294 | 294 | throw new RequestHelper_Exception( |
295 | 295 | 'Could not initialize a new cURL instance.', |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | } |
300 | 300 | |
301 | 301 | $this->setHeader('Content-Length', (string)$this->boundaries->getContentLength()); |
302 | - $this->setHeader('Content-Type', 'multipart/form-data; boundary=' . $this->mimeBoundary); |
|
302 | + $this->setHeader('Content-Type', 'multipart/form-data; boundary='.$this->mimeBoundary); |
|
303 | 303 | |
304 | 304 | curl_setopt($ch, CURLOPT_POST, true); |
305 | 305 | curl_setopt($ch, CURLOPT_URL, $url->getNormalizedWithoutAuth()); |
@@ -312,18 +312,18 @@ discard block |
||
312 | 312 | |
313 | 313 | $loggingEnabled = $this->configureLogging($ch); |
314 | 314 | |
315 | - if(!$loggingEnabled) |
|
315 | + if (!$loggingEnabled) |
|
316 | 316 | { |
317 | 317 | curl_setopt($ch, CURLINFO_HEADER_OUT, true); |
318 | 318 | } |
319 | 319 | |
320 | - if($this->verifySSL) |
|
320 | + if ($this->verifySSL) |
|
321 | 321 | { |
322 | 322 | curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); |
323 | 323 | curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); |
324 | 324 | } |
325 | 325 | |
326 | - if($url->hasUsername()) |
|
326 | + if ($url->hasUsername()) |
|
327 | 327 | { |
328 | 328 | curl_setopt($ch, CURLOPT_USERNAME, $url->getUsername()); |
329 | 329 | curl_setopt($ch, CURLOPT_PASSWORD, $url->getPassword()); |
@@ -338,14 +338,14 @@ discard block |
||
338 | 338 | */ |
339 | 339 | protected function configureLogging($ch) : bool |
340 | 340 | { |
341 | - if(empty($this->logfile)) |
|
341 | + if (empty($this->logfile)) |
|
342 | 342 | { |
343 | 343 | return false; |
344 | 344 | } |
345 | 345 | |
346 | 346 | $res = fopen($this->logfile, 'w+'); |
347 | 347 | |
348 | - if($res === false) |
|
348 | + if ($res === false) |
|
349 | 349 | { |
350 | 350 | throw new RequestHelper_Exception( |
351 | 351 | 'Cannot open logfile for writing.', |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | |
376 | 376 | $this->setHeader('Expect', ''); |
377 | 377 | |
378 | - foreach($this->headers as $name => $value) { |
|
378 | + foreach ($this->headers as $name => $value) { |
|
379 | 379 | $result[] = $name.': '.$value; |
380 | 380 | } |
381 | 381 | |
@@ -392,7 +392,7 @@ discard block |
||
392 | 392 | { |
393 | 393 | $response = $this->getResponse(); |
394 | 394 | |
395 | - if($response !== null) { |
|
395 | + if ($response !== null) { |
|
396 | 396 | return $response->getHeaders(); |
397 | 397 | } |
398 | 398 | |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | */ |
429 | 429 | public function getHeader(string $name) : string |
430 | 430 | { |
431 | - if(isset($this->headers[$name])) |
|
431 | + if (isset($this->headers[$name])) |
|
432 | 432 | { |
433 | 433 | return $this->headers[$name]; |
434 | 434 | } |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | |
244 | 244 | if (!empty($text)) { |
245 | 245 | $fragment = $this->dom->createDocumentFragment(); |
246 | - if(!@$fragment->appendXML($text)) { |
|
246 | + if (!@$fragment->appendXML($text)) { |
|
247 | 247 | throw new XMLHelper_Exception( |
248 | 248 | 'Cannot append XML fragment', |
249 | 249 | sprintf( |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | * @param array<string,mixed> $attributes |
286 | 286 | * @return DOMNode |
287 | 287 | */ |
288 | - public function createRoot(string $name, array $attributes=array()) |
|
288 | + public function createRoot(string $name, array $attributes = array()) |
|
289 | 289 | { |
290 | 290 | $root = $this->dom->appendChild($this->dom->createElement($name)); |
291 | 291 | $this->addAttributes($root, $attributes); |
@@ -311,8 +311,8 @@ discard block |
||
311 | 311 | $string = str_replace('<', 'LT_ESCAPE', $string); |
312 | 312 | $string = str_replace('>', 'GT_ESCAPE', $string); |
313 | 313 | |
314 | - $string = str_replace(' ',' ', $string); |
|
315 | - $string = str_replace('&','&', $string); |
|
314 | + $string = str_replace(' ', ' ', $string); |
|
315 | + $string = str_replace('&', '&', $string); |
|
316 | 316 | |
317 | 317 | return $string; |
318 | 318 | } |
@@ -331,9 +331,9 @@ discard block |
||
331 | 331 | */ |
332 | 332 | public static function downloadXML(string $xml, string $filename = 'download.xml') : void |
333 | 333 | { |
334 | - if(!headers_sent() && !self::$simulation) |
|
334 | + if (!headers_sent() && !self::$simulation) |
|
335 | 335 | { |
336 | - header('Content-Disposition: attachment; filename="' . $filename . '"'); |
|
336 | + header('Content-Disposition: attachment; filename="'.$filename.'"'); |
|
337 | 337 | } |
338 | 338 | |
339 | 339 | echo $xml; |
@@ -347,12 +347,12 @@ discard block |
||
347 | 347 | */ |
348 | 348 | public static function displayXML(string $xml) : void |
349 | 349 | { |
350 | - if(!headers_sent() && !self::$simulation) |
|
350 | + if (!headers_sent() && !self::$simulation) |
|
351 | 351 | { |
352 | 352 | header('Content-Type:text/xml; charset=utf-8'); |
353 | 353 | } |
354 | 354 | |
355 | - if(self::$simulation) |
|
355 | + if (self::$simulation) |
|
356 | 356 | { |
357 | 357 | $xml = '<pre>'.htmlspecialchars($xml).'</pre>'; |
358 | 358 | } |
@@ -370,16 +370,16 @@ discard block |
||
370 | 370 | * @param array<string,string> $customInfo Associative array with name => value pairs for custom tags to add to the output xml |
371 | 371 | * @see buildErrorXML() |
372 | 372 | */ |
373 | - public static function displayErrorXML($code, string $message, string $title, array $customInfo=array()) |
|
373 | + public static function displayErrorXML($code, string $message, string $title, array $customInfo = array()) |
|
374 | 374 | { |
375 | - if(!headers_sent() && !self::$simulation) { |
|
376 | - header('HTTP/1.1 400 Bad Request: ' . $title, true, 400); |
|
375 | + if (!headers_sent() && !self::$simulation) { |
|
376 | + header('HTTP/1.1 400 Bad Request: '.$title, true, 400); |
|
377 | 377 | } |
378 | 378 | |
379 | 379 | self::displayXML(self::buildErrorXML($code, $message, $title, $customInfo)); |
380 | 380 | } |
381 | 381 | |
382 | - public static function setSimulation(bool $simulate=true) : void |
|
382 | + public static function setSimulation(bool $simulate = true) : void |
|
383 | 383 | { |
384 | 384 | self::$simulation = $simulate; |
385 | 385 | } |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | * @param array<string,string> $customInfo |
429 | 429 | * @return string |
430 | 430 | */ |
431 | - public static function buildErrorXML($code, string $message, string $title, array $customInfo=array()) |
|
431 | + public static function buildErrorXML($code, string $message, string $title, array $customInfo = array()) |
|
432 | 432 | { |
433 | 433 | $xml = new DOMDocument('1.0', 'UTF-8'); |
434 | 434 | $xml->formatOutput = true; |
@@ -442,7 +442,7 @@ discard block |
||
442 | 442 | $helper->addTextTag($root, 'title', $title); |
443 | 443 | $helper->addTextTag($root, 'request_uri', $_SERVER['REQUEST_URI']); |
444 | 444 | |
445 | - foreach($customInfo as $name => $value) { |
|
445 | + foreach ($customInfo as $name => $value) { |
|
446 | 446 | $helper->addTextTag($root, $name, $value); |
447 | 447 | } |
448 | 448 |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | */ |
109 | 109 | public static function json($subject) : string |
110 | 110 | { |
111 | - if(!is_string($subject)) |
|
111 | + if (!is_string($subject)) |
|
112 | 112 | { |
113 | 113 | $subject = json_encode($subject, JSON_PRETTY_PRINT); |
114 | 114 | } |
@@ -125,9 +125,9 @@ discard block |
||
125 | 125 | * @param bool $formatSource Whether to format the source with indentation to make it readable. |
126 | 126 | * @return string |
127 | 127 | */ |
128 | - public static function xml(string $xml, bool $formatSource=false) : string |
|
128 | + public static function xml(string $xml, bool $formatSource = false) : string |
|
129 | 129 | { |
130 | - if($formatSource) |
|
130 | + if ($formatSource) |
|
131 | 131 | { |
132 | 132 | $dom = new DOMDocument(); |
133 | 133 | $dom->preserveWhiteSpace = false; |
@@ -148,9 +148,9 @@ discard block |
||
148 | 148 | * @param bool $formatSource |
149 | 149 | * @return string |
150 | 150 | */ |
151 | - public static function html(string $html, bool $formatSource=false) : string |
|
151 | + public static function html(string $html, bool $formatSource = false) : string |
|
152 | 152 | { |
153 | - if($formatSource) |
|
153 | + if ($formatSource) |
|
154 | 154 | { |
155 | 155 | $dom = new DOMDocument(); |
156 | 156 | $dom->preserveWhiteSpace = false; |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | */ |
49 | 49 | private function initUnits() : void |
50 | 50 | { |
51 | - if(isset(self::$units)) |
|
51 | + if (isset(self::$units)) |
|
52 | 52 | { |
53 | 53 | return; |
54 | 54 | } |
@@ -90,12 +90,12 @@ discard block |
||
90 | 90 | public function toString() : string |
91 | 91 | { |
92 | 92 | // specifically handle zero |
93 | - if($this->seconds <= 0) |
|
93 | + if ($this->seconds <= 0) |
|
94 | 94 | { |
95 | - return '0 ' . t('seconds'); |
|
95 | + return '0 '.t('seconds'); |
|
96 | 96 | } |
97 | 97 | |
98 | - if($this->seconds < 1) |
|
98 | + if ($this->seconds < 1) |
|
99 | 99 | { |
100 | 100 | return t('less than a second'); |
101 | 101 | } |
@@ -104,12 +104,12 @@ discard block |
||
104 | 104 | |
105 | 105 | $last = array_pop($tokens); |
106 | 106 | |
107 | - if(empty($tokens)) |
|
107 | + if (empty($tokens)) |
|
108 | 108 | { |
109 | 109 | return $last; |
110 | 110 | } |
111 | 111 | |
112 | - return implode(', ', $tokens) . ' ' . t('and') . ' ' . $last; |
|
112 | + return implode(', ', $tokens).' '.t('and').' '.$last; |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | /** |
@@ -122,18 +122,18 @@ discard block |
||
122 | 122 | $seconds = $this->seconds; |
123 | 123 | $tokens = array(); |
124 | 124 | |
125 | - foreach(self::$units as $def) |
|
125 | + foreach (self::$units as $def) |
|
126 | 126 | { |
127 | 127 | $unitValue = intval($seconds / $def['value']); |
128 | 128 | |
129 | - if($unitValue <= 0) |
|
129 | + if ($unitValue <= 0) |
|
130 | 130 | { |
131 | 131 | continue; |
132 | 132 | } |
133 | 133 | |
134 | - $item = strval($unitValue) . ' '; |
|
134 | + $item = strval($unitValue).' '; |
|
135 | 135 | |
136 | - if(abs($unitValue) > 1) |
|
136 | + if (abs($unitValue) > 1) |
|
137 | 137 | { |
138 | 138 | $item .= $def['plural']; |
139 | 139 | } |