8000 [Templating] Added type-hints to all classes. · symfony/symfony@f437345 · GitHub
[go: up one dir, main page]

Skip to content

Commit f437345

Browse files
committed
[Templating] Added type-hints to all classes.
1 parent 8fb4741 commit f437345

13 files changed

+28
-44
lines changed

src/Symfony/Component/Templating/Helper/Helper.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,8 @@ abstract class Helper implements HelperInterface
2525

2626
/**
2727
* Sets the default charset.
28-
*
29-
* @param string $charset The charset
3028
*/
31-
public function setCharset($charset)
29+
public function setCharset(string $charset)
3230
{
3331
$this->charset = $charset;
3432
}

src/Symfony/Component/Templating/Helper/HelperInterface.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,8 @@ public function getName();
2727

2828
/**
2929
* Sets the default charset.
30-
*
31-
* @param string $charset The charset
3230
*/
33-
public function setCharset($charset);
31+
public function setCharset(string $charset);
3432

3533
/**
3634
* Gets the default charset.

src/Symfony/Component/Templating/Helper/SlotsHelper.php

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,9 @@ class SlotsHelper extends Helper
2727
* This method starts an output buffer that will be
2828
* closed when the stop() method is called.
2929
*
30-
* @param string $name The slot name
31-
*
3230
* @throws \InvalidArgumentException if a slot with the same name is already started
3331
*/
34-
public function start($name)
32+
public function start(string $name)
3533
{
3634
if (\in_array($name, $this->openSlots)) {
3735
throw new \InvalidArgumentException(sprintf('A slot named "%s" is already started.', $name));
@@ -63,24 +61,21 @@ public function stop()
6361
/**
6462
* Returns true if the slot exists.
6563
*
66-
* @param string $name The slot name
67-
*
6864
* @return bool
6965
*/
70-
public function has($name)
66+
public function has(string $name)
7167
{
7268
return isset($this->slots[$name]);
7369
}
7470

7571
/**
7672
* Gets the slot value.
7773
*
78-
* @param string $name The slot name
7974
* @param bool|string $default The default slot content
8075
*
8176
* @return string The slot content
8277
*/
83-
public function get($name, $default = false)
78+
public function get(string $name, $default = false)
8479
{
8580
return isset($this->slots[$name]) ? $this->slots[$name] : $default;
8681
}
@@ -91,7 +86,7 @@ public function get($name, $default = false)
9186
* @param string $name The slot name
9287
* @param string $content The slot content
9388
*/
94-
public function set($name, $content)
89+
public function set(string $name, string $content)
9590
{
9691
$this->slots[$name] = $content;
9792
}
@@ -104,7 +99,7 @@ public function set($name, $content)
10499
*
105100
* @return bool true if the slot is defined or if a default content has been provided, false otherwise
106101
*/
107-
public function output($name, $default = false)
102+
public function output(string $name, $default = false)
108103
{
109104
if (!isset($this->slots[$name])) {
110105
if (false !== $default) {

src/Symfony/Component/Templating/Loader/CacheLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public function load(TemplateReferenceInterface $template)
8686
*
8787
* @return bool
8888
*/
89-
public function isFresh(TemplateReferenceInterface $template, $time)
89+
public function isFresh(TemplateReferenceInterface $template, int $time)
9090
{
9191
return $this->loader->isFresh($template, $time);
9292
}

src/Symfony/Component/Templating/Loader/ChainLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function load(TemplateReferenceInterface $template)
6565
*
6666
* @return bool
6767
*/
68-
public function isFresh(TemplateReferenceInterface $template, $time)
68+
public function isFresh(TemplateReferenceInterface $template, int $time)
6969
{
7070
foreach ($this->loaders as $loader) {
7171
return $loader->isFresh($template, $time);

src/Symfony/Component/Templating/Loader/FilesystemLoader.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function load(TemplateReferenceInterface $template)
8383
*
8484
* @return bool true if the template is still fresh, false otherwise
8585
*/
86-
public function isFresh(TemplateReferenceInterface $template, $time)
86+
public function isFresh(TemplateReferenceInterface $template, int $time)
8787
{
8888
if (false === $storage = $this->load($template)) {
8989
return false;
@@ -95,11 +95,9 @@ public function isFresh(TemplateReferenceInterface $template, $time)
9595
/**
9696
* Returns true if the file is an existing absolute path.
9797
*
98-
* @param string $file A path
99-
*
10098
* @return bool true if the path exists and is absolute, false otherwise
10199
*/
102-
protected static function isAbsolutePath($file)
100+
protected static function isAbsolutePath(string $file)
103101
{
104102
if ('/' == $file[0] || '\\' == $file[0]
105103
|| (\strlen($file) > 3 && ctype_alpha($file[0])

src/Symfony/Component/Templating/Loader/LoaderInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,5 @@ public function load(TemplateReferenceInterface $template);
3636
*
3737
* @return bool
3838
*/
39-
public function isFresh(TemplateReferenceInterface $template, $time);
39+
public function isFresh(TemplateReferenceInterface $template, int $time);
4040
}

src/Symfony/Component/Templating/PhpEngine.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ public function setHelpers(array $helpers)
245245
* @param HelperInterface $helper The helper instance
246246
* @param string $alias An alias
247247
*/
248-
public function set(HelperInterface $helper, $alias = null)
248+
public function set(HelperInterface $helper, string $alias = null)
249249
{
250250
$this->helpers[$helper->getName()] = $helper;
251251
if (null !== $alias) {
@@ -262,7 +262,7 @@ public function set(HelperInterface $helper, $alias = null)
262262
*
263263
* @return bool true if the helper is defined, false otherwise
264264
*/
265-
public function has($name)
265+
public function has(string $name)
266266
{
267267
return isset($this->helpers[$name]);
268268
}
@@ -276,7 +276,7 @@ public function has($name)
276276
*
277277
* @throws \InvalidArgumentException if the helper is not defined
278278
*/
279-
public function get($name)
279+
public function get(string $name)
280280
{
281281
if (!isset($this->helpers[$name])) {
282282
throw new \InvalidArgumentException(sprintf('The helper "%s" is not defined.', $name));
@@ -290,7 +290,7 @@ public function get($name)
290290
*
291291
* @param string $template The decorator logical name
292292
*/
293-
public function extend($template)
293+
public function extend(string $template)
294294
{
295295
$this->parents[$this->current] = $template;
296296
}
@@ -303,7 +303,7 @@ public function extend($template)
303303
*
304304
* @return string The escaped value
305305
*/
306-
public function escape($value, $context = 'html')
306+
public function escape($value, string $context = 'html')
307307
{
308308
if (is_numeric($value)) {
309309
return $value;
@@ -327,7 +327,7 @@ public function escape($value, $context = 'html')
327327
*
328328
* @param string $charset The charset
329329
*/
330-
public function setCharset($charset)
330+
public function setCharset(string $charset)
331331
{
332332
if ('UTF8' === $charset = strtoupper($charset)) {
333333
$charset = 'UTF-8'; // iconv on Windows requires "UTF-8" instead of "UTF8"
@@ -355,7 +355,7 @@ public function getCharset()
355355
* @param string $context The escaper context (html, js, ...)
356356
* @param callable $escaper A PHP callable
357357
*/
358-
public function setEscaper($context, callable $escaper)
358+
public function setEscaper(string $context, callable $escaper)
359359
{
360360
$this->escapers[$context] = $escaper;
361361
self::$escaperCache[$context] = [];
@@ -370,7 +370,7 @@ public function setEscaper($context, callable $escaper)
370370
*
371371
* @throws \InvalidArgumentException
372372
*/
373-
public function getEscaper($context)
373+
public function getEscaper(string $context)
374374
{
375375
if (!isset($this->escapers[$context])) {
376376
throw new \InvalidArgumentException(sprintf('No registered escaper for context "%s".', $context));
@@ -383,7 +383,7 @@ public function getEscaper($context)
383383
* @param string $name
384384
* @param mixed $value
385385
*/
386-
public function addGlobal($name, $value)
386+
public function addGlobal(string $name, $value)
387387
{
388388
$this->globals[$name] = $value;
389389
}

src/Symfony/Component/Templating/TemplateReference.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function __toString()
3939
/**
4040
* {@inheritdoc}
4141
*/
42-
public function set($name, $value)
42+
public function set(string $name, string $value)
4343
{
4444
if (\array_key_exists($name, $this->parameters)) {
4545
$this->parameters[$name] = $value;
@@ -53,7 +53,7 @@ public function set($name, $value)
5353
/**
5454
* {@inheritdoc}
5555
*/
56-
public function get($name)
56+
public function get(string $name)
5757
{
5858
if (\array_key_exists($name, $this->parameters)) {
5959
return $this->parameters[$name];

src/Symfony/Component/Templating/TemplateReferenceInterface.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,25 +28,20 @@ public function all();
2828
/**
2929
* Sets a template parameter.
3030
*
31-
* @param string $name The parameter name
32-
* @param string $value The parameter value
33-
*
3431
* @return $this
3532
*
3633
* @throws \InvalidArgumentException if the parameter name is not supported
3734
*/
38-
public function set($name, $value);
35+
public function set(string $name, string $value);
3936

4037
/**
4138
* Gets a template parameter.
4239
*
43-
* @param string $name The parameter name
44-
*
4540
* @return string The parameter value
4641
*
4742
* @throws \InvalidArgumentException if the parameter name is not supported
4843
*/
49-
public function get($name);
44+
public function get(string $name);
5045

5146
/**
5247
* Returns the path to the template.

src/Symfony/Component/Templating/Tests/Loader/CacheLoaderTest.php

Lines changed: 1 addition & 1 deletion
return false;
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public function load(TemplateReferenceInterface $template)
8787
return false;
8888
}
8989

90-
public function isFresh(TemplateReferenceInterface $template, $time)
90+
public function isFresh(TemplateReferenceInterface $template, int $time)
9191
{
9292
9393
}

src/Symfony/Component/Templating/Tests/Loader/LoaderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function getDebugger()
4242
return $this->debugger;
4343
}
4444

45-
public function isFresh(TemplateReferenceInterface $template, $time)
45+
public function isFresh(TemplateReferenceInterface $template, int $time)
4646
{
4747
return false;
4848
}

src/Symfony/Component/Templating/Tests/PhpEngineTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ public function load(TemplateReferenceInterface $template)
219219
return false;
220220
}
221221

222-
public function isFresh(TemplateReferenceInterface $template, $time)
222+
public function isFresh(TemplateReferenceInterface $template, int $time)
223223
{
224224
return false;
225225
}

0 commit comments

Comments
 (0)
0