Fix proper types

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
This commit is contained in:
Roeland Jago Douma 2018-02-22 10:22:11 +01:00
parent a229095af1
commit 0ee45d3d20
No known key found for this signature in database
GPG Key ID: F941078878347C0C
3 changed files with 12 additions and 4 deletions

View File

@ -678,7 +678,11 @@ class Request implements \ArrayAccess, \Countable, IRequest {
* @return string HTTP protocol. HTTP/2, HTTP/1.1 or HTTP/1.0.
*/
public function getHttpProtocol(): string {
$claimedProtocol = strtoupper($this->server['SERVER_PROTOCOL']);
$claimedProtocol = $this->server['SERVER_PROTOCOL'];
if (\is_string($claimedProtocol)) {
$claimedProtocol = strtoupper($claimedProtocol);
}
$validProtocols = [
'HTTP/1.0',
@ -738,10 +742,14 @@ class Request implements \ArrayAccess, \Countable, IRequest {
throw new \Exception("The requested uri($requestUri) cannot be processed by the script '$scriptName')");
}
}
if ($name === null) {
$name = '';
}
if (strpos($pathInfo, '/'.$name) === 0) {
$pathInfo = substr($pathInfo, \strlen($name) + 1);
}
if (strpos($pathInfo, $name) === 0) {
if ($name !== '' && strpos($pathInfo, $name) === 0) {
$pathInfo = substr($pathInfo, \strlen($name));
}
if($pathInfo === false || $pathInfo === '/'){

View File

@ -814,7 +814,7 @@ class Server extends ServerContainer implements IServerContainer {
'cookies' => $_COOKIE,
'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
? $_SERVER['REQUEST_METHOD']
: null,
: '',
'urlParams' => $urlParams,
],
$this->getSecureRandom(),

View File

@ -307,7 +307,7 @@ class RequestTest extends \Test\TestCase {
'method' => 'PUT',
'server' => [
'CONTENT_TYPE' => 'image/png',
'CONTENT_LENGTH' => strlen($data)
'CONTENT_LENGTH' => (string)strlen($data)
],
);