Skip to content

Commit 873417a

Browse files
committed
Add more specific return types for the HTTP API functions.
1 parent 956d2c2 commit 873417a

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

additionalParams.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
$httpReturnType = 'array{headers:array,body:string,response:array{code:int,message:string},cookies:WP_HTTP_Cookie[],filename:string|null}|WP_Error';
4+
5+
return [
6+
'wp_remote_get' => [$httpReturnType, 'url'=>'string', 'args'=>'array'],
7+
'wp_remote_head' => [$httpReturnType, 'url'=>'string', 'args'=>'array'],
8+
'wp_remote_post' => [$httpReturnType, 'url'=>'string', 'args'=>'array'],
9+
'wp_remote_request' => [$httpReturnType, 'url'=>'string', 'args'=>'array'],
10+
];

wordpress-stubs.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104097,6 +104097,9 @@ function wp_safe_remote_head($url, $args = array())
104097104097
* cookies: WP_HTTP_Cookie[],
104098104098
* http_response: WP_HTTP_Requests_Response|null,
104099104099
* }
104100+
* @phpstan-param string $url
104101+
* @phpstan-param array $args
104102+
* @phpstan-return array{headers:array,body:string,response:array{code:int,message:string},cookies:WP_HTTP_Cookie[],filename:string|null}|WP_Error
104100104103
*/
104101104104
function wp_remote_request($url, $args = array())
104102104105
{
@@ -104112,6 +104115,9 @@ function wp_remote_request($url, $args = array())
104112104115
* @param string $url URL to retrieve.
104113104116
* @param array $args Optional. Request arguments. Default empty array.
104114104117
* @return array|WP_Error The response or WP_Error on failure.
104118+
* @phpstan-param string $url
104119+
* @phpstan-param array $args
104120+
* @phpstan-return array{headers:array,body:string,response:array{code:int,message:string},cookies:WP_HTTP_Cookie[],filename:string|null}|WP_Error
104115104121
*/
104116104122
function wp_remote_get($url, $args = array())
104117104123
{
@@ -104127,6 +104133,9 @@ function wp_remote_get($url, $args = array())
104127104133
* @param string $url URL to retrieve.
104128104134
* @param array $args Optional. Request arguments. Default empty array.
104129104135
* @return array|WP_Error The response or WP_Error on failure.
104136+
* @phpstan-param string $url
104137+
* @phpstan-param array $args
104138+
* @phpstan-return array{headers:array,body:string,response:array{code:int,message:string},cookies:WP_HTTP_Cookie[],filename:string|null}|WP_Error
104130104139
*/
104131104140
function wp_remote_post($url, $args = array())
104132104141
{
@@ -104142,6 +104151,9 @@ function wp_remote_post($url, $args = array())
104142104151
* @param string $url URL to retrieve.
104143104152
* @param array $args Optional. Request arguments. Default empty array.
104144104153
* @return array|WP_Error The response or WP_Error on failure.
104154+
* @phpstan-param string $url
104155+
* @phpstan-param array $args
104156+
* @phpstan-return array{headers:array,body:string,response:array{code:int,message:string},cookies:WP_HTTP_Cookie[],filename:string|null}|WP_Error
104145104157
*/
104146104158
function wp_remote_head($url, $args = array())
104147104159
{

0 commit comments

Comments
 (0)