@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | // error wrappers. |
84 | 84 | $errors = libxml_get_errors(); |
85 | 85 | |
86 | - foreach($errors as $error) |
|
86 | + foreach ($errors as $error) |
|
87 | 87 | { |
88 | 88 | $this->errors[] = new XMLHelper_SimpleXML_Error($this, $error); |
89 | 89 | } |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | |
98 | 98 | $xml = $function($subject); |
99 | 99 | |
100 | - if($xml instanceof \SimpleXMLElement) |
|
100 | + if ($xml instanceof \SimpleXMLElement) |
|
101 | 101 | { |
102 | 102 | return $xml; |
103 | 103 | } |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | |
108 | 108 | public function getConverter() : XMLHelper_Converter |
109 | 109 | { |
110 | - if($this->element instanceof \SimpleXMLElement) |
|
110 | + if ($this->element instanceof \SimpleXMLElement) |
|
111 | 111 | { |
112 | 112 | return XMLHelper::convertElement($this->element); |
113 | 113 | } |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | { |
47 | 47 | $data = @json_decode($serialized, true); |
48 | 48 | |
49 | - if(!is_array($data)) |
|
49 | + if (!is_array($data)) |
|
50 | 50 | { |
51 | 51 | throw new XMLHelper_Exception( |
52 | 52 | 'Could not unserialize error data', |
@@ -72,9 +72,9 @@ discard block |
||
72 | 72 | |
73 | 73 | private static function checkErrorData(array $data) : void |
74 | 74 | { |
75 | - foreach(self::$requiredKeys as $key) |
|
75 | + foreach (self::$requiredKeys as $key) |
|
76 | 76 | { |
77 | - if(!array_key_exists($key, $data)) |
|
77 | + if (!array_key_exists($key, $data)) |
|
78 | 78 | { |
79 | 79 | throw new XMLHelper_Exception( |
80 | 80 | 'Required key missing in error data', |
@@ -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])); |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | |
33 | 33 | public function addClass(string $name) |
34 | 34 | { |
35 | - if(!in_array($name, $this->classes)) { |
|
35 | + if (!in_array($name, $this->classes)) { |
|
36 | 36 | $this->classes[] = $name; |
37 | 37 | } |
38 | 38 | |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | |
42 | 42 | public function addClasses(array $names) |
43 | 43 | { |
44 | - foreach($names as $name) { |
|
44 | + foreach ($names as $name) { |
|
45 | 45 | $this->addClass($name); |
46 | 46 | } |
47 | 47 | |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | { |
58 | 58 | $idx = array_search($name, $this->classes); |
59 | 59 | |
60 | - if($idx !== false) { |
|
60 | + if ($idx !== false) { |
|
61 | 61 | unset($this->classes[$idx]); |
62 | 62 | sort($this->classes); |
63 | 63 | } |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | */ |
92 | 92 | public function classesToAttribute() : string |
93 | 93 | { |
94 | - if(!empty($this->classes)) |
|
94 | + if (!empty($this->classes)) |
|
95 | 95 | { |
96 | 96 | return sprintf( |
97 | 97 | ' class="%s" ', |
@@ -90,11 +90,11 @@ discard block |
||
90 | 90 | public function getParam($name, $default = null) |
91 | 91 | { |
92 | 92 | $value = $default; |
93 | - if(isset($_REQUEST[$name])) { |
|
93 | + if (isset($_REQUEST[$name])) { |
|
94 | 94 | $value = $_REQUEST[$name]; |
95 | 95 | } |
96 | 96 | |
97 | - if(isset($this->knownParams[$name])) { |
|
97 | + if (isset($this->knownParams[$name])) { |
|
98 | 98 | $value = $this->knownParams[$name]->validate($value); |
99 | 99 | } |
100 | 100 | |
@@ -185,13 +185,13 @@ discard block |
||
185 | 185 | * @param string $dispatcher Relative path to script to use for the URL. Append trailing slash if needed. |
186 | 186 | * @return string |
187 | 187 | */ |
188 | - public function buildURL($params = array(), string $dispatcher='') |
|
188 | + public function buildURL($params = array(), string $dispatcher = '') |
|
189 | 189 | { |
190 | - $url = rtrim($this->getBaseURL(), '/') . '/' . $dispatcher; |
|
190 | + $url = rtrim($this->getBaseURL(), '/').'/'.$dispatcher; |
|
191 | 191 | |
192 | 192 | // append any leftover parameters to the end of the URL |
193 | 193 | if (!empty($params)) { |
194 | - $url .= '?' . http_build_query($params, '', '&'); |
|
194 | + $url .= '?'.http_build_query($params, '', '&'); |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | return $url; |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | */ |
223 | 223 | public function registerParam($name) |
224 | 224 | { |
225 | - if(!isset($this->knownParams[$name])) { |
|
225 | + if (!isset($this->knownParams[$name])) { |
|
226 | 226 | $param = new Request_Param($this, $name); |
227 | 227 | $this->knownParams[$name] = $param; |
228 | 228 | } |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | */ |
240 | 240 | public function getRegisteredParam(string $name) : Request_Param |
241 | 241 | { |
242 | - if(isset($this->knownParams[$name])) { |
|
242 | + if (isset($this->knownParams[$name])) { |
|
243 | 243 | return $this->knownParams[$name]; |
244 | 244 | } |
245 | 245 | |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | { |
300 | 300 | static $accept; |
301 | 301 | |
302 | - if(!isset($accept)) { |
|
302 | + if (!isset($accept)) { |
|
303 | 303 | $accept = new Request_AcceptHeaders(); |
304 | 304 | } |
305 | 305 | |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | { |
319 | 319 | $_REQUEST[$name] = $value; |
320 | 320 | |
321 | - if(isset($this->knownParams[$name])) { |
|
321 | + if (isset($this->knownParams[$name])) { |
|
322 | 322 | unset($this->knownParams[$name]); |
323 | 323 | } |
324 | 324 | |
@@ -352,11 +352,11 @@ discard block |
||
352 | 352 | */ |
353 | 353 | public function removeParam(string $name) : Request |
354 | 354 | { |
355 | - if(isset($_REQUEST[$name])) { |
|
355 | + if (isset($_REQUEST[$name])) { |
|
356 | 356 | unset($_REQUEST[$name]); |
357 | 357 | } |
358 | 358 | |
359 | - if(isset($this->knownParams[$name])) { |
|
359 | + if (isset($this->knownParams[$name])) { |
|
360 | 360 | unset($this->knownParams[$name]); |
361 | 361 | } |
362 | 362 | |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | */ |
372 | 372 | public function removeParams(array $names) : Request |
373 | 373 | { |
374 | - foreach($names as $name) { |
|
374 | + foreach ($names as $name) { |
|
375 | 375 | $this->removeParam($name); |
376 | 376 | } |
377 | 377 | |
@@ -387,10 +387,10 @@ discard block |
||
387 | 387 | * @param string $name |
388 | 388 | * @return bool |
389 | 389 | */ |
390 | - public function getBool($name, $default=false) |
|
390 | + public function getBool($name, $default = false) |
|
391 | 391 | { |
392 | 392 | $value = $this->getParam($name, $default); |
393 | - if(ConvertHelper::isBoolean($value)) { |
|
393 | + if (ConvertHelper::isBoolean($value)) { |
|
394 | 394 | return ConvertHelper::string2bool($value); |
395 | 395 | } |
396 | 396 | |
@@ -399,11 +399,11 @@ discard block |
||
399 | 399 | |
400 | 400 | public function validate() |
401 | 401 | { |
402 | - foreach($this->knownParams as $param) |
|
402 | + foreach ($this->knownParams as $param) |
|
403 | 403 | { |
404 | 404 | $name = $param->getName(); |
405 | 405 | |
406 | - if($param->isRequired() && !$this->hasParam($name)) |
|
406 | + if ($param->isRequired() && !$this->hasParam($name)) |
|
407 | 407 | { |
408 | 408 | throw new Request_Exception( |
409 | 409 | 'Missing request parameter '.$name, |
@@ -425,10 +425,10 @@ discard block |
||
425 | 425 | * @param mixed $default |
426 | 426 | * @return string |
427 | 427 | */ |
428 | - public function getFilteredParam($name, $default=null) |
|
428 | + public function getFilteredParam($name, $default = null) |
|
429 | 429 | { |
430 | 430 | $val = $this->getParam($name, $default); |
431 | - if(is_string($val)) { |
|
431 | + if (is_string($val)) { |
|
432 | 432 | $val = htmlspecialchars(trim(strip_tags($val)), ENT_QUOTES, 'UTF-8'); |
433 | 433 | } |
434 | 434 | |
@@ -447,24 +447,24 @@ discard block |
||
447 | 447 | * @see Request::getJSONAssoc() |
448 | 448 | * @see Request::getJSONObject() |
449 | 449 | */ |
450 | - public function getJSON(string $name, bool $assoc=true) |
|
450 | + public function getJSON(string $name, bool $assoc = true) |
|
451 | 451 | { |
452 | 452 | $value = $this->getParam($name); |
453 | 453 | |
454 | - if(!empty($value) && is_string($value)) |
|
454 | + if (!empty($value) && is_string($value)) |
|
455 | 455 | { |
456 | 456 | $data = json_decode($value, $assoc); |
457 | 457 | |
458 | - if($assoc && is_array($data)) { |
|
458 | + if ($assoc && is_array($data)) { |
|
459 | 459 | return $data; |
460 | 460 | } |
461 | 461 | |
462 | - if(is_object($data)) { |
|
462 | + if (is_object($data)) { |
|
463 | 463 | return $data; |
464 | 464 | } |
465 | 465 | } |
466 | 466 | |
467 | - if($assoc) { |
|
467 | + if ($assoc) { |
|
468 | 468 | return array(); |
469 | 469 | } |
470 | 470 | |
@@ -481,7 +481,7 @@ discard block |
||
481 | 481 | public function getJSONAssoc(string $name) : array |
482 | 482 | { |
483 | 483 | $result = $this->getJSON($name); |
484 | - if(is_array($result)) { |
|
484 | + if (is_array($result)) { |
|
485 | 485 | return $result; |
486 | 486 | } |
487 | 487 | |
@@ -498,7 +498,7 @@ discard block |
||
498 | 498 | public function getJSONObject(string $name) : object |
499 | 499 | { |
500 | 500 | $result = $this->getJSON($name, false); |
501 | - if(is_object($result)) { |
|
501 | + if (is_object($result)) { |
|
502 | 502 | return $result; |
503 | 503 | } |
504 | 504 | |
@@ -511,10 +511,10 @@ discard block |
||
511 | 511 | * @param array|string $data |
512 | 512 | * @param bool $exit Whether to exit the script afterwards. |
513 | 513 | */ |
514 | - public static function sendJSON($data, bool $exit=true) |
|
514 | + public static function sendJSON($data, bool $exit = true) |
|
515 | 515 | { |
516 | 516 | $payload = $data; |
517 | - if(!is_string($payload)) { |
|
517 | + if (!is_string($payload)) { |
|
518 | 518 | $payload = json_encode($payload); |
519 | 519 | } |
520 | 520 | |
@@ -524,7 +524,7 @@ discard block |
||
524 | 524 | |
525 | 525 | echo $payload; |
526 | 526 | |
527 | - if($exit) |
|
527 | + if ($exit) |
|
528 | 528 | { |
529 | 529 | exit; |
530 | 530 | } |
@@ -536,7 +536,7 @@ discard block |
||
536 | 536 | * @param string $html |
537 | 537 | * @param bool $exit Whether to exit the script afterwards. |
538 | 538 | */ |
539 | - public static function sendHTML(string $html, bool $exit=true) |
|
539 | + public static function sendHTML(string $html, bool $exit = true) |
|
540 | 540 | { |
541 | 541 | header('Cache-Control: no-cache, must-revalidate'); |
542 | 542 | header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); |
@@ -544,7 +544,7 @@ discard block |
||
544 | 544 | |
545 | 545 | echo $html; |
546 | 546 | |
547 | - if($exit) |
|
547 | + if ($exit) |
|
548 | 548 | { |
549 | 549 | exit; |
550 | 550 | } |
@@ -560,7 +560,7 @@ discard block |
||
560 | 560 | * @param array $limitParams Whether to limit the comparison to these specific parameter names (if present) |
561 | 561 | * @return Request_URLComparer |
562 | 562 | */ |
563 | - public function createURLComparer(string $sourceURL, string $targetURL, array $limitParams=array()) : Request_URLComparer |
|
563 | + public function createURLComparer(string $sourceURL, string $targetURL, array $limitParams = array()) : Request_URLComparer |
|
564 | 564 | { |
565 | 565 | $comparer = new Request_URLComparer($this, $sourceURL, $targetURL); |
566 | 566 | $comparer->addLimitParams($limitParams); |
@@ -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 | } |