|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Backpack\CRUD\app\Library\Uploaders\Validation; |
|
4
|
|
|
|
|
5
|
|
|
use Closure; |
|
6
|
|
|
use Illuminate\Contracts\Validation\DataAwareRule; |
|
7
|
|
|
use Illuminate\Contracts\Validation\ValidationRule; |
|
|
|
|
|
|
8
|
|
|
use Illuminate\Contracts\Validation\ValidatorAwareRule; |
|
9
|
|
|
use Illuminate\Validation\Rules\File; |
|
10
|
|
|
|
|
11
|
|
|
class ValidBackpackUpload implements ValidationRule, DataAwareRule, ValidatorAwareRule |
|
12
|
|
|
{ |
|
13
|
|
|
/** |
|
14
|
|
|
* @var \Illuminate\Contracts\Validation\Validator |
|
15
|
|
|
*/ |
|
16
|
|
|
protected $validator; |
|
17
|
|
|
|
|
18
|
|
|
protected array $data; |
|
19
|
|
|
|
|
20
|
|
|
public $arrayRules = []; |
|
21
|
|
|
|
|
22
|
|
|
public $fileRules = []; |
|
23
|
|
|
|
|
24
|
|
|
public static function make(): self |
|
25
|
|
|
{ |
|
26
|
|
|
return new static(); |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* Run the validation rule. |
|
31
|
|
|
* |
|
32
|
|
|
* @param string $attribute |
|
33
|
|
|
* @param mixed $value |
|
34
|
|
|
* @param \Closure(string): \Illuminate\Translation\PotentiallyTranslatedString $fail |
|
35
|
|
|
* @return void |
|
36
|
|
|
*/ |
|
37
|
|
|
public function validate(string $attribute, mixed $value, Closure $fail): void |
|
38
|
|
|
{ |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
public function arrayRules(string|array|File $rules): self |
|
42
|
|
|
{ |
|
43
|
|
|
if (is_string($rules)) { |
|
|
|
|
|
|
44
|
|
|
$rules = explode('|', $rules); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
if (! in_array('array', $rules)) { |
|
48
|
|
|
$rules[] = 'array'; |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
$this->arrayRules = $rules; |
|
52
|
|
|
|
|
53
|
|
|
return $this; |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
public function fileRules(string|array|File $rules): self |
|
57
|
|
|
{ |
|
58
|
|
|
if (is_string($rules)) { |
|
|
|
|
|
|
59
|
|
|
$rules = explode('|', $rules); |
|
60
|
|
|
} |
|
61
|
|
|
if (! is_array($rules)) { |
|
|
|
|
|
|
62
|
|
|
$rules = [$rules]; |
|
63
|
|
|
} |
|
64
|
|
|
$this->fileRules = $rules; |
|
65
|
|
|
|
|
66
|
|
|
return $this; |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* Set the performing validator. |
|
71
|
|
|
* |
|
72
|
|
|
* @param \Illuminate\Contracts\Validation\Validator $validator |
|
73
|
|
|
* @return $this |
|
74
|
|
|
*/ |
|
75
|
|
|
public function setValidator($validator) |
|
76
|
|
|
{ |
|
77
|
|
|
$this->validator = $validator; |
|
78
|
|
|
|
|
79
|
|
|
return $this; |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* Set the data under validation. |
|
84
|
|
|
* |
|
85
|
|
|
* @param array $data |
|
86
|
|
|
* @return $this |
|
87
|
|
|
*/ |
|
88
|
|
|
public function setData($data) |
|
89
|
|
|
{ |
|
90
|
|
|
$this->data = $data; |
|
91
|
|
|
|
|
92
|
|
|
return $this; |
|
93
|
|
|
} |
|
94
|
|
|
} |
|
95
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths