Completed
Branch develop (fa72bb)
by
unknown
26:08
created
htdocs/includes/restler/framework/Luracast/Restler/Data/Validator.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
         if (is_numeric($input) && '-' != substr($input, 0, 1)) {
189 189
             return $input;
190 190
         }
191
-        throw new Invalid('Expecting phone number, a numeric value ' .
191
+        throw new Invalid('Expecting phone number, a numeric value '.
192 192
             'with optional `+` prefix');
193 193
     }
194 194
 
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
         }
285 285
         throw new Invalid(
286 286
             'Expecting date in `YYYY-MM-DD` format, such as `'
287
-            . date("Y-m-d") . '`'
287
+            . date("Y-m-d").'`'
288 288
         );
289 289
     }
290 290
 
@@ -302,8 +302,8 @@  discard block
 block discarded – undo
302 302
     public static function datetime($input, ValidationInfo $info = null)
303 303
     {
304 304
         if (
305
-            preg_match('/^(?P<year>19\d\d|20\d\d)\-(?P<month>0[1-9]|1[0-2])\-' .
306
-                '(?P<day>0\d|[1-2]\d|3[0-1]) (?P<h>0\d|1\d|2[0-3]' .
305
+            preg_match('/^(?P<year>19\d\d|20\d\d)\-(?P<month>0[1-9]|1[0-2])\-'.
306
+                '(?P<day>0\d|[1-2]\d|3[0-1]) (?P<h>0\d|1\d|2[0-3]'.
307 307
                 ')\:(?P<i>[0-5][0-9])\:(?P<s>[0-5][0-9])$/',
308 308
                 $input, $date)
309 309
             && checkdate($date['month'], $date['day'], $date['year'])
@@ -312,7 +312,7 @@  discard block
 block discarded – undo
312 312
         }
313 313
         throw new Invalid(
314 314
             'Expecting date and time in `YYYY-MM-DD HH:MM:SS` format, such as `'
315
-            . date("Y-m-d H:i:s") . '`'
315
+            . date("Y-m-d H:i:s").'`'
316 316
         );
317 317
     }
318 318
 
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
         }
351 351
         throw new Invalid(
352 352
             'Expecting time in `HH:MM:SS` format, such as `'
353
-            . date("H:i:s") . '`'
353
+            . date("H:i:s").'`'
354 354
         );
355 355
     }
356 356
 
@@ -391,13 +391,13 @@  discard block
 block discarded – undo
391 391
      */
392 392
     public static function timestamp($input, ValidationInfo $info = null)
393 393
     {
394
-        if ((string)(int)$input == $input
394
+        if ((string) (int) $input == $input
395 395
             && ($input <= PHP_INT_MAX)
396 396
             && ($input >= ~PHP_INT_MAX)
397 397
         ) {
398
-            return (int)$input;
398
+            return (int) $input;
399 399
         }
400
-        throw new Invalid('Expecting unix timestamp, such as ' . time());
400
+        throw new Invalid('Expecting unix timestamp, such as '.time());
401 401
     }
402 402
 
403 403
     /**
@@ -433,7 +433,7 @@  discard block
 block discarded – undo
433 433
         try {
434 434
             if (is_null($input)) {
435 435
                 if ($info->required) {
436
-                    throw new RestException (400,
436
+                    throw new RestException(400,
437 437
                         "$name is required.");
438 438
                 }
439 439
                 return null;
@@ -465,7 +465,7 @@  discard block
 block discarded – undo
465 465
                         // just continue
466 466
                     }
467 467
                 }
468
-                throw new RestException (400, $error);
468
+                throw new RestException(400, $error);
469 469
             }
470 470
 
471 471
             //patterns are supported only for non numeric types
@@ -475,7 +475,7 @@  discard block
 block discarded – undo
475 475
                 && $info->type != 'number'
476 476
             ) {
477 477
                 if (!preg_match($info->pattern, $input)) {
478
-                    throw new RestException (400, $error);
478
+                    throw new RestException(400, $error);
479 479
                 }
480 480
             }
481 481
 
@@ -486,13 +486,13 @@  discard block
 block discarded – undo
486 486
                 } elseif (is_array($input)) {
487 487
                     foreach ($input as $i) {
488 488
                         if (!in_array($i, $info->choice)) {
489
-                            $error .= ". Expected one of (" . implode(',', $info->choice) . ").";
490
-                            throw new RestException (400, $error);
489
+                            $error .= ". Expected one of (".implode(',', $info->choice).").";
490
+                            throw new RestException(400, $error);
491 491
                         }
492 492
                     }
493 493
                 } elseif (!in_array($input, $info->choice)) {
494
-                    $error .= ". Expected one of (" . implode(',', $info->choice) . ").";
495
-                    throw new RestException (400, $error);
494
+                    $error .= ". Expected one of (".implode(',', $info->choice).").";
495
+                    throw new RestException(400, $error);
496 496
                 }
497 497
             }
498 498
 
@@ -504,7 +504,7 @@  discard block
 block discarded – undo
504 504
                 try {
505 505
                     return call_user_func("$class::$info->type", $input, $info);
506 506
                 } catch (Invalid $e) {
507
-                    throw new RestException(400, $error . '. ' . $e->getMessage());
507
+                    throw new RestException(400, $error.'. '.$e->getMessage());
508 508
                 }
509 509
             }
510 510
 
@@ -518,9 +518,9 @@  discard block
 block discarded – undo
518 518
                             . ' value';
519 519
                         break;
520 520
                     }
521
-                    if ($info->type == 'int' && (int)$input != $input) {
521
+                    if ($info->type == 'int' && (int) $input != $input) {
522 522
                         if ($info->fix) {
523
-                            $r = (int)$input;
523
+                            $r = (int) $input;
524 524
                         } else {
525 525
                             $error .= '. Expecting integer value';
526 526
                             break;
@@ -663,7 +663,7 @@  discard block
 block discarded – undo
663 663
                         }
664 664
                         return $input;
665 665
                     } elseif (isset($contentType)) {
666
-                        $error .= '. Expecting items of type ' .
666
+                        $error .= '. Expecting items of type '.
667 667
                             ($html ? "<strong>$contentType</strong>" : "`$contentType`");
668 668
                         break;
669 669
                     }
@@ -697,7 +697,7 @@  discard block
 block discarded – undo
697 697
                                 !is_array($input) ||
698 698
                                 $input === array_values($input)
699 699
                             ) {
700
-                                $error .= '. Expecting an item of type ' .
700
+                                $error .= '. Expecting an item of type '.
701 701
                                     ($html ? "<strong>$info->type</strong>" : "`$info->type`");
702 702
                                 break;
703 703
                             }
@@ -715,7 +715,7 @@  discard block
 block discarded – undo
715 715
                         return $instance;
716 716
                     }
717 717
             }
718
-            throw new RestException (400, $error);
718
+            throw new RestException(400, $error);
719 719
         } catch (\Exception $e) {
720 720
             static::$exceptions[$info->name] = $e;
721 721
             if (static::$holdException) {
Please login to merge, or discard this patch.
htdocs/includes/restler/framework/Luracast/Restler/Data/ValidationInfo.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -172,8 +172,8 @@  discard block
 block discarded – undo
172 172
 
173 173
     public static function numericValue($value)
174 174
     {
175
-        return ( int )$value == $value
176
-            ? ( int )$value
175
+        return (int) $value == $value
176
+            ? (int) $value
177 177
             : floatval($value);
178 178
     }
179 179
 
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
     {
189 189
         return is_array($value)
190 190
             ? implode($glue, $value)
191
-            : ( string )$value;
191
+            : (string) $value;
192 192
     }
193 193
 
194 194
     public static function booleanValue($value)
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
      */
267 267
     public static function __set_state(array $info)
268 268
     {
269
-        $o = new self ($info);
269
+        $o = new self($info);
270 270
         return $o;
271 271
     }
272 272
 }
Please login to merge, or discard this patch.
htdocs/includes/restler/framework/Luracast/Restler/Resources.php 1 patch
Spacing   +26 added lines, -27 removed lines patch added patch discarded remove patch
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
     public function _pre_get_json($id)
151 151
     {
152 152
         $userClass = Defaults::$userIdentifierClass;
153
-        $this->cacheName = $userClass::getCacheIdentifier() . '_resources_' . $id;
153
+        $this->cacheName = $userClass::getCacheIdentifier().'_resources_'.$id;
154 154
         if ($this->restler->getProductionMode()
155 155
             && !$this->restler->refreshCache
156 156
             && $this->restler->cache->isCached($this->cacheName)
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 
217 217
         $routes
218 218
             = Util::nestedValue(Routes::toArray(), "v$version")
219
-            ? : array();
219
+            ?: array();
220 220
 
221 221
         $prefix = Defaults::$useUrlBasedVersioning ? "/v$version" : '';
222 222
 
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
                 }
232 232
                 $fLen = strlen($fullPath);
233 233
                 if ($tSlash) {
234
-                    if ($fLen != $tLen && !Text::beginsWith($fullPath, $target . '/'))
234
+                    if ($fLen != $tLen && !Text::beginsWith($fullPath, $target.'/'))
235 235
                         continue;
236 236
                 } elseif ($fLen > $tLen + 1 && $fullPath[$tLen + 1] != '{' && !Text::beginsWith($fullPath, '{')) {
237 237
                     //when mapped to root exclude paths that have static parts
@@ -290,21 +290,21 @@  discard block
 block discarded – undo
290 290
                 $description = isset(
291 291
                 $m['classDescription'])
292 292
                     ? $m['classDescription']
293
-                    : $className . ' API';
293
+                    : $className.' API';
294 294
                 if (empty($m['description'])) {
295 295
                     $m['description'] = $this->restler->getProductionMode()
296 296
                         ? ''
297 297
                         : 'routes to <mark>'
298 298
                         . $route['className']
299 299
                         . '::'
300
-                        . $route['methodName'] . '();</mark>';
300
+                        . $route['methodName'].'();</mark>';
301 301
                 }
302 302
                 if (empty($m['longDescription'])) {
303 303
                     $m['longDescription'] = $this->restler->getProductionMode()
304 304
                         ? ''
305 305
                         : 'Add PHPDoc long description to '
306 306
                         . "<mark>$className::"
307
-                        . $route['methodName'] . '();</mark>'
307
+                        . $route['methodName'].'();</mark>'
308 308
                         . '  (the api method) to write here';
309 309
                 }
310 310
                 $operation = $this->_operation(
@@ -359,8 +359,8 @@  discard block
 block discarded – undo
359 359
                                 ['type'];
360 360
                                 if (class_exists($rt)) {
361 361
                                     $this->_model($rt);
362
-                                    $operation->responseClass .= '[' .
363
-                                        $this->_noNamespace($rt) . ']';
362
+                                    $operation->responseClass .= '['.
363
+                                        $this->_noNamespace($rt).']';
364 364
                                 }
365 365
                             }
366 366
                         }
@@ -392,7 +392,7 @@  discard block
 block discarded – undo
392 392
             $r->models = $this->_models;
393 393
         usort(
394 394
             $r->apis,
395
-            function ($a, $b) {
395
+            function($a, $b) {
396 396
                 $order = array(
397 397
                     'GET' => 1,
398 398
                     'POST' => 2,
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
     protected function _resourceListing()
451 451
     {
452 452
         $r = new stdClass();
453
-        $r->apiVersion = (string)$this->restler->_requestedApiVersion;
453
+        $r->apiVersion = (string) $this->restler->_requestedApiVersion;
454 454
         $r->swaggerVersion = "1.1";
455 455
         $r->basePath = $this->restler->getBaseUrl();
456 456
         $r->produces = $this->restler->getWritableMimeTypes();
@@ -493,7 +493,7 @@  discard block
 block discarded – undo
493 493
 
494 494
         $r->parameters = array();
495 495
 
496
-        $r->summary = $summary . ($route['accessLevel'] > 2
496
+        $r->summary = $summary.($route['accessLevel'] > 2
497 497
                 ? static::$apiDescriptionSuffixSymbols[2]
498 498
                 : static::$apiDescriptionSuffixSymbols[$route['accessLevel']]
499 499
             );
@@ -508,13 +508,13 @@  discard block
 block discarded – undo
508 508
         $r = new stdClass();
509 509
         $r->name = $param['name'];
510 510
         $r->description = !empty($param['description'])
511
-            ? $param['description'] . '.'
511
+            ? $param['description'].'.'
512 512
             : ($this->restler->getProductionMode()
513 513
                 ? ''
514
-                : 'add <mark>@param {type} $' . $r->name
514
+                : 'add <mark>@param {type} $'.$r->name
515 515
                 . ' {comment}</mark> to describe here');
516 516
         //paramType can be path or query or body or header
517
-        $r->paramType = Util::nestedValue($param, CommentParser::$embeddedDataName, 'from') ? : 'query';
517
+        $r->paramType = Util::nestedValue($param, CommentParser::$embeddedDataName, 'from') ?: 'query';
518 518
         $r->required = isset($param['required']) && $param['required'];
519 519
         if (isset($param['default'])) {
520 520
             $r->defaultValue = $param['default'];
@@ -583,7 +583,7 @@  discard block
 block discarded – undo
583 583
         }
584 584
         $this->_bodyParam['description'][$p->name]
585 585
             = "$p->name"
586
-            . ' : <tag>' . $p->dataType . '</tag> '
586
+            . ' : <tag>'.$p->dataType.'</tag> '
587 587
             . ($p->required ? ' <i>(required)</i> - ' : ' - ')
588 588
             . $p->description;
589 589
         $this->_bodyParam['required'] = $p->required
@@ -609,9 +609,9 @@  discard block
 block discarded – undo
609 609
                         . (count($a) > 1 ? ' properties.' : ' property.');
610 610
                     foreach ($a as $k => $v) {
611 611
                         $r->description .= "<hr/>$k : <tag>"
612
-                            . $v['type'] . '</tag> '
612
+                            . $v['type'].'</tag> '
613 613
                             . (isset($v['required']) ? '(required)' : '')
614
-                            . ' - ' . $v['description'];
614
+                            . ' - '.$v['description'];
615 615
                     }
616 616
                 }
617 617
                 $r->defaultValue = "{\n    \""
@@ -631,9 +631,9 @@  discard block
 block discarded – undo
631 631
                             . (count($a) > 1 ? ' properties.' : ' property.');
632 632
                         foreach ($a as $k => $v) {
633 633
                             $r->description .= "<hr/>$k : <tag>"
634
-                                . $v['type'] . '</tag> '
634
+                                . $v['type'].'</tag> '
635 635
                                 . (isset($v['required']) ? '(required)' : '')
636
-                                . ' - ' . $v['description'];
636
+                                . ' - '.$v['description'];
637 637
                         }
638 638
                     }
639 639
                     $r->defaultValue = "[\n    {\n        \""
@@ -734,11 +734,11 @@  discard block
 block discarded – undo
734 734
                 $type = Util::nestedValue(
735 735
                     $propertyMetaData,
736 736
                     'type'
737
-                ) ? : $this->getType($value, true);
737
+                ) ?: $this->getType($value, true);
738 738
                 $description = Util::nestedValue(
739 739
                     $propertyMetaData,
740 740
                     'description'
741
-                ) ? : '';
741
+                ) ?: '';
742 742
 
743 743
                 if (class_exists($type)) {
744 744
                     $this->_model($type);
@@ -766,8 +766,7 @@  discard block
 block discarded – undo
766 766
                     $propertyMetaData,
767 767
                     CommentParser::$embeddedDataName,
768 768
                     'type'
769
-                ) ? :
770
-                    (count($value)
769
+                ) ?: (count($value)
771 770
                         ? $this->getType(end($value), true)
772 771
                         : 'string');
773 772
                 if (class_exists($itemType)) {
@@ -894,7 +893,7 @@  discard block
 block discarded – undo
894 893
             if (!Text::contains($path, '{')) {
895 894
                 //add id
896 895
                 $r->apis[] = array(
897
-                    'path' => $path . $this->formatString,
896
+                    'path' => $path.$this->formatString,
898 897
                     'description' => $description
899 898
                 );
900 899
             }
@@ -915,8 +914,8 @@  discard block
 block discarded – undo
915 914
 
916 915
     protected function _loadResource($url)
917 916
     {
918
-        $ch = curl_init($this->restler->getBaseUrl() . $url
919
-            . (empty($_GET) ? '' : '?' . http_build_query($_GET)));
917
+        $ch = curl_init($this->restler->getBaseUrl().$url
918
+            . (empty($_GET) ? '' : '?'.http_build_query($_GET)));
920 919
         curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
921 920
         curl_setopt($ch, CURLOPT_TIMEOUT, 15);
922 921
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
@@ -925,7 +924,7 @@  discard block
 block discarded – undo
925 924
         ));
926 925
         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);        
927 926
         $result = json_decode(curl_exec($ch));
928
-        $http_status = (int)curl_getinfo($ch, CURLINFO_HTTP_CODE);
927
+        $http_status = (int) curl_getinfo($ch, CURLINFO_HTTP_CODE);
929 928
         return array($http_status, $result);
930 929
     }
931 930
 
Please login to merge, or discard this patch.
htdocs/includes/restler/framework/Luracast/Restler/Scope.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -80,12 +80,12 @@  discard block
 block discarded – undo
80 80
      */
81 81
     public static function register($name, $function, $singleton = true)
82 82
     {
83
-        static::$registry[$name] = (object)compact('function', 'singleton');
83
+        static::$registry[$name] = (object) compact('function', 'singleton');
84 84
     }
85 85
 
86 86
     public static function set($name, $instance)
87 87
     {
88
-        static::$instances[$name] = (object)array('instance' => $instance);
88
+        static::$instances[$name] = (object) array('instance' => $instance);
89 89
     }
90 90
 
91 91
     public static function get($name)
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
             $function = static::$registry[$name]->function;
101 101
             $r = $function();
102 102
             if (static::$registry[$name]->singleton) {
103
-                static::$instances[$name] = (object)array('instance' => $r);
103
+                static::$instances[$name] = (object) array('instance' => $r);
104 104
             }
105 105
         } elseif (is_callable(static::$resolver) && false === stristr($name, 'Luracast\Restler')) {
106 106
             $fullName = $name;
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
             /** @var Callable $function */
111 111
             $function = static::$resolver;
112 112
             $r = $function($fullName);
113
-            static::$instances[$name] = (object)array('instance' => $r);
113
+            static::$instances[$name] = (object) array('instance' => $r);
114 114
             static::$instances[$name]->initPending = true;
115 115
         } else {
116 116
             $fullName = $name;
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
             if (class_exists($fullName)) {
121 121
                 $shortName = Util::getShortName($name);
122 122
                 $r = new $fullName();
123
-                static::$instances[$name] = (object)array('instance' => $r);
123
+                static::$instances[$name] = (object) array('instance' => $r);
124 124
                 if ($name != 'Restler') {
125 125
                     /** @var Restler restler */
126 126
                     $r->restler = static::get('Restler');
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
         } elseif (array_key_exists($className, $scope)) {
211 211
             $qualified = $scope[$className];
212 212
         } else {
213
-            $qualified = $scope['*'] . $className;
213
+            $qualified = $scope['*'].$className;
214 214
         }
215 215
         if (class_exists($qualified)) {
216 216
             return $qualified;
Please login to merge, or discard this patch.
htdocs/includes/restler/framework/Luracast/Restler/RestException.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -80,10 +80,10 @@  discard block
 block discarded – undo
80 80
     public function __construct($httpStatusCode, $errorMessage = null, array $details = array(), Exception $previous = null)
81 81
     {
82 82
         $events = Scope::get('Restler')->getEvents();
83
-        if(count($events)<= 1){
83
+        if (count($events) <= 1) {
84 84
             $this->stage = 'setup';
85 85
         } else {
86
-            $this->stage = $previous ? $events[count($events)-2] : end($events);
86
+            $this->stage = $previous ? $events[count($events) - 2] : end($events);
87 87
         }
88 88
         $this->details = $details;
89 89
         parent::__construct($errorMessage, $httpStatusCode, $previous);
@@ -119,8 +119,8 @@  discard block
 block discarded – undo
119 119
         $statusCode = $this->getCode();
120 120
         $message = $this->getMessage();
121 121
         if (isset(RestException::$codes[$statusCode])) {
122
-            $message = RestException::$codes[$statusCode] .
123
-                (empty($message) ? '' : ': ' . $message);
122
+            $message = RestException::$codes[$statusCode].
123
+                (empty($message) ? '' : ': '.$message);
124 124
         }
125 125
         return $message;
126 126
     }
@@ -131,9 +131,9 @@  discard block
 block discarded – undo
131 131
         while ($e->getPrevious()) {
132 132
             $e = $e->getPrevious();
133 133
         }
134
-        return basename($e->getFile()) . ':'
135
-        . $e->getLine() . ' at '
136
-        . $this->getStage() . ' stage';
134
+        return basename($e->getFile()).':'
135
+        . $e->getLine().' at '
136
+        . $this->getStage().' stage';
137 137
     }
138 138
 }
139 139
 
Please login to merge, or discard this patch.
htdocs/includes/restler/framework/Luracast/Restler/iUseAuthentication.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -27,6 +27,6 @@
 block discarded – undo
27 27
      *
28 28
      * @return mixed
29 29
      */
30
-    public function __setAuthenticationStatus($isAuthenticated=false);
30
+    public function __setAuthenticationStatus($isAuthenticated = false);
31 31
 }
32 32
 
Please login to merge, or discard this patch.
htdocs/includes/restler/framework/Luracast/Restler/MemcacheCache.php 1 patch
Spacing   +5 added lines, -6 removed lines patch added patch discarded remove patch
@@ -63,9 +63,8 @@  discard block
 block discarded – undo
63 63
         function_exists('memcache_set') || $this->memcacheNotAvailable();
64 64
 
65 65
         try {
66
-            return $this->memcache->set(self::$namespace . "-" . $name, $data);
67
-        } catch
68
-        (\Exception $exception) {
66
+            return $this->memcache->set(self::$namespace."-".$name, $data);
67
+        } catch (\Exception $exception) {
69 68
             return false;
70 69
         }
71 70
     }
@@ -90,7 +89,7 @@  discard block
 block discarded – undo
90 89
         function_exists('memcache_get') || $this->memcacheNotAvailable();
91 90
 
92 91
         try {
93
-            return $this->memcache->get(self::$namespace . "-" . $name);
92
+            return $this->memcache->get(self::$namespace."-".$name);
94 93
         } catch (\Exception $exception) {
95 94
             if (!$ignoreErrors) {
96 95
                 throw $exception;
@@ -114,7 +113,7 @@  discard block
 block discarded – undo
114 113
         function_exists('memcache_delete') || $this->memcacheNotAvailable();
115 114
 
116 115
         try {
117
-            $this->memcache->delete(self::$namespace . "-" . $name);
116
+            $this->memcache->delete(self::$namespace."-".$name);
118 117
         } catch (\Exception $exception) {
119 118
             if (!$ignoreErrors) {
120 119
                 throw $exception;
@@ -133,7 +132,7 @@  discard block
 block discarded – undo
133 132
     public function isCached($name)
134 133
     {
135 134
         function_exists('memcache_get') || $this->memcacheNotAvailable();
136
-        $data = $this->memcache->get(self::$namespace . "-" . $name);
135
+        $data = $this->memcache->get(self::$namespace."-".$name);
137 136
         return !empty($data);
138 137
     }
139 138
 
Please login to merge, or discard this patch.
htdocs/includes/restler/framework/Luracast/Restler/Restler.php 1 patch
Spacing   +60 added lines, -61 removed lines patch added patch discarded remove patch
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
      *
111 111
      * @var int|null when specified it will override @status comment
112 112
      */
113
-    public $responseCode=null;
113
+    public $responseCode = null;
114 114
     /**
115 115
      * @var string base url of the api service
116 116
      */
@@ -246,8 +246,8 @@  discard block
 block discarded – undo
246 246
         Scope::set('Restler', $this);
247 247
         $this->productionMode = $productionMode;
248 248
         if (is_null(Defaults::$cacheDirectory)) {
249
-            Defaults::$cacheDirectory = dirname($_SERVER['SCRIPT_FILENAME']) .
250
-                DIRECTORY_SEPARATOR . 'cache';
249
+            Defaults::$cacheDirectory = dirname($_SERVER['SCRIPT_FILENAME']).
250
+                DIRECTORY_SEPARATOR.'cache';
251 251
         }
252 252
         $this->cache = new Defaults::$cacheClass();
253 253
         $this->refreshCache = $refreshCache;
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
             }
314 314
             $this->respond();
315 315
         } catch (Exception $e) {
316
-            try{
316
+            try {
317 317
                 if (Defaults::$returnResponse) {
318 318
                     return $this->message($e);
319 319
                 }
@@ -402,19 +402,19 @@  discard block
 block discarded – undo
402 402
             $obj = Scope::get($className);
403 403
 
404 404
             if (!$obj instanceof iFormat)
405
-                throw new Exception('Invalid format class; must implement ' .
405
+                throw new Exception('Invalid format class; must implement '.
406 406
                     'iFormat interface');
407 407
             if ($throwException && get_class($obj) == get_class($this->requestFormat)) {
408 408
                 $throwException = false;
409 409
             }
410 410
 
411 411
             foreach ($obj->getMIMEMap() as $mime => $extension) {
412
-                if($obj->isWritable()){
413
-                    $this->writableMimeTypes[]=$mime;
412
+                if ($obj->isWritable()) {
413
+                    $this->writableMimeTypes[] = $mime;
414 414
                     $extensions[".$extension"] = true;
415 415
                 }
416
-                if($obj->isReadable())
417
-                    $this->readableMimeTypes[]=$mime;
416
+                if ($obj->isReadable())
417
+                    $this->readableMimeTypes[] = $mime;
418 418
                 if (!isset($this->formatMap[$extension]))
419 419
                     $this->formatMap[$extension] = $className;
420 420
                 if (!isset($this->formatMap[$mime]))
@@ -424,7 +424,7 @@  discard block
 block discarded – undo
424 424
         if ($throwException) {
425 425
             throw new RestException(
426 426
                 403,
427
-                'Content type `' . $this->requestFormat->getMIME() . '` is not supported.'
427
+                'Content type `'.$this->requestFormat->getMIME().'` is not supported.'
428 428
             );
429 429
         }
430 430
         $this->formatMap['default'] = $args[0];
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
             $obj = Scope::get($className);
451 451
 
452 452
             if (!$obj instanceof iFormat)
453
-                throw new Exception('Invalid format class; must implement ' .
453
+                throw new Exception('Invalid format class; must implement '.
454 454
                     'iFormat interface');
455 455
 
456 456
             foreach ($obj->getMIMEMap() as $mime => $extension) {
@@ -458,7 +458,7 @@  discard block
 block discarded – undo
458 458
                     $this->formatOverridesMap[$extension] = $className;
459 459
                 if (!isset($this->formatOverridesMap[$mime]))
460 460
                     $this->formatOverridesMap[$mime] = $className;
461
-                if($obj->isWritable())
461
+                if ($obj->isWritable())
462 462
                     $extensions[".$extension"] = true;
463 463
             }
464 464
         }
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
     {
478 478
         if (func_num_args() > 1) {
479 479
             $urls = func_get_args();
480
-            usort($urls, function ($a, $b) {
480
+            usort($urls, function($a, $b) {
481 481
                 return strlen($a) - strlen($b);
482 482
             });
483 483
             foreach ($urls as $u) {
@@ -500,7 +500,7 @@  discard block
 block discarded – undo
500 500
         // fix SCRIPT_NAME for PHP 5.4 built-in web server
501 501
         if (false === strpos($_SERVER['SCRIPT_NAME'], '.php'))
502 502
             $_SERVER['SCRIPT_NAME']
503
-                = '/' . substr($_SERVER['SCRIPT_FILENAME'], strlen($_SERVER['DOCUMENT_ROOT']) + 1);
503
+                = '/'.substr($_SERVER['SCRIPT_FILENAME'], strlen($_SERVER['DOCUMENT_ROOT']) + 1);
504 504
 
505 505
         list($base, $path) = Util::splitCommonPath(
506 506
             strtok(urldecode($_SERVER['REQUEST_URI']), '?'), //remove query string
@@ -510,9 +510,9 @@  discard block
 block discarded – undo
510 510
         if (!$this->baseUrl) {
511 511
             // Fix port number retrieval if port is specified in HOST header.
512 512
             $host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '';
513
-            $portPos = strpos($host,":");
514
-            if ($portPos){
515
-               $port = substr($host,$portPos+1);
513
+            $portPos = strpos($host, ":");
514
+            if ($portPos) {
515
+               $port = substr($host, $portPos + 1);
516 516
             } else {
517 517
                $port = isset($_SERVER['SERVER_PORT']) ? $_SERVER['SERVER_PORT'] : '80';
518 518
                $port = isset($_SERVER['HTTP_X_FORWARDED_PORT']) ? $_SERVER['HTTP_X_FORWARDED_PORT'] : $port; // Amazon ELB
@@ -520,10 +520,10 @@  discard block
 block discarded – undo
520 520
             $https = $port == '443' ||
521 521
                 (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') || // Amazon ELB
522 522
                 (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on');
523
-            $baseUrl = ($https ? 'https://' : 'http://') . $_SERVER['SERVER_NAME'];
523
+            $baseUrl = ($https ? 'https://' : 'http://').$_SERVER['SERVER_NAME'];
524 524
             if (!$https && $port != '80' || $https && $port != '443')
525
-                $baseUrl .= ':' . $port;
526
-            $this->baseUrl = $baseUrl . $base;
525
+                $baseUrl .= ':'.$port;
526
+            $this->baseUrl = $baseUrl.$base;
527 527
         } elseif (!empty($base) && false === strpos($this->baseUrl, $base)) {
528 528
             $this->baseUrl .= $base;
529 529
         }
@@ -559,7 +559,7 @@  discard block
 block discarded – undo
559 559
      */
560 560
     protected function getRequestFormat()
561 561
     {
562
-        $format = null ;
562
+        $format = null;
563 563
         // check if client has sent any information on request format
564 564
         if (
565 565
             !empty($_SERVER['CONTENT_TYPE']) ||
@@ -591,7 +591,7 @@  discard block
 block discarded – undo
591 591
                 );
592 592
             }
593 593
         }
594
-        if(!$format){
594
+        if (!$format) {
595 595
             $format = Scope::get($this->formatMap['default']);
596 596
         }
597 597
         return $format;
@@ -630,7 +630,7 @@  discard block
 block discarded – undo
630 630
             }
631 631
 
632 632
             $stream = $this->getRequestStream();
633
-            if($stream === FALSE)
633
+            if ($stream === FALSE)
634 634
                 return array();
635 635
             $r = $this->requestFormat instanceof iDecodeStream
636 636
                 ? $this->requestFormat->decodeStream($stream)
@@ -676,7 +676,7 @@  discard block
 block discarded – undo
676 676
         if (!isset($o->className))
677 677
             throw new RestException(404);
678 678
 
679
-        if(isset($this->apiVersionMap[$o->className])){
679
+        if (isset($this->apiVersionMap[$o->className])) {
680 680
             Scope::$classAliases[Util::getShortName($o->className)]
681 681
                 = $this->apiVersionMap[$o->className][$this->requestedApiVersion];
682 682
         }
@@ -723,7 +723,7 @@  discard block
 block discarded – undo
723 723
                 header('Access-Control-Allow-Headers: '
724 724
                     . $_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']);
725 725
 
726
-            header('Access-Control-Allow-Origin: ' .
726
+            header('Access-Control-Allow-Origin: '.
727 727
                 ((Defaults::$accessControlAllowOrigin == '*' && isset($_SERVER['HTTP_ORIGIN']))
728 728
                     ? $_SERVER['HTTP_ORIGIN'] : Defaults::$accessControlAllowOrigin));
729 729
             header('Access-Control-Allow-Credentials: true');
@@ -752,7 +752,7 @@  discard block
 block discarded – undo
752 752
         //check if the api method insists on response format using @format comment
753 753
 
754 754
         if ($metadata && isset($metadata['format'])) {
755
-            $formats = explode(',', (string)$metadata['format']);
755
+            $formats = explode(',', (string) $metadata['format']);
756 756
             foreach ($formats as $i => $f) {
757 757
                 $f = trim($f);
758 758
                 if (!in_array($f, $this->formatOverridesMap))
@@ -800,7 +800,7 @@  discard block
 block discarded – undo
800 800
                     if (is_string(Defaults::$apiVendor)
801 801
                         && 0 === stripos($mime,
802 802
                             'application/vnd.'
803
-                            . Defaults::$apiVendor . '-v')
803
+                            . Defaults::$apiVendor.'-v')
804 804
                     ) {
805 805
                         $extension = substr($accept, $index + 1);
806 806
                         if (isset($this->formatMap[$extension])) {
@@ -846,8 +846,8 @@  discard block
 block discarded – undo
846 846
             $this->responseFormat = $format;
847 847
             throw new RestException(
848 848
                 406,
849
-                'Content negotiation failed. ' .
850
-                'Try `' . $format->getMIME() . '` instead.'
849
+                'Content negotiation failed. '.
850
+                'Try `'.$format->getMIME().'` instead.'
851 851
             );
852 852
         } else {
853 853
             // Tell cache content is based at Accept header
@@ -874,7 +874,7 @@  discard block
 block discarded – undo
874 874
                 } else {
875 875
                     throw new RestException(
876 876
                         406,
877
-                        'Content negotiation failed. ' .
877
+                        'Content negotiation failed. '.
878 878
                         'Requested charset is not supported'
879 879
                     );
880 880
                 }
@@ -922,8 +922,8 @@  discard block
 block discarded – undo
922 922
             $filterObj = Scope::get($filterClass);
923 923
 
924 924
             if (!$filterObj instanceof iFilter) {
925
-                throw new RestException (
926
-                    500, 'Filter Class ' .
925
+                throw new RestException(
926
+                    500, 'Filter Class '.
927 927
                     'should implement iFilter');
928 928
             } else if (!($ok = $filterObj->__isAllowed())) {
929 929
                 if (is_null($ok)
@@ -955,8 +955,8 @@  discard block
 block discarded – undo
955 955
                 try {
956 956
                     $authObj = Scope::get($authClass);
957 957
                     if (!method_exists($authObj, Defaults::$authenticationMethod)) {
958
-                        throw new RestException (
959
-                            500, 'Authentication Class ' .
958
+                        throw new RestException(
959
+                            500, 'Authentication Class '.
960 960
                             'should implement iAuthenticate');
961 961
                     } elseif (
962 962
                     !$authObj->{Defaults::$authenticationMethod}()
@@ -992,7 +992,7 @@  discard block
 block discarded – undo
992 992
      */
993 993
     protected function postAuthFilter()
994 994
     {
995
-        if(empty($this->postAuthFilterClasses)) {
995
+        if (empty($this->postAuthFilterClasses)) {
996 996
             return;
997 997
         }
998 998
         $this->dispatch('postAuthFilter');
@@ -1051,7 +1051,7 @@  discard block
 block discarded – undo
1051 1051
             $o->accessLevel);
1052 1052
         if (function_exists('newrelic_name_transaction'))
1053 1053
             newrelic_name_transaction("{$o->className}/{$o->methodName}");
1054
-        $object =  Scope::get($o->className);
1054
+        $object = Scope::get($o->className);
1055 1055
         switch ($accessLevel) {
1056 1056
             case 3 : //protected method
1057 1057
                 $reflectionMethod = new \ReflectionMethod(
@@ -1094,7 +1094,7 @@  discard block
 block discarded – undo
1094 1094
     {
1095 1095
         //only GET method should be cached if allowed by API developer
1096 1096
         $expires = $this->requestMethod == 'GET' ? Defaults::$headerExpires : 0;
1097
-        if(!is_array(Defaults::$headerCacheControl))
1097
+        if (!is_array(Defaults::$headerCacheControl))
1098 1098
             Defaults::$headerCacheControl = array(Defaults::$headerCacheControl);
1099 1099
         $cacheControl = Defaults::$headerCacheControl[0];
1100 1100
         if ($expires > 0) {
@@ -1104,14 +1104,14 @@  discard block
 block discarded – undo
1104 1104
             $cacheControl = str_replace('{expires}', $expires, $cacheControl);
1105 1105
             $expires = gmdate('D, d M Y H:i:s \G\M\T', time() + $expires);
1106 1106
         }
1107
-        @header('Cache-Control: ' . $cacheControl);
1108
-        @header('Expires: ' . $expires);
1109
-        @header('X-Powered-By: Luracast Restler v' . Restler::VERSION);
1107
+        @header('Cache-Control: '.$cacheControl);
1108
+        @header('Expires: '.$expires);
1109
+        @header('X-Powered-By: Luracast Restler v'.Restler::VERSION);
1110 1110
 
1111 1111
         if (Defaults::$crossOriginResourceSharing
1112 1112
             && isset($_SERVER['HTTP_ORIGIN'])
1113 1113
         ) {
1114
-            header('Access-Control-Allow-Origin: ' .
1114
+            header('Access-Control-Allow-Origin: '.
1115 1115
                 (Defaults::$accessControlAllowOrigin == '*'
1116 1116
                     ? $_SERVER['HTTP_ORIGIN']
1117 1117
                     : Defaults::$accessControlAllowOrigin)
@@ -1122,19 +1122,19 @@  discard block
 block discarded – undo
1122 1122
 
1123 1123
         $this->responseFormat->setCharset(Defaults::$charset);
1124 1124
         $charset = $this->responseFormat->getCharset()
1125
-            ? : Defaults::$charset;
1125
+            ?: Defaults::$charset;
1126 1126
 
1127
-        @header('Content-Type: ' . (
1127
+        @header('Content-Type: '.(
1128 1128
             Defaults::$useVendorMIMEVersioning
1129 1129
                 ? 'application/vnd.'
1130 1130
                 . Defaults::$apiVendor
1131 1131
                 . "-v{$this->requestedApiVersion}"
1132
-                . '+' . $this->responseFormat->getExtension()
1132
+                . '+'.$this->responseFormat->getExtension()
1133 1133
                 : $this->responseFormat->getMIME())
1134
-            . '; charset=' . $charset
1134
+            . '; charset='.$charset
1135 1135
         );
1136 1136
 
1137
-        @header('Content-Language: ' . Defaults::$language);
1137
+        @header('Content-Language: '.Defaults::$language);
1138 1138
 
1139 1139
         if (isset($this->apiMethodInfo->metadata['header'])) {
1140 1140
             foreach ($this->apiMethodInfo->metadata['header'] as $header)
@@ -1152,7 +1152,7 @@  discard block
 block discarded – undo
1152 1152
         }
1153 1153
         $this->responseCode = $code;
1154 1154
         @header(
1155
-            "{$_SERVER['SERVER_PROTOCOL']} $code " .
1155
+            "{$_SERVER['SERVER_PROTOCOL']} $code ".
1156 1156
             (isset(RestException::$codes[$code]) ? RestException::$codes[$code] : '')
1157 1157
         );
1158 1158
     }
@@ -1171,7 +1171,7 @@  discard block
 block discarded – undo
1171 1171
             $authString = count($this->authClasses)
1172 1172
                 ? Scope::get($this->authClasses[0])->__getWWWAuthenticateString()
1173 1173
                 : 'Unknown';
1174
-            @header('WWW-Authenticate: ' . $authString, false);
1174
+            @header('WWW-Authenticate: '.$authString, false);
1175 1175
         }
1176 1176
         $this->dispatch('complete');
1177 1177
         if (Defaults::$returnResponse) {
@@ -1197,7 +1197,7 @@  discard block
 block discarded – undo
1197 1197
 
1198 1198
         $this->exception = $exception;
1199 1199
 
1200
-        $method = 'handle' . $exception->getCode();
1200
+        $method = 'handle'.$exception->getCode();
1201 1201
         $handled = false;
1202 1202
         foreach ($this->errorClasses as $className) {
1203 1203
             if (method_exists($className, $method)) {
@@ -1255,8 +1255,7 @@  discard block
 block discarded – undo
1255 1255
     public function setAPIVersion($version = 1, $minimum = 1)
1256 1256
     {
1257 1257
         if (!is_int($version) && $version < 1) {
1258
-            throw new InvalidArgumentException
1259
-            ('version should be an integer greater than 0');
1258
+            throw new InvalidArgumentException('version should be an integer greater than 0');
1260 1259
         }
1261 1260
         $this->apiVersion = $version;
1262 1261
         if (is_int($minimum)) {
@@ -1311,7 +1310,7 @@  discard block
 block discarded – undo
1311 1310
      */
1312 1311
     public function addAPIClass($className, $resourcePath = null)
1313 1312
     {
1314
-        try{
1313
+        try {
1315 1314
             if ($this->productionMode && is_null($this->cached)) {
1316 1315
                 $routes = $this->cache->get('routes');
1317 1316
                 if (isset($routes) && is_array($routes)) {
@@ -1341,12 +1340,12 @@  discard block
 block discarded – undo
1341 1340
                 //versioned api
1342 1341
                 if (false !== ($index = strrpos($className, '\\'))) {
1343 1342
                     $name = substr($className, 0, $index)
1344
-                        . '\\v{$version}' . substr($className, $index);
1343
+                        . '\\v{$version}'.substr($className, $index);
1345 1344
                 } else if (false !== ($index = strrpos($className, '_'))) {
1346 1345
                     $name = substr($className, 0, $index)
1347
-                        . '_v{$version}' . substr($className, $index);
1346
+                        . '_v{$version}'.substr($className, $index);
1348 1347
                 } else {
1349
-                    $name = 'v{$version}\\' . $className;
1348
+                    $name = 'v{$version}\\'.$className;
1350 1349
                 }
1351 1350
 
1352 1351
                 for ($version = $this->apiMinimumVersion;
@@ -1478,13 +1477,13 @@  discard block
 block discarded – undo
1478 1477
                     //versioned api
1479 1478
                     if (false !== ($index = strrpos($className, '\\'))) {
1480 1479
                         $name = substr($className, 0, $index)
1481
-                            . '\\v{$version}' . substr($className, $index);
1480
+                            . '\\v{$version}'.substr($className, $index);
1482 1481
                     } else {
1483 1482
                         if (false !== ($index = strrpos($className, '_'))) {
1484 1483
                             $name = substr($className, 0, $index)
1485
-                                . '_v{$version}' . substr($className, $index);
1484
+                                . '_v{$version}'.substr($className, $index);
1486 1485
                         } else {
1487
-                            $name = 'v{$version}\\' . $className;
1486
+                            $name = 'v{$version}\\'.$className;
1488 1487
                         }
1489 1488
                     }
1490 1489
 
@@ -1524,7 +1523,7 @@  discard block
 block discarded – undo
1524 1523
             }
1525 1524
         } catch (Exception $e) {
1526 1525
             $e = new Exception(
1527
-                "mapAPIClasses failed. " . $e->getMessage(),
1526
+                "mapAPIClasses failed. ".$e->getMessage(),
1528 1527
                 $e->getCode(),
1529 1528
                 $e
1530 1529
             );
@@ -1653,7 +1652,7 @@  discard block
 block discarded – undo
1653 1652
     protected function preCall()
1654 1653
     {
1655 1654
         $o = & $this->apiMethodInfo;
1656
-        $preCall = '_pre_' . $o->methodName . '_'
1655
+        $preCall = '_pre_'.$o->methodName.'_'
1657 1656
             . $this->requestFormat->getExtension();
1658 1657
 
1659 1658
         if (method_exists($o->className, $preCall)) {
@@ -1676,7 +1675,7 @@  discard block
 block discarded – undo
1676 1675
     protected function postCall()
1677 1676
     {
1678 1677
         $o = & $this->apiMethodInfo;
1679
-        $postCall = '_post_' . $o->methodName . '_' .
1678
+        $postCall = '_post_'.$o->methodName.'_'.
1680 1679
             $this->responseFormat->getExtension();
1681 1680
         if (method_exists($o->className, $postCall)) {
1682 1681
             $this->dispatch('postCall');
Please login to merge, or discard this patch.
htdocs/includes/restler/framework/Luracast/Restler/PassThrough.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -47,10 +47,10 @@  discard block
 block discarded – undo
47 47
             if (!function_exists('finfo_open')) {
48 48
                 throw new RestException(
49 49
                     500,
50
-                    'Unable to find media type of ' .
51
-                    basename($filename) .
52
-                    ' either enable fileinfo php extension or update ' .
53
-                    'PassThrough::$mimeTypes to include mime type for ' . $extension .
50
+                    'Unable to find media type of '.
51
+                    basename($filename).
52
+                    ' either enable fileinfo php extension or update '.
53
+                    'PassThrough::$mimeTypes to include mime type for '.$extension.
54 54
                     ' extension'
55 55
                 );
56 56
             }
@@ -66,8 +66,8 @@  discard block
 block discarded – undo
66 66
             $cacheControl = str_replace('{expires}', $expires, $cacheControl);
67 67
             $expires = gmdate('D, d M Y H:i:s \G\M\T', time() + $expires);
68 68
         }
69
-        header('Cache-Control: ' . $cacheControl);
70
-        header('Expires: ' . $expires);
69
+        header('Cache-Control: '.$cacheControl);
70
+        header('Expires: '.$expires);
71 71
         $lastModified = filemtime($filename);
72 72
         if (
73 73
             isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) &&
@@ -76,13 +76,13 @@  discard block
 block discarded – undo
76 76
             header("{$_SERVER['SERVER_PROTOCOL']} 304 Not Modified");
77 77
             exit;
78 78
         }
79
-        header('Last-Modified: ' . date('r', $lastModified));
80
-        header('X-Powered-By: Luracast Restler v' . Restler::VERSION);
81
-        header('Content-type: ' . $mime);
82
-        header("Content-Length: " . filesize($filename));
79
+        header('Last-Modified: '.date('r', $lastModified));
80
+        header('X-Powered-By: Luracast Restler v'.Restler::VERSION);
81
+        header('Content-type: '.$mime);
82
+        header("Content-Length: ".filesize($filename));
83 83
         if ($forceDownload) {
84 84
             header("Content-Transfer-Encoding: binary");
85
-            header('Content-Disposition: attachment; filename="' . $filename . '"');
85
+            header('Content-Disposition: attachment; filename="'.$filename.'"');
86 86
         }
87 87
         readfile($filename);
88 88
         exit;
Please login to merge, or discard this patch.