Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Test Failed
Pull Request — main (#4819)
by Pedro
13:18
created
src/app/Library/CrudPanel/CrudColumn.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -75,7 +75,7 @@
 block discarded – undo
75 75
      */
76 76
     public function key(string $key)
77 77
     {
78
-        if (! isset($this->attributes['name'])) {
78
+        if (!isset($this->attributes['name'])) {
79 79
             abort(500, 'Column name must be defined before changing the key.');
80 80
         }
81 81
 
Please login to merge, or discard this patch.
src/app/Library/CrudPanel/Traits/Update.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
         }
48 48
 
49 49
         // always have a hidden input for the entry id
50
-        if (! array_key_exists('id', $fields)) {
50
+        if (!array_key_exists('id', $fields)) {
51 51
             $fields['id'] = [
52 52
                 'name'  => $entry->getKeyName(),
53 53
                 'value' => $entry->getKey(),
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
         $fieldEntity = $field['entity'] ?? false;
73 73
         $fakeField = $field['fake'] ?? false;
74 74
 
75
-        if ($fieldEntity && ! $fakeField) {
75
+        if ($fieldEntity && !$fakeField) {
76 76
             return $this->getModelAttributeValueFromRelationship($model, $field);
77 77
         }
78 78
 
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
     {
103 103
         [$relatedModel, $relationMethod] = $this->getModelAndMethodFromEntity($model, $field);
104 104
 
105
-        if (! method_exists($relatedModel, $relationMethod)) {
105
+        if (!method_exists($relatedModel, $relationMethod)) {
106 106
             return $relatedModel->{$relationMethod};
107 107
         }
108 108
 
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
                     $model = $this->setupRelatedModelLocale($model);
122 122
                     // when subfields are NOT set we don't need to get any more values
123 123
                     // we just return the plain models as we only need the ids
124
-                    if (! isset($field['subfields'])) {
124
+                    if (!isset($field['subfields'])) {
125 125
                         $result->push($model);
126 126
                         continue;
127 127
                     }
@@ -148,13 +148,13 @@  discard block
 block discarded – undo
148 148
                 break;
149 149
             case 'HasOne':
150 150
             case 'MorphOne':
151
-                if (! method_exists($relatedModel, $relationMethod)) {
151
+                if (!method_exists($relatedModel, $relationMethod)) {
152 152
                     return;
153 153
                 }
154 154
 
155 155
                 $model = $relatedModel->{$relationMethod};
156 156
 
157
-                if (! $model) {
157
+                if (!$model) {
158 158
                     return;
159 159
                 }
160 160
 
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
 
236 236
         $relationArray = explode('.', $relationEntity);
237 237
 
238
-        $relatedModel = array_reduce(array_splice($relationArray, 0, -1), function ($obj, $method) {
238
+        $relatedModel = array_reduce(array_splice($relationArray, 0, -1), function($obj, $method) {
239 239
             // if the string ends with `_id` we strip it out
240 240
             $method = Str::endsWith($method, '_id') ? Str::replaceLast('_id', '', $method) : $method;
241 241
 
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
             // if the subfield name does not contain a dot we just need to check
263 263
             // if it has subfields and return the result accordingly.
264 264
             foreach ((array) $subfield['name'] as $name) {
265
-                if (! Str::contains($name, '.')) {
265
+                if (!Str::contains($name, '.')) {
266 266
                     // when subfields are present, $relatedModel->{$name} returns a model instance
267 267
                     // otherwise returns the model attribute.
268 268
                     if ($relatedModel->{$name}) {
Please login to merge, or discard this patch.
src/app/Library/CrudPanel/Traits/Search.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -23,9 +23,9 @@  discard block
 block discarded – undo
23 23
      */
24 24
     public function applySearchTerm($searchTerm)
25 25
     {
26
-        return $this->query->where(function ($query) use ($searchTerm) {
26
+        return $this->query->where(function($query) use ($searchTerm) {
27 27
             foreach ($this->columns() as $column) {
28
-                if (! isset($column['type'])) {
28
+                if (!isset($column['type'])) {
29 29
                     abort(400, 'Missing column type when trying to apply search term.');
30 30
                 }
31 31
 
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 
86 86
                 case 'select':
87 87
                 case 'select_multiple':
88
-                    $query->orWhereHas($column['entity'], function ($q) use ($column, $searchTerm, $searchOperator) {
88
+                    $query->orWhereHas($column['entity'], function($q) use ($column, $searchTerm, $searchOperator) {
89 89
                         $q->where($this->getColumnWithTableNamePrefixed($q, $column['attribute']), $searchOperator, '%'.$searchTerm.'%');
90 90
                     });
91 91
                     break;
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
                 $column_number = (int) $order['column'];
110 110
                 $column_direction = (strtolower((string) $order['dir']) == 'asc' ? 'ASC' : 'DESC');
111 111
                 $column = $this->findColumnById($column_number);
112
-                if ($column['tableColumn'] && ! isset($column['orderLogic'])) {
112
+                if ($column['tableColumn'] && !isset($column['orderLogic'])) {
113 113
                     if (method_exists($this->model, 'translationEnabled') &&
114 114
                         $this->model->translationEnabled() &&
115 115
                         $this->model->isTranslatableAttribute($column['name']) &&
@@ -136,12 +136,12 @@  discard block
 block discarded – undo
136 136
         $table = $this->model->getTable();
137 137
         $key = $this->model->getKeyName();
138 138
 
139
-        $hasOrderByPrimaryKey = collect($orderBy)->some(function ($item) use ($key, $table) {
139
+        $hasOrderByPrimaryKey = collect($orderBy)->some(function($item) use ($key, $table) {
140 140
             return (isset($item['column']) && $item['column'] === $key)
141 141
                 || (isset($item['sql']) && str_contains($item['sql'], "$table.$key"));
142 142
         });
143 143
 
144
-        if (! $hasOrderByPrimaryKey) {
144
+        if (!$hasOrderByPrimaryKey) {
145 145
             $this->orderByWithPrefix($key, 'DESC');
146 146
         }
147 147
     }
@@ -320,13 +320,13 @@  discard block
 block discarded – undo
320 320
         if (isset($column['type'])) {
321 321
             // create a list of paths to column blade views
322 322
             // including the configured view_namespaces
323
-            $columnPaths = array_map(function ($item) use ($column) {
323
+            $columnPaths = array_map(function($item) use ($column) {
324 324
                 return $item.'.'.$column['type'];
325 325
             }, ViewNamespaces::getFor('columns'));
326 326
 
327 327
             // but always fall back to the stock 'text' column
328 328
             // if a view doesn't exist
329
-            if (! in_array('crud::columns.text', $columnPaths)) {
329
+            if (!in_array('crud::columns.text', $columnPaths)) {
330 330
                 $columnPaths[] = 'crud::columns.text';
331 331
             }
332 332
 
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
      */
366 366
     private function renderCellView($view, $column, $entry, $rowNumber = false)
367 367
     {
368
-        if (! view()->exists($view)) {
368
+        if (!view()->exists($view)) {
369 369
             $view = 'crud::columns.text'; // fallback to text column
370 370
         }
371 371
 
Please login to merge, or discard this patch.
src/app/Library/CrudPanel/Traits/Create.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
                     // - a single dimensional array: [1,2,3]
112 112
                     // - an array of arrays: [[1][2][3]]
113 113
                     // if is as single dimensional array we can only attach.
114
-                    if ($relationValues === null || ! is_multidimensional_array($relationValues)) {
114
+                    if ($relationValues === null || !is_multidimensional_array($relationValues)) {
115 115
                         $this->attachManyRelation($item, $relation, $relationDetails, $relationValues);
116 116
                     } else {
117 117
                         $this->createManyEntries($item, $relation, $relationMethod, $relationDetails);
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
 
276 276
         // if column is not nullable in database, and there is no column default (null),
277 277
         // we will delete the entry from the database, otherwise it will throw and ugly DB error.
278
-        if (! $relationColumnIsNullable && $dbColumnDefault === null) {
278
+        if (!$relationColumnIsNullable && $dbColumnDefault === null) {
279 279
             return $removedEntries->lazy()->each->delete();
280 280
         }
281 281
 
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
         }
321 321
 
322 322
         // use the collection of sent ids to match against database ids, delete the ones not found in the submitted ids.
323
-        if (! empty($relatedItemsSent)) {
323
+        if (!empty($relatedItemsSent)) {
324 324
             // we perform the cleanup of removed database items
325 325
             $entry->{$relationMethod}()->whereNotIn($relatedModelLocalKey, $relatedItemsSent)->lazy()->each->delete();
326 326
         }
Please login to merge, or discard this patch.
src/app/Library/CrudPanel/Traits/FieldsProtectedMethods.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
      */
70 70
     public function overwriteFieldNameFromDotNotationToArray($field)
71 71
     {
72
-        if (! is_array($field['name']) && strpos($field['name'], '.') !== false) {
72
+        if (!is_array($field['name']) && strpos($field['name'], '.') !== false) {
73 73
             $entity_array = explode('.', $field['name']);
74 74
             $name_string = '';
75 75
 
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
             return ['name' => $field];
116 116
         }
117 117
 
118
-        if (is_array($field) && ! isset($field['name'])) {
118
+        if (is_array($field) && !isset($field['name'])) {
119 119
             abort(500, 'All fields must have their name defined');
120 120
         }
121 121
 
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
         }
193 193
         // if there's a model defined, but no attribute
194 194
         // guess an attribute using the identifiableAttribute functionality in CrudTrait
195
-        if (isset($field['model']) && ! isset($field['attribute']) && method_exists($field['model'], 'identifiableAttribute')) {
195
+        if (isset($field['model']) && !isset($field['attribute']) && method_exists($field['model'], 'identifiableAttribute')) {
196 196
             $field['attribute'] = (new $field['model']())->identifiableAttribute();
197 197
         }
198 198
 
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
      */
209 209
     protected function makeSureFieldHasLabel($field)
210 210
     {
211
-        if (! isset($field['label'])) {
211
+        if (!isset($field['label'])) {
212 212
             $name = is_array($field['name']) ? $field['name'][0] : $field['name'];
213 213
             $name = str_replace('_id', '', $name);
214 214
             $field['label'] = mb_ucfirst(str_replace('_', ' ', $name));
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
      */
227 227
     protected function makeSureFieldHasType($field)
228 228
     {
229
-        if (! isset($field['type'])) {
229
+        if (!isset($field['type'])) {
230 230
             $field['type'] = isset($field['relation_type']) ? $this->inferFieldTypeFromRelationType($field['relation_type']) : $this->inferFieldTypeFromDbColumnType($field['name']);
231 231
         }
232 232
 
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
      */
264 264
     protected function makeSureSubfieldsHaveNecessaryAttributes($field)
265 265
     {
266
-        if (! isset($field['subfields'])) {
266
+        if (!isset($field['subfields'])) {
267 267
             return $field;
268 268
         }
269 269
 
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 
280 280
             $subfield['parentFieldName'] = is_array($field['name']) ? false : $field['name'];
281 281
 
282
-            if (! isset($field['model'])) {
282
+            if (!isset($field['model'])) {
283 283
                 // we're inside a simple 'repeatable' with no model/relationship, so
284 284
                 // we assume all subfields are supposed to be text fields
285 285
                 $subfield['type'] = $subfield['type'] ?? 'text';
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
     {
332 332
         // if a tab was mentioned, we should enable it
333 333
         if (isset($field['tab'])) {
334
-            if (! $this->tabsEnabled()) {
334
+            if (!$this->tabsEnabled()) {
335 335
                 $this->enableTabs();
336 336
             }
337 337
         }
Please login to merge, or discard this patch.
src/app/Library/CrudPanel/Traits/Views.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
         }
300 300
         // otherwise, loop through all the possible view namespaces
301 301
         // until you find a view that exists
302
-        $paths = array_map(function ($item) use ($viewPath) {
302
+        $paths = array_map(function($item) use ($viewPath) {
303 303
             return $item.'.'.$viewPath;
304 304
         }, ViewNamespaces::getFor('fields'));
305 305
 
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
         }
311 311
 
312 312
         // if no view exists, in any of the directories above... no bueno
313
-        if (! backpack_pro()) {
313
+        if (!backpack_pro()) {
314 314
             throw new BackpackProRequiredException('Cannot find the field view: '.$viewPath.'. Please check for typos.'.(backpack_pro() ? '' : ' If you are trying to use a PRO field, please first purchase and install the backpack/pro addon from backpackforlaravel.com'), 1);
315 315
         }
316 316
         abort(500, "Cannot find '{$viewPath}' field view in any of the regular locations.");
Please login to merge, or discard this patch.
src/app/Library/CrudPanel/Traits/Validation.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -46,10 +46,10 @@  discard block
 block discarded – undo
46 46
     private function getValidationRulesFromFieldsAndSubfields($fields)
47 47
     {
48 48
         $rules = collect($fields)
49
-            ->filter(function ($value, $key) {
49
+            ->filter(function($value, $key) {
50 50
                 // only keep fields where 'validationRules' OR there are subfields
51 51
                 return array_key_exists('validationRules', $value) || array_key_exists('subfields', $value);
52
-            })->map(function ($item, $key) {
52
+            })->map(function($item, $key) {
53 53
                 $validationRules = [];
54 54
                 // only keep the rules, not the entire field definition
55 55
                 if (isset($item['validationRules'])) {
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
                 }
58 58
                 // add validation rules for subfields
59 59
                 if (array_key_exists('subfields', $item)) {
60
-                    $subfieldsWithValidation = array_filter($item['subfields'], function ($subfield) {
60
+                    $subfieldsWithValidation = array_filter($item['subfields'], function($subfield) {
61 61
                         return array_key_exists('validationRules', $subfield);
62 62
                     });
63 63
 
@@ -82,10 +82,10 @@  discard block
 block discarded – undo
82 82
     {
83 83
         $messages = [];
84 84
         collect($fields)
85
-            ->filter(function ($value, $key) {
85
+            ->filter(function($value, $key) {
86 86
                 // only keep fields where 'validationMessages' OR there are subfields
87 87
                 return array_key_exists('validationMessages', $value) || array_key_exists('subfields', $value);
88
-            })->each(function ($item, $key) use (&$messages) {
88
+            })->each(function($item, $key) use (&$messages) {
89 89
                 if (isset($item['validationMessages'])) {
90 90
                     foreach ($item['validationMessages'] as $rule => $message) {
91 91
                         $messages[$key.'.'.$rule] = $message;
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
                 }
94 94
                 // add messages from subfields
95 95
                 if (array_key_exists('subfields', $item)) {
96
-                    $subfieldsWithValidationMessages = array_filter($item['subfields'], function ($subfield) {
96
+                    $subfieldsWithValidationMessages = array_filter($item['subfields'], function($subfield) {
97 97
                         return array_key_exists('validationRules', $subfield);
98 98
                     });
99 99
 
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
      */
130 130
     public function setValidation($classOrRulesArray = false, $messages = [])
131 131
     {
132
-        if (! $classOrRulesArray) {
132
+        if (!$classOrRulesArray) {
133 133
             $this->setValidationFromFields();
134 134
         } elseif (is_array($classOrRulesArray)) {
135 135
             $this->setValidationFromArray($classOrRulesArray, $messages);
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
             return app(get_class($extendedRequest), ['rules' => $rules, 'messages' => $messages]);
237 237
         }
238 238
 
239
-        return ! empty($rules) ? $this->checkRequestValidity($rules, $messages) : $this->getRequest();
239
+        return !empty($rules) ? $this->checkRequestValidity($rules, $messages) : $this->getRequest();
240 240
     }
241 241
 
242 242
     /**
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
      */
307 307
     public function isRequired($inputKey)
308 308
     {
309
-        if (! $this->hasOperationSetting('requiredFields')) {
309
+        if (!$this->hasOperationSetting('requiredFields')) {
310 310
             return false;
311 311
         }
312 312
 
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
     {
328 328
         [$rules, $messages] = $this->getValidationRulesAndMessagesFromField($field, $parent);
329 329
 
330
-        if (! empty($rules)) {
330
+        if (!empty($rules)) {
331 331
             $this->setValidation($rules, $messages);
332 332
         }
333 333
     }
Please login to merge, or discard this patch.
src/app/Library/CrudPanel/Traits/Read.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
      */
57 57
     public function getEntry($id)
58 58
     {
59
-        if (! $this->entry) {
59
+        if (!$this->entry) {
60 60
             $this->entry = $this->getModelWithCrudPanelQuery()->findOrFail($id);
61 61
             $this->entry = $this->entry->withFakes();
62 62
         }
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
      */
74 74
     public function getEntryWithLocale($id)
75 75
     {
76
-        if (! $this->entry) {
76
+        if (!$this->entry) {
77 77
             $this->entry = $this->getEntry($id);
78 78
         }
79 79
 
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
      */
163 163
     public function enableDetailsRow()
164 164
     {
165
-        if (! backpack_pro()) {
165
+        if (!backpack_pro()) {
166 166
             throw new BackpackProRequiredException('Details row');
167 167
         }
168 168
 
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
                 // we will apply the same labels as the values to the menu if developer didn't
262 262
                 $this->abortIfInvalidPageLength($menu[0]);
263 263
 
264
-                if (! isset($menu[1]) || ! is_array($menu[1])) {
264
+                if (!isset($menu[1]) || !is_array($menu[1])) {
265 265
                     $menu[1] = $menu[0];
266 266
                 }
267 267
             } else {
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
      */
350 350
     public function enableExportButtons()
351 351
     {
352
-        if (! backpack_pro()) {
352
+        if (!backpack_pro()) {
353 353
             throw new BackpackProRequiredException('Export buttons');
354 354
         }
355 355
 
Please login to merge, or discard this patch.
src/app/Library/CrudPanel/Traits/AutoSet.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -14,8 +14,8 @@  discard block
 block discarded – undo
14 14
     {
15 15
         $this->getDbColumnTypes();
16 16
 
17
-        array_map(function ($field) use ($setFields, $setColumns) {
18
-            if ($setFields && ! isset($this->getCleanStateFields()[$field])) {
17
+        array_map(function($field) use ($setFields, $setColumns) {
18
+            if ($setFields && !isset($this->getCleanStateFields()[$field])) {
19 19
                 $this->addField([
20 20
                     'name'       => $field,
21 21
                     'label'      => $this->makeLabel($field),
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
                 ]);
29 29
             }
30 30
 
31
-            if ($setColumns && ! in_array($field, $this->model->getHidden()) && ! isset($this->columns()[$field])) {
31
+            if ($setColumns && !in_array($field, $this->model->getHidden()) && !isset($this->columns()[$field])) {
32 32
                 $this->addColumn([
33 33
                     'name'    => $field,
34 34
                     'label'   => $this->makeLabel($field),
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
     {
51 51
         $dbColumnTypes = [];
52 52
 
53
-        if (! $this->driverIsSql()) {
53
+        if (!$this->driverIsSql()) {
54 54
             return $dbColumnTypes;
55 55
         }
56 56
 
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 
116 116
         $dbColumnTypes = $this->getDbColumnTypes();
117 117
 
118
-        if (! isset($dbColumnTypes[$fieldName])) {
118
+        if (!isset($dbColumnTypes[$fieldName])) {
119 119
             return 'text';
120 120
         }
121 121
 
@@ -212,12 +212,12 @@  discard block
 block discarded – undo
212 212
     {
213 213
         $fillable = $this->model->getFillable();
214 214
 
215
-        if (! $this->driverIsSql()) {
215
+        if (!$this->driverIsSql()) {
216 216
             $columns = $fillable;
217 217
         } else {
218 218
             // Automatically-set columns should be both in the database, and in the $fillable variable on the Eloquent Model
219 219
             $columns = $this->model::getDbTableSchema()->getColumnsNames();
220
-            if (! empty($fillable)) {
220
+            if (!empty($fillable)) {
221 221
                 $columns = array_intersect($columns, $fillable);
222 222
             }
223 223
         }
Please login to merge, or discard this patch.