Skip to content

Commit e222bdf

Browse files
committed
🚿
1 parent af74f4b commit e222bdf

File tree

6 files changed

+9
-11
lines changed

6 files changed

+9
-11
lines changed

src/Psr17/factory_helpers.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
function create_server_request_from_globals():ServerRequest{
3030

3131
$serverRequest = new ServerRequest(
32-
isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : ServerRequest::METHOD_GET,
32+
$_SERVER['REQUEST_METHOD'] ?? ServerRequest::METHOD_GET,
3333
create_uri_from_globals(),
3434
\function_exists('getallheaders') ? \getallheaders() : [],
3535
(new StreamFactory)->createStream(),

src/Psr18/HTTPClientAbstract.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ public function __construct(
6666
* @return \Psr\Http\Message\ResponseInterface
6767
*/
6868
public function request(string $uri, string $method = null, array $query = null, $body = null, array $headers = null):ResponseInterface{
69-
$method = \strtoupper($method ?? 'GET');
70-
$headers = Psr7\normalize_request_headers($headers);
71-
$request = new Request($method, Psr7\merge_query($uri, $query ?? []));
69+
$method = \strtoupper($method ?? 'GET');
70+
$headers = Psr7\normalize_request_headers($headers);
71+
$request = new Request($method, Psr7\merge_query($uri, $query ?? []));
7272

7373
if(\in_array($method, ['DELETE', 'PATCH', 'POST', 'PUT'], true) && $body !== null){
7474

src/Psr7/Request.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function __construct(string $method, $uri, array $headers = null, $body =
4646
parent::__construct($headers, $body, $version);
4747

4848
$this->method = \strtoupper($method);
49-
$this->uri = !$uri instanceof UriInterface ? new Uri($uri) : $uri;
49+
$this->uri = $uri instanceof UriInterface ? $uri : new Uri($uri);
5050

5151
if(!$this->hasHeader('Host')){
5252
$this->updateHostFromUri();

src/Psr7/ServerRequest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ final class ServerRequest extends Request implements ServerRequestInterface{
5151
* ServerRequest constructor.
5252
*
5353
* @param string $method
54-
* @param $uri
54+
* @param string|\Psr\Http\Message\UriInterface $uri
5555
* @param array|null $headers
5656
* @param null|string|resource|\Psr\Http\Message\StreamInterface $body
5757
* @param string|null $version

src/Psr7/Stream.php

+2
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ public function __toString(){
8585
// @codeCoverageIgnoreStart
8686
catch(Exception $e){
8787
// https://bugs.php.net/bug.php?id=53648
88+
// @todo: fixed in 7.4
8889
\trigger_error('Stream::__toString exception: '.$e->getMessage(), \E_USER_ERROR);
8990

9091
return '';
@@ -240,6 +241,7 @@ public function read($length):string{
240241
if(!$this->readable){
241242
throw new RuntimeException('Cannot read from non-readable stream');
242243
}
244+
243245
if($length < 0){
244246
throw new RuntimeException('Length parameter cannot be negative');
245247
}

src/Psr7/Uri.php

+1-5
Original file line numberDiff line numberDiff line change
@@ -501,11 +501,7 @@ protected function parseUriParts(array $parts):void{
501501
*/
502502
protected function replaceChars(string $str, bool $query = null):string{
503503
return \preg_replace_callback(
504-
'/(?:[^'
505-
.'a-z\d_\-\.~'
506-
.'!\$&\'\(\)\*\+,;='
507-
.'%:@\/'.($query ? '\?' : '')
508-
.']++|%(?![a-f\d]{2}))/i',
504+
'/(?:[^a-z\d_\-\.~!\$&\'\(\)\*\+,;=%:@\/'.($query ? '\?' : '').']++|%(?![a-f\d]{2}))/i',
509505
function(array $match):string{
510506
return \rawurlencode($match[0]);
511507
},

0 commit comments

Comments
 (0)