diff --git a/src/Symfony/Component/Routing/Generator/CompiledUrlGenerator.php b/src/Symfony/Component/Routing/Generator/CompiledUrlGenerator.php index 41cd5893ae2f..8c489f8d4c02 100644 --- a/src/Symfony/Component/Routing/Generator/CompiledUrlGenerator.php +++ b/src/Symfony/Component/Routing/Generator/CompiledUrlGenerator.php @@ -31,7 +31,7 @@ public function __construct(array $compiledRoutes, RequestContext $context, Logg $this->defaultLocale = $defaultLocale; } - public function generate($name, $parameters = [], $referenceType = self::ABSOLUTE_PATH) + public function generate(string $name, array $parameters = [], int $referenceType = self::ABSOLUTE_PATH) { $locale = $parameters['_locale'] ?? $this->context->getParameter('_locale') diff --git a/src/Symfony/Component/Routing/Generator/ConfigurableRequirementsInterface.php b/src/Symfony/Component/Routing/Generator/ConfigurableRequirementsInterface.php index 2e5dc5325bdd..568f7f775300 100644 --- a/src/Symfony/Component/Routing/Generator/ConfigurableRequirementsInterface.php +++ b/src/Symfony/Component/Routing/Generator/ConfigurableRequirementsInterface.php @@ -40,10 +40,8 @@ interface ConfigurableRequirementsInterface /** * Enables or disables the exception on incorrect parameters. * Passing null will deactivate the requirements check completely. - * - * @param bool|null $enabled */ - public function setStrictRequirements($enabled); + public function setStrictRequirements(?bool $enabled); /** * Returns whether to throw an exception on incorrect parameters. diff --git a/src/Symfony/Component/Routing/Generator/UrlGenerator.php b/src/Symfony/Component/Routing/Generator/UrlGenerator.php index e5811c73a842..6623578aaa5c 100644 --- a/src/Symfony/Component/Routing/Generator/UrlGenerator.php +++ b/src/Symfony/Component/Routing/Generator/UrlGenerator.php @@ -108,9 +108,9 @@ public function getContext() /** * {@inheritdoc} */ - public function setStrictRequirements($enabled) + public function setStrictRequirements(?bool $enabled) { - $this->strictRequirements = null === $enabled ? null : (bool) $enabled; + $this->strictRequirements = $enabled; } /** @@ -124,7 +124,7 @@ public function isStrictRequirements() /** * {@inheritdoc} */ - public function generate($name, $parameters = [], $referenceType = self::ABSOLUTE_PATH) + public function generate(string $name, array $parameters = [], int $referenceType = self::ABSOLUTE_PATH) { $route = null; $locale = $parameters['_locale'] @@ -155,7 +155,7 @@ public function generate($name, $parameters = [], $referenceType = self::ABSOLUT * @throws InvalidParameterException When a parameter value for a placeholder is not correct because * it does not match the requirement */ - protected function doGenerate($variables, $defaults, $requirements, $tokens, $parameters, $name, $referenceType, $hostTokens, array $requiredSchemes = []) + protected function doGenerate(array $variables, array $defaults, array $requirements, array $tokens, array $parameters, string $name, int $referenceType, array $hostTokens, array $requiredSchemes = []) { $variables = array_flip($variables); $mergedParams = array_replace($defaults, $this->context->getParameters(), $parameters); @@ -321,7 +321,7 @@ protected function doGenerate($variables, $defaults, $requirements, $tokens, $pa * * @return string The relative target path */ - public static function getRelativePath($basePath, $targetPath) + public static function getRelativePath(string $basePath, string $targetPath) { if ($basePath === $targetPath) { return ''; diff --git a/src/Symfony/Component/Routing/Generator/UrlGeneratorInterface.php b/src/Symfony/Component/Routing/Generator/UrlGeneratorInterface.php index f7d37b2564b1..5890ffa55eb8 100644 --- a/src/Symfony/Component/Routing/Generator/UrlGeneratorInterface.php +++ b/src/Symfony/Component/Routing/Generator/UrlGeneratorInterface.php @@ -71,10 +71,6 @@ interface UrlGeneratorInterface extends RequestContextAwareInterface * * The special parameter _fragment will be used as the document fragment suffixed to the final URL. * - * @param string $name The name of the route - * @param mixed $parameters An array of parameters - * @param int $referenceType The type of reference to be generated (one of the constants) - * * @return string The generated URL * * @throws RouteNotFoundException If the named route doesn't exist @@ -82,5 +78,5 @@ interface UrlGeneratorInterface extends RequestContextAwareInterface * @throws InvalidParameterException When a parameter value for a placeholder is not correct because * it does not match the requirement */ - public function generate($name, $parameters = [], $referenceType = self::ABSOLUTE_PATH); + public function generate(string $name, array $parameters = [], int $referenceType = self::ABSOLUTE_PATH); } diff --git a/src/Symfony/Component/Routing/Matcher/RedirectableUrlMatcher.php b/src/Symfony/Component/Routing/Matcher/RedirectableUrlMatcher.php index eb7bec7f3442..3cd7c81a6cb1 100644 --- a/src/Symfony/Component/Routing/Matcher/RedirectableUrlMatcher.php +++ b/src/Symfony/Component/Routing/Matcher/RedirectableUrlMatcher.php @@ -22,7 +22,7 @@ abstract class RedirectableUrlMatcher extends UrlMatcher implements Redirectable /** * {@inheritdoc} */ - public function match($pathinfo) + public function match(string $pathinfo) { try { return parent::match($pathinfo); diff --git a/src/Symfony/Component/Routing/Matcher/RedirectableUrlMatcherInterface.php b/src/Symfony/Component/Routing/Matcher/RedirectableUrlMatcherInterface.php index 7c27bc879653..144945d96796 100644 --- a/src/Symfony/Component/Routing/Matcher/RedirectableUrlMatcherInterface.php +++ b/src/Symfony/Component/Routing/Matcher/RedirectableUrlMatcherInterface.php @@ -27,5 +27,5 @@ interface RedirectableUrlMatcherInterface * * @return array An array of parameters */ - public function redirect($path, $route, $scheme = null); + public function redirect(string $path, string $route, string $scheme = null); } diff --git a/src/Symfony/Component/Routing/Matcher/UrlMatcher.php b/src/Symfony/Component/Routing/Matcher/UrlMatcher.php index dca1d6366fa0..adc0a891b2ae 100644 --- a/src/Symfony/Component/Routing/Matcher/UrlMatcher.php +++ b/src/Symfony/Component/Routing/Matcher/UrlMatcher.php @@ -81,7 +81,7 @@ public function getContext() /** * {@inheritdoc} */ - public function match($pathinfo) + public function match(string $pathinfo) { $this->allow = $this->allowSchemes = []; diff --git a/src/Symfony/Component/Routing/Matcher/UrlMatcherInterface.php b/src/Symfony/Component/Routing/Matcher/UrlMatcherInterface.php index 17f1f97b3b47..24f23e381fa5 100644 --- a/src/Symfony/Component/Routing/Matcher/UrlMatcherInterface.php +++ b/src/Symfony/Component/Routing/Matcher/UrlMatcherInterface.php @@ -37,5 +37,5 @@ interface UrlMatcherInterface extends RequestContextAwareInterface * @throws ResourceNotFoundException If the resource could not be found * @throws MethodNotAllowedException If the resource was found but the request method is not allowed */ - public function match($pathinfo); + public function match(string $pathinfo); } diff --git a/src/Symfony/Component/Routing/Router.php b/src/Symfony/Component/Routing/Router.php index 63c802d03e0d..a24b193d96aa 100644 --- a/src/Symfony/Component/Routing/Router.php +++ b/src/Symfony/Component/Routing/Router.php @@ -159,12 +159,11 @@ public function setOptions(array $options) /** * Sets an option. * - * @param string $key The key - * @param mixed $value The value + * @param mixed $value The value * * @throws \InvalidArgumentException */ - public function setOption($key, $value) + public function setOption(string $key, $value) { if (!\array_key_exists($key, $this->options)) { throw new \InvalidArgumentException(sprintf('The Router does not support the "%s" option.', $key)); @@ -176,13 +175,11 @@ public function setOption($key, $value) /** * Gets an option value. * - * @param string $key The key - * * @return mixed The value * * @throws \InvalidArgumentException */ - public function getOption($key) + public function getOption(string $key) { if (!\array_key_exists($key, $this->options)) { throw new \InvalidArgumentException(sprintf('The Router does not support the "%s" option.', $key)); @@ -237,7 +234,7 @@ public function setConfigCacheFactory(ConfigCacheFactoryInterface $configCacheFa /** * {@inheritdoc} */ - public function generate($name, $parameters = [], $referenceType = self::ABSOLUTE_PATH) + public function generate(string $name, array $parameters = [], int $referenceType = self::ABSOLUTE_PATH) { return $this->getGenerator()->generate($name, $parameters, $referenceType); } @@ -245,7 +242,7 @@ public function generate($name, $parameters = [], $referenceType = self::ABSOLUT /** * {@inheritdoc} */ - public function match($pathinfo) + public function match(string $pathinfo) { return $this->getMatcher()->match($pathinfo); } diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/RedirectableUrlMatcher.php b/src/Symfony/Component/Routing/Tests/Fixtures/RedirectableUrlMatcher.php index 79ae1cce54ca..5a950942c8e9 100644 --- a/src/Symfony/Component/Routing/Tests/Fixtures/RedirectableUrlMatcher.php +++ b/src/Symfony/Component/Routing/Tests/Fixtures/RedirectableUrlMatcher.php @@ -19,7 +19,7 @@ */ class RedirectableUrlMatcher extends UrlMatcher implements RedirectableUrlMatcherInterface { - public function redirect($path, $route, $scheme = null) + public function redirect(string $path, string $route, string $scheme = null) { return [ '_controller' => 'Some controller reference...', diff --git a/src/Symfony/Component/Routing/Tests/Matcher/CompiledRedirectableUrlMatcherTest.php b/src/Symfony/Component/Routing/Tests/Matcher/CompiledRedirectableUrlMatcherTest.php index 7fb7dfef9e97..1b3d7b66e8d2 100644 --- a/src/Symfony/Component/Routing/Tests/Matcher/CompiledRedirectableUrlMatcherTest.php +++ b/src/Symfony/Component/Routing/Tests/Matcher/CompiledRedirectableUrlMatcherTest.php @@ -33,7 +33,7 @@ protected function getUrlMatcher(RouteCollection $routes, RequestContext $contex class TestCompiledRedirectableUrlMatcher extends CompiledUrlMatcher implements RedirectableUrlMatcherInterface { - public function redirect($path, $route, $scheme = null) + public function redirect(string $path, string $route, string $scheme = null) { return []; } diff --git a/src/Symfony/Component/Routing/Tests/Matcher/Dumper/CompiledUrlMatcherDumperTest.php b/src/Symfony/Component/Routing/Tests/Matcher/Dumper/CompiledUrlMatcherDumperTest.php index ad9c8376f72c..87a453b4ef6f 100644 --- a/src/Symfony/Component/Routing/Tests/Matcher/Dumper/CompiledUrlMatcherDumperTest.php +++ b/src/Symfony/Component/Routing/Tests/Matcher/Dumper/CompiledUrlMatcherDumperTest.php @@ -489,7 +489,7 @@ public function testGenerateDumperMatcherWithObject() class TestCompiledUrlMatcher extends CompiledUrlMatcher implements RedirectableUrlMatcherInterface { - public function redirect($path, $route, $scheme = null) + public function redirect(string $path, string $route, string $scheme = null) { return []; }