Parcourir la source

CS fixes in Zend_Controller_Router

Frank Brückner il y a 11 ans
Parent
commit
233aa78683

+ 9 - 5
library/Zend/Controller/Router/Abstract.php

@@ -20,7 +20,6 @@
  * @version    $Id$
  */
 
-
 /** Zend_Controller_Router_Interface */
 require_once 'Zend/Controller/Router/Interface.php';
 
@@ -40,9 +39,10 @@ abstract class Zend_Controller_Router_Abstract implements Zend_Controller_Router
      * URI delimiter
      */
     const URI_DELIMITER = '/';
-    
+
     /**
      * Front controller instance
+     *
      * @var Zend_Controller_Front
      */
     protected $_frontController;
@@ -50,6 +50,7 @@ abstract class Zend_Controller_Router_Abstract implements Zend_Controller_Router
     /**
      * Array of invocation parameters to use when instantiating action
      * controllers
+     *
      * @var array
      */
     protected $_invokeParams = array();
@@ -73,8 +74,9 @@ abstract class Zend_Controller_Router_Abstract implements Zend_Controller_Router
      */
     public function setParam($name, $value)
     {
-        $name = (string) $name;
+        $name                       = (string)$name;
         $this->_invokeParams[$name] = $value;
+
         return $this;
     }
 
@@ -87,6 +89,7 @@ abstract class Zend_Controller_Router_Abstract implements Zend_Controller_Router
     public function setParams(array $params)
     {
         $this->_invokeParams = array_merge($this->_invokeParams, $params);
+
         return $this;
     }
 
@@ -98,7 +101,7 @@ abstract class Zend_Controller_Router_Abstract implements Zend_Controller_Router
      */
     public function getParam($name)
     {
-        if(isset($this->_invokeParams[$name])) {
+        if (isset($this->_invokeParams[$name])) {
             return $this->_invokeParams[$name];
         }
 
@@ -156,6 +159,7 @@ abstract class Zend_Controller_Router_Abstract implements Zend_Controller_Router
 
         require_once 'Zend/Controller/Front.php';
         $this->_frontController = Zend_Controller_Front::getInstance();
+
         return $this->_frontController;
     }
 
@@ -168,7 +172,7 @@ abstract class Zend_Controller_Router_Abstract implements Zend_Controller_Router
     public function setFrontController(Zend_Controller_Front $controller)
     {
         $this->_frontController = $controller;
+
         return $this;
     }
-
 }

+ 2 - 3
library/Zend/Controller/Router/Exception.php

@@ -20,11 +20,9 @@
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 
-
 /** Zend_Controller_Exception */
 require_once 'Zend/Controller/Exception.php';
 
-
 /**
  * @package    Zend_Controller
  * @subpackage Router
@@ -32,5 +30,6 @@ require_once 'Zend/Controller/Exception.php';
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 class Zend_Controller_Router_Exception extends Zend_Controller_Exception
-{}
+{
+}
 

+ 4 - 5
library/Zend/Controller/Router/Interface.php

@@ -54,9 +54,9 @@ interface Zend_Controller_Router_Interface
      * Encode tells to url encode resulting path parts.
      *
      * @param  array $userParams Options passed by a user used to override parameters
-     * @param  mixed $name The name of a Route to use
-     * @param  bool $reset Whether to reset to the route defaults ignoring URL params
-     * @param  bool $encode Tells to encode URL parts on output
+     * @param  mixed $name       The name of a Route to use
+     * @param  bool  $reset      Whether to reset to the route defaults ignoring URL params
+     * @param  bool  $encode     Tells to encode URL parts on output
      * @throws Zend_Controller_Router_Exception
      * @return string Resulting URL path
      */
@@ -81,7 +81,7 @@ interface Zend_Controller_Router_Interface
      * Add or modify a parameter with which to instantiate any helper objects
      *
      * @param string $name
-     * @param mixed $value
+     * @param mixed  $value
      * @return Zend_Controller_Router_Interface
      */
     public function setParam($name, $value);
@@ -120,5 +120,4 @@ interface Zend_Controller_Router_Interface
      * @return Zend_Controller_Router_Interface
      */
     public function clearParams($name = null);
-
 }

+ 42 - 29
library/Zend/Controller/Router/Rewrite.php

@@ -90,7 +90,7 @@ class Zend_Controller_Router_Rewrite extends Zend_Controller_Router_Abstract
     {
         if (!$this->hasRoute('default')) {
             $dispatcher = $this->getFrontController()->getDispatcher();
-            $request = $this->getFrontController()->getRequest();
+            $request    = $this->getFrontController()->getRequest();
 
             require_once 'Zend/Controller/Router/Route/Module.php';
             $compat = new Zend_Controller_Router_Route_Module(array(), $dispatcher, $request);
@@ -106,8 +106,8 @@ class Zend_Controller_Router_Rewrite extends Zend_Controller_Router_Abstract
      *
      * If route contains method setRequest(), it is initialized with a request object
      *
-     * @param  string                                 $name       Name of the route
-     * @param  Zend_Controller_Router_Route_Interface $route      Instance of the route
+     * @param  string                                 $name  Name of the route
+     * @param  Zend_Controller_Router_Route_Interface $route Instance of the route
      * @return Zend_Controller_Router_Rewrite
      */
     public function addRoute($name, Zend_Controller_Router_Route_Interface $route)
@@ -127,7 +127,8 @@ class Zend_Controller_Router_Rewrite extends Zend_Controller_Router_Abstract
      * @param  array $routes Array of routes with names as keys and routes as values
      * @return Zend_Controller_Router_Rewrite
      */
-    public function addRoutes($routes) {
+    public function addRoutes($routes)
+    {
         foreach ($routes as $name => $route) {
             $this->addRoute($name, $route);
         }
@@ -215,7 +216,12 @@ class Zend_Controller_Router_Rewrite extends Zend_Controller_Router_Abstract
             Zend_Loader::loadClass($class);
         }
 
-        $route = call_user_func(array($class, 'getInstance'), $info);
+        $route = call_user_func(
+            array(
+                $class,
+                'getInstance'
+            ), $info
+        );
 
         if (isset($info->abstract) && $info->abstract && method_exists($route, 'isAbstract')) {
             $route->isAbstract(true);
@@ -232,9 +238,11 @@ class Zend_Controller_Router_Rewrite extends Zend_Controller_Router_Abstract
      * @param  Zend_Config                            $childRoutesInfo
      * @return void
      */
-    protected function _addChainRoutesFromConfig($name,
-                                                 Zend_Controller_Router_Route_Interface $route,
-                                                 Zend_Config $childRoutesInfo)
+    protected function _addChainRoutesFromConfig(
+        $name,
+        Zend_Controller_Router_Route_Interface $route,
+        Zend_Config $childRoutesInfo
+    )
     {
         foreach ($childRoutesInfo as $childRouteName => $childRouteInfo) {
             if (is_string($childRouteInfo)) {
@@ -332,6 +340,7 @@ class Zend_Controller_Router_Rewrite extends Zend_Controller_Router_Abstract
             require_once 'Zend/Controller/Router/Exception.php';
             throw new Zend_Controller_Router_Exception("Current route is not defined");
         }
+
         return $this->getRoute($this->_currentRoute);
     }
 
@@ -347,6 +356,7 @@ class Zend_Controller_Router_Rewrite extends Zend_Controller_Router_Abstract
             require_once 'Zend/Controller/Router/Exception.php';
             throw new Zend_Controller_Router_Exception("Current route is not defined");
         }
+
         return $this->_currentRoute;
     }
 
@@ -372,7 +382,9 @@ class Zend_Controller_Router_Rewrite extends Zend_Controller_Router_Abstract
     {
         if (!$request instanceof Zend_Controller_Request_Http) {
             require_once 'Zend/Controller/Router/Exception.php';
-            throw new Zend_Controller_Router_Exception('Zend_Controller_Router_Rewrite requires a Zend_Controller_Request_Http-based request object');
+            throw new Zend_Controller_Router_Exception(
+                'Zend_Controller_Router_Rewrite requires a Zend_Controller_Request_Http-based request object'
+            );
         }
 
         if ($this->_useDefaultRoutes) {
@@ -403,20 +415,19 @@ class Zend_Controller_Router_Rewrite extends Zend_Controller_Router_Abstract
             }
         }
 
-         if (!$routeMatched) {
-             require_once 'Zend/Controller/Router/Exception.php';
-             throw new Zend_Controller_Router_Exception('No route matched the request', 404);
-         }
+        if (!$routeMatched) {
+            require_once 'Zend/Controller/Router/Exception.php';
+            throw new Zend_Controller_Router_Exception('No route matched the request', 404);
+        }
 
-        if($this->_useCurrentParamsAsGlobal) {
+        if ($this->_useCurrentParamsAsGlobal) {
             $params = $request->getParams();
-            foreach($params as $param => $value) {
+            foreach ($params as $param => $value) {
                 $this->setGlobalParam($param, $value);
             }
         }
 
         return $request;
-
     }
 
     /**
@@ -442,7 +453,6 @@ class Zend_Controller_Router_Rewrite extends Zend_Controller_Router_Abstract
             if ($param === $request->getActionKey()) {
                 $request->setActionName($value);
             }
-
         }
     }
 
@@ -450,9 +460,9 @@ class Zend_Controller_Router_Rewrite extends Zend_Controller_Router_Abstract
      * Generates a URL path that can be used in URL creation, redirection, etc.
      *
      * @param  array $userParams Options passed by a user used to override parameters
-     * @param  mixed $name The name of a Route to use
-     * @param  bool $reset Whether to reset to the route defaults ignoring URL params
-     * @param  bool $encode Tells to encode URL parts on output
+     * @param  mixed $name       The name of a Route to use
+     * @param  bool  $reset      Whether to reset to the route defaults ignoring URL params
+     * @param  bool  $encode     Tells to encode URL parts on output
      * @throws Zend_Controller_Router_Exception
      * @return string Resulting absolute URL path
      */
@@ -462,7 +472,7 @@ class Zend_Controller_Router_Rewrite extends Zend_Controller_Router_Abstract
             require_once 'Zend/Controller/Router/Exception.php';
             throw new Zend_Controller_Router_Exception('userParams must be an array');
         }
-        
+
         if ($name == null) {
             try {
                 $name = $this->getCurrentRouteName();
@@ -488,7 +498,7 @@ class Zend_Controller_Router_Rewrite extends Zend_Controller_Router_Abstract
      * Set a global parameter
      *
      * @param  string $name
-     * @param  mixed $value
+     * @param  mixed  $value
      * @return Zend_Controller_Router_Rewrite
      */
     public function setGlobalParam($name, $value)
@@ -504,7 +514,8 @@ class Zend_Controller_Router_Rewrite extends Zend_Controller_Router_Abstract
      * @param string $separator The separator to use
      * @return Zend_Controller_Router_Rewrite
      */
-    public function setChainNameSeparator($separator) {
+    public function setChainNameSeparator($separator)
+    {
         $this->_chainNameSeparator = $separator;
 
         return $this;
@@ -515,7 +526,8 @@ class Zend_Controller_Router_Rewrite extends Zend_Controller_Router_Abstract
      *
      * @return string
      */
-    public function getChainNameSeparator() {
+    public function getChainNameSeparator()
+    {
         return $this->_chainNameSeparator;
     }
 
@@ -523,19 +535,20 @@ class Zend_Controller_Router_Rewrite extends Zend_Controller_Router_Abstract
      * Determines/returns whether to use the request parameters as global parameters.
      *
      * @param boolean|null $use
-     *           Null/unset when you want to retrieve the current state.
-     *           True when request parameters should be global, false otherwise
+     *              Null/unset when you want to retrieve the current state.
+     *              True when request parameters should be global, false otherwise
      * @return boolean|Zend_Controller_Router_Rewrite
      *              Returns a boolean if first param isn't set, returns an
      *              instance of Zend_Controller_Router_Rewrite otherwise.
      *
      */
-    public function useRequestParametersAsGlobal($use = null) {
-        if($use === null) {
+    public function useRequestParametersAsGlobal($use = null)
+    {
+        if ($use === null) {
             return $this->_useCurrentParamsAsGlobal;
         }
 
-        $this->_useCurrentParamsAsGlobal = (bool) $use;
+        $this->_useCurrentParamsAsGlobal = (bool)$use;
 
         return $this;
     }

+ 72 - 36
library/Zend/Controller/Router/Route.php

@@ -34,6 +34,7 @@ require_once 'Zend/Controller/Router/Route/Abstract.php';
  */
 class Zend_Controller_Router_Route extends Zend_Controller_Router_Route_Abstract
 {
+
     /**
      * Default translator
      *
@@ -77,12 +78,16 @@ class Zend_Controller_Router_Route extends Zend_Controller_Router_Route_Abstract
     protected $_translatable = array();
 
     protected $_urlVariable = ':';
+
     protected $_urlDelimiter = self::URI_DELIMITER;
+
     protected $_regexDelimiter = '#';
+
     protected $_defaultRegex = null;
 
     /**
      * Holds names of all route's pattern variable names. Array index holds a position in URL.
+     *
      * @var array
      */
     protected $_variables = array();
@@ -91,12 +96,14 @@ class Zend_Controller_Router_Route extends Zend_Controller_Router_Route_Abstract
      * Holds Route patterns for all URL parts. In case of a variable it stores it's regex
      * requirement or null. In case of a static part, it holds only it's direct value.
      * In case of a wildcard, it stores an asterisk (*)
+     *
      * @var array
      */
     protected $_parts = array();
 
     /**
      * Holds user submitted default values for route's variables. Name and value pairs.
+     *
      * @var array
      */
     protected $_defaults = array();
@@ -104,6 +111,7 @@ class Zend_Controller_Router_Route extends Zend_Controller_Router_Route_Abstract
     /**
      * Holds user submitted regular expression patterns for route's variables' values.
      * Name and value pairs.
+     *
      * @var array
      */
     protected $_requirements = array();
@@ -111,6 +119,7 @@ class Zend_Controller_Router_Route extends Zend_Controller_Router_Route_Abstract
     /**
      * Associative array filled on match() that holds matched path values
      * for given variable names.
+     *
      * @var array
      */
     protected $_values = array();
@@ -118,6 +127,7 @@ class Zend_Controller_Router_Route extends Zend_Controller_Router_Route_Abstract
     /**
      * Associative array filled on match() that holds wildcard variable
      * names and values.
+     *
      * @var array
      */
     protected $_wildcardData = array();
@@ -125,11 +135,13 @@ class Zend_Controller_Router_Route extends Zend_Controller_Router_Route_Abstract
     /**
      * Helper var that holds a count of route pattern's static parts
      * for validation
+     *
      * @var int
      */
     protected $_staticCount = 0;
 
-    public function getVersion() {
+    public function getVersion()
+    {
         return 1;
     }
 
@@ -143,6 +155,7 @@ class Zend_Controller_Router_Route extends Zend_Controller_Router_Route_Abstract
     {
         $reqs = ($config->reqs instanceof Zend_Config) ? $config->reqs->toArray() : array();
         $defs = ($config->defaults instanceof Zend_Config) ? $config->defaults->toArray() : array();
+
         return new self($config->route, $defs, $reqs);
     }
 
@@ -157,11 +170,13 @@ class Zend_Controller_Router_Route extends Zend_Controller_Router_Route_Abstract
      * @param Zend_Translate $translator Translator to use for this instance
      * @param mixed|null     $locale
      */
-    public function __construct($route, $defaults = array(), $reqs = array(), Zend_Translate $translator = null, $locale = null)
+    public function __construct(
+        $route, $defaults = array(), $reqs = array(), Zend_Translate $translator = null, $locale = null
+    )
     {
         $route               = trim($route, $this->_urlDelimiter);
-        $this->_defaults     = (array) $defaults;
-        $this->_requirements = (array) $reqs;
+        $this->_defaults     = (array)$defaults;
+        $this->_requirements = (array)$reqs;
         $this->_translator   = $translator;
         $this->_locale       = $locale;
 
@@ -238,10 +253,12 @@ class Zend_Controller_Router_Route extends Zend_Controller_Router_Route_Abstract
                 // If it's a wildcard, get the rest of URL as wildcard data and stop matching
                 if ($this->_parts[$pos] == '*') {
                     $count = count($path);
-                    for($i = $pos; $i < $count; $i+=2) {
+                    for ($i = $pos; $i < $count; $i += 2) {
                         $var = urldecode($path[$i]);
-                        if (!isset($this->_wildcardData[$var]) && !isset($this->_defaults[$var]) && !isset($values[$var])) {
-                            $this->_wildcardData[$var] = (isset($path[$i+1])) ? urldecode($path[$i+1]) : null;
+                        if (!isset($this->_wildcardData[$var]) && !isset($this->_defaults[$var])
+                            && !isset($values[$var])
+                        ) {
+                            $this->_wildcardData[$var] = (isset($path[$i + 1])) ? urldecode($path[$i + 1]) : null;
                         }
                     }
 
@@ -254,7 +271,11 @@ class Zend_Controller_Router_Route extends Zend_Controller_Router_Route_Abstract
 
                 // Translate value if required
                 $part = $this->_parts[$pos];
-                if ($this->_isTranslated && (substr($part, 0, 1) === '@' && substr($part, 1, 1) !== '@' && $name === null) || $name !== null && in_array($name, $this->_translatable)) {
+                if ($this->_isTranslated
+                    && (substr($part, 0, 1) === '@' && substr($part, 1, 1) !== '@'
+                        && $name === null)
+                    || $name !== null && in_array($name, $this->_translatable)
+                ) {
                     if (substr($part, 0, 1) === '@') {
                         $part = substr($part, 1);
                     }
@@ -274,7 +295,11 @@ class Zend_Controller_Router_Route extends Zend_Controller_Router_Route_Abstract
                 }
 
                 // If it's a variable with requirement, match a regex. If not - everything matches
-                if ($part !== null && !preg_match($this->_regexDelimiter . '^' . $part . '$' . $this->_regexDelimiter . 'iu', $pathPart)) {
+                if ($part !== null
+                    && !preg_match(
+                        $this->_regexDelimiter . '^' . $part . '$' . $this->_regexDelimiter . 'iu', $pathPart
+                    )
+                ) {
                     return false;
                 }
 
@@ -309,7 +334,6 @@ class Zend_Controller_Router_Route extends Zend_Controller_Router_Route_Abstract
         $this->_values = $values;
 
         return $return;
-
     }
 
     /**
@@ -381,13 +405,15 @@ class Zend_Controller_Router_Route extends Zend_Controller_Router_Route_Abstract
                     $url[$key] = $part;
                 }
             } else {
-                if (!$reset) $data += $this->_wildcardData;
+                if (!$reset) {
+                    $data += $this->_wildcardData;
+                }
                 $defaults = $this->getDefaults();
                 foreach ($data as $var => $value) {
                     if ($value !== null && (!isset($defaults[$var]) || $value != $defaults[$var])) {
                         $url[$key++] = $var;
                         $url[$key++] = $value;
-                        $flag = true;
+                        $flag        = true;
                     }
                 }
             }
@@ -401,20 +427,23 @@ class Zend_Controller_Router_Route extends Zend_Controller_Router_Route_Abstract
             if (isset($this->_variables[$key])) {
                 $defaultValue = $this->getDefault($this->_variables[$key]);
 
-                if ($this->_isTranslated && $defaultValue !== null && isset($this->_translatable[$this->_variables[$key]])) {
+                if ($this->_isTranslated && $defaultValue !== null
+                    && isset($this->_translatable[$this->_variables[$key]])
+                ) {
                     $defaultValue = $translator->translate($defaultValue, $locale);
                 }
             }
 
             if ($flag || $value !== $defaultValue || $partial) {
-                if ($encode) $value = urlencode($value);
+                if ($encode) {
+                    $value = urlencode($value);
+                }
                 $return = $this->_urlDelimiter . $value . $return;
-                $flag = true;
+                $flag   = true;
             }
         }
 
         return trim($return, $this->_urlDelimiter);
-
     }
 
     /**
@@ -423,10 +452,12 @@ class Zend_Controller_Router_Route extends Zend_Controller_Router_Route_Abstract
      * @param string $name Array key of the parameter
      * @return string Previously set default
      */
-    public function getDefault($name) {
+    public function getDefault($name)
+    {
         if (isset($this->_defaults[$name])) {
             return $this->_defaults[$name];
         }
+
         return null;
     }
 
@@ -435,7 +466,8 @@ class Zend_Controller_Router_Route extends Zend_Controller_Router_Route_Abstract
      *
      * @return array Route defaults
      */
-    public function getDefaults() {
+    public function getDefaults()
+    {
         return $this->_defaults;
     }
 
@@ -491,17 +523,19 @@ class Zend_Controller_Router_Route extends Zend_Controller_Router_Route_Abstract
     {
         if ($this->_translator !== null) {
             return $this->_translator;
-        } else if (($translator = self::getDefaultTranslator()) !== null) {
-            return $translator;
         } else {
-            try {
-                $translator = Zend_Registry::get('Zend_Translate');
-            } catch (Zend_Exception $e) {
-                $translator = null;
-            }
-
-            if ($translator instanceof Zend_Translate) {
+            if (($translator = self::getDefaultTranslator()) !== null) {
                 return $translator;
+            } else {
+                try {
+                    $translator = Zend_Registry::get('Zend_Translate');
+                } catch (Zend_Exception $e) {
+                    $translator = null;
+                }
+
+                if ($translator instanceof Zend_Translate) {
+                    return $translator;
+                }
             }
         }
 
@@ -550,17 +584,19 @@ class Zend_Controller_Router_Route extends Zend_Controller_Router_Route_Abstract
     {
         if ($this->_locale !== null) {
             return $this->_locale;
-        } else if (($locale = self::getDefaultLocale()) !== null) {
-            return $locale;
         } else {
-            try {
-                $locale = Zend_Registry::get('Zend_Locale');
-            } catch (Zend_Exception $e) {
-                $locale = null;
-            }
-
-            if ($locale !== null) {
+            if (($locale = self::getDefaultLocale()) !== null) {
                 return $locale;
+            } else {
+                try {
+                    $locale = Zend_Registry::get('Zend_Locale');
+                } catch (Zend_Exception $e) {
+                    $locale = null;
+                }
+
+                if ($locale !== null) {
+                    return $locale;
+                }
             }
         }
 

+ 1 - 2
library/Zend/Controller/Router/Route/Abstract.php

@@ -41,7 +41,7 @@ abstract class Zend_Controller_Router_Route_Abstract implements Zend_Controller_
      * URI delimiter
      */
     const URI_DELIMITER = '/';
-    
+
     /**
      * Wether this route is abstract or not
      *
@@ -118,5 +118,4 @@ abstract class Zend_Controller_Router_Route_Abstract implements Zend_Controller_
 
         return $chain;
     }
-
 }

+ 5 - 4
library/Zend/Controller/Router/Route/Chain.php

@@ -33,6 +33,7 @@ require_once 'Zend/Controller/Router/Route/Abstract.php';
  */
 class Zend_Controller_Router_Route_Chain extends Zend_Controller_Router_Route_Abstract
 {
+
     /**
      * Routes
      *
@@ -56,6 +57,7 @@ class Zend_Controller_Router_Route_Chain extends Zend_Controller_Router_Route_Ab
     public static function getInstance(Zend_Config $config)
     {
         $defs = ($config->defaults instanceof Zend_Config) ? $config->defaults->toArray() : array();
+
         return new self($config->route, $defs);
     }
 
@@ -72,7 +74,6 @@ class Zend_Controller_Router_Route_Chain extends Zend_Controller_Router_Route_Ab
         $this->_separators[] = $separator;
 
         return $this;
-
     }
 
     /**
@@ -122,8 +123,8 @@ class Zend_Controller_Router_Route_Chain extends Zend_Controller_Router_Route_Ab
             $matchedPath = $route->getMatchedPath();
 
             if ($matchedPath !== null) {
-                $subPath     = substr($subPath, strlen($matchedPath));
-                $separator   = substr($subPath, 0, strlen($this->_separators[$key]));
+                $subPath   = substr($subPath, strlen($matchedPath));
+                $separator = substr($subPath, 0, strlen($this->_separators[$key]));
             }
 
             $values = $res + $values;
@@ -186,7 +187,7 @@ class Zend_Controller_Router_Route_Chain extends Zend_Controller_Router_Route_Ab
             }
         }
     }
-    
+
     /**
      * Return a single parameter of route's defaults
      *

+ 30 - 16
library/Zend/Controller/Router/Route/Hostname.php

@@ -34,12 +34,13 @@ require_once 'Zend/Controller/Router/Route/Abstract.php';
  */
 class Zend_Controller_Router_Route_Hostname extends Zend_Controller_Router_Route_Abstract
 {
+
     /**
      * Host variable
      *
      * @var string
      */
-    protected $_hostVariable   = ':';
+    protected $_hostVariable = ':';
 
     /**
      * Regex delimiter
@@ -53,7 +54,7 @@ class Zend_Controller_Router_Route_Hostname extends Zend_Controller_Router_Route
      *
      * @var string|null
      */
-    protected $_defaultRegex   = null;
+    protected $_defaultRegex = null;
 
     /**
      * Holds names of all route's pattern variable names. Array index holds a position in host.
@@ -110,6 +111,7 @@ class Zend_Controller_Router_Route_Hostname extends Zend_Controller_Router_Route
     /**
      * Helper var that holds a count of route pattern's static parts
      * for validation
+     *
      * @var int
      */
     private $_staticCount = 0;
@@ -150,6 +152,7 @@ class Zend_Controller_Router_Route_Hostname extends Zend_Controller_Router_Route
         $reqs   = ($config->reqs instanceof Zend_Config) ? $config->reqs->toArray() : array();
         $defs   = ($config->defaults instanceof Zend_Config) ? $config->defaults->toArray() : array();
         $scheme = (isset($config->scheme)) ? $config->scheme : null;
+
         return new self($config->route, $defs, $reqs, $scheme);
     }
 
@@ -158,9 +161,9 @@ class Zend_Controller_Router_Route_Hostname extends Zend_Controller_Router_Route
      * to a corresponding atomic parts. These parts are assigned
      * a position which is later used for matching and preparing values.
      *
-     * @param string $route Map used to match with later submitted hostname
+     * @param string $route    Map used to match with later submitted hostname
      * @param array  $defaults Defaults for map variables with keys as variable names
-     * @param array  $reqs Regular expression requirements for variables (keys as variable names)
+     * @param array  $reqs     Regular expression requirements for variables (keys as variable names)
      * @param string $scheme
      */
     public function __construct($route, $defaults = array(), $reqs = array(), $scheme = null)
@@ -173,8 +176,8 @@ class Zend_Controller_Router_Route_Hostname extends Zend_Controller_Router_Route
         if ($route != '') {
             foreach (explode('.', $route) as $pos => $part) {
                 if (substr($part, 0, 1) == $this->_hostVariable) {
-                    $name = substr($part, 1);
-                    $this->_parts[$pos] = (isset($reqs[$name]) ? $reqs[$name] : $this->_defaultRegex);
+                    $name                   = substr($part, 1);
+                    $this->_parts[$pos]     = (isset($reqs[$name]) ? $reqs[$name] : $this->_defaultRegex);
                     $this->_variables[$pos] = $name;
                 } else {
                     $this->_parts[$pos] = $part;
@@ -209,7 +212,7 @@ class Zend_Controller_Router_Route_Hostname extends Zend_Controller_Router_Route
         }
 
         $hostStaticCount = 0;
-        $values = array();
+        $values          = array();
 
         $host = trim($host, '.');
 
@@ -222,7 +225,7 @@ class Zend_Controller_Router_Route_Hostname extends Zend_Controller_Router_Route
                     return false;
                 }
 
-                $name = isset($this->_variables[$pos]) ? $this->_variables[$pos] : null;
+                $name     = isset($this->_variables[$pos]) ? $this->_variables[$pos] : null;
                 $hostPart = urldecode($hostPart);
 
                 // If it's a static part, match directly
@@ -231,7 +234,12 @@ class Zend_Controller_Router_Route_Hostname extends Zend_Controller_Router_Route
                 }
 
                 // If it's a variable with requirement, match a regex. If not - everything matches
-                if ($this->_parts[$pos] !== null && !preg_match($this->_regexDelimiter . '^' . $this->_parts[$pos] . '$' . $this->_regexDelimiter . 'iu', $hostPart)) {
+                if ($this->_parts[$pos] !== null
+                    && !preg_match(
+                        $this->_regexDelimiter . '^' . $this->_parts[$pos] . '$' . $this->_regexDelimiter . 'iu',
+                        $hostPart
+                    )
+                ) {
                     return false;
                 }
 
@@ -261,7 +269,6 @@ class Zend_Controller_Router_Route_Hostname extends Zend_Controller_Router_Route
         $this->_values = $values;
 
         return $return;
-
     }
 
     /**
@@ -307,10 +314,14 @@ class Zend_Controller_Router_Route_Hostname extends Zend_Controller_Router_Route
         $return = '';
 
         foreach (array_reverse($host, true) as $key => $value) {
-            if ($flag || !isset($this->_variables[$key]) || $value !== $this->getDefault($this->_variables[$key]) || $partial) {
-                if ($encode) $value = urlencode($value);
+            if ($flag || !isset($this->_variables[$key]) || $value !== $this->getDefault($this->_variables[$key])
+                || $partial
+            ) {
+                if ($encode) {
+                    $value = urlencode($value);
+                }
                 $return = '.' . $value . $return;
-                $flag = true;
+                $flag   = true;
             }
         }
 
@@ -327,7 +338,7 @@ class Zend_Controller_Router_Route_Hostname extends Zend_Controller_Router_Route
             }
         }
 
-        $url      = $scheme . '://' . $url;
+        $url = $scheme . '://' . $url;
 
         return $url;
     }
@@ -338,10 +349,12 @@ class Zend_Controller_Router_Route_Hostname extends Zend_Controller_Router_Route
      * @param string $name Array key of the parameter
      * @return string Previously set default
      */
-    public function getDefault($name) {
+    public function getDefault($name)
+    {
         if (isset($this->_defaults[$name])) {
             return $this->_defaults[$name];
         }
+
         return null;
     }
 
@@ -350,7 +363,8 @@ class Zend_Controller_Router_Route_Hostname extends Zend_Controller_Router_Route
      *
      * @return array Route defaults
      */
-    public function getDefaults() {
+    public function getDefaults()
+    {
         return $this->_defaults;
     }
 

+ 5 - 3
library/Zend/Controller/Router/Route/Interface.php

@@ -29,9 +29,11 @@ require_once 'Zend/Config.php';
  * @copyright  Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
-interface Zend_Controller_Router_Route_Interface {
+interface Zend_Controller_Router_Route_Interface
+{
     public function match($path);
+
     public function assemble($data = array(), $reset = false, $encode = false);
-    public static function getInstance(Zend_Config $config);
-}
 
+    public static function getInstance(Zend_Config $config);
+}

+ 31 - 17
library/Zend/Controller/Router/Route/Module.php

@@ -36,6 +36,7 @@ require_once 'Zend/Controller/Router/Route/Abstract.php';
  */
 class Zend_Controller_Router_Route_Module extends Zend_Controller_Router_Route_Abstract
 {
+
     /**
      * Default values for the route (ie. module, controller, action, params)
      *
@@ -62,6 +63,7 @@ class Zend_Controller_Router_Route_Module extends Zend_Controller_Router_Route_A
 
     /**#@+
      * Array keys to use for module, controller, and action. Should be taken out of request.
+     *
      * @var string
      */
     protected $_moduleKey     = 'module';
@@ -84,7 +86,8 @@ class Zend_Controller_Router_Route_Module extends Zend_Controller_Router_Route_A
      *
      * @return int
      */
-    public function getVersion() {
+    public function getVersion()
+    {
         return 1;
     }
 
@@ -108,13 +111,15 @@ class Zend_Controller_Router_Route_Module extends Zend_Controller_Router_Route_A
     /**
      * Constructor
      *
-     * @param array $defaults Defaults for map variables with keys as variable names
+     * @param array                                $defaults   Defaults for map variables with keys as variable names
      * @param Zend_Controller_Dispatcher_Interface $dispatcher Dispatcher object
-     * @param Zend_Controller_Request_Abstract $request Request object
+     * @param Zend_Controller_Request_Abstract     $request    Request object
      */
-    public function __construct(array $defaults = array(),
-                Zend_Controller_Dispatcher_Interface $dispatcher = null,
-                Zend_Controller_Request_Abstract $request = null)
+    public function __construct(
+        array $defaults = array(),
+        Zend_Controller_Dispatcher_Interface $dispatcher = null,
+        Zend_Controller_Request_Abstract $request = null
+    )
     {
         $this->_defaults = $defaults;
 
@@ -181,7 +186,7 @@ class Zend_Controller_Router_Route_Module extends Zend_Controller_Router_Route_A
 
             if ($this->_dispatcher && $this->_dispatcher->isValidModule($path[0])) {
                 $values[$this->_moduleKey] = array_shift($path);
-                $this->_moduleValid = true;
+                $this->_moduleValid        = true;
             }
 
             if (count($path) && !empty($path[0])) {
@@ -194,9 +199,9 @@ class Zend_Controller_Router_Route_Module extends Zend_Controller_Router_Route_A
 
             if ($numSegs = count($path)) {
                 for ($i = 0; $i < $numSegs; $i = $i + 2) {
-                    $key = urldecode($path[$i]);
-                    $val = isset($path[$i + 1]) ? urldecode($path[$i + 1]) : null;
-                    $params[$key] = (isset($params[$key]) ? (array_merge((array) $params[$key], array($val))): $val);
+                    $key          = urldecode($path[$i]);
+                    $val          = isset($path[$i + 1]) ? urldecode($path[$i + 1]) : null;
+                    $params[$key] = (isset($params[$key]) ? (array_merge((array)$params[$key], array($val))) : $val);
                 }
             }
         }
@@ -261,24 +266,32 @@ class Zend_Controller_Router_Route_Module extends Zend_Controller_Router_Route_A
                     $url .= self::URI_DELIMITER . $arrayValue;
                 }
             } else {
-                if ($encode) $value = urlencode($value);
+                if ($encode) {
+                    $value = urlencode($value);
+                }
                 $url .= self::URI_DELIMITER . $key;
                 $url .= self::URI_DELIMITER . $value;
             }
         }
 
         if (!empty($url) || $action !== $this->_defaults[$this->_actionKey]) {
-            if ($encode) $action = urlencode($action);
+            if ($encode) {
+                $action = urlencode($action);
+            }
             $url = self::URI_DELIMITER . $action . $url;
         }
 
         if (!empty($url) || $controller !== $this->_defaults[$this->_controllerKey]) {
-            if ($encode) $controller = urlencode($controller);
+            if ($encode) {
+                $controller = urlencode($controller);
+            }
             $url = self::URI_DELIMITER . $controller . $url;
         }
 
         if (isset($module)) {
-            if ($encode) $module = urlencode($module);
+            if ($encode) {
+                $module = urlencode($module);
+            }
             $url = self::URI_DELIMITER . $module . $url;
         }
 
@@ -291,7 +304,8 @@ class Zend_Controller_Router_Route_Module extends Zend_Controller_Router_Route_A
      * @param string $name Array key of the parameter
      * @return string Previously set default
      */
-    public function getDefault($name) {
+    public function getDefault($name)
+    {
         if (isset($this->_defaults[$name])) {
             return $this->_defaults[$name];
         }
@@ -302,8 +316,8 @@ class Zend_Controller_Router_Route_Module extends Zend_Controller_Router_Route_A
      *
      * @return array Route defaults
      */
-    public function getDefaults() {
+    public function getDefaults()
+    {
         return $this->_defaults;
     }
-
 }

+ 17 - 14
library/Zend/Controller/Router/Route/Regex.php

@@ -33,6 +33,7 @@ require_once 'Zend/Controller/Router/Route/Abstract.php';
  */
 class Zend_Controller_Router_Route_Regex extends Zend_Controller_Router_Route_Abstract
 {
+
     /**
      * Regex string
      *
@@ -76,9 +77,10 @@ class Zend_Controller_Router_Route_Regex extends Zend_Controller_Router_Route_Ab
      */
     public static function getInstance(Zend_Config $config)
     {
-        $defs = ($config->defaults instanceof Zend_Config) ? $config->defaults->toArray() : array();
-        $map = ($config->map instanceof Zend_Config) ? $config->map->toArray() : array();
+        $defs    = ($config->defaults instanceof Zend_Config) ? $config->defaults->toArray() : array();
+        $map     = ($config->map instanceof Zend_Config) ? $config->map->toArray() : array();
         $reverse = (isset($config->reverse)) ? $config->reverse : null;
+
         return new self($config->route, $defs, $map, $reverse);
     }
 
@@ -103,7 +105,8 @@ class Zend_Controller_Router_Route_Regex extends Zend_Controller_Router_Route_Ab
      *
      * @return int
      */
-    public function getVersion() {
+    public function getVersion()
+    {
         return 1;
     }
 
@@ -117,7 +120,7 @@ class Zend_Controller_Router_Route_Regex extends Zend_Controller_Router_Route_Ab
     public function match($path, $partial = false)
     {
         if (!$partial) {
-            $path = trim(urldecode($path), self::URI_DELIMITER);
+            $path  = trim(urldecode($path), self::URI_DELIMITER);
             $regex = '#^' . $this->_regex . '$#i';
         } else {
             $regex = '#^' . $this->_regex . '#i';
@@ -158,7 +161,7 @@ class Zend_Controller_Router_Route_Regex extends Zend_Controller_Router_Route_Ab
      * indexed numerically then every associative key will be stripped. Vice versa if reversed
      * is set to true.
      *
-     * @param  array   $values Indexed or associative array of values to map
+     * @param  array   $values   Indexed or associative array of values to map
      * @param  boolean $reversed False means translation of index to association. True means reverse.
      * @param  boolean $preserve Should wrong type of keys be preserved or stripped.
      * @return array   An array of mapped values
@@ -216,13 +219,13 @@ class Zend_Controller_Router_Route_Regex extends Zend_Controller_Router_Route_Ab
             throw new Zend_Controller_Router_Exception('Cannot assemble. Reversed route is not specified.');
         }
 
-        $defaultValuesMapped  = $this->_getMappedValues($this->_defaults, true, false);
-        $matchedValuesMapped  = $this->_getMappedValues($this->_values, true, false);
-        $dataValuesMapped     = $this->_getMappedValues($data, true, false);
+        $defaultValuesMapped = $this->_getMappedValues($this->_defaults, true, false);
+        $matchedValuesMapped = $this->_getMappedValues($this->_values, true, false);
+        $dataValuesMapped    = $this->_getMappedValues($data, true, false);
 
         // handle resets, if so requested (By null value) to do so
         if (($resetKeys = array_search(null, $dataValuesMapped, true)) !== false) {
-            foreach ((array) $resetKeys as $resetKey) {
+            foreach ((array)$resetKeys as $resetKey) {
                 if (isset($matchedValuesMapped[$resetKey])) {
                     unset($matchedValuesMapped[$resetKey]);
                     unset($dataValuesMapped[$resetKey]);
@@ -251,7 +254,6 @@ class Zend_Controller_Router_Route_Regex extends Zend_Controller_Router_Route_Ab
         }
 
         return $return;
-
     }
 
     /**
@@ -260,7 +262,8 @@ class Zend_Controller_Router_Route_Regex extends Zend_Controller_Router_Route_Ab
      * @param string $name Array key of the parameter
      * @return string Previously set default
      */
-    public function getDefault($name) {
+    public function getDefault($name)
+    {
         if (isset($this->_defaults[$name])) {
             return $this->_defaults[$name];
         }
@@ -271,7 +274,8 @@ class Zend_Controller_Router_Route_Regex extends Zend_Controller_Router_Route_Ab
      *
      * @return array Route defaults
      */
-    public function getDefaults() {
+    public function getDefaults()
+    {
         return $this->_defaults;
     }
 
@@ -309,8 +313,7 @@ class Zend_Controller_Router_Route_Regex extends Zend_Controller_Router_Route_Ab
         foreach ($array2 as $array2Index => $array2Value) {
             $returnArray[$array2Index] = $array2Value;
         }
+
         return $returnArray;
     }
-
-
 }

+ 13 - 7
library/Zend/Controller/Router/Route/Static.php

@@ -35,6 +35,7 @@ require_once 'Zend/Controller/Router/Route/Abstract.php';
  */
 class Zend_Controller_Router_Route_Static extends Zend_Controller_Router_Route_Abstract
 {
+
     /**
      * Route
      *
@@ -54,7 +55,8 @@ class Zend_Controller_Router_Route_Static extends Zend_Controller_Router_Route_A
      *
      * @return int
      */
-    public function getVersion() {
+    public function getVersion()
+    {
         return 1;
     }
 
@@ -67,18 +69,19 @@ class Zend_Controller_Router_Route_Static extends Zend_Controller_Router_Route_A
     public static function getInstance(Zend_Config $config)
     {
         $defs = ($config->defaults instanceof Zend_Config) ? $config->defaults->toArray() : array();
+
         return new self($config->route, $defs);
     }
 
     /**
      * Prepares the route for mapping.
      *
-     * @param string $route Map used to match with later submitted URL path
-     * @param array $defaults Defaults for map variables with keys as variable names
+     * @param string $route    Map used to match with later submitted URL path
+     * @param array  $defaults Defaults for map variables with keys as variable names
      */
     public function __construct($route, $defaults = array())
     {
-        $this->_route = trim($route, self::URI_DELIMITER);
+        $this->_route    = trim($route, self::URI_DELIMITER);
         $this->_defaults = (array) $defaults;
     }
 
@@ -96,6 +99,7 @@ class Zend_Controller_Router_Route_Static extends Zend_Controller_Router_Route_A
                 || (substr($path, 0, strlen($this->_route)) === $this->_route)
             ) {
                 $this->setMatchedPath($this->_route);
+
                 return $this->_defaults;
             }
         } else {
@@ -124,10 +128,12 @@ class Zend_Controller_Router_Route_Static extends Zend_Controller_Router_Route_A
      * @param string $name Array key of the parameter
      * @return string Previously set default
      */
-    public function getDefault($name) {
+    public function getDefault($name)
+    {
         if (isset($this->_defaults[$name])) {
             return $this->_defaults[$name];
         }
+
         return null;
     }
 
@@ -136,8 +142,8 @@ class Zend_Controller_Router_Route_Static extends Zend_Controller_Router_Route_A
      *
      * @return array Route defaults
      */
-    public function getDefaults() {
+    public function getDefaults()
+    {
         return $this->_defaults;
     }
-
 }