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 Kunstmaan\AdminBundle\Helper\AdminRouteHelper; |
||
6 | use Twig\Extension\AbstractExtension; |
||
7 | use Twig\TwigFunction; |
||
8 | |||
9 | /** |
||
10 | * @final since 5.4 |
||
11 | */ |
||
12 | class AdminRouteHelperTwigExtension extends AbstractExtension |
||
13 | { |
||
14 | /** @var AdminRouteHelper */ |
||
15 | private $adminRouteHelper; |
||
16 | |||
17 | public function __construct(AdminRouteHelper $adminRouteHelper) |
||
18 | { |
||
19 | $this->adminRouteHelper = $adminRouteHelper; |
||
20 | } |
||
21 | |||
22 | /** |
||
23 | * Returns a list of functions to add to the existing list. |
||
24 | * |
||
25 | * @return array An array of functions |
||
0 ignored issues
–
show
|
|||
26 | */ |
||
27 | public function getFunctions() |
||
28 | { |
||
29 | return [ |
||
30 | new TwigFunction('is_admin_route', [$this, 'isAdminRoute']), |
||
31 | ]; |
||
32 | } |
||
33 | |||
34 | /** |
||
35 | * Lets the adminroutehelper determine wether the URI is an admin route |
||
36 | * |
||
37 | * @return bool |
||
38 | */ |
||
39 | public function isAdminRoute($URI) |
||
40 | { |
||
41 | return $this->adminRouteHelper->isAdminRoute($URI); |
||
42 | } |
||
43 | |||
44 | /** |
||
45 | * Get the Twig extension name. |
||
46 | * |
||
47 | * @return string |
||
48 | */ |
||
49 | public function getName() |
||
50 | { |
||
51 | return 'admin_route_helper_twig_extension'; |
||
52 | } |
||
53 | } |
||
54 |
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.