@@ -126,11 +126,9 @@ public function getPath()
126126 *
127127 * This method implements a fluent interface.
128128 *
129- * @param string $pattern The path pattern
130- *
131129 * @return $this
132130 */
133- public function setPath ($ pattern )
131+ public function setPath (string $ pattern )
134132 {
135133if (false !==strpbrk ($ pattern ,'?< ' )) {
136134$ pattern =preg_replace_callback ('#\{(\w++)(<.*?>)?(\?[^\}]*+)?\}# ' ,function ($ m ) {
@@ -168,11 +166,9 @@ public function getHost()
168166 *
169167 * This method implements a fluent interface.
170168 *
171- * @param string $pattern The host pattern
172- *
173169 * @return $this
174170 */
175- public function setHost ($ pattern )
171+ public function setHost (? string $ pattern )
176172 {
177173$ this ->host = (string )$ pattern ;
178174$ this ->compiled =null ;
@@ -212,11 +208,9 @@ public function setSchemes($schemes)
212208/**
213209 * Checks if a scheme requirement has been set.
214210 *
215- * @param string $scheme
216- *
217211 * @return bool true if the scheme requirement exists, otherwise false
218212 */
219- public function hasScheme ($ scheme )
213+ public function hasScheme (string $ scheme )
220214 {
221215return \in_array (strtolower ($ scheme ),$ this ->schemes ,true );
222216 }
@@ -302,12 +296,11 @@ public function addOptions(array $options)
302296 *
303297 * This method implements a fluent interface.
304298 *
305- * @param string $name An option name
306- * @param mixed $value The option value
299+ * @param mixed $value The option value
307300 *
308301 * @return $this
309302 */
310- public function setOption ($ name ,$ value )
303+ public function setOption (string $ name ,$ value )
311304 {
312305$ this ->options [$ name ] =$ value ;
313306$ this ->compiled =null ;
@@ -318,23 +311,19 @@ public function setOption($name, $value)
318311/**
319312 * Get an option value.
320313 *
321- * @param string $name An option name
322- *
323314 * @return mixed The option value or null when not given
324315 */
325- public function getOption ($ name )
316+ public function getOption (string $ name )
326317 {
327318return isset ($ this ->options [$ name ]) ?$ this ->options [$ name ] :null ;
328319 }
329320
330321/**
331322 * Checks if an option has been set.
332323 *
333- * @param string $name An option name
334- *
335324 * @return bool true if the option is set, false otherwise
336325 */
337- public function hasOption ($ name )
326+ public function hasOption (string $ name )
338327 {
339328return \array_key_exists ($ name ,$ this ->options );
340329 }
@@ -387,36 +376,31 @@ public function addDefaults(array $defaults)
387376/**
388377 * Gets a default value.
389378 *
390- * @param string $name A variable name
391- *
392379 * @return mixed The default value or null when not given
393380 */
394- public function getDefault ($ name )
381+ public function getDefault (string $ name )
395382 {
396383return isset ($ this ->defaults [$ name ]) ?$ this ->defaults [$ name ] :null ;
397384 }
398385
399386/**
400387 * Checks if a default value is set for the given variable.
401388 *
402- * @param string $name A variable name
403- *
404389 * @return bool true if the default value is set, false otherwise
405390 */
406- public function hasDefault ($ name )
391+ public function hasDefault (string $ name )
407392 {
408393return \array_key_exists ($ name ,$ this ->defaults );
409394 }
410395
411396/**
412397 * Sets a default value.
413398 *
414- * @param string $name A variable name
415- * @param mixed $default The default value
399+ * @param mixed $default The default value
416400 *
417401 * @return $this
418402 */
419- public function setDefault ($ name ,$ default )
403+ public function setDefault (string $ name ,$ default )
420404 {
421405$ this ->defaults [$ name ] =$ default ;
422406$ this ->compiled =null ;
@@ -472,36 +456,29 @@ public function addRequirements(array $requirements)
472456/**
473457 * Returns the requirement for the given key.
474458 *
475- * @param string $key The key
476- *
477459 * @return string|null The regex or null when not given
478460 */
479- public function getRequirement ($ key )
461+ public function getRequirement (string $ key )
480462 {
481463return isset ($ this ->requirements [$ key ]) ?$ this ->requirements [$ key ] :null ;
482464 }
483465
484466/**
485467 * Checks if a requirement is set for the given key.
486468 *
487- * @param string $key A variable name
488- *
489469 * @return bool true if a requirement is specified, false otherwise
490470 */
491- public function hasRequirement ($ key )
471+ public function hasRequirement (string $ key )
492472 {
493473return \array_key_exists ($ key ,$ this ->requirements );
494474 }
495475
496476/**
497477 * Sets a requirement for the given key.
498478 *
499- * @param string $key The key
500- * @param string $regex The regex
501- *
502479 * @return $this
503480 */
504- public function setRequirement ($ key ,$ regex )
481+ public function setRequirement (string $ key ,string $ regex )
505482 {
506483$ this ->requirements [$ key ] =$ this ->sanitizeRequirement ($ key ,$ regex );
507484$ this ->compiled =null ;
@@ -524,11 +501,9 @@ public function getCondition()
524501 *
525502 * This method implements a fluent interface.
526503 *
527- * @param string $condition The condition
528- *
529504 * @return $this
530505 */
531- public function setCondition ($ condition )
506+ public function setCondition (? string $ condition )
532507 {
533508$ this ->condition = (string )$ condition ;
534509$ this ->compiled =null ;
@@ -557,12 +532,8 @@ public function compile()
557532return $ this ->compiled =$ class ::compile ($ this );
558533 }
559534
560- private function sanitizeRequirement ($ key ,$ regex )
535+ private function sanitizeRequirement (string $ key ,string $ regex )
561536 {
562- if (!\is_string ($ regex )) {
563- throw new \InvalidArgumentException (sprintf ('Routing requirement for "%s" must be a string. ' ,$ key ));
564- }
565-
566537if ('' !==$ regex &&'^ ' ===$ regex [0 ]) {
567538$ regex = (string )substr ($ regex ,1 );// returns false for a single character
568539 }