1 | <?php |
||
21 | class HttpRequestFactory extends ServerRequestFactory |
||
22 | { |
||
23 | 10 | public static function fromGlobals( |
|
24 | array $server = null, |
||
25 | array $query = null, |
||
26 | array $body = null, |
||
27 | array $cookies = null, |
||
28 | array $files = null |
||
29 | ) { |
||
30 | 10 | $server = static::normalizeServer($server ?: $_SERVER); |
|
31 | 10 | $files = static::normalizeFiles($files ?: $_FILES); |
|
32 | 10 | $headers = static::marshalHeaders($server); |
|
33 | |||
34 | 10 | return new Http( |
|
35 | $server, |
||
36 | $files, |
||
37 | 10 | static::marshalUriFromServer($server, $headers), |
|
38 | 10 | static::get('REQUEST_METHOD', $server, 'GET'), |
|
39 | 10 | 'php://input', |
|
40 | $headers, |
||
41 | 10 | $cookies ?: $_COOKIE, |
|
42 | 10 | $query ?: $_GET, |
|
43 | 10 | $body ?: $_POST, |
|
44 | 10 | static::marshalProtocolVersion($server) |
|
|
|||
45 | ); |
||
46 | |||
47 | } |
||
48 | |||
49 | 10 | private static function marshalProtocolVersion(array $server) |
|
64 | } |
||
65 |
Let’s assume you have a class which uses late-static binding:
}
The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the
getSomeVariable()
on that sub-class, you will receive a runtime error:In the case above, it makes sense to update
SomeClass
to useself
instead: