minor #32774 [TwigBridge] add parameter type declarations where possible (xabbuh)
This PR was merged into the 5.0-dev branch.
Discussion
----------
[TwigBridge] add parameter type declarations where possible
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | no
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | part of #32179
| License | MIT
| Doc PR |
Commits
-------
b9fa515e77
add parameter type declarations where possible
This commit is contained in:
commit
f545ba1fa4
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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('<abbr title="%s">%s</abbr>', $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)
|
||||
{
|
||||
// </span> ending tag from previous line
|
||||
$opening = strpos($line, '<span');
|
||||
|
@ -52,7 +52,7 @@ class DumpExtension extends AbstractExtension
|
||||
return 'dump';
|
||||
}
|
||||
|
||||
public function dump(Environment $env, $context)
|
||||
public function dump(Environment $env, array $context)
|
||||
{
|
||||
if (!$env->isDebug()) {
|
||||
return;
|
||||
|
@ -32,7 +32,7 @@ class ExpressionExtension extends AbstractExtension
|
||||
];
|
||||
}
|
||||
|
||||
public function createExpression($expression)
|
||||
public function createExpression(string $expression)
|
||||
{
|
||||
return new Expression($expression);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -32,13 +32,12 @@ 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
|
||||
*
|
||||
* @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
|
||||
*
|
||||
* @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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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']")
|
||||
*
|
||||
* @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]")
|
||||
*
|
||||
* @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]")
|
||||
*
|
||||
* @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]")
|
||||
*
|
||||
* @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]")
|
||||
*
|
||||
* @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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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%';
|
||||
|
@ -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.
|
||||
*/
|
||||
protected function loadResourcesFromTheme($cacheKey, &$theme)
|
||||
protected function loadResourcesFromTheme(string $cacheKey, &$theme)
|
||||
{
|
||||
if (!$theme instanceof Template) {
|
||||
/* @var Template $theme */
|
||||
|
@ -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');
|
||||
|
@ -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];
|
||||
|
@ -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']);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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": {
|
||||
|
@ -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.
|
||||
|
@ -24,10 +24,8 @@ interface FormRendererEngineInterface
|
||||
* @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
|
||||
*/
|
||||
public function setTheme(FormView $view, $themes, $useDefaultThemes = true);
|
||||
public function setTheme(FormView $view, $themes, bool $useDefaultThemes = true);
|
||||
|
||||
/**
|
||||
* Returns the resource for a block name.
|
||||
@ -42,11 +40,10 @@ interface FormRendererEngineInterface
|
||||
* 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
|
||||
*
|
||||
* @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 = []);
|
||||
}
|
||||
|
Reference in New Issue
Block a user