Skip to content

Commit

Permalink
docs: replace Response with ResponseInterface in doc comments
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjis committed Sep 23, 2022
1 parent 9812871 commit 7bcbeb6
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 36 deletions.
29 changes: 15 additions & 14 deletions system/API/ResponseTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use CodeIgniter\Format\FormatterInterface;
use CodeIgniter\HTTP\IncomingRequest;
use CodeIgniter\HTTP\Response;
use CodeIgniter\HTTP\ResponseInterface;
use Config\Services;

/**
Expand Down Expand Up @@ -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 = '')
{
Expand Down Expand Up @@ -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 = '')
{
Expand All @@ -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 = '')
{
Expand All @@ -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 = '')
{
Expand All @@ -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 = '')
{
Expand All @@ -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')
{
Expand All @@ -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 = '')
{
Expand All @@ -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 = '')
{
Expand All @@ -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 = '')
{
Expand All @@ -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
*/
Expand All @@ -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 = '')
{
Expand All @@ -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 = '')
{
Expand All @@ -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 = '')
{
Expand All @@ -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 = '')
{
Expand Down
5 changes: 2 additions & 3 deletions system/Config/BaseService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion system/Config/Services.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
4 changes: 2 additions & 2 deletions system/Debug/Exceptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -63,7 +63,7 @@ class Exceptions
/**
* The outgoing response.
*
* @var Response
* @var ResponseInterface
*/
protected $response;

Expand Down
3 changes: 0 additions & 3 deletions system/Debug/Toolbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -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();
Expand Down
6 changes: 1 addition & 5 deletions system/HTTP/ContentSecurityPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -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', []);

Expand Down
16 changes: 8 additions & 8 deletions system/RESTful/ResourceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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()
{
Expand All @@ -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)
{
Expand All @@ -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()
{
Expand All @@ -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()
{
Expand All @@ -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)
{
Expand All @@ -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)
{
Expand All @@ -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)
{
Expand Down

0 comments on commit 7bcbeb6

Please sign in to comment.