Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / vendor / symfony / routing / Route.php
index fee2002c9d9bb32a3dff243a8c254016c6538fa0..46e3e5502b95c08643ffeecf724de85f88e79ed0 100644 (file)
@@ -19,66 +19,36 @@ namespace Symfony\Component\Routing;
  */
 class Route implements \Serializable
 {
-    /**
-     * @var string
-     */
     private $path = '/';
-
-    /**
-     * @var string
-     */
     private $host = '';
-
-    /**
-     * @var array
-     */
     private $schemes = array();
-
-    /**
-     * @var array
-     */
     private $methods = array();
-
-    /**
-     * @var array
-     */
     private $defaults = array();
-
-    /**
-     * @var array
-     */
     private $requirements = array();
-
-    /**
-     * @var array
-     */
     private $options = array();
+    private $condition = '';
 
     /**
-     * @var null|CompiledRoute
+     * @var CompiledRoute|null
      */
     private $compiled;
 
-    /**
-     * @var string
-     */
-    private $condition = '';
-
     /**
      * Constructor.
      *
      * Available options:
      *
      *  * compiler_class: A class name able to compile this route instance (RouteCompiler by default)
+     *  * utf8:           Whether UTF-8 matching is enforced ot not
      *
-     * @param string       $path         The path pattern to match
-     * @param array        $defaults     An array of default parameter values
-     * @param array        $requirements An array of requirements for parameters (regexes)
-     * @param array        $options      An array of options
-     * @param string       $host         The host pattern to match
-     * @param string|array $schemes      A required URI scheme or an array of restricted schemes
-     * @param string|array $methods      A required HTTP method or an array of restricted methods
-     * @param string       $condition    A condition that should evaluate to true for the route to match
+     * @param string          $path         The path pattern to match
+     * @param array           $defaults     An array of default parameter values
+     * @param array           $requirements An array of requirements for parameters (regexes)
+     * @param array           $options      An array of options
+     * @param string          $host         The host pattern to match
+     * @param string|string[] $schemes      A required URI scheme or an array of restricted schemes
+     * @param string|string[] $methods      A required HTTP method or an array of restricted methods
+     * @param string          $condition    A condition that should evaluate to true for the route to match
      */
     public function __construct($path, array $defaults = array(), array $requirements = array(), array $options = array(), $host = '', $schemes = array(), $methods = array(), $condition = '')
     {
@@ -87,14 +57,8 @@ class Route implements \Serializable
         $this->setRequirements($requirements);
         $this->setOptions($options);
         $this->setHost($host);
-        // The conditions make sure that an initial empty $schemes/$methods does not override the corresponding requirement.
-        // They can be removed when the BC layer is removed.
-        if ($schemes) {
-            $this->setSchemes($schemes);
-        }
-        if ($methods) {
-            $this->setMethods($methods);
-        }
+        $this->setSchemes($schemes);
+        $this->setMethods($methods);
         $this->setCondition($condition);
     }
 
@@ -138,38 +102,6 @@ class Route implements \Serializable
         }
     }
 
-    /**
-     * Returns the pattern for the path.
-     *
-     * @return string The pattern
-     *
-     * @deprecated since version 2.2, to be removed in 3.0. Use getPath instead.
-     */
-    public function getPattern()
-    {
-        @trigger_error('The '.__METHOD__.' method is deprecated since version 2.2 and will be removed in 3.0. Use the getPath() method instead.', E_USER_DEPRECATED);
-
-        return $this->path;
-    }
-
-    /**
-     * Sets the pattern for the path.
-     *
-     * This method implements a fluent interface.
-     *
-     * @param string $pattern The path pattern
-     *
-     * @return $this
-     *
-     * @deprecated since version 2.2, to be removed in 3.0. Use setPath instead.
-     */
-    public function setPattern($pattern)
-    {
-        @trigger_error('The '.__METHOD__.' method is deprecated since version 2.2 and will be removed in 3.0. Use the setPath() method instead.', E_USER_DEPRECATED);
-
-        return $this->setPath($pattern);
-    }
-
     /**
      * Returns the pattern for the path.
      *
@@ -230,7 +162,7 @@ class Route implements \Serializable
      * Returns the lowercased schemes this route is restricted to.
      * So an empty array means that any scheme is allowed.
      *
-     * @return array The schemes
+     * @return string[] The schemes
      */
     public function getSchemes()
     {
@@ -243,21 +175,13 @@ class Route implements \Serializable
      *
      * This method implements a fluent interface.
      *
-     * @param string|array $schemes The scheme or an array of schemes
+     * @param string|string[] $schemes The scheme or an array of schemes
      *
      * @return $this
      */
     public function setSchemes($schemes)
     {
         $this->schemes = array_map('strtolower', (array) $schemes);
-
-        // this is to keep BC and will be removed in a future version
-        if ($this->schemes) {
-            $this->requirements['_scheme'] = implode('|', $this->schemes);
-        } else {
-            unset($this->requirements['_scheme']);
-        }
-
         $this->compiled = null;
 
         return $this;
@@ -272,14 +196,14 @@ class Route implements \Serializable
      */
     public function hasScheme($scheme)
     {
-        return in_array(strtolower($scheme), $this->schemes, true);
+        return \in_array(strtolower($scheme), $this->schemes, true);
     }
 
     /**
      * Returns the uppercased HTTP methods this route is restricted to.
      * So an empty array means that any method is allowed.
      *
-     * @return array The methods
+     * @return string[] The methods
      */
     public function getMethods()
     {
@@ -292,21 +216,13 @@ class Route implements \Serializable
      *
      * This method implements a fluent interface.
      *
-     * @param string|array $methods The method or an array of methods
+     * @param string|string[] $methods The method or an array of methods
      *
      * @return $this
      */
     public function setMethods($methods)
     {
         $this->methods = array_map('strtoupper', (array) $methods);
-
-        // this is to keep BC and will be removed in a future version
-        if ($this->methods) {
-            $this->requirements['_method'] = implode('|', $this->methods);
-        } else {
-            unset($this->requirements['_method']);
-        }
-
         $this->compiled = null;
 
         return $this;
@@ -540,12 +456,6 @@ class Route implements \Serializable
      */
     public function getRequirement($key)
     {
-        if ('_scheme' === $key) {
-            @trigger_error('The "_scheme" requirement is deprecated since version 2.2 and will be removed in 3.0. Use getSchemes() instead.', E_USER_DEPRECATED);
-        } elseif ('_method' === $key) {
-            @trigger_error('The "_method" requirement is deprecated since version 2.2 and will be removed in 3.0. Use getMethods() instead.', E_USER_DEPRECATED);
-        }
-
         return isset($this->requirements[$key]) ? $this->requirements[$key] : null;
     }
 
@@ -627,7 +537,7 @@ class Route implements \Serializable
 
     private function sanitizeRequirement($key, $regex)
     {
-        if (!is_string($regex)) {
+        if (!\is_string($regex)) {
             throw new \InvalidArgumentException(sprintf('Routing requirement for "%s" must be a string.', $key));
         }
 
@@ -643,17 +553,6 @@ class Route implements \Serializable
             throw new \InvalidArgumentException(sprintf('Routing requirement for "%s" cannot be empty.', $key));
         }
 
-        // this is to keep BC and will be removed in a future version
-        if ('_scheme' === $key) {
-            @trigger_error('The "_scheme" requirement is deprecated since version 2.2 and will be removed in 3.0. Use the setSchemes() method instead.', E_USER_DEPRECATED);
-
-            $this->setSchemes(explode('|', $regex));
-        } elseif ('_method' === $key) {
-            @trigger_error('The "_method" requirement is deprecated since version 2.2 and will be removed in 3.0. Use the setMethods() method instead.', E_USER_DEPRECATED);
-
-            $this->setMethods(explode('|', $regex));
-        }
-
         return $regex;
     }
 }