From 7b1744c425ab6fad32015aa687bef13b08d02bcb Mon Sep 17 00:00:00 2001 From: Woopicus Date: Wed, 5 Nov 2025 10:41:07 +0100 Subject: [PATCH 1/2] Added declare(strict_types=1); --- src/Command/GetMessagesCommand.php | 3 --- src/Controller/MessageController.php | 3 --- src/DTO/CreateMessageDTO.php | 3 --- src/DTO/UpdateMessageDTO.php | 3 --- src/Entity/Message.php | 3 --- src/Repository/MessageRepository.php | 3 --- src/Service/MessageService.php | 3 --- 7 files changed, 21 deletions(-) diff --git a/src/Command/GetMessagesCommand.php b/src/Command/GetMessagesCommand.php index 05fee05..47cb9ab 100644 --- a/src/Command/GetMessagesCommand.php +++ b/src/Command/GetMessagesCommand.php @@ -1,8 +1,5 @@ Date: Wed, 5 Nov 2025 11:43:13 +0100 Subject: [PATCH 2/2] Added declare(strict_types=1); (for real this time) Changed Method_Created to HTTP JsonResponses --- src/Command/GetMessagesCommand.php | 2 ++ src/Controller/MessageController.php | 13 +++++++------ src/DTO/CreateMessageDTO.php | 2 ++ src/DTO/UpdateMessageDTO.php | 2 ++ src/Entity/Message.php | 2 ++ src/Repository/MessageRepository.php | 2 ++ src/Service/MessageService.php | 2 ++ 7 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/Command/GetMessagesCommand.php b/src/Command/GetMessagesCommand.php index 47cb9ab..2b2272b 100644 --- a/src/Command/GetMessagesCommand.php +++ b/src/Command/GetMessagesCommand.php @@ -1,5 +1,7 @@ messageService->getMessages(); - return $this->json(['data' => $messages]); + return $this->json(['data' => $messages], JsonResponse::HTTP_OK); } #[Route('/api/messages/{messageId}', methods: ['GET'])] @@ -31,21 +32,21 @@ public function getMessage(int $messageId): JsonResponse { $message = $this->messageService->getMessage($messageId); - return $this->json(['data' => $message]); + return $this->json(['data' => $message], JsonResponse::HTTP_OK); } #[Route('/api/messages', methods: ['POST'])] public function createMessage(#[RequestDto] CreateMessageDTO $dto): JsonResponse { $message = $this->messageService->createMessage($dto); - return $this->json(['data' => $message], JsonResponse::Method_CREATED); + return $this->json(['data' => $message], JsonResponse::HTTP_CREATED); } #[Route('/api/messages/{messageId}', methods: ['PUT'])] public function updateMessage(int $messageId, #[RequestDto] UpdateMessageDTO $dto): JsonResponse { $message = $this->messageService->updateMessage($messageId, $dto); - return $this->json(['data' => $message], JsonResponse::Method_CREATED); + return $this->json(['data' => $message], JsonResponse::HTTP_OK); } #[Route('/api/messages/{messageId}', methods: ['DELETE'])] @@ -53,6 +54,6 @@ public function removeMessage(int $messageId): JsonResponse { $this->messageService->removeMessage($messageId); - return $this->json(null, JsonResponse::Method_CREATED); + return $this->json([], JsonResponse::HTTP_NO_CONTENT); } } diff --git a/src/DTO/CreateMessageDTO.php b/src/DTO/CreateMessageDTO.php index 66097b3..8687cfc 100644 --- a/src/DTO/CreateMessageDTO.php +++ b/src/DTO/CreateMessageDTO.php @@ -1,5 +1,7 @@