Merge commit '9cdea437947ed233feab875b2a6d30a68b8648fe'

This commit is contained in:
Dylan K. Taylor 2020-01-31 18:21:32 +00:00
commit 86f866de37

View File

@ -134,12 +134,15 @@ class Internet{
* GETs an URL using cURL
* NOTE: This is a blocking operation and can take a significant amount of time. It is inadvisable to use this method on the main thread.
*
* @param int $timeout default 10
* @param string $err reference parameter, will be set to the output of curl_error(). Use this to retrieve errors that occured during the operation.
* @param array[] $headers reference parameter
* @param int $httpCode reference parameter
* @param int $timeout default 10
* @param string[] $extraHeaders
* @param string $err reference parameter, will be set to the output of curl_error(). Use this to retrieve errors that occured during the operation.
* @param string[] $headers reference parameter
* @param int $httpCode reference parameter
* @phpstan-param list<string> $extraHeaders
* @phpstan-param array<string, string> $headers
*
* @return bool|mixed false if an error occurred, mixed data if successful.
* @return string|false
*/
public static function getURL(string $page, int $timeout = 10, array $extraHeaders = [], &$err = null, &$headers = null, &$httpCode = null){
try{
@ -155,12 +158,16 @@ class Internet{
* POSTs data to an URL
* NOTE: This is a blocking operation and can take a significant amount of time. It is inadvisable to use this method on the main thread.
*
* @param array|string $args
* @param string $err reference parameter, will be set to the output of curl_error(). Use this to retrieve errors that occured during the operation.
* @param array[] $headers reference parameter
* @param int $httpCode reference parameter
* @param string[]|string $args
* @param string[] $extraHeaders
* @param string $err reference parameter, will be set to the output of curl_error(). Use this to retrieve errors that occured during the operation.
* @param string[] $headers reference parameter
* @param int $httpCode reference parameter
* @phpstan-param string|array<string, string> $args
* @phpstan-param list<string> $extraHeaders
* @phpstan-param array<string, string> $headers
*
* @return bool|mixed false if an error occurred, mixed data if successful.
* @return string|false
*/
public static function postURL(string $page, $args, int $timeout = 10, array $extraHeaders = [], &$err = null, &$headers = null, &$httpCode = null){
try{
@ -181,11 +188,14 @@ class Internet{
*
* @param float|int $timeout The maximum connect timeout and timeout in seconds, correct to ms.
* @param string[] $extraHeaders extra headers to send as a plain string array
* @param array $extraOpts extra CURLOPT_* to set as an [opt => value] map
* @param \Closure|null $onSuccess function to be called if there is no error. Accepts a resource argument as the cURL handle.
* @param array $extraOpts extra CURLOPT_* to set as an [opt => value] map
* @param \Closure|null $onSuccess function to be called if there is no error. Accepts a resource argument as the cURL handle.
* @phpstan-param array<int, mixed> $extraOpts
* @phpstan-param list<string> $extraHeaders
* @phpstan-param (\Closure(resource) : void)|null $onSuccess
*
* @return array a plain array of three [result body : string, headers : array[], HTTP response code : int]. Headers are grouped by requests with strtolower(header name) as keys and header value as values
* @return array a plain array of three [result body : string, headers : string[][], HTTP response code : int]. Headers are grouped by requests with strtolower(header name) as keys and header value as values
* @phpstan-return array{string, list<array<string, string>>, int}
*
* @throws InternetException if a cURL error occurs
*/