File: AbstractExtension.php

package info (click to toggle)
php-twig 3.22.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,408 kB
  • sloc: php: 24,892; makefile: 111; sh: 43
file content (67 lines) | stat: -rw-r--r-- 1,365 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php

/*
 * This file is part of Twig.
 *
 * (c) Fabien Potencier
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Twig\Extension;

abstract class AbstractExtension implements LastModifiedExtensionInterface
{
    public function getTokenParsers()
    {
        return [];
    }

    public function getNodeVisitors()
    {
        return [];
    }

    public function getFilters()
    {
        return [];
    }

    public function getTests()
    {
        return [];
    }

    public function getFunctions()
    {
        return [];
    }

    public function getOperators()
    {
        return [[], []];
    }

    public function getExpressionParsers(): array
    {
        return [];
    }

    public function getLastModified(): int
    {
        $filename = (new \ReflectionClass($this))->getFileName();
        if (!is_file($filename)) {
            return 0;
        }

        $lastModified = filemtime($filename);

        // Track modifications of the runtime class if it exists and follows the naming convention
        if (str_ends_with($filename, 'Extension.php') && is_file($filename = substr($filename, 0, -13).'Runtime.php')) {
            $lastModified = max($lastModified, filemtime($filename));
        }

        return $lastModified;
    }
}