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/Response.php +19 -17 1.2.12 → 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 Dudlewebs\WPMCS\s3\Psr\Http\Message\ResponseInterface;
6 7 use Dudlewebs\WPMCS\s3\Psr\Http\Message\StreamInterface;
@@ -9,25 +10,23 @@
9 10 */
10 11 class Response implements ResponseInterface
11 12 {
12 13 use MessageTrait;
13 - /** @var array Map of standard HTTP status code/reason phrases */
14 - private static $phrases = [100 => 'Continue', 101 => 'Switching Protocols', 102 => 'Processing', 200 => 'OK', 201 => 'Created', 202 => 'Accepted', 203 => 'Non-Authoritative Information', 204 => 'No Content', 205 => 'Reset Content', 206 => 'Partial Content', 207 => 'Multi-status', 208 => 'Already Reported', 300 => 'Multiple Choices', 301 => 'Moved Permanently', 302 => 'Found', 303 => 'See Other', 304 => 'Not Modified', 305 => 'Use Proxy', 306 => 'Switch Proxy', 307 => 'Temporary Redirect', 400 => 'Bad Request', 401 => 'Unauthorized', 402 => 'Payment Required', 403 => 'Forbidden', 404 => 'Not Found', 405 => 'Method Not Allowed', 406 => 'Not Acceptable', 407 => 'Proxy Authentication Required', 408 => 'Request Time-out', 409 => 'Conflict', 410 => 'Gone', 411 => 'Length Required', 412 => 'Precondition Failed', 413 => 'Request Entity Too Large', 414 => 'Request-URI Too Large', 415 => 'Unsupported Media Type', 416 => 'Requested range not satisfiable', 417 => 'Expectation Failed', 418 => 'I\'m a teapot', 422 => 'Unprocessable Entity', 423 => 'Locked', 424 => 'Failed Dependency', 425 => 'Unordered Collection', 426 => 'Upgrade Required', 428 => 'Precondition Required', 429 => 'Too Many Requests', 431 => 'Request Header Fields Too Large', 451 => 'Unavailable For Legal Reasons', 500 => 'Internal Server Error', 501 => 'Not Implemented', 502 => 'Bad Gateway', 503 => 'Service Unavailable', 504 => 'Gateway Time-out', 505 => 'HTTP Version not supported', 506 => 'Variant Also Negotiates', 507 => 'Insufficient Storage', 508 => 'Loop Detected', 511 => 'Network Authentication Required'];
14 + /** Map of standard HTTP status code/reason phrases */
15 + private const PHRASES = [100 => 'Continue', 101 => 'Switching Protocols', 102 => 'Processing', 200 => 'OK', 201 => 'Created', 202 => 'Accepted', 203 => 'Non-Authoritative Information', 204 => 'No Content', 205 => 'Reset Content', 206 => 'Partial Content', 207 => 'Multi-status', 208 => 'Already Reported', 300 => 'Multiple Choices', 301 => 'Moved Permanently', 302 => 'Found', 303 => 'See Other', 304 => 'Not Modified', 305 => 'Use Proxy', 306 => 'Switch Proxy', 307 => 'Temporary Redirect', 308 => 'Permanent Redirect', 400 => 'Bad Request', 401 => 'Unauthorized', 402 => 'Payment Required', 403 => 'Forbidden', 404 => 'Not Found', 405 => 'Method Not Allowed', 406 => 'Not Acceptable', 407 => 'Proxy Authentication Required', 408 => 'Request Time-out', 409 => 'Conflict', 410 => 'Gone', 411 => 'Length Required', 412 => 'Precondition Failed', 413 => 'Request Entity Too Large', 414 => 'Request-URI Too Large', 415 => 'Unsupported Media Type', 416 => 'Requested range not satisfiable', 417 => 'Expectation Failed', 418 => 'I\'m a teapot', 422 => 'Unprocessable Entity', 423 => 'Locked', 424 => 'Failed Dependency', 425 => 'Unordered Collection', 426 => 'Upgrade Required', 428 => 'Precondition Required', 429 => 'Too Many Requests', 431 => 'Request Header Fields Too Large', 451 => 'Unavailable For Legal Reasons', 500 => 'Internal Server Error', 501 => 'Not Implemented', 502 => 'Bad Gateway', 503 => 'Service Unavailable', 504 => 'Gateway Time-out', 505 => 'HTTP Version not supported', 506 => 'Variant Also Negotiates', 507 => 'Insufficient Storage', 508 => 'Loop Detected', 510 => 'Not Extended', 511 => 'Network Authentication Required'];
15 16 /** @var string */
16 - private $reasonPhrase = '';
17 + private $reasonPhrase;
17 18 /** @var int */
18 - private $statusCode = 200;
19 + private $statusCode;
19 20 /**
20 21 * @param int $status Status code
21 - * @param array $headers Response headers
22 + * @param (string|string[])[] $headers Response headers
22 23 * @param string|resource|StreamInterface|null $body Response body
23 24 * @param string $version Protocol version
24 25 * @param string|null $reason Reason phrase (when empty a default will be used based on the status code)
25 26 */
26 - public function __construct($status = 200, array $headers = [], $body = null, $version = '1.1', $reason = null)
27 + public function __construct(int $status = 200, array $headers = [], $body = null, string $version = '1.1', ?string $reason = null)
27 28 {
28 - $this->assertStatusCodeIsInteger($status);
29 - $status = (int) $status;
30 29 $this->assertStatusCodeRange($status);
31 30 $this->statusCode = $status;
32 31 if ($body !== '' && $body !== null) {
33 32 $this->stream = Utils::streamFor($body);
@@ -32,24 +31,24 @@
32 31 if ($body !== '' && $body !== null) {
33 32 $this->stream = Utils::streamFor($body);
34 33 }
35 34 $this->setHeaders($headers);
36 - if ($reason == '' && isset(self::$phrases[$this->statusCode])) {
37 - $this->reasonPhrase = self::$phrases[$this->statusCode];
35 + if ($reason == '' && isset(self::PHRASES[$this->statusCode])) {
36 + $this->reasonPhrase = self::PHRASES[$this->statusCode];
38 37 } else {
39 38 $this->reasonPhrase = (string) $reason;
40 39 }
41 40 $this->protocol = $version;
42 41 }
43 - public function getStatusCode()
42 + public function getStatusCode() : int
44 43 {
45 44 return $this->statusCode;
46 45 }
47 - public function getReasonPhrase()
46 + public function getReasonPhrase() : string
48 47 {
49 48 return $this->reasonPhrase;
50 49 }
51 - public function withStatus($code, $reasonPhrase = '')
50 + public function withStatus($code, $reasonPhrase = '') : ResponseInterface
52 51 {
53 52 $this->assertStatusCodeIsInteger($code);
54 53 $code = (int) $code;
55 54 $this->assertStatusCodeRange($code);
@@ -54,21 +53,24 @@
54 53 $code = (int) $code;
55 54 $this->assertStatusCodeRange($code);
56 55 $new = clone $this;
57 56 $new->statusCode = $code;
58 - if ($reasonPhrase == '' && isset(self::$phrases[$new->statusCode])) {
59 - $reasonPhrase = self::$phrases[$new->statusCode];
57 + if ($reasonPhrase == '' && isset(self::PHRASES[$new->statusCode])) {
58 + $reasonPhrase = self::PHRASES[$new->statusCode];
60 59 }
61 60 $new->reasonPhrase = (string) $reasonPhrase;
62 61 return $new;
63 62 }
64 - private function assertStatusCodeIsInteger($statusCode)
63 + /**
64 + * @param mixed $statusCode
65 + */
66 + private function assertStatusCodeIsInteger($statusCode) : void
65 67 {
66 68 if (\filter_var($statusCode, \FILTER_VALIDATE_INT) === \false) {
67 69 throw new \InvalidArgumentException('Status code must be an integer value.');
68 70 }
69 71 }
70 - private function assertStatusCodeRange($statusCode)
72 + private function assertStatusCodeRange(int $statusCode) : void
71 73 {
72 74 if ($statusCode < 100 || $statusCode >= 600) {
73 75 throw new \InvalidArgumentException('Status code must be an integer value between 1xx and 5xx.');
74 76 }