Skip to content

Commit

Permalink
Add missing types
Browse files Browse the repository at this point in the history
Signed-off-by: ADmad <[email protected]>
  • Loading branch information
ADmad committed Nov 11, 2024
1 parent 746db20 commit 13a55f3
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 27 deletions.
12 changes: 4 additions & 8 deletions src/MessageTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,20 @@ trait MessageTrait
/**
* List of all registered headers, as key => array of values.
*
* @var array
* @psalm-var array<non-empty-string, list<string>>
*/
protected $headers = [];
protected array $headers = [];

/**
* Map of normalized header name to original name used to register header.
*
* @var array
* @psalm-var array<non-empty-string, non-empty-string>
*/
protected $headerNames = [];
protected array $headerNames = [];

/** @var string */
private $protocol = '1.1';
private string $protocol = '1.1';

/** @var StreamInterface */
private $stream;
private StreamInterface $stream;

/**
* Retrieves the HTTP protocol version as a string.
Expand Down
3 changes: 1 addition & 2 deletions src/Request/ArraySerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,9 @@ public static function fromArray(array $serializedRequest): Request
}

/**
* @return mixed
* @throws Exception\DeserializationException
*/
private static function getValueFromKey(array $data, string $key, ?string $message = null)
private static function getValueFromKey(array $data, string $key, ?string $message = null): mixed
{
if (isset($data[$key])) {
return $data[$key];
Expand Down
10 changes: 3 additions & 7 deletions src/RequestTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,14 @@ trait RequestTrait
{
use MessageTrait;

/** @var string */
private $method = 'GET';
private string $method = 'GET';

/**
* The request-target, if it has been provided or calculated.
*
* @var null|string
*/
private $requestTarget;
private ?string $requestTarget = null;

/** @var UriInterface */
private $uri;
private UriInterface $uri;

/**
* Initialize request state.
Expand Down
3 changes: 1 addition & 2 deletions src/Response/ArraySerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,9 @@ public static function fromArray(array $serializedResponse): Response
}

/**
* @return mixed
* @throws Exception\DeserializationException
*/
private static function getValueFromKey(array $data, string $key, ?string $message = null)
private static function getValueFromKey(array $data, string $key, ?string $message = null): mixed
{
if (isset($data[$key])) {
return $data[$key];
Expand Down
10 changes: 3 additions & 7 deletions src/Response/JsonResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ class JsonResponse extends Response
| JSON_HEX_QUOT
| JSON_UNESCAPED_SLASHES;

/** @var mixed */
private $payload;
private mixed $payload;

/**
* Create a JSON response with the given data.
Expand All @@ -65,7 +64,7 @@ class JsonResponse extends Response
* @throws Exception\InvalidArgumentException If unable to encode the $data to JSON.
*/
public function __construct(
$data,
mixed $data,
int $status = 200,
array $headers = [],
private int $encodingOptions = self::DEFAULT_JSON_FLAGS
Expand All @@ -80,10 +79,7 @@ public function __construct(
parent::__construct($body, $status, $headers);
}

/**
* @return mixed
*/
public function getPayload()
public function getPayload(): mixed
{
return $this->payload;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Uri.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class Uri implements UriInterface, Stringable
public const CHAR_UNRESERVED = 'a-zA-Z0-9_\-\.~\pL';

/** @var int[] Array indexed by valid scheme names to their corresponding ports. */
protected $allowedSchemes = [
protected array $allowedSchemes = [
'http' => 80,
'https' => 443,
];
Expand Down

0 comments on commit 13a55f3

Please sign in to comment.