1<?php
2
3/*
4 * This file is part of Twig.
5 *
6 * (c) Fabien Potencier
7 * (c) Arnaud Le Blanc
8 *
9 * For the full copyright and license information, please view the LICENSE
10 * file that was distributed with this source code.
11 */
12
13use Twig\Extension\ExtensionInterface;
14
15@trigger_error('The Twig_Function_Method class is deprecated since version 1.12 and will be removed in 2.0. Use \Twig\TwigFunction instead.', E_USER_DEPRECATED);
16
17/**
18 * Represents a method template function.
19 *
20 * Use \Twig\TwigFunction instead.
21 *
22 * @author Arnaud Le Blanc <arnaud.lb@gmail.com>
23 *
24 * @deprecated since 1.12 (to be removed in 2.0)
25 */
26class Twig_Function_Method extends Twig_Function
27{
28    protected $extension;
29    protected $method;
30
31    public function __construct(ExtensionInterface $extension, $method, array $options = [])
32    {
33        $options['callable'] = [$extension, $method];
34
35        parent::__construct($options);
36
37        $this->extension = $extension;
38        $this->method = $method;
39    }
40
41    public function compile()
42    {
43        return sprintf('$this->env->getExtension(\'%s\')->%s', \get_class($this->extension), $this->method);
44    }
45}
46