These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Kunstmaan\AdminBundle\Twig; |
||
4 | |||
5 | use Twig\Environment; |
||
6 | use Twig\Extension\AbstractExtension; |
||
7 | use Twig\TwigFunction; |
||
8 | |||
9 | /** |
||
10 | * Extension to render blocks of twig templates |
||
11 | * |
||
12 | * @final since 5.4 |
||
13 | */ |
||
14 | class ToolbarTwigExtension extends AbstractExtension |
||
15 | { |
||
16 | /** |
||
17 | * Returns a list of functions to add to the existing list. |
||
18 | * |
||
19 | * @return array An array of functions |
||
0 ignored issues
–
show
|
|||
20 | */ |
||
21 | public function getFunctions() |
||
22 | { |
||
23 | return [ |
||
24 | new TwigFunction('block_render', [$this, 'renderBlock'], ['needs_environment' => true, 'is_safe' => ['html']]), |
||
25 | ]; |
||
26 | } |
||
27 | |||
28 | /** |
||
29 | * @param $template |
||
30 | * @param $block |
||
31 | * @param $context |
||
32 | * |
||
33 | * @return string |
||
34 | */ |
||
35 | public function renderBlock(Environment $env, $template, $block, $context) |
||
36 | { |
||
37 | $template = $env->load($template); |
||
38 | $context = $env->mergeGlobals($context); |
||
39 | |||
40 | return $template->renderBlock($block, $context); |
||
41 | } |
||
42 | |||
43 | /** |
||
44 | * @return string |
||
45 | */ |
||
46 | public function getName() |
||
47 | { |
||
48 | return 'toolbar_twig_extension'; |
||
49 | } |
||
50 | } |
||
51 |
This check looks for the generic type
array
as a return type and suggests a more specific type. This type is inferred from the actual code.