Skip to content

Commit 0989491

Browse files
authored
Merge pull request #7803 from ya861220/230809-phpstan-HTTP
2 parents e5223ec + f50eee5 commit 0989491

12 files changed

+43
-111
lines changed

phpstan-baseline.php

-110
Original file line numberDiff line numberDiff line change
@@ -846,81 +846,11 @@
846846
'count' => 1,
847847
'path' => __DIR__ . '/system/Filters/Filters.php',
848848
];
849-
$ignoreErrors[] = [
850-
'message' => '#^Method CodeIgniter\\\\HTTP\\\\CLIRequest\\:\\:parseCommand\\(\\) has no return type specified\\.$#',
851-
'count' => 1,
852-
'path' => __DIR__ . '/system/HTTP/CLIRequest.php',
853-
];
854849
$ignoreErrors[] = [
855850
'message' => '#^Constructor of class CodeIgniter\\\\HTTP\\\\CURLRequest has an unused parameter \\$config\\.$#',
856851
'count' => 1,
857852
'path' => __DIR__ . '/system/HTTP/CURLRequest.php',
858853
];
859-
$ignoreErrors[] = [
860-
'message' => '#^Method CodeIgniter\\\\HTTP\\\\CURLRequest\\:\\:parseOptions\\(\\) has no return type specified\\.$#',
861-
'count' => 1,
862-
'path' => __DIR__ . '/system/HTTP/CURLRequest.php',
863-
];
864-
$ignoreErrors[] = [
865-
'message' => '#^Method CodeIgniter\\\\HTTP\\\\CURLRequest\\:\\:resetOptions\\(\\) has no return type specified\\.$#',
866-
'count' => 1,
867-
'path' => __DIR__ . '/system/HTTP/CURLRequest.php',
868-
];
869-
$ignoreErrors[] = [
870-
'message' => '#^Method CodeIgniter\\\\HTTP\\\\CURLRequest\\:\\:setResponseHeaders\\(\\) has no return type specified\\.$#',
871-
'count' => 1,
872-
'path' => __DIR__ . '/system/HTTP/CURLRequest.php',
873-
];
874-
$ignoreErrors[] = [
875-
'message' => '#^Method CodeIgniter\\\\HTTP\\\\ContentSecurityPolicy\\:\\:addOption\\(\\) has no return type specified\\.$#',
876-
'count' => 1,
877-
'path' => __DIR__ . '/system/HTTP/ContentSecurityPolicy.php',
878-
];
879-
$ignoreErrors[] = [
880-
'message' => '#^Method CodeIgniter\\\\HTTP\\\\ContentSecurityPolicy\\:\\:addToHeader\\(\\) has no return type specified\\.$#',
881-
'count' => 1,
882-
'path' => __DIR__ . '/system/HTTP/ContentSecurityPolicy.php',
883-
];
884-
$ignoreErrors[] = [
885-
'message' => '#^Method CodeIgniter\\\\HTTP\\\\ContentSecurityPolicy\\:\\:buildHeaders\\(\\) has no return type specified\\.$#',
886-
'count' => 1,
887-
'path' => __DIR__ . '/system/HTTP/ContentSecurityPolicy.php',
888-
];
889-
$ignoreErrors[] = [
890-
'message' => '#^Method CodeIgniter\\\\HTTP\\\\ContentSecurityPolicy\\:\\:finalize\\(\\) has no return type specified\\.$#',
891-
'count' => 1,
892-
'path' => __DIR__ . '/system/HTTP/ContentSecurityPolicy.php',
893-
];
894-
$ignoreErrors[] = [
895-
'message' => '#^Method CodeIgniter\\\\HTTP\\\\ContentSecurityPolicy\\:\\:generateNonces\\(\\) has no return type specified\\.$#',
896-
'count' => 1,
897-
'path' => __DIR__ . '/system/HTTP/ContentSecurityPolicy.php',
898-
];
899-
$ignoreErrors[] = [
900-
'message' => '#^Method CodeIgniter\\\\HTTP\\\\DownloadResponse\\:\\:buildHeaders\\(\\) has no return type specified\\.$#',
901-
'count' => 1,
902-
'path' => __DIR__ . '/system/HTTP/DownloadResponse.php',
903-
];
904-
$ignoreErrors[] = [
905-
'message' => '#^Method CodeIgniter\\\\HTTP\\\\DownloadResponse\\:\\:setBinary\\(\\) has no return type specified\\.$#',
906-
'count' => 1,
907-
'path' => __DIR__ . '/system/HTTP/DownloadResponse.php',
908-
];
909-
$ignoreErrors[] = [
910-
'message' => '#^Method CodeIgniter\\\\HTTP\\\\DownloadResponse\\:\\:setContentTypeByMimeType\\(\\) has no return type specified\\.$#',
911-
'count' => 1,
912-
'path' => __DIR__ . '/system/HTTP/DownloadResponse.php',
913-
];
914-
$ignoreErrors[] = [
915-
'message' => '#^Method CodeIgniter\\\\HTTP\\\\DownloadResponse\\:\\:setFilePath\\(\\) has no return type specified\\.$#',
916-
'count' => 1,
917-
'path' => __DIR__ . '/system/HTTP/DownloadResponse.php',
918-
];
919-
$ignoreErrors[] = [
920-
'message' => '#^Method CodeIgniter\\\\HTTP\\\\Files\\\\FileCollection\\:\\:populateFiles\\(\\) has no return type specified\\.$#',
921-
'count' => 1,
922-
'path' => __DIR__ . '/system/HTTP/Files/FileCollection.php',
923-
];
924854
$ignoreErrors[] = [
925855
'message' => '#^Expression on left side of \\?\\? is not nullable\\.$#',
926856
'count' => 1,
@@ -936,21 +866,6 @@
936866
'count' => 1,
937867
'path' => __DIR__ . '/system/HTTP/Files/UploadedFile.php',
938868
];
939-
$ignoreErrors[] = [
940-
'message' => '#^Method CodeIgniter\\\\HTTP\\\\Files\\\\UploadedFileInterface\\:\\:move\\(\\) has no return type specified\\.$#',
941-
'count' => 1,
942-
'path' => __DIR__ . '/system/HTTP/Files/UploadedFileInterface.php',
943-
];
944-
$ignoreErrors[] = [
945-
'message' => '#^Method CodeIgniter\\\\HTTP\\\\IncomingRequest\\:\\:detectLocale\\(\\) has no return type specified\\.$#',
946-
'count' => 1,
947-
'path' => __DIR__ . '/system/HTTP/IncomingRequest.php',
948-
];
949-
$ignoreErrors[] = [
950-
'message' => '#^Method CodeIgniter\\\\HTTP\\\\IncomingRequest\\:\\:detectURI\\(\\) has no return type specified\\.$#',
951-
'count' => 1,
952-
'path' => __DIR__ . '/system/HTTP/IncomingRequest.php',
953-
];
954869
$ignoreErrors[] = [
955870
'message' => '#^Property CodeIgniter\\\\HTTP\\\\Message\\:\\:\\$protocolVersion \\(string\\) on left side of \\?\\? is not nullable\\.$#',
956871
'count' => 1,
@@ -966,21 +881,6 @@
966881
'count' => 1,
967882
'path' => __DIR__ . '/system/HTTP/RedirectResponse.php',
968883
];
969-
$ignoreErrors[] = [
970-
'message' => '#^Method CodeIgniter\\\\HTTP\\\\Request\\:\\:populateGlobals\\(\\) has no return type specified\\.$#',
971-
'count' => 1,
972-
'path' => __DIR__ . '/system/HTTP/Request.php',
973-
];
974-
$ignoreErrors[] = [
975-
'message' => '#^Method CodeIgniter\\\\HTTP\\\\Response\\:\\:sendCookies\\(\\) has no return type specified\\.$#',
976-
'count' => 1,
977-
'path' => __DIR__ . '/system/HTTP/Response.php',
978-
];
979-
$ignoreErrors[] = [
980-
'message' => '#^Method CodeIgniter\\\\HTTP\\\\URI\\:\\:applyParts\\(\\) has no return type specified\\.$#',
981-
'count' => 1,
982-
'path' => __DIR__ . '/system/HTTP/URI.php',
983-
];
984884
$ignoreErrors[] = [
985885
'message' => '#^Property CodeIgniter\\\\HTTP\\\\URI\\:\\:\\$fragment \\(string\\) on left side of \\?\\? is not nullable\\.$#',
986886
'count' => 1,
@@ -996,16 +896,6 @@
996896
'count' => 1,
997897
'path' => __DIR__ . '/system/HTTP/URI.php',
998898
];
999-
$ignoreErrors[] = [
1000-
'message' => '#^Method CodeIgniter\\\\HTTP\\\\UserAgent\\:\\:compileData\\(\\) has no return type specified\\.$#',
1001-
'count' => 1,
1002-
'path' => __DIR__ . '/system/HTTP/UserAgent.php',
1003-
];
1004-
$ignoreErrors[] = [
1005-
'message' => '#^Method CodeIgniter\\\\HTTP\\\\UserAgent\\:\\:parse\\(\\) has no return type specified\\.$#',
1006-
'count' => 1,
1007-
'path' => __DIR__ . '/system/HTTP/UserAgent.php',
1008-
];
1009899
$ignoreErrors[] = [
1010900
'message' => '#^Right side of && is always true\\.$#',
1011901
'count' => 1,

system/HTTP/CLIRequest.php

+2
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,8 @@ public function getOptionString(bool $useLongOpts = false): string
175175
*
176176
* NOTE: I tried to use getopt but had it fail occasionally to find
177177
* any options, where argv has always had our back.
178+
*
179+
* @return void
178180
*/
179181
protected function parseCommand()
180182
{

system/HTTP/CURLRequest.php

+6
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,8 @@ public function request($method, string $url, array $options = []): ResponseInte
151151

152152
/**
153153
* Reset all options to default.
154+
*
155+
* @return void
154156
*/
155157
protected function resetOptions()
156158
{
@@ -277,6 +279,8 @@ public function setJSON($data)
277279
/**
278280
* Sets the correct settings based on the options array
279281
* passed in.
282+
*
283+
* @return void
280284
*/
281285
protected function parseOptions(array $options)
282286
{
@@ -479,6 +483,8 @@ protected function applyBody(array $curlOptions = []): array
479483
/**
480484
* Parses the header retrieved from the cURL response into
481485
* our Response object.
486+
*
487+
* @return void
482488
*/
483489
protected function setResponseHeaders(array $headers = [])
484490
{

system/HTTP/ContentSecurityPolicy.php

+10
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,8 @@ public function getScriptNonce(): string
298298
* Compiles and sets the appropriate headers in the request.
299299
*
300300
* Should be called just prior to sending the response to the user agent.
301+
*
302+
* @return void
301303
*/
302304
public function finalize(ResponseInterface $response)
303305
{
@@ -641,6 +643,8 @@ public function upgradeInsecureRequests(bool $value = true)
641643
* DRY method to add an string or array to a class property.
642644
*
643645
* @param array|string $options
646+
*
647+
* @return void
644648
*/
645649
protected function addOption($options, string $target, ?bool $explicitReporting = null)
646650
{
@@ -662,6 +666,8 @@ protected function addOption($options, string $target, ?bool $explicitReporting
662666
* Scans the body of the request message and replaces any nonce
663667
* placeholders with actual nonces, that we'll then add to our
664668
* headers.
669+
*
670+
* @return void
665671
*/
666672
protected function generateNonces(ResponseInterface $response)
667673
{
@@ -688,6 +694,8 @@ protected function generateNonces(ResponseInterface $response)
688694
* Based on the current state of the elements, will add the appropriate
689695
* Content-Security-Policy and Content-Security-Policy-Report-Only headers
690696
* with their values to the response object.
697+
*
698+
* @return void
691699
*/
692700
protected function buildHeaders(ResponseInterface $response)
693701
{
@@ -768,6 +776,8 @@ protected function buildHeaders(ResponseInterface $response)
768776
* reportOnly header, since it's viable to have both simultaneously.
769777
*
770778
* @param array|string|null $values
779+
*
780+
* @return void
771781
*/
772782
protected function addToHeader(string $name, $values = null)
773783
{

system/HTTP/DownloadResponse.php

+7-1
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ public function __construct(string $filename, bool $setMime)
7676

7777
/**
7878
* set download for binary string.
79+
*
80+
* @return void
7981
*/
8082
public function setBinary(string $binary)
8183
{
@@ -88,6 +90,8 @@ public function setBinary(string $binary)
8890

8991
/**
9092
* set download for file.
93+
*
94+
* @return void
9195
*/
9296
public function setFilePath(string $filepath)
9397
{
@@ -129,7 +133,7 @@ public function getContentLength(): int
129133
/**
130134
* Set content type by guessing mime type from file extension
131135
*/
132-
private function setContentTypeByMimeType()
136+
private function setContentTypeByMimeType(): void
133137
{
134138
$mime = null;
135139
$charset = '';
@@ -262,6 +266,8 @@ public function send()
262266

263267
/**
264268
* set header for file download.
269+
*
270+
* @return void
265271
*/
266272
public function buildHeaders()
267273
{

system/HTTP/Files/FileCollection.php

+2
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@ public function hasFile(string $fileID): bool
135135
* of UploadedFile for each one, saving the results to this->files.
136136
*
137137
* Called by files(), file(), and hasFile()
138+
*
139+
* @return void
138140
*/
139141
protected function populateFiles()
140142
{

system/HTTP/Files/UploadedFileInterface.php

+2
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ public function __construct(string $path, string $originalName, ?string $mimeTyp
5959
* @param string $targetPath Path to which to move the uploaded file.
6060
* @param string $name the name to rename the file to.
6161
*
62+
* @return bool
63+
*
6264
* @throws InvalidArgumentException if the $path specified is invalid.
6365
* @throws RuntimeException on any error during the move operation.
6466
* @throws RuntimeException on the second or subsequent call to the method.

system/HTTP/IncomingRequest.php

+4
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,8 @@ private function getPostMaxSize(): int
208208
* content negotiation.
209209
*
210210
* @param App $config
211+
*
212+
* @return void
211213
*/
212214
public function detectLocale($config)
213215
{
@@ -226,6 +228,8 @@ public function detectLocale($config)
226228
* determined from the environment as needed.
227229
*
228230
* @deprecated $protocol and $baseURL are deprecated. No longer used.
231+
*
232+
* @return void
229233
*/
230234
protected function detectURI(string $protocol, string $baseURL)
231235
{

system/HTTP/RequestTrait.php

+2
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,8 @@ public function fetchGlobal(string $method, $index = null, ?int $filter = null,
337337
/**
338338
* Saves a copy of the current state of one of several PHP globals
339339
* so we can retrieve them later.
340+
*
341+
* @return void
340342
*/
341343
protected function populateGlobals(string $method)
342344
{

system/HTTP/ResponseTrait.php

+2
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,8 @@ public function getCookies()
718718

719719
/**
720720
* Actually sets the cookies.
721+
*
722+
* @return void
721723
*/
722724
protected function sendCookies()
723725
{

system/HTTP/URI.php

+2
Original file line numberDiff line numberDiff line change
@@ -946,6 +946,8 @@ protected function filterPath(?string $path = null): string
946946

947947
/**
948948
* Saves our parts from a parse_url call.
949+
*
950+
* @return void
949951
*/
950952
protected function applyParts(array $parts)
951953
{

system/HTTP/UserAgent.php

+4
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,8 @@ public function getReferrer(): string
247247

248248
/**
249249
* Parse a custom user-agent string
250+
*
251+
* @return void
250252
*/
251253
public function parse(string $string)
252254
{
@@ -269,6 +271,8 @@ public function parse(string $string)
269271

270272
/**
271273
* Compile the User Agent Data
274+
*
275+
* @return void
272276
*/
273277
protected function compileData()
274278
{

0 commit comments

Comments
 (0)