[Routing] added more phpdoc and replaced 'array of type' by 'Type[]'
This commit is contained in:
parent
966053069d
commit
1e1cb13faf
@ -22,7 +22,10 @@ namespace Symfony\Component\Routing\Exception;
|
|||||||
*/
|
*/
|
||||||
class MethodNotAllowedException extends \RuntimeException implements ExceptionInterface
|
class MethodNotAllowedException extends \RuntimeException implements ExceptionInterface
|
||||||
{
|
{
|
||||||
protected $allowedMethods;
|
/**
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $allowedMethods = array();
|
||||||
|
|
||||||
public function __construct(array $allowedMethods, $message = null, $code = 0, \Exception $previous = null)
|
public function __construct(array $allowedMethods, $message = null, $code = 0, \Exception $previous = null)
|
||||||
{
|
{
|
||||||
@ -31,6 +34,11 @@ class MethodNotAllowedException extends \RuntimeException implements ExceptionIn
|
|||||||
parent::__construct($message, $code, $previous);
|
parent::__construct($message, $code, $previous);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the allowed HTTP methods.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public function getAllowedMethods()
|
public function getAllowedMethods()
|
||||||
{
|
{
|
||||||
return $this->allowedMethods;
|
return $this->allowedMethods;
|
||||||
|
@ -20,6 +20,9 @@ use Symfony\Component\Routing\RouteCollection;
|
|||||||
*/
|
*/
|
||||||
abstract class GeneratorDumper implements GeneratorDumperInterface
|
abstract class GeneratorDumper implements GeneratorDumperInterface
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @var RouteCollection
|
||||||
|
*/
|
||||||
private $routes;
|
private $routes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -28,8 +28,24 @@ use Symfony\Component\HttpKernel\Log\LoggerInterface;
|
|||||||
*/
|
*/
|
||||||
class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInterface
|
class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInterface
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @var RouteCollection
|
||||||
|
*/
|
||||||
|
protected $routes;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var RequestContext
|
||||||
|
*/
|
||||||
protected $context;
|
protected $context;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Boolean|null
|
||||||
|
*/
|
||||||
protected $strictRequirements = true;
|
protected $strictRequirements = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var LoggerInterface|null
|
||||||
|
*/
|
||||||
protected $logger;
|
protected $logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -60,14 +76,12 @@ class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInt
|
|||||||
'%7C' => '|',
|
'%7C' => '|',
|
||||||
);
|
);
|
||||||
|
|
||||||
protected $routes;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
* @param RouteCollection $routes A RouteCollection instance
|
* @param RouteCollection $routes A RouteCollection instance
|
||||||
* @param RequestContext $context The context
|
* @param RequestContext $context The context
|
||||||
* @param LoggerInterface $logger A logger instance
|
* @param LoggerInterface|null $logger A logger instance
|
||||||
*
|
*
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
|
@ -56,9 +56,20 @@ use Symfony\Component\Config\Loader\LoaderResolverInterface;
|
|||||||
*/
|
*/
|
||||||
abstract class AnnotationClassLoader implements LoaderInterface
|
abstract class AnnotationClassLoader implements LoaderInterface
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @var Reader
|
||||||
|
*/
|
||||||
protected $reader;
|
protected $reader;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
protected $routeAnnotationClass = 'Symfony\\Component\\Routing\\Annotation\\Route';
|
protected $routeAnnotationClass = 'Symfony\\Component\\Routing\\Annotation\\Route';
|
||||||
protected $defaultRouteIndex;
|
|
||||||
|
/**
|
||||||
|
* @var integer
|
||||||
|
*/
|
||||||
|
protected $defaultRouteIndex = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
@ -84,7 +95,7 @@ abstract class AnnotationClassLoader implements LoaderInterface
|
|||||||
* Loads from annotations from a class.
|
* Loads from annotations from a class.
|
||||||
*
|
*
|
||||||
* @param string $class A class name
|
* @param string $class A class name
|
||||||
* @param string $type The resource type
|
* @param string|null $type The resource type
|
||||||
*
|
*
|
||||||
* @return RouteCollection A RouteCollection instance
|
* @return RouteCollection A RouteCollection instance
|
||||||
*
|
*
|
||||||
|
@ -26,7 +26,7 @@ class AnnotationDirectoryLoader extends AnnotationFileLoader
|
|||||||
* Loads from annotations from a directory.
|
* Loads from annotations from a directory.
|
||||||
*
|
*
|
||||||
* @param string $path A directory path
|
* @param string $path A directory path
|
||||||
* @param string $type The resource type
|
* @param string|null $type The resource type
|
||||||
*
|
*
|
||||||
* @return RouteCollection A RouteCollection instance
|
* @return RouteCollection A RouteCollection instance
|
||||||
*
|
*
|
||||||
|
@ -14,7 +14,7 @@ namespace Symfony\Component\Routing\Loader;
|
|||||||
use Symfony\Component\Routing\RouteCollection;
|
use Symfony\Component\Routing\RouteCollection;
|
||||||
use Symfony\Component\Config\Resource\FileResource;
|
use Symfony\Component\Config\Resource\FileResource;
|
||||||
use Symfony\Component\Config\Loader\FileLoader;
|
use Symfony\Component\Config\Loader\FileLoader;
|
||||||
use Symfony\Component\Config\FileLocator;
|
use Symfony\Component\Config\FileLocatorInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AnnotationFileLoader loads routing information from annotations set
|
* AnnotationFileLoader loads routing information from annotations set
|
||||||
@ -29,11 +29,11 @@ class AnnotationFileLoader extends FileLoader
|
|||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
* @param FileLocator $locator A FileLocator instance
|
* @param FileLocatorInterface $locator A FileLocator instance
|
||||||
* @param AnnotationClassLoader $loader An AnnotationClassLoader instance
|
* @param AnnotationClassLoader $loader An AnnotationClassLoader instance
|
||||||
* @param string|array $paths A path or an array of paths where to look for resources
|
* @param string|array $paths A path or an array of paths where to look for resources
|
||||||
*/
|
*/
|
||||||
public function __construct(FileLocator $locator, AnnotationClassLoader $loader, $paths = array())
|
public function __construct(FileLocatorInterface $locator, AnnotationClassLoader $loader, $paths = array())
|
||||||
{
|
{
|
||||||
if (!function_exists('token_get_all')) {
|
if (!function_exists('token_get_all')) {
|
||||||
throw new \RuntimeException('The Tokenizer extension is required for the routing annotation loaders.');
|
throw new \RuntimeException('The Tokenizer extension is required for the routing annotation loaders.');
|
||||||
@ -48,7 +48,7 @@ class AnnotationFileLoader extends FileLoader
|
|||||||
* Loads from annotations from a file.
|
* Loads from annotations from a file.
|
||||||
*
|
*
|
||||||
* @param string $file A PHP file path
|
* @param string $file A PHP file path
|
||||||
* @param string $type The resource type
|
* @param string|null $type The resource type
|
||||||
*
|
*
|
||||||
* @return RouteCollection A RouteCollection instance
|
* @return RouteCollection A RouteCollection instance
|
||||||
*
|
*
|
||||||
|
@ -28,7 +28,7 @@ class ClosureLoader extends Loader
|
|||||||
* Loads a Closure.
|
* Loads a Closure.
|
||||||
*
|
*
|
||||||
* @param \Closure $closure A Closure
|
* @param \Closure $closure A Closure
|
||||||
* @param string $type The resource type
|
* @param string|null $type The resource type
|
||||||
*
|
*
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
|
@ -28,8 +28,8 @@ class PhpFileLoader extends FileLoader
|
|||||||
/**
|
/**
|
||||||
* Loads a PHP file.
|
* Loads a PHP file.
|
||||||
*
|
*
|
||||||
* @param mixed $file A PHP file path
|
* @param string $file A PHP file path
|
||||||
* @param string $type The resource type
|
* @param string|null $type The resource type
|
||||||
*
|
*
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
|
@ -29,7 +29,7 @@ class XmlFileLoader extends FileLoader
|
|||||||
* Loads an XML file.
|
* Loads an XML file.
|
||||||
*
|
*
|
||||||
* @param string $file An XML file path
|
* @param string $file An XML file path
|
||||||
* @param string $type The resource type
|
* @param string|null $type The resource type
|
||||||
*
|
*
|
||||||
* @return RouteCollection A RouteCollection instance
|
* @return RouteCollection A RouteCollection instance
|
||||||
*
|
*
|
||||||
@ -65,6 +65,8 @@ class XmlFileLoader extends FileLoader
|
|||||||
* @param \DOMElement $node the node to parse
|
* @param \DOMElement $node the node to parse
|
||||||
* @param string $path the path of the XML file being processed
|
* @param string $path the path of the XML file being processed
|
||||||
* @param string $file
|
* @param string $file
|
||||||
|
*
|
||||||
|
* @throws \InvalidArgumentException When a tag can't be parsed
|
||||||
*/
|
*/
|
||||||
protected function parseNode(RouteCollection $collection, \DOMElement $node, $path, $file)
|
protected function parseNode(RouteCollection $collection, \DOMElement $node, $path, $file)
|
||||||
{
|
{
|
||||||
|
@ -34,7 +34,7 @@ class YamlFileLoader extends FileLoader
|
|||||||
* Loads a Yaml file.
|
* Loads a Yaml file.
|
||||||
*
|
*
|
||||||
* @param string $file A Yaml file path
|
* @param string $file A Yaml file path
|
||||||
* @param string $type The resource type
|
* @param string|null $type The resource type
|
||||||
*
|
*
|
||||||
* @return RouteCollection A RouteCollection instance
|
* @return RouteCollection A RouteCollection instance
|
||||||
*
|
*
|
||||||
|
@ -18,14 +18,25 @@ namespace Symfony\Component\Routing\Matcher\Dumper;
|
|||||||
*/
|
*/
|
||||||
class DumperCollection implements \IteratorAggregate
|
class DumperCollection implements \IteratorAggregate
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @var DumperCollection|null
|
||||||
|
*/
|
||||||
private $parent;
|
private $parent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var (DumperCollection|DumperRoute)[]
|
||||||
|
*/
|
||||||
private $children = array();
|
private $children = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
private $attributes = array();
|
private $attributes = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the children routes and collections.
|
* Returns the children routes and collections.
|
||||||
*
|
*
|
||||||
* @return array Array of DumperCollection|DumperRoute
|
* @return (DumperCollection|DumperRoute)[] Array of DumperCollection|DumperRoute
|
||||||
*/
|
*/
|
||||||
public function all()
|
public function all()
|
||||||
{
|
{
|
||||||
|
@ -18,6 +18,9 @@ namespace Symfony\Component\Routing\Matcher\Dumper;
|
|||||||
*/
|
*/
|
||||||
class DumperPrefixCollection extends DumperCollection
|
class DumperPrefixCollection extends DumperCollection
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
private $prefix = '';
|
private $prefix = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -20,7 +20,14 @@ use Symfony\Component\Routing\Route;
|
|||||||
*/
|
*/
|
||||||
class DumperRoute
|
class DumperRoute
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
private $name;
|
private $name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Route
|
||||||
|
*/
|
||||||
private $route;
|
private $route;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -20,6 +20,9 @@ use Symfony\Component\Routing\RouteCollection;
|
|||||||
*/
|
*/
|
||||||
abstract class MatcherDumper implements MatcherDumperInterface
|
abstract class MatcherDumper implements MatcherDumperInterface
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @var RouteCollection
|
||||||
|
*/
|
||||||
private $routes;
|
private $routes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -325,7 +325,7 @@ EOF;
|
|||||||
* Flattens a tree of routes to a single collection.
|
* Flattens a tree of routes to a single collection.
|
||||||
*
|
*
|
||||||
* @param RouteCollection $routes Collection of routes
|
* @param RouteCollection $routes Collection of routes
|
||||||
* @param DumperCollection $to A DumperCollection to add routes to
|
* @param DumperCollection|null $to A DumperCollection to add routes to
|
||||||
*
|
*
|
||||||
* @return DumperCollection
|
* @return DumperCollection
|
||||||
*/
|
*/
|
||||||
|
@ -24,8 +24,8 @@ interface RedirectableUrlMatcherInterface
|
|||||||
* Redirects the user to another URL.
|
* Redirects the user to another URL.
|
||||||
*
|
*
|
||||||
* @param string $path The path info to redirect to.
|
* @param string $path The path info to redirect to.
|
||||||
* @param string $route The route that matched
|
* @param string $route The route name that matched
|
||||||
* @param string $scheme The URL scheme (null to keep the current one)
|
* @param string|null $scheme The URL scheme (null to keep the current one)
|
||||||
*
|
*
|
||||||
* @return array An array of parameters
|
* @return array An array of parameters
|
||||||
*
|
*
|
||||||
|
@ -30,9 +30,19 @@ class UrlMatcher implements UrlMatcherInterface
|
|||||||
const REQUIREMENT_MISMATCH = 1;
|
const REQUIREMENT_MISMATCH = 1;
|
||||||
const ROUTE_MATCH = 2;
|
const ROUTE_MATCH = 2;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var RequestContext
|
||||||
|
*/
|
||||||
protected $context;
|
protected $context;
|
||||||
protected $allow;
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $allow = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var RouteCollection
|
||||||
|
*/
|
||||||
private $routes;
|
private $routes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -28,7 +28,11 @@ class RequestContext
|
|||||||
private $scheme;
|
private $scheme;
|
||||||
private $httpPort;
|
private $httpPort;
|
||||||
private $httpsPort;
|
private $httpsPort;
|
||||||
private $parameters;
|
|
||||||
|
/**
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
private $parameters = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
@ -50,7 +54,6 @@ class RequestContext
|
|||||||
$this->scheme = strtolower($scheme);
|
$this->scheme = strtolower($scheme);
|
||||||
$this->httpPort = $httpPort;
|
$this->httpPort = $httpPort;
|
||||||
$this->httpsPort = $httpsPort;
|
$this->httpsPort = $httpsPort;
|
||||||
$this->parameters = array();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function fromRequest(Request $request)
|
public function fromRequest(Request $request)
|
||||||
|
@ -20,11 +20,34 @@ namespace Symfony\Component\Routing;
|
|||||||
*/
|
*/
|
||||||
class Route implements \Serializable
|
class Route implements \Serializable
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
private $pattern;
|
private $pattern;
|
||||||
private $defaults;
|
|
||||||
private $requirements;
|
/**
|
||||||
private $options;
|
* @var array
|
||||||
|
*/
|
||||||
|
private $defaults = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
private $requirements = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
private $options = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var null|RouteCompiler
|
||||||
|
*/
|
||||||
private $compiled;
|
private $compiled;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
private $hostnamePattern;
|
private $hostnamePattern;
|
||||||
|
|
||||||
private static $compilers = array();
|
private static $compilers = array();
|
||||||
|
@ -26,24 +26,30 @@ use Symfony\Component\Config\Resource\ResourceInterface;
|
|||||||
*/
|
*/
|
||||||
class RouteCollection implements \IteratorAggregate, \Countable
|
class RouteCollection implements \IteratorAggregate, \Countable
|
||||||
{
|
{
|
||||||
private $routes;
|
/**
|
||||||
private $resources;
|
* @var (RouteCollection|Route)[]
|
||||||
private $prefix;
|
*/
|
||||||
private $parent;
|
private $routes = array();
|
||||||
private $hostnamePattern;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* @var array
|
||||||
*
|
|
||||||
* @api
|
|
||||||
*/
|
*/
|
||||||
public function __construct()
|
private $resources = array();
|
||||||
{
|
|
||||||
$this->routes = array();
|
/**
|
||||||
$this->resources = array();
|
* @var string
|
||||||
$this->prefix = '';
|
*/
|
||||||
$this->hostnamePattern = '';
|
private $prefix = '';
|
||||||
}
|
|
||||||
|
/**
|
||||||
|
* @var RouteCollection|null
|
||||||
|
*/
|
||||||
|
private $parent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $hostnamePattern = '';
|
||||||
|
|
||||||
public function __clone()
|
public function __clone()
|
||||||
{
|
{
|
||||||
@ -129,7 +135,7 @@ class RouteCollection implements \IteratorAggregate, \Countable
|
|||||||
/**
|
/**
|
||||||
* Returns all routes in this collection and its children.
|
* Returns all routes in this collection and its children.
|
||||||
*
|
*
|
||||||
* @return array An array of routes
|
* @return Route[] An array of routes
|
||||||
*/
|
*/
|
||||||
public function all()
|
public function all()
|
||||||
{
|
{
|
||||||
|
@ -26,13 +26,44 @@ use Symfony\Component\Routing\Matcher\UrlMatcherInterface;
|
|||||||
*/
|
*/
|
||||||
class Router implements RouterInterface
|
class Router implements RouterInterface
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @var UrlMatcherInterface|null
|
||||||
|
*/
|
||||||
protected $matcher;
|
protected $matcher;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var UrlGeneratorInterface|null
|
||||||
|
*/
|
||||||
protected $generator;
|
protected $generator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var RequestContext
|
||||||
|
*/
|
||||||
protected $context;
|
protected $context;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var LoaderInterface
|
||||||
|
*/
|
||||||
protected $loader;
|
protected $loader;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var RouteCollection|null
|
||||||
|
*/
|
||||||
protected $collection;
|
protected $collection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var mixed
|
||||||
|
*/
|
||||||
protected $resource;
|
protected $resource;
|
||||||
protected $options;
|
|
||||||
|
/**
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $options = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var LoggerInterface|null
|
||||||
|
*/
|
||||||
protected $logger;
|
protected $logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user