comparison vendor/symfony/routing/Route.php @ 17:129ea1e6d783

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:21:36 +0000
parents 1fec387a4317
children af1871eacc83
comparison
equal deleted inserted replaced
16:c2387f117808 17:129ea1e6d783
19 */ 19 */
20 class Route implements \Serializable 20 class Route implements \Serializable
21 { 21 {
22 private $path = '/'; 22 private $path = '/';
23 private $host = ''; 23 private $host = '';
24 private $schemes = array(); 24 private $schemes = [];
25 private $methods = array(); 25 private $methods = [];
26 private $defaults = array(); 26 private $defaults = [];
27 private $requirements = array(); 27 private $requirements = [];
28 private $options = array(); 28 private $options = [];
29 private $condition = ''; 29 private $condition = '';
30 30
31 /** 31 /**
32 * @var null|CompiledRoute 32 * @var CompiledRoute|null
33 */ 33 */
34 private $compiled; 34 private $compiled;
35 35
36 /** 36 /**
37 * Constructor. 37 * Constructor.
48 * @param string $host The host pattern to match 48 * @param string $host The host pattern to match
49 * @param string|string[] $schemes A required URI scheme or an array of restricted schemes 49 * @param string|string[] $schemes A required URI scheme or an array of restricted schemes
50 * @param string|string[] $methods A required HTTP method or an array of restricted methods 50 * @param string|string[] $methods A required HTTP method or an array of restricted methods
51 * @param string $condition A condition that should evaluate to true for the route to match 51 * @param string $condition A condition that should evaluate to true for the route to match
52 */ 52 */
53 public function __construct($path, array $defaults = array(), array $requirements = array(), array $options = array(), $host = '', $schemes = array(), $methods = array(), $condition = '') 53 public function __construct($path, array $defaults = [], array $requirements = [], array $options = [], $host = '', $schemes = [], $methods = [], $condition = '')
54 { 54 {
55 $this->setPath($path); 55 $this->setPath($path);
56 $this->setDefaults($defaults); 56 $this->setDefaults($defaults);
57 $this->setRequirements($requirements); 57 $this->setRequirements($requirements);
58 $this->setOptions($options); 58 $this->setOptions($options);
65 /** 65 /**
66 * {@inheritdoc} 66 * {@inheritdoc}
67 */ 67 */
68 public function serialize() 68 public function serialize()
69 { 69 {
70 return serialize(array( 70 return serialize([
71 'path' => $this->path, 71 'path' => $this->path,
72 'host' => $this->host, 72 'host' => $this->host,
73 'defaults' => $this->defaults, 73 'defaults' => $this->defaults,
74 'requirements' => $this->requirements, 74 'requirements' => $this->requirements,
75 'options' => $this->options, 75 'options' => $this->options,
76 'schemes' => $this->schemes, 76 'schemes' => $this->schemes,
77 'methods' => $this->methods, 77 'methods' => $this->methods,
78 'condition' => $this->condition, 78 'condition' => $this->condition,
79 'compiled' => $this->compiled, 79 'compiled' => $this->compiled,
80 )); 80 ]);
81 } 81 }
82 82
83 /** 83 /**
84 * {@inheritdoc} 84 * {@inheritdoc}
85 */ 85 */
194 * 194 *
195 * @return bool true if the scheme requirement exists, otherwise false 195 * @return bool true if the scheme requirement exists, otherwise false
196 */ 196 */
197 public function hasScheme($scheme) 197 public function hasScheme($scheme)
198 { 198 {
199 return in_array(strtolower($scheme), $this->schemes, true); 199 return \in_array(strtolower($scheme), $this->schemes, true);
200 } 200 }
201 201
202 /** 202 /**
203 * Returns the uppercased HTTP methods this route is restricted to. 203 * Returns the uppercased HTTP methods this route is restricted to.
204 * So an empty array means that any method is allowed. 204 * So an empty array means that any method is allowed.
247 * 247 *
248 * @return $this 248 * @return $this
249 */ 249 */
250 public function setOptions(array $options) 250 public function setOptions(array $options)
251 { 251 {
252 $this->options = array( 252 $this->options = [
253 'compiler_class' => 'Symfony\\Component\\Routing\\RouteCompiler', 253 'compiler_class' => 'Symfony\\Component\\Routing\\RouteCompiler',
254 ); 254 ];
255 255
256 return $this->addOptions($options); 256 return $this->addOptions($options);
257 } 257 }
258 258
259 /** 259 /**
336 * 336 *
337 * @return $this 337 * @return $this
338 */ 338 */
339 public function setDefaults(array $defaults) 339 public function setDefaults(array $defaults)
340 { 340 {
341 $this->defaults = array(); 341 $this->defaults = [];
342 342
343 return $this->addDefaults($defaults); 343 return $this->addDefaults($defaults);
344 } 344 }
345 345
346 /** 346 /**
421 * 421 *
422 * @return $this 422 * @return $this
423 */ 423 */
424 public function setRequirements(array $requirements) 424 public function setRequirements(array $requirements)
425 { 425 {
426 $this->requirements = array(); 426 $this->requirements = [];
427 427
428 return $this->addRequirements($requirements); 428 return $this->addRequirements($requirements);
429 } 429 }
430 430
431 /** 431 /**
535 return $this->compiled = $class::compile($this); 535 return $this->compiled = $class::compile($this);
536 } 536 }
537 537
538 private function sanitizeRequirement($key, $regex) 538 private function sanitizeRequirement($key, $regex)
539 { 539 {
540 if (!is_string($regex)) { 540 if (!\is_string($regex)) {
541 throw new \InvalidArgumentException(sprintf('Routing requirement for "%s" must be a string.', $key)); 541 throw new \InvalidArgumentException(sprintf('Routing requirement for "%s" must be a string.', $key));
542 } 542 }
543 543
544 if ('' !== $regex && '^' === $regex[0]) { 544 if ('' !== $regex && '^' === $regex[0]) {
545 $regex = (string) substr($regex, 1); // returns false for a single character 545 $regex = (string) substr($regex, 1); // returns false for a single character