1 | <?php |
||
11 | abstract class JsonApiRequest extends FormRequest |
||
12 | { |
||
13 | /** |
||
14 | * Base validation rules for all JSON API requests. |
||
15 | * |
||
16 | * @var array |
||
17 | */ |
||
18 | private $baseRules = [ |
||
19 | 'fields' => 'regex:^([A-Za-z]+[A-Za-z_.\-,]*)*[A-Za-z]+$', |
||
20 | 'include' => 'regex:^([A-Za-z]+[A-Za-z_.\-,]*)*[A-Za-z]+$', |
||
21 | 'sort' => 'regex:^-?([A-Za-z]+[A-Za-z_.\-,]*)*[A-Za-z]+$', |
||
22 | 'filter' => 'array', |
||
23 | 'filter.*' => 'alpha_dash', |
||
24 | 'page' => 'array', |
||
25 | 'page.size' => 'numeric', |
||
26 | 'page.number' => 'numeric', |
||
27 | ]; |
||
28 | |||
29 | /** |
||
30 | * Base validation rules for the individual request type. |
||
31 | * |
||
32 | * @var array |
||
33 | */ |
||
34 | protected $rules = []; |
||
35 | |||
36 | /** |
||
37 | * Get the validator instance for the request. |
||
38 | * |
||
39 | * @return Validator |
||
40 | */ |
||
41 | protected function getValidatorInstance() |
||
48 | |||
49 | /** |
||
50 | * Perform additional logic before the request input is validated. |
||
51 | */ |
||
52 | protected function beforeValidation() |
||
58 | |||
59 | /** |
||
60 | * Format the errors from the given Validator instance. |
||
61 | * |
||
62 | * {@inheritdoc} |
||
63 | */ |
||
64 | protected function formatErrors(Validator $validator) |
||
82 | |||
83 | /** |
||
84 | * Get the proper failed validation response for the request. |
||
85 | * |
||
86 | * @param array $errors |
||
87 | * |
||
88 | * @return JsonApiResponse |
||
89 | */ |
||
90 | public function response(array $errors) |
||
94 | } |
||
95 |
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.