From 7bcbeb6bfbbc4e10a33c11b868d375a6affdf6ad Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 23 Sep 2022 10:22:05 +0900 Subject: [PATCH] docs: replace Response with ResponseInterface in doc comments --- system/API/ResponseTrait.php | 29 ++++++++++++++------------- system/Config/BaseService.php | 5 ++--- system/Config/Services.php | 2 +- system/Debug/Exceptions.php | 4 ++-- system/Debug/Toolbar.php | 3 --- system/HTTP/ContentSecurityPolicy.php | 6 +----- system/RESTful/ResourceController.php | 16 +++++++-------- 7 files changed, 29 insertions(+), 36 deletions(-) diff --git a/system/API/ResponseTrait.php b/system/API/ResponseTrait.php index a893843c149b..b2627f684093 100644 --- a/system/API/ResponseTrait.php +++ b/system/API/ResponseTrait.php @@ -14,6 +14,7 @@ use CodeIgniter\Format\FormatterInterface; use CodeIgniter\HTTP\IncomingRequest; use CodeIgniter\HTTP\Response; +use CodeIgniter\HTTP\ResponseInterface; use Config\Services; /** @@ -85,7 +86,7 @@ trait ResponseTrait * * @param array|string|null $data * - * @return Response + * @return ResponseInterface */ protected function respond($data = null, ?int $status = null, string $message = '') { @@ -119,7 +120,7 @@ protected function respond($data = null, ?int $status = null, string $message = * @param int $status HTTP status code * @param string|null $code Custom, API-specific, error code * - * @return Response + * @return ResponseInterface */ protected function fail($messages, int $status = 400, ?string $code = null, string $customMessage = '') { @@ -145,7 +146,7 @@ protected function fail($messages, int $status = 400, ?string $code = null, stri * * @param mixed $data * - * @return Response + * @return ResponseInterface */ protected function respondCreated($data = null, string $message = '') { @@ -157,7 +158,7 @@ protected function respondCreated($data = null, string $message = '') * * @param mixed $data * - * @return Response + * @return ResponseInterface */ protected function respondDeleted($data = null, string $message = '') { @@ -169,7 +170,7 @@ protected function respondDeleted($data = null, string $message = '') * * @param mixed $data * - * @return Response + * @return ResponseInterface */ protected function respondUpdated($data = null, string $message = '') { @@ -180,7 +181,7 @@ protected function respondUpdated($data = null, string $message = '') * Used after a command has been successfully executed but there is no * meaningful reply to send back to the client. * - * @return Response + * @return ResponseInterface */ protected function respondNoContent(string $message = 'No Content') { @@ -192,7 +193,7 @@ protected function respondNoContent(string $message = 'No Content') * or had bad authorization credentials. User is encouraged to try again * with the proper information. * - * @return Response + * @return ResponseInterface */ protected function failUnauthorized(string $description = 'Unauthorized', ?string $code = null, string $message = '') { @@ -203,7 +204,7 @@ protected function failUnauthorized(string $description = 'Unauthorized', ?strin * Used when access is always denied to this resource and no amount * of trying again will help. * - * @return Response + * @return ResponseInterface */ protected function failForbidden(string $description = 'Forbidden', ?string $code = null, string $message = '') { @@ -213,7 +214,7 @@ protected function failForbidden(string $description = 'Forbidden', ?string $cod /** * Used when a specified resource cannot be found. * - * @return Response + * @return ResponseInterface */ protected function failNotFound(string $description = 'Not Found', ?string $code = null, string $message = '') { @@ -223,7 +224,7 @@ protected function failNotFound(string $description = 'Not Found', ?string $code /** * Used when the data provided by the client cannot be validated. * - * @return Response + * @return ResponseInterface * * @deprecated Use failValidationErrors instead */ @@ -237,7 +238,7 @@ protected function failValidationError(string $description = 'Bad Request', ?str * * @param string|string[] $errors * - * @return Response + * @return ResponseInterface */ protected function failValidationErrors($errors, ?string $code = null, string $message = '') { @@ -247,7 +248,7 @@ protected function failValidationErrors($errors, ?string $code = null, string $m /** * Use when trying to create a new resource and it already exists. * - * @return Response + * @return ResponseInterface */ protected function failResourceExists(string $description = 'Conflict', ?string $code = null, string $message = '') { @@ -259,7 +260,7 @@ protected function failResourceExists(string $description = 'Conflict', ?string * Not Found, because here we know the data previously existed, but is now gone, * where Not Found means we simply cannot find any information about it. * - * @return Response + * @return ResponseInterface */ protected function failResourceGone(string $description = 'Gone', ?string $code = null, string $message = '') { @@ -269,7 +270,7 @@ protected function failResourceGone(string $description = 'Gone', ?string $code /** * Used when the user has made too many requests for the resource recently. * - * @return Response + * @return ResponseInterface */ protected function failTooManyRequests(string $description = 'Too Many Requests', ?string $code = null, string $message = '') { diff --git a/system/Config/BaseService.php b/system/Config/BaseService.php index a240246d3c5c..98cb19fde9e7 100644 --- a/system/Config/BaseService.php +++ b/system/Config/BaseService.php @@ -35,7 +35,6 @@ use CodeIgniter\HTTP\RedirectResponse; use CodeIgniter\HTTP\Request; use CodeIgniter\HTTP\RequestInterface; -use CodeIgniter\HTTP\Response; use CodeIgniter\HTTP\ResponseInterface; use CodeIgniter\HTTP\URI; use CodeIgniter\Images\Handlers\BaseHandler; @@ -101,7 +100,7 @@ * @method static CURLRequest curlrequest($options = [], ResponseInterface $response = null, App $config = null, $getShared = true) * @method static Email email($config = null, $getShared = true) * @method static EncrypterInterface encrypter(Encryption $config = null, $getShared = false) - * @method static Exceptions exceptions(ConfigExceptions $config = null, IncomingRequest $request = null, Response $response = null, $getShared = true) + * @method static Exceptions exceptions(ConfigExceptions $config = null, IncomingRequest $request = null, ResponseInterface $response = null, $getShared = true) * @method static Filters filters(ConfigFilters $config = null, $getShared = true) * @method static Format format(ConfigFormat $config = null, $getShared = true) * @method static Honeypot honeypot(ConfigHoneyPot $config = null, $getShared = true) @@ -117,7 +116,7 @@ * @method static RedirectResponse redirectresponse(App $config = null, $getShared = true) * @method static View renderer($viewPath = null, ConfigView $config = null, $getShared = true) * @method static IncomingRequest|CLIRequest request(App $config = null, $getShared = true) - * @method static Response response(App $config = null, $getShared = true) + * @method static ResponseInterface response(App $config = null, $getShared = true) * @method static Router router(RouteCollectionInterface $routes = null, Request $request = null, $getShared = true) * @method static RouteCollection routes($getShared = true) * @method static Security security(App $config = null, $getShared = true) diff --git a/system/Config/Services.php b/system/Config/Services.php index edfe13113457..aa2be0219b71 100644 --- a/system/Config/Services.php +++ b/system/Config/Services.php @@ -546,7 +546,7 @@ public static function incomingrequest(?App $config = null, bool $getShared = tr /** * The Response class models an HTTP response. * - * @return Response + * @return ResponseInterface */ public static function response(?App $config = null, bool $getShared = true) { diff --git a/system/Debug/Exceptions.php b/system/Debug/Exceptions.php index 01609788bd0f..1e976fc6be1a 100644 --- a/system/Debug/Exceptions.php +++ b/system/Debug/Exceptions.php @@ -18,7 +18,7 @@ use CodeIgniter\HTTP\CLIRequest; use CodeIgniter\HTTP\Exceptions\HTTPException; use CodeIgniter\HTTP\IncomingRequest; -use CodeIgniter\HTTP\Response; +use CodeIgniter\HTTP\ResponseInterface; use Config\Exceptions as ExceptionsConfig; use Config\Paths; use ErrorException; @@ -63,7 +63,7 @@ class Exceptions /** * The outgoing response. * - * @var Response + * @var ResponseInterface */ protected $response; diff --git a/system/Debug/Toolbar.php b/system/Debug/Toolbar.php index a2f76e48d3d7..a225bc3a4c61 100644 --- a/system/Debug/Toolbar.php +++ b/system/Debug/Toolbar.php @@ -20,7 +20,6 @@ use CodeIgniter\HTTP\DownloadResponse; use CodeIgniter\HTTP\IncomingRequest; use CodeIgniter\HTTP\RequestInterface; -use CodeIgniter\HTTP\Response; use CodeIgniter\HTTP\ResponseInterface; use Config\Services; use Config\Toolbar as ToolbarConfig; @@ -71,7 +70,6 @@ public function __construct(ToolbarConfig $config) * * @param float $startTime App start time * @param IncomingRequest $request - * @param Response $response * * @return string JSON encoded data */ @@ -355,7 +353,6 @@ public function prepare(?RequestInterface $request = null, ?ResponseInterface $r { /** * @var IncomingRequest|null $request - * @var Response|null $response */ if (CI_DEBUG && ! is_cli()) { $app = Services::codeigniter(); diff --git a/system/HTTP/ContentSecurityPolicy.php b/system/HTTP/ContentSecurityPolicy.php index 36292621397e..70f61e2c0b0f 100644 --- a/system/HTTP/ContentSecurityPolicy.php +++ b/system/HTTP/ContentSecurityPolicy.php @@ -691,11 +691,7 @@ protected function generateNonces(ResponseInterface $response) */ protected function buildHeaders(ResponseInterface $response) { - /** - * Ensure both headers are available and arrays... - * - * @var Response $response - */ + // Ensure both headers are available and arrays... $response->setHeader('Content-Security-Policy', []); $response->setHeader('Content-Security-Policy-Report-Only', []); diff --git a/system/RESTful/ResourceController.php b/system/RESTful/ResourceController.php index 42bf93831e85..93a16d0dff98 100644 --- a/system/RESTful/ResourceController.php +++ b/system/RESTful/ResourceController.php @@ -12,7 +12,7 @@ namespace CodeIgniter\RESTful; use CodeIgniter\API\ResponseTrait; -use CodeIgniter\HTTP\Response; +use CodeIgniter\HTTP\ResponseInterface; /** * An extendable controller to provide a RESTful API for a resource. @@ -24,7 +24,7 @@ class ResourceController extends BaseResource /** * Return an array of resource objects, themselves in array format * - * @return Response|string|void + * @return ResponseInterface|string|void */ public function index() { @@ -36,7 +36,7 @@ public function index() * * @param int|string|null $id * - * @return Response|string|void + * @return ResponseInterface|string|void */ public function show($id = null) { @@ -46,7 +46,7 @@ public function show($id = null) /** * Return a new resource object, with default properties * - * @return Response|string|void + * @return ResponseInterface|string|void */ public function new() { @@ -56,7 +56,7 @@ public function new() /** * Create a new resource object, from "posted" parameters * - * @return Response|string|void + * @return ResponseInterface|string|void */ public function create() { @@ -68,7 +68,7 @@ public function create() * * @param int|string|null $id * - * @return Response|string|void + * @return ResponseInterface|string|void */ public function edit($id = null) { @@ -80,7 +80,7 @@ public function edit($id = null) * * @param string|null|int$id * - * @return Response|string|void + * @return ResponseInterface|string|void */ public function update($id = null) { @@ -92,7 +92,7 @@ public function update($id = null) * * @param int|string|null $id * - * @return Response|string|void + * @return ResponseInterface|string|void */ public function delete($id = null) {