diff --git a/composer.json b/composer.json index 518cd6a..8ebedc8 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ } }, "require": { - "php": ">=8.0", + "php": ">=7.4", "ext-json": "*", "contributte/api-router": "^4.0|^5.0", "opis/json-schema": "^2.3" diff --git a/src/ApiRoute.php b/src/ApiRoute.php index 83a3606..0bcaa06 100755 --- a/src/ApiRoute.php +++ b/src/ApiRoute.php @@ -23,7 +23,7 @@ class ApiRoute extends \Contributte\ApiRouter\ApiRoute * @param array $data See parent constructor * @param ?array $bodySchema JSON schema as returned when parsed by json_decode */ - public function __construct(array|string $path, string $presenter, array $data, ?array $bodySchema = null) + public function __construct($path, string $presenter, array $data, ?array $bodySchema = null) { parent::__construct($path, $presenter, $data); $this->bodySchema = $bodySchema; @@ -99,8 +99,8 @@ public function resolveMethod(Nette\Http\IRequest $request): string { if (!in_array($request->getMethod(), $this->getMethods(), true)) { throw new ClientException( - 'Allowed methods: ' . implode(', ', $this->getMethods()) . '.', - Nette\Http\IResponse::S405_MethodNotAllowed + 'Allowed methods: ' . implode(', ', $this->getMethods()) . '. Used method: ' . $request->getMethod() . '.', + 405 // MethodNotAllowed ); } diff --git a/src/Exception/FormatInputException.php b/src/Exception/FormatInputException.php index 65e03d4..4cf4d77 100755 --- a/src/Exception/FormatInputException.php +++ b/src/Exception/FormatInputException.php @@ -5,12 +5,11 @@ namespace ADT\ApiJsonRouter\Exception; use Exception; -use Nette\Http\IResponse; class FormatInputException extends Exception implements ApiJsonRouterException { public function __construct(string $message) { - parent::__construct($message, IResponse::S400_BadRequest); + parent::__construct($message, 400); } } diff --git a/src/Exception/FormatSchemaException.php b/src/Exception/FormatSchemaException.php index 5348a04..aba529d 100755 --- a/src/Exception/FormatSchemaException.php +++ b/src/Exception/FormatSchemaException.php @@ -5,12 +5,11 @@ namespace ADT\ApiJsonRouter\Exception; use Exception; -use Nette\Http\IResponse; class FormatSchemaException extends Exception implements ApiJsonRouterException { public function __construct(string $message) { - parent::__construct($message, IResponse::S500_InternalServerError); + parent::__construct($message, 500); } }