-
-
Notifications
You must be signed in to change notification settings - Fork 21
/
ServerRequestCreatorInterface.php
58 lines (52 loc) · 2.2 KB
/
ServerRequestCreatorInterface.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
declare(strict_types=1);
namespace Nyholm\Psr7Server;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Message\StreamInterface;
/**
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
* @author Martijn van der Ven <martijn@vanderven.se>
*/
interface ServerRequestCreatorInterface
{
/**
* Create a new server request from the current environment variables.
* Defaults to a GET request to minimise the risk of an \InvalidArgumentException.
* Includes the current request headers as supplied by the server through `getallheaders()`.
* If `getallheaders()` is unavailable on the current server it will fallback to its own `getHeadersFromServer()` method.
* Defaults to php://input for the request body.
*
* @throws \InvalidArgumentException if no valid method or URI can be determined
*/
public function fromGlobals(): ServerRequestInterface;
/**
* Create a new server request from a set of arrays.
*
* @param array $server typically $_SERVER or similar structure
* @param array $headers typically the output of getallheaders() or similar structure
* @param array $cookie typically $_COOKIE or similar structure
* @param array $get typically $_GET or similar structure
* @param array $post typically $_POST or similar structure
* @param array $files typically $_FILES or similar structure
* @param StreamInterface|resource|string|null $body Typically stdIn
*
* @throws \InvalidArgumentException if no valid method or URI can be determined
*/
public function fromArrays(
array $server,
array $headers = [],
array $cookie = [],
array $get = [],
array $post = [],
array $files = [],
$body = null
): ServerRequestInterface;
/**
* Get parsed headers from ($_SERVER) array.
*
* @param array $server typically $_SERVER or similar structure
*
* @return array
*/
public static function getHeadersFromServer(array $server): array;
}