Skip to content
Merged
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
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
}
],
"config": {
"process-timeout": 0,
"allow-plugins": {
"phpstan/extension-installer": true,
"pestphp/pest-plugin": true
Expand Down
6 changes: 2 additions & 4 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
includes:
- phar://phpstan.phar/conf/bleedingEdge.neon

parameters:
level: 5
level: 6
paths:
- src
treatPhpDocTypesAsCertain: false
2 changes: 2 additions & 0 deletions src/Client/ArtemeonHttpClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ final public function send(Request $request, ?ClientOptions $clientOptions = nul
* -------- 2. GuzzleClientException -> ClientResponseException
* ```
*
* @param array<array-key, mixed> $guzzleOptions
*
* @throws HttpClientException
*/
private function doSend(Request $request, array $guzzleOptions): Response
Expand Down
2 changes: 2 additions & 0 deletions src/Client/Decorator/OAuth2/ClientCredentials.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ public static function forHeaderAuthorization(string $clientId, string $clientSe

/**
* Creates the required key => value pairs for the Access Token Request.
*
* @return array<string, mixed>
*/
public function toArray(bool $includeClientCredentials = true): array
{
Expand Down
8 changes: 7 additions & 1 deletion src/Client/HttpClientTestFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,15 @@
*/
class HttpClientTestFactory
{
/**
* @var array<int, array<string, mixed>>
*/
private array $transactionLog = [];
private readonly MockHandler $mockHandler;
private static HttpClientTestFactory $instance;

public function __construct()
{
$this->transactionLog = [];
$this->mockHandler = new MockHandler();
}

Expand Down Expand Up @@ -111,6 +113,8 @@ public static function withMockHandler(): HttpClient
/**
* Register the responses to mock.
*
* @param list<ResponseInterface> $responses
*
* @throws InvalidArgumentException
*/
public static function mockResponses(array $responses): void
Expand All @@ -128,6 +132,8 @@ public static function mockResponses(array $responses): void

/**
* Return the recorded transaction log array.
*
* @return array<int, array<string, mixed>>
*/
public static function getTransactionLog(): array
{
Expand Down
4 changes: 4 additions & 0 deletions src/Client/Options/ClientOptionsConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ class ClientOptionsConverter
{
/**
* Converts the given ClientOptions to the guzzle options array format.
*
* @return array<string, mixed>
*/
public function toGuzzleOptionsArray(ClientOptions $clientOptions): array
{
Expand Down Expand Up @@ -60,6 +62,8 @@ private function createVerifyKey(ClientOptions $clientOptions): bool | string

/**
* @see http://docs.guzzlephp.org/en/6.5/request-options.html#allow-redirects
*
* @return array{max:int,referer:bool}|false
*/
private function createAllowRedirectsKey(ClientOptions $clientOptions): array | false
{
Expand Down
4 changes: 2 additions & 2 deletions src/Http/Body/Encoder/FormUrlEncoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class FormUrlEncoder implements Encoder
/**
* FormUrlEncoder constructor.
*
* @param array $formValues Array with the form values to encode: ['formFieldName' = 'value'],
* @param array<string, mixed> $formValues Array with the form values to encode: ['formFieldName' = 'value'],
*/
private function __construct(private readonly array $formValues)
{
Expand All @@ -40,7 +40,7 @@ private function __construct(private readonly array $formValues)
* $encoder->encode();
* ```
*
* @param array $formValues ['formFieldName' = 'value'],
* @param array<string, mixed> $formValues ['formFieldName' = 'value'],
*/
public static function fromArray(array $formValues): self
{
Expand Down
3 changes: 2 additions & 1 deletion src/Http/Body/Encoder/JsonEncoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
class JsonEncoder implements Encoder
{
/**
* @param array<array-key, mixed>|object $value
* @param int $options Optional json encode options: @see https://www.php.net/manual/de/function.json-encode.php
* @param string $mimeType Optional custom mime type
*/
Expand All @@ -51,7 +52,7 @@ private function __construct(
* $encoder->encode();
* ```
*
* @param array $value Array to encode, associative array always encoded as json object
* @param array<array-key, mixed> $value Array to encode, associative array always encoded as json object
* @param int $options Optional Bitmask of json constants: @see https://www.php.net/manual/en/function.json-encode.php
* @param string $mimeType Optional custom mime type
*/
Expand Down
16 changes: 13 additions & 3 deletions src/Http/Header/Header.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
class Header
{
private readonly string $name;

/**
* @var array<array-key, string>
*/
private array $values;

/**
Expand Down Expand Up @@ -50,7 +54,7 @@ public static function fromString(string $name, string $value): self
* Named constructor to create an instance based on the given string[] values.
*
* @param string $name Name of the http header field
* @param array $values Array of header values
* @param array<array-key, string> $values Array of header values
* @throws InvalidArgumentException
*/
public static function fromArray(string $name, array $values): self
Expand Down Expand Up @@ -89,7 +93,7 @@ public function addValue(string $value): void
/**
* Add an array of values to the header, doublets will be skipped.
*
* @param array $values The string value to add
* @param array<array-key, string> $values The string values to add
*/
public function addValues(array $values): void
{
Expand All @@ -105,6 +109,8 @@ public function addValues(array $values): void

/**
* Returns all value of the http header field.
*
* @return array<array-key, string>
*/
public function getValues(): array
{
Expand All @@ -122,7 +128,11 @@ public function getValue(): string
/**
* Check and normalize header values.
*
* @param non-empty-array<array-key, string> $values
*
* @throws InvalidArgumentException
*
* @return non-empty-array<array-key, string>
*/
private function assertValues(array $values): array
{
Expand All @@ -139,7 +149,7 @@ private function assertValues(array $values): array
}
}

return $values;
return array_values($values);
}

/**
Expand Down
4 changes: 4 additions & 0 deletions src/Http/Header/Headers.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

/**
* Header collection class for http requests and responses.
*
* @implements IteratorAggregate<array-key, Header>
*/
class Headers implements Countable, IteratorAggregate
{
Expand Down Expand Up @@ -152,6 +154,8 @@ public function get(string $headerField): Header

/**
* @inheritDoc
*
* @return ArrayIterator<array-key, Header>
*/
#[Override]
public function getIterator(): ArrayIterator
Expand Down
2 changes: 2 additions & 0 deletions src/Http/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@ public function withBody(StreamInterface $body): MessageInterface
/**
* Checks the header data.
*
* @param array<array-key, mixed>|float|int|string $value
*
* @throws InvalidArgumentException
*/
private function assertHeader(string $name, array | float | int | string $value): void
Expand Down
13 changes: 6 additions & 7 deletions src/Http/Uri.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ private function __construct(string $uri)
* Named constructor to create an instance based on the given url and query params.
*
* @param string $uri Url string with protocol
* @param array $queryParams Query params array: ["varName" => value]
* @param array<string, mixed> $queryParams Query params array: ["varName" => value]
* @throws InvalidArgumentException
*/
public static function fromQueryParams(string $uri, array $queryParams): self
Expand Down Expand Up @@ -260,6 +260,9 @@ private function filterUserInfoComponent(string $component): string
);
}

/**
* @param string[] $match
*/
private function rawurlencodeMatchZero(array $match): string
{
return rawurlencode((string) $match[0]);
Expand Down Expand Up @@ -293,7 +296,7 @@ public function withPort(?int $port): self
* @inheritDoc
*/
#[Override]
public function withPath(array | bool | int | string $path): self
public function withPath(string $path): self
{
$cloned = clone $this;
$cloned->path = $cloned->filterPath($path);
Expand Down Expand Up @@ -367,12 +370,8 @@ private function filterHost(string $host): string
*
* @throws InvalidArgumentException
*/
private function filterPath(array | bool | int | string $path): string
private function filterPath(string $path): string
{
if (!is_string($path)) {
throw new InvalidArgumentException('path must be a string');
}

$pattern = '/(?:[^' . self::UNRESERVED . self::DELIMITER . "%:@\/]++|%(?![A-Fa-f0-9]{2}))/";

return preg_replace_callback($pattern, [$this, 'encode'], $path);
Expand Down
2 changes: 2 additions & 0 deletions src/Stream/Stream.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ class Stream implements AppendableStream

/**
* @see https://www.php.net/manual/de/function.stream-get-meta-data
*
* @var array<string, mixed>
*/
private array $metaData;

Expand Down