@@ -425,7 +425,7 @@ |
||
| 425 | 425 | */ |
| 426 | 426 | public function collectData($attributes = null, $options = []) |
| 427 | 427 | { |
| 428 | - $data = []; |
|
| 428 | + $data = []; |
|
| 429 | 429 | foreach ($this->models as $model) { |
| 430 | 430 | /* @var $model ActiveRecord */ |
| 431 | 431 | $key = $model->getPrimaryKey(); |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | 'config' => [ |
| 48 | 48 | 'base_uri' => $this->site, |
| 49 | 49 | ], |
| 50 | - 'errorChecker' => function ($res) { |
|
| 50 | + 'errorChecker' => function($res) { |
|
| 51 | 51 | return null; |
| 52 | 52 | }, |
| 53 | 53 | ]); |
@@ -61,15 +61,15 @@ discard block |
||
| 61 | 61 | { |
| 62 | 62 | $result = $this->object->get($this->url, [], $this->body, false); |
| 63 | 63 | $this->assertSame($this->result, $result); |
| 64 | - $this->assertSame('request', $this->mock->name); |
|
| 65 | - $this->assertSame('GET', $this->mock->args[0]); |
|
| 66 | - $this->assertSame($this->url, $this->mock->args[1]); |
|
| 64 | + $this->assertSame('request', $this->mock->name); |
|
| 65 | + $this->assertSame('GET', $this->mock->args[0]); |
|
| 66 | + $this->assertSame($this->url, $this->mock->args[1]); |
|
| 67 | 67 | $this->assertSame($this->body, $this->mock->args[2]['form_params']); |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | public function testErrorChecker() |
| 71 | 71 | { |
| 72 | - $this->object->setErrorChecker(function ($res) { return $res; }); |
|
| 72 | + $this->object->setErrorChecker(function($res) { return $res; }); |
|
| 73 | 73 | $this->setExpectedException('hiqdev\hiart\ErrorResponseException', $this->result); |
| 74 | 74 | $this->object->get($this->url, [], $this->body, false); |
| 75 | 75 | } |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | public static function index() |
| 202 | 202 | { |
| 203 | 203 | // return Inflector::pluralize(Inflector::camel2id(StringHelper::basename(get_called_class()), '-')); |
| 204 | - return mb_strtolower(StringHelper::basename(get_called_class()) . 's'); |
|
| 204 | + return mb_strtolower(StringHelper::basename(get_called_class()).'s'); |
|
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | public static function joinIndex() |
@@ -352,7 +352,7 @@ discard block |
||
| 352 | 352 | */ |
| 353 | 353 | public static function perform($action, $options = [], $bulk = false) |
| 354 | 354 | { |
| 355 | - $action = ($bulk === true ? static::index() : static::type()) . $action; |
|
| 355 | + $action = ($bulk === true ? static::index() : static::type()).$action; |
|
| 356 | 356 | $result = static::getDb()->createCommand()->perform($action, $options); |
| 357 | 357 | |
| 358 | 358 | return $result; |
@@ -399,7 +399,7 @@ discard block |
||
| 399 | 399 | if (is_array($result)) { |
| 400 | 400 | return implode('', $result); |
| 401 | 401 | } else { |
| 402 | - return static::type() . ($bulk ? 's' : '') . $result; |
|
| 402 | + return static::type().($bulk ? 's' : '').$result; |
|
| 403 | 403 | } |
| 404 | 404 | } |
| 405 | 405 | |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | */ |
| 47 | 47 | public function search($options = []) |
| 48 | 48 | { |
| 49 | - $url = $this->index . Inflector::id2camel(ArrayHelper::remove($options, 'scenario', 'search')); |
|
| 49 | + $url = $this->index.Inflector::id2camel(ArrayHelper::remove($options, 'scenario', 'search')); |
|
| 50 | 50 | $query = $this->queryParts; |
| 51 | 51 | $options = array_merge($query, $options); |
| 52 | 52 | |
@@ -58,15 +58,15 @@ discard block |
||
| 58 | 58 | $options = array_merge($data, $options); |
| 59 | 59 | |
| 60 | 60 | if ($id !== null) { |
| 61 | - return $this->db->put($action . 'Update', array_merge($options, ['id' => $id])); |
|
| 61 | + return $this->db->put($action.'Update', array_merge($options, ['id' => $id])); |
|
| 62 | 62 | } else { |
| 63 | - return $this->db->post($action . 'Create', $options); |
|
| 63 | + return $this->db->post($action.'Create', $options); |
|
| 64 | 64 | } |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | public function get($modelName, $primaryKey, $options) |
| 68 | 68 | { |
| 69 | - return $this->db->post($modelName . 'GetInfo', ArrayHelper::merge(['id' => $primaryKey], $options)); |
|
| 69 | + return $this->db->post($modelName.'GetInfo', ArrayHelper::merge(['id' => $primaryKey], $options)); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | public function mget($index, $type, $ids, $options = []) |
@@ -83,14 +83,14 @@ discard block |
||
| 83 | 83 | |
| 84 | 84 | public function delete($index, $id, $options = []) |
| 85 | 85 | { |
| 86 | - return $this->db->delete($index . 'Delete', array_merge($options, ['id' => $id])); |
|
| 86 | + return $this->db->delete($index.'Delete', array_merge($options, ['id' => $id])); |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | public function update($index, $id, $data, $options = []) |
| 90 | 90 | { |
| 91 | 91 | $options['id'] = $id; |
| 92 | 92 | |
| 93 | - return $this->db->put($index . 'Update', array_merge($data, $options)); |
|
| 93 | + return $this->db->put($index.'Update', array_merge($data, $options)); |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | /** |
@@ -264,7 +264,7 @@ discard block |
||
| 264 | 264 | $url = $path; |
| 265 | 265 | $query = array_merge($this->getAuth(), $query); |
| 266 | 266 | if (!empty($query)) { |
| 267 | - $url .= (strpos($url, '?') === false ? '?' : '&') . http_build_query($query); |
|
| 267 | + $url .= (strpos($url, '?') === false ? '?' : '&').http_build_query($query); |
|
| 268 | 268 | } |
| 269 | 269 | |
| 270 | 270 | return $url; |
@@ -283,7 +283,7 @@ discard block |
||
| 283 | 283 | protected function handleRequest($method, $url, $body = null, $raw = false) |
| 284 | 284 | { |
| 285 | 285 | $method = strtoupper($method); |
| 286 | - $profile = $method . ' ' . $url . '#' . (is_array($body) ? http_build_query($body) : $body); |
|
| 286 | + $profile = $method.' '.$url.'#'.(is_array($body) ? http_build_query($body) : $body); |
|
| 287 | 287 | $options = [(is_array($body) ? 'form_params' : 'body') => $body]; |
| 288 | 288 | Yii::beginProfile($profile, __METHOD__); |
| 289 | 289 | $response = $this->getHandler()->request($method, $url, $options); |
@@ -11,5 +11,5 @@ |
||
| 11 | 11 | |
| 12 | 12 | error_reporting(E_ALL & ~E_NOTICE); |
| 13 | 13 | |
| 14 | -require_once __DIR__ . '/../vendor/autoload.php'; |
|
| 15 | -require_once __DIR__ . '/../vendor/yiisoft/yii2/Yii.php'; |
|
| 14 | +require_once __DIR__.'/../vendor/autoload.php'; |
|
| 15 | +require_once __DIR__.'/../vendor/yiisoft/yii2/Yii.php'; |
|
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | public function buildOrderBy($orderBy, &$parts) |
| 80 | 80 | { |
| 81 | 81 | if (!empty($orderBy)) { |
| 82 | - $parts['orderby'] = key($orderBy) . $this->_sort[reset($orderBy)]; |
|
| 82 | + $parts['orderby'] = key($orderBy).$this->_sort[reset($orderBy)]; |
|
| 83 | 83 | } |
| 84 | 84 | } |
| 85 | 85 | |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | |
| 121 | 121 | return $this->$method($operator, $condition); |
| 122 | 122 | } else { |
| 123 | - throw new InvalidParamException('Found unknown operator in query: ' . $operator); |
|
| 123 | + throw new InvalidParamException('Found unknown operator in query: '.$operator); |
|
| 124 | 124 | } |
| 125 | 125 | } else { |
| 126 | 126 | return $this->buildHashCondition($condition); |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | foreach ($condition as $attribute => $value) { |
| 134 | 134 | if (is_array($value)) { // IN condition |
| 135 | 135 | // $parts[] = [$attribute.'s' => join(',',$value)]; |
| 136 | - $parts[$attribute . 's'] = implode(',', $value); |
|
| 136 | + $parts[$attribute.'s'] = implode(',', $value); |
|
| 137 | 137 | } else { |
| 138 | 138 | $parts[$attribute] = $value; |
| 139 | 139 | } |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | |
| 145 | 145 | private function buildLikeCondition($operator, $operands) |
| 146 | 146 | { |
| 147 | - return [$operands[0] . '_like' => $operands[1]]; |
|
| 147 | + return [$operands[0].'_like' => $operands[1]]; |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | private function buildCompareCondition($operator, $operands) |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | throw new InvalidParamException("Operator '$operator' requires three operands."); |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | - return [$operands[0] . '_' . $operator => $operands[1]]; |
|
| 156 | + return [$operands[0].'_'.$operator => $operands[1]]; |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | private function buildAndCondition($operator, $operands) |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | } |
| 200 | 200 | } |
| 201 | 201 | |
| 202 | - return [$column . '_in' => $values]; |
|
| 202 | + return [$column.'_in' => $values]; |
|
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | private function buildEqCondition($operator, $operands) |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | foreach ($timings as $timing) { |
| 55 | 55 | $queryTime += $timing[3]; |
| 56 | 56 | } |
| 57 | - $queryTime = number_format($queryTime * 1000) . ' ms'; |
|
| 57 | + $queryTime = number_format($queryTime * 1000).' ms'; |
|
| 58 | 58 | $url = $this->getUrl(); |
| 59 | 59 | $output = <<<HTML |
| 60 | 60 | <div class="yii-debug-toolbar__block"> |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | try { |
| 84 | 84 | $component = \Yii::$app->get('hiart'); |
| 85 | 85 | $apiUrl = (StringHelper::endsWith($component->config['base_uri'], |
| 86 | - '/')) ? $component->config['base_uri'] : $component->config['base_uri'] . '/'; |
|
| 86 | + '/')) ? $component->config['base_uri'] : $component->config['base_uri'].'/'; |
|
| 87 | 87 | } catch (\yii\base\InvalidConfigException $e) { |
| 88 | 88 | // Pass |
| 89 | 89 | } |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | if (!empty($traces)) { |
| 103 | 103 | $traceString .= Html::ul($traces, [ |
| 104 | 104 | 'class' => 'trace', |
| 105 | - 'item' => function ($trace) { |
|
| 105 | + 'item' => function($trace) { |
|
| 106 | 106 | return "<li>{$trace['file']}({$trace['line']})</li>"; |
| 107 | 107 | }, |
| 108 | 108 | ]); |
@@ -111,15 +111,15 @@ discard block |
||
| 111 | 111 | $runLink = Html::a('run query', $ajaxUrl, [ |
| 112 | 112 | 'class' => 'hiart-link', |
| 113 | 113 | 'data' => ['id' => $i], |
| 114 | - ]) . '<br/>'; |
|
| 114 | + ]).'<br/>'; |
|
| 115 | 115 | $path = preg_replace('/^[A-Z]+\s+/', '', $url); |
| 116 | 116 | if (strpos($path, '?') !== false) { |
| 117 | - $newTabUrl = $apiUrl . rtrim($path, '&') . '&' . $body; |
|
| 117 | + $newTabUrl = $apiUrl.rtrim($path, '&').'&'.$body; |
|
| 118 | 118 | } else { |
| 119 | - $newTabUrl = $apiUrl . $path . '?' . $body; |
|
| 119 | + $newTabUrl = $apiUrl.$path.'?'.$body; |
|
| 120 | 120 | } |
| 121 | - $newTabLink = Html::a('to new tab', $newTabUrl, ['target' => '_blank']) . '<br/>'; |
|
| 122 | - $url_encoded = Html::encode((isset($apiUrl)) ? str_replace(' ', ' ' . $apiUrl, $url) : $url); |
|
| 121 | + $newTabLink = Html::a('to new tab', $newTabUrl, ['target' => '_blank']).'<br/>'; |
|
| 122 | + $url_encoded = Html::encode((isset($apiUrl)) ? str_replace(' ', ' '.$apiUrl, $url) : $url); |
|
| 123 | 123 | $body_encoded = Html::encode($body); |
| 124 | 124 | $rows[] = <<<HTML |
| 125 | 125 | <tr> |
@@ -11,7 +11,6 @@ |
||
| 11 | 11 | |
| 12 | 12 | namespace hiqdev\hiart; |
| 13 | 13 | |
| 14 | -use yii\base\NotSupportedException; |
|
| 15 | 14 | use yii\db\ActiveQueryInterface; |
| 16 | 15 | use yii\db\ActiveQueryTrait; |
| 17 | 16 | use yii\db\ActiveRelationTrait; |