Completed
Push — master ( 1de9b7...830752 )
by Kristof
38:46 queued 24:09
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;
7
8
/**
9
 * Extension to render blocks of twig templates
10
 */
11
class ToolbarTwigExtension extends Twig_Extension
12
{
13
    /**
14
     * Returns a list of functions to add to the existing list.
15
     *
16
     * @return array An array of functions
0 ignored issues
show
Consider making the return type a bit more specific; maybe use \Twig_SimpleFunction[].

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...
17
     */
18
    public function getFunctions()
19
    {
20
        return array(
21
            new \Twig_SimpleFunction('block_render', array($this, 'renderBlock'), array('needs_environment' => true, 'is_safe' => array('html'))),
22
        );
23
    }
24
25
    /**
26
     * @param Twig_Environment $env
27
     * @param $template
28
     * @param $block
29
     * @param $context
30
     *
31
     * @return string
32
     */
33
    public function renderBlock(Twig_Environment $env, $template, $block, $context)
34
    {
35
        $template = $env->loadTemplate($template);
36
        $context = $env->mergeGlobals($context);
37
38
        return $template->renderBlock($block, $context);
39
    }
40
41
    /**
42
     * @return string
43
     */
44
    public function getName()
45
    {
46
        return 'toolbar_twig_extension';
47
    }
48
}
49