Skip to content

Commit

Permalink
HTTP typos changes
Browse files Browse the repository at this point in the history
  • Loading branch information
atishhamte committed Apr 19, 2019
1 parent 2c8b28a commit 928448e
Show file tree
Hide file tree
Showing 14 changed files with 65 additions and 62 deletions.
2 changes: 1 addition & 1 deletion system/Format/FormatterInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ interface FormatterInterface
/**
* Takes the given data and formats it.
*
* @param array $data
* @param string|array $data
*
* @return mixed
*/
Expand Down
6 changes: 3 additions & 3 deletions system/HTTP/CURLRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ protected function prepareURL(string $url): string
*
* @return string
*/
public function getMethod($upper = false): string
public function getMethod(bool $upper = false): string
{
return ($upper) ? strtoupper($this->method) : strtolower($this->method);
}
Expand Down Expand Up @@ -514,9 +514,9 @@ protected function applyRequestHeaders(array $curl_options = []): array
* @param string $method
* @param array $curl_options
*
* @return array|integer
* @return array
*/
protected function applyMethod($method, array $curl_options): array
protected function applyMethod(string $method, array $curl_options): array
{
$method = strtoupper($method);

Expand Down
4 changes: 2 additions & 2 deletions system/HTTP/ContentSecurityPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -535,9 +535,9 @@ public function addPluginType($mime, ?bool $explicitReporting = null)
*
* @return $this
*/
public function setReportURI($uri)
public function setReportURI(string $uri)
{
$this->reportURI = (string) $uri;
$this->reportURI = $uri;

return $this;
}
Expand Down
23 changes: 13 additions & 10 deletions system/HTTP/Files/UploadedFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@

use CodeIgniter\Files\File;
use CodeIgniter\HTTP\Exceptions\HTTPException;
use Config\Mimes;
use Exception;

/**
* Value object representing a single file uploaded through an
Expand Down Expand Up @@ -177,7 +179,7 @@ public function move(string $targetPath, string $name = null, bool $overwrite =
{
move_uploaded_file($this->path, $destination);
}
catch (\Exception $e)
catch (Exception $e)
{
$error = error_get_last();
throw HTTPException::forMoveFailed(basename($this->path), $targetPath, strip_tags($error['message']));
Expand All @@ -201,7 +203,7 @@ public function move(string $targetPath, string $name = null, bool $overwrite =
*
* @return string The path set or created.
*/
protected function setPath($path)
protected function setPath(string $path): string
{
if (! is_dir($path))
{
Expand Down Expand Up @@ -261,8 +263,6 @@ public function getError(): int
/**
* Get error string
*
* @var array $errors
*
* @return string
*/
public function getErrorString(): string
Expand Down Expand Up @@ -290,8 +290,7 @@ public function getErrorString(): string
* This is NOT a trusted value.
* For a trusted version, use getMimeType() instead.
*
* @return string|null The media type sent by the client or null if none
* was provided.
* @return string The media type sent by the client or null if none was provided.
*/
public function getClientMimeType(): string
{
Expand All @@ -305,8 +304,7 @@ public function getClientMimeType(): string
* by the client, and should not be trusted. If the file has been
* moved, this will return the final name of the moved file.
*
* @return string|null The filename sent by the client or null if none
* was provided.
* @return string The filename sent by the client or null if none was provided.
*/
public function getName(): string
{
Expand Down Expand Up @@ -353,9 +351,14 @@ public function getExtension(): string
return $this->guessExtension();
}

/**
* Attempts to determine the best file extension.
*
* @return string|null
*/
public function guessExtension(): ?string
{
return \Config\Mimes::guessExtensionFromType($this->getClientMimeType(), $this->getClientExtension());
return Mimes::guessExtensionFromType($this->getClientMimeType(), $this->getClientExtension());
}

//--------------------------------------------------------------------
Expand All @@ -365,7 +368,7 @@ public function guessExtension(): ?string
* was uploaded. This is NOT a trusted source.
* For a trusted version, use guessExtension() instead.
*
* @return string|null
* @return string
*/
public function getClientExtension(): string
{
Expand Down
2 changes: 1 addition & 1 deletion system/HTTP/Header.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function __construct(string $name, $value = null)
*
* @return string
*/
public function getName()
public function getName(): string
{
return $this->name;
}
Expand Down
14 changes: 7 additions & 7 deletions system/HTTP/IncomingRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,11 @@ class IncomingRequest extends Request
* Constructor
*
* @param object $config
* @param URI $uri
* @param string $body
* @param \CodeIgniter\HTTP\URI $uri
* @param string|null $body
* @param \CodeIgniter\HTTP\UserAgent $userAgent
*/
public function __construct($config, $uri = null, $body = 'php://input', UserAgent $userAgent)
public function __construct($config, URI $uri = null, $body = 'php://input', UserAgent $userAgent)
{
// Get our body from php://input
if ($body === 'php://input')
Expand Down Expand Up @@ -321,9 +321,9 @@ public function isSecure(): bool
* to grab data from the request object and can be used in lieu of the
* other get* methods in most cases.
*
* @param null $index
* @param null $filter
* @param null $flags
* @param string|array|null $index
* @param integer|null $filter Filter constant
* @param mixed $flags
*
* @return mixed
*/
Expand Down Expand Up @@ -531,7 +531,7 @@ public function getOldInput(string $key)
*
* @return array
*/
public function getFiles()
public function getFiles(): array
{
if (is_null($this->files))
{
Expand Down
12 changes: 6 additions & 6 deletions system/HTTP/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ public function getHeaders(): array
*
* @return array|\CodeIgniter\HTTP\Header
*/
public function getHeader($name)
public function getHeader(string $name)
{
$orig_name = $this->getHeaderName($name);

Expand All @@ -214,11 +214,11 @@ public function getHeader($name)
/**
* Determines whether a header exists.
*
* @param $name
* @param string $name
*
* @return boolean
*/
public function hasHeader($name): bool
public function hasHeader(string $name): bool
{
$orig_name = $this->getHeaderName($name);

Expand Down Expand Up @@ -318,7 +318,7 @@ public function removeHeader(string $name)
*
* @return Message
*/
public function appendHeader(string $name, $value)
public function appendHeader(string $name, string $value)
{
$orig_name = $this->getHeaderName($name);

Expand All @@ -338,7 +338,7 @@ public function appendHeader(string $name, $value)
*
* @return Message
*/
public function prependHeader(string $name, $value)
public function prependHeader(string $name, string $value)
{
$orig_name = $this->getHeaderName($name);

Expand Down Expand Up @@ -395,7 +395,7 @@ public function setProtocolVersion(string $version)
*
* @return string
*/
protected function getHeaderName($name): string
protected function getHeaderName(string $name): string
{
$lower_name = strtolower($name);

Expand Down
8 changes: 4 additions & 4 deletions system/HTTP/Negotiate.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class Negotiate
*
* @param \CodeIgniter\HTTP\RequestInterface $request
*/
public function __construct(\CodeIgniter\HTTP\RequestInterface $request = null)
public function __construct(RequestInterface $request = null)
{
if (! is_null($request))
{
Expand All @@ -85,7 +85,7 @@ public function __construct(\CodeIgniter\HTTP\RequestInterface $request = null)
*
* @return $this
*/
public function setRequest(\CodeIgniter\HTTP\RequestInterface $request)
public function setRequest(RequestInterface $request)
{
$this->request = $request;

Expand Down Expand Up @@ -253,7 +253,7 @@ protected function getBestMatch(array $supported, string $header = null, bool $e
*
* @return array
*/
public function parseHeader(string $header)
public function parseHeader(string $header): array
{
$results = [];
$acceptable = explode(',', $header);
Expand Down Expand Up @@ -341,7 +341,7 @@ public function parseHeader(string $header)
* @param boolean $enforceTypes
* @return boolean
*/
protected function match(array $acceptable, string $supported, bool $enforceTypes = false)
protected function match(array $acceptable, string $supported, bool $enforceTypes = false): bool
{
$supported = $this->parseHeader($supported);
if (is_array($supported) && count($supported) === 1)
Expand Down
2 changes: 1 addition & 1 deletion system/HTTP/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ public function isValidIP(string $ip = null, string $which = null): bool
*
* @return string
*/
public function getMethod($upper = false): string
public function getMethod(bool $upper = false): string
{
return ($upper) ? strtoupper($this->method) : strtolower($this->method);
}
Expand Down
2 changes: 1 addition & 1 deletion system/HTTP/RequestInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function isValidIP(string $ip, string $which = null): bool;
*
* @return string
*/
public function getMethod($upper = false): string;
public function getMethod(bool $upper = false): string;

//--------------------------------------------------------------------

Expand Down
12 changes: 6 additions & 6 deletions system/HTTP/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -904,7 +904,7 @@ public function setCookie(
*
* @return boolean
*/
public function hasCookie(string $name, $value = null, string $prefix = '')
public function hasCookie(string $name, string $value = null, string $prefix = ''): bool
{
if ($prefix === '' && $this->cookiePrefix !== '')
{
Expand Down Expand Up @@ -967,14 +967,14 @@ public function getCookie(string $name = null, string $prefix = '')
/**
* Sets a cookie to be deleted when the response is sent.
*
* @param $name
* @param string $name
* @param string $domain
* @param string $path
* @param string $prefix
*
* @return $this
*/
public function deleteCookie($name = '', string $domain = '', string $path = '/', string $prefix = '')
public function deleteCookie(string $name = '', string $domain = '', string $path = '/', string $prefix = '')
{
if (empty($name))
{
Expand Down Expand Up @@ -1035,9 +1035,9 @@ protected function sendCookies()
* Generates the headers that force a download to happen. And
* sends the file to the browser.
*
* @param string $filename The path to the file to send
* @param string $data The data to be downloaded
* @param boolean $setMime Whether to try and send the actual MIME type
* @param string $filename The path to the file to send
* @param string|null $data The data to be downloaded
* @param boolean $setMime Whether to try and send the actual MIME type
*
* @return \CodeIgniter\HTTP\DownloadResponse|null
*/
Expand Down
Loading

0 comments on commit 928448e

Please sign in to comment.