1 | <?php |
||
10 | abstract class JsonApiRequest extends FormRequest |
||
11 | { |
||
12 | /** |
||
13 | * Base validation rules for all JSON API requests. |
||
14 | * |
||
15 | * @var array |
||
16 | */ |
||
17 | private $baseRules = [ |
||
18 | 'fields' => 'regex:^([A-Za-z]+[A-Za-z_.\-,]*)*[A-Za-z]+$', |
||
19 | 'include' => 'regex:^([A-Za-z]+[A-Za-z_.\-,]*)*[A-Za-z]+$', |
||
20 | 'sort' => 'regex:^-?([A-Za-z]+[A-Za-z_.\-,]*)*[A-Za-z]+$', |
||
21 | 'filter' => 'array', |
||
22 | 'filter.*' => 'regex:[A-Za-z]+', |
||
23 | ]; |
||
24 | |||
25 | /** |
||
26 | * Base validation rules for the individual request type. |
||
27 | * |
||
28 | * @var array |
||
29 | */ |
||
30 | protected $rules = []; |
||
31 | |||
32 | /** |
||
33 | * Get the validator instance for the request. |
||
34 | * |
||
35 | * @return Validator |
||
36 | */ |
||
37 | protected function getValidatorInstance() |
||
42 | |||
43 | /** |
||
44 | * Format the errors from the given Validator instance. |
||
45 | * |
||
46 | * {@inheritdoc} |
||
47 | */ |
||
48 | protected function formatErrors(Validator $validator) |
||
66 | |||
67 | /** |
||
68 | * Get the proper failed validation response for the request. |
||
69 | * |
||
70 | * @param array $errors |
||
71 | * |
||
72 | * @return JsonApiResponse |
||
73 | */ |
||
74 | public function response(array $errors) |
||
78 | } |
||
79 |
This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.