updated core and modules

This commit is contained in:
Bachir Soussi Chiadmi
2017-09-09 16:27:51 +02:00
parent 027aa99b32
commit 41863f872c
7810 changed files with 318922 additions and 83631 deletions
+1 -1
View File
@@ -34,7 +34,7 @@ class Route
/**
* Constructor.
*
* @param array $data An array of key/value parameters.
* @param array $data An array of key/value parameters
*
* @throws \BadMethodCallException
*/
+16
View File
@@ -7,6 +7,22 @@ CHANGELOG
* allowed specifying a directory to recursively load all routing configuration files it contains
* Added ObjectRouteLoader and ServiceRouteLoader that allow routes to be loaded
by calling a method on an object/service.
* [DEPRECATION] Deprecated the hardcoded value for the `$referenceType` argument of the `UrlGeneratorInterface::generate` method.
Use the constants defined in the `UrlGeneratorInterface` instead.
Before:
```php
$router->generate('blog_show', array('slug' => 'my-blog-post'), true);
```
After:
```php
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
$router->generate('blog_show', array('slug' => 'my-blog-post'), UrlGeneratorInterface::ABSOLUTE_URL);
```
2.5.0
-----
+4 -1
View File
@@ -278,7 +278,10 @@ class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInt
}
// add a query string if needed
$extra = array_diff_key($parameters, $variables, $defaults);
$extra = array_udiff_assoc(array_diff_key($parameters, $variables), $defaults, function ($a, $b) {
return $a == $b ? 0 : 1;
});
if ($extra && $query = http_build_query($extra, '', '&')) {
// "/" and "?" can be left decoded for better user experience, see
// http://tools.ietf.org/html/rfc3986#section-3.4
+1 -1
View File
@@ -1,4 +1,4 @@
Copyright (c) 2004-2016 Fabien Potencier
Copyright (c) 2004-2017 Fabien Potencier
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
+1 -1
View File
@@ -139,7 +139,7 @@ abstract class AnnotationClassLoader implements LoaderInterface
$defaults = array_replace($globals['defaults'], $annot->getDefaults());
foreach ($method->getParameters() as $param) {
if (!isset($defaults[$param->getName()]) && $param->isDefaultValueAvailable()) {
if (false !== strpos($globals['path'].$annot->getPath(), sprintf('{%s}', $param->getName())) && !isset($defaults[$param->getName()]) && $param->isDefaultValueAvailable()) {
$defaults[$param->getName()] = $param->getDefaultValue();
}
}
+41 -2
View File
@@ -38,7 +38,15 @@ class AnnotationDirectoryLoader extends AnnotationFileLoader
$collection = new RouteCollection();
$collection->addResource(new DirectoryResource($dir, '/\.php$/'));
$files = iterator_to_array(new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($dir), \RecursiveIteratorIterator::LEAVES_ONLY));
$files = iterator_to_array(new \RecursiveIteratorIterator(
new RecursiveCallbackFilterIterator(
new \RecursiveDirectoryIterator($dir),
function (\SplFileInfo $current) {
return '.' !== substr($current->getBasename(), 0, 1);
}
),
\RecursiveIteratorIterator::LEAVES_ONLY
));
usort($files, function (\SplFileInfo $a, \SplFileInfo $b) {
return (string) $a > (string) $b ? 1 : -1;
});
@@ -69,7 +77,7 @@ class AnnotationDirectoryLoader extends AnnotationFileLoader
if (!is_string($resource)) {
return false;
}
try {
$path = $this->locator->locate($resource);
} catch (\Exception $e) {
@@ -79,3 +87,34 @@ class AnnotationDirectoryLoader extends AnnotationFileLoader
return is_dir($path) && (!$type || 'annotation' === $type);
}
}
/**
* @internal To be removed as RecursiveCallbackFilterIterator is available since PHP 5.4
*/
class RecursiveCallbackFilterIterator extends \FilterIterator implements \RecursiveIterator
{
private $iterator;
private $callback;
public function __construct(\RecursiveIterator $iterator, $callback)
{
$this->iterator = $iterator;
$this->callback = $callback;
parent::__construct($iterator);
}
public function accept()
{
return call_user_func($this->callback, $this->current(), $this->key(), $this->iterator);
}
public function hasChildren()
{
return $this->iterator->hasChildren();
}
public function getChildren()
{
return new static($this->iterator->getChildren(), $this->callback);
}
}
+18 -1
View File
@@ -112,7 +112,24 @@ class AnnotationFileLoader extends FileLoader
}
if (T_CLASS === $token[0]) {
$class = true;
// Skip usage of ::class constant
$isClassConstant = false;
for ($j = $i - 1; $j > 0; --$j) {
if (!isset($tokens[$j][1])) {
break;
}
if (T_DOUBLE_COLON === $tokens[$j][0]) {
$isClassConstant = true;
break;
} elseif (!in_array($tokens[$j][0], array(T_WHITESPACE, T_DOC_COMMENT, T_COMMENT))) {
break;
}
}
if (!$isClassConstant) {
$class = true;
}
}
if (T_NAMESPACE === $token[0]) {
+1 -1
View File
@@ -219,7 +219,7 @@ class XmlFileLoader extends FileLoader
* @param \DOMElement $node Element to parse that contains the configs
* @param string $path Full path of the XML file being processed
*
* @return array An array with the defaults as first item, requirements as second and options as third.
* @return array An array with the defaults as first item, requirements as second and options as third
*
* @throws \InvalidArgumentException When the XML is invalid
*/
+5 -5
View File
@@ -26,7 +26,7 @@ class DumperCollection implements \IteratorAggregate
private $parent;
/**
* @var (DumperCollection|DumperRoute)[]
* @var DumperCollection[]|DumperRoute[]
*/
private $children = array();
@@ -38,7 +38,7 @@ class DumperCollection implements \IteratorAggregate
/**
* Returns the children routes and collections.
*
* @return (DumperCollection|DumperRoute)[] Array of DumperCollection|DumperRoute
* @return self[]|DumperRoute[]
*/
public function all()
{
@@ -76,7 +76,7 @@ class DumperCollection implements \IteratorAggregate
/**
* Returns an iterator over the children.
*
* @return \Iterator The iterator
* @return \Iterator|DumperCollection[]|DumperRoute[] The iterator
*/
public function getIterator()
{
@@ -86,7 +86,7 @@ class DumperCollection implements \IteratorAggregate
/**
* Returns the root of the collection.
*
* @return DumperCollection The root collection
* @return self The root collection
*/
public function getRoot()
{
@@ -96,7 +96,7 @@ class DumperCollection implements \IteratorAggregate
/**
* Returns the parent collection.
*
* @return DumperCollection|null The parent collection or null if the collection has no parent
* @return self|null The parent collection or null if the collection has no parent
*/
protected function getParent()
{
@@ -50,7 +50,7 @@ class DumperPrefixCollection extends DumperCollection
*
* @param DumperRoute $route The route
*
* @return DumperPrefixCollection The node the route was added to
* @return self
*
* @throws \LogicException
*/
@@ -21,7 +21,7 @@ interface RedirectableUrlMatcherInterface
/**
* 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 name that matched
* @param string|null $scheme The URL scheme (null to keep the current one)
*
+11 -11
View File
@@ -66,7 +66,7 @@ class RequestContext
*
* @param Request $request A Request instance
*
* @return RequestContext The current instance, implementing a fluent interface
* @return $this
*/
public function fromRequest(Request $request)
{
@@ -97,7 +97,7 @@ class RequestContext
*
* @param string $baseUrl The base URL
*
* @return RequestContext The current instance, implementing a fluent interface
* @return $this
*/
public function setBaseUrl($baseUrl)
{
@@ -121,7 +121,7 @@ class RequestContext
*
* @param string $pathInfo The path info
*
* @return RequestContext The current instance, implementing a fluent interface
* @return $this
*/
public function setPathInfo($pathInfo)
{
@@ -147,7 +147,7 @@ class RequestContext
*
* @param string $method The HTTP method
*
* @return RequestContext The current instance, implementing a fluent interface
* @return $this
*/
public function setMethod($method)
{
@@ -173,7 +173,7 @@ class RequestContext
*
* @param string $host The HTTP host
*
* @return RequestContext The current instance, implementing a fluent interface
* @return $this
*/
public function setHost($host)
{
@@ -197,7 +197,7 @@ class RequestContext
*
* @param string $scheme The HTTP scheme
*
* @return RequestContext The current instance, implementing a fluent interface
* @return $this
*/
public function setScheme($scheme)
{
@@ -221,7 +221,7 @@ class RequestContext
*
* @param int $httpPort The HTTP port
*
* @return RequestContext The current instance, implementing a fluent interface
* @return $this
*/
public function setHttpPort($httpPort)
{
@@ -245,7 +245,7 @@ class RequestContext
*
* @param int $httpsPort The HTTPS port
*
* @return RequestContext The current instance, implementing a fluent interface
* @return $this
*/
public function setHttpsPort($httpsPort)
{
@@ -269,7 +269,7 @@ class RequestContext
*
* @param string $queryString The query string (after "?")
*
* @return RequestContext The current instance, implementing a fluent interface
* @return $this
*/
public function setQueryString($queryString)
{
@@ -294,7 +294,7 @@ class RequestContext
*
* @param array $parameters The parameters
*
* @return RequestContext The current instance, implementing a fluent interface
* @return $this
*/
public function setParameters(array $parameters)
{
@@ -333,7 +333,7 @@ class RequestContext
* @param string $name A parameter name
* @param mixed $parameter The parameter value
*
* @return RequestContext The current instance, implementing a fluent interface
* @return $this
*/
public function setParameter($name, $parameter)
{
+15 -15
View File
@@ -159,7 +159,7 @@ class Route implements \Serializable
*
* @param string $pattern The path pattern
*
* @return Route The current Route instance
* @return $this
*
* @deprecated since version 2.2, to be removed in 3.0. Use setPath instead.
*/
@@ -187,7 +187,7 @@ class Route implements \Serializable
*
* @param string $pattern The path pattern
*
* @return Route The current Route instance
* @return $this
*/
public function setPath($pattern)
{
@@ -216,7 +216,7 @@ class Route implements \Serializable
*
* @param string $pattern The host pattern
*
* @return Route The current Route instance
* @return $this
*/
public function setHost($pattern)
{
@@ -245,7 +245,7 @@ class Route implements \Serializable
*
* @param string|array $schemes The scheme or an array of schemes
*
* @return Route The current Route instance
* @return $this
*/
public function setSchemes($schemes)
{
@@ -294,7 +294,7 @@ class Route implements \Serializable
*
* @param string|array $methods The method or an array of methods
*
* @return Route The current Route instance
* @return $this
*/
public function setMethods($methods)
{
@@ -329,7 +329,7 @@ class Route implements \Serializable
*
* @param array $options The options
*
* @return Route The current Route instance
* @return $this
*/
public function setOptions(array $options)
{
@@ -347,7 +347,7 @@ class Route implements \Serializable
*
* @param array $options The options
*
* @return Route The current Route instance
* @return $this
*/
public function addOptions(array $options)
{
@@ -367,7 +367,7 @@ class Route implements \Serializable
* @param string $name An option name
* @param mixed $value The option value
*
* @return Route The current Route instance
* @return $this
*/
public function setOption($name, $value)
{
@@ -418,7 +418,7 @@ class Route implements \Serializable
*
* @param array $defaults The defaults
*
* @return Route The current Route instance
* @return $this
*/
public function setDefaults(array $defaults)
{
@@ -434,7 +434,7 @@ class Route implements \Serializable
*
* @param array $defaults The defaults
*
* @return Route The current Route instance
* @return $this
*/
public function addDefaults(array $defaults)
{
@@ -476,7 +476,7 @@ class Route implements \Serializable
* @param string $name A variable name
* @param mixed $default The default value
*
* @return Route The current Route instance
* @return $this
*/
public function setDefault($name, $default)
{
@@ -503,7 +503,7 @@ class Route implements \Serializable
*
* @param array $requirements The requirements
*
* @return Route The current Route instance
* @return $this
*/
public function setRequirements(array $requirements)
{
@@ -519,7 +519,7 @@ class Route implements \Serializable
*
* @param array $requirements The requirements
*
* @return Route The current Route instance
* @return $this
*/
public function addRequirements(array $requirements)
{
@@ -567,7 +567,7 @@ class Route implements \Serializable
* @param string $key The key
* @param string $regex The regex
*
* @return Route The current Route instance
* @return $this
*/
public function setRequirement($key, $regex)
{
@@ -594,7 +594,7 @@ class Route implements \Serializable
*
* @param string $condition The condition
*
* @return Route The current Route instance
* @return $this
*/
public function setCondition($condition)
{
+1 -1
View File
@@ -49,7 +49,7 @@ class RouteCollection implements \IteratorAggregate, \Countable
*
* @see all()
*
* @return \ArrayIterator An \ArrayIterator object for iterating over routes
* @return \ArrayIterator|Route[] An \ArrayIterator object for iterating over routes
*/
public function getIterator()
{
+5 -5
View File
@@ -55,7 +55,7 @@ class RouteCollectionBuilder
* @param string|null $prefix
* @param string $type
*
* @return RouteCollectionBuilder
* @return self
*
* @throws FileLoaderLoadException
*/
@@ -101,7 +101,7 @@ class RouteCollectionBuilder
/**
* Returns a RouteCollectionBuilder that can be configured and then added with mount().
*
* @return RouteCollectionBuilder
* @return self
*/
public function createBuilder()
{
@@ -170,7 +170,7 @@ class RouteCollectionBuilder
/**
* Sets a default value that will be added to all embedded routes (unless that
* default value is already set.
* default value is already set).
*
* @param string $key
* @param mixed $value
@@ -186,7 +186,7 @@ class RouteCollectionBuilder
/**
* Sets a requirement that will be added to all embedded routes (unless that
* requirement is already set.
* requirement is already set).
*
* @param string $key
* @param mixed $regex
@@ -202,7 +202,7 @@ class RouteCollectionBuilder
/**
* Sets an opiton that will be added to all embedded routes (unless that
* option is already set.
* option is already set).
*
* @param string $key
* @param mixed $value
+18 -4
View File
@@ -28,12 +28,20 @@ class RouteCompiler implements RouteCompilerInterface
*/
const SEPARATORS = '/,;.:-_~+*=@|';
/**
* The maximum supported length of a PCRE subpattern name
* http://pcre.org/current/doc/html/pcre2pattern.html#SEC16.
*
* @internal
*/
const VARIABLE_MAXIMUM_LENGTH = 32;
/**
* {@inheritdoc}
*
* @throws \LogicException If a variable is referenced more than once
* @throws \DomainException If a variable name is numeric because PHP raises an error for such
* subpatterns in PCRE and thus would break matching, e.g. "(?P<123>.+)".
* @throws \DomainException If a variable name starts with a digit or if it is too long to be successfully used as
* a PCRE subpattern.
*/
public static function compile(Route $route)
{
@@ -95,13 +103,19 @@ class RouteCompiler implements RouteCompilerInterface
$precedingChar = strlen($precedingText) > 0 ? substr($precedingText, -1) : '';
$isSeparator = '' !== $precedingChar && false !== strpos(static::SEPARATORS, $precedingChar);
if (is_numeric($varName)) {
throw new \DomainException(sprintf('Variable name "%s" cannot be numeric in route pattern "%s". Please use a different name.', $varName, $pattern));
// A PCRE subpattern name must start with a non-digit. Also a PHP variable cannot start with a digit so the
// variable would not be usable as a Controller action argument.
if (preg_match('/^\d/', $varName)) {
throw new \DomainException(sprintf('Variable name "%s" cannot start with a digit in route pattern "%s". Please use a different name.', $varName, $pattern));
}
if (in_array($varName, $variables)) {
throw new \LogicException(sprintf('Route pattern "%s" cannot reference variable name "%s" more than once.', $pattern, $varName));
}
if (strlen($varName) > self::VARIABLE_MAXIMUM_LENGTH) {
throw new \DomainException(sprintf('Variable name "%s" cannot be longer than %s characters in route pattern "%s". Please use a shorter name.', $varName, self::VARIABLE_MAXIMUM_LENGTH, $pattern));
}
if ($isSeparator && strlen($precedingText) > 1) {
$tokens[] = array('text', substr($precedingText, 0, -1));
} elseif (!$isSeparator && strlen($precedingText) > 0) {
+14 -4
View File
@@ -106,9 +106,19 @@ class Router implements RouterInterface, RequestMatcherInterface
*
* Available options:
*
* * cache_dir: The cache directory (or null to disable caching)
* * debug: Whether to enable debugging or not (false by default)
* * resource_type: Type hint for the main resource (optional)
* * cache_dir: The cache directory (or null to disable caching)
* * debug: Whether to enable debugging or not (false by default)
* * generator_class: The name of a UrlGeneratorInterface implementation
* * generator_base_class: The base class for the dumped generator class
* * generator_cache_class: The class name for the dumped generator class
* * generator_dumper_class: The name of a GeneratorDumperInterface implementation
* * matcher_class: The name of a UrlMatcherInterface implementation
* * matcher_base_class: The base class for the dumped matcher class
* * matcher_dumper_class: The class name for the dumped matcher class
* * matcher_cache_class: The name of a MatcherDumperInterface implementation
* * resource_type: Type hint for the main resource (optional)
* * strict_requirements: Configure strict requirement checking for generators
* implementing ConfigurableRequirementsInterface (default is true)
*
* @param array $options An array of options
*
@@ -219,7 +229,7 @@ class Router implements RouterInterface, RequestMatcherInterface
/**
* Sets the ConfigCache factory to use.
*
* @param ConfigCacheFactoryInterface $configCacheFactory The factory to use.
* @param ConfigCacheFactoryInterface $configCacheFactory The factory to use
*/
public function setConfigCacheFactory(ConfigCacheFactoryInterface $configCacheFactory)
{
+1 -1
View File
@@ -21,7 +21,7 @@
"require-dev": {
"symfony/config": "~2.7|~3.0.0",
"symfony/http-foundation": "~2.3|~3.0.0",
"symfony/yaml": "~2.0,>=2.0.5|~3.0.0",
"symfony/yaml": "^2.0.5|~3.0.0",
"symfony/expression-language": "~2.4|~3.0.0",
"doctrine/annotations": "~1.0",
"doctrine/common": "~2.2",