Skip to content
This repository was archived by the owner on Jun 4, 2025. It is now read-only.

Commit b154d0e

Browse files
committed
Some Psalm level 1
1 parent 4854503 commit b154d0e

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

src/Message.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ abstract class Message
2222
* The keys represent the lowercase header name, and
2323
* each value is an array of strings associated with the header.
2424
*
25-
* @var array
25+
* @var array<string, list<string>>
2626
*/
2727
protected array $headers = [];
2828

@@ -64,7 +64,7 @@ public function withProtocolVersion(string $version): Message
6464
* The keys represent the header name as it will be sent over the wire, and
6565
* each value is an array of strings associated with the header.
6666
*
67-
* @return array
67+
* @return array<string, list<string>>
6868
*/
6969
public function getHeaders() : array
7070
{

src/Request.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ public static function getCurrent(bool $trustProxy = false, int $hostPortSource
127127
{
128128
$request = new Request();
129129

130+
/** @var array<string, string> $_SERVER */
131+
130132
if (isset($_SERVER['HTTPS'])) {
131133
if ($_SERVER['HTTPS'] === 'on' || $_SERVER['HTTPS'] === '1') {
132134
$request->isSecure = true;
@@ -253,13 +255,14 @@ public static function getCurrent(bool $trustProxy = false, int $hostPortSource
253255
* - keys are lowercased
254256
* - values are arrays of strings
255257
*
256-
* @return array
258+
* @return array<string, list<string>>
257259
*/
258260
private static function getCurrentRequestHeaders() : array
259261
{
260262
$headers = [];
261263

262264
if (function_exists('apache_request_headers')) {
265+
/** @var array<string, string> $requestHeaders */
263266
$requestHeaders = apache_request_headers();
264267

265268
if ($requestHeaders) {
@@ -272,6 +275,8 @@ private static function getCurrentRequestHeaders() : array
272275
}
273276
}
274277

278+
/** @var array<string, string> $_SERVER */
279+
275280
foreach ($_SERVER as $key => $value) {
276281
if (substr($key, 0, 5) === 'HTTP_') {
277282
$key = substr($key, 5);
@@ -1175,6 +1180,7 @@ private function parseQualityValues(string $header) : array
11751180
{
11761181
$values = $this->parseHeaderParameters($header);
11771182

1183+
/** @psalm-var list<array{string, float, int}> $result */
11781184
$result = [];
11791185

11801186
$count = count($values);
@@ -1216,11 +1222,12 @@ private function parseQualityValues(string $header) : array
12161222
/**
12171223
* Parses a header with multiple values and optional parameters.
12181224
*
1219-
* Example: text/html; charset=utf8, text/xml => ['text/html' => ['charset' => 'utf8'], 'text/xml' => []]
1225+
* Example: text/html; charset=utf8, text/xml
1226+
* => ['text/html' => ['charset' => 'utf8'], 'text/xml' => []]
12201227
*
12211228
* @param string $header The header to parse.
12221229
*
1223-
* @return array An associative array of values and theirs parameters.
1230+
* @return array<string, array<string, string>> An associative array of values and theirs parameters.
12241231
*/
12251232
private function parseHeaderParameters(string $header) : array
12261233
{

0 commit comments

Comments
 (0)