@@ -160,7 +160,7 @@ |
||
160 | 160 | } |
161 | 161 | |
162 | 162 | /** |
163 | - * @param $field |
|
163 | + * @param string $field |
|
164 | 164 | * @param bool $required |
165 | 165 | * @return Field |
166 | 166 | */ |
@@ -35,19 +35,19 @@ discard block |
||
35 | 35 | $behaviors = $tableMap->getBehaviors(); |
36 | 36 | foreach ($map::getFieldNames() as $field) { |
37 | 37 | $fDto = self::parseFormField($domain, $tableMap, $field, $behaviors); |
38 | - if(null !== $fDto) { |
|
38 | + if (null !== $fDto) { |
|
39 | 39 | $form->addField($fDto); |
40 | 40 | } |
41 | 41 | } |
42 | 42 | |
43 | - if(array_key_exists('i18n', $behaviors)) { |
|
44 | - $relateI18n = $tableMap->getRelation($tableMap->getPhpName() . 'I18n'); |
|
45 | - if(null !== $relateI18n) { |
|
43 | + if (array_key_exists('i18n', $behaviors)) { |
|
44 | + $relateI18n = $tableMap->getRelation($tableMap->getPhpName().'I18n'); |
|
45 | + if (null !== $relateI18n) { |
|
46 | 46 | $i18NTableMap = $relateI18n->getLocalTable(); |
47 | - foreach($i18NTableMap->getColumns() as $columnMap) { |
|
48 | - if(!$form->fieldExists($columnMap->getPhpName())) { |
|
47 | + foreach ($i18NTableMap->getColumns() as $columnMap) { |
|
48 | + if (!$form->fieldExists($columnMap->getPhpName())) { |
|
49 | 49 | $fDto = self::parseFormField($domain, $i18NTableMap, $columnMap->getPhpName(), $i18NTableMap->getBehaviors()); |
50 | - if(null !== $fDto) { |
|
50 | + if (null !== $fDto) { |
|
51 | 51 | $fDto->pk = false; |
52 | 52 | $form->addField($fDto); |
53 | 53 | } |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | $fDto->entity = $relatedModel; |
77 | 77 | $relatedField = $foreignTable->getColumn($mappedColumn->getRelatedColumnName()); |
78 | 78 | $fDto->relatedField = $relatedField->getPhpName(); |
79 | - $fDto->url = Router::getInstance()->getRoute(strtolower($domain) . '-api-' . $relatedModel); |
|
79 | + $fDto->url = Router::getInstance()->getRoute(strtolower($domain).'-api-'.$relatedModel); |
|
80 | 80 | return $fDto; |
81 | 81 | } |
82 | 82 | |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | $column = null; |
185 | 185 | try { |
186 | 186 | $column = $tableMap->getColumnByPhpName($field); |
187 | - } catch (\Exception $e) { |
|
187 | + }catch (\Exception $e) { |
|
188 | 188 | Logger::log($e->getMessage(), LOG_WARNING); |
189 | 189 | //foreach($tableMap->getRelations() as $relation) { |
190 | 190 | // $column = self::checkFieldExists($relation->getLocalTable(), $field); |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | * @param ModelCriteria $query |
199 | 199 | * @param mixed $value |
200 | 200 | */ |
201 | - private static function addQueryFilter(ColumnMap $column, ModelCriteria &$query, $value = null) |
|
201 | + private static function addQueryFilter(ColumnMap $column, ModelCriteria & $query, $value = null) |
|
202 | 202 | { |
203 | 203 | $tableField = $column->getFullyQualifiedName(); |
204 | 204 | if (preg_match('/^\[/', $value) && preg_match('/\]$/', $value)) { |
@@ -206,11 +206,11 @@ discard block |
||
206 | 206 | } elseif (preg_match('/^(\'|\")(.*)(\'|\")$/', $value)) { |
207 | 207 | $text = preg_replace('/(\'|\")/', '', $value); |
208 | 208 | $text = preg_replace('/\ /', '%', $text); |
209 | - $query->add($tableField, '%' . $text . '%', Criteria::LIKE); |
|
210 | - } else { |
|
211 | - if(null !== $column->getValueSet()) { |
|
209 | + $query->add($tableField, '%'.$text.'%', Criteria::LIKE); |
|
210 | + }else { |
|
211 | + if (null !== $column->getValueSet()) { |
|
212 | 212 | $valueSet = $column->getValueSet(); |
213 | - if(in_array($value, $valueSet)) { |
|
213 | + if (in_array($value, $valueSet)) { |
|
214 | 214 | $value = array_search($value, $valueSet); |
215 | 215 | } |
216 | 216 | } |
@@ -224,35 +224,35 @@ discard block |
||
224 | 224 | * @param array $extraColumns |
225 | 225 | * @param mixed $value |
226 | 226 | */ |
227 | - public static function composerComboField(TableMap $tableMap, ModelCriteria &$query, array $extraColumns = [], $value = null) |
|
227 | + public static function composerComboField(TableMap $tableMap, ModelCriteria & $query, array $extraColumns = [], $value = null) |
|
228 | 228 | { |
229 | 229 | $exp = 'CONCAT('; |
230 | 230 | $sep = ''; |
231 | 231 | foreach ($tableMap->getColumns() as $column) { |
232 | 232 | if ($column->isText()) { |
233 | - $exp .= $sep . 'IFNULL(' . $column->getFullyQualifiedName() . ',"")'; |
|
233 | + $exp .= $sep.'IFNULL('.$column->getFullyQualifiedName().',"")'; |
|
234 | 234 | $sep = ', " ", '; |
235 | 235 | } |
236 | 236 | } |
237 | - foreach($tableMap->getRelations() as $relation) { |
|
238 | - if(preg_match('/I18n$/i', $relation->getName())) { |
|
237 | + foreach ($tableMap->getRelations() as $relation) { |
|
238 | + if (preg_match('/I18n$/i', $relation->getName())) { |
|
239 | 239 | $localeTableMap = $relation->getLocalTable(); |
240 | 240 | foreach ($localeTableMap->getColumns() as $column) { |
241 | 241 | if ($column->isText()) { |
242 | - $exp .= $sep . 'IFNULL(' . $column->getFullyQualifiedName() . ',"")'; |
|
242 | + $exp .= $sep.'IFNULL('.$column->getFullyQualifiedName().',"")'; |
|
243 | 243 | $sep = ', " ", '; |
244 | 244 | } |
245 | 245 | } |
246 | 246 | } |
247 | 247 | } |
248 | 248 | foreach ($extraColumns as $extra => $name) { |
249 | - $exp .= $sep . $extra; |
|
249 | + $exp .= $sep.$extra; |
|
250 | 250 | $sep = ', " ", '; |
251 | 251 | } |
252 | 252 | $exp .= ")"; |
253 | 253 | $text = preg_replace('/(\'|\")/', '', $value); |
254 | 254 | $text = preg_replace('/\ /', '%', $text); |
255 | - $query->where($exp . Criteria::LIKE . '"%' . $text . '%"'); |
|
255 | + $query->where($exp.Criteria::LIKE.'"%'.$text.'%"'); |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | /** |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | * @param string $field |
263 | 263 | * @param mixed $value |
264 | 264 | */ |
265 | - public static function addModelField(TableMap $tableMap, ModelCriteria &$query, $field, $value = null) |
|
265 | + public static function addModelField(TableMap $tableMap, ModelCriteria & $query, $field, $value = null) |
|
266 | 266 | { |
267 | 267 | if ($column = self::checkFieldExists($tableMap, $field)) { |
268 | 268 | self::addQueryFilter($column, $query, $value); |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | */ |
278 | 278 | public static function extractQuery($modelNameNamespace, ConnectionInterface $con = null) |
279 | 279 | { |
280 | - $queryReflector = new \ReflectionClass($modelNameNamespace . "Query"); |
|
280 | + $queryReflector = new \ReflectionClass($modelNameNamespace."Query"); |
|
281 | 281 | /** @var \Propel\Runtime\ActiveQuery\ModelCriteria $query */ |
282 | 282 | $query = $queryReflector->getMethod('create')->invoke($con); |
283 | 283 | |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | } elseif ($mappedColumn->isText()) { |
307 | 307 | if ($mappedColumn->getSize() > 100) { |
308 | 308 | $fDto = self::createField($field, Field::TEXTAREA_TYPE, $required); |
309 | - } else { |
|
309 | + }else { |
|
310 | 310 | $fDto = self::generateStringField($field, $required); |
311 | 311 | } |
312 | 312 | } elseif ($mappedColumn->getType() === PropelTypes::BOOLEAN) { |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | */ |
344 | 344 | public static function extractPrimaryKeyColumnName(TableMap $tableMap) { |
345 | 345 | $modelPk = null; |
346 | - foreach($tableMap->getPrimaryKeys() as $pk) { |
|
346 | + foreach ($tableMap->getPrimaryKeys() as $pk) { |
|
347 | 347 | $modelPk = $pk; |
348 | 348 | break; |
349 | 349 | } |
@@ -352,15 +352,15 @@ discard block |
||
352 | 352 | |
353 | 353 | private static function mapResult(ActiveRecordInterface $model, array $data = []) { |
354 | 354 | $result = []; |
355 | - foreach($data as $key => $value) { |
|
355 | + foreach ($data as $key => $value) { |
|
356 | 356 | try { |
357 | 357 | $realValue = $model->getByName($key); |
358 | - } catch(\Exception $e) { |
|
358 | + }catch (\Exception $e) { |
|
359 | 359 | $realValue = $value; |
360 | 360 | } |
361 | - if(Api::API_MODEL_KEY_FIELD === $key) { |
|
361 | + if (Api::API_MODEL_KEY_FIELD === $key) { |
|
362 | 362 | $result[$key] = (integer)$realValue; |
363 | - } else { |
|
363 | + }else { |
|
364 | 364 | $result[$key] = $realValue; |
365 | 365 | } |
366 | 366 | } |
@@ -376,7 +376,7 @@ discard block |
||
376 | 376 | /** @var ActiveRecordInterface $obj */ |
377 | 377 | $obj = $formatter->getAllObjectsFromRow($data); |
378 | 378 | $result = self::mapResult($obj, $data); |
379 | - if(!preg_match('/' . $modelPk->getPhpName() . '/i', $query[Api::API_FIELDS_RESULT_FIELD])) { |
|
379 | + if (!preg_match('/'.$modelPk->getPhpName().'/i', $query[Api::API_FIELDS_RESULT_FIELD])) { |
|
380 | 380 | unset($result[$modelPk->getPhpName()]); |
381 | 381 | } |
382 | 382 | return $result; |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | |
40 | 40 | /** |
41 | 41 | * Method that extract the Api name |
42 | - * @return mixed |
|
42 | + * @return string |
|
43 | 43 | */ |
44 | 44 | public function getApi() |
45 | 45 | { |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | |
51 | 51 | /** |
52 | 52 | * Method that extract the Domain name |
53 | - * @return mixed |
|
53 | + * @return string |
|
54 | 54 | */ |
55 | 55 | public function getDomain() |
56 | 56 | { |
@@ -114,7 +114,9 @@ |
||
114 | 114 | try { |
115 | 115 | $query->filterBy($phpName, $pks[$i]); |
116 | 116 | $i++; |
117 | - if($i >= count($pks)) break; |
|
117 | + if($i >= count($pks)) { |
|
118 | + break; |
|
119 | + } |
|
118 | 120 | } catch(\Exception $e) { |
119 | 121 | Logger::log($e->getMessage(), LOG_DEBUG); |
120 | 122 | } |
@@ -95,14 +95,14 @@ discard block |
||
95 | 95 | */ |
96 | 96 | protected function hydrateBulkRequest() { |
97 | 97 | $class = new \ReflectionClass($this->getModelNamespace()); |
98 | - foreach($this->data as $item) { |
|
99 | - if(count($this->list) < Config::getParam('api.block.limit', 1000)) { |
|
98 | + foreach ($this->data as $item) { |
|
99 | + if (count($this->list) < Config::getParam('api.block.limit', 1000)) { |
|
100 | 100 | /** @var ActiveRecordInterface $model */ |
101 | 101 | $model = $class->newInstance(); |
102 | 102 | $this->hydrateModelFromRequest($model, $item); |
103 | 103 | $this->list[] = $model; |
104 | - } else { |
|
105 | - Logger::log(_('Max items per bulk insert raised'), LOG_WARNING, count($this->data) . _('items')); |
|
104 | + }else { |
|
105 | + Logger::log(_('Max items per bulk insert raised'), LOG_WARNING, count($this->data)._('items')); |
|
106 | 106 | } |
107 | 107 | } |
108 | 108 | } |
@@ -112,12 +112,12 @@ discard block |
||
112 | 112 | */ |
113 | 113 | protected function saveBulk() { |
114 | 114 | $tablemap = $this->getTableMap(); |
115 | - foreach($this->list as &$model) { |
|
115 | + foreach ($this->list as &$model) { |
|
116 | 116 | $con = Propel::getWriteConnection($tablemap::DATABASE_NAME); |
117 | 117 | try { |
118 | 118 | $model->save($con); |
119 | 119 | $con->commit(); |
120 | - } catch(\Exception $e) { |
|
120 | + }catch (\Exception $e) { |
|
121 | 121 | Logger::log($e->getMessage(), LOG_ERR, $model->toArray()); |
122 | 122 | $con->rollBack(); |
123 | 123 | } |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | protected function exportList() { |
131 | 131 | $list = []; |
132 | 132 | /** @var ActiveRecordInterface $item */ |
133 | - foreach($this->list as $item) { |
|
133 | + foreach ($this->list as $item) { |
|
134 | 134 | $list[] = $item->toArray(); |
135 | 135 | } |
136 | 136 | return $list; |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | * |
142 | 142 | * @param ModelCriteria $query |
143 | 143 | */ |
144 | - protected function joinTables(ModelCriteria &$query) |
|
144 | + protected function joinTables(ModelCriteria & $query) |
|
145 | 145 | { |
146 | 146 | //TODO for specific implementations |
147 | 147 | } |
@@ -154,16 +154,16 @@ discard block |
||
154 | 154 | */ |
155 | 155 | protected function findPk(ModelCriteria $query, $pk) { |
156 | 156 | $pks = explode(Api::API_PK_SEPARATOR, urldecode($pk)); |
157 | - if(count($pks) == 1 && !empty($pks[0])) { |
|
157 | + if (count($pks) == 1 && !empty($pks[0])) { |
|
158 | 158 | $model = $query->findPk($pks[0], $this->con); |
159 | - } else { |
|
159 | + }else { |
|
160 | 160 | $i = 0; |
161 | - foreach($this->getPkDbName() as $key => $phpName) { |
|
161 | + foreach ($this->getPkDbName() as $key => $phpName) { |
|
162 | 162 | try { |
163 | 163 | $query->filterBy($phpName, $pks[$i]); |
164 | 164 | $i++; |
165 | - if($i >= count($pks)) break; |
|
166 | - } catch(\Exception $e) { |
|
165 | + if ($i >= count($pks)) break; |
|
166 | + }catch (\Exception $e) { |
|
167 | 167 | Logger::log($e->getMessage(), LOG_DEBUG); |
168 | 168 | } |
169 | 169 | } |
@@ -193,8 +193,8 @@ discard block |
||
193 | 193 | try { |
194 | 194 | $query = $this->prepareQuery(); |
195 | 195 | $this->model = $this->findPk($query, $pk); |
196 | - } catch (\Exception $e) { |
|
197 | - Logger::log(get_class($this) . ': ' . $e->getMessage(), LOG_ERR); |
|
196 | + }catch (\Exception $e) { |
|
197 | + Logger::log(get_class($this).': '.$e->getMessage(), LOG_ERR); |
|
198 | 198 | } |
199 | 199 | } |
200 | 200 | |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | /** |
216 | 216 | * @param ModelCriteria $query |
217 | 217 | */ |
218 | - protected function checkReturnFields(ModelCriteria &$query) |
|
218 | + protected function checkReturnFields(ModelCriteria & $query) |
|
219 | 219 | { |
220 | 220 | $returnFields = Request::getInstance()->getQuery(Api::API_FIELDS_RESULT_FIELD); |
221 | 221 | if (null !== $returnFields) { |
@@ -48,7 +48,7 @@ |
||
48 | 48 | return ($aOrder < $bOrder) ? -1 : 1; |
49 | 49 | }); |
50 | 50 | $array['actions'] = []; |
51 | - foreach($this->actions as $action) { |
|
51 | + foreach ($this->actions as $action) { |
|
52 | 52 | $array['actions'][] = $action->__toArray(); |
53 | 53 | } |
54 | 54 | return $array; |
@@ -39,8 +39,8 @@ |
||
39 | 39 | "domain" => $this->getDomain(), |
40 | 40 | "listLabel" => Api::API_LIST_NAME_FIELD, |
41 | 41 | 'modelId' => Api::API_MODEL_KEY_FIELD, |
42 | - 'formUrl' => preg_replace('/\/\{(.*)\}$/i', '', $this->getRoute(strtolower('admin-api-form-' . $this->getDomain() . '-' . $this->getApi()), TRUE)), |
|
43 | - "url" => preg_replace('/\/\{(.*)\}$/i', '', $this->getRoute(strtolower($this->getDomain() . '-' . 'api-' . $this->getApi() . "-pk"), TRUE)), |
|
42 | + 'formUrl' => preg_replace('/\/\{(.*)\}$/i', '', $this->getRoute(strtolower('admin-api-form-'.$this->getDomain().'-'.$this->getApi()), TRUE)), |
|
43 | + "url" => preg_replace('/\/\{(.*)\}$/i', '', $this->getRoute(strtolower($this->getDomain().'-'.'api-'.$this->getApi()."-pk"), TRUE)), |
|
44 | 44 | ), [], ''); |
45 | 45 | } |
46 | 46 |
@@ -6,7 +6,6 @@ |
||
6 | 6 | use Propel\Runtime\Propel; |
7 | 7 | use PSFS\base\config\Config; |
8 | 8 | use PSFS\base\Logger; |
9 | -use PSFS\base\types\traits\DebugTrait; |
|
10 | 9 | |
11 | 10 | /** |
12 | 11 | * Trait ConnectionTrait |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | { |
33 | 33 | $this->con = Propel::getConnection($tableMap::DATABASE_NAME); |
34 | 34 | $this->con->beginTransaction(); |
35 | - if(method_exists($this->con, 'useDebug')) { |
|
35 | + if (method_exists($this->con, 'useDebug')) { |
|
36 | 36 | Logger::log('Enabling debug queries mode', LOG_INFO); |
37 | 37 | $this->con->useDebug(Config::getParam('debug')); |
38 | 38 | } |
@@ -45,12 +45,12 @@ discard block |
||
45 | 45 | */ |
46 | 46 | protected function closeTransaction($status) |
47 | 47 | { |
48 | - if(null !== $this->con) { |
|
48 | + if (null !== $this->con) { |
|
49 | 49 | $this->traceDebugQuery(); |
50 | 50 | if (null !== $this->con && $this->con->inTransaction()) { |
51 | 51 | if ($status === 200) { |
52 | 52 | $this->con->commit(); |
53 | - } else { |
|
53 | + }else { |
|
54 | 54 | $this->con->rollBack(); |
55 | 55 | } |
56 | 56 | } |
@@ -72,13 +72,13 @@ discard block |
||
72 | 72 | * Checks if the connection has a transaction initialized |
73 | 73 | */ |
74 | 74 | protected function checkTransaction() { |
75 | - if(null !== $this->con && !$this->con->inTransaction()) { |
|
75 | + if (null !== $this->con && !$this->con->inTransaction()) { |
|
76 | 76 | $this->con->beginTransaction(); |
77 | 77 | } |
78 | - if(null !== $this->con && $this->con->inTransaction()) { |
|
78 | + if (null !== $this->con && $this->con->inTransaction()) { |
|
79 | 79 | $this->items++; |
80 | 80 | } |
81 | - if($this->items >= Config::getParam('api.block.limit', 1000)) { |
|
81 | + if ($this->items >= Config::getParam('api.block.limit', 1000)) { |
|
82 | 82 | $this->con->commit(); |
83 | 83 | $this->items = 0; |
84 | 84 | } |
@@ -42,7 +42,7 @@ |
||
42 | 42 | $this->success = $result; |
43 | 43 | $this->total = $total ?: count($data); |
44 | 44 | $this->pages = $pages; |
45 | - if(null !== $message) { |
|
45 | + if (null !== $message) { |
|
46 | 46 | $this->message = $message; |
47 | 47 | } |
48 | 48 | } |
@@ -2,15 +2,11 @@ |
||
2 | 2 | namespace PSFS\base\types; |
3 | 3 | |
4 | 4 | use PSFS\base\config\Config; |
5 | -use PSFS\base\exception\RouterException; |
|
6 | -use PSFS\base\Request; |
|
7 | -use PSFS\base\Router; |
|
8 | 5 | use PSFS\base\Singleton; |
9 | 6 | use PSFS\base\types\helpers\GeneratorHelper; |
10 | 7 | use PSFS\base\types\helpers\Inspector; |
11 | 8 | use PSFS\base\types\interfaces\ControllerInterface; |
12 | 9 | use PSFS\base\types\traits\JsonTrait; |
13 | -use PSFS\base\types\traits\OutputTrait; |
|
14 | 10 | use PSFS\base\types\traits\RouteTrait; |
15 | 11 | |
16 | 12 | /** |
@@ -41,11 +41,11 @@ discard block |
||
41 | 41 | public function render($template, array $vars = array(), $cookies = array(), $domain = null) |
42 | 42 | { |
43 | 43 | $vars['__menu__'] = $this->getMenu(); |
44 | - if(Config::getParam('profiling.enable')) { |
|
44 | + if (Config::getParam('profiling.enable')) { |
|
45 | 45 | $vars['__profiling__'] = Inspector::getStats(); |
46 | 46 | } |
47 | 47 | $domain = (null === $domain) ? $this->getDomain() : $domain; |
48 | - return $this->tpl->render($domain . $template, $vars, $cookies); |
|
48 | + return $this->tpl->render($domain.$template, $vars, $cookies); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | { |
77 | 77 | $vars['__menu__'] = $this->getMenu(); |
78 | 78 | $domain = $domain ?: $this->getDomain(); |
79 | - return $this->tpl->dump($domain . $template, $vars); |
|
79 | + return $this->tpl->dump($domain.$template, $vars); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
@@ -14,6 +14,9 @@ |
||
14 | 14 | ]; |
15 | 15 | } |
16 | 16 | |
17 | + /** |
|
18 | + * @param string $name |
|
19 | + */ |
|
17 | 20 | public static function stats($name = null) { |
18 | 21 | self::$profiling[] = self::collect($name); |
19 | 22 | } |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | protected static function calculateStats(array $stats, $ts, $mem = 0, $files = 0) { |
29 | 29 | return [ |
30 | 30 | 'ts' => round($stats['ts'] - $ts, 4), |
31 | - 'mem' => round(($stats['mem'] - $mem) / 1024 / 1024, 4), |
|
31 | + 'mem' => round(($stats['mem'] - $mem)/1024/1024, 4), |
|
32 | 32 | 'files' => $stats['files'] - $files, |
33 | 33 | 'name' => $stats['name'], |
34 | 34 | ]; |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | $ts = defined('PSFS_START_TS') ? PSFS_START_TS : 0; |
43 | 43 | $mem = defined('PSFS_START_MEM') ? PSFS_START_MEM : 0; |
44 | 44 | $files = 0; |
45 | - foreach(self::$profiling as $key => &$value) { |
|
45 | + foreach (self::$profiling as $key => &$value) { |
|
46 | 46 | $value = self::calculateStats($value, $ts, $mem, $files); |
47 | 47 | } |
48 | 48 | self::$profiling[] = self::calculateStats(self::collect('Profiling collect ends'), $ts, $mem, $files); |
@@ -18,7 +18,7 @@ |
||
18 | 18 | * @param mixed $response |
19 | 19 | * @param int $statusCode |
20 | 20 | * |
21 | - * @return mixed JSON |
|
21 | + * @return string|null JSON |
|
22 | 22 | */ |
23 | 23 | public function json($response, $statusCode = 200) |
24 | 24 | { |
@@ -23,10 +23,10 @@ discard block |
||
23 | 23 | */ |
24 | 24 | public function json($response, $statusCode = 200) |
25 | 25 | { |
26 | - if(Config::getParam('profiling.enable')) { |
|
27 | - if(is_array($response)) { |
|
26 | + if (Config::getParam('profiling.enable')) { |
|
27 | + if (is_array($response)) { |
|
28 | 28 | $response['profiling'] = Inspector::getStats(); |
29 | - } elseif($response instanceof JsonResponse) { |
|
29 | + } elseif ($response instanceof JsonResponse) { |
|
30 | 30 | $response = ProfilingJsonResponse::createFromPrevious($response, Inspector::getStats()); |
31 | 31 | } |
32 | 32 | } |
@@ -34,13 +34,13 @@ discard block |
||
34 | 34 | $this->decodeJsonReponse($response); |
35 | 35 | |
36 | 36 | $mask = JSON_UNESCAPED_UNICODE | JSON_BIGINT_AS_STRING; |
37 | - if(Config::getParam('output.json.strict_numbers')) { |
|
37 | + if (Config::getParam('output.json.strict_numbers')) { |
|
38 | 38 | $mask = JSON_UNESCAPED_UNICODE | JSON_BIGINT_AS_STRING | JSON_NUMERIC_CHECK; |
39 | 39 | } |
40 | 40 | |
41 | 41 | $data = json_encode($response, $mask); |
42 | - if(Config::getParam('angular.protection', false)) { |
|
43 | - $data = ")]}',\n" . $data; |
|
42 | + if (Config::getParam('angular.protection', false)) { |
|
43 | + $data = ")]}',\n".$data; |
|
44 | 44 | } |
45 | 45 | $this->setStatus($statusCode); |
46 | 46 | ResponseHelper::setDebugHeaders([]); |