Файловый менеджер - Редактировать - /home/tuudkjt/globeasy/wp-includes/ID3/vendor.zip
Назад
PK �H,]�+,u� � twig/twig/composer.jsonnu ��� { "name": "twig\/twig", "type": "library", "description": "Twig, the flexible, fast, and secure template language for PHP", "keywords": [ "templating" ], "homepage": "https:\/\/twig.symfony.com", "license": "BSD-3-Clause", "minimum-stability": "dev", "authors": [ { "name": "Fabien Potencier", "email": "fabien@symfony.com", "homepage": "http:\/\/fabien.potencier.org", "role": "Lead Developer" }, { "name": "Twig Team", "role": "Contributors" }, { "name": "Armin Ronacher", "email": "armin.ronacher@active-4.com", "role": "Project Founder" } ], "require": { "php": ">=7.2.5", "symfony\/polyfill-mbstring": "^1.3", "symfony\/polyfill-ctype": "^1.8" }, "require-dev": { "symfony\/phpunit-bridge": "^5.4.9|^6.3", "psr\/container": "^1.0|^2.0" }, "autoload": { "psr-4": { "Rvx\\Twig\\": "src\/" } }, "autoload-dev": { "psr-4": { "Rvx\\Twig\\Tests\\": "tests\/" } } }PK �H,]Ձv?� � twig/twig/README.rstnu ��� Twig, the flexible, fast, and secure template language for PHP ============================================================== Twig is a template language for PHP. Twig uses a syntax similar to the Django and Jinja template languages which inspired the Twig runtime environment. Sponsors -------- .. raw:: html <a href="https://blackfire.io/docs/introduction?utm_source=twig&utm_medium=github_readme&utm_campaign=logo"> <img src="https://static.blackfire.io/assets/intemporals/logo/png/blackfire-io_secondary_horizontal_transparent.png?1" width="255px" alt="Blackfire.io"> </a> More Information ---------------- Read the `documentation`_ for more information. .. _documentation: https://twig.symfony.com/documentation PK �H,]�W W twig/twig/CHANGELOGnu ��� # 3.7.1 (2023-08-28) * Fix some phpdocs # 3.7.0 (2023-07-26) * Add support for the ...spread operator on arrays and hashes # 3.6.1 (2023-06-08) * Suppress some native return type deprecation messages # 3.6.0 (2023-05-03) * Allow psr/container 2.0 * Add the new PHP 8.0 IntlDateFormatter::RELATIVE_* constants for date formatting * Make the Lexer initialize itself lazily # 3.5.1 (2023-02-08) * Arrow functions passed to the "reduce" filter now accept the current key as a third argument * Restores the leniency of the matches twig comparison * Fix error messages in sandboxed mode for "has some" and "has every" # 3.5.0 (2022-12-27) * Make Twig\ExpressionParser non-internal * Add "has some" and "has every" operators * Add Compile::reset() * Throw a better runtime error when the "matches" regexp is not valid * Add "twig *_names" intl functions * Fix optimizing closures callbacks * Add a better exception when getting an undefined constant via `constant` * Fix `if` nodes when outside of a block and with an empty body # 3.4.3 (2022-09-28) * Fix a security issue on filesystem loader (possibility to load a template outside a configured directory) # 3.4.2 (2022-08-12) * Allow inherited magic method to still run with calling class * Fix CallExpression::reflectCallable() throwing TypeError * Fix typo in naming (currency_code) # 3.4.1 (2022-05-17) * Fix optimizing non-public named closures # 3.4.0 (2022-05-22) * Add support for named closures # 3.3.10 (2022-04-06) * Enable bytecode invalidation when auto_reload is enabled # 3.3.9 (2022-03-25) * Fix custom escapers when using multiple Twig environments * Add support for "constant('class', object)" * Do not reuse internally generated variable names during parsing # 3.3.8 (2022-02-04) * Fix a security issue when in a sandbox: the `sort` filter must require a Closure for the `arrow` parameter * Fix deprecation notice on `round` * Fix call to deprecated `convertToHtml` method # 3.3.7 (2022-01-03) * Allow more null support when Twig expects a string (for better 8.1 support) * Only use Commonmark extensions if markdown enabled # 3.3.6 (2022-01-03) * Only use Commonmark extensions if markdown enabled # 3.3.5 (2022-01-03) * Allow CommonMark extensions to easily be added * Allow null when Twig expects a string (for better 8.1 support) * Make some performance optimizations * Allow Symfony translation contract v3+ # 3.3.4 (2021-11-25) * Bump minimum supported Symfony component versions * Fix a deprecated message # 3.3.3 (2021-09-17) * Allow Symfony 6 * Improve compatibility with PHP 8.1 * Explicitly specify the encoding for mb_ord in JS escaper # 3.3.2 (2021-05-16) * Revert "Throw a proper exception when a template name is an absolute path (as it has never been supported)" # 3.3.1 (2021-05-12) * Fix PHP 8.1 compatibility * Throw a proper exception when a template name is an absolute path (as it has never been supported) # 3.3.0 (2021-02-08) * Fix macro calls in a "cache" tag * Add the slug filter * Allow extra bundle to be compatible with Twig 2 # 3.2.1 (2021-01-05) * Fix extra bundle compat with older versions of Symfony # 3.2.0 (2021-01-05) * Add the Cache extension in the "extra" repositories: "cache" tag * Add "registerUndefinedTokenParserCallback" * Mark built-in node visitors as @internal * Fix "odd" not working for negative numbers # 3.1.1 (2020-10-27) * Fix "include(template_from_string())" # 3.1.0 (2020-10-21) * Fix sandbox support when using "include(template_from_string())" * Make round brackets optional for one argument tests like "same as" or "divisible by" * Add support for ES2015 style object initialisation shortcut { a } is the same as { 'a': a } # 3.0.5 (2020-08-05) * Fix twig_compare w.r.t. whitespace trimming * Fix sandbox not disabled if syntax error occurs within {% sandbox %} tag * Fix a regression when not using a space before an operator * Restrict callables to closures in filters * Allow trailing commas in argument lists (in calls as well as definitions) # 3.0.4 (2020-07-05) * Fix comparison operators * Fix options not taken into account when using "Michelf\MarkdownExtra" * Fix "Twig\Extra\Intl\IntlExtension::getCountryName()" to accept "null" as a first argument * Throw exception in case non-Traversable data is passed to "filter" * Fix context optimization on PHP 7.4 * Fix PHP 8 compatibility * Fix ambiguous syntax parsing # 3.0.3 (2020-02-11) * Add a check to ensure that iconv() is defined # 3.0.2 (2020-02-11) * Avoid exceptions when an intl resource is not found * Fix implementation of case-insensitivity for method names # 3.0.1 (2019-12-28) * fixed Symfony 5.0 support for the HTML extra extension # 3.0.0 (2019-11-15) * fixed number formatter in Intl extra extension when using a formatter prototype # 3.0.0-BETA1 (2019-11-11) * removed the "if" condition support on the "for" tag * made the in, <, >, <=, >=, ==, and != operators more strict when comparing strings and integers/floats * removed the "filter" tag * added type hints everywhere * changed Environment::resolveTemplate() to always return a TemplateWrapper instance * removed Template::__toString() * removed Parser::isReservedMacroName() * removed SanboxedPrintNode * removed Node::setTemplateName() * made classes maked as "@final" final * removed InitRuntimeInterface, ExistsLoaderInterface, and SourceContextLoaderInterface * removed the "spaceless" tag * removed Twig\Environment::getBaseTemplateClass() and Twig\Environment::setBaseTemplateClass() * removed the "base_template_class" option on Twig\Environment * bumped minimum PHP version to 7.2 * removed PSR-0 classes PK �H,]��Z� � twig/twig/LICENSEnu ��� Copyright (c) 2009-present by the Twig Team. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of Twig nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. PK �H,]+����` �` twig/twig/src/Environment.phpnu ��� <?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 Rvx\Twig; use Rvx\Twig\Cache\CacheInterface; use Rvx\Twig\Cache\FilesystemCache; use Rvx\Twig\Cache\NullCache; use Rvx\Twig\Error\Error; use Rvx\Twig\Error\LoaderError; use Rvx\Twig\Error\RuntimeError; use Rvx\Twig\Error\SyntaxError; use Rvx\Twig\Extension\CoreExtension; use Rvx\Twig\Extension\EscaperExtension; use Rvx\Twig\Extension\ExtensionInterface; use Rvx\Twig\Extension\OptimizerExtension; use Rvx\Twig\Loader\ArrayLoader; use Rvx\Twig\Loader\ChainLoader; use Rvx\Twig\Loader\LoaderInterface; use Rvx\Twig\Node\Expression\Binary\AbstractBinary; use Rvx\Twig\Node\Expression\Unary\AbstractUnary; use Rvx\Twig\Node\ModuleNode; use Rvx\Twig\Node\Node; use Rvx\Twig\NodeVisitor\NodeVisitorInterface; use Rvx\Twig\RuntimeLoader\RuntimeLoaderInterface; use Rvx\Twig\TokenParser\TokenParserInterface; /** * Stores the Twig configuration and renders templates. * * @author Fabien Potencier <fabien@symfony.com> */ class Environment { public const VERSION = '3.7.1'; public const VERSION_ID = 30701; public const MAJOR_VERSION = 3; public const MINOR_VERSION = 7; public const RELEASE_VERSION = 1; public const EXTRA_VERSION = ''; private $charset; private $loader; private $debug; private $autoReload; private $cache; private $lexer; private $parser; private $compiler; /** @var array<string, mixed> */ private $globals = []; private $resolvedGlobals; private $loadedTemplates; private $strictVariables; private $templateClassPrefix = '\\Rvx\\__TwigTemplate_'; private $originalCache; private $extensionSet; private $runtimeLoaders = []; private $runtimes = []; private $optionsHash; /** * Constructor. * * Available options: * * * debug: When set to true, it automatically set "auto_reload" to true as * well (default to false). * * * charset: The charset used by the templates (default to UTF-8). * * * cache: An absolute path where to store the compiled templates, * a \Twig\Cache\CacheInterface implementation, * or false to disable compilation cache (default). * * * auto_reload: Whether to reload the template if the original source changed. * If you don't provide the auto_reload option, it will be * determined automatically based on the debug value. * * * strict_variables: Whether to ignore invalid variables in templates * (default to false). * * * autoescape: Whether to enable auto-escaping (default to html): * * false: disable auto-escaping * * html, js: set the autoescaping to one of the supported strategies * * name: set the autoescaping strategy based on the template name extension * * PHP callback: a PHP callback that returns an escaping strategy based on the template "name" * * * optimizations: A flag that indicates which optimizations to apply * (default to -1 which means that all optimizations are enabled; * set it to 0 to disable). */ public function __construct(LoaderInterface $loader, $options = []) { $this->setLoader($loader); $options = \array_merge(['debug' => \false, 'charset' => 'UTF-8', 'strict_variables' => \false, 'autoescape' => 'html', 'cache' => \false, 'auto_reload' => null, 'optimizations' => -1], $options); $this->debug = (bool) $options['debug']; $this->setCharset($options['charset'] ?? 'UTF-8'); $this->autoReload = null === $options['auto_reload'] ? $this->debug : (bool) $options['auto_reload']; $this->strictVariables = (bool) $options['strict_variables']; $this->setCache($options['cache']); $this->extensionSet = new ExtensionSet(); $this->addExtension(new CoreExtension()); $this->addExtension(new EscaperExtension($options['autoescape'])); $this->addExtension(new OptimizerExtension($options['optimizations'])); } /** * Enables debugging mode. */ public function enableDebug() { $this->debug = \true; $this->updateOptionsHash(); } /** * Disables debugging mode. */ public function disableDebug() { $this->debug = \false; $this->updateOptionsHash(); } /** * Checks if debug mode is enabled. * * @return bool true if debug mode is enabled, false otherwise */ public function isDebug() { return $this->debug; } /** * Enables the auto_reload option. */ public function enableAutoReload() { $this->autoReload = \true; } /** * Disables the auto_reload option. */ public function disableAutoReload() { $this->autoReload = \false; } /** * Checks if the auto_reload option is enabled. * * @return bool true if auto_reload is enabled, false otherwise */ public function isAutoReload() { return $this->autoReload; } /** * Enables the strict_variables option. */ public function enableStrictVariables() { $this->strictVariables = \true; $this->updateOptionsHash(); } /** * Disables the strict_variables option. */ public function disableStrictVariables() { $this->strictVariables = \false; $this->updateOptionsHash(); } /** * Checks if the strict_variables option is enabled. * * @return bool true if strict_variables is enabled, false otherwise */ public function isStrictVariables() { return $this->strictVariables; } /** * Gets the current cache implementation. * * @param bool $original Whether to return the original cache option or the real cache instance * * @return CacheInterface|string|false A Twig\Cache\CacheInterface implementation, * an absolute path to the compiled templates, * or false to disable cache */ public function getCache($original = \true) { return $original ? $this->originalCache : $this->cache; } /** * Sets the current cache implementation. * * @param CacheInterface|string|false $cache A Twig\Cache\CacheInterface implementation, * an absolute path to the compiled templates, * or false to disable cache */ public function setCache($cache) { if (\is_string($cache)) { $this->originalCache = $cache; $this->cache = new FilesystemCache($cache, $this->autoReload ? FilesystemCache::FORCE_BYTECODE_INVALIDATION : 0); } elseif (\false === $cache) { $this->originalCache = $cache; $this->cache = new NullCache(); } elseif ($cache instanceof CacheInterface) { $this->originalCache = $this->cache = $cache; } else { throw new \LogicException('Cache can only be a string, false, or a \\Twig\\Cache\\CacheInterface implementation.'); } } /** * Gets the template class associated with the given string. * * The generated template class is based on the following parameters: * * * The cache key for the given template; * * The currently enabled extensions; * * Whether the Twig C extension is available or not; * * PHP version; * * Twig version; * * Options with what environment was created. * * @param string $name The name for which to calculate the template class name * @param int|null $index The index if it is an embedded template * * @internal */ public function getTemplateClass(string $name, int $index = null) : string { $key = $this->getLoader()->getCacheKey($name) . $this->optionsHash; return $this->templateClassPrefix . \hash(\PHP_VERSION_ID < 80100 ? 'sha256' : 'xxh128', $key) . (null === $index ? '' : '___' . $index); } /** * Renders a template. * * @param string|TemplateWrapper $name The template name * * @throws LoaderError When the template cannot be found * @throws SyntaxError When an error occurred during compilation * @throws RuntimeError When an error occurred during rendering */ public function render($name, array $context = []) : string { return $this->load($name)->render($context); } /** * Displays a template. * * @param string|TemplateWrapper $name The template name * * @throws LoaderError When the template cannot be found * @throws SyntaxError When an error occurred during compilation * @throws RuntimeError When an error occurred during rendering */ public function display($name, array $context = []) : void { $this->load($name)->display($context); } /** * Loads a template. * * @param string|TemplateWrapper $name The template name * * @throws LoaderError When the template cannot be found * @throws RuntimeError When a previously generated cache is corrupted * @throws SyntaxError When an error occurred during compilation */ public function load($name) : TemplateWrapper { if ($name instanceof TemplateWrapper) { return $name; } return new TemplateWrapper($this, $this->loadTemplate($this->getTemplateClass($name), $name)); } /** * Loads a template internal representation. * * This method is for internal use only and should never be called * directly. * * @param string $name The template name * @param int $index The index if it is an embedded template * * @throws LoaderError When the template cannot be found * @throws RuntimeError When a previously generated cache is corrupted * @throws SyntaxError When an error occurred during compilation * * @internal */ public function loadTemplate(string $cls, string $name, int $index = null) : Template { $mainCls = $cls; if (null !== $index) { $cls .= '___' . $index; } if (isset($this->loadedTemplates[$cls])) { return $this->loadedTemplates[$cls]; } if (!\class_exists($cls, \false)) { $key = $this->cache->generateKey($name, $mainCls); if (!$this->isAutoReload() || $this->isTemplateFresh($name, $this->cache->getTimestamp($key))) { $this->cache->load($key); } $source = null; if (!\class_exists($cls, \false)) { $source = $this->getLoader()->getSourceContext($name); $content = $this->compileSource($source); $this->cache->write($key, $content); $this->cache->load($key); if (!\class_exists($mainCls, \false)) { /* Last line of defense if either $this->bcWriteCacheFile was used, * $this->cache is implemented as a no-op or we have a race condition * where the cache was cleared between the above calls to write to and load from * the cache. */ eval('?>' . $content); } if (!\class_exists($cls, \false)) { throw new RuntimeError(\sprintf('Failed to load Twig template "%s", index "%s": cache might be corrupted.', $name, $index), -1, $source); } } } $this->extensionSet->initRuntime(); return $this->loadedTemplates[$cls] = new $cls($this); } /** * Creates a template from source. * * This method should not be used as a generic way to load templates. * * @param string $template The template source * @param string $name An optional name of the template to be used in error messages * * @throws LoaderError When the template cannot be found * @throws SyntaxError When an error occurred during compilation */ public function createTemplate(string $template, string $name = null) : TemplateWrapper { $hash = \hash(\PHP_VERSION_ID < 80100 ? 'sha256' : 'xxh128', $template, \false); if (null !== $name) { $name = \sprintf('%s (string template %s)', $name, $hash); } else { $name = \sprintf('__string_template__%s', $hash); } $loader = new ChainLoader([new ArrayLoader([$name => $template]), $current = $this->getLoader()]); $this->setLoader($loader); try { return new TemplateWrapper($this, $this->loadTemplate($this->getTemplateClass($name), $name)); } finally { $this->setLoader($current); } } /** * Returns true if the template is still fresh. * * Besides checking the loader for freshness information, * this method also checks if the enabled extensions have * not changed. * * @param int $time The last modification time of the cached template */ public function isTemplateFresh(string $name, int $time) : bool { return $this->extensionSet->getLastModified() <= $time && $this->getLoader()->isFresh($name, $time); } /** * Tries to load a template consecutively from an array. * * Similar to load() but it also accepts instances of \Twig\Template and * \Twig\TemplateWrapper, and an array of templates where each is tried to be loaded. * * @param string|TemplateWrapper|array $names A template or an array of templates to try consecutively * * @throws LoaderError When none of the templates can be found * @throws SyntaxError When an error occurred during compilation */ public function resolveTemplate($names) : TemplateWrapper { if (!\is_array($names)) { return $this->load($names); } $count = \count($names); foreach ($names as $name) { if ($name instanceof Template) { return $name; } if ($name instanceof TemplateWrapper) { return $name; } if (1 !== $count && !$this->getLoader()->exists($name)) { continue; } return $this->load($name); } throw new LoaderError(\sprintf('Unable to find one of the following templates: "%s".', \implode('", "', $names))); } public function setLexer(Lexer $lexer) { $this->lexer = $lexer; } /** * @throws SyntaxError When the code is syntactically wrong */ public function tokenize(Source $source) : TokenStream { if (null === $this->lexer) { $this->lexer = new Lexer($this); } return $this->lexer->tokenize($source); } public function setParser(Parser $parser) { $this->parser = $parser; } /** * Converts a token stream to a node tree. * * @throws SyntaxError When the token stream is syntactically or semantically wrong */ public function parse(TokenStream $stream) : ModuleNode { if (null === $this->parser) { $this->parser = new Parser($this); } return $this->parser->parse($stream); } public function setCompiler(Compiler $compiler) { $this->compiler = $compiler; } /** * Compiles a node and returns the PHP code. */ public function compile(Node $node) : string { if (null === $this->compiler) { $this->compiler = new Compiler($this); } return $this->compiler->compile($node)->getSource(); } /** * Compiles a template source code. * * @throws SyntaxError When there was an error during tokenizing, parsing or compiling */ public function compileSource(Source $source) : string { try { return $this->compile($this->parse($this->tokenize($source))); } catch (Error $e) { $e->setSourceContext($source); throw $e; } catch (\Exception $e) { throw new SyntaxError(\sprintf('An exception has been thrown during the compilation of a template ("%s").', $e->getMessage()), -1, $source, $e); } } public function setLoader(LoaderInterface $loader) { $this->loader = $loader; } public function getLoader() : LoaderInterface { return $this->loader; } public function setCharset(string $charset) { if ('UTF8' === ($charset = null === $charset ? null : \strtoupper($charset))) { // iconv on Windows requires "UTF-8" instead of "UTF8" $charset = 'UTF-8'; } $this->charset = $charset; } public function getCharset() : string { return $this->charset; } public function hasExtension(string $class) : bool { return $this->extensionSet->hasExtension($class); } public function addRuntimeLoader(RuntimeLoaderInterface $loader) { $this->runtimeLoaders[] = $loader; } /** * @template TExtension of ExtensionInterface * * @param class-string<TExtension> $class * * @return TExtension */ public function getExtension(string $class) : ExtensionInterface { return $this->extensionSet->getExtension($class); } /** * Returns the runtime implementation of a Twig element (filter/function/tag/test). * * @template TRuntime of object * * @param class-string<TRuntime> $class A runtime class name * * @return TRuntime The runtime implementation * * @throws RuntimeError When the template cannot be found */ public function getRuntime(string $class) { if (isset($this->runtimes[$class])) { return $this->runtimes[$class]; } foreach ($this->runtimeLoaders as $loader) { if (null !== ($runtime = $loader->load($class))) { return $this->runtimes[$class] = $runtime; } } throw new RuntimeError(\sprintf('Unable to load the "%s" runtime.', $class)); } public function addExtension(ExtensionInterface $extension) { $this->extensionSet->addExtension($extension); $this->updateOptionsHash(); } /** * @param ExtensionInterface[] $extensions An array of extensions */ public function setExtensions(array $extensions) { $this->extensionSet->setExtensions($extensions); $this->updateOptionsHash(); } /** * @return ExtensionInterface[] An array of extensions (keys are for internal usage only and should not be relied on) */ public function getExtensions() : array { return $this->extensionSet->getExtensions(); } public function addTokenParser(TokenParserInterface $parser) { $this->extensionSet->addTokenParser($parser); } /** * @return TokenParserInterface[] * * @internal */ public function getTokenParsers() : array { return $this->extensionSet->getTokenParsers(); } /** * @internal */ public function getTokenParser(string $name) : ?TokenParserInterface { return $this->extensionSet->getTokenParser($name); } public function registerUndefinedTokenParserCallback(callable $callable) : void { $this->extensionSet->registerUndefinedTokenParserCallback($callable); } public function addNodeVisitor(NodeVisitorInterface $visitor) { $this->extensionSet->addNodeVisitor($visitor); } /** * @return NodeVisitorInterface[] * * @internal */ public function getNodeVisitors() : array { return $this->extensionSet->getNodeVisitors(); } public function addFilter(TwigFilter $filter) { $this->extensionSet->addFilter($filter); } /** * @internal */ public function getFilter(string $name) : ?TwigFilter { return $this->extensionSet->getFilter($name); } public function registerUndefinedFilterCallback(callable $callable) : void { $this->extensionSet->registerUndefinedFilterCallback($callable); } /** * Gets the registered Filters. * * Be warned that this method cannot return filters defined with registerUndefinedFilterCallback. * * @return TwigFilter[] * * @see registerUndefinedFilterCallback * * @internal */ public function getFilters() : array { return $this->extensionSet->getFilters(); } public function addTest(TwigTest $test) { $this->extensionSet->addTest($test); } /** * @return TwigTest[] * * @internal */ public function getTests() : array { return $this->extensionSet->getTests(); } /** * @internal */ public function getTest(string $name) : ?TwigTest { return $this->extensionSet->getTest($name); } public function addFunction(TwigFunction $function) { $this->extensionSet->addFunction($function); } /** * @internal */ public function getFunction(string $name) : ?TwigFunction { return $this->extensionSet->getFunction($name); } public function registerUndefinedFunctionCallback(callable $callable) : void { $this->extensionSet->registerUndefinedFunctionCallback($callable); } /** * Gets registered functions. * * Be warned that this method cannot return functions defined with registerUndefinedFunctionCallback. * * @return TwigFunction[] * * @see registerUndefinedFunctionCallback * * @internal */ public function getFunctions() : array { return $this->extensionSet->getFunctions(); } /** * Registers a Global. * * New globals can be added before compiling or rendering a template; * but after, you can only update existing globals. * * @param mixed $value The global value */ public function addGlobal(string $name, $value) { if ($this->extensionSet->isInitialized() && !\array_key_exists($name, $this->getGlobals())) { throw new \LogicException(\sprintf('Unable to add global "%s" as the runtime or the extensions have already been initialized.', $name)); } if (null !== $this->resolvedGlobals) { $this->resolvedGlobals[$name] = $value; } else { $this->globals[$name] = $value; } } /** * @internal * * @return array<string, mixed> */ public function getGlobals() : array { if ($this->extensionSet->isInitialized()) { if (null === $this->resolvedGlobals) { $this->resolvedGlobals = \array_merge($this->extensionSet->getGlobals(), $this->globals); } return $this->resolvedGlobals; } return \array_merge($this->extensionSet->getGlobals(), $this->globals); } public function mergeGlobals(array $context) : array { // we don't use array_merge as the context being generally // bigger than globals, this code is faster. foreach ($this->getGlobals() as $key => $value) { if (!\array_key_exists($key, $context)) { $context[$key] = $value; } } return $context; } /** * @internal * * @return array<string, array{precedence: int, class: class-string<AbstractUnary>}> */ public function getUnaryOperators() : array { return $this->extensionSet->getUnaryOperators(); } /** * @internal * * @return array<string, array{precedence: int, class: class-string<AbstractBinary>, associativity: ExpressionParser::OPERATOR_*}> */ public function getBinaryOperators() : array { return $this->extensionSet->getBinaryOperators(); } private function updateOptionsHash() : void { $this->optionsHash = \implode(':', [$this->extensionSet->getSignature(), \PHP_MAJOR_VERSION, \PHP_MINOR_VERSION, self::VERSION, (int) $this->debug, (int) $this->strictVariables]); } } PK �H,]X�� � ! twig/twig/src/TemplateWrapper.phpnu ��� <?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 Rvx\Twig; /** * Exposes a template to userland. * * @author Fabien Potencier <fabien@symfony.com> */ final class TemplateWrapper { private $env; private $template; /** * This method is for internal use only and should never be called * directly (use \\Rvx\\Twig\\Environment::load() instead). * * @internal */ public function __construct(Environment $env, Template $template) { $this->env = $env; $this->template = $template; } public function render(array $context = []) : string { // using func_get_args() allows to not expose the blocks argument // as it should only be used by internal code return $this->template->render($context, \func_get_args()[1] ?? []); } public function display(array $context = []) { // using func_get_args() allows to not expose the blocks argument // as it should only be used by internal code $this->template->display($context, \func_get_args()[1] ?? []); } public function hasBlock(string $name, array $context = []) : bool { return $this->template->hasBlock($name, $context); } /** * @return string[] An array of defined template block names */ public function getBlockNames(array $context = []) : array { return $this->template->getBlockNames($context); } public function renderBlock(string $name, array $context = []) : string { $context = $this->env->mergeGlobals($context); $level = \ob_get_level(); if ($this->env->isDebug()) { \ob_start(); } else { \ob_start(function () { return ''; }); } try { $this->template->displayBlock($name, $context); } catch (\Throwable $e) { while (\ob_get_level() > $level) { \ob_end_clean(); } throw $e; } return \ob_get_clean(); } public function displayBlock(string $name, array $context = []) { $this->template->displayBlock($name, $this->env->mergeGlobals($context)); } public function getSourceContext() : Source { return $this->template->getSourceContext(); } public function getTemplateName() : string { return $this->template->getTemplateName(); } /** * @internal * * @return Template */ public function unwrap() { return $this->template; } } PK �H,]�!Q� twig/twig/src/TwigFunction.phpnu ��� <?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 Rvx\Twig; use Rvx\Twig\Node\Expression\FunctionExpression; use Rvx\Twig\Node\Node; /** * Represents a template function. * * @author Fabien Potencier <fabien@symfony.com> * * @see https://twig.symfony.com/doc/templates.html#functions */ final class TwigFunction { private $name; private $callable; private $options; private $arguments = []; /** * @param callable|array{class-string, string}|null $callable A callable implementing the function. If null, you need to overwrite the "node_class" option to customize compilation. */ public function __construct(string $name, $callable = null, array $options = []) { $this->name = $name; $this->callable = $callable; $this->options = \array_merge(['needs_environment' => \false, 'needs_context' => \false, 'is_variadic' => \false, 'is_safe' => null, 'is_safe_callback' => null, 'node_class' => FunctionExpression::class, 'deprecated' => \false, 'alternative' => null], $options); } public function getName() : string { return $this->name; } /** * Returns the callable to execute for this function. * * @return callable|array{class-string, string}|null */ public function getCallable() { return $this->callable; } public function getNodeClass() : string { return $this->options['node_class']; } public function setArguments(array $arguments) : void { $this->arguments = $arguments; } public function getArguments() : array { return $this->arguments; } public function needsEnvironment() : bool { return $this->options['needs_environment']; } public function needsContext() : bool { return $this->options['needs_context']; } public function getSafe(Node $functionArgs) : ?array { if (null !== $this->options['is_safe']) { return $this->options['is_safe']; } if (null !== $this->options['is_safe_callback']) { return $this->options['is_safe_callback']($functionArgs); } return []; } public function isVariadic() : bool { return (bool) $this->options['is_variadic']; } public function isDeprecated() : bool { return (bool) $this->options['deprecated']; } public function getDeprecatedVersion() : string { return \is_bool($this->options['deprecated']) ? '' : $this->options['deprecated']; } public function getAlternative() : ?string { return $this->options['alternative']; } } PK �H,]�� �N N twig/twig/src/TokenStream.phpnu ��� <?php /* * This file is part of Twig. * * (c) Fabien Potencier * (c) Armin Ronacher * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Rvx\Twig; use Rvx\Twig\Error\SyntaxError; /** * Represents a token stream. * * @author Fabien Potencier <fabien@symfony.com> */ final class TokenStream { private $tokens; private $current = 0; private $source; public function __construct(array $tokens, Source $source = null) { $this->tokens = $tokens; $this->source = $source ?: new Source('', ''); } public function __toString() { return \implode("\n", $this->tokens); } public function injectTokens(array $tokens) { $this->tokens = \array_merge(\array_slice($this->tokens, 0, $this->current), $tokens, \array_slice($this->tokens, $this->current)); } /** * Sets the pointer to the next token and returns the old one. */ public function next() : Token { if (!isset($this->tokens[++$this->current])) { throw new SyntaxError('Unexpected end of template.', $this->tokens[$this->current - 1]->getLine(), $this->source); } return $this->tokens[$this->current - 1]; } /** * Tests a token, sets the pointer to the next one and returns it or throws a syntax error. * * @return Token|null The next token if the condition is true, null otherwise */ public function nextIf($primary, $secondary = null) { if ($this->tokens[$this->current]->test($primary, $secondary)) { return $this->next(); } } /** * Tests a token and returns it or throws a syntax error. */ public function expect($type, $value = null, string $message = null) : Token { $token = $this->tokens[$this->current]; if (!$token->test($type, $value)) { $line = $token->getLine(); throw new SyntaxError(\sprintf('%sUnexpected token "%s"%s ("%s" expected%s).', $message ? $message . '. ' : '', Token::typeToEnglish($token->getType()), $token->getValue() ? \sprintf(' of value "%s"', $token->getValue()) : '', Token::typeToEnglish($type), $value ? \sprintf(' with value "%s"', $value) : ''), $line, $this->source); } $this->next(); return $token; } /** * Looks at the next token. */ public function look(int $number = 1) : Token { if (!isset($this->tokens[$this->current + $number])) { throw new SyntaxError('Unexpected end of template.', $this->tokens[$this->current + $number - 1]->getLine(), $this->source); } return $this->tokens[$this->current + $number]; } /** * Tests the current token. */ public function test($primary, $secondary = null) : bool { return $this->tokens[$this->current]->test($primary, $secondary); } /** * Checks if end of stream was reached. */ public function isEOF() : bool { return -1 === $this->tokens[$this->current]->getType(); } public function getCurrent() : Token { return $this->tokens[$this->current]; } /** * Gets the source associated with this stream. * * @internal */ public function getSourceContext() : Source { return $this->source; } } PK �H,]� ˢ� � twig/twig/src/Compiler.phpnu ��� <?php /* * This file is part of Twig. * * (c) Fabien Potencier * (c) Armin Ronacher * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Rvx\Twig; use Rvx\Twig\Node\Node; /** * @author Fabien Potencier <fabien@symfony.com> */ class Compiler { private $lastLine; private $source; private $indentation; private $env; private $debugInfo = []; private $sourceOffset; private $sourceLine; private $varNameSalt = 0; public function __construct(Environment $env) { $this->env = $env; } public function getEnvironment() : Environment { return $this->env; } public function getSource() : string { return $this->source; } /** * @return $this */ public function reset(int $indentation = 0) { $this->lastLine = null; $this->source = ''; $this->debugInfo = []; $this->sourceOffset = 0; // source code starts at 1 (as we then increment it when we encounter new lines) $this->sourceLine = 1; $this->indentation = $indentation; $this->varNameSalt = 0; return $this; } /** * @return $this */ public function compile(Node $node, int $indentation = 0) { $this->reset($indentation); $node->compile($this); return $this; } /** * @return $this */ public function subcompile(Node $node, bool $raw = \true) { if (\false === $raw) { $this->source .= \str_repeat(' ', $this->indentation * 4); } $node->compile($this); return $this; } /** * Adds a raw string to the compiled code. * * @return $this */ public function raw(string $string) { $this->source .= $string; return $this; } /** * Writes a string to the compiled code by adding indentation. * * @return $this */ public function write(...$strings) { foreach ($strings as $string) { $this->source .= \str_repeat(' ', $this->indentation * 4) . $string; } return $this; } /** * Adds a quoted string to the compiled code. * * @return $this */ public function string(string $value) { $this->source .= \sprintf('"%s"', \addcslashes($value, "\x00\t\"\$\\")); return $this; } /** * Returns a PHP representation of a given value. * * @return $this */ public function repr($value) { if (\is_int($value) || \is_float($value)) { if (\false !== ($locale = \setlocale(\LC_NUMERIC, '0'))) { \setlocale(\LC_NUMERIC, 'C'); } $this->raw(\var_export($value, \true)); if (\false !== $locale) { \setlocale(\LC_NUMERIC, $locale); } } elseif (null === $value) { $this->raw('null'); } elseif (\is_bool($value)) { $this->raw($value ? 'true' : 'false'); } elseif (\is_array($value)) { $this->raw('array('); $first = \true; foreach ($value as $key => $v) { if (!$first) { $this->raw(', '); } $first = \false; $this->repr($key); $this->raw(' => '); $this->repr($v); } $this->raw(')'); } else { $this->string($value); } return $this; } /** * @return $this */ public function addDebugInfo(Node $node) { if ($node->getTemplateLine() != $this->lastLine) { $this->write(\sprintf("// line %d\n", $node->getTemplateLine())); $this->sourceLine += \substr_count($this->source, "\n", $this->sourceOffset); $this->sourceOffset = \strlen($this->source); $this->debugInfo[$this->sourceLine] = $node->getTemplateLine(); $this->lastLine = $node->getTemplateLine(); } return $this; } public function getDebugInfo() : array { \ksort($this->debugInfo); return $this->debugInfo; } /** * @return $this */ public function indent(int $step = 1) { $this->indentation += $step; return $this; } /** * @return $this * * @throws \LogicException When trying to outdent too much so the indentation would become negative */ public function outdent(int $step = 1) { // can't outdent by more steps than the current indentation level if ($this->indentation < $step) { throw new \LogicException('Unable to call outdent() as the indentation would become negative.'); } $this->indentation -= $step; return $this; } public function getVarName() : string { return \sprintf('__internal_compile_%d', $this->varNameSalt++); } } PK �H,]����# # $ twig/twig/src/Loader/ChainLoader.phpnu ��� <?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 Rvx\Twig\Loader; use Rvx\Twig\Error\LoaderError; use Rvx\Twig\Source; /** * Loads templates from other loaders. * * @author Fabien Potencier <fabien@symfony.com> */ final class ChainLoader implements LoaderInterface { private $hasSourceCache = []; private $loaders = []; /** * @param LoaderInterface[] $loaders */ public function __construct(array $loaders = []) { foreach ($loaders as $loader) { $this->addLoader($loader); } } public function addLoader(LoaderInterface $loader) : void { $this->loaders[] = $loader; $this->hasSourceCache = []; } /** * @return LoaderInterface[] */ public function getLoaders() : array { return $this->loaders; } public function getSourceContext(string $name) : Source { $exceptions = []; foreach ($this->loaders as $loader) { if (!$loader->exists($name)) { continue; } try { return $loader->getSourceContext($name); } catch (LoaderError $e) { $exceptions[] = $e->getMessage(); } } throw new LoaderError(\sprintf('Template "%s" is not defined%s.', $name, $exceptions ? ' (' . \implode(', ', $exceptions) . ')' : '')); } public function exists(string $name) : bool { if (isset($this->hasSourceCache[$name])) { return $this->hasSourceCache[$name]; } foreach ($this->loaders as $loader) { if ($loader->exists($name)) { return $this->hasSourceCache[$name] = \true; } } return $this->hasSourceCache[$name] = \false; } public function getCacheKey(string $name) : string { $exceptions = []; foreach ($this->loaders as $loader) { if (!$loader->exists($name)) { continue; } try { return $loader->getCacheKey($name); } catch (LoaderError $e) { $exceptions[] = \get_class($loader) . ': ' . $e->getMessage(); } } throw new LoaderError(\sprintf('Template "%s" is not defined%s.', $name, $exceptions ? ' (' . \implode(', ', $exceptions) . ')' : '')); } public function isFresh(string $name, int $time) : bool { $exceptions = []; foreach ($this->loaders as $loader) { if (!$loader->exists($name)) { continue; } try { return $loader->isFresh($name, $time); } catch (LoaderError $e) { $exceptions[] = \get_class($loader) . ': ' . $e->getMessage(); } } throw new LoaderError(\sprintf('Template "%s" is not defined%s.', $name, $exceptions ? ' (' . \implode(', ', $exceptions) . ')' : '')); } } PK �H,] ffUa a ( twig/twig/src/Loader/LoaderInterface.phpnu ��� <?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 Rvx\Twig\Loader; use Rvx\Twig\Error\LoaderError; use Rvx\Twig\Source; /** * Interface all loaders must implement. * * @author Fabien Potencier <fabien@symfony.com> */ interface LoaderInterface { /** * Returns the source context for a given template logical name. * * @throws LoaderError When $name is not found */ public function getSourceContext(string $name) : Source; /** * Gets the cache key to use for the cache for a given template name. * * @throws LoaderError When $name is not found */ public function getCacheKey(string $name) : string; /** * @param int $time Timestamp of the last modification time of the cached template * * @throws LoaderError When $name is not found */ public function isFresh(string $name, int $time) : bool; /** * @return bool */ public function exists(string $name); } PK �H,]����e e ) twig/twig/src/Loader/FilesystemLoader.phpnu ��� <?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 Rvx\Twig\Loader; use Rvx\Twig\Error\LoaderError; use Rvx\Twig\Source; /** * Loads template from the filesystem. * * @author Fabien Potencier <fabien@symfony.com> */ class FilesystemLoader implements LoaderInterface { /** Identifier of the main namespace. */ public const MAIN_NAMESPACE = '__main__'; protected $paths = []; protected $cache = []; protected $errorCache = []; private $rootPath; /** * @param string|array $paths A path or an array of paths where to look for templates * @param string|null $rootPath The root path common to all relative paths (null for getcwd()) */ public function __construct($paths = [], string $rootPath = null) { $this->rootPath = (null === $rootPath ? \getcwd() : $rootPath) . \DIRECTORY_SEPARATOR; if (null !== $rootPath && \false !== ($realPath = \realpath($rootPath))) { $this->rootPath = $realPath . \DIRECTORY_SEPARATOR; } if ($paths) { $this->setPaths($paths); } } /** * Returns the paths to the templates. */ public function getPaths(string $namespace = self::MAIN_NAMESPACE) : array { return $this->paths[$namespace] ?? []; } /** * Returns the path namespaces. * * The main namespace is always defined. */ public function getNamespaces() : array { return \array_keys($this->paths); } /** * @param string|array $paths A path or an array of paths where to look for templates */ public function setPaths($paths, string $namespace = self::MAIN_NAMESPACE) : void { if (!\is_array($paths)) { $paths = [$paths]; } $this->paths[$namespace] = []; foreach ($paths as $path) { $this->addPath($path, $namespace); } } /** * @throws LoaderError */ public function addPath(string $path, string $namespace = self::MAIN_NAMESPACE) : void { // invalidate the cache $this->cache = $this->errorCache = []; $checkPath = $this->isAbsolutePath($path) ? $path : $this->rootPath . $path; if (!\is_dir($checkPath)) { throw new LoaderError(\sprintf('The "%s" directory does not exist ("%s").', $path, $checkPath)); } $this->paths[$namespace][] = \rtrim($path, '/\\'); } /** * @throws LoaderError */ public function prependPath(string $path, string $namespace = self::MAIN_NAMESPACE) : void { // invalidate the cache $this->cache = $this->errorCache = []; $checkPath = $this->isAbsolutePath($path) ? $path : $this->rootPath . $path; if (!\is_dir($checkPath)) { throw new LoaderError(\sprintf('The "%s" directory does not exist ("%s").', $path, $checkPath)); } $path = \rtrim($path, '/\\'); if (!isset($this->paths[$namespace])) { $this->paths[$namespace][] = $path; } else { \array_unshift($this->paths[$namespace], $path); } } public function getSourceContext(string $name) : Source { if (null === ($path = $this->findTemplate($name))) { return new Source('', $name, ''); } return new Source(\file_get_contents($path), $name, $path); } public function getCacheKey(string $name) : string { if (null === ($path = $this->findTemplate($name))) { return ''; } $len = \strlen($this->rootPath); if (0 === \strncmp($this->rootPath, $path, $len)) { return \substr($path, $len); } return $path; } /** * @return bool */ public function exists(string $name) { $name = $this->normalizeName($name); if (isset($this->cache[$name])) { return \true; } return null !== $this->findTemplate($name, \false); } public function isFresh(string $name, int $time) : bool { // false support to be removed in 3.0 if (null === ($path = $this->findTemplate($name))) { return \false; } return \filemtime($path) < $time; } /** * @return string|null */ protected function findTemplate(string $name, bool $throw = \true) { $name = $this->normalizeName($name); if (isset($this->cache[$name])) { return $this->cache[$name]; } if (isset($this->errorCache[$name])) { if (!$throw) { return null; } throw new LoaderError($this->errorCache[$name]); } try { list($namespace, $shortname) = $this->parseName($name); $this->validateName($shortname); } catch (LoaderError $e) { if (!$throw) { return null; } throw $e; } if (!isset($this->paths[$namespace])) { $this->errorCache[$name] = \sprintf('There are no registered paths for namespace "%s".', $namespace); if (!$throw) { return null; } throw new LoaderError($this->errorCache[$name]); } foreach ($this->paths[$namespace] as $path) { if (!$this->isAbsolutePath($path)) { $path = $this->rootPath . $path; } if (\is_file($path . '/' . $shortname)) { if (\false !== ($realpath = \realpath($path . '/' . $shortname))) { return $this->cache[$name] = $realpath; } return $this->cache[$name] = $path . '/' . $shortname; } } $this->errorCache[$name] = \sprintf('Unable to find template "%s" (looked into: %s).', $name, \implode(', ', $this->paths[$namespace])); if (!$throw) { return null; } throw new LoaderError($this->errorCache[$name]); } private function normalizeName(string $name) : string { return \preg_replace('#/{2,}#', '/', \str_replace('\\', '/', $name)); } private function parseName(string $name, string $default = self::MAIN_NAMESPACE) : array { if (isset($name[0]) && '@' == $name[0]) { if (\false === ($pos = \strpos($name, '/'))) { throw new LoaderError(\sprintf('Malformed namespaced template name "%s" (expecting "@namespace/template_name").', $name)); } $namespace = \substr($name, 1, $pos - 1); $shortname = \substr($name, $pos + 1); return [$namespace, $shortname]; } return [$default, $name]; } private function validateName(string $name) : void { if (\false !== \strpos($name, "\x00")) { throw new LoaderError('A template name cannot contain NUL bytes.'); } $name = \ltrim($name, '/'); $parts = \explode('/', $name); $level = 0; foreach ($parts as $part) { if ('..' === $part) { --$level; } elseif ('.' !== $part) { ++$level; } if ($level < 0) { throw new LoaderError(\sprintf('Looks like you try to load a template outside configured directories (%s).', $name)); } } } private function isAbsolutePath(string $file) : bool { return \strspn($file, '/\\', 0, 1) || \strlen($file) > 3 && \ctype_alpha($file[0]) && ':' === $file[1] && \strspn($file, '/\\', 2, 1) || null !== \parse_url($file, \PHP_URL_SCHEME); } } PK �H,]�5RQ" " $ twig/twig/src/Loader/ArrayLoader.phpnu ��� <?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 Rvx\Twig\Loader; use Rvx\Twig\Error\LoaderError; use Rvx\Twig\Source; /** * Loads a template from an array. * * When using this loader with a cache mechanism, you should know that a new cache * key is generated each time a template content "changes" (the cache key being the * source code of the template). If you don't want to see your cache grows out of * control, you need to take care of clearing the old cache file by yourself. * * This loader should only be used for unit testing. * * @author Fabien Potencier <fabien@symfony.com> */ final class ArrayLoader implements LoaderInterface { private $templates = []; /** * @param array $templates An array of templates (keys are the names, and values are the source code) */ public function __construct(array $templates = []) { $this->templates = $templates; } public function setTemplate(string $name, string $template) : void { $this->templates[$name] = $template; } public function getSourceContext(string $name) : Source { if (!isset($this->templates[$name])) { throw new LoaderError(\sprintf('Template "%s" is not defined.', $name)); } return new Source($this->templates[$name], $name); } public function exists(string $name) : bool { return isset($this->templates[$name]); } public function getCacheKey(string $name) : string { if (!isset($this->templates[$name])) { throw new LoaderError(\sprintf('Template "%s" is not defined.', $name)); } return $name . ':' . $this->templates[$name]; } public function isFresh(string $name, int $time) : bool { if (!isset($this->templates[$name])) { throw new LoaderError(\sprintf('Template "%s" is not defined.', $name)); } return \true; } } PK �H,]7�&� &� "