1
0
mirror of https://github.com/guzzle/guzzle.git synced 2025-01-29 11:17:44 +01:00

Be strict about array_replace that may return null (#2471)

* Be strict about array_replace that may return null

* revert cs changes
This commit is contained in:
Mponos George 2019-12-21 10:36:23 +02:00 committed by Tobias Nyholm
parent 45b360e8cb
commit ece8392e00
2 changed files with 6 additions and 6 deletions

View File

@ -165,11 +165,6 @@ parameters:
count: 1
path: src/Cookie/SetCookie.php
-
message: "#^Property GuzzleHttp\\\\Cookie\\\\SetCookie\\:\\:\\$data \\(array\\) does not accept array\\|null\\.$#"
count: 1
path: src/Cookie/SetCookie.php
-
message: "#^Parameter \\#1 \\$timestamp of method GuzzleHttp\\\\Cookie\\\\SetCookie\\:\\:setExpires\\(\\) expects int, mixed given\\.$#"
count: 1

View File

@ -69,7 +69,12 @@ class SetCookie
*/
public function __construct(array $data = [])
{
$this->data = \array_replace(self::$defaults, $data);
$replaced = \array_replace(self::$defaults, $data);
if ($replaced === null) {
throw new \InvalidArgumentException('Unable to replace the default values for the Cookie.');
}
$this->data = $replaced;
// Extract the Expires value and turn it into a UNIX timestamp if needed
if (!$this->getExpires() && $this->getMaxAge()) {
// Calculate the Expires date