Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Commit

Permalink
Merge branch 'hotfix/function_imports' into release-2.0
Browse files Browse the repository at this point in the history
Conflicts:
	src/functions/marshal_headers_from_sapi.php
	src/functions/marshal_protocol_version_from_sapi.php
	src/functions/marshal_uri_from_sapi.php
	src/functions/normalize_server.php
	src/functions/normalize_uploaded_files.php
	src/functions/parse_cookie_header.php
  • Loading branch information
weierophinney committed Jun 27, 2018
2 parents 146be7b + 1fbad75 commit 883d290
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 15 deletions.
19 changes: 18 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,24 @@ All notable changes to this project will be documented in this file, in reverse

### Added

- Nothing.
- [#307](https://github.com/zendframework/zend-diactoros/pull/307) adds the following functions under the `Zend\Diactoros` namespace, each of
which may be used to derive artifacts from SAPI supergloabls for the purposes
of generating a `ServerRequest` instance:
- `normalizeServer(array $server, callable $apacheRequestHeaderCallback = null) : array`
(main purpose is to aggregate the `Authorization` header in the SAPI params
when under Apache)
- `marshalProtocolVersionFromSapi(array $server) : string`
- `marshalMethodFromSapi(array $server) : string`
- `marshalUriFromSapi(array $server, array $headers) : Uri`
- `marshalHeadersFromSapi(array $server) : array`
- `parseCookieHeader(string $header) : array`
- `createUploadedFile(array $spec) : UploadedFile` (creates the instance from
a normal `$_FILES` entry)
- `normalizeUploadedFiles(array $files) : UploadedFileInterface[]` (traverses
a potentially nested array of uploaded file instances and/or `$_FILES`
entries, including those aggregated under mod_php, php-fpm, and php-cgi in
order to create a flat array of `UploadedFileInterface` instances to use in a
request)

### Changed

Expand Down
13 changes: 0 additions & 13 deletions src/ServerRequestFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,13 @@

use function array_change_key_case;
use function array_key_exists;
use function array_keys;
use function explode;
use function implode;
use function is_array;
use function is_callable;
use function ltrim;
use function preg_match;
use function preg_match_all;
use function preg_replace;
use function sprintf;
use function strlen;
use function strpos;
use function strrpos;
use function strtolower;
use function strtr;
use function substr;
use function urldecode;

use const CASE_LOWER;
use const PREG_SET_ORDER;

/**
* Class for marshaling a request object from the current PHP environment.
Expand Down
6 changes: 6 additions & 0 deletions src/functions/marshal_headers_from_sapi.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@

namespace Zend\Diactoros;

use function array_key_exists;
use function strpos;
use function strtolower;
use function strtr;
use function substr;

/**
* @param array $server Values obtained from the SAPI (generally `$_SERVER`).
* @return array Header/value pairs
Expand Down
2 changes: 2 additions & 0 deletions src/functions/marshal_protocol_version_from_sapi.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

use UnexpectedValueException;

use function preg_match;

/**
* Return HTTP protocol version (X.Y) as discovered within a `$_SERVER` array.
*
Expand Down
14 changes: 13 additions & 1 deletion src/functions/marshal_uri_from_sapi.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,19 @@

namespace Zend\Diactoros;

use function array_change_key_case;
use function array_key_exists;
use function explode;
use function implode;
use function is_array;
use function ltrim;
use function preg_match;
use function preg_replace;
use function strlen;
use function strpos;
use function strtolower;
use function substr;

/**
* Marshal a Uri instance based on the values presnt in the $_SERVER array and headers.
*
Expand Down Expand Up @@ -168,7 +181,6 @@ function marshalUriFromSapi(array $server, array $headers)
$uri = $uri->withScheme($scheme);

// Set the host
$accumulator = (object) ['host' => '', 'port' => null];
list($host, $port) = $marshalHostAndPort($headers, $server);
if (! empty($host)) {
$uri = $uri->withHost($host);
Expand Down
2 changes: 2 additions & 0 deletions src/functions/normalize_server.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

namespace Zend\Diactoros;

use function is_callable;

/**
* Marshal the $_SERVER array
*
Expand Down
2 changes: 2 additions & 0 deletions src/functions/normalize_uploaded_files.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
use InvalidArgumentException;
use Psr\Http\Message\UploadedFileInterface;

use function is_array;

/**
* Normalize uploaded files
*
Expand Down
3 changes: 3 additions & 0 deletions src/functions/parse_cookie_header.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

namespace Zend\Diactoros;

use function preg_match_all;
use function urldecode;

/**
* Parse a cookie header according to RFC 6265.
*
Expand Down

0 comments on commit 883d290

Please sign in to comment.