Commit 47d6b51c authored by Guillaume Perréal's avatar Guillaume Perréal
Browse files

UploadController: return type hints.

parent d40c50ed
...@@ -91,7 +91,7 @@ class UploadController extends Controller ...@@ -91,7 +91,7 @@ class UploadController extends Controller
* *
* @return JsonResponse * @return JsonResponse
*/ */
public function createAction(Request $request) public function createAction(Request $request): JsonResponse
{ {
$request->setRequestFormat(self::REQUEST_FORMAT); $request->setRequestFormat(self::REQUEST_FORMAT);
$data = $request->request->get('file'); $data = $request->request->get('file');
...@@ -136,7 +136,7 @@ class UploadController extends Controller ...@@ -136,7 +136,7 @@ class UploadController extends Controller
* *
* @return JsonResponse|Response * @return JsonResponse|Response
*/ */
public function putContentAction(Request $request, UploadedFile $file) public function putContentAction(Request $request, UploadedFile $file): Response
{ {
$request->setRequestFormat(self::REQUEST_FORMAT); $request->setRequestFormat(self::REQUEST_FORMAT);
$this->validateCsrfToken($request); $this->validateCsrfToken($request);
...@@ -160,7 +160,7 @@ class UploadController extends Controller ...@@ -160,7 +160,7 @@ class UploadController extends Controller
* *
* @return array * @return array
*/ */
protected function handleRangeHeader(Request $request) protected function handleRangeHeader(Request $request): array
{ {
if (!$request->headers->has('Content-Range')) { if (!$request->headers->has('Content-Range')) {
return [0, PHP_INT_MAX, true]; return [0, PHP_INT_MAX, true];
...@@ -188,7 +188,7 @@ class UploadController extends Controller ...@@ -188,7 +188,7 @@ class UploadController extends Controller
* *
* @return Response * @return Response
*/ */
protected function completeUpload(UploadedFileInterface $file) protected function completeUpload(UploadedFileInterface $file): Response
{ {
try { try {
$this->fileManager->completed($file); $this->fileManager->completed($file);
...@@ -222,7 +222,7 @@ class UploadController extends Controller ...@@ -222,7 +222,7 @@ class UploadController extends Controller
* *
* @return UploadedFileResponse * @return UploadedFileResponse
*/ */
public function getContentAction(Request $request, UploadedFile $file) public function getContentAction(Request $request, UploadedFile $file): UploadedFileResponse
{ {
$this->validateCsrfToken($request); $this->validateCsrfToken($request);
...@@ -245,7 +245,7 @@ class UploadController extends Controller ...@@ -245,7 +245,7 @@ class UploadController extends Controller
* *
* @return JsonResponse * @return JsonResponse
*/ */
public function deleteAction(Request $request, UploadedFile $file) public function deleteAction(Request $request, UploadedFile $file): JsonResponse
{ {
$request->setRequestFormat(self::REQUEST_FORMAT); $request->setRequestFormat(self::REQUEST_FORMAT);
...@@ -261,7 +261,7 @@ class UploadController extends Controller ...@@ -261,7 +261,7 @@ class UploadController extends Controller
* *
* @throws HttpException * @throws HttpException
*/ */
protected function validateCsrfToken(Request $request) protected function validateCsrfToken(Request $request): void
{ {
$token = $this->csrfTokenManager->getToken($request->query->get('token')); $token = $this->csrfTokenManager->getToken($request->query->get('token'));
if (!$this->csrfTokenManager->isTokenValid($token)) { if (!$this->csrfTokenManager->isTokenValid($token)) {
...@@ -277,7 +277,7 @@ class UploadController extends Controller ...@@ -277,7 +277,7 @@ class UploadController extends Controller
* *
* @return JsonResponse * @return JsonResponse
*/ */
protected function createResponse($status = Response::HTTP_OK, $message = 'OK', array $data = [], array $headers = []) protected function createResponse($status = Response::HTTP_OK, $message = 'OK', array $data = [], array $headers = []): JsonResponse
{ {
$data['status'] = $status; $data['status'] = $status;
$data['message'] = $message; $data['message'] = $message;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment