@@ -27,6 +27,6 @@ |
||
27 | 27 | * |
28 | 28 | * @return mixed |
29 | 29 | */ |
30 | - public function __setAuthenticationStatus($isAuthenticated=false); |
|
30 | + public function __setAuthenticationStatus($isAuthenticated = false); |
|
31 | 31 | } |
32 | 32 |
@@ -63,9 +63,8 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
@@ -110,7 +110,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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'); |
@@ -47,10 +47,10 @@ discard block |
||
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 |
||
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 |
||
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; |
@@ -31,8 +31,8 @@ |
||
31 | 31 | public static function getUniqueIdentifier($includePlatform = false) |
32 | 32 | { |
33 | 33 | if (!static::$initialized) static::init(); |
34 | - return static::$id ? : base64_encode('ip:' . ($includePlatform |
|
35 | - ? static::$ip . '-' . static::$platform |
|
34 | + return static::$id ?: base64_encode('ip:'.($includePlatform |
|
35 | + ? static::$ip.'-'.static::$platform |
|
36 | 36 | : static::$ip |
37 | 37 | )); |
38 | 38 | } |
@@ -28,7 +28,7 @@ |
||
28 | 28 | //changes in iAuthenticate |
29 | 29 | Defaults::$authenticationMethod = '__isAuthenticated'; |
30 | 30 | |
31 | -include __DIR__ . '/iAuthenticate.php'; |
|
31 | +include __DIR__.'/iAuthenticate.php'; |
|
32 | 32 | |
33 | 33 | //changes in auto routing |
34 | 34 | Defaults::$smartAutoRouting = false; |
@@ -6,7 +6,7 @@ |
||
6 | 6 | |
7 | 7 | //changes in iAuthenticate |
8 | 8 | Defaults::$authenticationMethod = 'isAuthenticated'; |
9 | -include __DIR__ . '/iAuthenticate.php'; |
|
9 | +include __DIR__.'/iAuthenticate.php'; |
|
10 | 10 | |
11 | 11 | //changes in routing |
12 | 12 | Defaults::$autoRoutingEnabled = false; |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | use Luracast\Restler\Restler; |
3 | 3 | use Luracast\Restler\Util; |
4 | 4 | |
5 | -$template_vars = $data;//get_defined_vars(); |
|
5 | +$template_vars = $data; //get_defined_vars(); |
|
6 | 6 | |
7 | 7 | unset($template_vars['response']); |
8 | 8 | unset($template_vars['api']); |
@@ -43,11 +43,11 @@ discard block |
||
43 | 43 | continue; |
44 | 44 | } |
45 | 45 | //$output .= print_r($entry, true) . "\n"; |
46 | - $output .= "\nFile: " . $entry['file'] . " (Line: " . $entry['line'] . ")\n"; |
|
46 | + $output .= "\nFile: ".$entry['file']." (Line: ".$entry['line'].")\n"; |
|
47 | 47 | if (isset($entry['class'])) |
48 | - $output .= $entry['class'] . "::"; |
|
48 | + $output .= $entry['class']."::"; |
|
49 | 49 | $output .= $entry['function'] |
50 | - . "( " . json_encode($entry['args']) . " )\n"; |
|
50 | + . "( ".json_encode($entry['args'])." )\n"; |
|
51 | 51 | } |
52 | 52 | return $output; |
53 | 53 | } |
@@ -64,18 +64,18 @@ discard block |
||
64 | 64 | } else { |
65 | 65 | if (isset($response['error']['message'])) { |
66 | 66 | $icon = '<icon class="denied"></icon>'; |
67 | - $title = end(explode(':',$response['error']['message'],2)); |
|
67 | + $title = end(explode(':', $response['error']['message'], 2)); |
|
68 | 68 | } else { |
69 | 69 | $icon = '<icon class="warning"></icon>'; |
70 | 70 | $title = 'No Matching Resource'; |
71 | 71 | } |
72 | 72 | } |
73 | -function render($data, $shadow=true) |
|
73 | +function render($data, $shadow = true) |
|
74 | 74 | { |
75 | 75 | $r = ''; |
76 | 76 | if (empty($data)) |
77 | 77 | return $r; |
78 | - $r .= $shadow ? "<ul class=\"shadow\">\n": "<ul>\n"; |
|
78 | + $r .= $shadow ? "<ul class=\"shadow\">\n" : "<ul>\n"; |
|
79 | 79 | if (is_array($data)) { |
80 | 80 | // field name |
81 | 81 | foreach ($data as $key => $value) { |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | $r .= '<span>'; |
87 | 87 | if (is_array($value)) { |
88 | 88 | // recursive |
89 | - $r .= render($value,false); |
|
89 | + $r .= render($value, false); |
|
90 | 90 | } else { |
91 | 91 | // value, with hyperlinked hyperlinks |
92 | 92 | if (is_bool($value)) { |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | } |
95 | 95 | $value = htmlentities($value, ENT_COMPAT, 'UTF-8'); |
96 | 96 | if (strpos($value, 'http://') === 0) { |
97 | - $r .= '<a href="' . $value . '">' . $value . '</a>'; |
|
97 | + $r .= '<a href="'.$value.'">'.$value.'</a>'; |
|
98 | 98 | } else { |
99 | 99 | $r .= $value; |
100 | 100 | } |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | $r .= "</span></li>\n"; |
103 | 103 | } |
104 | 104 | } elseif (is_bool($data)) { |
105 | - $r .= '<li>' . ($data ? 'true' : 'false') . '</li>'; |
|
105 | + $r .= '<li>'.($data ? 'true' : 'false').'</li>'; |
|
106 | 106 | } else { |
107 | 107 | $r .= "<li><strong>$data</strong></li>"; |
108 | 108 | } |
@@ -110,11 +110,11 @@ discard block |
||
110 | 110 | return $r; |
111 | 111 | } |
112 | 112 | $reqHeadersArr = array(); |
113 | -$requestHeaders = $_SERVER['REQUEST_METHOD'] . ' ' . $_SERVER['REQUEST_URI'] . ' ' . $_SERVER['SERVER_PROTOCOL'] . PHP_EOL; |
|
113 | +$requestHeaders = $_SERVER['REQUEST_METHOD'].' '.$_SERVER['REQUEST_URI'].' '.$_SERVER['SERVER_PROTOCOL'].PHP_EOL; |
|
114 | 114 | foreach ($reqHeadersArr as $key => $value) { |
115 | 115 | if ($key == 'Host') |
116 | 116 | continue; |
117 | - $requestHeaders .= "$key: $value" . PHP_EOL; |
|
117 | + $requestHeaders .= "$key: $value".PHP_EOL; |
|
118 | 118 | } |
119 | 119 | // $requestHeaders = $this->encode(apache_request_headers(), FALSE, |
120 | 120 | // FALSE); |
@@ -134,20 +134,20 @@ discard block |
||
134 | 134 | <body> |
135 | 135 | <div id="breadcrumbs-one"> |
136 | 136 | <?php |
137 | - if(Util::$restler->exception){ |
|
138 | - $stages = Util::$restler->exception->getStages(); |
|
137 | + if (Util::$restler->exception) { |
|
138 | + $stages = Util::$restler->exception->getStages(); |
|
139 | 139 | $curStage = Util::$restler->exception->getStage(); |
140 | - foreach($stages['success'] as $stage){ |
|
140 | + foreach ($stages['success'] as $stage) { |
|
141 | 141 | echo "<a href=\"#\">$stage</a>"; |
142 | 142 | } |
143 | - foreach($stages['failure'] as $stage){ |
|
143 | + foreach ($stages['failure'] as $stage) { |
|
144 | 144 | echo '<a href="#" class="failure">' |
145 | 145 | . $stage |
146 | - . ($stage==$curStage ? ' <span class="state"/> ' : '') |
|
146 | + . ($stage == $curStage ? ' <span class="state"/> ' : '') |
|
147 | 147 | . '</a>'; |
148 | 148 | } |
149 | 149 | } else { |
150 | - foreach(Util::$restler->_events as $stage){ |
|
150 | + foreach (Util::$restler->_events as $stage) { |
|
151 | 151 | echo "<a href=\"#\">$stage</a>"; |
152 | 152 | } |
153 | 153 | } |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | </header> |
159 | 159 | <article> |
160 | 160 | |
161 | - <h2>Response:<right><?php echo $icon;?></right></h2> |
|
161 | + <h2>Response:<right><?php echo $icon; ?></right></h2> |
|
162 | 162 | <pre class="header"><?php echo $responseHeaders ?></pre> |
163 | 163 | <?php echo render($response); ?> |
164 | 164 | <h2>Additional Template Data:</h2> |
@@ -152,8 +152,8 @@ discard block |
||
152 | 152 | $filename == 'index.html' |
153 | 153 | ) { |
154 | 154 | $status = 302; |
155 | - $url = $this->restler->getBaseUrl() . '/' . $this->base() . '/'; |
|
156 | - header("{$_SERVER['SERVER_PROTOCOL']} $status " . RestException::$codes[$status]); |
|
155 | + $url = $this->restler->getBaseUrl().'/'.$this->base().'/'; |
|
156 | + header("{$_SERVER['SERVER_PROTOCOL']} $status ".RestException::$codes[$status]); |
|
157 | 157 | header("Location: $url"); |
158 | 158 | exit; |
159 | 159 | } |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | ) { |
164 | 164 | $filename .= '.js'; |
165 | 165 | } |
166 | - PassThrough::file(__DIR__ . '/explorer/' . (empty($filename) ? 'index.html' : $filename), false, |
|
166 | + PassThrough::file(__DIR__.'/explorer/'.(empty($filename) ? 'index.html' : $filename), false, |
|
167 | 167 | 0); //60 * 60 * 24); |
168 | 168 | } |
169 | 169 | |
@@ -173,15 +173,15 @@ discard block |
||
173 | 173 | public function swagger() |
174 | 174 | { |
175 | 175 | $r = new stdClass(); |
176 | - $version = (string)$this->restler->getRequestedApiVersion(); |
|
176 | + $version = (string) $this->restler->getRequestedApiVersion(); |
|
177 | 177 | $r->swagger = static::SWAGGER; |
178 | 178 | |
179 | 179 | $info = parse_url($this->restler->getBaseUrl()); |
180 | 180 | $r->host = $info['host']; |
181 | 181 | if (isset($info['port'])) { |
182 | - $r->host .= ':' . $info['port']; |
|
182 | + $r->host .= ':'.$info['port']; |
|
183 | 183 | } |
184 | - $r->basePath = isset($info['path']) ? $info['path'] : ''; |
|
184 | + $r->basePath = isset($info['path']) ? $info['path'] : ''; |
|
185 | 185 | if (!empty(static::$schemes)) { |
186 | 186 | $r->schemes = static::$schemes; |
187 | 187 | } |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | $r->consumes = $this->restler->getReadableMimeTypes(); |
191 | 191 | |
192 | 192 | $r->paths = $this->paths($version); |
193 | - $r->definitions = (object)$this->models; |
|
193 | + $r->definitions = (object) $this->models; |
|
194 | 194 | $r->securityDefinitions = $this->securityDefinitions(); |
195 | 195 | $r->info = compact('version') + array_filter(get_class_vars(static::$infoClass)); |
196 | 196 | |
@@ -302,8 +302,8 @@ discard block |
||
302 | 302 | $description = ''; //'<section class="body-param">'; |
303 | 303 | foreach ($firstChild['children'] as $child) { |
304 | 304 | $description .= isset($child['required']) && $child['required'] |
305 | - ? '**' . $child['name'] . '** (required) '.PHP_EOL |
|
306 | - : $child['name'] . ' '.PHP_EOL; |
|
305 | + ? '**'.$child['name'].'** (required) '.PHP_EOL |
|
306 | + : $child['name'].' '.PHP_EOL; |
|
307 | 307 | } |
308 | 308 | //$description .= '</section>'; |
309 | 309 | } |
@@ -312,8 +312,8 @@ discard block |
||
312 | 312 | $description = ''; //'<section class="body-param">'; |
313 | 313 | foreach ($children as $child) { |
314 | 314 | $description .= isset($child['required']) && $child['required'] |
315 | - ? '**' . $child['name'] . '** (required) '.PHP_EOL |
|
316 | - : $child['name'] . ' '.PHP_EOL; |
|
315 | + ? '**'.$child['name'].'** (required) '.PHP_EOL |
|
316 | + : $child['name'].' '.PHP_EOL; |
|
317 | 317 | } |
318 | 318 | //$description .= '</section>'; |
319 | 319 | |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | //$p->allowMultiple = false; |
367 | 367 | |
368 | 368 | if (isset($p->{'$ref'})) { |
369 | - $p->schema = (object)array('$ref' => ($p->{'$ref'})); |
|
369 | + $p->schema = (object) array('$ref' => ($p->{'$ref'})); |
|
370 | 370 | unset($p->{'$ref'}); |
371 | 371 | } |
372 | 372 | |
@@ -377,7 +377,7 @@ discard block |
||
377 | 377 | { |
378 | 378 | $code = '200'; |
379 | 379 | $r = array( |
380 | - $code => (object)array( |
|
380 | + $code => (object) array( |
|
381 | 381 | 'description' => 'Success', |
382 | 382 | 'schema' => new stdClass() |
383 | 383 | ) |
@@ -445,7 +445,7 @@ discard block |
||
445 | 445 | if ($info->children) { |
446 | 446 | $contentType = Util::getShortName($info->contentType); |
447 | 447 | $model = $this->model($contentType, $info->children); |
448 | - $object->items = (object)array( |
|
448 | + $object->items = (object) array( |
|
449 | 449 | '$ref' => "#/definitions/$contentType" |
450 | 450 | ); |
451 | 451 | } elseif ($info->contentType && $info->contentType == 'associative') { |
@@ -463,23 +463,23 @@ discard block |
||
463 | 463 | if (is_string($info->contentType) && $t = Util::nestedValue(static::$dataTypeAlias, |
464 | 464 | strtolower($info->contentType))) { |
465 | 465 | if (is_array($t)) { |
466 | - $object->items = (object)array( |
|
466 | + $object->items = (object) array( |
|
467 | 467 | 'type' => $t[0], |
468 | 468 | 'format' => $t[1], |
469 | 469 | ); |
470 | 470 | } else { |
471 | - $object->items = (object)array( |
|
471 | + $object->items = (object) array( |
|
472 | 472 | 'type' => $t, |
473 | 473 | ); |
474 | 474 | } |
475 | 475 | } else { |
476 | 476 | $contentType = Util::getShortName($info->contentType); |
477 | - $object->items = (object)array( |
|
477 | + $object->items = (object) array( |
|
478 | 478 | '$ref' => "#/definitions/$contentType" |
479 | 479 | ); |
480 | 480 | } |
481 | 481 | } else { |
482 | - $object->items = (object)array( |
|
482 | + $object->items = (object) array( |
|
483 | 483 | 'type' => 'string' |
484 | 484 | ); |
485 | 485 | } |
@@ -513,7 +513,7 @@ discard block |
||
513 | 513 | private function operationId(array $route) |
514 | 514 | { |
515 | 515 | static $hash = array(); |
516 | - $id = $route['httpMethod'] . ' ' . $route['url']; |
|
516 | + $id = $route['httpMethod'].' '.$route['url']; |
|
517 | 517 | if (isset($hash[$id])) { |
518 | 518 | return $hash[$id]; |
519 | 519 | } |
@@ -521,14 +521,14 @@ discard block |
||
521 | 521 | $method = $route['methodName']; |
522 | 522 | |
523 | 523 | if (isset(static::$prefixes[$method])) { |
524 | - $method = static::$prefixes[$method] . $class; |
|
524 | + $method = static::$prefixes[$method].$class; |
|
525 | 525 | } else { |
526 | 526 | $method = str_replace( |
527 | 527 | array_keys(static::$prefixes), |
528 | 528 | array_values(static::$prefixes), |
529 | 529 | $method |
530 | 530 | ); |
531 | - $method = lcfirst($class) . ucfirst($method); |
|
531 | + $method = lcfirst($class).ucfirst($method); |
|
532 | 532 | } |
533 | 533 | $hash[$id] = $method; |
534 | 534 | |
@@ -537,13 +537,13 @@ discard block |
||
537 | 537 | |
538 | 538 | private function modelName(array $route) |
539 | 539 | { |
540 | - return $this->operationId($route) . 'Model'; |
|
540 | + return $this->operationId($route).'Model'; |
|
541 | 541 | } |
542 | 542 | |
543 | 543 | private function securityDefinitions() |
544 | 544 | { |
545 | 545 | $r = new stdClass(); |
546 | - $r->api_key = (object)array( |
|
546 | + $r->api_key = (object) array( |
|
547 | 547 | 'type' => 'apiKey', |
548 | 548 | 'name' => 'api_key', |
549 | 549 | 'in' => 'query', |