Skip to content

Commit

Permalink
Resolves a dozen of bogus docblocks in the MVC component
Browse files Browse the repository at this point in the history
  • Loading branch information
unknown committed Mar 20, 2012
1 parent d11b139 commit b47b6ab
Show file tree
Hide file tree
Showing 15 changed files with 222 additions and 220 deletions.
44 changes: 22 additions & 22 deletions library/Zend/Mvc/Router/Http/Hostname.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,46 +49,46 @@ class Hostname implements Route

/**
* Constraints for parameters.
*
*
* @var array
*/
protected $constraints;

/**
* Default values.
*
* @var array
*/
protected $defaults;

/**
* List of assembled parameters.
*
*
* @var array
*/
protected $assembledParams = array();

/**
* Create a new hostname route.
*
*
* @param string $route
* @param array $constraints
* @param array $defaults
* @return void
* @param array $defaults
*/
public function __construct($route, array $constraints = array(), array $defaults = array())
{
$this->route = explode('.', $route);
$this->constraints = $constraints;
$this->defaults = $defaults;
}

/**
* factory(): defined by Route interface.
*
* @see Route::factory()
* @param array|Traversable $options
* @return void
* @param array|\Traversable $options
* @throws \Zend\Mvc\Router\Exception\InvalidArgumentException
* @return Hostname
*/
public static function factory($options = array())
{
Expand All @@ -105,7 +105,7 @@ public static function factory($options = array())
if (!isset($options['constraints'])) {
$options['constraints'] = array();
}

if (!isset($options['defaults'])) {
$options['defaults'] = array();
}
Expand Down Expand Up @@ -133,19 +133,19 @@ public function match(Request $request)
if (count($hostname) !== count($this->route)) {
return null;
}

foreach ($this->route as $index => $routePart) {
if (preg_match('(^:(?<name>.+)$)', $routePart, $matches)) {
if (isset($this->constraints[$matches['name']]) && !preg_match('(^' . $this->constraints[$matches['name']] . '$)', $hostname[$index])) {
return null;
}

$params[$matches['name']] = $hostname[$index];
} elseif ($hostname[$index] !== $routePart) {
return null;
}
}

return new RouteMatch(array_merge($this->defaults, $params));
}

Expand All @@ -161,34 +161,34 @@ public function assemble(array $params = array(), array $options = array())
{
$mergedParams = array_merge($this->defaults, $params);
$this->assembledParams = array();

if (isset($options['uri'])) {
$parts = array();

foreach ($this->route as $index => $routePart) {
if (preg_match('(^:(?<name>.+)$)', $routePart, $matches)) {
if (!isset($mergedParams[$matches['name']])) {
throw new Exception\InvalidArgumentException(sprintf('Missing parameter "%s"', $matches['name']));
}

$parts[] = $mergedParams[$matches['name']];

$this->assembledParams[] = $matches['name'];
} else {
$parts[] = $routePart;
}
}

$options['uri']->setHost(implode('.', $parts));
}

// A hostname does not contribute to the path, thus nothing is returned.
return '';
}

/**
* getAssembledParams(): defined by Route interface.
*
*
* @see Route::getAssembledParams
* @return array
*/
Expand Down
23 changes: 12 additions & 11 deletions library/Zend/Mvc/Router/Http/Literal.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,23 +56,23 @@ class Literal implements Route

/**
* Create a new literal route.
*
*
* @param string $route
* @param array $defaults
* @return void
* @param array $defaults
*/
public function __construct($route, array $defaults = array())
{
$this->route = $route;
$this->defaults = $defaults;
}

/**
* factory(): defined by Route interface.
*
* @see Route::factory()
* @param array|Traversable $options
* @return void
* @param array|\Traversable $options
* @throws \Zend\Mvc\Router\Exception\InvalidArgumentException
* @return Literal
*/
public static function factory($options = array())
{
Expand All @@ -97,8 +97,9 @@ public static function factory($options = array())
* match(): defined by Route interface.
*
* @see Route::match()
* @param Request $request
* @return RouteMatch
* @param Request $request
* @param int|null $pathOffset
* @return RouteMatch|null
*/
public function match(Request $request, $pathOffset = null)
{
Expand All @@ -115,7 +116,7 @@ public function match(Request $request, $pathOffset = null)
return new RouteMatch($this->defaults, strlen($this->route));
}
}

return null;
}

Expand All @@ -138,10 +139,10 @@ public function assemble(array $params = array(), array $options = array())
{
return $this->route;
}

/**
* getAssembledParams(): defined by Route interface.
*
*
* @see Route::getAssembledParams
* @return array
*/
Expand Down
9 changes: 5 additions & 4 deletions library/Zend/Mvc/Router/Http/Part.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ class Part extends TreeRouteStack implements Route
* @param mixed $route
* @param boolean $mayTerminate
* @param RouteBroker $routeBroker
* @param array $childRoutes
* @return void
* @param array|null $childRoutes
*/
public function __construct($route, $mayTerminate, RouteBroker $routeBroker, array $childRoutes = null)
{
Expand All @@ -95,7 +94,8 @@ public function __construct($route, $mayTerminate, RouteBroker $routeBroker, arr
*
* @see Route::factory()
* @param mixed $options
* @return void
* @throws \Zend\Mvc\Router\Exception\InvalidArgumentException
* @return Part
*/
public static function factory($options = array())
{
Expand Down Expand Up @@ -131,7 +131,8 @@ public static function factory($options = array())
* match(): defined by Route interface.
*
* @see Route::match()
* @param Request $request
* @param Request $request
* @param int|null $pathOffset
* @return RouteMatch|null
*/
public function match(Request $request, $pathOffset = null)
Expand Down
35 changes: 18 additions & 17 deletions library/Zend/Mvc/Router/Http/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,38 +42,38 @@
*/
class Query implements Route
{

/**
* Default values.
*
*
* @var array
*/
protected $defaults;

/**
* List of assembled parameters.
*
*
* @var array
*/
protected $assembledParams = array();

/**
* Create a new wildcard route.
*
* @param array $defaults
* @return void
*
* @param array $defaults
*/
public function __construct(array $defaults = array())
{
$this->defaults = $defaults;
}

/**
* factory(): defined by Route interface.
*
* @see Route::factory()
* @param array|Traversable $options
* @return void
* @param array|\Traversable $options
* @throws \Zend\Mvc\Router\Exception\InvalidArgumentException
* @return Query
*/
public static function factory($options = array())
{
Expand All @@ -83,7 +83,7 @@ public static function factory($options = array())
throw new Exception\InvalidArgumentException(__METHOD__ . ' expects an array or Traversable set of options');
}


if (!isset($options['defaults'])) {
$options['defaults'] = array();
}
Expand All @@ -96,15 +96,16 @@ public static function factory($options = array())
*
* @see Route::match()
* @param Request $request
* @param int|null $pathOffset
* @return RouteMatch
*/
public function match(Request $request, $pathOffset = null)
{
$matches = array();

foreach($_GET as $key=>$value) {
$matches[urldecode($key)] = urldecode($value);

}

return new RouteMatch(array_merge($this->defaults, $matches));
Expand All @@ -126,16 +127,16 @@ public function assemble(array $params = array(), array $options = array())
foreach ($mergedParams as $key => $value) {
$this->assembledParams[] = $key;
}

return '?' . str_replace('+', '%20', http_build_query($mergedParams));
}

return null;
}

/**
* getAssembledParams(): defined by Route interface.
*
*
* @see Route::getAssembledParams
* @return array
*/
Expand Down
Loading

0 comments on commit b47b6ab

Please sign in to comment.