From 4233ba483e376034cac01eb686ce88949159cda8 Mon Sep 17 00:00:00 2001 From: Artur Bodera Date: Mon, 23 Jul 2012 19:59:28 +0200 Subject: [PATCH 1/2] Fix indentation after last commit. --- src/Request.php | 112 +++++++++++++++++++++---------------------- test/RequestTest.php | 10 ++-- 2 files changed, 61 insertions(+), 61 deletions(-) diff --git a/src/Request.php b/src/Request.php index 7feda70212..69d1b6de33 100644 --- a/src/Request.php +++ b/src/Request.php @@ -266,13 +266,13 @@ public function setQuery(ParametersInterface $query) return $this; } - /** - * Return the parameter container responsible for query parameters or a single query parameter - * - * @param string|null $name Parameter name to retrieve, or null to get the whole container. - * @param mixed|null $default Default value to use when the parameter is missing. - * @return \Zend\Stdlib\ParametersInterface|mixed - */ + /** + * Return the parameter container responsible for query parameters or a single query parameter + * + * @param string|null $name Parameter name to retrieve, or null to get the whole container. + * @param mixed|null $default Default value to use when the parameter is missing. + * @return \Zend\Stdlib\ParametersInterface|mixed + */ public function getQuery($name = null, $default = null) { if ($this->queryParams === null) { @@ -280,10 +280,10 @@ public function getQuery($name = null, $default = null) } if($name === null){ - return $this->queryParams; - }else{ - return $this->queryParams->get($name, $default); - } + return $this->queryParams; + }else{ + return $this->queryParams->get($name, $default); + } } /** @@ -302,9 +302,9 @@ public function setPost(ParametersInterface $post) /** * Return the parameter container responsible for post parameters or a single post parameter. * - * @param string|null $name Parameter name to retrieve, or null to get the whole container. - * @param mixed|null $default Default value to use when the parameter is missing. - * @return \Zend\Stdlib\ParametersInterface|mixed + * @param string|null $name Parameter name to retrieve, or null to get the whole container. + * @param mixed|null $default Default value to use when the parameter is missing. + * @return \Zend\Stdlib\ParametersInterface|mixed */ public function getPost($name = null, $default = null) { @@ -313,10 +313,10 @@ public function getPost($name = null, $default = null) } if($name === null){ - return $this->postParams; - }else{ - return $this->postParams->get($name, $default); - } + return $this->postParams; + }else{ + return $this->postParams->get($name, $default); + } } /** @@ -345,9 +345,9 @@ public function setFile(ParametersInterface $files) /** * Return the parameter container responsible for file parameters or a single file. - * - * @param string|null $name Parameter name to retrieve, or null to get the whole container. - * @param mixed|null $default Default value to use when the parameter is missing. + * + * @param string|null $name Parameter name to retrieve, or null to get the whole container. + * @param mixed|null $default Default value to use when the parameter is missing. * @return ParametersInterface|mixed */ public function getFile($name = null, $default = null) @@ -357,10 +357,10 @@ public function getFile($name = null, $default = null) } if($name === null){ - return $this->fileParams; - }else{ - return $this->fileParams->get($name, $default); - } + return $this->fileParams; + }else{ + return $this->fileParams->get($name, $default); + } } /** @@ -379,8 +379,8 @@ public function setServer(ParametersInterface $server) /** * Return the parameter container responsible for server parameters or a single parameter value. * - * @param string|null $name Parameter name to retrieve, or null to get the whole container. - * @param mixed|null $default Default value to use when the parameter is missing. + * @param string|null $name Parameter name to retrieve, or null to get the whole container. + * @param mixed|null $default Default value to use when the parameter is missing. * @see http://www.faqs.org/rfcs/rfc3875.html * @return \Zend\Stdlib\ParametersInterface|mixed */ @@ -391,10 +391,10 @@ public function getServer($name = null, $default = null) } if($name === null){ - return $this->serverParams; - }else{ - return $this->serverParams->get($name, $default); - } + return $this->serverParams; + }else{ + return $this->serverParams->get($name, $default); + } } /** @@ -412,10 +412,10 @@ public function setEnv(ParametersInterface $env) /** * Return the parameter container responsible for env parameters or a single parameter value. - * - * @param string|null $name Parameter name to retrieve, or null to get the whole container. - * @param mixed|null $default Default value to use when the parameter is missing. * @return \Zend\Stdlib\ParametersInterface - * @return \Zend\Stdlib\ParametersInterface|mixed + * + * @param string|null $name Parameter name to retrieve, or null to get the whole container. + * @param mixed|null $default Default value to use when the parameter is missing. * @return \Zend\Stdlib\ParametersInterface + * @return \Zend\Stdlib\ParametersInterface|mixed */ public function getEnv($name = null, $default = null) { @@ -424,10 +424,10 @@ public function getEnv($name = null, $default = null) } if($name === null){ - return $this->envParams; - }else{ - return $this->envParams->get($name, $default); - } + return $this->envParams; + }else{ + return $this->envParams->get($name, $default); + } } /** @@ -445,12 +445,12 @@ public function setHeaders(Headers $headers) /** * Return the header container responsible for headers or all headers of a certain name/type - * - * @see \Zend\Http\Headers::get() - * @param string|null $name Header name to retrieve, or null to get the whole container. - * @param mixed|null $default Default value to use when the requested header is missing. - * @return \Zend\Http\Headers|bool|\Zend\Http\Header\HeaderInterface|\ArrayIterator - */ + * + * @see \Zend\Http\Headers::get() + * @param string|null $name Header name to retrieve, or null to get the whole container. + * @param mixed|null $default Default value to use when the requested header is missing. + * @return \Zend\Http\Headers|bool|\Zend\Http\Header\HeaderInterface|\ArrayIterator + */ public function getHeaders($name = null, $default = false) { if ($this->headers === null || is_string($this->headers)) { @@ -459,21 +459,21 @@ public function getHeaders($name = null, $default = false) } if($name === null){ - return $this->headers; - }elseif($this->headers->has($name)){ - return $this->headers->get($name); - }else{ - return $default; - } + return $this->headers; + }elseif($this->headers->has($name)){ + return $this->headers->get($name); + }else{ + return $default; + } } /** * Get all headers of a certain name/type. - * - * @see Request::getHeaders() - * @param string|null $name Header name to retrieve, or null to get the whole container. - * @param mixed|null $default Default value to use when the requested header is missing. - * @return \Zend\Http\Headers|bool|\Zend\Http\Header\HeaderInterface|\ArrayIterator + * + * @see Request::getHeaders() + * @param string|null $name Header name to retrieve, or null to get the whole container. + * @param mixed|null $default Default value to use when the requested header is missing. + * @return \Zend\Http\Headers|bool|\Zend\Http\Header\HeaderInterface|\ArrayIterator */ public function getHeader($name, $default = false) { diff --git a/test/RequestTest.php b/test/RequestTest.php index 334799ad1f..cefb04d636 100644 --- a/test/RequestTest.php +++ b/test/RequestTest.php @@ -63,7 +63,7 @@ public function testRetrievingASingleValueForParameters() { $request = new Request(); $p = new \Zend\Stdlib\Parameters(array( - 'foo' => 'bar' + 'foo' => 'bar' )); $request->setQuery($p); $request->setPost($p); @@ -77,7 +77,7 @@ public function testRetrievingASingleValueForParameters() $this->assertSame('bar', $request->getServer('foo')); $this->assertSame('bar', $request->getEnv('foo')); - $headers = new Headers(); + $headers = new Headers(); $h = new GenericHeader('foo','bar'); $headers->addHeader($h); @@ -91,15 +91,15 @@ public function testParameterRetrievalDefaultValue() { $request = new Request(); $p = new \Zend\Stdlib\Parameters(array( - 'foo' => 'bar' + 'foo' => 'bar' )); $request->setQuery($p); $request->setPost($p); $request->setFile($p); $request->setServer($p); $request->setEnv($p); - - $default = 15; + + $default = 15; $this->assertSame($default, $request->getQuery('baz', $default)); $this->assertSame($default, $request->getPost('baz', $default)); $this->assertSame($default, $request->getFile('baz', $default)); From 076ada7833c8faa064365c8480f3084d10aaa100 Mon Sep 17 00:00:00 2001 From: Artur Bodera Date: Mon, 23 Jul 2012 23:21:21 +0200 Subject: [PATCH 2/2] Fix minor cs issues. --- src/Request.php | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/Request.php b/src/Request.php index 69d1b6de33..98a5c8554e 100644 --- a/src/Request.php +++ b/src/Request.php @@ -281,9 +281,9 @@ public function getQuery($name = null, $default = null) if($name === null){ return $this->queryParams; - }else{ - return $this->queryParams->get($name, $default); } + + return $this->queryParams->get($name, $default); } /** @@ -314,9 +314,9 @@ public function getPost($name = null, $default = null) if($name === null){ return $this->postParams; - }else{ - return $this->postParams->get($name, $default); } + + return $this->postParams->get($name, $default); } /** @@ -358,9 +358,9 @@ public function getFile($name = null, $default = null) if($name === null){ return $this->fileParams; - }else{ - return $this->fileParams->get($name, $default); } + + return $this->fileParams->get($name, $default); } /** @@ -392,9 +392,9 @@ public function getServer($name = null, $default = null) if($name === null){ return $this->serverParams; - }else{ - return $this->serverParams->get($name, $default); } + + return $this->serverParams->get($name, $default); } /** @@ -425,9 +425,9 @@ public function getEnv($name = null, $default = null) if($name === null){ return $this->envParams; - }else{ - return $this->envParams->get($name, $default); } + + return $this->envParams->get($name, $default); } /** @@ -460,11 +460,13 @@ public function getHeaders($name = null, $default = false) if($name === null){ return $this->headers; - }elseif($this->headers->has($name)){ + } + + if($this->headers->has($name)){ return $this->headers->get($name); - }else{ - return $default; } + + return $default; } /**