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 (#5427)
by Cristian
29:45 queued 14:40
created
src/app/Library/Uploaders/Support/Traits/HandleRepeatableUploads.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 {
15 15
     public bool $handleRepeatableFiles = false;
16 16
 
17
-    public null|string $repeatableContainerName = null;
17
+    public null | string $repeatableContainerName = null;
18 18
 
19 19
     /*******************************
20 20
      * Setters - fluently configure the uploader
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
     /*******************************
32 32
      * Getters
33 33
      *******************************/
34
-    public function getRepeatableContainerName(): null|string
34
+    public function getRepeatableContainerName(): null | string
35 35
     {
36 36
         return $this->repeatableContainerName;
37 37
     }
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
         return $entry;
57 57
     }
58 58
 
59
-    public static function collecFilesAndValuesFromRequest(string $attribute): array|Collection
59
+    public static function collecFilesAndValuesFromRequest(string $attribute): array | Collection
60 60
     {
61 61
         $values = collect(CRUD::getRequest()->get($attribute));
62 62
         $files = collect(CRUD::getRequest()->file($attribute));
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
         foreach (app('UploadersRepository')->getRepeatableUploadersFor($this->getRepeatableContainerName()) as $uploader) {
138 138
             $uploadedValues = $uploader->uploadRepeatableFiles($values->pluck($uploader->getAttributeName())->toArray(), $this->getPreviousRepeatableValues($entry, $uploader));
139 139
 
140
-            $values = $values->map(function ($item, $key) use ($uploadedValues, $uploader) {
140
+            $values = $values->map(function($item, $key) use ($uploadedValues, $uploader) {
141 141
                 $item[$uploader->getAttributeName()] = $uploadedValues[$key] ?? null;
142 142
 
143 143
                 return $item;
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 
158 158
         $values = $entry->{$this->getRepeatableContainerName()};
159 159
         $values = is_string($values) ? json_decode($values, true) : $values;
160
-        $values = array_map(function ($item) use ($repeatableUploaders) {
160
+        $values = array_map(function($item) use ($repeatableUploaders) {
161 161
             foreach ($repeatableUploaders as $upload) {
162 162
                 $item[$upload->getAttributeName()] = $this->getValuesWithPathStripped($item, $upload);
163 163
             }
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 
173 173
     private function retrieveRepeatableRelationFiles(Model $entry)
174 174
     {
175
-        switch($this->getRepeatableRelationType()) {
175
+        switch ($this->getRepeatableRelationType()) {
176 176
             case 'BelongsToMany':
177 177
             case 'MorphToMany':
178 178
                 $pivotClass = app('crud')->getModel()->{$this->getUploaderSubfield()['baseEntity']}()->getPivotClass();
@@ -218,12 +218,12 @@  discard block
 block discarded – undo
218 218
 
219 219
         $repeatableValues = collect($entry->{$this->getName()});
220 220
         foreach (app('UploadersRepository')->getRepeatableUploadersFor($this->getRepeatableContainerName()) as $upload) {
221
-            if (! $upload->shouldDeleteFiles()) {
221
+            if (!$upload->shouldDeleteFiles()) {
222 222
                 continue;
223 223
             }
224 224
             $values = $repeatableValues->pluck($upload->getName())->toArray();
225 225
             foreach ($values as $value) {
226
-                if (! $value) {
226
+                if (!$value) {
227 227
                     continue;
228 228
                 }
229 229
 
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
     {
251 251
         $items = CRUD::getRequest()->input('_order_'.$this->getRepeatableContainerName()) ?? [];
252 252
 
253
-        array_walk($items, function (&$key, $value) {
253
+        array_walk($items, function(&$key, $value) {
254 254
             $requestValue = $key[$this->getName()] ?? null;
255 255
             $key = $this->handleMultipleFiles ? (is_string($requestValue) ? explode(',', $requestValue) : $requestValue) : $requestValue;
256 256
         });
@@ -262,18 +262,18 @@  discard block
 block discarded – undo
262 262
     {
263 263
         $previousValues = json_decode($entry->getOriginal($uploader->getRepeatableContainerName()), true);
264 264
 
265
-        if (! empty($previousValues)) {
265
+        if (!empty($previousValues)) {
266 266
             $previousValues = array_column($previousValues, $uploader->getName());
267 267
         }
268 268
 
269 269
         return $previousValues ?? [];
270 270
     }
271 271
 
272
-    private function getValuesWithPathStripped(array|string|null $item, UploaderInterface $upload)
272
+    private function getValuesWithPathStripped(array | string | null $item, UploaderInterface $upload)
273 273
     {
274 274
         $uploadedValues = $item[$upload->getName()] ?? null;
275 275
         if (is_array($uploadedValues)) {
276
-            return array_map(function ($value) use ($upload) {
276
+            return array_map(function($value) use ($upload) {
277 277
                 return Str::after($value, $upload->getPath());
278 278
             }, $uploadedValues);
279 279
         }
@@ -292,19 +292,19 @@  discard block
 block discarded – undo
292 292
     {
293 293
         if (in_array($this->getRepeatableRelationType(), ['BelongsToMany', 'MorphToMany'])) {
294 294
             $pivotAttributes = $entry->getAttributes();
295
-            $connectedPivot = $entry->pivotParent->{$this->getRepeatableContainerName()}->where(function ($item) use ($pivotAttributes) {
295
+            $connectedPivot = $entry->pivotParent->{$this->getRepeatableContainerName()}->where(function($item) use ($pivotAttributes) {
296 296
                 $itemPivotAttributes = $item->pivot->only(array_keys($pivotAttributes));
297 297
 
298 298
                 return $itemPivotAttributes === $pivotAttributes;
299 299
             })->first();
300 300
 
301
-            if (! $connectedPivot) {
301
+            if (!$connectedPivot) {
302 302
                 return;
303 303
             }
304 304
 
305 305
             $files = $connectedPivot->getOriginal()['pivot_'.$this->getAttributeName()];
306 306
 
307
-            if (! $files) {
307
+            if (!$files) {
308 308
                 return;
309 309
             }
310 310
 
Please login to merge, or discard this patch.
src/app/Library/Uploaders/Uploader.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 
27 27
     private bool $deleteWhenEntryIsDeleted = true;
28 28
 
29
-    private bool|string $attachedToFakeField = false;
29
+    private bool | string $attachedToFakeField = false;
30 30
 
31 31
     /**
32 32
      * Cloud disks have the ability to generate temporary URLs to files, should we do it?
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
     /*******************************
64 64
      * Static methods
65 65
      *******************************/
66
-    public static function for(array $crudObject, array $definition): UploaderInterface
66
+    public static function for (array $crudObject, array $definition): UploaderInterface
67 67
     {
68 68
         return new static($crudObject, $definition);
69 69
     }
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
     public function deleteUploadedFiles(Model $entry): void
105 105
     {
106 106
         if ($this->deleteWhenEntryIsDeleted) {
107
-            if (! in_array(SoftDeletes::class, class_uses_recursive($entry), true)) {
107
+            if (!in_array(SoftDeletes::class, class_uses_recursive($entry), true)) {
108 108
                 $this->performFileDeletion($entry);
109 109
 
110 110
                 return;
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 
181 181
     public function getPreviousFiles(Model $entry): mixed
182 182
     {
183
-        if (! $this->attachedToFakeField) {
183
+        if (!$this->attachedToFakeField) {
184 184
             return $this->getOriginalValue($entry);
185 185
         }
186 186
 
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
         $value = $entry->{$this->getAttributeName()};
220 220
 
221 221
         if ($this->handleMultipleFiles) {
222
-            if (! isset($entry->getCasts()[$this->getName()]) && is_string($value)) {
222
+            if (!isset($entry->getCasts()[$this->getName()]) && is_string($value)) {
223 223
                 $entry->{$this->getAttributeName()} = json_decode($value, true);
224 224
             }
225 225
 
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
 
252 252
         if ($this->handleMultipleFiles) {
253 253
             // ensure we have an array of values when field is not casted in model.
254
-            if (! isset($entry->getCasts()[$this->name]) && is_string($values)) {
254
+            if (!isset($entry->getCasts()[$this->name]) && is_string($values)) {
255 255
                 $values = json_decode($values, true);
256 256
             }
257 257
             foreach ($values ?? [] as $value) {
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
 
269 269
     private function performFileDeletion(Model $entry)
270 270
     {
271
-        if (! $this->handleRepeatableFiles) {
271
+        if (!$this->handleRepeatableFiles) {
272 272
             $this->deleteFiles($entry);
273 273
 
274 274
             return;
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
 
296 296
         $previousValue = $entry->getOriginal($field ?? $this->getAttributeName());
297 297
 
298
-        if (! $previousValue) {
298
+        if (!$previousValue) {
299 299
             return $previousValue;
300 300
         }
301 301
 
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
     /**
314 314
      * Given two multidimensional arrays/collections, merge them recursively.
315 315
      */
316
-    public static function mergeFilesAndValuesRecursive(array|Collection $array1, array|Collection $array2): array|Collection
316
+    public static function mergeFilesAndValuesRecursive(array | Collection $array1, array | Collection $array2): array | Collection
317 317
     {
318 318
         $merged = $array1;
319 319
         foreach ($array2 as $key => &$value) {
Please login to merge, or discard this patch.
src/app/Library/Validation/Rules/ValidUpload.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -33,18 +33,18 @@  discard block
 block discarded – undo
33 33
             return;
34 34
         }
35 35
 
36
-        if (! array_key_exists($attribute, $this->data) && $entry) {
36
+        if (!array_key_exists($attribute, $this->data) && $entry) {
37 37
             return;
38 38
         }
39 39
 
40 40
         $this->createValidator($attribute, $this->getFieldRules(), $value, $fail);
41 41
 
42
-        if (! empty($value) && ! empty($this->getFileRules())) {
42
+        if (!empty($value) && !empty($this->getFileRules())) {
43 43
             $this->createValidator($attribute, $this->getFileRules(), $value, $fail);
44 44
         }
45 45
     }
46 46
 
47
-    public static function field(string|array|ValidationRule|Rule $rules = []): self
47
+    public static function field(string | array | ValidationRule | Rule $rules = []): self
48 48
     {
49 49
         return parent::field($rules);
50 50
     }
@@ -57,13 +57,13 @@  discard block
 block discarded – undo
57 57
 
58 58
         $values[$mainField] = Uploader::mergeFilesAndValuesRecursive($this->data[$mainField], $this->data['_order_'.$mainField] ?? []);
59 59
 
60
-        if (! array_key_exists($subfield, $values[$mainField][$row]) && $entry) {
60
+        if (!array_key_exists($subfield, $values[$mainField][$row]) && $entry) {
61 61
             return;
62 62
         }
63 63
 
64 64
         $this->createValidator($subfield, $this->getFieldRules(), $values[$mainField][$row][$subfield] ?? null, $fail);
65 65
 
66
-        if (! empty($value) && ! empty($this->getFileRules())) {
66
+        if (!empty($value) && !empty($this->getFileRules())) {
67 67
             $this->createValidator($subfield, $this->getFileRules(), $values[$mainField][$row][$subfield] ?? null, $fail);
68 68
         }
69 69
     }
Please login to merge, or discard this patch.
src/app/Library/Validation/Rules/ValidUploadMultiple.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
     {
23 23
         $entry = CrudPanelFacade::getCurrentEntry() ?: null;
24 24
         
25
-        if (! $value = self::ensureValidValue($value)) {
25
+        if (!$value = self::ensureValidValue($value)) {
26 26
             $fail('Unable to determine the value type.');
27 27
 
28 28
             return;
@@ -77,13 +77,13 @@  discard block
 block discarded – undo
77 77
         $row = (int) Str::before(Str::after($attribute, '.'), '.');
78 78
         $dataFiles = explode(',', $this->data['_order_'.$mainField][$row][$subfield] ?? '');
79 79
         $values[$mainField] = Uploader::mergeFilesAndValuesRecursive($this->data[$mainField], $this->data['_order_'.$mainField]);
80
-        if (! array_key_exists($subfield, $values[$mainField][$row]) && $entry) {
80
+        if (!array_key_exists($subfield, $values[$mainField][$row]) && $entry) {
81 81
             return;
82 82
         }
83 83
 
84 84
         $this->createValidator($subfield, $this->getFieldRules(), $values[$mainField][$row][$subfield] ?? null, $fail);
85 85
 
86
-        if (! empty($value) && ! empty($this->getFileRules())) {
86
+        if (!empty($value) && !empty($this->getFileRules())) {
87 87
             $this->createValidator($subfield.'.*', $this->getFileRules(), $values[$mainField][$row][$subfield] ?? null, $fail);
88 88
         }
89 89
     }
Please login to merge, or discard this patch.
src/app/Library/CrudPanel/Traits/FieldsProtectedMethods.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
             return ['name' => Str::replace(' ', '', $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
 
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
         }
190 190
         // if there's a model defined, but no attribute
191 191
         // guess an attribute using the identifiableAttribute functionality in CrudTrait
192
-        if (isset($field['model']) && ! isset($field['attribute']) && method_exists($field['model'], 'identifiableAttribute')) {
192
+        if (isset($field['model']) && !isset($field['attribute']) && method_exists($field['model'], 'identifiableAttribute')) {
193 193
             $field['attribute'] = (new $field['model']())->identifiableAttribute();
194 194
         }
195 195
 
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
      */
206 206
     protected function makeSureFieldHasLabel($field)
207 207
     {
208
-        if (! isset($field['label'])) {
208
+        if (!isset($field['label'])) {
209 209
             $name = str_replace(',', ' ', $field['name']);
210 210
             $name = str_replace('_id', '', $name);
211 211
             $field['label'] = mb_ucfirst(str_replace('_', ' ', $name));
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
      */
224 224
     protected function makeSureFieldHasType($field)
225 225
     {
226
-        if (! isset($field['type'])) {
226
+        if (!isset($field['type'])) {
227 227
             $field['type'] = isset($field['relation_type']) ? $this->inferFieldTypeFromRelationType($field['relation_type']) : $this->inferFieldTypeFromDbColumnType($field['name']);
228 228
         }
229 229
 
@@ -256,16 +256,16 @@  discard block
 block discarded – undo
256 256
      */
257 257
     protected function makeSureSubfieldsHaveNecessaryAttributes($field)
258 258
     {
259
-        if (! isset($field['subfields']) || ! is_array($field['subfields'])) {
259
+        if (!isset($field['subfields']) || !is_array($field['subfields'])) {
260 260
             return $field;
261 261
         }
262 262
 
263
-        if (! is_multidimensional_array($field['subfields'], true)) {
263
+        if (!is_multidimensional_array($field['subfields'], true)) {
264 264
             abort(500, 'Subfields of «'.$field['name'].'» are malformed. Make sure you provide an array of subfields.');
265 265
         }
266 266
 
267 267
         foreach ($field['subfields'] as $key => $subfield) {
268
-            if (empty($subfield) || ! isset($subfield['name'])) {
268
+            if (empty($subfield) || !isset($subfield['name'])) {
269 269
                 abort(500, 'A subfield of «'.$field['name'].'» is malformed. Subfield attribute name can\'t be empty.');
270 270
             }
271 271
 
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
             $subfield['baseFieldName'] = is_array($subfield['name']) ? implode(',', $subfield['name']) : $subfield['name'];
281 281
             $subfield['baseFieldName'] = Str::afterLast($subfield['baseFieldName'], '.');
282 282
 
283
-            if (! isset($field['model'])) {
283
+            if (!isset($field['model'])) {
284 284
                 // we're inside a simple 'repeatable' with no model/relationship, so
285 285
                 // we assume all subfields are supposed to be text fields
286 286
                 $subfield['type'] = $subfield['type'] ?? 'text';
@@ -305,11 +305,11 @@  discard block
 block discarded – undo
305 305
                 case 'BelongsToMany':
306 306
                     $pivotSelectorField = static::getPivotFieldStructure($field);
307 307
 
308
-                    $pivot = Arr::where($field['subfields'], function ($item) use ($pivotSelectorField) {
308
+                    $pivot = Arr::where($field['subfields'], function($item) use ($pivotSelectorField) {
309 309
                         return $item['name'] === $pivotSelectorField['name'];
310 310
                     });
311 311
 
312
-                    if (! empty($pivot)) {
312
+                    if (!empty($pivot)) {
313 313
                         break;
314 314
                     }
315 315
 
@@ -322,11 +322,11 @@  discard block
 block discarded – undo
322 322
                     $entity = isset($field['baseEntity']) ? $field['baseEntity'].'.'.$field['entity'] : $field['entity'];
323 323
                     $relationInstance = $this->getRelationInstance(['entity' => $entity]);
324 324
 
325
-                    $localKeyField = Arr::where($field['subfields'], function ($item) use ($relationInstance) {
325
+                    $localKeyField = Arr::where($field['subfields'], function($item) use ($relationInstance) {
326 326
                         return $item['name'] === $relationInstance->getRelated()->getKeyName();
327 327
                     });
328 328
 
329
-                    if (! empty($localKeyField)) {
329
+                    if (!empty($localKeyField)) {
330 330
                         break;
331 331
                     }
332 332
 
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
     {
352 352
         // if a tab was mentioned, we should enable it
353 353
         if (isset($field['tab'])) {
354
-            if (! $this->tabsEnabled()) {
354
+            if (!$this->tabsEnabled()) {
355 355
                 $this->enableTabs();
356 356
             }
357 357
         }
Please login to merge, or discard this patch.