Skip to content

Commit

Permalink
Merge pull request codeigniter4#7803 from ya861220/230809-phpstan-HTTP
Browse files Browse the repository at this point in the history
  • Loading branch information
MGatner authored Aug 12, 2023
2 parents e5223ec + f50eee5 commit 0989491
Show file tree
Hide file tree
Showing 12 changed files with 43 additions and 111 deletions.
110 changes: 0 additions & 110 deletions phpstan-baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -846,81 +846,11 @@
'count' => 1,
'path' => __DIR__ . '/system/Filters/Filters.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\HTTP\\\\CLIRequest\\:\\:parseCommand\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/HTTP/CLIRequest.php',
];
$ignoreErrors[] = [
'message' => '#^Constructor of class CodeIgniter\\\\HTTP\\\\CURLRequest has an unused parameter \\$config\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/HTTP/CURLRequest.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\HTTP\\\\CURLRequest\\:\\:parseOptions\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/HTTP/CURLRequest.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\HTTP\\\\CURLRequest\\:\\:resetOptions\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/HTTP/CURLRequest.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\HTTP\\\\CURLRequest\\:\\:setResponseHeaders\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/HTTP/CURLRequest.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\HTTP\\\\ContentSecurityPolicy\\:\\:addOption\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/HTTP/ContentSecurityPolicy.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\HTTP\\\\ContentSecurityPolicy\\:\\:addToHeader\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/HTTP/ContentSecurityPolicy.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\HTTP\\\\ContentSecurityPolicy\\:\\:buildHeaders\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/HTTP/ContentSecurityPolicy.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\HTTP\\\\ContentSecurityPolicy\\:\\:finalize\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/HTTP/ContentSecurityPolicy.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\HTTP\\\\ContentSecurityPolicy\\:\\:generateNonces\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/HTTP/ContentSecurityPolicy.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\HTTP\\\\DownloadResponse\\:\\:buildHeaders\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/HTTP/DownloadResponse.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\HTTP\\\\DownloadResponse\\:\\:setBinary\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/HTTP/DownloadResponse.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\HTTP\\\\DownloadResponse\\:\\:setContentTypeByMimeType\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/HTTP/DownloadResponse.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\HTTP\\\\DownloadResponse\\:\\:setFilePath\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/HTTP/DownloadResponse.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\HTTP\\\\Files\\\\FileCollection\\:\\:populateFiles\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/HTTP/Files/FileCollection.php',
];
$ignoreErrors[] = [
'message' => '#^Expression on left side of \\?\\? is not nullable\\.$#',
'count' => 1,
Expand All @@ -936,21 +866,6 @@
'count' => 1,
'path' => __DIR__ . '/system/HTTP/Files/UploadedFile.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\HTTP\\\\Files\\\\UploadedFileInterface\\:\\:move\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/HTTP/Files/UploadedFileInterface.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\HTTP\\\\IncomingRequest\\:\\:detectLocale\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/HTTP/IncomingRequest.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\HTTP\\\\IncomingRequest\\:\\:detectURI\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/HTTP/IncomingRequest.php',
];
$ignoreErrors[] = [
'message' => '#^Property CodeIgniter\\\\HTTP\\\\Message\\:\\:\\$protocolVersion \\(string\\) on left side of \\?\\? is not nullable\\.$#',
'count' => 1,
Expand All @@ -966,21 +881,6 @@
'count' => 1,
'path' => __DIR__ . '/system/HTTP/RedirectResponse.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\HTTP\\\\Request\\:\\:populateGlobals\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/HTTP/Request.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\HTTP\\\\Response\\:\\:sendCookies\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/HTTP/Response.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\HTTP\\\\URI\\:\\:applyParts\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/HTTP/URI.php',
];
$ignoreErrors[] = [
'message' => '#^Property CodeIgniter\\\\HTTP\\\\URI\\:\\:\\$fragment \\(string\\) on left side of \\?\\? is not nullable\\.$#',
'count' => 1,
Expand All @@ -996,16 +896,6 @@
'count' => 1,
'path' => __DIR__ . '/system/HTTP/URI.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\HTTP\\\\UserAgent\\:\\:compileData\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/HTTP/UserAgent.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\HTTP\\\\UserAgent\\:\\:parse\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/HTTP/UserAgent.php',
];
$ignoreErrors[] = [
'message' => '#^Right side of && is always true\\.$#',
'count' => 1,
Expand Down
2 changes: 2 additions & 0 deletions system/HTTP/CLIRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ public function getOptionString(bool $useLongOpts = false): string
*
* NOTE: I tried to use getopt but had it fail occasionally to find
* any options, where argv has always had our back.
*
* @return void
*/
protected function parseCommand()
{
Expand Down
6 changes: 6 additions & 0 deletions system/HTTP/CURLRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ public function request($method, string $url, array $options = []): ResponseInte

/**
* Reset all options to default.
*
* @return void
*/
protected function resetOptions()
{
Expand Down Expand Up @@ -277,6 +279,8 @@ public function setJSON($data)
/**
* Sets the correct settings based on the options array
* passed in.
*
* @return void
*/
protected function parseOptions(array $options)
{
Expand Down Expand Up @@ -479,6 +483,8 @@ protected function applyBody(array $curlOptions = []): array
/**
* Parses the header retrieved from the cURL response into
* our Response object.
*
* @return void
*/
protected function setResponseHeaders(array $headers = [])
{
Expand Down
10 changes: 10 additions & 0 deletions system/HTTP/ContentSecurityPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,8 @@ public function getScriptNonce(): string
* Compiles and sets the appropriate headers in the request.
*
* Should be called just prior to sending the response to the user agent.
*
* @return void
*/
public function finalize(ResponseInterface $response)
{
Expand Down Expand Up @@ -641,6 +643,8 @@ public function upgradeInsecureRequests(bool $value = true)
* DRY method to add an string or array to a class property.
*
* @param array|string $options
*
* @return void
*/
protected function addOption($options, string $target, ?bool $explicitReporting = null)
{
Expand All @@ -662,6 +666,8 @@ protected function addOption($options, string $target, ?bool $explicitReporting
* Scans the body of the request message and replaces any nonce
* placeholders with actual nonces, that we'll then add to our
* headers.
*
* @return void
*/
protected function generateNonces(ResponseInterface $response)
{
Expand All @@ -688,6 +694,8 @@ protected function generateNonces(ResponseInterface $response)
* Based on the current state of the elements, will add the appropriate
* Content-Security-Policy and Content-Security-Policy-Report-Only headers
* with their values to the response object.
*
* @return void
*/
protected function buildHeaders(ResponseInterface $response)
{
Expand Down Expand Up @@ -768,6 +776,8 @@ protected function buildHeaders(ResponseInterface $response)
* reportOnly header, since it's viable to have both simultaneously.
*
* @param array|string|null $values
*
* @return void
*/
protected function addToHeader(string $name, $values = null)
{
Expand Down
8 changes: 7 additions & 1 deletion system/HTTP/DownloadResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ public function __construct(string $filename, bool $setMime)

/**
* set download for binary string.
*
* @return void
*/
public function setBinary(string $binary)
{
Expand All @@ -88,6 +90,8 @@ public function setBinary(string $binary)

/**
* set download for file.
*
* @return void
*/
public function setFilePath(string $filepath)
{
Expand Down Expand Up @@ -129,7 +133,7 @@ public function getContentLength(): int
/**
* Set content type by guessing mime type from file extension
*/
private function setContentTypeByMimeType()
private function setContentTypeByMimeType(): void
{
$mime = null;
$charset = '';
Expand Down Expand Up @@ -262,6 +266,8 @@ public function send()

/**
* set header for file download.
*
* @return void
*/
public function buildHeaders()
{
Expand Down
2 changes: 2 additions & 0 deletions system/HTTP/Files/FileCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ public function hasFile(string $fileID): bool
* of UploadedFile for each one, saving the results to this->files.
*
* Called by files(), file(), and hasFile()
*
* @return void
*/
protected function populateFiles()
{
Expand Down
2 changes: 2 additions & 0 deletions system/HTTP/Files/UploadedFileInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ public function __construct(string $path, string $originalName, ?string $mimeTyp
* @param string $targetPath Path to which to move the uploaded file.
* @param string $name the name to rename the file to.
*
* @return bool
*
* @throws InvalidArgumentException if the $path specified is invalid.
* @throws RuntimeException on any error during the move operation.
* @throws RuntimeException on the second or subsequent call to the method.
Expand Down
4 changes: 4 additions & 0 deletions system/HTTP/IncomingRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ private function getPostMaxSize(): int
* content negotiation.
*
* @param App $config
*
* @return void
*/
public function detectLocale($config)
{
Expand All @@ -226,6 +228,8 @@ public function detectLocale($config)
* determined from the environment as needed.
*
* @deprecated $protocol and $baseURL are deprecated. No longer used.
*
* @return void
*/
protected function detectURI(string $protocol, string $baseURL)
{
Expand Down
2 changes: 2 additions & 0 deletions system/HTTP/RequestTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,8 @@ public function fetchGlobal(string $method, $index = null, ?int $filter = null,
/**
* Saves a copy of the current state of one of several PHP globals
* so we can retrieve them later.
*
* @return void
*/
protected function populateGlobals(string $method)
{
Expand Down
2 changes: 2 additions & 0 deletions system/HTTP/ResponseTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,8 @@ public function getCookies()

/**
* Actually sets the cookies.
*
* @return void
*/
protected function sendCookies()
{
Expand Down
2 changes: 2 additions & 0 deletions system/HTTP/URI.php
Original file line number Diff line number Diff line change
Expand Up @@ -946,6 +946,8 @@ protected function filterPath(?string $path = null): string

/**
* Saves our parts from a parse_url call.
*
* @return void
*/
protected function applyParts(array $parts)
{
Expand Down
4 changes: 4 additions & 0 deletions system/HTTP/UserAgent.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,8 @@ public function getReferrer(): string

/**
* Parse a custom user-agent string
*
* @return void
*/
public function parse(string $string)
{
Expand All @@ -269,6 +271,8 @@ public function parse(string $string)

/**
* Compile the User Agent Data
*
* @return void
*/
protected function compileData()
{
Expand Down

0 comments on commit 0989491

Please sign in to comment.