@@ -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 |
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | //changes in auto loading |
| 10 | 10 | $classMap = array(); |
| 11 | 11 | //find lowercase php files representing a class/interface |
| 12 | -foreach (explode(PATH_SEPARATOR, get_include_path()) as $path) |
|
| 12 | +foreach (explode(PATH_SEPARATOR, get_include_path()) as $path) { |
|
| 13 | 13 | foreach (new DirectoryIterator($path) as $fileInfo) |
| 14 | 14 | if ($fileInfo->isFile() |
| 15 | 15 | && 'php' === $fileInfo->getExtension() |
@@ -22,6 +22,7 @@ discard block |
||
| 22 | 22 | ) |
| 23 | 23 | ) |
| 24 | 24 | $classMap[$matches[2]] = $fileInfo->getPathname(); |
| 25 | +} |
|
| 25 | 26 | |
| 26 | 27 | AutoLoader::seen($classMap); |
| 27 | 28 | |
@@ -44,8 +44,9 @@ discard block |
||
| 44 | 44 | } |
| 45 | 45 | //$output .= print_r($entry, true) . "\n"; |
| 46 | 46 | $output .= "\nFile: " . $entry['file'] . " (Line: " . $entry['line'] . ")\n"; |
| 47 | - if (isset($entry['class'])) |
|
| 48 | - $output .= $entry['class'] . "::"; |
|
| 47 | + if (isset($entry['class'])) { |
|
| 48 | + $output .= $entry['class'] . "::"; |
|
| 49 | + } |
|
| 49 | 50 | $output .= $entry['function'] |
| 50 | 51 | . "( " . json_encode($entry['args']) . " )\n"; |
| 51 | 52 | } |
@@ -73,8 +74,9 @@ discard block |
||
| 73 | 74 | function render($data, $shadow=true) |
| 74 | 75 | { |
| 75 | 76 | $r = ''; |
| 76 | - if (empty($data)) |
|
| 77 | - return $r; |
|
| 77 | + if (empty($data)) { |
|
| 78 | + return $r; |
|
| 79 | + } |
|
| 78 | 80 | $r .= $shadow ? "<ul class=\"shadow\">\n": "<ul>\n"; |
| 79 | 81 | if (is_array($data)) { |
| 80 | 82 | // field name |
@@ -112,8 +114,9 @@ discard block |
||
| 112 | 114 | $reqHeadersArr = array(); |
| 113 | 115 | $requestHeaders = $_SERVER['REQUEST_METHOD'] . ' ' . $_SERVER['REQUEST_URI'] . ' ' . $_SERVER['SERVER_PROTOCOL'] . PHP_EOL; |
| 114 | 116 | foreach ($reqHeadersArr as $key => $value) { |
| 115 | - if ($key == 'Host') |
|
| 116 | - continue; |
|
| 117 | + if ($key == 'Host') { |
|
| 118 | + continue; |
|
| 119 | + } |
|
| 117 | 120 | $requestHeaders .= "$key: $value" . PHP_EOL; |
| 118 | 121 | } |
| 119 | 122 | // $requestHeaders = $this->encode(apache_request_headers(), FALSE, |
@@ -353,7 +353,9 @@ |
||
| 353 | 353 | */ |
| 354 | 354 | public static function setProperty($name, $value) |
| 355 | 355 | { |
| 356 | - if (!property_exists(__CLASS__, $name)) return false; |
|
| 356 | + if (!property_exists(__CLASS__, $name)) { |
|
| 357 | + return false; |
|
| 358 | + } |
|
| 357 | 359 | if (@is_array(Defaults::$validation[$name])) { |
| 358 | 360 | $info = new ValidationInfo(Defaults::$validation[$name]); |
| 359 | 361 | $value = Validator::validate($value, $info); |
@@ -243,7 +243,9 @@ |
||
| 243 | 243 | public static function getShortName($className) |
| 244 | 244 | { |
| 245 | 245 | // @CHANGE LDR |
| 246 | - if (!is_string($className)) return; |
|
| 246 | + if (!is_string($className)) { |
|
| 247 | + return; |
|
| 248 | + } |
|
| 247 | 249 | |
| 248 | 250 | $className = explode('\\', $className); |
| 249 | 251 | return end($className); |
@@ -55,8 +55,9 @@ discard block |
||
| 55 | 55 | } |
| 56 | 56 | $this->markAsChildren($c); |
| 57 | 57 | $this->children = $c; |
| 58 | - if (static::$initializer) |
|
| 59 | - call_user_func_array(static::$initializer, array(& $this)); |
|
| 58 | + if (static::$initializer) { |
|
| 59 | + call_user_func_array(static::$initializer, array(& $this)); |
|
| 60 | + } |
|
| 60 | 61 | } |
| 61 | 62 | |
| 62 | 63 | /** |
@@ -98,8 +99,9 @@ discard block |
||
| 98 | 99 | $lineBreak = false; |
| 99 | 100 | foreach ($this->children as $key => $child) { |
| 100 | 101 | $prefix = $this->prefix; |
| 101 | - if (!is_null($this->tag)) |
|
| 102 | - $prefix .= $this->indent; |
|
| 102 | + if (!is_null($this->tag)) { |
|
| 103 | + $prefix .= $this->indent; |
|
| 104 | + } |
|
| 103 | 105 | if ($child instanceof $this) { |
| 104 | 106 | $child->prefix = $prefix; |
| 105 | 107 | $child->indent = $this->indent; |
@@ -109,23 +111,27 @@ discard block |
||
| 109 | 111 | $children .= $child; |
| 110 | 112 | } |
| 111 | 113 | } |
| 112 | - if ($lineBreak) |
|
| 113 | - $children .= PHP_EOL . $this->prefix; |
|
| 114 | + if ($lineBreak) { |
|
| 115 | + $children .= PHP_EOL . $this->prefix; |
|
| 116 | + } |
|
| 114 | 117 | } else { |
| 115 | 118 | $children = implode('', $this->children); |
| 116 | 119 | } |
| 117 | - if (is_null($this->tag)) |
|
| 118 | - return $children; |
|
| 120 | + if (is_null($this->tag)) { |
|
| 121 | + return $children; |
|
| 122 | + } |
|
| 119 | 123 | $attributes = ''; |
| 120 | - foreach ($this->attributes as $attribute => &$value) |
|
| 121 | - $attributes .= " $attribute=\"$value\""; |
|
| 124 | + foreach ($this->attributes as $attribute => &$value) { |
|
| 125 | + $attributes .= " $attribute=\"$value\""; |
|
| 126 | + } |
|
| 122 | 127 | |
| 123 | - if (count($this->children)) |
|
| 124 | - return static::$humanReadable |
|
| 128 | + if (count($this->children)) { |
|
| 129 | + return static::$humanReadable |
|
| 125 | 130 | ? "$this->prefix<{$this->tag}{$attributes}>" |
| 126 | 131 | . "$children" |
| 127 | 132 | . "</{$this->tag}>" |
| 128 | 133 | : "<{$this->tag}{$attributes}>$children</{$this->tag}>"; |
| 134 | + } |
|
| 129 | 135 | |
| 130 | 136 | return "$this->prefix<{$this->tag}{$attributes}/>"; |
| 131 | 137 | } |
@@ -163,10 +169,12 @@ discard block |
||
| 163 | 169 | |
| 164 | 170 | public function __get($name) |
| 165 | 171 | { |
| 166 | - if ('parent' == $name) |
|
| 167 | - return $this->_parent; |
|
| 168 | - if (isset($this->attributes[$name])) |
|
| 169 | - return $this->attributes[$name]; |
|
| 172 | + if ('parent' == $name) { |
|
| 173 | + return $this->_parent; |
|
| 174 | + } |
|
| 175 | + if (isset($this->attributes[$name])) { |
|
| 176 | + return $this->attributes[$name]; |
|
| 177 | + } |
|
| 170 | 178 | return; |
| 171 | 179 | } |
| 172 | 180 | |
@@ -265,8 +273,9 @@ discard block |
||
| 265 | 273 | private function markAsChildren(& $children) |
| 266 | 274 | { |
| 267 | 275 | foreach ($children as $i => $child) { |
| 268 | - if (is_string($child)) |
|
| 269 | - continue; |
|
| 276 | + if (is_string($child)) { |
|
| 277 | + continue; |
|
| 278 | + } |
|
| 270 | 279 | if (!is_object($child)) { |
| 271 | 280 | unset($children[$i]); |
| 272 | 281 | continue; |