@@ -53,7 +53,9 @@ discard block |
||
| 53 | 53 | public function getCustomHTMLBody($callback = false) |
| 54 | 54 | { |
| 55 | 55 | $body = $this->getHtmlBody(); |
| 56 | - if($body === null) return null; |
|
| 56 | + if($body === null) { |
|
| 57 | + return null; |
|
| 58 | + } |
|
| 57 | 59 | |
| 58 | 60 | if ($callback !== false) { |
| 59 | 61 | $aAttachment = $this->parent->getAttachments(); |
@@ -61,7 +63,7 @@ discard block |
||
| 61 | 63 | /** @var Attachment $oAttachment */ |
| 62 | 64 | if(is_callable($callback)) { |
| 63 | 65 | $body = $callback($body, $oAttachment); |
| 64 | - }elseif(is_string($callback)) { |
|
| 66 | + } elseif(is_string($callback)) { |
|
| 65 | 67 | call_user_func($callback, [$body, $oAttachment]); |
| 66 | 68 | } |
| 67 | 69 | }); |
@@ -244,7 +244,9 @@ discard block |
||
| 244 | 244 | { |
| 245 | 245 | $this->client->checkConnection(); |
| 246 | 246 | $status = $this->client->getConnection()->renameFolder($this->full_name, $new_name); |
| 247 | - if($expunge) $this->client->expunge(); |
|
| 247 | + if($expunge) { |
|
| 248 | + $this->client->expunge(); |
|
| 249 | + } |
|
| 248 | 250 | |
| 249 | 251 | $folder = $this->client->getFolder($new_name); |
| 250 | 252 | $event = $this->getEvent("folder", "moved"); |
@@ -326,7 +328,9 @@ discard block |
||
| 326 | 328 | public function delete($expunge = true) |
| 327 | 329 | { |
| 328 | 330 | $status = $this->client->getConnection()->deleteFolder($this->path); |
| 329 | - if($expunge) $this->client->expunge(); |
|
| 331 | + if($expunge) { |
|
| 332 | + $this->client->expunge(); |
|
| 333 | + } |
|
| 330 | 334 | |
| 331 | 335 | $event = $this->getEvent("folder", "deleted"); |
| 332 | 336 | $event::dispatch($this); |
@@ -403,7 +407,7 @@ discard block |
||
| 403 | 407 | |
| 404 | 408 | $connection->idle(); |
| 405 | 409 | } |
| 406 | - }catch (Exceptions\RuntimeException $e) { |
|
| 410 | + } catch (Exceptions\RuntimeException $e) { |
|
| 407 | 411 | if(strpos($e->getMessage(), "connection closed") === false) { |
| 408 | 412 | throw $e; |
| 409 | 413 | } |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | return null; |
| 134 | - }elseif (strtolower(substr($method, 0, 3)) === 'set') { |
|
| 134 | + } elseif (strtolower(substr($method, 0, 3)) === 'set') { |
|
| 135 | 135 | $name = Str::snake(substr($method, 3)); |
| 136 | 136 | |
| 137 | 137 | $this->attributes[$name] = array_pop($arguments); |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | $this->setName($filename); |
| 230 | 230 | } elseif (($name = $this->part->name) !== null) { |
| 231 | 231 | $this->setName($name); |
| 232 | - }else { |
|
| 232 | + } else { |
|
| 233 | 233 | $this->setName("undefined"); |
| 234 | 234 | } |
| 235 | 235 | |
@@ -266,7 +266,7 @@ discard block |
||
| 266 | 266 | if ($name !== null) { |
| 267 | 267 | if($decoder === 'utf-8' && extension_loaded('imap')) { |
| 268 | 268 | $this->name = \imap_utf8($name); |
| 269 | - }else{ |
|
| 269 | + } else{ |
|
| 270 | 270 | $this->name = mb_decode_mimeheader($name); |
| 271 | 271 | } |
| 272 | 272 | } |
@@ -64,7 +64,6 @@ |
||
| 64 | 64 | ) |
| 65 | 65 | ) { |
| 66 | 66 | echo 'Done. Check ' . realpath($fileName) . ' file.'; |
| 67 | -} |
|
| 68 | -else { |
|
| 67 | +} else { |
|
| 69 | 68 | echo 'Failed to write ' . realpath($fileName) . ' to disk.'; |
| 70 | 69 | } |
@@ -48,8 +48,9 @@ discard block |
||
| 48 | 48 | public function __call($eventName, $params) |
| 49 | 49 | { |
| 50 | 50 | if (0 === strpos($eventName, 'on')) { |
| 51 | - if (!isset($this->listeners[$eventName]) || !is_array($this->listeners[$eventName])) |
|
| 52 | - $this->listeners[$eventName] = array(); |
|
| 51 | + if (!isset($this->listeners[$eventName]) || !is_array($this->listeners[$eventName])) { |
|
| 52 | + $this->listeners[$eventName] = array(); |
|
| 53 | + } |
|
| 53 | 54 | $this->listeners[$eventName][] = $params[0]; |
| 54 | 55 | } |
| 55 | 56 | return $this; |
@@ -93,8 +94,9 @@ discard block |
||
| 93 | 94 | $this->events[] = $eventName; |
| 94 | 95 | $params = func_get_args(); |
| 95 | 96 | $eventName = 'on' . ucfirst(array_shift($params)); |
| 96 | - if (isset($this->listeners[$eventName])) |
|
| 97 | - foreach ($this->listeners[$eventName] as $callback) |
|
| 97 | + if (isset($this->listeners[$eventName])) { |
|
| 98 | + foreach ($this->listeners[$eventName] as $callback) |
|
| 98 | 99 | call_user_func_array($callback, $params); |
| 100 | + } |
|
| 99 | 101 | } |
| 100 | 102 | } |
@@ -285,8 +285,9 @@ discard block |
||
| 285 | 285 | $this->route(); |
| 286 | 286 | throw $e; |
| 287 | 287 | } |
| 288 | - if (Defaults::$useVendorMIMEVersioning) |
|
| 289 | - $this->responseFormat = $this->negotiateResponseFormat(); |
|
| 288 | + if (Defaults::$useVendorMIMEVersioning) { |
|
| 289 | + $this->responseFormat = $this->negotiateResponseFormat(); |
|
| 290 | + } |
|
| 290 | 291 | $this->route(); |
| 291 | 292 | } catch (Exception $e) { |
| 292 | 293 | $this->negotiate(); |
@@ -401,9 +402,10 @@ discard block |
||
| 401 | 402 | foreach ($args as $className) { |
| 402 | 403 | $obj = Scope::get($className); |
| 403 | 404 | |
| 404 | - if (!$obj instanceof iFormat) |
|
| 405 | - throw new Exception('Invalid format class; must implement ' . |
|
| 405 | + if (!$obj instanceof iFormat) { |
|
| 406 | + throw new Exception('Invalid format class; must implement ' . |
|
| 406 | 407 | 'iFormat interface'); |
| 408 | + } |
|
| 407 | 409 | if ($throwException && get_class($obj) == get_class($this->requestFormat)) { |
| 408 | 410 | $throwException = false; |
| 409 | 411 | } |
@@ -413,12 +415,15 @@ discard block |
||
| 413 | 415 | $this->writableMimeTypes[] = $mime; |
| 414 | 416 | $extensions[".$extension"] = true; |
| 415 | 417 | } |
| 416 | - if($obj->isReadable()) |
|
| 417 | - $this->readableMimeTypes[] = $mime; |
|
| 418 | - if (!isset($this->formatMap[$extension])) |
|
| 419 | - $this->formatMap[$extension] = $className; |
|
| 420 | - if (!isset($this->formatMap[$mime])) |
|
| 421 | - $this->formatMap[$mime] = $className; |
|
| 418 | + if($obj->isReadable()) { |
|
| 419 | + $this->readableMimeTypes[] = $mime; |
|
| 420 | + } |
|
| 421 | + if (!isset($this->formatMap[$extension])) { |
|
| 422 | + $this->formatMap[$extension] = $className; |
|
| 423 | + } |
|
| 424 | + if (!isset($this->formatMap[$mime])) { |
|
| 425 | + $this->formatMap[$mime] = $className; |
|
| 426 | + } |
|
| 422 | 427 | } |
| 423 | 428 | } |
| 424 | 429 | if ($throwException) { |
@@ -448,17 +453,21 @@ discard block |
||
| 448 | 453 | foreach ($args as $className) { |
| 449 | 454 | $obj = Scope::get($className); |
| 450 | 455 | |
| 451 | - if (!$obj instanceof iFormat) |
|
| 452 | - throw new Exception('Invalid format class; must implement ' . |
|
| 456 | + if (!$obj instanceof iFormat) { |
|
| 457 | + throw new Exception('Invalid format class; must implement ' . |
|
| 453 | 458 | 'iFormat interface'); |
| 459 | + } |
|
| 454 | 460 | |
| 455 | 461 | foreach ($obj->getMIMEMap() as $mime => $extension) { |
| 456 | - if (!isset($this->formatOverridesMap[$extension])) |
|
| 457 | - $this->formatOverridesMap[$extension] = $className; |
|
| 458 | - if (!isset($this->formatOverridesMap[$mime])) |
|
| 459 | - $this->formatOverridesMap[$mime] = $className; |
|
| 460 | - if($obj->isWritable()) |
|
| 461 | - $extensions[".$extension"] = true; |
|
| 462 | + if (!isset($this->formatOverridesMap[$extension])) { |
|
| 463 | + $this->formatOverridesMap[$extension] = $className; |
|
| 464 | + } |
|
| 465 | + if (!isset($this->formatOverridesMap[$mime])) { |
|
| 466 | + $this->formatOverridesMap[$mime] = $className; |
|
| 467 | + } |
|
| 468 | + if($obj->isWritable()) { |
|
| 469 | + $extensions[".$extension"] = true; |
|
| 470 | + } |
|
| 462 | 471 | } |
| 463 | 472 | } |
| 464 | 473 | $this->formatOverridesMap['extensions'] = array_keys($extensions); |
@@ -497,9 +506,10 @@ discard block |
||
| 497 | 506 | protected function getPath() |
| 498 | 507 | { |
| 499 | 508 | // fix SCRIPT_NAME for PHP 5.4 built-in web server |
| 500 | - if (false === strpos($_SERVER['SCRIPT_NAME'], '.php')) |
|
| 501 | - $_SERVER['SCRIPT_NAME'] |
|
| 509 | + if (false === strpos($_SERVER['SCRIPT_NAME'], '.php')) { |
|
| 510 | + $_SERVER['SCRIPT_NAME'] |
|
| 502 | 511 | = '/' . substr($_SERVER['SCRIPT_FILENAME'], strlen($_SERVER['DOCUMENT_ROOT']) + 1); |
| 512 | + } |
|
| 503 | 513 | |
| 504 | 514 | list($base, $path) = Util::splitCommonPath( |
| 505 | 515 | strtok(urldecode($_SERVER['REQUEST_URI']), '?'), //remove query string |
@@ -520,8 +530,9 @@ discard block |
||
| 520 | 530 | (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') || // Amazon ELB |
| 521 | 531 | (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on'); |
| 522 | 532 | $baseUrl = ($https ? 'https://' : 'http://') . $_SERVER['SERVER_NAME']; |
| 523 | - if (!$https && $port != '80' || $https && $port != '443') |
|
| 524 | - $baseUrl .= ':' . $port; |
|
| 533 | + if (!$https && $port != '80' || $https && $port != '443') { |
|
| 534 | + $baseUrl .= ':' . $port; |
|
| 535 | + } |
|
| 525 | 536 | $this->baseUrl = $baseUrl . $base; |
| 526 | 537 | } elseif (!empty($base) && false === strpos($this->baseUrl, $base)) { |
| 527 | 538 | $this->baseUrl .= $base; |
@@ -571,9 +582,9 @@ discard block |
||
| 571 | 582 | if (false !== $pos = strpos($mime, ';')) { |
| 572 | 583 | $mime = substr($mime, 0, $pos); |
| 573 | 584 | } |
| 574 | - if ($mime == UrlEncodedFormat::MIME) |
|
| 575 | - $format = Scope::get('UrlEncodedFormat'); |
|
| 576 | - elseif (isset($this->formatMap[$mime])) { |
|
| 585 | + if ($mime == UrlEncodedFormat::MIME) { |
|
| 586 | + $format = Scope::get('UrlEncodedFormat'); |
|
| 587 | + } elseif (isset($this->formatMap[$mime])) { |
|
| 577 | 588 | $format = Scope::get($this->formatMap[$mime]); |
| 578 | 589 | $format->setMIME($mime); |
| 579 | 590 | } elseif (!$this->requestFormatDiffered && isset($this->formatOverridesMap[$mime])) { |
@@ -630,8 +641,9 @@ discard block |
||
| 630 | 641 | } |
| 631 | 642 | |
| 632 | 643 | $stream = $this->getRequestStream(); |
| 633 | - if($stream === FALSE) |
|
| 634 | - return array(); |
|
| 644 | + if($stream === FALSE) { |
|
| 645 | + return array(); |
|
| 646 | + } |
|
| 635 | 647 | $r = $this->requestFormat instanceof iDecodeStream |
| 636 | 648 | ? $this->requestFormat->decodeStream($stream) |
| 637 | 649 | : $this->requestFormat->decode(stream_get_contents($stream)); |
@@ -673,8 +685,9 @@ discard block |
||
| 673 | 685 | } |
| 674 | 686 | } |
| 675 | 687 | } |
| 676 | - if (!isset($o->className)) |
|
| 677 | - throw new RestException(404); |
|
| 688 | + if (!isset($o->className)) { |
|
| 689 | + throw new RestException(404); |
|
| 690 | + } |
|
| 678 | 691 | |
| 679 | 692 | if(isset($this->apiVersionMap[$o->className])){ |
| 680 | 693 | Scope::$classAliases[Util::getShortName($o->className)] |
@@ -715,13 +728,15 @@ discard block |
||
| 715 | 728 | $this->requestMethod == 'OPTIONS' |
| 716 | 729 | && Defaults::$crossOriginResourceSharing |
| 717 | 730 | ) { |
| 718 | - if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_METHOD'])) |
|
| 719 | - header('Access-Control-Allow-Methods: ' |
|
| 731 | + if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_METHOD'])) { |
|
| 732 | + header('Access-Control-Allow-Methods: ' |
|
| 720 | 733 | . Defaults::$accessControlAllowMethods); |
| 734 | + } |
|
| 721 | 735 | |
| 722 | - if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS'])) |
|
| 723 | - header('Access-Control-Allow-Headers: ' |
|
| 736 | + if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS'])) { |
|
| 737 | + header('Access-Control-Allow-Headers: ' |
|
| 724 | 738 | . $_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']); |
| 739 | + } |
|
| 725 | 740 | |
| 726 | 741 | header('Access-Control-Allow-Origin: ' . |
| 727 | 742 | ((Defaults::$accessControlAllowOrigin == '*' && isset($_SERVER['HTTP_ORIGIN'])) |
@@ -755,11 +770,12 @@ discard block |
||
| 755 | 770 | $formats = explode(',', (string)$metadata['format']); |
| 756 | 771 | foreach ($formats as $i => $f) { |
| 757 | 772 | $f = trim($f); |
| 758 | - if (!in_array($f, $this->formatOverridesMap)) |
|
| 759 | - throw new RestException( |
|
| 773 | + if (!in_array($f, $this->formatOverridesMap)) { |
|
| 774 | + throw new RestException( |
|
| 760 | 775 | 500, |
| 761 | 776 | "Given @format is not present in overriding formats. Please call `\$r->setOverridingFormats('$f');` first." |
| 762 | 777 | ); |
| 778 | + } |
|
| 763 | 779 | $formats[$i] = $f; |
| 764 | 780 | } |
| 765 | 781 | call_user_func_array(array($this, 'setSupportedFormats'), $formats); |
@@ -1036,8 +1052,9 @@ discard block |
||
| 1036 | 1052 | } |
| 1037 | 1053 | $valid = $o->parameters[$index]; |
| 1038 | 1054 | $o->parameters[$index] = null; |
| 1039 | - if (empty(Validator::$exceptions)) |
|
| 1040 | - $o->metadata['param'][$index]['autofocus'] = true; |
|
| 1055 | + if (empty(Validator::$exceptions)) { |
|
| 1056 | + $o->metadata['param'][$index]['autofocus'] = true; |
|
| 1057 | + } |
|
| 1041 | 1058 | $valid = $validator::validate( |
| 1042 | 1059 | $valid, $info |
| 1043 | 1060 | ); |
@@ -1054,8 +1071,9 @@ discard block |
||
| 1054 | 1071 | $accessLevel = max( |
| 1055 | 1072 | Defaults::$apiAccessLevel, |
| 1056 | 1073 | $o->accessLevel); |
| 1057 | - if (function_exists('newrelic_name_transaction')) |
|
| 1058 | - newrelic_name_transaction("{$o->className}/{$o->methodName}"); |
|
| 1074 | + if (function_exists('newrelic_name_transaction')) { |
|
| 1075 | + newrelic_name_transaction("{$o->className}/{$o->methodName}"); |
|
| 1076 | + } |
|
| 1059 | 1077 | $object = Scope::get($o->className); |
| 1060 | 1078 | switch ($accessLevel) { |
| 1061 | 1079 | case 3: //protected method |
@@ -1099,8 +1117,9 @@ discard block |
||
| 1099 | 1117 | { |
| 1100 | 1118 | //only GET method should be cached if allowed by API developer |
| 1101 | 1119 | $expires = $this->requestMethod == 'GET' ? Defaults::$headerExpires : 0; |
| 1102 | - if(!is_array(Defaults::$headerCacheControl)) |
|
| 1103 | - Defaults::$headerCacheControl = array(Defaults::$headerCacheControl); |
|
| 1120 | + if(!is_array(Defaults::$headerCacheControl)) { |
|
| 1121 | + Defaults::$headerCacheControl = array(Defaults::$headerCacheControl); |
|
| 1122 | + } |
|
| 1104 | 1123 | $cacheControl = Defaults::$headerCacheControl[0]; |
| 1105 | 1124 | if ($expires > 0) { |
| 1106 | 1125 | $cacheControl = $this->apiMethodInfo->accessLevel |
@@ -1141,8 +1160,9 @@ discard block |
||
| 1141 | 1160 | @header('Content-Language: ' . Defaults::$language); |
| 1142 | 1161 | |
| 1143 | 1162 | if (isset($this->apiMethodInfo->metadata['header'])) { |
| 1144 | - foreach ($this->apiMethodInfo->metadata['header'] as $header) |
|
| 1145 | - @header($header, true); |
|
| 1163 | + foreach ($this->apiMethodInfo->metadata['header'] as $header) { |
|
| 1164 | + @header($header, true); |
|
| 1165 | + } |
|
| 1146 | 1166 | } |
| 1147 | 1167 | $code = 200; |
| 1148 | 1168 | if (!Defaults::$suppressResponseCode) { |
@@ -1206,8 +1226,9 @@ discard block |
||
| 1206 | 1226 | foreach ($this->errorClasses as $className) { |
| 1207 | 1227 | if (method_exists($className, $method)) { |
| 1208 | 1228 | $obj = Scope::get($className); |
| 1209 | - if ($obj->$method($exception)) |
|
| 1210 | - $handled = true; |
|
| 1229 | + if ($obj->$method($exception)) { |
|
| 1230 | + $handled = true; |
|
| 1231 | + } |
|
| 1211 | 1232 | } |
| 1212 | 1233 | } |
| 1213 | 1234 | if ($handled) { |
@@ -38,10 +38,12 @@ discard block |
||
| 38 | 38 | */ |
| 39 | 39 | public static function file($filename, $forceDownload = false, $expires = 0, $isPublic = true) |
| 40 | 40 | { |
| 41 | - if (!is_file($filename)) |
|
| 42 | - throw new RestException(404); |
|
| 43 | - if (!is_readable($filename)) |
|
| 44 | - throw new RestException(403); |
|
| 41 | + if (!is_file($filename)) { |
|
| 42 | + throw new RestException(404); |
|
| 43 | + } |
|
| 44 | + if (!is_readable($filename)) { |
|
| 45 | + throw new RestException(403); |
|
| 46 | + } |
|
| 45 | 47 | $extension = strtolower(pathinfo($filename, PATHINFO_EXTENSION)); |
| 46 | 48 | if (!$mime = Util::nestedValue(static::$mimeTypes, $extension)) { |
| 47 | 49 | if (!function_exists('finfo_open')) { |
@@ -57,8 +59,9 @@ discard block |
||
| 57 | 59 | $finfo = finfo_open(FILEINFO_MIME_TYPE); |
| 58 | 60 | $mime = finfo_file($finfo, $filename); |
| 59 | 61 | } |
| 60 | - if (!is_array(Defaults::$headerCacheControl)) |
|
| 61 | - Defaults::$headerCacheControl = array(Defaults::$headerCacheControl); |
|
| 62 | + if (!is_array(Defaults::$headerCacheControl)) { |
|
| 63 | + Defaults::$headerCacheControl = array(Defaults::$headerCacheControl); |
|
| 64 | + } |
|
| 62 | 65 | $cacheControl = Defaults::$headerCacheControl[0]; |
| 63 | 66 | if ($expires > 0) { |
| 64 | 67 | $cacheControl = $isPublic ? 'public' : 'private'; |
@@ -233,8 +233,9 @@ discard block |
||
| 233 | 233 | } |
| 234 | 234 | $fLen = strlen($fullPath); |
| 235 | 235 | if ($tSlash) { |
| 236 | - if ($fLen != $tLen && !Text::beginsWith($fullPath, $target . '/')) |
|
| 237 | - continue; |
|
| 236 | + if ($fLen != $tLen && !Text::beginsWith($fullPath, $target . '/')) { |
|
| 237 | + continue; |
|
| 238 | + } |
|
| 238 | 239 | } elseif ($fLen > $tLen + 1 && $fullPath[$tLen + 1] != '{' && !Text::beginsWith($fullPath, '{')) { |
| 239 | 240 | //when mapped to root exclude paths that have static parts |
| 240 | 241 | //they are listed else where under that static part name |
@@ -246,8 +247,9 @@ discard block |
||
| 246 | 247 | } |
| 247 | 248 | foreach (static::$excludedPaths as $exclude) { |
| 248 | 249 | if (empty($exclude)) { |
| 249 | - if ($fullPath == $exclude) |
|
| 250 | - continue 2; |
|
| 250 | + if ($fullPath == $exclude) { |
|
| 251 | + continue 2; |
|
| 252 | + } |
|
| 251 | 253 | } elseif (Text::beginsWith($fullPath, $exclude)) { |
| 252 | 254 | continue 2; |
| 253 | 255 | } |
@@ -285,8 +287,9 @@ discard block |
||
| 285 | 287 | } |
| 286 | 288 | $nickname = $this->_nickname($route); |
| 287 | 289 | $index = static::$placeFormatExtensionBeforeDynamicParts && $pos > 0 ? $pos : 0; |
| 288 | - if (!empty($parts[$index])) |
|
| 289 | - $parts[$index] .= $this->formatString; |
|
| 290 | + if (!empty($parts[$index])) { |
|
| 291 | + $parts[$index] .= $this->formatString; |
|
| 292 | + } |
|
| 290 | 293 | |
| 291 | 294 | $fullPath = implode('/', $parts); |
| 292 | 295 | $description = isset( |
@@ -391,8 +394,9 @@ discard block |
||
| 391 | 394 | if (!$count) { |
| 392 | 395 | throw new RestException(404); |
| 393 | 396 | } |
| 394 | - if (!is_null($r)) |
|
| 395 | - $r->models = $this->_models; |
|
| 397 | + if (!is_null($r)) { |
|
| 398 | + $r->models = $this->_models; |
|
| 399 | + } |
|
| 396 | 400 | usort( |
| 397 | 401 | $r->apis, |
| 398 | 402 | function ($a, $b) { |
@@ -684,8 +688,9 @@ discard block |
||
| 684 | 688 | // Create default object that includes parameters to be submitted |
| 685 | 689 | $defaultObject = new \StdClass(); |
| 686 | 690 | foreach ($this->_bodyParam['names'] as $name => $values) { |
| 687 | - if (!$values->required) |
|
| 688 | - continue; |
|
| 691 | + if (!$values->required) { |
|
| 692 | + continue; |
|
| 693 | + } |
|
| 689 | 694 | if (class_exists($values->dataType)) { |
| 690 | 695 | $myClassName = $values->dataType; |
| 691 | 696 | $defaultObject->$name = new $myClassName(); |
@@ -709,8 +714,9 @@ discard block |
||
| 709 | 714 | } |
| 710 | 715 | $properties = array(); |
| 711 | 716 | if (!$instance) { |
| 712 | - if (!class_exists($className)) |
|
| 713 | - return; |
|
| 717 | + if (!class_exists($className)) { |
|
| 718 | + return; |
|
| 719 | + } |
|
| 714 | 720 | $instance = new $className(); |
| 715 | 721 | } |
| 716 | 722 | $data = get_object_vars($instance); |
@@ -831,8 +837,12 @@ discard block |
||
| 831 | 837 | } |
| 832 | 838 | return 'array'; |
| 833 | 839 | } |
| 834 | - if (is_bool($o)) return 'boolean'; |
|
| 835 | - if (is_numeric($o)) return is_float($o) ? 'float' : 'int'; |
|
| 840 | + if (is_bool($o)) { |
|
| 841 | + return 'boolean'; |
|
| 842 | + } |
|
| 843 | + if (is_numeric($o)) { |
|
| 844 | + return is_float($o) ? 'float' : 'int'; |
|
| 845 | + } |
|
| 836 | 846 | return 'string'; |
| 837 | 847 | } |
| 838 | 848 | |
@@ -883,8 +893,9 @@ discard block |
||
| 883 | 893 | */ |
| 884 | 894 | public function index() |
| 885 | 895 | { |
| 886 | - if (!static::$accessControlFunction && Defaults::$accessControlFunction) |
|
| 887 | - static::$accessControlFunction = Defaults::$accessControlFunction; |
|
| 896 | + if (!static::$accessControlFunction && Defaults::$accessControlFunction) { |
|
| 897 | + static::$accessControlFunction = Defaults::$accessControlFunction; |
|
| 898 | + } |
|
| 888 | 899 | $version = $this->restler->getRequestedApiVersion(); |
| 889 | 900 | $allRoutes = Util::nestedValue(Routes::toArray(), "v$version"); |
| 890 | 901 | $r = $this->_resourceListing(); |
@@ -937,8 +948,9 @@ discard block |
||
| 937 | 948 | foreach ($allRoutes as $fullPath => $routes) { |
| 938 | 949 | $path = explode('/', $fullPath); |
| 939 | 950 | $resource = isset($path[0]) ? $path[0] : ''; |
| 940 | - if ($resource == 'resources' || Text::endsWith($resource, 'index')) |
|
| 941 | - continue; |
|
| 951 | + if ($resource == 'resources' || Text::endsWith($resource, 'index')) { |
|
| 952 | + continue; |
|
| 953 | + } |
|
| 942 | 954 | foreach ($routes as $httpMethod => $route) { |
| 943 | 955 | if (in_array($httpMethod, static::$excludedHttpMethods)) { |
| 944 | 956 | continue; |
@@ -949,8 +961,9 @@ discard block |
||
| 949 | 961 | |
| 950 | 962 | foreach (static::$excludedPaths as $exclude) { |
| 951 | 963 | if (empty($exclude)) { |
| 952 | - if ($fullPath == $exclude) |
|
| 953 | - continue 2; |
|
| 964 | + if ($fullPath == $exclude) { |
|
| 965 | + continue 2; |
|
| 966 | + } |
|
| 954 | 967 | } elseif (Text::beginsWith($fullPath, $exclude)) { |
| 955 | 968 | continue 2; |
| 956 | 969 | } |
@@ -30,7 +30,9 @@ |
||
| 30 | 30 | |
| 31 | 31 | public static function getUniqueIdentifier($includePlatform = false) |
| 32 | 32 | { |
| 33 | - if (!static::$initialized) static::init(); |
|
| 33 | + if (!static::$initialized) { |
|
| 34 | + static::init(); |
|
| 35 | + } |
|
| 34 | 36 | return static::$id ? : base64_encode('ip:' . ($includePlatform |
| 35 | 37 | ? static::$ip . '-' . static::$platform |
| 36 | 38 | : static::$ip |