Completed
Push — master ( 06c1ce...67d37c )
by Jeroen
06:20
created

AdminBundle/Twig/ToolbarTwigExtension.php (1 issue)

Checks whether return doc types can be made more specific.

Documentation Informational

Upgrade to new PHP Analysis Engine

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
Consider making the return type a bit more specific; maybe use TwigFunction[].

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.

Loading history...
20
     */
21
    public function getFunctions()
22
    {
23
        return array(
24
            new TwigFunction('block_render', array($this, 'renderBlock'), array('needs_environment' => true, 'is_safe' => array('html'))),
25
        );
26
    }
27
28
    /**
29
     * @param Environment $env
30
     * @param $template
31
     * @param $block
32
     * @param $context
33
     *
34
     * @return string
35
     */
36
    public function renderBlock(Environment $env, $template, $block, $context)
37
    {
38
        $template = $env->load($template);
39
        $context = $env->mergeGlobals($context);
40
41
        return $template->renderBlock($block, $context);
42
    }
43
44
    /**
45
     * @return string
46
     */
47
    public function getName()
48
    {
49
        return 'toolbar_twig_extension';
50
    }
51
}
52