Passed
Push — master ( a594cd...3c388a )
by Sebastian
03:13
created
src/VariableInfo/Renderer/String/Array.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -13,15 +13,15 @@
 block discarded – undo
13 13
         return print_r($result, true);
14 14
     }
15 15
     
16
-    protected function traverseArray(array $array, int $level=0) : array
16
+    protected function traverseArray(array $array, int $level = 0) : array
17 17
     {
18 18
         $result = array();
19 19
         
20
-        foreach($array as $key => $val)
20
+        foreach ($array as $key => $val)
21 21
         {
22
-            if(is_array($val))
22
+            if (is_array($val))
23 23
             {
24
-                $result[$key] = $this->traverseArray($val, ($level+1));
24
+                $result[$key] = $this->traverseArray($val, ($level + 1));
25 25
             }
26 26
             else
27 27
             {
Please login to merge, or discard this patch.
src/Request.php 1 patch
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -90,11 +90,11 @@  discard block
 block discarded – undo
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
         
@@ -143,9 +143,9 @@  discard block
 block discarded – undo
143 143
         
144 144
         $exclude = array_merge($exclude, $this->getExcludeParams());
145 145
         
146
-        foreach($exclude as $name) 
146
+        foreach ($exclude as $name) 
147 147
         {
148
-            if(isset($vars[$name])) 
148
+            if (isset($vars[$name])) 
149 149
             {
150 150
                 unset($vars[$name]);
151 151
             }
@@ -156,9 +156,9 @@  discard block
 block discarded – undo
156 156
         // remove the HTML_QuickForm2 form variable if present, to 
157 157
         // avoid redirect loops when using the refresh URL in
158 158
         // a page in which a form has been submitted.
159
-        foreach($names as $name) 
159
+        foreach ($names as $name) 
160 160
         {
161
-            if(strstr($name, '_qf__')) 
161
+            if (strstr($name, '_qf__')) 
162 162
             {
163 163
                 unset($vars[$name]);
164 164
                 break;
@@ -186,13 +186,13 @@  discard block
 block discarded – undo
186 186
      * @param string $dispatcher Relative path to script to use for the URL. Append trailing slash if needed.
187 187
      * @return string
188 188
      */
189
-    public function buildURL($params = array(), string $dispatcher='')
189
+    public function buildURL($params = array(), string $dispatcher = '')
190 190
     {
191
-        $url = rtrim($this->getBaseURL(), '/') . '/' . $dispatcher;
191
+        $url = rtrim($this->getBaseURL(), '/').'/'.$dispatcher;
192 192
         
193 193
         // append any leftover parameters to the end of the URL
194 194
         if (!empty($params)) {
195
-            $url .= '?' . http_build_query($params, '', '&');
195
+            $url .= '?'.http_build_query($params, '', '&');
196 196
         }
197 197
         
198 198
         return $url;
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
      */
224 224
     public function registerParam($name)
225 225
     {
226
-        if(!isset($this->knownParams[$name])) {
226
+        if (!isset($this->knownParams[$name])) {
227 227
             $param = new Request_Param($this, $name);
228 228
             $this->knownParams[$name] = $param;
229 229
         }
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
     */
241 241
     public function getRegisteredParam(string $name) : Request_Param
242 242
     {
243
-        if(isset($this->knownParams[$name])) {
243
+        if (isset($this->knownParams[$name])) {
244 244
             return $this->knownParams[$name];
245 245
         }
246 246
         
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
     {
301 301
         static $accept;
302 302
         
303
-        if(!isset($accept)) {
303
+        if (!isset($accept)) {
304 304
             $accept = new Request_AcceptHeaders();
305 305
         }
306 306
         
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
     {
320 320
         $_REQUEST[$name] = $value;
321 321
         
322
-        if(isset($this->knownParams[$name])) {
322
+        if (isset($this->knownParams[$name])) {
323 323
             unset($this->knownParams[$name]);
324 324
         }
325 325
         
@@ -353,11 +353,11 @@  discard block
 block discarded – undo
353 353
     */
354 354
     public function removeParam(string $name) : Request
355 355
     {
356
-        if(isset($_REQUEST[$name])) {
356
+        if (isset($_REQUEST[$name])) {
357 357
             unset($_REQUEST[$name]);
358 358
         }
359 359
         
360
-        if(isset($this->knownParams[$name])) {
360
+        if (isset($this->knownParams[$name])) {
361 361
             unset($this->knownParams[$name]);
362 362
         }
363 363
         
@@ -372,7 +372,7 @@  discard block
 block discarded – undo
372 372
     */
373 373
     public function removeParams(array $names) : Request
374 374
     {
375
-        foreach($names as $name) {
375
+        foreach ($names as $name) {
376 376
             $this->removeParam($name);
377 377
         }
378 378
         
@@ -388,10 +388,10 @@  discard block
 block discarded – undo
388 388
      * @param string $name
389 389
      * @return bool
390 390
      */
391
-    public function getBool($name, $default=false)
391
+    public function getBool($name, $default = false)
392 392
     {
393 393
         $value = $this->getParam($name, $default);
394
-        if(ConvertHelper::isBoolean($value)) {
394
+        if (ConvertHelper::isBoolean($value)) {
395 395
             return ConvertHelper::string2bool($value);
396 396
         }
397 397
         
@@ -400,11 +400,11 @@  discard block
 block discarded – undo
400 400
     
401 401
     public function validate()
402 402
     {
403
-        foreach($this->knownParams as $param) 
403
+        foreach ($this->knownParams as $param) 
404 404
         {
405 405
             $name = $param->getName();
406 406
             
407
-            if($param->isRequired() && !$this->hasParam($name)) 
407
+            if ($param->isRequired() && !$this->hasParam($name)) 
408 408
             {
409 409
                 throw new Request_Exception(
410 410
                     'Missing request parameter '.$name,
@@ -426,10 +426,10 @@  discard block
 block discarded – undo
426 426
      * @param mixed $default
427 427
      * @return string
428 428
      */
429
-    public function getFilteredParam($name, $default=null)
429
+    public function getFilteredParam($name, $default = null)
430 430
     {
431 431
         $val = $this->getParam($name, $default);
432
-        if(is_string($val)) {
432
+        if (is_string($val)) {
433 433
             $val = htmlspecialchars(trim(strip_tags($val)), ENT_QUOTES, 'UTF-8');
434 434
         }
435 435
         
@@ -448,24 +448,24 @@  discard block
 block discarded – undo
448 448
     * @see Request::getJSONAssoc()
449 449
     * @see Request::getJSONObject()
450 450
     */
451
-    public function getJSON(string $name, bool $assoc=true)
451
+    public function getJSON(string $name, bool $assoc = true)
452 452
     {
453 453
         $value = $this->getParam($name);
454 454
         
455
-        if(!empty($value) && is_string($value)) 
455
+        if (!empty($value) && is_string($value)) 
456 456
         {
457 457
             $data = json_decode($value, $assoc);
458 458
             
459
-            if($assoc && is_array($data)) {
459
+            if ($assoc && is_array($data)) {
460 460
                 return $data;
461 461
             }
462 462
             
463
-            if(is_object($data)) {
463
+            if (is_object($data)) {
464 464
                 return $data;
465 465
             }
466 466
         }
467 467
         
468
-        if($assoc) {
468
+        if ($assoc) {
469 469
             return array();
470 470
         }
471 471
         
@@ -482,7 +482,7 @@  discard block
 block discarded – undo
482 482
     public function getJSONAssoc(string $name) : array
483 483
     {
484 484
         $result = $this->getJSON($name);
485
-        if(is_array($result)) {
485
+        if (is_array($result)) {
486 486
             return $result;
487 487
         }
488 488
         
@@ -499,7 +499,7 @@  discard block
 block discarded – undo
499 499
     public function getJSONObject(string $name) : object
500 500
     {
501 501
         $result = $this->getJSON($name, false);
502
-        if(is_object($result)) {
502
+        if (is_object($result)) {
503 503
             return $result;
504 504
         }
505 505
         
@@ -512,10 +512,10 @@  discard block
 block discarded – undo
512 512
     * @param array|string $data
513 513
     * @param bool $exit Whether to exit the script afterwards.
514 514
     */
515
-    public static function sendJSON($data, bool $exit=true)
515
+    public static function sendJSON($data, bool $exit = true)
516 516
     {
517 517
         $payload = $data;
518
-        if(!is_string($payload)) {
518
+        if (!is_string($payload)) {
519 519
             $payload = json_encode($payload);
520 520
         }
521 521
         
@@ -525,7 +525,7 @@  discard block
 block discarded – undo
525 525
         
526 526
         echo $payload;
527 527
         
528
-        if($exit) 
528
+        if ($exit) 
529 529
         {
530 530
             exit;
531 531
         }
@@ -537,7 +537,7 @@  discard block
 block discarded – undo
537 537
     * @param string $html
538 538
     * @param bool $exit Whether to exit the script afterwards.
539 539
     */
540
-    public static function sendHTML(string $html, bool $exit=true)
540
+    public static function sendHTML(string $html, bool $exit = true)
541 541
     {
542 542
         header('Cache-Control: no-cache, must-revalidate');
543 543
         header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
@@ -545,7 +545,7 @@  discard block
 block discarded – undo
545 545
         
546 546
         echo $html;
547 547
         
548
-        if($exit)
548
+        if ($exit)
549 549
         {
550 550
             exit;
551 551
         }
@@ -561,7 +561,7 @@  discard block
 block discarded – undo
561 561
     * @param array $limitParams Whether to limit the comparison to these specific parameter names (if present)
562 562
     * @return Request_URLComparer
563 563
     */
564
-    public function createURLComparer(string $sourceURL, string $targetURL, array $limitParams=array()) : Request_URLComparer
564
+    public function createURLComparer(string $sourceURL, string $targetURL, array $limitParams = array()) : Request_URLComparer
565 565
     {
566 566
         $comparer = new Request_URLComparer($this, $sourceURL, $targetURL);
567 567
         $comparer->addLimitParams($limitParams);
Please login to merge, or discard this patch.
src/ConvertHelper/DateInterval.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@
 block discarded – undo
57 57
         
58 58
         $interval = $d2->diff($d1);
59 59
         
60
-        if(!$interval instanceof \DateInterval) 
60
+        if (!$interval instanceof \DateInterval) 
61 61
         {
62 62
             throw new ConvertHelper_Exception(
63 63
                 'Cannot create interval',
Please login to merge, or discard this patch.
src/XMLHelper/SimpleXML.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
         }
Please login to merge, or discard this patch.
src/XMLHelper/DOMErrors/Error.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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',
Please login to merge, or discard this patch.
src/XMLHelper/HTMLLoader.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
         }
Please login to merge, or discard this patch.
src/XMLHelper/DOMErrors.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -33,13 +33,13 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
         }
Please login to merge, or discard this patch.
src/XMLHelper.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
      */
106 106
     public function addAttribute($parent, string $name, $value)
107 107
     {
108
-        if(!$parent instanceof \DOMNode) {
108
+        if (!$parent instanceof \DOMNode) {
109 109
             throw new XMLHelper_Exception(
110 110
                 'The specified parent node is not a node instance.',
111 111
                 sprintf('Tried adding attribute [%s].', $name),
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
 
228 228
         if (!empty($text)) {
229 229
             $fragment = $this->dom->createDocumentFragment();
230
-            if(!@$fragment->appendXML($text)) {
230
+            if (!@$fragment->appendXML($text)) {
231 231
                 throw new XMLHelper_Exception(
232 232
                     'Cannot append XML fragment',
233 233
                     sprintf(
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
      * @param array $attributes
270 270
      * @return \DOMNode
271 271
      */
272
-    public function createRoot($name, $attributes=array())
272
+    public function createRoot($name, $attributes = array())
273 273
     {
274 274
         $root = $this->dom->appendChild($this->dom->createElement($name));
275 275
         $this->addAttributes($root, $attributes);
@@ -290,8 +290,8 @@  discard block
 block discarded – undo
290 290
         $string = str_replace('&lt;', 'LT_ESCAPE', $string);
291 291
         $string = str_replace('&gt;', 'GT_ESCAPE', $string);
292 292
 
293
-        $string = str_replace('&nbsp;',' ',  $string);
294
-        $string = str_replace('&','&amp;',  $string);
293
+        $string = str_replace('&nbsp;', ' ', $string);
294
+        $string = str_replace('&', '&amp;', $string);
295 295
 
296 296
         return $string;
297 297
     }
@@ -306,8 +306,8 @@  discard block
 block discarded – undo
306 306
      */
307 307
     public static function downloadXML($xml, $filename = 'download.xml')
308 308
     {
309
-        if(!headers_sent() && !self::$simulation) {
310
-            header('Content-Disposition: attachment; filename="' . $filename . '"');
309
+        if (!headers_sent() && !self::$simulation) {
310
+            header('Content-Disposition: attachment; filename="'.$filename.'"');
311 311
         }
312 312
         
313 313
         echo $xml;
@@ -322,11 +322,11 @@  discard block
 block discarded – undo
322 322
      */
323 323
     public static function displayXML($xml)
324 324
     {
325
-        if(!headers_sent() && !self::$simulation) {
325
+        if (!headers_sent() && !self::$simulation) {
326 326
             header('Content-Type:text/xml; charset=utf-8');
327 327
         }
328 328
         
329
-        if(self::$simulation) {
329
+        if (self::$simulation) {
330 330
             $xml = '<pre>'.htmlspecialchars($xml).'</pre>';
331 331
         }
332 332
         
@@ -344,10 +344,10 @@  discard block
 block discarded – undo
344 344
      * @param string[] $customInfo Associative array with name => value pairs for custom tags to add to the output xml
345 345
      * @see buildErrorXML()
346 346
      */
347
-    public static function displayErrorXML($code, $message, $title, $customInfo=array())
347
+    public static function displayErrorXML($code, $message, $title, $customInfo = array())
348 348
     {
349
-        if(!headers_sent() && !self::$simulation) {
350
-            header('HTTP/1.1 400 Bad Request: ' . $title, true, 400);
349
+        if (!headers_sent() && !self::$simulation) {
350
+            header('HTTP/1.1 400 Bad Request: '.$title, true, 400);
351 351
         }
352 352
 
353 353
         self::displayXML(self::buildErrorXML($code, $message, $title, $customInfo));
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
     
356 356
     protected static $simulation = false;
357 357
     
358
-    public static function setSimulation($simulate=true)
358
+    public static function setSimulation($simulate = true)
359 359
     {
360 360
         self::$simulation = $simulate;
361 361
     }
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
      * @param string $title
404 404
      * @return string
405 405
      */
406
-    public static function buildErrorXML($code, $message, $title, $customInfo=array())
406
+    public static function buildErrorXML($code, $message, $title, $customInfo = array())
407 407
     {
408 408
         $xml = new \DOMDocument('1.0', 'UTF-8');
409 409
         $xml->formatOutput = true;
@@ -417,7 +417,7 @@  discard block
 block discarded – undo
417 417
         $helper->addTextTag($root, 'title', $title);
418 418
         $helper->addTextTag($root, 'request_uri', $_SERVER['REQUEST_URI']);
419 419
         
420
-        foreach($customInfo as $name => $value) {
420
+        foreach ($customInfo as $name => $value) {
421 421
             $helper->addTextTag($root, $name, $value);
422 422
         }
423 423
 
Please login to merge, or discard this patch.
docs/libxml/generate-errorcodes.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@
 block discarded – undo
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]));
Please login to merge, or discard this patch.