add parameter type declarations where possible

This commit is contained in:
Christian Flothmann 2019-07-28 09:04:51 +02:00
parent be50e2e177
commit b9fa515e77
25 changed files with 89 additions and 169 deletions

View File

@ -39,14 +39,14 @@ class AppVariable
$this->requestStack = $requestStack; $this->requestStack = $requestStack;
} }
public function setEnvironment($environment) public function setEnvironment(string $environment)
{ {
$this->environment = $environment; $this->environment = $environment;
} }
public function setDebug($debug) public function setDebug(bool $debug)
{ {
$this->debug = (bool) $debug; $this->debug = $debug;
} }
/** /**

View File

@ -107,7 +107,7 @@ EOF
return $filesInfo; return $filesInfo;
} }
protected function findFiles($filename) protected function findFiles(string $filename)
{ {
if (is_file($filename)) { if (is_file($filename)) {
return [$filename]; return [$filename];

View File

@ -46,12 +46,9 @@ class AssetExtension extends AbstractExtension
* If the package used to generate the path is an instance of * If the package used to generate the path is an instance of
* UrlPackage, you will always get a URL and not a path. * 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 * @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); return $this->packages->getUrl($path, $packageName);
} }
@ -59,12 +56,9 @@ class AssetExtension extends AbstractExtension
/** /**
* Returns the version of an asset. * 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 * @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); return $this->packages->getVersion($path, $packageName);
} }

View File

@ -57,7 +57,7 @@ class CodeExtension extends AbstractExtension
]; ];
} }
public function abbrClass($class) public function abbrClass(string $class)
{ {
$parts = explode('\\', $class); $parts = explode('\\', $class);
$short = array_pop($parts); $short = array_pop($parts);
@ -65,7 +65,7 @@ class CodeExtension extends AbstractExtension
return sprintf('<abbr title="%s">%s</abbr>', $class, $short); return sprintf('<abbr title="%s">%s</abbr>', $class, $short);
} }
public function abbrMethod($method) public function abbrMethod(string $method)
{ {
if (false !== strpos($method, '::')) { if (false !== strpos($method, '::')) {
list($class, $method) = explode('::', $method, 2); list($class, $method) = explode('::', $method, 2);
@ -82,11 +82,9 @@ class CodeExtension extends AbstractExtension
/** /**
* Formats an array as a string. * Formats an array as a string.
* *
* @param array $args The argument array
*
* @return string * @return string
*/ */
public function formatArgs($args) public function formatArgs(array $args)
{ {
$result = []; $result = [];
foreach ($args as $key => $item) { foreach ($args as $key => $item) {
@ -115,11 +113,9 @@ class CodeExtension extends AbstractExtension
/** /**
* Formats an array as a string. * Formats an array as a string.
* *
* @param array $args The argument array
*
* @return string * @return string
*/ */
public function formatArgsAsText($args) public function formatArgsAsText(array $args)
{ {
return strip_tags($this->formatArgs($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. * 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 * @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)) { if (is_file($file) && is_readable($file)) {
// highlight_file could throw warnings // highlight_file could throw warnings
@ -165,13 +157,9 @@ class CodeExtension extends AbstractExtension
/** /**
* Formats a file path. * 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 * @return string
*/ */
public function formatFile($file, $line, $text = null) public function formatFile(string $file, int $line, string $text = null)
{ {
$file = trim($file); $file = trim($file);
@ -197,12 +185,9 @@ class CodeExtension extends AbstractExtension
/** /**
* Returns the link for a given file/line pair. * 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 * @return string|false A link or false
*/ */
public function getFileLink($file, $line) public function getFileLink(string $file, int $line)
{ {
if ($fmt = $this->fileLinkFormat) { if ($fmt = $this->fileLinkFormat) {
return \is_string($fmt) ? strtr($fmt, ['%f' => $file, '%l' => $line]) : $fmt->format($file, $line); return \is_string($fmt) ? strtr($fmt, ['%f' => $file, '%l' => $line]) : $fmt->format($file, $line);
@ -222,7 +207,7 @@ class CodeExtension extends AbstractExtension
return null; return null;
} }
public function formatFileFromText($text) public function formatFileFromText(string $text)
{ {
return preg_replace_callback('/in ("|&quot;)?(.+?)\1(?: +(?:on|at))? +line (\d+)/s', function ($match) { return preg_replace_callback('/in ("|&quot;)?(.+?)\1(?: +(?:on|at))? +line (\d+)/s', function ($match) {
return 'in '.$this->formatFile($match[2], $match[3]); return 'in '.$this->formatFile($match[2], $match[3]);
@ -232,7 +217,7 @@ class CodeExtension extends AbstractExtension
/** /**
* @internal * @internal
*/ */
public function formatLogMessage($message, array $context) public function formatLogMessage(string $message, array $context)
{ {
if ($context && false !== strpos($message, '{')) { if ($context && false !== strpos($message, '{')) {
$replacements = []; $replacements = [];
@ -258,7 +243,7 @@ class CodeExtension extends AbstractExtension
return 'code'; return 'code';
} }
protected static function fixCodeMarkup($line) protected static function fixCodeMarkup(string $line)
{ {
// </span> ending tag from previous line // </span> ending tag from previous line
$opening = strpos($line, '<span'); $opening = strpos($line, '<span');

View File

@ -52,7 +52,7 @@ class DumpExtension extends AbstractExtension
return 'dump'; return 'dump';
} }
public function dump(Environment $env, $context) public function dump(Environment $env, array $context)
{ {
if (!$env->isDebug()) { if (!$env->isDebug()) {
return; return;

View File

@ -32,7 +32,7 @@ class ExpressionExtension extends AbstractExtension
]; ];
} }
public function createExpression($expression) public function createExpression(string $expression)
{ {
return new Expression($expression); return new Expression($expression);
} }

View File

@ -46,13 +46,11 @@ class HttpFoundationExtension extends AbstractExtension
* *
* This method returns the path unchanged if no request is available. * This method returns the path unchanged if no request is available.
* *
* @param string $path The path
*
* @return string The absolute URL * @return string The absolute URL
* *
* @see Request::getUriForPath() * @see Request::getUriForPath()
*/ */
public function generateAbsoluteUrl($path) public function generateAbsoluteUrl(string $path)
{ {
return $this->urlHelper->getAbsoluteUrl($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. * This method returns the path unchanged if no request is available.
* *
* @param string $path The path
*
* @return string The relative path * @return string The relative path
* *
* @see Request::getRelativeUriForPath() * @see Request::getRelativeUriForPath()
*/ */
public function generateRelativePath($path) public function generateRelativePath(string $path)
{ {
return $this->urlHelper->getRelativePath($path); return $this->urlHelper->getRelativePath($path);
} }

View File

@ -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); return new ControllerReference($controller, $attributes, $query);
} }

View File

@ -31,14 +31,13 @@ class HttpKernelRuntime
/** /**
* Renders a fragment. * Renders a fragment.
* *
* @param string|ControllerReference $uri A URI as a string or a ControllerReference instance * @param string|ControllerReference $uri A URI as a string or a ControllerReference instance
* @param array $options An array of options
* *
* @return string The fragment content * @return string The fragment content
* *
* @see FragmentHandler::render() * @see FragmentHandler::render()
*/ */
public function renderFragment($uri, $options = []) public function renderFragment($uri, array $options = [])
{ {
$strategy = isset($options['strategy']) ? $options['strategy'] : 'inline'; $strategy = isset($options['strategy']) ? $options['strategy'] : 'inline';
unset($options['strategy']); unset($options['strategy']);
@ -49,15 +48,13 @@ class HttpKernelRuntime
/** /**
* Renders a fragment. * Renders a fragment.
* *
* @param string $strategy A strategy name * @param string|ControllerReference $uri A URI as a string or a ControllerReference instance
* @param string|ControllerReference $uri A URI as a string or a ControllerReference instance
* @param array $options An array of options
* *
* @return string The fragment content * @return string The fragment content
* *
* @see FragmentHandler::render() * @see FragmentHandler::render()
*/ */
public function renderFragmentStrategy($strategy, $uri, $options = []) public function renderFragmentStrategy(string $strategy, $uri, array $options = [])
{ {
return $this->handler->render($uri, $strategy, $options); return $this->handler->render($uri, $strategy, $options);
} }

View File

@ -47,7 +47,7 @@ class LogoutUrlExtension extends AbstractExtension
* *
* @return string The relative logout URL * @return string The relative logout URL
*/ */
public function getLogoutPath($key = null) public function getLogoutPath(string $key = null)
{ {
return $this->generator->getLogoutPath($key); return $this->generator->getLogoutPath($key);
} }
@ -59,7 +59,7 @@ class LogoutUrlExtension extends AbstractExtension
* *
* @return string The absolute logout URL * @return string The absolute logout URL
*/ */
public function getLogoutUrl($key = null) public function getLogoutUrl(string $key = null)
{ {
return $this->generator->getLogoutUrl($key); return $this->generator->getLogoutUrl($key);
} }

View File

@ -46,25 +46,17 @@ class RoutingExtension extends AbstractExtension
} }
/** /**
* @param string $name
* @param array $parameters
* @param bool $relative
*
* @return string * @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); return $this->generator->generate($name, $parameters, $relative ? UrlGeneratorInterface::RELATIVE_PATH : UrlGeneratorInterface::ABSOLUTE_PATH);
} }
/** /**
* @param string $name
* @param array $parameters
* @param bool $schemeRelative
*
* @return string * @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); return $this->generator->generate($name, $parameters, $schemeRelative ? UrlGeneratorInterface::NETWORK_PATH : UrlGeneratorInterface::ABSOLUTE_URL);
} }

View File

@ -31,7 +31,7 @@ class SecurityExtension extends AbstractExtension
$this->securityChecker = $securityChecker; $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) { if (null === $this->securityChecker) {
return false; return false;

View File

@ -94,7 +94,7 @@ class TranslationExtension extends AbstractExtension
return $this->translationNodeVisitor ?: $this->translationNodeVisitor = new TranslationNodeVisitor(); 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) { if (null !== $count) {
$arguments['%count%'] = $count; $arguments['%count%'] = $count;

View File

@ -49,13 +49,12 @@ class WebLinkExtension extends AbstractExtension
/** /**
* Adds a "Link" HTTP header. * 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 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]") * @param array $attributes The attributes of this link (e.g. "['as' => true]", "['pr' => 0.5]")
* *
* @return string The relation URI * @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()) { if (!$request = $this->requestStack->getMasterRequest()) {
return $uri; return $uri;
@ -75,12 +74,11 @@ class WebLinkExtension extends AbstractExtension
/** /**
* Preloads a resource. * 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 * @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); return $this->link($uri, 'preload', $attributes);
} }
@ -88,12 +86,11 @@ class WebLinkExtension extends AbstractExtension
/** /**
* Resolves a resource origin as early as possible. * 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 * @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); 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). * 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 * @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); return $this->link($uri, 'preconnect', $attributes);
} }
@ -114,12 +110,11 @@ class WebLinkExtension extends AbstractExtension
/** /**
* Indicates to the client that it should prefetch this resource. * 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 * @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); return $this->link($uri, 'prefetch', $attributes);
} }
@ -127,12 +122,11 @@ class WebLinkExtension extends AbstractExtension
/** /**
* Indicates to the client that it should prerender this resource . * 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 * @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); return $this->link($uri, 'prerender', $attributes);
} }

View File

@ -46,13 +46,9 @@ class WorkflowExtension extends AbstractExtension
/** /**
* Returns true if the transition is enabled. * 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 * @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); return $this->workflowRegistry->get($subject, $name)->can($subject, $transitionName);
} }
@ -60,12 +56,9 @@ class WorkflowExtension extends AbstractExtension
/** /**
* Returns all enabled transitions. * Returns all enabled transitions.
* *
* @param object $subject A subject
* @param string $name A workflow name
*
* @return Transition[] All enabled transitions * @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); return $this->workflowRegistry->get($subject, $name)->getEnabledTransitions($subject);
} }
@ -73,13 +66,9 @@ class WorkflowExtension extends AbstractExtension
/** /**
* Returns true if the place is marked. * 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 * @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); return $this->workflowRegistry->get($subject, $name)->getMarking($subject)->has($placeName);
} }
@ -87,13 +76,9 @@ class WorkflowExtension extends AbstractExtension
/** /**
* Returns marked places. * 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[] * @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(); $places = $this->workflowRegistry->get($subject, $name)->getMarking($subject)->getPlaces();
@ -107,12 +92,11 @@ class WorkflowExtension extends AbstractExtension
/** /**
* Returns the metadata for a specific subject. * Returns the metadata for a specific subject.
* *
* @param object $subject A subject
* @param string|Transition|null $metadataSubject Use null to get workflow metadata * @param string|Transition|null $metadataSubject Use null to get workflow metadata
* Use a string (the place name) to get place metadata * Use a string (the place name) to get place metadata
* Use a Transition instance to get transition 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 return $this
->workflowRegistry ->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); $workflow = $this->workflowRegistry->get($subject, $name);

View File

@ -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; static $dumper;
@ -49,7 +49,7 @@ class YamlExtension extends AbstractExtension
return $dumper->dump($input, $inline, 0, false, $dumpObjects); 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)) { if (\is_resource($value)) {
return '%Resource%'; return '%Resource%';

View File

@ -40,7 +40,7 @@ class TwigRendererEngine extends AbstractRendererEngine
/** /**
* {@inheritdoc} * {@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]; $cacheKey = $view->vars[self::CACHE_KEY_VAR];
@ -70,13 +70,9 @@ class TwigRendererEngine extends AbstractRendererEngine
* *
* @see getResourceForBlock() * @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 * @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 // The caller guarantees that $this->resources[$cacheKey][$block] is
// not set, but it doesn't have to check whether $this->resources[$cacheKey] // 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. * 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
* @param mixed $theme The theme to load the block from. This parameter * is passed by reference, because it might be necessary
* is passed by reference, because it might be necessary * to initialize the theme first. Any changes made to
* to initialize the theme first. Any changes made to * this variable will be kept and be available upon
* this variable will be kept and be available upon * further calls to this method using the same theme.
* further calls to this method using the same theme.
*/ */
protected function loadResourcesFromTheme($cacheKey, &$theme) protected function loadResourcesFromTheme(string $cacheKey, &$theme)
{ {
if (!$theme instanceof Template) { if (!$theme instanceof Template) {
/* @var Template $theme */ /* @var Template $theme */

View File

@ -103,7 +103,7 @@ class TransNode extends Node
$compiler->raw(");\n"); $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) { if ($body instanceof ConstantExpression) {
$msg = $body->getAttribute('value'); $msg = $body->getAttribute('value');

View File

@ -50,14 +50,11 @@ class Scope
/** /**
* Stores data into current scope. * Stores data into current scope.
* *
* @param string $key
* @param mixed $value
*
* @return $this * @return $this
* *
* @throws \LogicException * @throws \LogicException
*/ */
public function set($key, $value) public function set(string $key, $value)
{ {
if ($this->left) { if ($this->left) {
throw new \LogicException('Left scope is not mutable.'); throw new \LogicException('Left scope is not mutable.');
@ -71,11 +68,9 @@ class Scope
/** /**
* Tests if a data is visible from current scope. * Tests if a data is visible from current scope.
* *
* @param string $key
*
* @return bool * @return bool
*/ */
public function has($key) public function has(string $key)
{ {
if (\array_key_exists($key, $this->data)) { if (\array_key_exists($key, $this->data)) {
return true; return true;
@ -91,12 +86,9 @@ class Scope
/** /**
* Returns data visible from current scope. * Returns data visible from current scope.
* *
* @param string $key
* @param mixed $default
*
* @return mixed * @return mixed
*/ */
public function get($key, $default = null) public function get(string $key, $default = null)
{ {
if (\array_key_exists($key, $this->data)) { if (\array_key_exists($key, $this->data)) {
return $this->data[$key]; return $this->data[$key];

View File

@ -84,7 +84,7 @@ class TransTokenParser extends AbstractTokenParser
return new TransNode($body, $domain, $count, $vars, $locale, $lineno, $this->getTag()); return new TransNode($body, $domain, $count, $vars, $locale, $lineno, $this->getTag());
} }
public function decideTransFork($token) public function decideTransFork(Token $token)
{ {
return $token->test(['endtrans']); return $token->test(['endtrans']);
} }

View File

@ -76,12 +76,12 @@ class TwigExtractor extends AbstractFileExtractor implements ExtractorInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function setPrefix($prefix) public function setPrefix(string $prefix)
{ {
$this->prefix = $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 = $this->twig->getExtension('Symfony\Bridge\Twig\Extension\TranslationExtension')->getTranslationNodeVisitor();
$visitor->enable(); $visitor->enable();
@ -96,11 +96,9 @@ class TwigExtractor extends AbstractFileExtractor implements ExtractorInterface
} }
/** /**
* @param string $file
*
* @return bool * @return bool
*/ */
protected function canBeExtracted($file) protected function canBeExtracted(string $file)
{ {
return $this->isFile($file) && 'twig' === pathinfo($file, PATHINFO_EXTENSION); return $this->isFile($file) && 'twig' === pathinfo($file, PATHINFO_EXTENSION);
} }

View File

@ -65,7 +65,7 @@ class UndefinedCallableHandler
'workflow' => 'enable "framework.workflows"', 'workflow' => 'enable "framework.workflows"',
]; ];
public static function onUndefinedFilter($name) public static function onUndefinedFilter(string $name)
{ {
if (!isset(self::$filterComponents[$name])) { if (!isset(self::$filterComponents[$name])) {
return false; return false;
@ -74,7 +74,7 @@ class UndefinedCallableHandler
self::onUndefined($name, 'filter', self::$filterComponents[$name]); self::onUndefined($name, 'filter', self::$filterComponents[$name]);
} }
public static function onUndefinedFunction($name) public static function onUndefinedFunction(string $name)
{ {
if (!isset(self::$functionComponents[$name])) { if (!isset(self::$functionComponents[$name])) {
return false; return false;

View File

@ -25,13 +25,13 @@
"symfony/asset": "^4.4|^5.0", "symfony/asset": "^4.4|^5.0",
"symfony/dependency-injection": "^4.4|^5.0", "symfony/dependency-injection": "^4.4|^5.0",
"symfony/finder": "^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-foundation": "^4.4|^5.0",
"symfony/http-kernel": "^4.4|^5.0", "symfony/http-kernel": "^4.4|^5.0",
"symfony/mime": "^4.4|^5.0", "symfony/mime": "^4.4|^5.0",
"symfony/polyfill-intl-icu": "~1.0", "symfony/polyfill-intl-icu": "~1.0",
"symfony/routing": "^4.4|^5.0", "symfony/routing": "^4.4|^5.0",
"symfony/translation": "^4.4|^5.0", "symfony/translation": "^5.0",
"symfony/yaml": "^4.4|^5.0", "symfony/yaml": "^4.4|^5.0",
"symfony/security-acl": "^2.8|^3.0", "symfony/security-acl": "^2.8|^3.0",
"symfony/security-csrf": "^4.4|^5.0", "symfony/security-csrf": "^4.4|^5.0",
@ -45,9 +45,9 @@
}, },
"conflict": { "conflict": {
"symfony/console": "<4.4", "symfony/console": "<4.4",
"symfony/form": "<4.4", "symfony/form": "<5.0",
"symfony/http-foundation": "<4.4", "symfony/http-foundation": "<4.4",
"symfony/translation": "<4.4", "symfony/translation": "<5.0",
"symfony/workflow": "<4.4" "symfony/workflow": "<4.4"
}, },
"suggest": { "suggest": {

View File

@ -44,7 +44,7 @@ abstract class AbstractRendererEngine implements FormRendererEngineInterface
/** /**
* {@inheritdoc} * {@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]; $cacheKey = $view->vars[self::CACHE_KEY_VAR];
@ -61,7 +61,7 @@ abstract class AbstractRendererEngine implements FormRendererEngineInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getResourceForBlockName(FormView $view, $blockName) public function getResourceForBlockName(FormView $view, string $blockName)
{ {
$cacheKey = $view->vars[self::CACHE_KEY_VAR]; $cacheKey = $view->vars[self::CACHE_KEY_VAR];
@ -75,7 +75,7 @@ abstract class AbstractRendererEngine implements FormRendererEngineInterface
/** /**
* {@inheritdoc} * {@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]; $cacheKey = $view->vars[self::CACHE_KEY_VAR];
$blockName = $blockNameHierarchy[$hierarchyLevel]; $blockName = $blockNameHierarchy[$hierarchyLevel];
@ -90,7 +90,7 @@ abstract class AbstractRendererEngine implements FormRendererEngineInterface
/** /**
* {@inheritdoc} * {@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]; $cacheKey = $view->vars[self::CACHE_KEY_VAR];
$blockName = $blockNameHierarchy[$hierarchyLevel]; $blockName = $blockNameHierarchy[$hierarchyLevel];
@ -114,13 +114,9 @@ abstract class AbstractRendererEngine implements FormRendererEngineInterface
* *
* @see getResourceForBlock() * @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 * @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. * Loads the cache with the resource for a specific level of a block hierarchy.

View File

@ -21,13 +21,11 @@ interface FormRendererEngineInterface
/** /**
* Sets the theme(s) to be used for rendering a view and its children. * 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 FormView $view The view to assign the theme(s) to
* @param mixed $themes The theme(s). The type of these themes * @param mixed $themes The theme(s). The type of these themes
* is open to the implementation. * is open to the implementation.
* @param bool $useDefaultThemes If true, will use default themes specified
* in the engine
*/ */
public function setTheme(FormView $view, $themes, $useDefaultThemes = true); public function setTheme(FormView $view, $themes, bool $useDefaultThemes = true);
/** /**
* Returns the resource for a block name. * 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 * The type of the resource is decided by the implementation. The resource
* is later passed to {@link renderBlock()} by the rendering algorithm. * is later passed to {@link renderBlock()} by the rendering algorithm.
* *
* @param FormView $view The view for determining the used themes. * @param FormView $view The view for determining the used themes.
* First the themes attached directly to the * First the themes attached directly to the
* view with {@link setTheme()} are considered, * view with {@link setTheme()} are considered,
* then the ones of its parent etc. * then the ones of its parent etc.
* @param string $blockName The name of the block to render
* *
* @return mixed the renderer resource or false, if none was found * @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. * Returns the resource for a block hierarchy.
@ -82,7 +79,7 @@ interface FormRendererEngineInterface
* *
* @return mixed The renderer resource or false, if none was found * @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. * 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 * @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. * Renders a block in the given renderer resource.
@ -136,5 +133,5 @@ interface FormRendererEngineInterface
* *
* @return string The HTML markup * @return string The HTML markup
*/ */
public function renderBlock(FormView $view, $resource, $blockName, array $variables = []); public function renderBlock(FormView $view, $resource, string $blockName, array $variables = []);
} }