Skip to content

Commit

Permalink
qa: fixes as proposed by Marco
Browse files Browse the repository at this point in the history
- Better return value annotations
- Removal of unnecessary note
- Refactor to reduce need for temporary values

Signed-off-by: Matthew Weier O'Phinney <matthew@weierophinney.net>
  • Loading branch information
weierophinney committed Jun 27, 2022
1 parent 80fc3de commit 0aa29ba
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions src/ServerRequestFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,17 +114,14 @@ private static function marshalUriFromSapi(array $server) : Uri
$uri = new Uri('');

// URI scheme
$scheme = 'http';
$https = false;
if (array_key_exists('HTTPS', $server)) {
$https = self::marshalHttpsValue($server['HTTPS']);
} elseif (array_key_exists('https', $server)) {
$https = self::marshalHttpsValue($server['https']);
} else {
$https = false;
}

$scheme = $https ? 'https' : $scheme;
$uri = $uri->withScheme($scheme);
$uri = $uri->withScheme($https ? 'https' : 'http');

// Set the host
[$host, $port] = self::marshalHostAndPort($server);
Expand Down Expand Up @@ -162,8 +159,8 @@ private static function marshalUriFromSapi(array $server) : Uri
/**
* Marshal the host and port from the PHP environment.
*
* @return array Array of two items, host and port, in that order (can be
* passed to a list() operation).
* @return array{string, numeric-string} Array of two items, host and port,
* in that order (can be passed to a list() operation).
*/
private static function marshalHostAndPort(array $server) : array
{
Expand All @@ -188,8 +185,8 @@ private static function marshalHostAndPort(array $server) : array
}

/**
* @return array Array of two items, host and port, in that order (can be
* passed to a list() operation).
* @return array{string, numeric-string} Array of two items, host and port,
* in that order (can be passed to a list() operation).
*/
private static function marshalIpv6HostAndPort(array $server, ?int $port) : array
{
Expand All @@ -212,8 +209,6 @@ private static function marshalIpv6HostAndPort(array $server, ?int $port) : arra
* - IIS7 UrlRewrite environment
* - REQUEST_URI
* - ORIG_PATH_INFO
*
* From Laminas\Http\PhpEnvironment\Request class
*/
private static function marshalRequestPath(array $server) : string
{
Expand Down

0 comments on commit 0aa29ba

Please sign in to comment.