From a4aaef83d98462fdcd7cd4bca781aeb59bad6aa4 Mon Sep 17 00:00:00 2001 From: Chad Gray Date: Sun, 13 Jul 2014 08:04:50 -0400 Subject: [PATCH] PHPCS fixes for Zend\Http --- src/Client.php | 2 -- src/ClientStatic.php | 1 - src/Cookies.php | 10 +++++--- src/Exception/OutOfRangeException.php | 3 +-- src/Header/AbstractAccept.php | 14 ++++------- src/Header/AbstractLocation.php | 7 +++--- src/Header/Connection.php | 2 -- src/Header/Location.php | 1 - src/Header/SetCookie.php | 36 +++++++++++++++++++-------- src/PhpEnvironment/RemoteAddress.php | 1 - 10 files changed, 40 insertions(+), 37 deletions(-) diff --git a/src/Client.php b/src/Client.php index 71ff2d4905..29d04fd84a 100644 --- a/src/Client.php +++ b/src/Client.php @@ -262,7 +262,6 @@ public function getResponse() return $this->response; } - /** * Get the last request (as a string) * @@ -939,7 +938,6 @@ public function send(Request $request = null) $this->setMethod(Request::METHOD_GET); } - // If we got a well formed absolute URI if (($scheme = substr($location, 0, 6)) && ($scheme == 'http:/' || $scheme == 'https:')) { diff --git a/src/ClientStatic.php b/src/ClientStatic.php index 020fa07e23..21070593eb 100644 --- a/src/ClientStatic.php +++ b/src/ClientStatic.php @@ -9,7 +9,6 @@ namespace Zend\Http; - /** * Http static client */ diff --git a/src/Cookies.php b/src/Cookies.php index 7d4ac275da..c53395ce9b 100644 --- a/src/Cookies.php +++ b/src/Cookies.php @@ -13,7 +13,6 @@ use Zend\Http\Header\SetCookie; use Zend\Uri; - /** * A Zend\Http\Cookies object is designed to contain and maintain HTTP cookies, and should * be used along with Zend\Http\Client in order to manage cookies across HTTP requests and @@ -161,9 +160,12 @@ public function getAllCookies($retAs = self::COOKIE_OBJECT) * @throws Exception\InvalidArgumentException if invalid URI specified * @return array|string */ - public function getMatchingCookies($uri, $matchSessionCookies = true, - $retAs = self::COOKIE_OBJECT, $now = null) - { + public function getMatchingCookies( + $uri, + $matchSessionCookies = true, + $retAs = self::COOKIE_OBJECT, + $now = null + ) { if (is_string($uri)) { $uri = Uri\UriFactory::factory($uri, 'http'); } elseif (!$uri instanceof Uri\Uri) { diff --git a/src/Exception/OutOfRangeException.php b/src/Exception/OutOfRangeException.php index 5d1b20e33d..cdbfac9ae1 100644 --- a/src/Exception/OutOfRangeException.php +++ b/src/Exception/OutOfRangeException.php @@ -9,7 +9,6 @@ namespace Zend\Http\Exception; -class OutOfRangeException extends \OutOfRangeException implements - ExceptionInterface +class OutOfRangeException extends \OutOfRangeException implements ExceptionInterface { } diff --git a/src/Header/AbstractAccept.php b/src/Header/AbstractAccept.php index ec11a90660..17af575343 100644 --- a/src/Header/AbstractAccept.php +++ b/src/Header/AbstractAccept.php @@ -53,7 +53,6 @@ abstract class AbstractAccept implements HeaderInterface */ protected $sorted = false; - /** * Parse a full header line or just the field value part. * @@ -102,7 +101,7 @@ public function getFieldValuePartsFromHeaderLine($headerLine) || !isset($values[0]) ) { throw new Exception\InvalidArgumentException( - 'Invalid header line for ' . $this->getFieldName() . ' header string' + 'Invalid header line for ' . $this->getFieldName() . ' header string' ); } @@ -182,7 +181,6 @@ protected function getParametersFromFieldValuePart($fieldValuePart) return $params; } - /** * Get field value * @@ -205,7 +203,6 @@ public function getFieldValue($values = null) return implode(', ', $strings); } - /** * Assemble and escape the field value parameters based on RFC 2616 section 2.1 * @@ -219,7 +216,8 @@ protected function assembleAcceptParam(&$value, $key) $separators = array('(', ')', '<', '>', '@', ',', ';', ':', '/', '[', ']', '?', '=', '{', '}', ' ', "\t"); - $escaped = preg_replace_callback('/[[:cntrl:]"\\\\]/', // escape cntrl, ", \ + $escaped = preg_replace_callback( + '/[[:cntrl:]"\\\\]/', // escape cntrl, ", \ function ($v) { return '\\' . $v[0]; }, @@ -269,15 +267,14 @@ protected function addType($type, $priority = 1, array $params = array()) } $assembledString = $this->getFieldValue( - array((object) array('typeString' => $type, 'params' => $params)) - ); + array((object) array('typeString' => $type, 'params' => $params)) + ); $value = $this->parseFieldValuePart($assembledString); $this->addFieldValuePartToQueue($value); return $this; } - /** * Does the header have the requested type? * @@ -375,7 +372,6 @@ protected function matchAcceptParams($match1, $match2) return $match1; } - /** * Add a key/value combination to the internal queue * diff --git a/src/Header/AbstractLocation.php b/src/Header/AbstractLocation.php index 12088cc9e0..0e639871bb 100644 --- a/src/Header/AbstractLocation.php +++ b/src/Header/AbstractLocation.php @@ -13,7 +13,6 @@ use Zend\Uri\UriFactory; use Zend\Uri\UriInterface; - /** * Abstract Location Header * Supports headers that have URI as value @@ -74,9 +73,9 @@ public function setUri($uri) $uri = UriFactory::factory($uri); } catch (UriException\InvalidUriPartException $e) { throw new Exception\InvalidArgumentException( - sprintf('Invalid URI passed as string (%s)', (string) $uri), - $e->getCode(), - $e + sprintf('Invalid URI passed as string (%s)', (string) $uri), + $e->getCode(), + $e ); } } elseif (!($uri instanceof UriInterface)) { diff --git a/src/Header/Connection.php b/src/Header/Connection.php index 16cb1258be..686546e354 100644 --- a/src/Header/Connection.php +++ b/src/Header/Connection.php @@ -47,7 +47,6 @@ public static function fromString($headerLine) return $header; } - /** * Set Connection header to define persistent connection * @@ -87,7 +86,6 @@ public function setValue($value) return $this; } - /** * Connection header name * diff --git a/src/Header/Location.php b/src/Header/Location.php index 8d391ebf58..9dfe0c479c 100644 --- a/src/Header/Location.php +++ b/src/Header/Location.php @@ -9,7 +9,6 @@ namespace Zend\Http\Header; - /** * Location Header * diff --git a/src/Header/SetCookie.php b/src/Header/SetCookie.php index 9a134c38d4..e5627a81d5 100644 --- a/src/Header/SetCookie.php +++ b/src/Header/SetCookie.php @@ -114,7 +114,7 @@ public static function fromString($headerLine, $bypassHeaderFieldName = false) } // First K=V pair is always the cookie name and value - if ($header->getName() === NULL) { + if ($header->getName() === null) { $header->setName($headerKey); $header->setValue(urldecode($headerValue)); continue; @@ -122,13 +122,27 @@ public static function fromString($headerLine, $bypassHeaderFieldName = false) // Process the remaining elements switch (str_replace(array('-', '_'), '', strtolower($headerKey))) { - case 'expires' : $header->setExpires($headerValue); break; - case 'domain' : $header->setDomain($headerValue); break; - case 'path' : $header->setPath($headerValue); break; - case 'secure' : $header->setSecure(true); break; - case 'httponly': $header->setHttponly(true); break; - case 'version' : $header->setVersion((int) $headerValue); break; - case 'maxage' : $header->setMaxAge((int) $headerValue); break; + case 'expires': + $header->setExpires($headerValue); + break; + case 'domain': + $header->setDomain($headerValue); + break; + case 'path': + $header->setPath($headerValue); + break; + case 'secure': + $header->setSecure(true); + break; + case 'httponly': + $header->setHttponly(true); + break; + case 'version': + $header->setVersion((int) $headerValue); + break; + case 'maxage': + $header->setMaxAge((int) $headerValue); + break; default: // Intentionally omitted } @@ -210,7 +224,7 @@ public function getFieldValue() } $value = urlencode($this->getValue()); - if ( $this->hasQuoteFieldValue() ) { + if ($this->hasQuoteFieldValue()) { $value = '"'. $value . '"'; } @@ -369,7 +383,7 @@ public function setExpires($expires) // if $tsExpires is invalid and PHP is compiled as 32bit. Check if it fail reason is the 2038 bug if (!is_int($tsExpires) && PHP_INT_SIZE === 4) { $dateTime = new DateTime($expires); - if ( $dateTime->format('Y') > 2038) { + if ($dateTime->format('Y') > 2038) { $tsExpires = PHP_INT_MAX; } } @@ -552,7 +566,7 @@ public function isValidForRequest($requestDomain, $path, $isSecure = false) */ public function match($uri, $matchSessionCookies = true, $now = null) { - if (is_string ($uri)) { + if (is_string($uri)) { $uri = UriFactory::factory($uri); } diff --git a/src/PhpEnvironment/RemoteAddress.php b/src/PhpEnvironment/RemoteAddress.php index 077768ab8f..fd92afcec3 100644 --- a/src/PhpEnvironment/RemoteAddress.php +++ b/src/PhpEnvironment/RemoteAddress.php @@ -150,7 +150,6 @@ protected function getIpAddressFromProxy() return $ip; } - /** * Normalize a header string *