From 611386cb849bff0db7ff53b662aba5ec33698ca1 Mon Sep 17 00:00:00 2001 From: Daniel Olfelt Date: Fri, 22 May 2015 08:26:38 -0500 Subject: [PATCH] Fix error when accessing a single attribute before any have been added. --- src/ServerRequest.php | 2 +- test/ServerRequestTest.php | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ServerRequest.php b/src/ServerRequest.php index f295ebea..cfd8569e 100644 --- a/src/ServerRequest.php +++ b/src/ServerRequest.php @@ -35,7 +35,7 @@ class ServerRequest implements ServerRequestInterface /** * @var array */ - private $attributes; + private $attributes = []; /** * @var array diff --git a/test/ServerRequestTest.php b/test/ServerRequestTest.php index 7e655893..e1665a51 100644 --- a/test/ServerRequestTest.php +++ b/test/ServerRequestTest.php @@ -76,6 +76,10 @@ public function testAttributesAreEmptyByDefault() $this->assertEmpty($this->request->getAttributes()); } + public function testSingleAttributesWhenEmptyByDefault() + { + $this->assertEmpty($this->request->getAttribute('does-not-exist')); + } /** * @depends testAttributesAreEmptyByDefault */