@@ -25,9 +25,11 @@ |
||
25 | 25 | * |
26 | 26 | * @return void |
27 | 27 | */ |
28 | - public function do() |
|
28 | + public function do { |
|
29 | + () |
|
29 | 30 | { |
30 | 31 | global $globalaaa, $globalbbb; |
32 | + } |
|
31 | 33 | echo 'dobbb'."\n"; |
32 | 34 | $globalaaa.='+bbb'; |
33 | 35 | $globalbbb.='+bbb'; |
@@ -27,8 +27,10 @@ |
||
27 | 27 | * |
28 | 28 | * @return void |
29 | 29 | */ |
30 | - public function do() |
|
30 | + public function do { |
|
31 | + () |
|
31 | 32 | { |
32 | 33 | echo 'doaaa'."\n"; |
33 | 34 | } |
35 | + } |
|
34 | 36 | } |
@@ -25,8 +25,9 @@ discard block |
||
25 | 25 | */ |
26 | 26 | public static function contains($haystack, $needle, $caseSensitive = true) |
27 | 27 | { |
28 | - if (empty($needle)) |
|
29 | - return true; |
|
28 | + if (empty($needle)) { |
|
29 | + return true; |
|
30 | + } |
|
30 | 31 | return $caseSensitive |
31 | 32 | ? strpos($haystack, $needle) !== false |
32 | 33 | : stripos($haystack, $needle) !== false; |
@@ -62,7 +63,9 @@ discard block |
||
62 | 63 | } |
63 | 64 | |
64 | 65 | // @CHANGE LDR |
65 | - if (!is_string($haystack)) return false; |
|
66 | + if (!is_string($haystack)) { |
|
67 | + return false; |
|
68 | + } |
|
66 | 69 | |
67 | 70 | return (substr($haystack, -$length) === $needle); |
68 | 71 | } |
@@ -25,9 +25,13 @@ |
||
25 | 25 | { |
26 | 26 | $copy = array(); |
27 | 27 | foreach ($arr as $key => $value) { |
28 | - if (is_array($value)) $copy[$key] = static::copy($value); |
|
29 | - else if (is_object($value)) $copy[$key] = clone $value; |
|
30 | - else $copy[$key] = $value; |
|
28 | + if (is_array($value)) { |
|
29 | + $copy[$key] = static::copy($value); |
|
30 | + } else if (is_object($value)) { |
|
31 | + $copy[$key] = clone $value; |
|
32 | + } else { |
|
33 | + $copy[$key] = $value; |
|
34 | + } |
|
31 | 35 | } |
32 | 36 | return $copy; |
33 | 37 | } |
@@ -549,7 +549,9 @@ |
||
549 | 549 | case 'string' : |
550 | 550 | case 'password' : //password fields with string |
551 | 551 | case 'search' : //search field with string |
552 | - if (is_bool($input)) $input = $input ? 'true' : 'false'; |
|
552 | + if (is_bool($input)) { |
|
553 | + $input = $input ? 'true' : 'false'; |
|
554 | + } |
|
553 | 555 | if (!is_string($input)) { |
554 | 556 | $error .= '. Expecting alpha numeric value'; |
555 | 557 | break; |
@@ -231,8 +231,9 @@ discard block |
||
231 | 231 | } |
232 | 232 | $fLen = strlen($fullPath); |
233 | 233 | if ($tSlash) { |
234 | - if ($fLen != $tLen && !Text::beginsWith($fullPath, $target . '/')) |
|
235 | - continue; |
|
234 | + if ($fLen != $tLen && !Text::beginsWith($fullPath, $target . '/')) { |
|
235 | + continue; |
|
236 | + } |
|
236 | 237 | } elseif ($fLen > $tLen + 1 && $fullPath[$tLen + 1] != '{' && !Text::beginsWith($fullPath, '{')) { |
237 | 238 | //when mapped to root exclude paths that have static parts |
238 | 239 | //they are listed else where under that static part name |
@@ -244,8 +245,9 @@ discard block |
||
244 | 245 | } |
245 | 246 | foreach (static::$excludedPaths as $exclude) { |
246 | 247 | if (empty($exclude)) { |
247 | - if ($fullPath == $exclude) |
|
248 | - continue 2; |
|
248 | + if ($fullPath == $exclude) { |
|
249 | + continue 2; |
|
250 | + } |
|
249 | 251 | } elseif (Text::beginsWith($fullPath, $exclude)) { |
250 | 252 | continue 2; |
251 | 253 | } |
@@ -283,8 +285,9 @@ discard block |
||
283 | 285 | } |
284 | 286 | $nickname = $this->_nickname($route); |
285 | 287 | $index = static::$placeFormatExtensionBeforeDynamicParts && $pos > 0 ? $pos : 0; |
286 | - if (!empty($parts[$index])) |
|
287 | - $parts[$index] .= $this->formatString; |
|
288 | + if (!empty($parts[$index])) { |
|
289 | + $parts[$index] .= $this->formatString; |
|
290 | + } |
|
288 | 291 | |
289 | 292 | $fullPath = implode('/', $parts); |
290 | 293 | $description = isset( |
@@ -388,8 +391,9 @@ discard block |
||
388 | 391 | if (!$count) { |
389 | 392 | throw new RestException(404); |
390 | 393 | } |
391 | - if (!is_null($r)) |
|
392 | - $r->models = $this->_models; |
|
394 | + if (!is_null($r)) { |
|
395 | + $r->models = $this->_models; |
|
396 | + } |
|
393 | 397 | usort( |
394 | 398 | $r->apis, |
395 | 399 | function ($a, $b) { |
@@ -681,8 +685,9 @@ discard block |
||
681 | 685 | // Create default object that includes parameters to be submitted |
682 | 686 | $defaultObject = new \StdClass(); |
683 | 687 | foreach ($this->_bodyParam['names'] as $name => $values) { |
684 | - if (!$values->required) |
|
685 | - continue; |
|
688 | + if (!$values->required) { |
|
689 | + continue; |
|
690 | + } |
|
686 | 691 | if (class_exists($values->dataType)) { |
687 | 692 | $myClassName = $values->dataType; |
688 | 693 | $defaultObject->$name = new $myClassName(); |
@@ -706,8 +711,9 @@ discard block |
||
706 | 711 | } |
707 | 712 | $properties = array(); |
708 | 713 | if (!$instance) { |
709 | - if (!class_exists($className)) |
|
710 | - return; |
|
714 | + if (!class_exists($className)) { |
|
715 | + return; |
|
716 | + } |
|
711 | 717 | $instance = new $className(); |
712 | 718 | } |
713 | 719 | $data = get_object_vars($instance); |
@@ -828,8 +834,12 @@ discard block |
||
828 | 834 | } |
829 | 835 | return 'array'; |
830 | 836 | } |
831 | - if (is_bool($o)) return 'boolean'; |
|
832 | - if (is_numeric($o)) return is_float($o) ? 'float' : 'int'; |
|
837 | + if (is_bool($o)) { |
|
838 | + return 'boolean'; |
|
839 | + } |
|
840 | + if (is_numeric($o)) { |
|
841 | + return is_float($o) ? 'float' : 'int'; |
|
842 | + } |
|
833 | 843 | return 'string'; |
834 | 844 | } |
835 | 845 | |
@@ -879,8 +889,9 @@ discard block |
||
879 | 889 | */ |
880 | 890 | public function index() |
881 | 891 | { |
882 | - if (!static::$accessControlFunction && Defaults::$accessControlFunction) |
|
883 | - static::$accessControlFunction = Defaults::$accessControlFunction; |
|
892 | + if (!static::$accessControlFunction && Defaults::$accessControlFunction) { |
|
893 | + static::$accessControlFunction = Defaults::$accessControlFunction; |
|
894 | + } |
|
884 | 895 | $version = $this->restler->getRequestedApiVersion(); |
885 | 896 | $allRoutes = Util::nestedValue(Routes::toArray(), "v$version"); |
886 | 897 | $r = $this->_resourceListing(); |
@@ -934,8 +945,9 @@ discard block |
||
934 | 945 | foreach ($allRoutes as $fullPath => $routes) { |
935 | 946 | $path = explode('/', $fullPath); |
936 | 947 | $resource = isset($path[0]) ? $path[0] : ''; |
937 | - if ($resource == 'resources' || Text::endsWith($resource, 'index')) |
|
938 | - continue; |
|
948 | + if ($resource == 'resources' || Text::endsWith($resource, 'index')) { |
|
949 | + continue; |
|
950 | + } |
|
939 | 951 | foreach ($routes as $httpMethod => $route) { |
940 | 952 | if (in_array($httpMethod, static::$excludedHttpMethods)) { |
941 | 953 | continue; |
@@ -946,8 +958,9 @@ discard block |
||
946 | 958 | |
947 | 959 | foreach (static::$excludedPaths as $exclude) { |
948 | 960 | if (empty($exclude)) { |
949 | - if ($fullPath == $exclude) |
|
950 | - continue 2; |
|
961 | + if ($fullPath == $exclude) { |
|
962 | + continue 2; |
|
963 | + } |
|
951 | 964 | } elseif (Text::beginsWith($fullPath, $exclude)) { |
952 | 965 | continue 2; |
953 | 966 | } |
@@ -284,8 +284,9 @@ discard block |
||
284 | 284 | $this->route(); |
285 | 285 | throw $e; |
286 | 286 | } |
287 | - if (Defaults::$useVendorMIMEVersioning) |
|
288 | - $this->responseFormat = $this->negotiateResponseFormat(); |
|
287 | + if (Defaults::$useVendorMIMEVersioning) { |
|
288 | + $this->responseFormat = $this->negotiateResponseFormat(); |
|
289 | + } |
|
289 | 290 | $this->route(); |
290 | 291 | } catch (Exception $e) { |
291 | 292 | $this->negotiate(); |
@@ -401,9 +402,10 @@ discard block |
||
401 | 402 | |
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) { |
@@ -449,17 +454,21 @@ discard block |
||
449 | 454 | |
450 | 455 | $obj = Scope::get($className); |
451 | 456 | |
452 | - if (!$obj instanceof iFormat) |
|
453 | - throw new Exception('Invalid format class; must implement ' . |
|
457 | + if (!$obj instanceof iFormat) { |
|
458 | + throw new Exception('Invalid format class; must implement ' . |
|
454 | 459 | 'iFormat interface'); |
460 | + } |
|
455 | 461 | |
456 | 462 | foreach ($obj->getMIMEMap() as $mime => $extension) { |
457 | - if (!isset($this->formatOverridesMap[$extension])) |
|
458 | - $this->formatOverridesMap[$extension] = $className; |
|
459 | - if (!isset($this->formatOverridesMap[$mime])) |
|
460 | - $this->formatOverridesMap[$mime] = $className; |
|
461 | - if($obj->isWritable()) |
|
462 | - $extensions[".$extension"] = true; |
|
463 | + if (!isset($this->formatOverridesMap[$extension])) { |
|
464 | + $this->formatOverridesMap[$extension] = $className; |
|
465 | + } |
|
466 | + if (!isset($this->formatOverridesMap[$mime])) { |
|
467 | + $this->formatOverridesMap[$mime] = $className; |
|
468 | + } |
|
469 | + if($obj->isWritable()) { |
|
470 | + $extensions[".$extension"] = true; |
|
471 | + } |
|
463 | 472 | } |
464 | 473 | } |
465 | 474 | $this->formatOverridesMap['extensions'] = array_keys($extensions); |
@@ -498,9 +507,10 @@ discard block |
||
498 | 507 | protected function getPath() |
499 | 508 | { |
500 | 509 | // fix SCRIPT_NAME for PHP 5.4 built-in web server |
501 | - if (false === strpos($_SERVER['SCRIPT_NAME'], '.php')) |
|
502 | - $_SERVER['SCRIPT_NAME'] |
|
510 | + if (false === strpos($_SERVER['SCRIPT_NAME'], '.php')) { |
|
511 | + $_SERVER['SCRIPT_NAME'] |
|
503 | 512 | = '/' . substr($_SERVER['SCRIPT_FILENAME'], strlen($_SERVER['DOCUMENT_ROOT']) + 1); |
513 | + } |
|
504 | 514 | |
505 | 515 | list($base, $path) = Util::splitCommonPath( |
506 | 516 | strtok(urldecode($_SERVER['REQUEST_URI']), '?'), //remove query string |
@@ -521,8 +531,9 @@ discard block |
||
521 | 531 | (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') || // Amazon ELB |
522 | 532 | (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on'); |
523 | 533 | $baseUrl = ($https ? 'https://' : 'http://') . $_SERVER['SERVER_NAME']; |
524 | - if (!$https && $port != '80' || $https && $port != '443') |
|
525 | - $baseUrl .= ':' . $port; |
|
534 | + if (!$https && $port != '80' || $https && $port != '443') { |
|
535 | + $baseUrl .= ':' . $port; |
|
536 | + } |
|
526 | 537 | $this->baseUrl = $baseUrl . $base; |
527 | 538 | } elseif (!empty($base) && false === strpos($this->baseUrl, $base)) { |
528 | 539 | $this->baseUrl .= $base; |
@@ -572,9 +583,9 @@ discard block |
||
572 | 583 | if (false !== $pos = strpos($mime, ';')) { |
573 | 584 | $mime = substr($mime, 0, $pos); |
574 | 585 | } |
575 | - if ($mime == UrlEncodedFormat::MIME) |
|
576 | - $format = Scope::get('UrlEncodedFormat'); |
|
577 | - elseif (isset($this->formatMap[$mime])) { |
|
586 | + if ($mime == UrlEncodedFormat::MIME) { |
|
587 | + $format = Scope::get('UrlEncodedFormat'); |
|
588 | + } elseif (isset($this->formatMap[$mime])) { |
|
578 | 589 | $format = Scope::get($this->formatMap[$mime]); |
579 | 590 | $format->setMIME($mime); |
580 | 591 | } 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); |
@@ -1032,8 +1048,9 @@ discard block |
||
1032 | 1048 | } |
1033 | 1049 | $valid = $o->parameters[$index]; |
1034 | 1050 | $o->parameters[$index] = null; |
1035 | - if (empty(Validator::$exceptions)) |
|
1036 | - $o->metadata['param'][$index]['autofocus'] = true; |
|
1051 | + if (empty(Validator::$exceptions)) { |
|
1052 | + $o->metadata['param'][$index]['autofocus'] = true; |
|
1053 | + } |
|
1037 | 1054 | $valid = $validator::validate( |
1038 | 1055 | $valid, $info |
1039 | 1056 | ); |
@@ -1049,8 +1066,9 @@ discard block |
||
1049 | 1066 | $o = & $this->apiMethodInfo; |
1050 | 1067 | $accessLevel = max(Defaults::$apiAccessLevel, |
1051 | 1068 | $o->accessLevel); |
1052 | - if (function_exists('newrelic_name_transaction')) |
|
1053 | - newrelic_name_transaction("{$o->className}/{$o->methodName}"); |
|
1069 | + if (function_exists('newrelic_name_transaction')) { |
|
1070 | + newrelic_name_transaction("{$o->className}/{$o->methodName}"); |
|
1071 | + } |
|
1054 | 1072 | $object = Scope::get($o->className); |
1055 | 1073 | switch ($accessLevel) { |
1056 | 1074 | case 3 : //protected method |
@@ -1094,8 +1112,9 @@ discard block |
||
1094 | 1112 | { |
1095 | 1113 | //only GET method should be cached if allowed by API developer |
1096 | 1114 | $expires = $this->requestMethod == 'GET' ? Defaults::$headerExpires : 0; |
1097 | - if(!is_array(Defaults::$headerCacheControl)) |
|
1098 | - Defaults::$headerCacheControl = array(Defaults::$headerCacheControl); |
|
1115 | + if(!is_array(Defaults::$headerCacheControl)) { |
|
1116 | + Defaults::$headerCacheControl = array(Defaults::$headerCacheControl); |
|
1117 | + } |
|
1099 | 1118 | $cacheControl = Defaults::$headerCacheControl[0]; |
1100 | 1119 | if ($expires > 0) { |
1101 | 1120 | $cacheControl = $this->apiMethodInfo->accessLevel |
@@ -1137,8 +1156,9 @@ discard block |
||
1137 | 1156 | @header('Content-Language: ' . Defaults::$language); |
1138 | 1157 | |
1139 | 1158 | if (isset($this->apiMethodInfo->metadata['header'])) { |
1140 | - foreach ($this->apiMethodInfo->metadata['header'] as $header) |
|
1141 | - @header($header, true); |
|
1159 | + foreach ($this->apiMethodInfo->metadata['header'] as $header) { |
|
1160 | + @header($header, true); |
|
1161 | + } |
|
1142 | 1162 | } |
1143 | 1163 | $code = 200; |
1144 | 1164 | if (!Defaults::$suppressResponseCode) { |
@@ -1202,8 +1222,9 @@ discard block |
||
1202 | 1222 | foreach ($this->errorClasses as $className) { |
1203 | 1223 | if (method_exists($className, $method)) { |
1204 | 1224 | $obj = Scope::get($className); |
1205 | - if ($obj->$method($exception)) |
|
1206 | - $handled = true; |
|
1225 | + if ($obj->$method($exception)) { |
|
1226 | + $handled = true; |
|
1227 | + } |
|
1207 | 1228 | } |
1208 | 1229 | } |
1209 | 1230 | 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'; |
@@ -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 |