From b285c522e3a6a51d7fda5c62a87159127aad0dc3 Mon Sep 17 00:00:00 2001
From: Adrian Suter <adrian@suter-wirz.ch>
Date: Sun, 26 Jan 2020 14:08:44 +0100
Subject: [PATCH 1/2] Add cookie test for get using default value

---
 tests/CookiesTest.php | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tests/CookiesTest.php b/tests/CookiesTest.php
index 1e0c2f6..0c1d84a 100644
--- a/tests/CookiesTest.php
+++ b/tests/CookiesTest.php
@@ -189,8 +189,9 @@ public function testSetSameSiteCookieValuesAreCaseInsensitive()
 
     public function testGet()
     {
-        $cookies = new Cookies(['foo' => 'bar']);
+        $cookies = new Cookies(['foo' => 'bar', 'baz' => null]);
         $this->assertEquals('bar', $cookies->get('foo'));
+        $this->assertNull($cookies->get('baz', 'defaultValue'));
         $this->assertNull($cookies->get('missing'));
         $this->assertEquals('defaultValue', $cookies->get('missing', 'defaultValue'));
     }

From 99ea72cc5392fa19673be3d4d7b8685d23479e5f Mon Sep 17 00:00:00 2001
From: Adrian Suter <adrian@suter-wirz.ch>
Date: Mon, 27 Jan 2020 22:25:43 +0100
Subject: [PATCH 2/2] Fix isset is false if value is null

---
 src/Cookies.php | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/Cookies.php b/src/Cookies.php
index 0eb5422..db8174f 100644
--- a/src/Cookies.php
+++ b/src/Cookies.php
@@ -12,6 +12,7 @@
 
 use InvalidArgumentException;
 
+use function array_key_exists;
 use function array_replace;
 use function count;
 use function explode;
@@ -89,7 +90,7 @@ public function setDefaults(array $settings): self
      */
     public function get(string $name, $default = null)
     {
-        return isset($this->requestCookies[$name]) ? $this->requestCookies[$name] : $default;
+        return array_key_exists($name, $this->requestCookies) ? $this->requestCookies[$name] : $default;
     }
 
     /**