diff --git a/src/Symfony/Bridge/Twig/AppVariable.php b/src/Symfony/Bridge/Twig/AppVariable.php index 21020270a0..7c1a8f18f2 100644 --- a/src/Symfony/Bridge/Twig/AppVariable.php +++ b/src/Symfony/Bridge/Twig/AppVariable.php @@ -39,14 +39,14 @@ class AppVariable $this->requestStack = $requestStack; } - public function setEnvironment($environment) + public function setEnvironment(string $environment) { $this->environment = $environment; } - public function setDebug($debug) + public function setDebug(bool $debug) { - $this->debug = (bool) $debug; + $this->debug = $debug; } /** diff --git a/src/Symfony/Bridge/Twig/Command/LintCommand.php b/src/Symfony/Bridge/Twig/Command/LintCommand.php index d2f7542af7..9ea2ff7eb6 100644 --- a/src/Symfony/Bridge/Twig/Command/LintCommand.php +++ b/src/Symfony/Bridge/Twig/Command/LintCommand.php @@ -107,7 +107,7 @@ EOF return $filesInfo; } - protected function findFiles($filename) + protected function findFiles(string $filename) { if (is_file($filename)) { return [$filename]; diff --git a/src/Symfony/Bridge/Twig/Extension/AssetExtension.php b/src/Symfony/Bridge/Twig/Extension/AssetExtension.php index cc2cdb268e..2093553629 100644 --- a/src/Symfony/Bridge/Twig/Extension/AssetExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/AssetExtension.php @@ -46,12 +46,9 @@ class AssetExtension extends AbstractExtension * If the package used to generate the path is an instance of * UrlPackage, you will always get a URL and not a path. * - * @param string $path A public path - * @param string $packageName The name of the asset package to use - * * @return string The public path of the asset */ - public function getAssetUrl($path, $packageName = null) + public function getAssetUrl(string $path, string $packageName = null) { return $this->packages->getUrl($path, $packageName); } @@ -59,12 +56,9 @@ class AssetExtension extends AbstractExtension /** * Returns the version of an asset. * - * @param string $path A public path - * @param string $packageName The name of the asset package to use - * * @return string The asset version */ - public function getAssetVersion($path, $packageName = null) + public function getAssetVersion(string $path, string $packageName = null) { return $this->packages->getVersion($path, $packageName); } diff --git a/src/Symfony/Bridge/Twig/Extension/CodeExtension.php b/src/Symfony/Bridge/Twig/Extension/CodeExtension.php index 56211fe6ec..c911922d6b 100644 --- a/src/Symfony/Bridge/Twig/Extension/CodeExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/CodeExtension.php @@ -57,7 +57,7 @@ class CodeExtension extends AbstractExtension ]; } - public function abbrClass($class) + public function abbrClass(string $class) { $parts = explode('\\', $class); $short = array_pop($parts); @@ -65,7 +65,7 @@ class CodeExtension extends AbstractExtension return sprintf('%s', $class, $short); } - public function abbrMethod($method) + public function abbrMethod(string $method) { if (false !== strpos($method, '::')) { list($class, $method) = explode('::', $method, 2); @@ -82,11 +82,9 @@ class CodeExtension extends AbstractExtension /** * Formats an array as a string. * - * @param array $args The argument array - * * @return string */ - public function formatArgs($args) + public function formatArgs(array $args) { $result = []; foreach ($args as $key => $item) { @@ -115,11 +113,9 @@ class CodeExtension extends AbstractExtension /** * Formats an array as a string. * - * @param array $args The argument array - * * @return string */ - public function formatArgsAsText($args) + public function formatArgsAsText(array $args) { return strip_tags($this->formatArgs($args)); } @@ -127,13 +123,9 @@ class CodeExtension extends AbstractExtension /** * Returns an excerpt of a code file around the given line number. * - * @param string $file A file path - * @param int $line The selected line number - * @param int $srcContext The number of displayed lines around or -1 for the whole file - * * @return string An HTML string */ - public function fileExcerpt($file, $line, $srcContext = 3) + public function fileExcerpt(string $file, int $line, int $srcContext = 3) { if (is_file($file) && is_readable($file)) { // highlight_file could throw warnings @@ -165,13 +157,9 @@ class CodeExtension extends AbstractExtension /** * Formats a file path. * - * @param string $file An absolute file path - * @param int $line The line number - * @param string $text Use this text for the link rather than the file path - * * @return string */ - public function formatFile($file, $line, $text = null) + public function formatFile(string $file, int $line, string $text = null) { $file = trim($file); @@ -197,12 +185,9 @@ class CodeExtension extends AbstractExtension /** * Returns the link for a given file/line pair. * - * @param string $file An absolute file path - * @param int $line The line number - * * @return string|false A link or false */ - public function getFileLink($file, $line) + public function getFileLink(string $file, int $line) { if ($fmt = $this->fileLinkFormat) { return \is_string($fmt) ? strtr($fmt, ['%f' => $file, '%l' => $line]) : $fmt->format($file, $line); @@ -222,7 +207,7 @@ class CodeExtension extends AbstractExtension return null; } - public function formatFileFromText($text) + public function formatFileFromText(string $text) { return preg_replace_callback('/in ("|")?(.+?)\1(?: +(?:on|at))? +line (\d+)/s', function ($match) { return 'in '.$this->formatFile($match[2], $match[3]); @@ -232,7 +217,7 @@ class CodeExtension extends AbstractExtension /** * @internal */ - public function formatLogMessage($message, array $context) + public function formatLogMessage(string $message, array $context) { if ($context && false !== strpos($message, '{')) { $replacements = []; @@ -258,7 +243,7 @@ class CodeExtension extends AbstractExtension return 'code'; } - protected static function fixCodeMarkup($line) + protected static function fixCodeMarkup(string $line) { // ending tag from previous line $opening = strpos($line, 'isDebug()) { return; diff --git a/src/Symfony/Bridge/Twig/Extension/ExpressionExtension.php b/src/Symfony/Bridge/Twig/Extension/ExpressionExtension.php index 21f6be4d6e..4ed79ea009 100644 --- a/src/Symfony/Bridge/Twig/Extension/ExpressionExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/ExpressionExtension.php @@ -32,7 +32,7 @@ class ExpressionExtension extends AbstractExtension ]; } - public function createExpression($expression) + public function createExpression(string $expression) { return new Expression($expression); } diff --git a/src/Symfony/Bridge/Twig/Extension/HttpFoundationExtension.php b/src/Symfony/Bridge/Twig/Extension/HttpFoundationExtension.php index 8e9fad837d..e03676d34f 100644 --- a/src/Symfony/Bridge/Twig/Extension/HttpFoundationExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/HttpFoundationExtension.php @@ -46,13 +46,11 @@ class HttpFoundationExtension extends AbstractExtension * * This method returns the path unchanged if no request is available. * - * @param string $path The path - * * @return string The absolute URL * * @see Request::getUriForPath() */ - public function generateAbsoluteUrl($path) + public function generateAbsoluteUrl(string $path) { return $this->urlHelper->getAbsoluteUrl($path); } @@ -62,13 +60,11 @@ class HttpFoundationExtension extends AbstractExtension * * This method returns the path unchanged if no request is available. * - * @param string $path The path - * * @return string The relative path * * @see Request::getRelativeUriForPath() */ - public function generateRelativePath($path) + public function generateRelativePath(string $path) { return $this->urlHelper->getRelativePath($path); } diff --git a/src/Symfony/Bridge/Twig/Extension/HttpKernelExtension.php b/src/Symfony/Bridge/Twig/Extension/HttpKernelExtension.php index f8b93ada15..ac9cacca2a 100644 --- a/src/Symfony/Bridge/Twig/Extension/HttpKernelExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/HttpKernelExtension.php @@ -31,7 +31,7 @@ class HttpKernelExtension extends AbstractExtension ]; } - public static function controller($controller, $attributes = [], $query = []) + public static function controller(string $controller, array $attributes = [], array $query = []) { return new ControllerReference($controller, $attributes, $query); } diff --git a/src/Symfony/Bridge/Twig/Extension/HttpKernelRuntime.php b/src/Symfony/Bridge/Twig/Extension/HttpKernelRuntime.php index fcd7c24416..4e4cae489c 100644 --- a/src/Symfony/Bridge/Twig/Extension/HttpKernelRuntime.php +++ b/src/Symfony/Bridge/Twig/Extension/HttpKernelRuntime.php @@ -31,14 +31,13 @@ class HttpKernelRuntime /** * Renders a fragment. * - * @param string|ControllerReference $uri A URI as a string or a ControllerReference instance - * @param array $options An array of options + * @param string|ControllerReference $uri A URI as a string or a ControllerReference instance * * @return string The fragment content * * @see FragmentHandler::render() */ - public function renderFragment($uri, $options = []) + public function renderFragment($uri, array $options = []) { $strategy = isset($options['strategy']) ? $options['strategy'] : 'inline'; unset($options['strategy']); @@ -49,15 +48,13 @@ class HttpKernelRuntime /** * Renders a fragment. * - * @param string $strategy A strategy name - * @param string|ControllerReference $uri A URI as a string or a ControllerReference instance - * @param array $options An array of options + * @param string|ControllerReference $uri A URI as a string or a ControllerReference instance * * @return string The fragment content * * @see FragmentHandler::render() */ - public function renderFragmentStrategy($strategy, $uri, $options = []) + public function renderFragmentStrategy(string $strategy, $uri, array $options = []) { return $this->handler->render($uri, $strategy, $options); } diff --git a/src/Symfony/Bridge/Twig/Extension/LogoutUrlExtension.php b/src/Symfony/Bridge/Twig/Extension/LogoutUrlExtension.php index e8bc6190cd..b409216b60 100644 --- a/src/Symfony/Bridge/Twig/Extension/LogoutUrlExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/LogoutUrlExtension.php @@ -47,7 +47,7 @@ class LogoutUrlExtension extends AbstractExtension * * @return string The relative logout URL */ - public function getLogoutPath($key = null) + public function getLogoutPath(string $key = null) { return $this->generator->getLogoutPath($key); } @@ -59,7 +59,7 @@ class LogoutUrlExtension extends AbstractExtension * * @return string The absolute logout URL */ - public function getLogoutUrl($key = null) + public function getLogoutUrl(string $key = null) { return $this->generator->getLogoutUrl($key); } diff --git a/src/Symfony/Bridge/Twig/Extension/RoutingExtension.php b/src/Symfony/Bridge/Twig/Extension/RoutingExtension.php index cab0809129..96e355e335 100644 --- a/src/Symfony/Bridge/Twig/Extension/RoutingExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/RoutingExtension.php @@ -46,25 +46,17 @@ class RoutingExtension extends AbstractExtension } /** - * @param string $name - * @param array $parameters - * @param bool $relative - * * @return string */ - public function getPath($name, $parameters = [], $relative = false) + public function getPath(string $name, array $parameters = [], bool $relative = false) { return $this->generator->generate($name, $parameters, $relative ? UrlGeneratorInterface::RELATIVE_PATH : UrlGeneratorInterface::ABSOLUTE_PATH); } /** - * @param string $name - * @param array $parameters - * @param bool $schemeRelative - * * @return string */ - public function getUrl($name, $parameters = [], $schemeRelative = false) + public function getUrl(string $name, array $parameters = [], bool $schemeRelative = false) { return $this->generator->generate($name, $parameters, $schemeRelative ? UrlGeneratorInterface::NETWORK_PATH : UrlGeneratorInterface::ABSOLUTE_URL); } diff --git a/src/Symfony/Bridge/Twig/Extension/SecurityExtension.php b/src/Symfony/Bridge/Twig/Extension/SecurityExtension.php index 439c31aad3..3fa35e290a 100644 --- a/src/Symfony/Bridge/Twig/Extension/SecurityExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/SecurityExtension.php @@ -31,7 +31,7 @@ class SecurityExtension extends AbstractExtension $this->securityChecker = $securityChecker; } - public function isGranted($role, $object = null, $field = null) + public function isGranted($role, object $object = null, string $field = null) { if (null === $this->securityChecker) { return false; diff --git a/src/Symfony/Bridge/Twig/Extension/TranslationExtension.php b/src/Symfony/Bridge/Twig/Extension/TranslationExtension.php index 2d90bb6556..b25fa47655 100644 --- a/src/Symfony/Bridge/Twig/Extension/TranslationExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/TranslationExtension.php @@ -94,7 +94,7 @@ class TranslationExtension extends AbstractExtension return $this->translationNodeVisitor ?: $this->translationNodeVisitor = new TranslationNodeVisitor(); } - public function trans($message, array $arguments = [], $domain = null, $locale = null, $count = null): string + public function trans(string $message, array $arguments = [], string $domain = null, string $locale = null, int $count = null): string { if (null !== $count) { $arguments['%count%'] = $count; diff --git a/src/Symfony/Bridge/Twig/Extension/WebLinkExtension.php b/src/Symfony/Bridge/Twig/Extension/WebLinkExtension.php index 0ca519ee72..d169e65fbf 100644 --- a/src/Symfony/Bridge/Twig/Extension/WebLinkExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/WebLinkExtension.php @@ -49,13 +49,12 @@ class WebLinkExtension extends AbstractExtension /** * Adds a "Link" HTTP header. * - * @param string $uri The relation URI * @param string $rel The relation type (e.g. "preload", "prefetch", "prerender" or "dns-prefetch") * @param array $attributes The attributes of this link (e.g. "['as' => true]", "['pr' => 0.5]") * * @return string The relation URI */ - public function link($uri, $rel, array $attributes = []) + public function link(string $uri, string $rel, array $attributes = []) { if (!$request = $this->requestStack->getMasterRequest()) { return $uri; @@ -75,12 +74,11 @@ class WebLinkExtension extends AbstractExtension /** * Preloads a resource. * - * @param string $uri A public path - * @param array $attributes The attributes of this link (e.g. "['as' => true]", "['crossorigin' => 'use-credentials']") + * @param array $attributes The attributes of this link (e.g. "['as' => true]", "['crossorigin' => 'use-credentials']") * * @return string The path of the asset */ - public function preload($uri, array $attributes = []) + public function preload(string $uri, array $attributes = []) { return $this->link($uri, 'preload', $attributes); } @@ -88,12 +86,11 @@ class WebLinkExtension extends AbstractExtension /** * Resolves a resource origin as early as possible. * - * @param string $uri A public path - * @param array $attributes The attributes of this link (e.g. "['as' => true]", "['pr' => 0.5]") + * @param array $attributes The attributes of this link (e.g. "['as' => true]", "['pr' => 0.5]") * * @return string The path of the asset */ - public function dnsPrefetch($uri, array $attributes = []) + public function dnsPrefetch(string $uri, array $attributes = []) { return $this->link($uri, 'dns-prefetch', $attributes); } @@ -101,12 +98,11 @@ class WebLinkExtension extends AbstractExtension /** * Initiates a early connection to a resource (DNS resolution, TCP handshake, TLS negotiation). * - * @param string $uri A public path - * @param array $attributes The attributes of this link (e.g. "['as' => true]", "['pr' => 0.5]") + * @param array $attributes The attributes of this link (e.g. "['as' => true]", "['pr' => 0.5]") * * @return string The path of the asset */ - public function preconnect($uri, array $attributes = []) + public function preconnect(string $uri, array $attributes = []) { return $this->link($uri, 'preconnect', $attributes); } @@ -114,12 +110,11 @@ class WebLinkExtension extends AbstractExtension /** * Indicates to the client that it should prefetch this resource. * - * @param string $uri A public path - * @param array $attributes The attributes of this link (e.g. "['as' => true]", "['pr' => 0.5]") + * @param array $attributes The attributes of this link (e.g. "['as' => true]", "['pr' => 0.5]") * * @return string The path of the asset */ - public function prefetch($uri, array $attributes = []) + public function prefetch(string $uri, array $attributes = []) { return $this->link($uri, 'prefetch', $attributes); } @@ -127,12 +122,11 @@ class WebLinkExtension extends AbstractExtension /** * Indicates to the client that it should prerender this resource . * - * @param string $uri A public path - * @param array $attributes The attributes of this link (e.g. "['as' => true]", "['pr' => 0.5]") + * @param array $attributes The attributes of this link (e.g. "['as' => true]", "['pr' => 0.5]") * * @return string The path of the asset */ - public function prerender($uri, array $attributes = []) + public function prerender(string $uri, array $attributes = []) { return $this->link($uri, 'prerender', $attributes); } diff --git a/src/Symfony/Bridge/Twig/Extension/WorkflowExtension.php b/src/Symfony/Bridge/Twig/Extension/WorkflowExtension.php index 85b4f7a4d7..14a5ec4258 100644 --- a/src/Symfony/Bridge/Twig/Extension/WorkflowExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/WorkflowExtension.php @@ -46,13 +46,9 @@ class WorkflowExtension extends AbstractExtension /** * Returns true if the transition is enabled. * - * @param object $subject A subject - * @param string $transitionName A transition - * @param string $name A workflow name - * * @return bool true if the transition is enabled */ - public function canTransition($subject, $transitionName, $name = null) + public function canTransition(object $subject, string $transitionName, string $name = null) { return $this->workflowRegistry->get($subject, $name)->can($subject, $transitionName); } @@ -60,12 +56,9 @@ class WorkflowExtension extends AbstractExtension /** * Returns all enabled transitions. * - * @param object $subject A subject - * @param string $name A workflow name - * * @return Transition[] All enabled transitions */ - public function getEnabledTransitions($subject, $name = null) + public function getEnabledTransitions(object $subject, string $name = null) { return $this->workflowRegistry->get($subject, $name)->getEnabledTransitions($subject); } @@ -73,13 +66,9 @@ class WorkflowExtension extends AbstractExtension /** * Returns true if the place is marked. * - * @param object $subject A subject - * @param string $placeName A place name - * @param string $name A workflow name - * * @return bool true if the transition is enabled */ - public function hasMarkedPlace($subject, $placeName, $name = null) + public function hasMarkedPlace(object $subject, string $placeName, string $name = null) { return $this->workflowRegistry->get($subject, $name)->getMarking($subject)->has($placeName); } @@ -87,13 +76,9 @@ class WorkflowExtension extends AbstractExtension /** * Returns marked places. * - * @param object $subject A subject - * @param bool $placesNameOnly If true, returns only places name. If false returns the raw representation - * @param string $name A workflow name - * * @return string[]|int[] */ - public function getMarkedPlaces($subject, $placesNameOnly = true, $name = null) + public function getMarkedPlaces(object $subject, bool $placesNameOnly = true, string $name = null) { $places = $this->workflowRegistry->get($subject, $name)->getMarking($subject)->getPlaces(); @@ -107,12 +92,11 @@ class WorkflowExtension extends AbstractExtension /** * Returns the metadata for a specific subject. * - * @param object $subject A subject * @param string|Transition|null $metadataSubject Use null to get workflow metadata * Use a string (the place name) to get place metadata * Use a Transition instance to get transition metadata */ - public function getMetadata($subject, string $key, $metadataSubject = null, string $name = null): ?string + public function getMetadata(object $subject, string $key, $metadataSubject = null, string $name = null): ?string { return $this ->workflowRegistry @@ -122,7 +106,7 @@ class WorkflowExtension extends AbstractExtension ; } - public function buildTransitionBlockerList($subject, string $transitionName, string $name = null): TransitionBlockerList + public function buildTransitionBlockerList(object $subject, string $transitionName, string $name = null): TransitionBlockerList { $workflow = $this->workflowRegistry->get($subject, $name); diff --git a/src/Symfony/Bridge/Twig/Extension/YamlExtension.php b/src/Symfony/Bridge/Twig/Extension/YamlExtension.php index 3284ec5cd3..1c543137a1 100644 --- a/src/Symfony/Bridge/Twig/Extension/YamlExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/YamlExtension.php @@ -34,7 +34,7 @@ class YamlExtension extends AbstractExtension ]; } - public function encode($input, $inline = 0, $dumpObjects = 0) + public function encode($input, int $inline = 0, int $dumpObjects = 0) { static $dumper; @@ -49,7 +49,7 @@ class YamlExtension extends AbstractExtension return $dumper->dump($input, $inline, 0, false, $dumpObjects); } - public function dump($value, $inline = 0, $dumpObjects = false) + public function dump($value, int $inline = 0, int $dumpObjects = 0) { if (\is_resource($value)) { return '%Resource%'; diff --git a/src/Symfony/Bridge/Twig/Form/TwigRendererEngine.php b/src/Symfony/Bridge/Twig/Form/TwigRendererEngine.php index 8dc8998a74..a995a6fd9d 100644 --- a/src/Symfony/Bridge/Twig/Form/TwigRendererEngine.php +++ b/src/Symfony/Bridge/Twig/Form/TwigRendererEngine.php @@ -40,7 +40,7 @@ class TwigRendererEngine extends AbstractRendererEngine /** * {@inheritdoc} */ - public function renderBlock(FormView $view, $resource, $blockName, array $variables = []) + public function renderBlock(FormView $view, $resource, string $blockName, array $variables = []) { $cacheKey = $view->vars[self::CACHE_KEY_VAR]; @@ -70,13 +70,9 @@ class TwigRendererEngine extends AbstractRendererEngine * * @see getResourceForBlock() * - * @param string $cacheKey The cache key of the form view - * @param FormView $view The form view for finding the applying themes - * @param string $blockName The name of the block to load - * * @return bool True if the resource could be loaded, false otherwise */ - protected function loadResourceForBlockName($cacheKey, FormView $view, $blockName) + protected function loadResourceForBlockName(string $cacheKey, FormView $view, string $blockName) { // The caller guarantees that $this->resources[$cacheKey][$block] is // not set, but it doesn't have to check whether $this->resources[$cacheKey] @@ -143,14 +139,13 @@ class TwigRendererEngine extends AbstractRendererEngine /** * Loads the resources for all blocks in a theme. * - * @param string $cacheKey The cache key for storing the resource - * @param mixed $theme The theme to load the block from. This parameter - * is passed by reference, because it might be necessary - * to initialize the theme first. Any changes made to - * this variable will be kept and be available upon - * further calls to this method using the same theme. + * @param mixed $theme The theme to load the block from. This parameter + * is passed by reference, because it might be necessary + * to initialize the theme first. Any changes made to + * this variable will be kept and be available upon + * further calls to this method using the same theme. */ - protected function loadResourcesFromTheme($cacheKey, &$theme) + protected function loadResourcesFromTheme(string $cacheKey, &$theme) { if (!$theme instanceof Template) { /* @var Template $theme */ diff --git a/src/Symfony/Bridge/Twig/Node/TransNode.php b/src/Symfony/Bridge/Twig/Node/TransNode.php index e844801a5f..3cdf025857 100644 --- a/src/Symfony/Bridge/Twig/Node/TransNode.php +++ b/src/Symfony/Bridge/Twig/Node/TransNode.php @@ -103,7 +103,7 @@ class TransNode extends Node $compiler->raw(");\n"); } - protected function compileString(Node $body, ArrayExpression $vars, $ignoreStrictCheck = false) + protected function compileString(Node $body, ArrayExpression $vars, bool $ignoreStrictCheck = false) { if ($body instanceof ConstantExpression) { $msg = $body->getAttribute('value'); diff --git a/src/Symfony/Bridge/Twig/NodeVisitor/Scope.php b/src/Symfony/Bridge/Twig/NodeVisitor/Scope.php index 642623f2a6..765b4b69bd 100644 --- a/src/Symfony/Bridge/Twig/NodeVisitor/Scope.php +++ b/src/Symfony/Bridge/Twig/NodeVisitor/Scope.php @@ -50,14 +50,11 @@ class Scope /** * Stores data into current scope. * - * @param string $key - * @param mixed $value - * * @return $this * * @throws \LogicException */ - public function set($key, $value) + public function set(string $key, $value) { if ($this->left) { throw new \LogicException('Left scope is not mutable.'); @@ -71,11 +68,9 @@ class Scope /** * Tests if a data is visible from current scope. * - * @param string $key - * * @return bool */ - public function has($key) + public function has(string $key) { if (\array_key_exists($key, $this->data)) { return true; @@ -91,12 +86,9 @@ class Scope /** * Returns data visible from current scope. * - * @param string $key - * @param mixed $default - * * @return mixed */ - public function get($key, $default = null) + public function get(string $key, $default = null) { if (\array_key_exists($key, $this->data)) { return $this->data[$key]; diff --git a/src/Symfony/Bridge/Twig/TokenParser/TransTokenParser.php b/src/Symfony/Bridge/Twig/TokenParser/TransTokenParser.php index 023e3dbf43..a6e19daead 100644 --- a/src/Symfony/Bridge/Twig/TokenParser/TransTokenParser.php +++ b/src/Symfony/Bridge/Twig/TokenParser/TransTokenParser.php @@ -84,7 +84,7 @@ class TransTokenParser extends AbstractTokenParser return new TransNode($body, $domain, $count, $vars, $locale, $lineno, $this->getTag()); } - public function decideTransFork($token) + public function decideTransFork(Token $token) { return $token->test(['endtrans']); } diff --git a/src/Symfony/Bridge/Twig/Translation/TwigExtractor.php b/src/Symfony/Bridge/Twig/Translation/TwigExtractor.php index a921582dba..7bd7fb7166 100644 --- a/src/Symfony/Bridge/Twig/Translation/TwigExtractor.php +++ b/src/Symfony/Bridge/Twig/Translation/TwigExtractor.php @@ -76,12 +76,12 @@ class TwigExtractor extends AbstractFileExtractor implements ExtractorInterface /** * {@inheritdoc} */ - public function setPrefix($prefix) + public function setPrefix(string $prefix) { $this->prefix = $prefix; } - protected function extractTemplate($template, MessageCatalogue $catalogue) + protected function extractTemplate(string $template, MessageCatalogue $catalogue) { $visitor = $this->twig->getExtension('Symfony\Bridge\Twig\Extension\TranslationExtension')->getTranslationNodeVisitor(); $visitor->enable(); @@ -96,11 +96,9 @@ class TwigExtractor extends AbstractFileExtractor implements ExtractorInterface } /** - * @param string $file - * * @return bool */ - protected function canBeExtracted($file) + protected function canBeExtracted(string $file) { return $this->isFile($file) && 'twig' === pathinfo($file, PATHINFO_EXTENSION); } diff --git a/src/Symfony/Bridge/Twig/UndefinedCallableHandler.php b/src/Symfony/Bridge/Twig/UndefinedCallableHandler.php index 8c6253ef2b..0eaa014f74 100644 --- a/src/Symfony/Bridge/Twig/UndefinedCallableHandler.php +++ b/src/Symfony/Bridge/Twig/UndefinedCallableHandler.php @@ -65,7 +65,7 @@ class UndefinedCallableHandler 'workflow' => 'enable "framework.workflows"', ]; - public static function onUndefinedFilter($name) + public static function onUndefinedFilter(string $name) { if (!isset(self::$filterComponents[$name])) { return false; @@ -74,7 +74,7 @@ class UndefinedCallableHandler self::onUndefined($name, 'filter', self::$filterComponents[$name]); } - public static function onUndefinedFunction($name) + public static function onUndefinedFunction(string $name) { if (!isset(self::$functionComponents[$name])) { return false; diff --git a/src/Symfony/Bridge/Twig/composer.json b/src/Symfony/Bridge/Twig/composer.json index 0368ad5822..63012f95f8 100644 --- a/src/Symfony/Bridge/Twig/composer.json +++ b/src/Symfony/Bridge/Twig/composer.json @@ -25,13 +25,13 @@ "symfony/asset": "^4.4|^5.0", "symfony/dependency-injection": "^4.4|^5.0", "symfony/finder": "^4.4|^5.0", - "symfony/form": "^4.4|^5.0", + "symfony/form": "^5.0", "symfony/http-foundation": "^4.4|^5.0", "symfony/http-kernel": "^4.4|^5.0", "symfony/mime": "^4.4|^5.0", "symfony/polyfill-intl-icu": "~1.0", "symfony/routing": "^4.4|^5.0", - "symfony/translation": "^4.4|^5.0", + "symfony/translation": "^5.0", "symfony/yaml": "^4.4|^5.0", "symfony/security-acl": "^2.8|^3.0", "symfony/security-csrf": "^4.4|^5.0", @@ -45,9 +45,9 @@ }, "conflict": { "symfony/console": "<4.4", - "symfony/form": "<4.4", + "symfony/form": "<5.0", "symfony/http-foundation": "<4.4", - "symfony/translation": "<4.4", + "symfony/translation": "<5.0", "symfony/workflow": "<4.4" }, "suggest": { diff --git a/src/Symfony/Component/Form/AbstractRendererEngine.php b/src/Symfony/Component/Form/AbstractRendererEngine.php index e0954c9537..834615c351 100644 --- a/src/Symfony/Component/Form/AbstractRendererEngine.php +++ b/src/Symfony/Component/Form/AbstractRendererEngine.php @@ -44,7 +44,7 @@ abstract class AbstractRendererEngine implements FormRendererEngineInterface /** * {@inheritdoc} */ - public function setTheme(FormView $view, $themes, $useDefaultThemes = true) + public function setTheme(FormView $view, $themes, bool $useDefaultThemes = true) { $cacheKey = $view->vars[self::CACHE_KEY_VAR]; @@ -61,7 +61,7 @@ abstract class AbstractRendererEngine implements FormRendererEngineInterface /** * {@inheritdoc} */ - public function getResourceForBlockName(FormView $view, $blockName) + public function getResourceForBlockName(FormView $view, string $blockName) { $cacheKey = $view->vars[self::CACHE_KEY_VAR]; @@ -75,7 +75,7 @@ abstract class AbstractRendererEngine implements FormRendererEngineInterface /** * {@inheritdoc} */ - public function getResourceForBlockNameHierarchy(FormView $view, array $blockNameHierarchy, $hierarchyLevel) + public function getResourceForBlockNameHierarchy(FormView $view, array $blockNameHierarchy, int $hierarchyLevel) { $cacheKey = $view->vars[self::CACHE_KEY_VAR]; $blockName = $blockNameHierarchy[$hierarchyLevel]; @@ -90,7 +90,7 @@ abstract class AbstractRendererEngine implements FormRendererEngineInterface /** * {@inheritdoc} */ - public function getResourceHierarchyLevel(FormView $view, array $blockNameHierarchy, $hierarchyLevel) + public function getResourceHierarchyLevel(FormView $view, array $blockNameHierarchy, int $hierarchyLevel) { $cacheKey = $view->vars[self::CACHE_KEY_VAR]; $blockName = $blockNameHierarchy[$hierarchyLevel]; @@ -114,13 +114,9 @@ abstract class AbstractRendererEngine implements FormRendererEngineInterface * * @see getResourceForBlock() * - * @param string $cacheKey The cache key of the form view - * @param FormView $view The form view for finding the applying themes - * @param string $blockName The name of the block to load - * * @return bool True if the resource could be loaded, false otherwise */ - abstract protected function loadResourceForBlockName($cacheKey, FormView $view, $blockName); + abstract protected function loadResourceForBlockName(string $cacheKey, FormView $view, string $blockName); /** * Loads the cache with the resource for a specific level of a block hierarchy. diff --git a/src/Symfony/Component/Form/FormRendererEngineInterface.php b/src/Symfony/Component/Form/FormRendererEngineInterface.php index 4743ffea3f..4ed174c706 100644 --- a/src/Symfony/Component/Form/FormRendererEngineInterface.php +++ b/src/Symfony/Component/Form/FormRendererEngineInterface.php @@ -21,13 +21,11 @@ interface FormRendererEngineInterface /** * Sets the theme(s) to be used for rendering a view and its children. * - * @param FormView $view The view to assign the theme(s) to - * @param mixed $themes The theme(s). The type of these themes - * is open to the implementation. - * @param bool $useDefaultThemes If true, will use default themes specified - * in the engine + * @param FormView $view The view to assign the theme(s) to + * @param mixed $themes The theme(s). The type of these themes + * is open to the implementation. */ - public function setTheme(FormView $view, $themes, $useDefaultThemes = true); + public function setTheme(FormView $view, $themes, bool $useDefaultThemes = true); /** * Returns the resource for a block name. @@ -38,15 +36,14 @@ interface FormRendererEngineInterface * The type of the resource is decided by the implementation. The resource * is later passed to {@link renderBlock()} by the rendering algorithm. * - * @param FormView $view The view for determining the used themes. - * First the themes attached directly to the - * view with {@link setTheme()} are considered, - * then the ones of its parent etc. - * @param string $blockName The name of the block to render + * @param FormView $view The view for determining the used themes. + * First the themes attached directly to the + * view with {@link setTheme()} are considered, + * then the ones of its parent etc. * * @return mixed the renderer resource or false, if none was found */ - public function getResourceForBlockName(FormView $view, $blockName); + public function getResourceForBlockName(FormView $view, string $blockName); /** * Returns the resource for a block hierarchy. @@ -82,7 +79,7 @@ interface FormRendererEngineInterface * * @return mixed The renderer resource or false, if none was found */ - public function getResourceForBlockNameHierarchy(FormView $view, array $blockNameHierarchy, $hierarchyLevel); + public function getResourceForBlockNameHierarchy(FormView $view, array $blockNameHierarchy, int $hierarchyLevel); /** * Returns the hierarchy level at which a resource can be found. @@ -120,7 +117,7 @@ interface FormRendererEngineInterface * * @return int|bool The hierarchy level or false, if no resource was found */ - public function getResourceHierarchyLevel(FormView $view, array $blockNameHierarchy, $hierarchyLevel); + public function getResourceHierarchyLevel(FormView $view, array $blockNameHierarchy, int $hierarchyLevel); /** * Renders a block in the given renderer resource. @@ -136,5 +133,5 @@ interface FormRendererEngineInterface * * @return string The HTML markup */ - public function renderBlock(FormView $view, $resource, $blockName, array $variables = []); + public function renderBlock(FormView $view, $resource, string $blockName, array $variables = []); }