Fix PhpDoc errors
This commit is contained in:
parent
a5c180dace
commit
13e683225d
|
|
@ -1,11 +1,30 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* pjdietz\WellRESTed\HandlerUnpacker
|
||||||
|
*
|
||||||
|
* @author PJ Dietz <pj@pjdietz.com>
|
||||||
|
* @copyright Copyright 2015 by PJ Dietz
|
||||||
|
* @license MIT
|
||||||
|
*/
|
||||||
|
|
||||||
namespace pjdietz\WellRESTed;
|
namespace pjdietz\WellRESTed;
|
||||||
|
|
||||||
use pjdietz\WellRESTed\Interfaces\RequestInterface;
|
use pjdietz\WellRESTed\Interfaces\RequestInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class for retreiving a handler or response from a callable, string, or instance.
|
||||||
|
*/
|
||||||
class HandlerUnpacker
|
class HandlerUnpacker
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Return the handler or response from a callable, string, or instance.
|
||||||
|
*
|
||||||
|
* @param $handler
|
||||||
|
* @param RequestInterface $request
|
||||||
|
* @param array $args
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
public function unpack($handler, RequestInterface $request = null, array $args = null)
|
public function unpack($handler, RequestInterface $request = null, array $args = null)
|
||||||
{
|
{
|
||||||
if (is_callable($handler)) {
|
if (is_callable($handler)) {
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,9 @@
|
||||||
|
|
||||||
namespace pjdietz\WellRESTed\Interfaces\Routes;
|
namespace pjdietz\WellRESTed\Interfaces\Routes;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface for routes that map to paths begining with a given prefix or prefixes
|
||||||
|
*/
|
||||||
interface PrefixRouteInterface
|
interface PrefixRouteInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,9 @@
|
||||||
|
|
||||||
namespace pjdietz\WellRESTed\Interfaces\Routes;
|
namespace pjdietz\WellRESTed\Interfaces\Routes;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface for routes that map to an exact path or paths
|
||||||
|
*/
|
||||||
interface StaticRouteInterface
|
interface StaticRouteInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -92,7 +92,6 @@ abstract class Message
|
||||||
* Add or update a header to a given value
|
* Add or update a header to a given value
|
||||||
*
|
*
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @param $value
|
|
||||||
* @param string $value
|
* @param string $value
|
||||||
*/
|
*/
|
||||||
public function setHeader($name, $value)
|
public function setHeader($name, $value)
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,12 @@ class RouteBuilder
|
||||||
/** @var array Associative array of variable names and regex patterns. */
|
/** @var array Associative array of variable names and regex patterns. */
|
||||||
private $templateVariablePatterns;
|
private $templateVariablePatterns;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new RouteBuilder
|
||||||
|
*
|
||||||
|
* @deprecated Use {@see Router::add} instead.
|
||||||
|
* @see Router::add
|
||||||
|
*/
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
trigger_error("RouteBuilder is deprecated. Use Router::add", E_USER_DEPRECATED);
|
trigger_error("RouteBuilder is deprecated. Use Router::add", E_USER_DEPRECATED);
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ class Router implements HandlerInterface
|
||||||
{
|
{
|
||||||
/** @var array Hash array of status code => error handler */
|
/** @var array Hash array of status code => error handler */
|
||||||
private $errorHandlers;
|
private $errorHandlers;
|
||||||
/** @var RouteTable */
|
/** @var RouteTable Collection of routes */
|
||||||
private $routeTable;
|
private $routeTable;
|
||||||
|
|
||||||
/** Create a new Router. */
|
/** Create a new Router. */
|
||||||
|
|
@ -165,6 +165,15 @@ class Router implements HandlerInterface
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obtain a response from the register error handlers.
|
||||||
|
*
|
||||||
|
* @param int $status HTTP Status Code
|
||||||
|
* @param RequestInterface $request The original request
|
||||||
|
* @param null $args Optional additional data
|
||||||
|
* @param null $response The response providing the error
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
private function getErrorResponse($status, $request, $args = null, $response = null)
|
private function getErrorResponse($status, $request, $args = null, $response = null)
|
||||||
{
|
{
|
||||||
if (isset($this->errorHandlers[$status])) {
|
if (isset($this->errorHandlers[$status])) {
|
||||||
|
|
@ -212,6 +221,8 @@ class Router implements HandlerInterface
|
||||||
////////////////
|
////////////////
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Set a route for specific prefix
|
||||||
|
*
|
||||||
* @deprecated Use {@see addRoute} instead.
|
* @deprecated Use {@see addRoute} instead.
|
||||||
* @see addRoute
|
* @see addRoute
|
||||||
* @param array|string $prefixes
|
* @param array|string $prefixes
|
||||||
|
|
@ -224,6 +235,8 @@ class Router implements HandlerInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Set a route for a given path
|
||||||
|
*
|
||||||
* @deprecated Use {@see addRoute} instead.
|
* @deprecated Use {@see addRoute} instead.
|
||||||
* @see addRoute
|
* @see addRoute
|
||||||
* @param array|string $paths
|
* @param array|string $paths
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,17 @@ use ReflectionClass;
|
||||||
class RouteFactory
|
class RouteFactory
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
* Create and return a route given a string path, a handler, and optional extra arguments.
|
||||||
|
*
|
||||||
|
* The method will determine the most appropriate route subclass to use and will forward the arguments
|
||||||
|
* on to the subclass's constructor.
|
||||||
|
*
|
||||||
|
* - Paths with no special characters will generate StaticRoutes
|
||||||
|
* - Paths ending with * will generate PrefixRoutes
|
||||||
|
* - Paths containing URI variables (e.g., {id}) will generate TemplateRoutes
|
||||||
|
* - Regular exressions will generate RegexRoutes
|
||||||
|
*
|
||||||
|
* @param mixed
|
||||||
* @return HandlerInterface
|
* @return HandlerInterface
|
||||||
*/
|
*/
|
||||||
public function createRoute()
|
public function createRoute()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue