diff --git a/composer.json b/composer.json index 5f3a49e17..7fdb2a2c5 100644 --- a/composer.json +++ b/composer.json @@ -32,7 +32,8 @@ "ext-json": "*", "guzzlehttp/promises": "^1.4", "guzzlehttp/psr7": "^1.7 || ^2.0", - "psr/http-client": "^1.0" + "psr/http-client": "^1.0", + "symfony/deprecation-contracts": "^2.2" }, "provide": { "psr/http-client-implementation": "1.0" diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 8ada6052b..a3bd3376e 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -110,3 +110,7 @@ parameters: count: 2 path: src/Middleware.php + - + message: "#^Result of && is always false\\.$#" + count: 1 + path: src/Cookie/SetCookie.php diff --git a/src/Cookie/SetCookie.php b/src/Cookie/SetCookie.php index 602370d6f..e3bafef9d 100644 --- a/src/Cookie/SetCookie.php +++ b/src/Cookie/SetCookie.php @@ -128,6 +128,10 @@ public function getName() */ public function setName($name): void { + if (!is_string($name)) { + trigger_deprecation('guzzlehttp/guzzle', '7.4', 'Not passing a string to %s::%s() is deprecated and will cause an error in 8.0.', __CLASS__, __FUNCTION__); + } + $this->data['Name'] = $name; } @@ -148,6 +152,10 @@ public function getValue() */ public function setValue($value): void { + if (!is_string($value)) { + trigger_deprecation('guzzlehttp/guzzle', '7.4', 'Not passing a string to %s::%s() is deprecated and will cause an error in 8.0.', __CLASS__, __FUNCTION__); + } + $this->data['Value'] = $value; } @@ -168,6 +176,10 @@ public function getDomain() */ public function setDomain($domain): void { + if (!is_string($domain)) { + trigger_deprecation('guzzlehttp/guzzle', '7.4', 'Not passing a string to %s::%s() is deprecated and will cause an error in 8.0.', __CLASS__, __FUNCTION__); + } + $this->data['Domain'] = $domain; } @@ -188,6 +200,10 @@ public function getPath() */ public function setPath($path): void { + if (!is_string($path)) { + trigger_deprecation('guzzlehttp/guzzle', '7.4', 'Not passing a string to %s::%s() is deprecated and will cause an error in 8.0.', __CLASS__, __FUNCTION__); + } + $this->data['Path'] = $path; } @@ -198,7 +214,7 @@ public function setPath($path): void */ public function getMaxAge() { - return $this->data['Max-Age']; + return null === $this->data['Max-Age'] ? null : (int) $this->data['Max-Age']; } /** @@ -208,6 +224,10 @@ public function getMaxAge() */ public function setMaxAge($maxAge): void { + if (!is_int($maxAge)) { + trigger_deprecation('guzzlehttp/guzzle', '7.4', 'Not passing an int to %s::%s() is deprecated and will cause an error in 8.0.', __CLASS__, __FUNCTION__); + } + $this->data['Max-Age'] = $maxAge; } @@ -228,6 +248,10 @@ public function getExpires() */ public function setExpires($timestamp): void { + if (!is_int($timestamp) && !is_string($timestamp)) { + trigger_deprecation('guzzlehttp/guzzle', '7.4', 'Not passing an int or string to %s::%s() is deprecated and will cause an error in 8.0.', __CLASS__, __FUNCTION__); + } + $this->data['Expires'] = \is_numeric($timestamp) ? (int) $timestamp : \strtotime($timestamp); @@ -250,6 +274,10 @@ public function getSecure() */ public function setSecure($secure): void { + if (!is_bool($secure)) { + trigger_deprecation('guzzlehttp/guzzle', '7.4', 'Not passing a boolean to %s::%s() is deprecated and will cause an error in 8.0.', __CLASS__, __FUNCTION__); + } + $this->data['Secure'] = $secure; } @@ -270,6 +298,10 @@ public function getDiscard() */ public function setDiscard($discard): void { + if (!is_bool($discard)) { + trigger_deprecation('guzzlehttp/guzzle', '7.4', 'Not passing a boolean to %s::%s() is deprecated and will cause an error in 8.0.', __CLASS__, __FUNCTION__); + } + $this->data['Discard'] = $discard; } @@ -290,6 +322,10 @@ public function getHttpOnly() */ public function setHttpOnly($httpOnly): void { + if (!is_bool($httpOnly)) { + trigger_deprecation('guzzlehttp/guzzle', '7.4', 'Not passing a boolean to %s::%s() is deprecated and will cause an error in 8.0.', __CLASS__, __FUNCTION__); + } + $this->data['HttpOnly'] = $httpOnly; }