PluginProbe
Media Cloud Sync / 1.4.2
Media Cloud Sync v1.4.2
1.4.2 1.4.1 1.4.0 1.3.12 1.3.11 1.3.10 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.2.0 1.2.10 1.2.11 1.2.12 1.2.13 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 All 36 releases
← All changes | includes/sdk/s3/GuzzleHttp/Psr7/Request.php +17 -13 1.2.4 → 1.4.2 View file →
@@ -1,6 +1,7 @@
1 1 <?php
2 2
3 +declare (strict_types=1);
3 4 namespace Dudlewebs\WPMCS\s3\GuzzleHttp\Psr7;
4 5
5 6 use InvalidArgumentException;
6 7 use Dudlewebs\WPMCS\s3\Psr\Http\Message\RequestInterface;
@@ -20,13 +21,13 @@
20 21 private $uri;
21 22 /**
22 23 * @param string $method HTTP method
23 24 * @param string|UriInterface $uri URI
24 - * @param array $headers Request headers
25 + * @param (string|string[])[] $headers Request headers
25 26 * @param string|resource|StreamInterface|null $body Request body
26 27 * @param string $version Protocol version
27 28 */
28 - public function __construct($method, $uri, array $headers = [], $body = null, $version = '1.1')
29 + public function __construct(string $method, $uri, array $headers = [], $body = null, string $version = '1.1')
29 30 {
30 31 $this->assertMethod($method);
31 32 if (!$uri instanceof UriInterface) {
32 33 $uri = new Uri($uri);
@@ -41,15 +42,15 @@
41 42 if ($body !== '' && $body !== null) {
42 43 $this->stream = Utils::streamFor($body);
43 44 }
44 45 }
45 - public function getRequestTarget()
46 + public function getRequestTarget() : string
46 47 {
47 48 if ($this->requestTarget !== null) {
48 49 return $this->requestTarget;
49 50 }
50 51 $target = $this->uri->getPath();
51 - if ($target == '') {
52 + if ($target === '') {
52 53 $target = '/';
53 54 }
54 55 if ($this->uri->getQuery() != '') {
55 56 $target .= '?' . $this->uri->getQuery();
@@ -55,9 +56,9 @@
55 56 $target .= '?' . $this->uri->getQuery();
56 57 }
57 58 return $target;
58 59 }
59 - public function withRequestTarget($requestTarget)
60 + public function withRequestTarget($requestTarget) : RequestInterface
60 61 {
61 62 if (\preg_match('#\\s#', $requestTarget)) {
62 63 throw new InvalidArgumentException('Invalid request target provided; cannot contain whitespace');
63 64 }
@@ -64,13 +65,13 @@
64 65 $new = clone $this;
65 66 $new->requestTarget = $requestTarget;
66 67 return $new;
67 68 }
68 - public function getMethod()
69 + public function getMethod() : string
69 70 {
70 71 return $this->method;
71 72 }
72 - public function withMethod($method)
73 + public function withMethod($method) : RequestInterface
73 74 {
74 75 $this->assertMethod($method);
75 76 $new = clone $this;
76 77 $new->method = \strtoupper($method);
@@ -75,13 +76,13 @@
75 76 $new = clone $this;
76 77 $new->method = \strtoupper($method);
77 78 return $new;
78 79 }
79 - public function getUri()
80 + public function getUri() : UriInterface
80 81 {
81 82 return $this->uri;
82 83 }
83 - public function withUri(UriInterface $uri, $preserveHost = \false)
84 + public function withUri(UriInterface $uri, $preserveHost = \false) : RequestInterface
84 85 {
85 86 if ($uri === $this->uri) {
86 87 return $this;
87 88 }
@@ -91,9 +92,9 @@
91 92 $new->updateHostFromUri();
92 93 }
93 94 return $new;
94 95 }
95 - private function updateHostFromUri()
96 + private function updateHostFromUri() : void
96 97 {
97 98 $host = $this->uri->getHost();
98 99 if ($host == '') {
99 100 return;
@@ -107,14 +108,17 @@
107 108 $header = 'Host';
108 109 $this->headerNames['host'] = 'Host';
109 110 }
110 111 // Ensure Host is the first header.
111 - // See: http://tools.ietf.org/html/rfc7230#section-5.4
112 + // See: https://datatracker.ietf.org/doc/html/rfc7230#section-5.4
112 113 $this->headers = [$header => [$host]] + $this->headers;
113 114 }
114 - private function assertMethod($method)
115 + /**
116 + * @param mixed $method
117 + */
118 + private function assertMethod($method) : void
115 119 {
116 120 if (!\is_string($method) || $method === '') {
117 - throw new \InvalidArgumentException('Method must be a non-empty string.');
121 + throw new InvalidArgumentException('Method must be a non-empty string.');
118 122 }
119 123 }
120 124 }