Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 31 additions & 25 deletions system/HTTP/CLIRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,21 @@ class CLIRequest extends Request
/**
* Stores the segments of our cli "URI" command.
*
* @var array
* @var list<string>
*/
protected $segments = [];

/**
* Command line options and their values.
*
* @var array
* @var array<string, bool|string>
*/
protected $options = [];

/**
* Command line arguments (segments and options).
*
* @var array
* @var array<array-key, bool|string>
*/
protected $args = [];

Expand Down Expand Up @@ -101,6 +101,8 @@ public function getPath(): string
/**
* Returns an associative array of all CLI options found, with
* their values.
*
* @return array<string, bool|string>
*/
public function getOptions(): array
{
Expand All @@ -109,6 +111,8 @@ public function getOptions(): array

/**
* Returns an array of all CLI arguments (segments and options).
*
* @return array<array-key, bool|string>
*/
public function getArgs(): array
{
Expand All @@ -117,6 +121,8 @@ public function getArgs(): array

/**
* Returns the path segments.
*
* @return list<string>
*/
public function getSegments(): array
{
Expand Down Expand Up @@ -226,11 +232,11 @@ public function isCLI(): bool
/**
* Fetch an item from GET data.
*
* @param array|string|null $index Index for item to fetch from $_GET.
* @param int|null $filter A filter name to apply.
* @param array|int|null $flags
* @param list<string>|string|null $index Index for item to fetch from $_GET.
* @param int|null $filter A filter name to apply.
* @param array<string, mixed>|int|null $flags
*
* @return array|null
* @return array{}|null
*/
public function getGet($index = null, $filter = null, $flags = null)
{
Expand All @@ -240,11 +246,11 @@ public function getGet($index = null, $filter = null, $flags = null)
/**
* Fetch an item from POST.
*
* @param array|string|null $index Index for item to fetch from $_POST.
* @param int|null $filter A filter name to apply
* @param array|int|null $flags
* @param list<string>|string|null $index Index for item to fetch from $_POST.
* @param int|null $filter A filter name to apply
* @param array<string, mixed>|int|null $flags
*
* @return array|null
* @return array{}|null
*/
public function getPost($index = null, $filter = null, $flags = null)
{
Expand All @@ -254,11 +260,11 @@ public function getPost($index = null, $filter = null, $flags = null)
/**
* Fetch an item from POST data with fallback to GET.
*
* @param array|string|null $index Index for item to fetch from $_POST or $_GET
* @param int|null $filter A filter name to apply
* @param array|int|null $flags
* @param list<string>|string|null $index Index for item to fetch from $_POST or $_GET
* @param int|null $filter A filter name to apply
* @param array<string, mixed>|int|null $flags
*
* @return array|null
* @return array{}|null
*/
public function getPostGet($index = null, $filter = null, $flags = null)
{
Expand All @@ -268,11 +274,11 @@ public function getPostGet($index = null, $filter = null, $flags = null)
/**
* Fetch an item from GET data with fallback to POST.
*
* @param array|string|null $index Index for item to be fetched from $_GET or $_POST
* @param int|null $filter A filter name to apply
* @param array|int|null $flags
* @param list<string>|string|null $index Index for item to be fetched from $_GET or $_POST
* @param int|null $filter A filter name to apply
* @param array<string, mixed>|int|null $flags
*
* @return array|null
* @return array{}|null
*/
public function getGetPost($index = null, $filter = null, $flags = null)
{
Expand All @@ -282,21 +288,21 @@ public function getGetPost($index = null, $filter = null, $flags = null)
/**
* This is a place holder for calls from cookie_helper get_cookie().
*
* @param array|string|null $index Index for item to be fetched from $_COOKIE
* @param int|null $filter A filter name to be applied
* @param mixed $flags
* @param list<string>|string|null $index Index for item to be fetched from $_COOKIE
* @param int|null $filter A filter name to be applied
* @param mixed $flags
*
* @return array|null
* @return array{}|null
*/
public function getCookie($index = null, $filter = null, $flags = null)
{
return $this->returnNullOrEmptyArray($index);
}

/**
* @param array|string|null $index
* @param list<string>|string|null $index
*
* @return array|null
* @return array{}|null
*/
private function returnNullOrEmptyArray($index)
{
Expand Down
49 changes: 43 additions & 6 deletions system/HTTP/CURLRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ class CURLRequest extends OutgoingRequest
/**
* The setting values
*
* @var array
* @var array<string, mixed>
*/
protected $config;

/**
* The default setting values
*
* @var array
* @var array<string, mixed>
*/
protected $defaultConfig = [
'timeout' => 0.0,
Expand All @@ -71,7 +71,7 @@ class CURLRequest extends OutgoingRequest
* Default values for when 'allow_redirects'
* option is true.
*
* @var array
* @var array<string, mixed>
*/
protected $redirectDefaults = [
'max' => 5,
Expand All @@ -92,6 +92,8 @@ class CURLRequest extends OutgoingRequest

/**
* The default options from the constructor. Applied to all requests.
*
* @var array<string, mixed>
*/
private readonly array $defaultOptions;

Expand Down Expand Up @@ -156,7 +158,8 @@ public function __construct(App $config, URI $uri, ?ResponseInterface $response
* Sends an HTTP request to the specified $url. If this is a relative
* URL, it will be merged with $this->baseURI to form a complete URL.
*
* @param string $method HTTP method
* @param string $method HTTP method
* @param array<string, mixed> $options
*/
public function request($method, string $url, array $options = []): ResponseInterface
{
Expand Down Expand Up @@ -200,6 +203,8 @@ protected function resetOptions()

/**
* Convenience method for sending a GET request.
*
* @param array<string, mixed> $options
*/
public function get(string $url, array $options = []): ResponseInterface
{
Expand All @@ -208,6 +213,8 @@ public function get(string $url, array $options = []): ResponseInterface

/**
* Convenience method for sending a DELETE request.
*
* @param array<string, mixed> $options
*/
public function delete(string $url, array $options = []): ResponseInterface
{
Expand All @@ -216,6 +223,8 @@ public function delete(string $url, array $options = []): ResponseInterface

/**
* Convenience method for sending a HEAD request.
*
* @param array<string, mixed> $options
*/
public function head(string $url, array $options = []): ResponseInterface
{
Expand All @@ -224,6 +233,8 @@ public function head(string $url, array $options = []): ResponseInterface

/**
* Convenience method for sending an OPTIONS request.
*
* @param array<string, mixed> $options
*/
public function options(string $url, array $options = []): ResponseInterface
{
Expand All @@ -232,6 +243,8 @@ public function options(string $url, array $options = []): ResponseInterface

/**
* Convenience method for sending a PATCH request.
*
* @param array<string, mixed> $options
*/
public function patch(string $url, array $options = []): ResponseInterface
{
Expand All @@ -240,6 +253,8 @@ public function patch(string $url, array $options = []): ResponseInterface

/**
* Convenience method for sending a POST request.
*
* @param array<string, mixed> $options
*/
public function post(string $url, array $options = []): ResponseInterface
{
Expand All @@ -248,6 +263,8 @@ public function post(string $url, array $options = []): ResponseInterface

/**
* Convenience method for sending a PUT request.
*
* @param array<string, mixed> $options
*/
public function put(string $url, array $options = []): ResponseInterface
{
Expand All @@ -271,7 +288,8 @@ public function setAuth(string $username, #[SensitiveParameter] string $password
/**
* Set form data to be sent.
*
* @param bool $multipart Set TRUE if you are sending CURLFiles
* @param bool $multipart Set TRUE if you are sending CURLFiles
* @param array<string, mixed> $params
*
* @return $this
*/
Expand Down Expand Up @@ -304,6 +322,8 @@ public function setJSON($data)
* Sets the correct settings based on the options array
* passed in.
*
* @param array<string, mixed> $options
*
* @return void
*/
protected function parseOptions(array $options)
Expand Down Expand Up @@ -430,6 +450,10 @@ public function send(string $method, string $url)

/**
* Adds $this->headers to the cURL request.
*
* @param array<int, mixed> $curlOptions
*
* @return array<int, mixed>
*/
protected function applyRequestHeaders(array $curlOptions = []): array
{
Expand All @@ -450,6 +474,10 @@ protected function applyRequestHeaders(array $curlOptions = []): array

/**
* Apply method
*
* @param array<int, mixed> $curlOptions
*
* @return array<int, mixed>
*/
protected function applyMethod(string $method, array $curlOptions): array
{
Expand Down Expand Up @@ -477,6 +505,10 @@ protected function applyMethod(string $method, array $curlOptions): array

/**
* Apply body
*
* @param array<int, mixed> $curlOptions
*
* @return array<int, mixed>
*/
protected function applyBody(array $curlOptions = []): array
{
Expand All @@ -491,6 +523,8 @@ protected function applyBody(array $curlOptions = []): array
* Parses the header retrieved from the cURL response into
* our Response object.
*
* @param list<string> $headers
*
* @return void
*/
protected function setResponseHeaders(array $headers = [])
Expand Down Expand Up @@ -522,7 +556,10 @@ protected function setResponseHeaders(array $headers = [])
/**
* Set CURL options
*
* @return array
* @param array<int, mixed> $curlOptions
* @param array<string, mixed> $config
*
* @return array<int, mixed>
*
* @throws InvalidArgumentException
*/
Expand Down
16 changes: 11 additions & 5 deletions system/HTTP/Files/FileCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class FileCollection
* Populated the first time either files(), file(), or hasFile()
* is called.
*
* @var array|null
* @var array<string, array<array-key, UploadedFile>|UploadedFile>|null
*/
protected $files;

Expand All @@ -40,7 +40,7 @@ class FileCollection
* Each element in the array will be an instance of UploadedFile.
* The key of each element will be the client filename.
*
* @return array|null
* @return array<string, array<array-key, UploadedFile>|UploadedFile>|null
*/
public function all()
{
Expand Down Expand Up @@ -167,7 +167,9 @@ protected function populateFiles()
* Given a file array, will create UploadedFile instances. Will
* loop over an array and create objects for each.
*
* @return list<UploadedFile>|UploadedFile
* @param array<string, mixed> $array
*
* @return array<array-key, array<array-key, UploadedFile>|UploadedFile>|UploadedFile
*/
protected function createFileObject(array $array)
{
Expand Down Expand Up @@ -203,6 +205,10 @@ protected function createFileObject(array $array)
* of this method.
*
* @see http://php.net/manual/en/reserved.variables.files.php#118294
*
* @param array<string, mixed> $data
*
* @return array<string, mixed>
*/
protected function fixFilesArray(array $data): array
{
Expand Down Expand Up @@ -246,8 +252,8 @@ protected function fixFilesArray(array $data): array
/**
* Navigate through an array looking for a particular index
*
* @param array $index The index sequence we are navigating down
* @param array $value The portion of the array to process
* @param list<string> $index The index sequence we are navigating down
* @param array<array-key, array<array-key, UploadedFile>|UploadedFile> $value The portion of the array to process
*
* @return list<UploadedFile>|UploadedFile|null
*/
Expand Down
7 changes: 0 additions & 7 deletions system/HTTP/Files/UploadedFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,6 @@ class UploadedFile extends File implements UploadedFileInterface
*/
protected $name;

/**
* The type of file as provided by PHP
*
* @var string
*/
protected $originalMimeType;

/**
* The error constant of the upload
* (one of PHP's UPLOADERRXXX constants)
Expand Down
Loading
Loading