Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 07d80a5

Browse filesBrowse files
committed
add parameter type declarations where possible
1 parent 1cc7067 commit 07d80a5
Copy full SHA for 07d80a5

28 files changed

+104
-184
lines changed

‎src/Symfony/Bridge/Twig/AppVariable.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/AppVariable.php
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@ public function setRequestStack(RequestStack $requestStack)
3939
$this->requestStack = $requestStack;
4040
}
4141

42-
public function setEnvironment($environment)
42+
public function setEnvironment(string $environment)
4343
{
4444
$this->environment = $environment;
4545
}
4646

47-
public function setDebug($debug)
47+
public function setDebug(bool $debug)
4848
{
49-
$this->debug = (bool) $debug;
49+
$this->debug = $debug;
5050
}
5151

5252
/**

‎src/Symfony/Bridge/Twig/Command/DebugCommand.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Command/DebugCommand.php
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ private function displayGeneralText(SymfonyStyle $io, string $filter = null)
234234
}
235235
}
236236

237-
private function displayGeneralJson(SymfonyStyle $io, $filter)
237+
private function displayGeneralJson(SymfonyStyle $io, string $filter = null)
238238
{
239239
$decorated = $io->isDecorated();
240240
$types = ['functions', 'filters', 'tests', 'globals'];
@@ -288,7 +288,7 @@ private function getLoaderPaths(string $name = null): array
288288
return $loaderPaths;
289289
}
290290

291-
private function getMetadata($type, $entity)
291+
private function getMetadata(string $type, $entity)
292292
{
293293
if ('globals' === $type) {
294294
return $entity;
@@ -344,7 +344,7 @@ private function getMetadata($type, $entity)
344344
}
345345
}
346346

347-
private function getPrettyMetadata($type, $entity, $decorated)
347+
private function getPrettyMetadata(string $type, $entity, bool $decorated)
348348
{
349349
if ('tests' === $type) {
350350
return '';

‎src/Symfony/Bridge/Twig/Command/LintCommand.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Command/LintCommand.php
+9-9Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ private function getFilesInfo(array $filenames)
107107
return $filesInfo;
108108
}
109109

110-
protected function findFiles($filename)
110+
protected function findFiles(string $filename)
111111
{
112112
if (is_file($filename)) {
113113
return [$filename];
@@ -118,13 +118,13 @@ protected function findFiles($filename)
118118
throw new RuntimeException(sprintf('File or directory "%s" is not readable', $filename));
119119
}
120120

121-
private function validate($template, $file)
121+
private function validate(string $template, string $file)
122122
{
123123
$realLoader = $this->twig->getLoader();
124124
try {
125-
$temporaryLoader = new ArrayLoader([(string) $file => $template]);
125+
$temporaryLoader = new ArrayLoader([$file => $template]);
126126
$this->twig->setLoader($temporaryLoader);
127-
$nodeTree = $this->twig->parse($this->twig->tokenize(new Source($template, (string) $file)));
127+
$nodeTree = $this->twig->parse($this->twig->tokenize(new Source($template, $file)));
128128
$this->twig->compile($nodeTree);
129129
$this->twig->setLoader($realLoader);
130130
} catch (Error $e) {
@@ -136,7 +136,7 @@ private function validate($template, $file)
136136
return ['template' => $template, 'file' => $file, 'valid' => true];
137137
}
138138

139-
private function display(InputInterface $input, OutputInterface $output, SymfonyStyle $io, $files)
139+
private function display(InputInterface $input, OutputInterface $output, SymfonyStyle $io, array $files)
140140
{
141141
switch ($input->getOption('format')) {
142142
case 'txt':
@@ -148,7 +148,7 @@ private function display(InputInterface $input, OutputInterface $output, Symfony
148148
}
149149
}
150150

151-
private function displayTxt(OutputInterface $output, SymfonyStyle $io, $filesInfo)
151+
private function displayTxt(OutputInterface $output, SymfonyStyle $io, array $filesInfo)
152152
{
153153
$errors = 0;
154154

@@ -170,7 +170,7 @@ private function displayTxt(OutputInterface $output, SymfonyStyle $io, $filesInf
170170
return min($errors, 1);
171171
}
172172

173-
private function displayJson(OutputInterface $output, $filesInfo)
173+
private function displayJson(OutputInterface $output, array $filesInfo)
174174
{
175175
$errors = 0;
176176

@@ -189,7 +189,7 @@ private function displayJson(OutputInterface $output, $filesInfo)
189189
return min($errors, 1);
190190
}
191191

192-
private function renderException(OutputInterface $output, $template, Error $exception, $file = null)
192+
private function renderException(OutputInterface $output, $template, Error $exception, string $file = null)
193193
{
194194
$line = $exception->getTemplateLine();
195195

@@ -212,7 +212,7 @@ private function renderException(OutputInterface $output, $template, Error $exce
212212
}
213213
}
214214

215-
private function getContext($template, $line, $context = 3)
215+
private function getContext(string $template, int $line, int $context = 3)
216216
{
217217
$lines = explode("\n", $template);
218218

‎src/Symfony/Bridge/Twig/DataCollector/TwigDataCollector.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/DataCollector/TwigDataCollector.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ public function getProfile()
147147
return $this->profile;
148148
}
149149

150-
private function getComputedData($index)
150+
private function getComputedData(string $index)
151151
{
152152
if (null === $this->computed) {
153153
$this->computed = $this->computeData($this->getProfile());

‎src/Symfony/Bridge/Twig/Extension/AssetExtension.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Extension/AssetExtension.php
+2-8Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,25 +46,19 @@ public function getFunctions()
4646
* If the package used to generate the path is an instance of
4747
* UrlPackage, you will always get a URL and not a path.
4848
*
49-
* @param string $path A public path
50-
* @param string $packageName The name of the asset package to use
51-
*
5249
* @return string The public path of the asset
5350
*/
54-
public function getAssetUrl($path, $packageName = null)
51+
public function getAssetUrl(string $path, string $packageName = null)
5552
{
5653
return $this->packages->getUrl($path, $packageName);
5754
}
5855

5956
/**
6057
* Returns the version of an asset.
6158
*
62-
* @param string $path A public path
63-
* @param string $packageName The name of the asset package to use
64-
*
6559
* @return string The asset version
6660
*/
67-
public function getAssetVersion($path, $packageName = null)
61+
public function getAssetVersion(string $path, string $packageName = null)
6862
{
6963
return $this->packages->getVersion($path, $packageName);
7064
}

‎src/Symfony/Bridge/Twig/Extension/CodeExtension.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Extension/CodeExtension.php
+10-25Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,15 @@ public function getFilters()
5757
];
5858
}
5959

60-
public function abbrClass($class)
60+
public function abbrClass(string $class)
6161
{
6262
$parts = explode('\\', $class);
6363
$short = array_pop($parts);
6464

6565
return sprintf('<abbr title="%s">%s</abbr>', $class, $short);
6666
}
6767

68-
public function abbrMethod($method)
68+
public function abbrMethod(string $method)
6969
{
7070
if (false !== strpos($method, '::')) {
7171
list($class, $method) = explode('::', $method, 2);
@@ -82,11 +82,9 @@ public function abbrMethod($method)
8282
/**
8383
* Formats an array as a string.
8484
*
85-
* @param array $args The argument array
86-
*
8785
* @return string
8886
*/
89-
public function formatArgs($args)
87+
public function formatArgs(array $args)
9088
{
9189
$result = [];
9290
foreach ($args as $key => $item) {
@@ -115,25 +113,19 @@ public function formatArgs($args)
115113
/**
116114
* Formats an array as a string.
117115
*
118-
* @param array $args The argument array
119-
*
120116
* @return string
121117
*/
122-
public function formatArgsAsText($args)
118+
public function formatArgsAsText(array $args)
123119
{
124120
return strip_tags($this->formatArgs($args));
125121
}
126122

127123
/**
128124
* Returns an excerpt of a code file around the given line number.
129125
*
130-
* @param string $file A file path
131-
* @param int $line The selected line number
132-
* @param int $srcContext The number of displayed lines around or -1 for the whole file
133-
*
134126
* @return string An HTML string
135127
*/
136-
public function fileExcerpt($file, $line, $srcContext = 3)
128+
public function fileExcerpt(string $file, int $line, int $srcContext = 3)
137129
{
138130
if (is_file($file) && is_readable($file)) {
139131
// highlight_file could throw warnings
@@ -165,13 +157,9 @@ public function fileExcerpt($file, $line, $srcContext = 3)
165157
/**
166158
* Formats a file path.
167159
*
168-
* @param string $file An absolute file path
169-
* @param int $line The line number
170-
* @param string $text Use this text for the link rather than the file path
171-
*
172160
* @return string
173161
*/
174-
public function formatFile($file, $line, $text = null)
162+
public function formatFile(string $file, int $line, string $text = null)
175163
{
176164
$file = trim($file);
177165

@@ -197,12 +185,9 @@ public function formatFile($file, $line, $text = null)
197185
/**
198186
* Returns the link for a given file/line pair.
199187
*
200-
* @param string $file An absolute file path
201-
* @param int $line The line number
202-
*
203188
* @return string|false A link or false
204189
*/
205-
public function getFileLink($file, $line)
190+
public function getFileLink(string $file, int $line)
206191
{
207192
if ($fmt = $this->fileLinkFormat) {
208193
return \is_string($fmt) ? strtr($fmt, ['%f' => $file, '%l' => $line]) : $fmt->format($file, $line);
@@ -222,7 +207,7 @@ public function getFileRelative(string $file): ?string
222207
return null;
223208
}
224209

225-
public function formatFileFromText($text)
210+
public function formatFileFromText(string $text)
226211
{
227212
return preg_replace_callback('/in ("|&quot;)?(.+?)\1(?: +(?:on|at))? +line (\d+)/s', function ($match) {
228213
return 'in '.$this->formatFile($match[2], $match[3]);
@@ -232,7 +217,7 @@ public function formatFileFromText($text)
232217
/**
233218
* @internal
234219
*/
235-
public function formatLogMessage($message, array $context)
220+
public function formatLogMessage(string $message, array $context)
236221
{
237222
if ($context && false !== strpos($message, '{')) {
238223
$replacements = [];
@@ -258,7 +243,7 @@ public function getName()
258243
return 'code';
259244
}
260245

261-
protected static function fixCodeMarkup($line)
246+
protected static function fixCodeMarkup(string $line)
262247
{
263248
// </span> ending tag from previous line
264249
$opening = strpos($line, '<span');

‎src/Symfony/Bridge/Twig/Extension/DumpExtension.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Extension/DumpExtension.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function getName()
5252
return 'dump';
5353
}
5454

55-
public function dump(Environment $env, $context)
55+
public function dump(Environment $env, array $context)
5656
{
5757
if (!$env->isDebug()) {
5858
return;

‎src/Symfony/Bridge/Twig/Extension/ExpressionExtension.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Extension/ExpressionExtension.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function getFunctions()
3232
];
3333
}
3434

35-
public function createExpression($expression)
35+
public function createExpression(string $expression)
3636
{
3737
return new Expression($expression);
3838
}

‎src/Symfony/Bridge/Twig/Extension/HttpFoundationExtension.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Extension/HttpFoundationExtension.php
+2-6Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,11 @@ public function getFunctions()
4646
*
4747
* This method returns the path unchanged if no request is available.
4848
*
49-
* @param string $path The path
50-
*
5149
* @return string The absolute URL
5250
*
5351
* @see Request::getUriForPath()
5452
*/
55-
public function generateAbsoluteUrl($path)
53+
public function generateAbsoluteUrl(string $path)
5654
{
5755
return $this->urlHelper->getAbsoluteUrl($path);
5856
}
@@ -62,13 +60,11 @@ public function generateAbsoluteUrl($path)
6260
*
6361
* This method returns the path unchanged if no request is available.
6462
*
65-
* @param string $path The path
66-
*
6763
* @return string The relative path
6864
*
6965
* @see Request::getRelativeUriForPath()
7066
*/
71-
public function generateRelativePath($path)
67+
public function generateRelativePath(string $path)
7268
{
7369
return $this->urlHelper->getRelativePath($path);
7470
}

‎src/Symfony/Bridge/Twig/Extension/HttpKernelExtension.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Extension/HttpKernelExtension.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function getFunctions()
3131
];
3232
}
3333

34-
public static function controller($controller, $attributes = [], $query = [])
34+
public static function controller(string $controller, array $attributes = [], array $query = [])
3535
{
3636
return new ControllerReference($controller, $attributes, $query);
3737
}

‎src/Symfony/Bridge/Twig/Extension/HttpKernelRuntime.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Extension/HttpKernelRuntime.php
+4-7Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,13 @@ public function __construct(FragmentHandler $handler)
3131
/**
3232
* Renders a fragment.
3333
*
34-
* @param string|ControllerReference $uri A URI as a string or a ControllerReference instance
35-
* @param array $options An array of options
34+
* @param string|ControllerReference $uri A URI as a string or a ControllerReference instance
3635
*
3736
* @return string The fragment content
3837
*
3938
* @see FragmentHandler::render()
4039
*/
41-
public function renderFragment($uri, $options = [])
40+
public function renderFragment($uri, array $options = [])
4241
{
4342
$strategy = isset($options['strategy']) ? $options['strategy'] : 'inline';
4443
unset($options['strategy']);
@@ -49,15 +48,13 @@ public function renderFragment($uri, $options = [])
4948
/**
5049
* Renders a fragment.
5150
*
52-
* @param string $strategy A strategy name
53-
* @param string|ControllerReference $uri A URI as a string or a ControllerReference instance
54-
* @param array $options An array of options
51+
* @param string|ControllerReference $uri A URI as a string or a ControllerReference instance
5552
*
5653
* @return string The fragment content
5754
*
5855
* @see FragmentHandler::render()
5956
*/
60-
public function renderFragmentStrategy($strategy, $uri, $options = [])
57+
public function renderFragmentStrategy(string $strategy, $uri, array $options = [])
6158
{
6259
return $this->handler->render($uri, $strategy, $options);
6360
}

‎src/Symfony/Bridge/Twig/Extension/LogoutUrlExtension.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Extension/LogoutUrlExtension.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function getFunctions()
4747
*
4848
* @return string The relative logout URL
4949
*/
50-
public function getLogoutPath($key = null)
50+
public function getLogoutPath(string $key = null)
5151
{
5252
return $this->generator->getLogoutPath($key);
5353
}
@@ -59,7 +59,7 @@ public function getLogoutPath($key = null)
5959
*
6060
* @return string The absolute logout URL
6161
*/
62-
public function getLogoutUrl($key = null)
62+
public function getLogoutUrl(string $key = null)
6363
{
6464
return $this->generator->getLogoutUrl($key);
6565
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.