1<?php
2
3/*
4 * This file is part of Twig.
5 *
6 * (c) Fabien Potencier
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Twig\Extension;
13
14use Twig\Environment;
15use Twig\NodeVisitor\NodeVisitorInterface;
16use Twig\TokenParser\TokenParserInterface;
17use Twig\TwigFilter;
18use Twig\TwigFunction;
19use Twig\TwigTest;
20
21/**
22 * Interface implemented by extension classes.
23 *
24 * @author Fabien Potencier <fabien@symfony.com>
25 */
26interface ExtensionInterface
27{
28    /**
29     * Initializes the runtime environment.
30     *
31     * This is where you can load some file that contains filter functions for instance.
32     *
33     * @deprecated since 1.23 (to be removed in 2.0), implement \Twig_Extension_InitRuntimeInterface instead
34     */
35    public function initRuntime(Environment $environment);
36
37    /**
38     * Returns the token parser instances to add to the existing list.
39     *
40     * @return TokenParserInterface[]
41     */
42    public function getTokenParsers();
43
44    /**
45     * Returns the node visitor instances to add to the existing list.
46     *
47     * @return NodeVisitorInterface[]
48     */
49    public function getNodeVisitors();
50
51    /**
52     * Returns a list of filters to add to the existing list.
53     *
54     * @return TwigFilter[]
55     */
56    public function getFilters();
57
58    /**
59     * Returns a list of tests to add to the existing list.
60     *
61     * @return TwigTest[]
62     */
63    public function getTests();
64
65    /**
66     * Returns a list of functions to add to the existing list.
67     *
68     * @return TwigFunction[]
69     */
70    public function getFunctions();
71
72    /**
73     * Returns a list of operators to add to the existing list.
74     *
75     * @return array<array> First array of unary operators, second array of binary operators
76     */
77    public function getOperators();
78
79    /**
80     * Returns a list of global variables to add to the existing list.
81     *
82     * @return array An array of global variables
83     *
84     * @deprecated since 1.23 (to be removed in 2.0), implement \Twig_Extension_GlobalsInterface instead
85     */
86    public function getGlobals();
87
88    /**
89     * Returns the name of the extension.
90     *
91     * @return string The extension name
92     *
93     * @deprecated since 1.26 (to be removed in 2.0), not used anymore internally
94     */
95    public function getName();
96}
97
98class_alias('Twig\Extension\ExtensionInterface', 'Twig_ExtensionInterface');
99
100// Ensure that the aliased name is loaded to keep BC for classes implementing the typehint with the old aliased name.
101class_exists('Twig\Environment');
102