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 14abstract class AbstractExtension implements LastModifiedExtensionInterface 15{ 16 public function getTokenParsers() 17 { 18 return []; 19 } 20 21 public function getNodeVisitors() 22 { 23 return []; 24 } 25 26 public function getFilters() 27 { 28 return []; 29 } 30 31 public function getTests() 32 { 33 return []; 34 } 35 36 public function getFunctions() 37 { 38 return []; 39 } 40 41 public function getOperators() 42 { 43 return [[], []]; 44 } 45 46 public function getExpressionParsers(): array 47 { 48 return []; 49 } 50 51 public function getLastModified(): int 52 { 53 $filename = (new \ReflectionClass($this))->getFileName(); 54 if (!is_file($filename)) { 55 return 0; 56 } 57 58 $lastModified = filemtime($filename); 59 60 // Track modifications of the runtime class if it exists and follows the naming convention 61 if (str_ends_with($filename, 'Extension.php') && is_file($filename = substr($filename, 0, -13).'Runtime.php')) { 62 $lastModified = max($lastModified, filemtime($filename)); 63 } 64 65 return $lastModified; 66 } 67} 68