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 (#5440)
by Cristian
26:23 queued 11:28
created

ValidUpload::validateRules()   A

Complexity

Conditions 5
Paths 3

Size

Total Lines 15
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 5
eloc 7
c 0
b 0
f 0
nc 3
nop 2
dl 0
loc 15
rs 9.6111
1
<?php
2
3
namespace Backpack\CRUD\app\Library\Validation\Rules;
4
5
use Backpack\CRUD\app\Library\CrudPanel\CrudPanelFacade;
6
use Backpack\CRUD\app\Library\Validation\Rules\Support\HasFiles;
7
use Closure;
8
use Illuminate\Contracts\Validation\Rule;
9
use Illuminate\Contracts\Validation\ValidationRule;
10
11
class ValidUpload extends BackpackCustomRule
12
{
13
    use HasFiles;
14
15
    /**
16
     * Run the validation rule.
17
     *
18
     * @param  string  $attribute
19
     * @param  mixed  $value
20
     * @param  Closure(string): \Illuminate\Translation\PotentiallyTranslatedString  $fail
21
     * @return void
22
     */
23
    public function validateRules(string $attribute, mixed $value): array
24
    {
25
        $entry = CrudPanelFacade::getCurrentEntry();
0 ignored issues
show
Bug introduced by
The method getCurrentEntry() does not exist on Backpack\CRUD\app\Librar...udPanel\CrudPanelFacade. Since you implemented __callStatic, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

25
        /** @scrutinizer ignore-call */ 
26
        $entry = CrudPanelFacade::getCurrentEntry();
Loading history...
26
27
        if (! array_key_exists($attribute, $this->data) && $entry) {
28
            return [];
0 ignored issues
show
Bug Best Practice introduced by
The expression return array() returns the type array which is incompatible with the documented return type void.
Loading history...
29
        }
30
31
        $fieldErrors = $this->validateFieldRules($attribute, $value);
32
33
        if (! empty($value) && ! empty($this->getFileRules())) {
34
            $fileErrors = $this->validateFileRules($attribute, $value);
35
        }
36
37
        return array_merge($fieldErrors, $fileErrors ?? []);
0 ignored issues
show
Bug Best Practice introduced by
The expression return array_merge($fiel...$fileErrors ?? array()) returns the type array which is incompatible with the documented return type void.
Loading history...
38
    }
39
40
    public static function field(string|array|ValidationRule|Rule $rules = []): self
41
    {
42
        return parent::field($rules);
0 ignored issues
show
Bug Best Practice introduced by
The expression return parent::field($rules) returns the type Backpack\CRUD\app\Librar...ules\BackpackCustomRule which includes types incompatible with the type-hinted return Backpack\CRUD\app\Librar...ation\Rules\ValidUpload.
Loading history...
43
    }
44
}
45