1 | <?php |
||
14 | class Validator |
||
15 | { |
||
16 | use AccessProtectedTrait; |
||
17 | use RuleListTrait; |
||
18 | |||
19 | /** |
||
20 | * Validator extension name. |
||
21 | */ |
||
22 | const EXTENSION_NAME = 'jsvalidation'; |
||
23 | |||
24 | /** |
||
25 | * @var \Illuminate\Validation\Validator |
||
26 | */ |
||
27 | protected $validator; |
||
28 | |||
29 | /** |
||
30 | * Whether to escape validation messages. |
||
31 | * |
||
32 | * @var bool |
||
33 | */ |
||
34 | protected $escape; |
||
35 | |||
36 | /** |
||
37 | * RemoteValidator constructor. |
||
38 | * |
||
39 | * @param \Illuminate\Validation\Validator $validator |
||
40 | * @param bool $escape |
||
41 | */ |
||
42 | 72 | public function __construct(BaseValidator $validator, $escape = false) |
|
43 | { |
||
44 | 72 | $this->validator = $validator; |
|
45 | 72 | $this->escape = $escape; |
|
46 | 72 | } |
|
47 | |||
48 | /** |
||
49 | * Validate request. |
||
50 | * |
||
51 | * @param $field |
||
52 | * @param $parameters |
||
53 | * @return void |
||
54 | * |
||
55 | * @throws \Illuminate\Validation\ValidationException |
||
56 | */ |
||
57 | 72 | public function validate($field, $parameters = []) |
|
58 | { |
||
59 | 72 | $attribute = $this->parseAttributeName($field); |
|
60 | 72 | $validationParams = $this->parseParameters($parameters); |
|
61 | 72 | $validationResult = $this->validateJsRemoteRequest($attribute, $validationParams); |
|
62 | |||
63 | 72 | $this->throwValidationException($validationResult, $this->validator); |
|
64 | } |
||
65 | |||
66 | /** |
||
67 | * Throw the failed validation exception. |
||
68 | * |
||
69 | * @param mixed $result |
||
70 | * @param \Illuminate\Validation\Validator $validator |
||
71 | * @return void |
||
72 | * |
||
73 | * @throws \Illuminate\Validation\ValidationException|\Illuminate\Http\Exceptions\HttpResponseException |
||
74 | */ |
||
75 | 72 | protected function throwValidationException($result, $validator) |
|
85 | |||
86 | /** |
||
87 | * Parse Validation input request data. |
||
88 | * |
||
89 | * @param $data |
||
90 | * @return array |
||
91 | */ |
||
92 | 72 | protected function parseAttributeName($data) |
|
100 | |||
101 | /** |
||
102 | * Parse Validation parameters. |
||
103 | * |
||
104 | * @param $parameters |
||
105 | * @return array |
||
106 | */ |
||
107 | 72 | protected function parseParameters($parameters) |
|
116 | |||
117 | /** |
||
118 | * Validate remote Javascript Validations. |
||
119 | * |
||
120 | * @param $attribute |
||
121 | * @param array $parameters |
||
122 | * @return array|bool |
||
123 | */ |
||
124 | 72 | protected function validateJsRemoteRequest($attribute, $parameters) |
|
143 | |||
144 | /** |
||
145 | * Sets data for validate remote rules. |
||
146 | * |
||
147 | * @param $attribute |
||
148 | * @param bool $validateAll |
||
149 | * @return void |
||
150 | */ |
||
151 | 72 | protected function setRemoteValidation($attribute, $validateAll = false) |
|
166 | |||
167 | /** |
||
168 | * Remove rules that should not be validated remotely. |
||
169 | * |
||
170 | * @param $rules |
||
171 | * @param BaseValidator $validator |
||
172 | * @return mixed |
||
173 | */ |
||
174 | 48 | protected function purgeNonRemoteRules($rules, $validator) |
|
187 | } |
||
188 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: