13
13
14
14
use Symfony \Component \Form \FormView ;
15
15
use Symfony \Component \Form \FormRenderer ;
16
+ use Twig \Extension \AbstractExtension ;
17
+ use Twig \TwigFunction ;
16
18
17
19
/**
18
20
* FormExtension extends Twig with form capabilities.
19
21
*
20
22
* @author Olivier Chauvel <olivier@generation-multiple.com>
21
23
*/
22
- class FormExtension extends \Twig_Extension
24
+ class FormExtension extends AbstractExtension
23
25
{
24
26
/**
25
27
* This property is public so that it can be accessed directly from compiled
@@ -37,11 +39,11 @@ public function __construct(FormRenderer $renderer)
37
39
/**
38
40
* {@inheritdoc}
39
41
*/
40
- public function getFunctions ()
42
+ public function getFunctions (): array
41
43
{
42
44
return array (
43
- new \ Twig_SimpleFunction ('form_javascript ' , array ($ this , 'renderJavascript ' ), array ('is_safe ' => array ('html ' ))),
44
- new \ Twig_SimpleFunction ('form_stylesheet ' , null , array ('node_class ' => 'Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode ' , 'is_safe ' => array ('html ' ))),
45
+ new TwigFunction ('form_javascript ' , array ($ this , 'renderJavascript ' ), array ('is_safe ' => array ('html ' ))),
46
+ new TwigFunction ('form_stylesheet ' , null , array ('node_class ' => 'Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode ' , 'is_safe ' => array ('html ' ))),
45
47
);
46
48
}
47
49
@@ -53,7 +55,7 @@ public function getFunctions()
53
55
*
54
56
* @return string
55
57
*/
56
- public function renderJavascript (FormView $ view , $ prototype = false )
58
+ public function renderJavascript (FormView $ view , $ prototype = false ): string
57
59
{
58
60
$ block = $ prototype ? 'javascript_prototype ' : 'javascript ' ;
59
61
@@ -63,7 +65,7 @@ public function renderJavascript(FormView $view, $prototype = false)
63
65
/**
64
66
* {@inheritdoc}
65
67
*/
66
- public function getName ()
68
+ public function getName (): string
67
69
{
68
70
return 'collot.twig.extension.form ' ;
69
71
}
0 commit comments