We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
@@ -2,8 +2,8 @@ |
||
2 | 2 | |
3 | 3 | namespace Backpack\CRUD\Tests\Unit\Http; |
4 | 4 | |
5 | -use Backpack\CRUD\app\Library\CrudPanel\CrudPanel; |
|
6 | 5 | use Backpack\CRUD\Tests\BaseTest; |
6 | +use Backpack\CRUD\app\Library\CrudPanel\CrudPanel; |
|
7 | 7 | |
8 | 8 | class CrudControllerTest extends BaseTest |
9 | 9 | { |
@@ -19,7 +19,7 @@ |
||
19 | 19 | $controller = '\Backpack\CRUD\Tests\Unit\Http\Controllers\UserCrudController'; |
20 | 20 | $app['router']->get('users/{id}/edit', "$controller@edit"); |
21 | 21 | $app['router']->put('users/{id}', "$controller@update"); |
22 | - $app->singleton('crud', function ($app) { |
|
22 | + $app->singleton('crud', function($app) { |
|
23 | 23 | return new CrudPanel($app); |
24 | 24 | }); |
25 | 25 | } |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | */ |
70 | 70 | public function setRequest($request = null) |
71 | 71 | { |
72 | - if (! $request) { |
|
72 | + if (!$request) { |
|
73 | 73 | $request = \Request::instance(); |
74 | 74 | } |
75 | 75 | $this->request = $request; |
@@ -89,11 +89,11 @@ discard block |
||
89 | 89 | */ |
90 | 90 | public function setModel($model_namespace) |
91 | 91 | { |
92 | - if (! class_exists($model_namespace)) { |
|
92 | + if (!class_exists($model_namespace)) { |
|
93 | 93 | throw new \Exception('The model does not exist.', 500); |
94 | 94 | } |
95 | 95 | |
96 | - if (! method_exists($model_namespace, 'hasCrudTrait')) { |
|
96 | + if (!method_exists($model_namespace, 'hasCrudTrait')) { |
|
97 | 97 | throw new \Exception('Please use CrudTrait on the model.', 500); |
98 | 98 | } |
99 | 99 | |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | { |
157 | 157 | $complete_route = $route.'.index'; |
158 | 158 | |
159 | - if (! \Route::has($complete_route)) { |
|
159 | + if (!\Route::has($complete_route)) { |
|
160 | 160 | throw new \Exception('There are no routes for this route name.', 404); |
161 | 161 | } |
162 | 162 | |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | */ |
258 | 258 | public function getFirstOfItsTypeInArray($type, $array) |
259 | 259 | { |
260 | - return array_first($array, function ($item) use ($type) { |
|
260 | + return array_first($array, function($item) use ($type) { |
|
261 | 261 | return $item['type'] == $type; |
262 | 262 | }); |
263 | 263 | } |
@@ -274,8 +274,8 @@ discard block |
||
274 | 274 | |
275 | 275 | public function sync($type, $fields, $attributes) |
276 | 276 | { |
277 | - if (! empty($this->{$type})) { |
|
278 | - $this->{$type} = array_map(function ($field) use ($fields, $attributes) { |
|
277 | + if (!empty($this->{$type})) { |
|
278 | + $this->{$type} = array_map(function($field) use ($fields, $attributes) { |
|
279 | 279 | if (in_array($field['name'], (array) $fields)) { |
280 | 280 | $field = array_merge($field, $attributes); |
281 | 281 | } |
@@ -306,15 +306,15 @@ discard block |
||
306 | 306 | { |
307 | 307 | $relationArray = explode('.', $relationString); |
308 | 308 | |
309 | - if (! isset($length)) { |
|
309 | + if (!isset($length)) { |
|
310 | 310 | $length = count($relationArray); |
311 | 311 | } |
312 | 312 | |
313 | - if (! isset($model)) { |
|
313 | + if (!isset($model)) { |
|
314 | 314 | $model = $this->model; |
315 | 315 | } |
316 | 316 | |
317 | - $result = array_reduce(array_splice($relationArray, 0, $length), function ($obj, $method) { |
|
317 | + $result = array_reduce(array_splice($relationArray, 0, $length), function($obj, $method) { |
|
318 | 318 | return $obj->$method()->getRelated(); |
319 | 319 | }, $model); |
320 | 320 | |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | $relation = $model->{$firstRelationName}; |
365 | 365 | |
366 | 366 | $results = []; |
367 | - if (! empty($relation)) { |
|
367 | + if (!empty($relation)) { |
|
368 | 368 | if ($relation instanceof Collection) { |
369 | 369 | $currentResults = $relation->toArray(); |
370 | 370 | } else { |
@@ -373,7 +373,7 @@ discard block |
||
373 | 373 | |
374 | 374 | array_shift($relationArray); |
375 | 375 | |
376 | - if (! empty($relationArray)) { |
|
376 | + if (!empty($relationArray)) { |
|
377 | 377 | foreach ($currentResults as $currentResult) { |
378 | 378 | $results = array_merge($results, $this->getRelationModelInstances($currentResult, implode('.', $relationArray))); |
379 | 379 | } |
@@ -30,7 +30,7 @@ |
||
30 | 30 | /** |
31 | 31 | * Execute the console command. |
32 | 32 | * |
33 | - * @return mixed Command-line output |
|
33 | + * @return false|null Command-line output |
|
34 | 34 | */ |
35 | 35 | public function handle() |
36 | 36 | { |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | $createUploadDirectoryCommand = 'mkdir -p public/uploads'; |
89 | 89 | break; |
90 | 90 | case '\\': // windows |
91 | - if (! file_exists('public\uploads')) { |
|
91 | + if (!file_exists('public\uploads')) { |
|
92 | 92 | $createUploadDirectoryCommand = 'mkdir public\uploads'; |
93 | 93 | } |
94 | 94 | break; |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | $this->echo('info', $beforeNotice ? ' '.$beforeNotice : $command); |
134 | 134 | |
135 | 135 | $process = new Process($command, null, null, null, $this->option('timeout')); |
136 | - $process->run(function ($type, $buffer) { |
|
136 | + $process->run(function($type, $buffer) { |
|
137 | 137 | if (Process::ERR === $type) { |
138 | 138 | $this->echo('comment', $buffer); |
139 | 139 | } else { |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | }); |
143 | 143 | |
144 | 144 | // executes after the command finishes |
145 | - if (! $process->isSuccessful()) { |
|
145 | + if (!$process->isSuccessful()) { |
|
146 | 146 | throw new ProcessFailedException($process); |
147 | 147 | } |
148 | 148 |
@@ -326,8 +326,6 @@ discard block |
||
326 | 326 | * Check if the create/update form has upload fields. |
327 | 327 | * Upload fields are the ones that have "upload" => true defined on them. |
328 | 328 | * |
329 | - * @param string $form create/update/both - defaults to 'both' |
|
330 | - * @param bool|int $id id of the entity - defaults to false |
|
331 | 329 | * |
332 | 330 | * @return bool |
333 | 331 | */ |
@@ -358,7 +356,7 @@ discard block |
||
358 | 356 | /** |
359 | 357 | * Set an array of field type names as already loaded for the current operation. |
360 | 358 | * |
361 | - * @param array $fieldTypes |
|
359 | + * @param string[] $fieldTypes |
|
362 | 360 | */ |
363 | 361 | public function setLoadedFieldTypes($fieldTypes) |
364 | 362 | { |
@@ -369,7 +367,7 @@ discard block |
||
369 | 367 | * Get a namespaced version of the field type name. |
370 | 368 | * Appends the 'view_namespace' attribute of the field to the `type', using dot notation. |
371 | 369 | * |
372 | - * @param mixed $field |
|
370 | + * @param string $field |
|
373 | 371 | * @return string Namespaced version of the field type name. Ex: 'text', 'custom.view.path.text' |
374 | 372 | */ |
375 | 373 | public function getFieldTypeWithNamespace($field) |
@@ -48,24 +48,24 @@ discard block |
||
48 | 48 | |
49 | 49 | // if this is a relation type field and no corresponding model was specified, |
50 | 50 | // get it from the relation method defined in the main model |
51 | - if (isset($newField['entity']) && ! isset($newField['model'])) { |
|
51 | + if (isset($newField['entity']) && !isset($newField['model'])) { |
|
52 | 52 | $newField['model'] = $this->getRelationModel($newField['entity']); |
53 | 53 | } |
54 | 54 | |
55 | 55 | // if the label is missing, we should set it |
56 | - if (! isset($newField['label'])) { |
|
56 | + if (!isset($newField['label'])) { |
|
57 | 57 | $label = is_array($newField['name']) ? $newField['name'][0] : $newField['name']; |
58 | 58 | $newField['label'] = mb_ucfirst(str_replace('_', ' ', $label)); |
59 | 59 | } |
60 | 60 | |
61 | 61 | // if the field type is missing, we should set it |
62 | - if (! isset($newField['type'])) { |
|
62 | + if (!isset($newField['type'])) { |
|
63 | 63 | $newField['type'] = $this->getFieldTypeFromDbColumnType($newField['name']); |
64 | 64 | } |
65 | 65 | |
66 | 66 | // if a tab was mentioned, we should enable it |
67 | 67 | if (isset($newField['tab'])) { |
68 | - if (! $this->tabsEnabled()) { |
|
68 | + if (!$this->tabsEnabled()) { |
|
69 | 69 | $this->enableTabs(); |
70 | 70 | } |
71 | 71 | } |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | */ |
100 | 100 | public function afterField($targetFieldName) |
101 | 101 | { |
102 | - $this->transformFields(function ($fields) use ($targetFieldName) { |
|
102 | + $this->transformFields(function($fields) use ($targetFieldName) { |
|
103 | 103 | return $this->moveField($fields, $targetFieldName, false); |
104 | 104 | }); |
105 | 105 | } |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | */ |
112 | 112 | public function beforeField($targetFieldName) |
113 | 113 | { |
114 | - $this->transformFields(function ($fields) use ($targetFieldName) { |
|
114 | + $this->transformFields(function($fields) use ($targetFieldName) { |
|
115 | 115 | return $this->moveField($fields, $targetFieldName, true); |
116 | 116 | }); |
117 | 117 | } |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | */ |
154 | 154 | public function removeField($name) |
155 | 155 | { |
156 | - $this->transformFields(function ($fields) use ($name) { |
|
156 | + $this->transformFields(function($fields) use ($name) { |
|
157 | 157 | array_forget($fields, $name); |
158 | 158 | |
159 | 159 | return $fields; |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | */ |
168 | 168 | public function removeFields($array_of_names) |
169 | 169 | { |
170 | - if (! empty($array_of_names)) { |
|
170 | + if (!empty($array_of_names)) { |
|
171 | 171 | foreach ($array_of_names as $name) { |
172 | 172 | $this->removeField($name); |
173 | 173 | } |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | public function removeAllFields() |
181 | 181 | { |
182 | 182 | $current_fields = $this->getCurrentFields(); |
183 | - if (! empty($current_fields)) { |
|
183 | + if (!empty($current_fields)) { |
|
184 | 184 | foreach ($current_fields as $field) { |
185 | 185 | $this->removeField($field['name']); |
186 | 186 | } |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | $jsonCastables = ['array', 'object', 'json']; |
255 | 255 | $fieldCasting = $casted_attributes[$field['name']]; |
256 | 256 | |
257 | - if (in_array($fieldCasting, $jsonCastables) && isset($data[$field['name']]) && ! empty($data[$field['name']]) && ! is_array($data[$field['name']])) { |
|
257 | + if (in_array($fieldCasting, $jsonCastables) && isset($data[$field['name']]) && !empty($data[$field['name']]) && !is_array($data[$field['name']])) { |
|
258 | 258 | try { |
259 | 259 | $data[$field['name']] = json_decode($data[$field['name']]); |
260 | 260 | } catch (\Exception $e) { |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | */ |
284 | 284 | public function orderFields($order) |
285 | 285 | { |
286 | - $this->transformFields(function ($fields) use ($order) { |
|
286 | + $this->transformFields(function($fields) use ($order) { |
|
287 | 287 | return $this->applyOrderToFields($fields, $order); |
288 | 288 | }); |
289 | 289 | } |
@@ -346,7 +346,7 @@ discard block |
||
346 | 346 | public function hasUploadFields() |
347 | 347 | { |
348 | 348 | $fields = $this->getFields(); |
349 | - $upload_fields = array_where($fields, function ($value, $key) { |
|
349 | + $upload_fields = array_where($fields, function($value, $key) { |
|
350 | 350 | return isset($value['upload']) && $value['upload'] == true; |
351 | 351 | }); |
352 | 352 | |
@@ -409,7 +409,7 @@ discard block |
||
409 | 409 | $alreadyLoaded = $this->getLoadedFieldTypes(); |
410 | 410 | $type = $this->getFieldTypeWithNamespace($field); |
411 | 411 | |
412 | - if (! in_array($type, $this->getLoadedFieldTypes(), true)) { |
|
412 | + if (!in_array($type, $this->getLoadedFieldTypes(), true)) { |
|
413 | 413 | $alreadyLoaded[] = $type; |
414 | 414 | $this->setLoadedFieldTypes($alreadyLoaded); |
415 | 415 | |
@@ -450,7 +450,7 @@ discard block |
||
450 | 450 | */ |
451 | 451 | public function fieldTypeNotLoaded($field) |
452 | 452 | { |
453 | - return ! in_array($this->getFieldTypeWithNamespace($field), $this->getLoadedFieldTypes()); |
|
453 | + return !in_array($this->getFieldTypeWithNamespace($field), $this->getLoadedFieldTypes()); |
|
454 | 454 | } |
455 | 455 | |
456 | 456 | /** |
@@ -67,7 +67,7 @@ |
||
67 | 67 | * |
68 | 68 | * @param \Illuminate\Http\Request $request |
69 | 69 | * |
70 | - * @return mixed |
|
70 | + * @return \Illuminate\Http\RedirectResponse |
|
71 | 71 | */ |
72 | 72 | protected function loggedOut(Request $request) |
73 | 73 | { |
@@ -52,9 +52,9 @@ |
||
52 | 52 | public function checkIfFieldNameBelongsToAnyRelation($fieldName) |
53 | 53 | { |
54 | 54 | $relations = $this->getAvailableRelationsInModel(); |
55 | - if (! empty($relations)) { |
|
55 | + if (!empty($relations)) { |
|
56 | 56 | if (in_array($fieldName, array_column($relations, 'name'))) { |
57 | - return array_filter($relations, function ($arr) use ($fieldName) { |
|
57 | + return array_filter($relations, function($arr) use ($fieldName) { |
|
58 | 58 | if (isset($arr['name'])) { |
59 | 59 | return $arr['name'] == $fieldName; |
60 | 60 | } |
@@ -155,7 +155,7 @@ |
||
155 | 155 | * Based on relation type returns if relation allows multiple entities. |
156 | 156 | * |
157 | 157 | * @param string $relationType |
158 | - * @return bool |
|
158 | + * @return boolean|null |
|
159 | 159 | */ |
160 | 160 | public function relationAllowsMultiple($relationType) |
161 | 161 | { |
@@ -10,7 +10,7 @@ |
||
10 | 10 | $array_of_values = []; |
11 | 11 | |
12 | 12 | foreach ($values as $key => $value) { |
13 | - if (! is_null($value)) { |
|
13 | + if (!is_null($value)) { |
|
14 | 14 | $array_of_values[] = $column['options'][$value] ?? $value; |
15 | 15 | } else { |
16 | 16 | echo '-'; |
@@ -87,10 +87,10 @@ |
||
87 | 87 | $field = $this->crud->fields()[request()->get('field')]; |
88 | 88 | $options = []; |
89 | 89 | |
90 | - if (! empty($field)) { |
|
90 | + if (!empty($field)) { |
|
91 | 91 | $relatedModelInstance = new $field['model'](); |
92 | 92 | |
93 | - if (! isset($field['options'])) { |
|
93 | + if (!isset($field['options'])) { |
|
94 | 94 | $options = $field['model']::all()->pluck($field['attribute'], $relatedModelInstance->getKeyName()); |
95 | 95 | } else { |
96 | 96 | $options = call_user_func($field['options'], $field['model']::query()->pluck($field['attribute'], $relatedModelInstance->getKeyName())); |