From: Alexander Ebert Date: Sun, 17 Mar 2024 15:50:04 +0000 (+0100) Subject: Fix the casing of the enum X-Git-Tag: 6.1.0_Alpha_1~148^2~6 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=11b223c0b9fad84c6c79f56028df16ad9112a9d2;p=GitHub%2FWoltLab%2FWCF.git Fix the casing of the enum --- diff --git a/wcfsetup/install/files/lib/action/ApiAction.class.php b/wcfsetup/install/files/lib/action/ApiAction.class.php index 6721ade812..3ca4361788 100644 --- a/wcfsetup/install/files/lib/action/ApiAction.class.php +++ b/wcfsetup/install/files/lib/action/ApiAction.class.php @@ -34,12 +34,12 @@ final class ApiAction implements RequestHandlerInterface }; if (!$isSupportedVerb) { - return $this->toErrorResponse(RequestFailure::METHOD_NOT_ALLOWED, 'unacceptable_method'); + return $this->toErrorResponse(RequestFailure::MethodNotAllowed, 'unacceptable_method'); } $endpoint = $this->getEndpointFromPathInfo(RouteHandler::getPathInfo()); if ($endpoint === null) { - return $this->toErrorResponse(RequestFailure::UNKNOWN_ENDPOINT, 'missing_endpoint'); + return $this->toErrorResponse(RequestFailure::UnknownEndpoint, 'missing_endpoint'); } // TODO: This is currently very inefficient and should be cached in some @@ -68,11 +68,11 @@ final class ApiAction implements RequestHandlerInterface $result = $dispatcher->dispatch($request->getMethod(), $endpoint); if ($result instanceof NotMatched) { - return $this->toErrorResponse(RequestFailure::UNKNOWN_ENDPOINT, 'unknown_endpoint'); + return $this->toErrorResponse(RequestFailure::UnknownEndpoint, 'unknown_endpoint'); } if ($result instanceof MethodNotAllowed) { - return $this->toErrorResponse(RequestFailure::METHOD_NOT_ALLOWED, 'endpoint_does_not_allow_method'); + return $this->toErrorResponse(RequestFailure::MethodNotAllowed, 'endpoint_does_not_allow_method'); } /** @var IController */ @@ -81,13 +81,13 @@ final class ApiAction implements RequestHandlerInterface try { return $controller($request, $result->variables); } catch (MappingError $e) { - return $this->toErrorResponse(RequestFailure::VALIDATION_FAILED, 'mapping_error', $e->getMessage()); + return $this->toErrorResponse(RequestFailure::ValidationFailed, 'mapping_error', $e->getMessage()); } catch (PermissionDeniedException) { - return $this->toErrorResponse(RequestFailure::PERMISSION_DENIED, 'permission_denied'); + return $this->toErrorResponse(RequestFailure::PermissionDenied, 'permission_denied'); } catch (UserInputException $e) { - return $this->toErrorResponse(RequestFailure::VALIDATION_FAILED, $e->getType(), $e->getMessage(), $e->getField()); + return $this->toErrorResponse(RequestFailure::ValidationFailed, $e->getType(), $e->getMessage(), $e->getField()); } catch (\Throwable $e) { - return $this->toErrorResponse(RequestFailure::INTERNAL_ERROR, 'unknown_exception', $e->getMessage()); + return $this->toErrorResponse(RequestFailure::InternalError, 'unknown_exception', $e->getMessage()); } } diff --git a/wcfsetup/install/files/lib/system/endpoint/DeleteRequest.class.php b/wcfsetup/install/files/lib/system/endpoint/DeleteRequest.class.php index 6b43821461..803525078d 100644 --- a/wcfsetup/install/files/lib/system/endpoint/DeleteRequest.class.php +++ b/wcfsetup/install/files/lib/system/endpoint/DeleteRequest.class.php @@ -7,6 +7,6 @@ final class DeleteRequest extends RequestType { public function __construct(string $uri) { - parent::__construct(RequestMethod::GET, $uri); + parent::__construct(RequestMethod::DELETE, $uri); } } diff --git a/wcfsetup/install/files/lib/system/endpoint/RequestFailure.class.php b/wcfsetup/install/files/lib/system/endpoint/RequestFailure.class.php index 36d72bccd6..2f8dfb8d65 100644 --- a/wcfsetup/install/files/lib/system/endpoint/RequestFailure.class.php +++ b/wcfsetup/install/files/lib/system/endpoint/RequestFailure.class.php @@ -4,31 +4,31 @@ namespace wcf\system\endpoint; enum RequestFailure { - case INTERNAL_ERROR; - case METHOD_NOT_ALLOWED; - case PERMISSION_DENIED; - case VALIDATION_FAILED; - case UNKNOWN_ENDPOINT; + case InternalError; + case MethodNotAllowed; + case PermissionDenied; + case ValidationFailed; + case UnknownEndpoint; public function toString(): string { return match ($this) { - self::INTERNAL_ERROR => 'api_error', - self::METHOD_NOT_ALLOWED => 'invalid_request_error', - self::PERMISSION_DENIED => 'invalid_request_error', - self::VALIDATION_FAILED => 'invalid_request_error', - self::UNKNOWN_ENDPOINT => 'invalid_request_error', + self::InternalError => 'api_error', + self::MethodNotAllowed => 'invalid_request_error', + self::PermissionDenied => 'invalid_request_error', + self::ValidationFailed => 'invalid_request_error', + self::UnknownEndpoint => 'invalid_request_error', }; } public function toStatusCode(): int { return match ($this) { - self::INTERNAL_ERROR => 503, - self::METHOD_NOT_ALLOWED => 405, - self::PERMISSION_DENIED => 403, - self::VALIDATION_FAILED => 400, - self::UNKNOWN_ENDPOINT => 404, + self::InternalError => 503, + self::MethodNotAllowed => 405, + self::PermissionDenied => 403, + self::ValidationFailed => 400, + self::UnknownEndpoint => 404, }; } }