1 | <?php |
||
11 | class RequestHelper |
||
12 | { |
||
13 | /** |
||
14 | * Check if the current request has at least one file |
||
15 | * @return bool |
||
16 | */ |
||
17 | public static function currentRequestHasFiles() : bool |
||
21 | |||
22 | /** |
||
23 | * Check if the passed request has at least one file |
||
24 | * @param Request $request |
||
25 | * @return bool |
||
26 | */ |
||
27 | public static function requestHasFiles(Request $request) : bool |
||
31 | |||
32 | /** |
||
33 | * Check if uploaded File in current request is valid and has a valid Mime Type. |
||
34 | * Return true is all ok, otherwise return false. |
||
35 | * @param string $uploadField |
||
36 | * @param array $arrMimeType |
||
37 | * @return bool |
||
38 | */ |
||
39 | public static function isValidCurrentRequestUploadFile(string $uploadField, array $arrMimeType = array()) : bool |
||
43 | |||
44 | /** |
||
45 | * Check if uploaded File is valid and has a valid Mime Type. |
||
46 | * Return true is all ok, otherwise return false. |
||
47 | * @param string $uploadField |
||
48 | * @param array $arrMimeType |
||
49 | * @param Request $request |
||
50 | * @return bool |
||
51 | */ |
||
52 | public static function isValidUploadFile(string $uploadField, array $arrMimeType = array(), Request $request) : bool |
||
62 | |||
63 | /** |
||
64 | * Return File in Current Request if ok, otherwise return null |
||
65 | * @param string $uploadField |
||
66 | * @param array $arrMimeType |
||
67 | * @return null|UploadedFile |
||
68 | */ |
||
69 | public static function getCurrentRequestFileSafe(string $uploadField, array $arrMimeType = array()) : UploadedFile |
||
73 | |||
74 | /** |
||
75 | * Return File in passed request if ok, otherwise return null |
||
76 | * @param string $uploadField |
||
77 | * @param array $arrMimeType |
||
78 | * @param Request $request |
||
79 | * @return null|UploadedFile |
||
80 | */ |
||
81 | public static function getFileSafe(string $uploadField, array $arrMimeType = array(), Request $request) : UploadedFile |
||
90 | } |
||
91 |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.