first commit
This commit is contained in:
BIN
vendor/twig/@eaDir/twig@SynoEAStream
vendored
Normal file
BIN
vendor/twig/@eaDir/twig@SynoEAStream
vendored
Normal file
Binary file not shown.
BIN
vendor/twig/twig/@eaDir/CHANGELOG@SynoEAStream
vendored
Normal file
BIN
vendor/twig/twig/@eaDir/CHANGELOG@SynoEAStream
vendored
Normal file
Binary file not shown.
BIN
vendor/twig/twig/@eaDir/LICENSE@SynoEAStream
vendored
Normal file
BIN
vendor/twig/twig/@eaDir/LICENSE@SynoEAStream
vendored
Normal file
Binary file not shown.
BIN
vendor/twig/twig/@eaDir/README.rst@SynoEAStream
vendored
Normal file
BIN
vendor/twig/twig/@eaDir/README.rst@SynoEAStream
vendored
Normal file
Binary file not shown.
BIN
vendor/twig/twig/@eaDir/composer.json@SynoEAStream
vendored
Normal file
BIN
vendor/twig/twig/@eaDir/composer.json@SynoEAStream
vendored
Normal file
Binary file not shown.
BIN
vendor/twig/twig/@eaDir/splitsh.json@SynoEAStream
vendored
Normal file
BIN
vendor/twig/twig/@eaDir/splitsh.json@SynoEAStream
vendored
Normal file
Binary file not shown.
BIN
vendor/twig/twig/@eaDir/src@SynoEAStream
vendored
Normal file
BIN
vendor/twig/twig/@eaDir/src@SynoEAStream
vendored
Normal file
Binary file not shown.
487
vendor/twig/twig/CHANGELOG
vendored
Normal file
487
vendor/twig/twig/CHANGELOG
vendored
Normal file
@@ -0,0 +1,487 @@
|
||||
# 3.23.0 (2026-01-23)
|
||||
|
||||
* Add `=` assignment operator (allows to set variables in expression or to replace the short-form of the set tag)
|
||||
* Add sequence, mapping, and object destructuring
|
||||
* Add `?.` null-safe operator
|
||||
* Add `===` and `!==` operators (equivalent to the `same as` and `not same as` tests)
|
||||
* Fix opcache preload warning for unlinked anonymous class
|
||||
* Fix spread operator behavior
|
||||
|
||||
# 3.22.2 (2025-12-14)
|
||||
|
||||
* Fix "cycle" with non-countable ArrayAccess + Traversable objects
|
||||
* Use "getShareDir" as an indicator of Symfony version in Symfony bundle
|
||||
* Fix escaper compatibility with PHP 8.5
|
||||
|
||||
# 3.22.1 (2025-11-16)
|
||||
|
||||
* Add support for Symfony 8
|
||||
|
||||
# 3.22.0 (2025-10-29)
|
||||
|
||||
* Add support for two words test in guard tag
|
||||
* Add `Environment::registerUndefinedTestCallback()`
|
||||
* Fix compatibility with Symfony 8
|
||||
* Fix accessing arrays with stringable objects as key
|
||||
* Avoid errors when failing to guess the template info for an error
|
||||
* Fix expression parser compatibility layer
|
||||
* Fix compiling 'index' with repr (not string) in EmbedNode
|
||||
* Update configuration keys + allow extra keys for CommonMark extensions
|
||||
* Allow usage of other Markdown converters than CommonMark in LeagueMarkdown
|
||||
|
||||
# 3.21.1 (2025-05-03)
|
||||
|
||||
* Fix ExtensionSet usage of BinaryOperatorExpressionParser
|
||||
|
||||
# 3.21.0 (2025-05-02)
|
||||
|
||||
* Fix wrong array index
|
||||
* Deprecate `Template::loadTemplate()`
|
||||
* Fix testing and expression when it evaluates to an instance of `Markup`
|
||||
* Add `ReturnPrimitiveTypeInterface` (and sub-interfaces for number, boolean, string, and array)
|
||||
* Add `SupportDefinedTestInterface` for expression nodes supporting the `defined` test
|
||||
* Deprecate using the `|` operator in an expression with `+` or `-` without using parentheses to clarify precedence
|
||||
* Deprecate operator precedence outside of the [0, 512] range
|
||||
* Introduce expression parser classes to describe operators and operands provided by extensions
|
||||
instead of arrays (it comes with many deprecations that are documented in
|
||||
the ``deprecated`` documentation chapter)
|
||||
* Deprecate the `Twig\ExpressionParser`, and `Twig\OperatorPrecedenceChange` classes
|
||||
* Add attributes `AsTwigFilter`, `AsTwigFunction`, and `AsTwigTest` to ease extension development
|
||||
|
||||
# 3.20.0 (2025-02-13)
|
||||
|
||||
* Fix support for ignoring syntax errors in an undefined handler in guard
|
||||
* Add configuration for Commonmark
|
||||
* Fix wrong array index
|
||||
* Bump minimum PHP version to 8.1
|
||||
* Add support for registering callbacks for undefined functions, filters or token parsers in the IntegrationTestCase
|
||||
* Use correct line number for `ForElseNode`
|
||||
* Fix timezone conversion on strings
|
||||
|
||||
# 3.19.0 (2025-01-28)
|
||||
|
||||
* Fix a security issue where escaping was missing when using `??`
|
||||
* Deprecate `Token::getType()`, use `Token::test()` instead
|
||||
* Add `Token::toEnglish()`
|
||||
* Add `ForElseNode`
|
||||
* Deprecate `Twig\ExpressionParser::parseOnlyArguments()` and
|
||||
`Twig\ExpressionParser::parseArguments()` (use
|
||||
`Twig\ExpressionParser::parseNamedArguments()` instead)
|
||||
* Fix `constant()` behavior when used with `??`
|
||||
* Add the `invoke` filter
|
||||
* Make `{}` optional for the `types` tag
|
||||
* Add `LastModifiedExtensionInterface` and implementation in `AbstractExtension` to track modification of runtime classes
|
||||
* Ignore static properties when using the dot operator
|
||||
|
||||
# 3.18.0 (2024-12-29)
|
||||
|
||||
* Support for invoking closures
|
||||
* Fix unary operator precedence change
|
||||
* Ignore `SyntaxError` exceptions from undefined handlers when using the `guard` tag
|
||||
* Add a way to stream template rendering (`TemplateWrapper::stream()` and `TemplateWrapper::streamBlock()`)
|
||||
|
||||
# 3.17.1 (2024-12-12)
|
||||
|
||||
* Fix the null coalescing operator when the test returns null
|
||||
* Fix the Elvis operator when used as '? :' instead of '?:'
|
||||
|
||||
# 3.17.0 (2024-12-10)
|
||||
|
||||
* Fix ArrayAccess with objects as keys
|
||||
* Support underscores in number literals
|
||||
* Deprecate `ConditionalExpression` and `NullCoalesceExpression` (use `ConditionalTernary` and `NullCoalesceBinary` instead)
|
||||
|
||||
# 3.16.0 (2024-11-29)
|
||||
|
||||
* Deprecate `InlinePrint`
|
||||
* Fix having macro variables starting with an underscore
|
||||
* Deprecate not passing a `Source` instance to `TokenStream`
|
||||
* Deprecate returning `null` from `TwigFilter::getSafe()` and `TwigFunction::getSafe()`, return `[]` instead
|
||||
|
||||
# 3.15.0 (2024-11-17)
|
||||
|
||||
* [BC BREAK] Add support for accessing class constants with the dot operator;
|
||||
this can be a BC break if you don't use UPPERCASE constant names
|
||||
* Add Spanish inflector support for the `plural` and `singular` filters in the String extension
|
||||
* Deprecate `TempNameExpression` in favor of `LocalVariable`
|
||||
* Deprecate `NameExpression` in favor of `ContextVariable`
|
||||
* Deprecate `AssignNameExpression` in favor of `AssignContextVariable`
|
||||
* Remove `MacroAutoImportNodeVisitor`
|
||||
* Deprecate `MethodCallExpression` in favor of `MacroReferenceExpression`
|
||||
* Fix support for the "is defined" test on `_self.xxx` (auto-imported) macros
|
||||
* Fix support for the "is defined" test on inherited macros
|
||||
* Add named arguments support for the dot operator arguments (`foo.bar(some: arg)`)
|
||||
* Add named arguments support for macros
|
||||
* Add a new `guard` tag that allows to test if some Twig callables are available at compilation time
|
||||
* Allow arrow functions everywhere
|
||||
* Deprecate passing a string or an array to Twig callable arguments accepting arrow functions (pass a `\Closure`)
|
||||
* Add support for triggering deprecations for future operator precedence changes
|
||||
* Deprecate using the `not` unary operator in an expression with ``*``, ``/``, ``//``, or ``%`` without using explicit parentheses to clarify precedence
|
||||
* Deprecate using the `??` binary operator without explicit parentheses
|
||||
* Deprecate using the `~` binary operator in an expression with `+` or `-` without using parentheses to clarify precedence
|
||||
* Deprecate not passing `AbstractExpression` args to most constructor arguments for classes extending `AbstractExpression`
|
||||
* Fix `power` expressions with a negative number in parenthesis (`(-1) ** 2`)
|
||||
* Deprecate instantiating `Node` directly. Use `EmptyNode` or `Nodes` instead.
|
||||
* Add support for inline comments
|
||||
* Add `Profile::getStartTime()` and `Profile::getEndTime()`
|
||||
* Fix "ignore missing" when used on an "embed" tag
|
||||
* Fix the possibility to override an aliased block (via use)
|
||||
* Add template cache hot reload
|
||||
* Allow Twig callable argument names to be free-form (snake-case or camelCase) independently of the PHP callable signature
|
||||
They were automatically converted to snake-cased before
|
||||
* Deprecate the `attribute` function; use the `.` notation and wrap the name with parenthesis instead
|
||||
* Add support for argument unpackaging
|
||||
* Add JSON support for the file extension escaping strategy
|
||||
* Support Markup instances (and any other \Stringable) as dynamic mapping keys
|
||||
* Deprecate the `sandbox` tag
|
||||
* Improve the way one can deprecate a Twig callable (use `deprecation_info` instead of the other callable options)
|
||||
* Add the `enum` function
|
||||
* Add support for logical `xor` operator
|
||||
|
||||
# 3.14.2 (2024-11-07)
|
||||
|
||||
* Fix an infinite recursion in the sandbox code
|
||||
|
||||
# 3.14.1 (2024-11-06)
|
||||
|
||||
* [BC BREAK] Fix a security issue in the sandbox mode allowing an attacker to call attributes on Array-like objects
|
||||
They are now checked via the property policy
|
||||
* Fix a security issue in the sandbox mode allowing an attacker to be able to call `toString()`
|
||||
under some circumstances on an object even if the `__toString()` method is not allowed by the security policy
|
||||
|
||||
# 3.14.0 (2024-09-09)
|
||||
|
||||
* Fix a security issue when an included sandboxed template has been loaded before without the sandbox context
|
||||
* Add the possibility to reset globals via `Environment::resetGlobals()`
|
||||
* Deprecate `Environment::mergeGlobals()`
|
||||
|
||||
# 3.13.0 (2024-09-07)
|
||||
|
||||
* Add the `types` tag (experimental)
|
||||
* Deprecate the `Twig\Test\NodeTestCase::getTests()` data provider, override `provideTests()` instead.
|
||||
* Mark `Twig\Test\NodeTestCase::getEnvironment()` as final, override `createEnvironment()` instead.
|
||||
* Deprecate `Twig\Test\NodeTestCase::getVariableGetter()`, call `createVariableGetter()` instead.
|
||||
* Deprecate `Twig\Test\NodeTestCase::getAttributeGetter()`, call `createAttributeGetter()` instead.
|
||||
* Deprecate not overriding `Twig\Test\IntegrationTestCase::getFixturesDirectory()`, this method will be abstract in 4.0
|
||||
* Marked `Twig\Test\IntegrationTestCase::getTests()` and `getLegacyTests()` as final
|
||||
|
||||
# 3.12.0 (2024-08-29)
|
||||
|
||||
* Deprecate the fact that the `extends` and `use` tags are always allowed in a sandboxed template.
|
||||
This behavior will change in 4.0 where these tags will need to be explicitly allowed like any other tag.
|
||||
* Deprecate the "tag" constructor argument of the "Twig\Node\Node" class as the tag is now automatically set by the Parser when needed
|
||||
* Fix precedence of two-word tests when the first word is a valid test
|
||||
* Deprecate the `spaceless` filter
|
||||
* Deprecate some internal methods from `Parser`: `getBlockStack()`, `hasBlock()`, `getBlock()`, `hasMacro()`, `hasTraits()`, `getParent()`
|
||||
* Deprecate passing `null` to `Twig\Parser::setParent()`
|
||||
* Update `Node::__toString()` to include the node tag if set
|
||||
* Add support for integers in methods of `Twig\Node\Node` that take a Node name
|
||||
* Deprecate not passing a `BodyNode` instance as the body of a `ModuleNode` or `MacroNode` constructor
|
||||
* Deprecate returning "null" from "TokenParserInterface::parse()".
|
||||
* Deprecate `OptimizerNodeVisitor::OPTIMIZE_TEXT_NODES`
|
||||
* Fix performance regression when `use_yield` is `false` (which is the default)
|
||||
* Improve compatibility when `use_yield` is `false` (as extensions still using `echo` will work as is)
|
||||
* Accept colons (`:`) in addition to equals (`=`) to separate argument names and values in named arguments
|
||||
* Add the `html_cva` function (in the HTML extra package)
|
||||
* Add support for named arguments to the `block` and `attribute` functions
|
||||
* Throw a SyntaxError exception at compile time when a Twig callable has not the minimum number of required arguments
|
||||
* Add a `CallableArgumentsExtractor` class
|
||||
* Deprecate passing a name to `FunctionExpression`, `FilterExpression`, and `TestExpression`;
|
||||
pass a `TwigFunction`, `TwigFilter`, or `TestFilter` instead
|
||||
* Deprecate all Twig callable attributes on `FunctionExpression`, `FilterExpression`, and `TestExpression`
|
||||
* Deprecate the `filter` node of `FilterExpression`
|
||||
* Add the notion of Twig callables (functions, filters, and tests)
|
||||
* Bump minimum PHP version to 8.0
|
||||
* Fix integration tests when a test has more than one data/expect section and deprecations
|
||||
* Add the `enum_cases` function
|
||||
|
||||
# 3.11.2 (2024-11-06)
|
||||
|
||||
* [BC BREAK] Fix a security issue in the sandbox mode allowing an attacker to call attributes on Array-like objects
|
||||
They are now checked via the property policy
|
||||
* Fix a security issue in the sandbox mode allowing an attacker to be able to call `toString()`
|
||||
under some circumstances on an object even if the `__toString()` method is not allowed by the security policy
|
||||
|
||||
# 3.11.1 (2024-09-10)
|
||||
|
||||
* Fix a security issue when an included sandboxed template has been loaded before without the sandbox context
|
||||
|
||||
# 3.11.0 (2024-08-08)
|
||||
|
||||
* Deprecate `OptimizerNodeVisitor::OPTIMIZE_RAW_FILTER`
|
||||
* Add `Twig\Cache\ChainCache` and `Twig\Cache\ReadOnlyFilesystemCache`
|
||||
* Add the possibility to deprecate attributes and nodes on `Node`
|
||||
* Add the possibility to add a package and a version to the `deprecated` tag
|
||||
* Add the possibility to add a package for filter/function/test deprecations
|
||||
* Mark `ConstantExpression` as being `@final`
|
||||
* Add the `find` filter
|
||||
* Fix optimizer mode validation in `OptimizerNodeVisitor`
|
||||
* Add the possibility to yield from a generator in `PrintNode`
|
||||
* Add the `shuffle` filter
|
||||
* Add the `singular` and `plural` filters in `StringExtension`
|
||||
* Deprecate the second argument of `Twig\Node\Expression\CallExpression::compileArguments()`
|
||||
* Deprecate `Twig\ExpressionParser\parseHashExpression()` in favor of
|
||||
`Twig\ExpressionParser::parseMappingExpression()`
|
||||
* Deprecate `Twig\ExpressionParser\parseArrayExpression()` in favor of
|
||||
`Twig\ExpressionParser::parseSequenceExpression()`
|
||||
* Add `sequence` and `mapping` tests
|
||||
* Deprecate `Twig\Node\Expression\NameExpression::isSimple()` and
|
||||
`Twig\Node\Expression\NameExpression::isSpecial()`
|
||||
|
||||
# 3.10.3 (2024-05-16)
|
||||
|
||||
* Fix missing ; in generated code
|
||||
|
||||
# 3.10.2 (2024-05-14)
|
||||
|
||||
* Fix support for the deprecated escaper signature
|
||||
|
||||
# 3.10.1 (2024-05-12)
|
||||
|
||||
* Fix BC break on escaper extension
|
||||
* Fix constant return type
|
||||
|
||||
# 3.10.0 (2024-05-11)
|
||||
|
||||
* Make `CoreExtension::formatDate`, `CoreExtension::convertDate`, and
|
||||
`CoreExtension::formatNumber` part of the public API
|
||||
* Add `needs_charset` option for filters and functions
|
||||
* Extract the escaping logic from the `EscaperExtension` class to a new
|
||||
`EscaperRuntime` class.
|
||||
|
||||
The following methods from ``Twig\\Extension\\EscaperExtension`` are
|
||||
deprecated: ``setEscaper()``, ``getEscapers()``, ``setSafeClasses``,
|
||||
``addSafeClasses()``. Use the same methods on the
|
||||
``Twig\\Runtime\\EscaperRuntime`` class instead.
|
||||
* Fix capturing output from extensions that still use echo
|
||||
* Fix a PHP warning in the Lexer on malformed templates
|
||||
* Fix blocks not available under some circumstances
|
||||
* Synchronize source context in templates when setting a Node on a Node
|
||||
|
||||
# 3.9.3 (2024-04-18)
|
||||
|
||||
* Add missing `twig_escape_filter_is_safe` deprecated function
|
||||
* Fix yield usage with CaptureNode
|
||||
* Add missing unwrap call when using a TemplateWrapper instance internally
|
||||
* Ensure Lexer is initialized early on
|
||||
|
||||
# 3.9.2 (2024-04-17)
|
||||
|
||||
* Fix usage of display_end hook
|
||||
|
||||
# 3.9.1 (2024-04-17)
|
||||
|
||||
* Fix missing `$blocks` variable in `CaptureNode`
|
||||
|
||||
# 3.9.0 (2024-04-16)
|
||||
|
||||
* Add support for PHP 8.4
|
||||
* Deprecate AbstractNodeVisitor
|
||||
* Deprecate passing Template to Environment::resolveTemplate(), Environment::load(), and Template::loadTemplate()
|
||||
* Add a new "yield" mode for output generation;
|
||||
Node implementations that use "echo" or "print" should use "yield" instead;
|
||||
all Node implementations should be flagged with `#[YieldReady]` once they've been made ready for "yield";
|
||||
the "use_yield" Environment option can be turned on when all nodes have been made `#[YieldReady]`;
|
||||
"yield" will be the only strategy supported in the next major version
|
||||
* Add return type for Symfony 7 compatibility
|
||||
* Fix premature loop exit in Security Policy lookup of allowed methods/properties
|
||||
* Deprecate all internal extension functions in favor of methods on the extension classes
|
||||
* Mark all extension functions as @internal
|
||||
* Add SourcePolicyInterface to selectively enable the Sandbox based on a template's Source
|
||||
* Throw a proper Twig exception when using cycle on an empty array
|
||||
|
||||
# 3.8.0 (2023-11-21)
|
||||
|
||||
* Catch errors thrown during template rendering
|
||||
* Fix IntlExtension::formatDateTime use of date formatter prototype
|
||||
* Fix premature loop exit in Security Policy lookup of allowed methods/properties
|
||||
* Remove NumberFormatter::TYPE_CURRENCY (deprecated in PHP 8.3)
|
||||
* Restore return type annotations
|
||||
* Allow Symfony 7 packages to be installed
|
||||
* Deprecate `twig_test_iterable` function. Use the native `is_iterable` instead.
|
||||
|
||||
# 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 marked 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
|
||||
27
vendor/twig/twig/LICENSE
vendored
Normal file
27
vendor/twig/twig/LICENSE
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
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.
|
||||
23
vendor/twig/twig/README.rst
vendored
Normal file
23
vendor/twig/twig/README.rst
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
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://docs.blackfire.io/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
|
||||
53
vendor/twig/twig/composer.json
vendored
Normal file
53
vendor/twig/twig/composer.json
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
{
|
||||
"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": ">=8.1.0",
|
||||
"symfony/deprecation-contracts": "^2.5|^3",
|
||||
"symfony/polyfill-mbstring": "^1.3",
|
||||
"symfony/polyfill-ctype": "^1.8"
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/phpunit-bridge": "^5.4.9|^6.4|^7.0",
|
||||
"psr/container": "^1.0|^2.0",
|
||||
"phpstan/phpstan": "^2.0"
|
||||
},
|
||||
"autoload": {
|
||||
"files": [
|
||||
"src/Resources/core.php",
|
||||
"src/Resources/debug.php",
|
||||
"src/Resources/escaper.php",
|
||||
"src/Resources/string_loader.php"
|
||||
],
|
||||
"psr-4" : {
|
||||
"Twig\\" : "src/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4" : {
|
||||
"Twig\\Tests\\" : "tests/"
|
||||
}
|
||||
}
|
||||
}
|
||||
15
vendor/twig/twig/splitsh.json
vendored
Normal file
15
vendor/twig/twig/splitsh.json
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"subtrees": {
|
||||
"twig-extra-bundle": "extra/twig-extra-bundle",
|
||||
"cache-extra": "extra/cache-extra",
|
||||
"cssinliner-extra": "extra/cssinliner-extra",
|
||||
"html-extra": "extra/html-extra",
|
||||
"inky-extra": "extra/inky-extra",
|
||||
"intl-extra": "extra/intl-extra",
|
||||
"markdown-extra": "extra/markdown-extra",
|
||||
"string-extra": "extra/string-extra"
|
||||
},
|
||||
"defaults": {
|
||||
"git_constraint": "<1.8.2"
|
||||
}
|
||||
}
|
||||
BIN
vendor/twig/twig/src/@eaDir/AbstractTwigCallable.php@SynoEAStream
vendored
Normal file
BIN
vendor/twig/twig/src/@eaDir/AbstractTwigCallable.php@SynoEAStream
vendored
Normal file
Binary file not shown.
BIN
vendor/twig/twig/src/@eaDir/Attribute@SynoEAStream
vendored
Normal file
BIN
vendor/twig/twig/src/@eaDir/Attribute@SynoEAStream
vendored
Normal file
Binary file not shown.
BIN
vendor/twig/twig/src/@eaDir/Cache@SynoEAStream
vendored
Normal file
BIN
vendor/twig/twig/src/@eaDir/Cache@SynoEAStream
vendored
Normal file
Binary file not shown.
BIN
vendor/twig/twig/src/@eaDir/Compiler.php@SynoEAStream
vendored
Normal file
BIN
vendor/twig/twig/src/@eaDir/Compiler.php@SynoEAStream
vendored
Normal file
Binary file not shown.
BIN
vendor/twig/twig/src/@eaDir/DeprecatedCallableInfo.php@SynoEAStream
vendored
Normal file
BIN
vendor/twig/twig/src/@eaDir/DeprecatedCallableInfo.php@SynoEAStream
vendored
Normal file
Binary file not shown.
BIN
vendor/twig/twig/src/@eaDir/Environment.php@SynoEAStream
vendored
Normal file
BIN
vendor/twig/twig/src/@eaDir/Environment.php@SynoEAStream
vendored
Normal file
Binary file not shown.
BIN
vendor/twig/twig/src/@eaDir/Error@SynoEAStream
vendored
Normal file
BIN
vendor/twig/twig/src/@eaDir/Error@SynoEAStream
vendored
Normal file
Binary file not shown.
BIN
vendor/twig/twig/src/@eaDir/ExpressionParser.php@SynoEAStream
vendored
Normal file
BIN
vendor/twig/twig/src/@eaDir/ExpressionParser.php@SynoEAStream
vendored
Normal file
Binary file not shown.
BIN
vendor/twig/twig/src/@eaDir/ExpressionParser@SynoEAStream
vendored
Normal file
BIN
vendor/twig/twig/src/@eaDir/ExpressionParser@SynoEAStream
vendored
Normal file
Binary file not shown.
BIN
vendor/twig/twig/src/@eaDir/Extension@SynoEAStream
vendored
Normal file
BIN
vendor/twig/twig/src/@eaDir/Extension@SynoEAStream
vendored
Normal file
Binary file not shown.
BIN
vendor/twig/twig/src/@eaDir/ExtensionSet.php@SynoEAStream
vendored
Normal file
BIN
vendor/twig/twig/src/@eaDir/ExtensionSet.php@SynoEAStream
vendored
Normal file
Binary file not shown.
BIN
vendor/twig/twig/src/@eaDir/FileExtensionEscapingStrategy.php@SynoEAStream
vendored
Normal file
BIN
vendor/twig/twig/src/@eaDir/FileExtensionEscapingStrategy.php@SynoEAStream
vendored
Normal file
Binary file not shown.
BIN
vendor/twig/twig/src/@eaDir/Lexer.php@SynoEAStream
vendored
Normal file
BIN
vendor/twig/twig/src/@eaDir/Lexer.php@SynoEAStream
vendored
Normal file
Binary file not shown.
BIN
vendor/twig/twig/src/@eaDir/Loader@SynoEAStream
vendored
Normal file
BIN
vendor/twig/twig/src/@eaDir/Loader@SynoEAStream
vendored
Normal file
Binary file not shown.
BIN
vendor/twig/twig/src/@eaDir/Markup.php@SynoEAStream
vendored
Normal file
BIN
vendor/twig/twig/src/@eaDir/Markup.php@SynoEAStream
vendored
Normal file
Binary file not shown.
BIN
vendor/twig/twig/src/@eaDir/Node@SynoEAStream
vendored
Normal file
BIN
vendor/twig/twig/src/@eaDir/Node@SynoEAStream
vendored
Normal file
Binary file not shown.
BIN
vendor/twig/twig/src/@eaDir/NodeTraverser.php@SynoEAStream
vendored
Normal file
BIN
vendor/twig/twig/src/@eaDir/NodeTraverser.php@SynoEAStream
vendored
Normal file
Binary file not shown.
BIN
vendor/twig/twig/src/@eaDir/NodeVisitor@SynoEAStream
vendored
Normal file
BIN
vendor/twig/twig/src/@eaDir/NodeVisitor@SynoEAStream
vendored
Normal file
Binary file not shown.
BIN
vendor/twig/twig/src/@eaDir/OperatorPrecedenceChange.php@SynoEAStream
vendored
Normal file
BIN
vendor/twig/twig/src/@eaDir/OperatorPrecedenceChange.php@SynoEAStream
vendored
Normal file
Binary file not shown.
BIN
vendor/twig/twig/src/@eaDir/Parser.php@SynoEAStream
vendored
Normal file
BIN
vendor/twig/twig/src/@eaDir/Parser.php@SynoEAStream
vendored
Normal file
Binary file not shown.
BIN
vendor/twig/twig/src/@eaDir/Profiler@SynoEAStream
vendored
Normal file
BIN
vendor/twig/twig/src/@eaDir/Profiler@SynoEAStream
vendored
Normal file
Binary file not shown.
BIN
vendor/twig/twig/src/@eaDir/Resources@SynoEAStream
vendored
Normal file
BIN
vendor/twig/twig/src/@eaDir/Resources@SynoEAStream
vendored
Normal file
Binary file not shown.
BIN
vendor/twig/twig/src/@eaDir/Runtime@SynoEAStream
vendored
Normal file
BIN
vendor/twig/twig/src/@eaDir/Runtime@SynoEAStream
vendored
Normal file
Binary file not shown.
BIN
vendor/twig/twig/src/@eaDir/RuntimeLoader@SynoEAStream
vendored
Normal file
BIN
vendor/twig/twig/src/@eaDir/RuntimeLoader@SynoEAStream
vendored
Normal file
Binary file not shown.
BIN
vendor/twig/twig/src/@eaDir/Sandbox@SynoEAStream
vendored
Normal file
BIN
vendor/twig/twig/src/@eaDir/Sandbox@SynoEAStream
vendored
Normal file
Binary file not shown.
BIN
vendor/twig/twig/src/@eaDir/Source.php@SynoEAStream
vendored
Normal file
BIN
vendor/twig/twig/src/@eaDir/Source.php@SynoEAStream
vendored
Normal file
Binary file not shown.
BIN
vendor/twig/twig/src/@eaDir/Template.php@SynoEAStream
vendored
Normal file
BIN
vendor/twig/twig/src/@eaDir/Template.php@SynoEAStream
vendored
Normal file
Binary file not shown.
BIN
vendor/twig/twig/src/@eaDir/TemplateWrapper.php@SynoEAStream
vendored
Normal file
BIN
vendor/twig/twig/src/@eaDir/TemplateWrapper.php@SynoEAStream
vendored
Normal file
Binary file not shown.
BIN
vendor/twig/twig/src/@eaDir/Test@SynoEAStream
vendored
Normal file
BIN
vendor/twig/twig/src/@eaDir/Test@SynoEAStream
vendored
Normal file
Binary file not shown.
BIN
vendor/twig/twig/src/@eaDir/Token.php@SynoEAStream
vendored
Normal file
BIN
vendor/twig/twig/src/@eaDir/Token.php@SynoEAStream
vendored
Normal file
Binary file not shown.
BIN
vendor/twig/twig/src/@eaDir/TokenParser@SynoEAStream
vendored
Normal file
BIN
vendor/twig/twig/src/@eaDir/TokenParser@SynoEAStream
vendored
Normal file
Binary file not shown.
BIN
vendor/twig/twig/src/@eaDir/TokenStream.php@SynoEAStream
vendored
Normal file
BIN
vendor/twig/twig/src/@eaDir/TokenStream.php@SynoEAStream
vendored
Normal file
Binary file not shown.
BIN
vendor/twig/twig/src/@eaDir/TwigCallableInterface.php@SynoEAStream
vendored
Normal file
BIN
vendor/twig/twig/src/@eaDir/TwigCallableInterface.php@SynoEAStream
vendored
Normal file
Binary file not shown.
BIN
vendor/twig/twig/src/@eaDir/TwigFilter.php@SynoEAStream
vendored
Normal file
BIN
vendor/twig/twig/src/@eaDir/TwigFilter.php@SynoEAStream
vendored
Normal file
Binary file not shown.
BIN
vendor/twig/twig/src/@eaDir/TwigFunction.php@SynoEAStream
vendored
Normal file
BIN
vendor/twig/twig/src/@eaDir/TwigFunction.php@SynoEAStream
vendored
Normal file
Binary file not shown.
BIN
vendor/twig/twig/src/@eaDir/TwigTest.php@SynoEAStream
vendored
Normal file
BIN
vendor/twig/twig/src/@eaDir/TwigTest.php@SynoEAStream
vendored
Normal file
Binary file not shown.
BIN
vendor/twig/twig/src/@eaDir/Util@SynoEAStream
vendored
Normal file
BIN
vendor/twig/twig/src/@eaDir/Util@SynoEAStream
vendored
Normal file
Binary file not shown.
187
vendor/twig/twig/src/AbstractTwigCallable.php
vendored
Normal file
187
vendor/twig/twig/src/AbstractTwigCallable.php
vendored
Normal file
@@ -0,0 +1,187 @@
|
||||
<?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;
|
||||
|
||||
/**
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
abstract class AbstractTwigCallable implements TwigCallableInterface
|
||||
{
|
||||
protected $options;
|
||||
|
||||
private $name;
|
||||
private $dynamicName;
|
||||
private $callable;
|
||||
private $arguments;
|
||||
|
||||
public function __construct(string $name, $callable = null, array $options = [])
|
||||
{
|
||||
$this->name = $this->dynamicName = $name;
|
||||
$this->callable = $callable;
|
||||
$this->arguments = [];
|
||||
$this->options = array_merge([
|
||||
'needs_environment' => false,
|
||||
'needs_context' => false,
|
||||
'needs_charset' => false,
|
||||
'is_variadic' => false,
|
||||
'deprecation_info' => null,
|
||||
'deprecated' => false,
|
||||
'deprecating_package' => '',
|
||||
'alternative' => null,
|
||||
], $options);
|
||||
|
||||
if ($this->options['deprecation_info'] && !$this->options['deprecation_info'] instanceof DeprecatedCallableInfo) {
|
||||
throw new \LogicException(\sprintf('The "deprecation_info" option must be an instance of "%s".', DeprecatedCallableInfo::class));
|
||||
}
|
||||
|
||||
if ($this->options['deprecated']) {
|
||||
if ($this->options['deprecation_info']) {
|
||||
throw new \LogicException('When setting the "deprecation_info" option, you need to remove the obsolete deprecated options.');
|
||||
}
|
||||
|
||||
trigger_deprecation('twig/twig', '3.15', 'Using the "deprecated", "deprecating_package", and "alternative" options is deprecated, pass a "deprecation_info" one instead.');
|
||||
|
||||
$this->options['deprecation_info'] = new DeprecatedCallableInfo(
|
||||
$this->options['deprecating_package'],
|
||||
$this->options['deprecated'],
|
||||
null,
|
||||
$this->options['alternative'],
|
||||
);
|
||||
}
|
||||
|
||||
if ($this->options['deprecation_info']) {
|
||||
$this->options['deprecation_info']->setName($name);
|
||||
$this->options['deprecation_info']->setType($this->getType());
|
||||
}
|
||||
}
|
||||
|
||||
public function __toString(): string
|
||||
{
|
||||
return \sprintf('%s(%s)', static::class, $this->name);
|
||||
}
|
||||
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function getDynamicName(): string
|
||||
{
|
||||
return $this->dynamicName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return callable|array{class-string, string}|null
|
||||
*/
|
||||
public function getCallable()
|
||||
{
|
||||
return $this->callable;
|
||||
}
|
||||
|
||||
public function getNodeClass(): string
|
||||
{
|
||||
return $this->options['node_class'];
|
||||
}
|
||||
|
||||
public function needsCharset(): bool
|
||||
{
|
||||
return $this->options['needs_charset'];
|
||||
}
|
||||
|
||||
public function needsEnvironment(): bool
|
||||
{
|
||||
return $this->options['needs_environment'];
|
||||
}
|
||||
|
||||
public function needsContext(): bool
|
||||
{
|
||||
return $this->options['needs_context'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
public function withDynamicArguments(string $name, string $dynamicName, array $arguments): self
|
||||
{
|
||||
$new = clone $this;
|
||||
$new->name = $name;
|
||||
$new->dynamicName = $dynamicName;
|
||||
$new->arguments = $arguments;
|
||||
|
||||
return $new;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since Twig 3.12, use withDynamicArguments() instead
|
||||
*/
|
||||
public function setArguments(array $arguments): void
|
||||
{
|
||||
trigger_deprecation('twig/twig', '3.12', 'The "%s::setArguments()" method is deprecated, use "%s::withDynamicArguments()" instead.', static::class, static::class);
|
||||
|
||||
$this->arguments = $arguments;
|
||||
}
|
||||
|
||||
public function getArguments(): array
|
||||
{
|
||||
return $this->arguments;
|
||||
}
|
||||
|
||||
public function isVariadic(): bool
|
||||
{
|
||||
return $this->options['is_variadic'];
|
||||
}
|
||||
|
||||
public function isDeprecated(): bool
|
||||
{
|
||||
return (bool) $this->options['deprecation_info'];
|
||||
}
|
||||
|
||||
public function triggerDeprecation(?string $file = null, ?int $line = null): void
|
||||
{
|
||||
$this->options['deprecation_info']->triggerDeprecation($file, $line);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since Twig 3.15
|
||||
*/
|
||||
public function getDeprecatingPackage(): string
|
||||
{
|
||||
trigger_deprecation('twig/twig', '3.15', 'The "%s" method is deprecated, use "%s::triggerDeprecation()" instead.', __METHOD__, static::class);
|
||||
|
||||
return $this->options['deprecating_package'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since Twig 3.15
|
||||
*/
|
||||
public function getDeprecatedVersion(): string
|
||||
{
|
||||
trigger_deprecation('twig/twig', '3.15', 'The "%s" method is deprecated, use "%s::triggerDeprecation()" instead.', __METHOD__, static::class);
|
||||
|
||||
return \is_bool($this->options['deprecated']) ? '' : $this->options['deprecated'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since Twig 3.15
|
||||
*/
|
||||
public function getAlternative(): ?string
|
||||
{
|
||||
trigger_deprecation('twig/twig', '3.15', 'The "%s" method is deprecated, use "%s::triggerDeprecation()" instead.', __METHOD__, static::class);
|
||||
|
||||
return $this->options['alternative'];
|
||||
}
|
||||
|
||||
public function getMinimalNumberOfRequiredArguments(): int
|
||||
{
|
||||
return ($this->options['needs_charset'] ? 1 : 0) + ($this->options['needs_environment'] ? 1 : 0) + ($this->options['needs_context'] ? 1 : 0) + \count($this->arguments);
|
||||
}
|
||||
}
|
||||
BIN
vendor/twig/twig/src/Attribute/@eaDir/AsTwigFilter.php@SynoEAStream
vendored
Normal file
BIN
vendor/twig/twig/src/Attribute/@eaDir/AsTwigFilter.php@SynoEAStream
vendored
Normal file
Binary file not shown.
BIN
vendor/twig/twig/src/Attribute/@eaDir/AsTwigFunction.php@SynoEAStream
vendored
Normal file
BIN
vendor/twig/twig/src/Attribute/@eaDir/AsTwigFunction.php@SynoEAStream
vendored
Normal file
Binary file not shown.
BIN
vendor/twig/twig/src/Attribute/@eaDir/AsTwigTest.php@SynoEAStream
vendored
Normal file
BIN
vendor/twig/twig/src/Attribute/@eaDir/AsTwigTest.php@SynoEAStream
vendored
Normal file
Binary file not shown.
BIN
vendor/twig/twig/src/Attribute/@eaDir/FirstClassTwigCallableReady.php@SynoEAStream
vendored
Normal file
BIN
vendor/twig/twig/src/Attribute/@eaDir/FirstClassTwigCallableReady.php@SynoEAStream
vendored
Normal file
Binary file not shown.
BIN
vendor/twig/twig/src/Attribute/@eaDir/YieldReady.php@SynoEAStream
vendored
Normal file
BIN
vendor/twig/twig/src/Attribute/@eaDir/YieldReady.php@SynoEAStream
vendored
Normal file
Binary file not shown.
56
vendor/twig/twig/src/Attribute/AsTwigFilter.php
vendored
Normal file
56
vendor/twig/twig/src/Attribute/AsTwigFilter.php
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
<?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\Attribute;
|
||||
|
||||
use Twig\DeprecatedCallableInfo;
|
||||
use Twig\TwigFilter;
|
||||
|
||||
/**
|
||||
* Registers a method as template filter.
|
||||
*
|
||||
* If the first argument of the method has Twig\Environment type-hint, the filter will receive the current environment.
|
||||
* Additional arguments of the method come from the filter call.
|
||||
*
|
||||
* #[AsTwigFilter(name: 'foo')]
|
||||
* function fooFilter(Environment $env, $string, $arg1 = null, ...) { ... }
|
||||
*
|
||||
* {{ 'string'|foo(arg1) }}
|
||||
*
|
||||
* @see TwigFilter
|
||||
*/
|
||||
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
|
||||
final class AsTwigFilter
|
||||
{
|
||||
/**
|
||||
* @param non-empty-string $name The name of the filter in Twig
|
||||
* @param bool|null $needsCharset Whether the filter needs the charset passed as the first argument
|
||||
* @param bool|null $needsEnvironment Whether the filter needs the environment passed as the first argument, or after the charset
|
||||
* @param bool|null $needsContext Whether the filter needs the context array passed as the first argument, or after the charset and the environment
|
||||
* @param string[]|null $isSafe List of formats in which you want the raw output to be printed unescaped
|
||||
* @param string|array|null $isSafeCallback Function called at compilation time to determine if the filter is safe
|
||||
* @param string|null $preEscape Some filters may need to work on input that is already escaped or safe
|
||||
* @param string[]|null $preservesSafety Preserves the safety of the value that the filter is applied to
|
||||
* @param DeprecatedCallableInfo|null $deprecationInfo Information about the deprecation
|
||||
*/
|
||||
public function __construct(
|
||||
public string $name,
|
||||
public ?bool $needsCharset = null,
|
||||
public ?bool $needsEnvironment = null,
|
||||
public ?bool $needsContext = null,
|
||||
public ?array $isSafe = null,
|
||||
public string|array|null $isSafeCallback = null,
|
||||
public ?string $preEscape = null,
|
||||
public ?array $preservesSafety = null,
|
||||
public ?DeprecatedCallableInfo $deprecationInfo = null,
|
||||
) {
|
||||
}
|
||||
}
|
||||
52
vendor/twig/twig/src/Attribute/AsTwigFunction.php
vendored
Normal file
52
vendor/twig/twig/src/Attribute/AsTwigFunction.php
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
<?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\Attribute;
|
||||
|
||||
use Twig\DeprecatedCallableInfo;
|
||||
use Twig\TwigFunction;
|
||||
|
||||
/**
|
||||
* Registers a method as template function.
|
||||
*
|
||||
* If the first argument of the method has Twig\Environment type-hint, the function will receive the current environment.
|
||||
* Additional arguments of the method come from the function call.
|
||||
*
|
||||
* #[AsTwigFunction(name: 'foo')]
|
||||
* function fooFunction(Environment $env, string $string, $arg1 = null, ...) { ... }
|
||||
*
|
||||
* {{ foo('string', arg1) }}
|
||||
*
|
||||
* @see TwigFunction
|
||||
*/
|
||||
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
|
||||
final class AsTwigFunction
|
||||
{
|
||||
/**
|
||||
* @param non-empty-string $name The name of the function in Twig
|
||||
* @param bool|null $needsCharset Whether the function needs the charset passed as the first argument
|
||||
* @param bool|null $needsEnvironment Whether the function needs the environment passed as the first argument, or after the charset
|
||||
* @param bool|null $needsContext Whether the function needs the context array passed as the first argument, or after the charset and the environment
|
||||
* @param string[]|null $isSafe List of formats in which you want the raw output to be printed unescaped
|
||||
* @param string|array|null $isSafeCallback Function called at compilation time to determine if the function is safe
|
||||
* @param DeprecatedCallableInfo|null $deprecationInfo Information about the deprecation
|
||||
*/
|
||||
public function __construct(
|
||||
public string $name,
|
||||
public ?bool $needsCharset = null,
|
||||
public ?bool $needsEnvironment = null,
|
||||
public ?bool $needsContext = null,
|
||||
public ?array $isSafe = null,
|
||||
public string|array|null $isSafeCallback = null,
|
||||
public ?DeprecatedCallableInfo $deprecationInfo = null,
|
||||
) {
|
||||
}
|
||||
}
|
||||
48
vendor/twig/twig/src/Attribute/AsTwigTest.php
vendored
Normal file
48
vendor/twig/twig/src/Attribute/AsTwigTest.php
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
<?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\Attribute;
|
||||
|
||||
use Twig\DeprecatedCallableInfo;
|
||||
use Twig\TwigTest;
|
||||
|
||||
/**
|
||||
* Registers a method as template test.
|
||||
*
|
||||
* The first argument is the value to test and the other arguments are the
|
||||
* arguments passed to the test in the template.
|
||||
*
|
||||
* #[AsTwigTest(name: 'foo')]
|
||||
* public function fooTest($value, $arg1 = null) { ... }
|
||||
*
|
||||
* {% if value is foo(arg1) %}
|
||||
*
|
||||
* @see TwigTest
|
||||
*/
|
||||
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
|
||||
final class AsTwigTest
|
||||
{
|
||||
/**
|
||||
* @param non-empty-string $name The name of the test in Twig
|
||||
* @param bool|null $needsCharset Whether the test needs the charset passed as the first argument
|
||||
* @param bool|null $needsEnvironment Whether the test needs the environment passed as the first argument, or after the charset
|
||||
* @param bool|null $needsContext Whether the test needs the context array passed as the first argument, or after the charset and the environment
|
||||
* @param DeprecatedCallableInfo|null $deprecationInfo Information about the deprecation
|
||||
*/
|
||||
public function __construct(
|
||||
public string $name,
|
||||
public ?bool $needsCharset = null,
|
||||
public ?bool $needsEnvironment = null,
|
||||
public ?bool $needsContext = null,
|
||||
public ?DeprecatedCallableInfo $deprecationInfo = null,
|
||||
) {
|
||||
}
|
||||
}
|
||||
20
vendor/twig/twig/src/Attribute/FirstClassTwigCallableReady.php
vendored
Normal file
20
vendor/twig/twig/src/Attribute/FirstClassTwigCallableReady.php
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
<?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\Attribute;
|
||||
|
||||
/**
|
||||
* Marks nodes that are ready to accept a TwigCallable instead of its name.
|
||||
*/
|
||||
#[\Attribute(\Attribute::TARGET_METHOD)]
|
||||
final class FirstClassTwigCallableReady
|
||||
{
|
||||
}
|
||||
20
vendor/twig/twig/src/Attribute/YieldReady.php
vendored
Normal file
20
vendor/twig/twig/src/Attribute/YieldReady.php
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
<?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\Attribute;
|
||||
|
||||
/**
|
||||
* Marks nodes that are ready for using "yield" instead of "echo" or "print()" for rendering.
|
||||
*/
|
||||
#[\Attribute(\Attribute::TARGET_CLASS)]
|
||||
final class YieldReady
|
||||
{
|
||||
}
|
||||
BIN
vendor/twig/twig/src/Cache/@eaDir/CacheInterface.php@SynoEAStream
vendored
Normal file
BIN
vendor/twig/twig/src/Cache/@eaDir/CacheInterface.php@SynoEAStream
vendored
Normal file
Binary file not shown.
BIN
vendor/twig/twig/src/Cache/@eaDir/ChainCache.php@SynoEAStream
vendored
Normal file
BIN
vendor/twig/twig/src/Cache/@eaDir/ChainCache.php@SynoEAStream
vendored
Normal file
Binary file not shown.
BIN
vendor/twig/twig/src/Cache/@eaDir/FilesystemCache.php@SynoEAStream
vendored
Normal file
BIN
vendor/twig/twig/src/Cache/@eaDir/FilesystemCache.php@SynoEAStream
vendored
Normal file
Binary file not shown.
BIN
vendor/twig/twig/src/Cache/@eaDir/NullCache.php@SynoEAStream
vendored
Normal file
BIN
vendor/twig/twig/src/Cache/@eaDir/NullCache.php@SynoEAStream
vendored
Normal file
Binary file not shown.
BIN
vendor/twig/twig/src/Cache/@eaDir/ReadOnlyFilesystemCache.php@SynoEAStream
vendored
Normal file
BIN
vendor/twig/twig/src/Cache/@eaDir/ReadOnlyFilesystemCache.php@SynoEAStream
vendored
Normal file
Binary file not shown.
BIN
vendor/twig/twig/src/Cache/@eaDir/RemovableCacheInterface.php@SynoEAStream
vendored
Normal file
BIN
vendor/twig/twig/src/Cache/@eaDir/RemovableCacheInterface.php@SynoEAStream
vendored
Normal file
Binary file not shown.
46
vendor/twig/twig/src/Cache/CacheInterface.php
vendored
Normal file
46
vendor/twig/twig/src/Cache/CacheInterface.php
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
<?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\Cache;
|
||||
|
||||
/**
|
||||
* Interface implemented by cache classes.
|
||||
*
|
||||
* It is highly recommended to always store templates on the filesystem to
|
||||
* benefit from the PHP opcode cache. This interface is mostly useful if you
|
||||
* need to implement a custom strategy for storing templates on the filesystem.
|
||||
*
|
||||
* @author Andrew Tch <andrew@noop.lv>
|
||||
*/
|
||||
interface CacheInterface
|
||||
{
|
||||
/**
|
||||
* Generates a cache key for the given template class name.
|
||||
*/
|
||||
public function generateKey(string $name, string $className): string;
|
||||
|
||||
/**
|
||||
* Writes the compiled template to cache.
|
||||
*
|
||||
* @param string $content The template representation as a PHP class
|
||||
*/
|
||||
public function write(string $key, string $content): void;
|
||||
|
||||
/**
|
||||
* Loads a template from the cache.
|
||||
*/
|
||||
public function load(string $key): void;
|
||||
|
||||
/**
|
||||
* Returns the modification timestamp of a key.
|
||||
*/
|
||||
public function getTimestamp(string $key): int;
|
||||
}
|
||||
88
vendor/twig/twig/src/Cache/ChainCache.php
vendored
Normal file
88
vendor/twig/twig/src/Cache/ChainCache.php
vendored
Normal file
@@ -0,0 +1,88 @@
|
||||
<?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\Cache;
|
||||
|
||||
/**
|
||||
* Chains several caches together.
|
||||
*
|
||||
* Cached items are fetched from the first cache having them in its data store.
|
||||
* They are saved and deleted in all adapters at once.
|
||||
*
|
||||
* @author Quentin Devos <quentin@devos.pm>
|
||||
*/
|
||||
final class ChainCache implements CacheInterface, RemovableCacheInterface
|
||||
{
|
||||
/**
|
||||
* @param iterable<CacheInterface> $caches The ordered list of caches used to store and fetch cached items
|
||||
*/
|
||||
public function __construct(
|
||||
private iterable $caches,
|
||||
) {
|
||||
}
|
||||
|
||||
public function generateKey(string $name, string $className): string
|
||||
{
|
||||
return $className.'#'.$name;
|
||||
}
|
||||
|
||||
public function write(string $key, string $content): void
|
||||
{
|
||||
$splitKey = $this->splitKey($key);
|
||||
|
||||
foreach ($this->caches as $cache) {
|
||||
$cache->write($cache->generateKey(...$splitKey), $content);
|
||||
}
|
||||
}
|
||||
|
||||
public function load(string $key): void
|
||||
{
|
||||
[$name, $className] = $this->splitKey($key);
|
||||
|
||||
foreach ($this->caches as $cache) {
|
||||
$cache->load($cache->generateKey($name, $className));
|
||||
|
||||
if (class_exists($className, false)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getTimestamp(string $key): int
|
||||
{
|
||||
$splitKey = $this->splitKey($key);
|
||||
|
||||
foreach ($this->caches as $cache) {
|
||||
if (0 < $timestamp = $cache->getTimestamp($cache->generateKey(...$splitKey))) {
|
||||
return $timestamp;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function remove(string $name, string $cls): void
|
||||
{
|
||||
foreach ($this->caches as $cache) {
|
||||
if ($cache instanceof RemovableCacheInterface) {
|
||||
$cache->remove($name, $cls);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
private function splitKey(string $key): array
|
||||
{
|
||||
return array_reverse(explode('#', $key, 2));
|
||||
}
|
||||
}
|
||||
95
vendor/twig/twig/src/Cache/FilesystemCache.php
vendored
Normal file
95
vendor/twig/twig/src/Cache/FilesystemCache.php
vendored
Normal file
@@ -0,0 +1,95 @@
|
||||
<?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\Cache;
|
||||
|
||||
/**
|
||||
* Implements a cache on the filesystem.
|
||||
*
|
||||
* @author Andrew Tch <andrew@noop.lv>
|
||||
*/
|
||||
class FilesystemCache implements CacheInterface, RemovableCacheInterface
|
||||
{
|
||||
public const FORCE_BYTECODE_INVALIDATION = 1;
|
||||
|
||||
private $directory;
|
||||
private $options;
|
||||
|
||||
public function __construct(string $directory, int $options = 0)
|
||||
{
|
||||
$this->directory = rtrim($directory, '\/').'/';
|
||||
$this->options = $options;
|
||||
}
|
||||
|
||||
public function generateKey(string $name, string $className): string
|
||||
{
|
||||
$hash = hash(\PHP_VERSION_ID < 80100 ? 'sha256' : 'xxh128', $className);
|
||||
|
||||
return $this->directory.$hash[0].$hash[1].'/'.$hash.'.php';
|
||||
}
|
||||
|
||||
public function load(string $key): void
|
||||
{
|
||||
if (is_file($key)) {
|
||||
@include_once $key;
|
||||
}
|
||||
}
|
||||
|
||||
public function write(string $key, string $content): void
|
||||
{
|
||||
$dir = \dirname($key);
|
||||
if (!is_dir($dir)) {
|
||||
if (false === @mkdir($dir, 0777, true)) {
|
||||
clearstatcache(true, $dir);
|
||||
if (!is_dir($dir)) {
|
||||
throw new \RuntimeException(\sprintf('Unable to create the cache directory (%s).', $dir));
|
||||
}
|
||||
}
|
||||
} elseif (!is_writable($dir)) {
|
||||
throw new \RuntimeException(\sprintf('Unable to write in the cache directory (%s).', $dir));
|
||||
}
|
||||
|
||||
$tmpFile = tempnam($dir, basename($key));
|
||||
if (false !== @file_put_contents($tmpFile, $content) && @rename($tmpFile, $key)) {
|
||||
@chmod($key, 0666 & ~umask());
|
||||
|
||||
if (self::FORCE_BYTECODE_INVALIDATION == ($this->options & self::FORCE_BYTECODE_INVALIDATION)) {
|
||||
// Compile cached file into bytecode cache
|
||||
if (\function_exists('opcache_invalidate') && filter_var(\ini_get('opcache.enable'), \FILTER_VALIDATE_BOOLEAN)) {
|
||||
@opcache_invalidate($key, true);
|
||||
} elseif (\function_exists('apc_compile_file')) {
|
||||
apc_compile_file($key);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
throw new \RuntimeException(\sprintf('Failed to write cache file "%s".', $key));
|
||||
}
|
||||
|
||||
public function remove(string $name, string $cls): void
|
||||
{
|
||||
$key = $this->generateKey($name, $cls);
|
||||
if (!@unlink($key) && file_exists($key)) {
|
||||
throw new \RuntimeException(\sprintf('Failed to delete cache file "%s".', $key));
|
||||
}
|
||||
}
|
||||
|
||||
public function getTimestamp(string $key): int
|
||||
{
|
||||
if (!is_file($key)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return (int) @filemtime($key);
|
||||
}
|
||||
}
|
||||
42
vendor/twig/twig/src/Cache/NullCache.php
vendored
Normal file
42
vendor/twig/twig/src/Cache/NullCache.php
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
<?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\Cache;
|
||||
|
||||
/**
|
||||
* Implements a no-cache strategy.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
final class NullCache implements CacheInterface, RemovableCacheInterface
|
||||
{
|
||||
public function generateKey(string $name, string $className): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
public function write(string $key, string $content): void
|
||||
{
|
||||
}
|
||||
|
||||
public function load(string $key): void
|
||||
{
|
||||
}
|
||||
|
||||
public function getTimestamp(string $key): int
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function remove(string $name, string $cls): void
|
||||
{
|
||||
}
|
||||
}
|
||||
25
vendor/twig/twig/src/Cache/ReadOnlyFilesystemCache.php
vendored
Normal file
25
vendor/twig/twig/src/Cache/ReadOnlyFilesystemCache.php
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
<?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\Cache;
|
||||
|
||||
/**
|
||||
* Implements a cache on the filesystem that can only be read, not written to.
|
||||
*
|
||||
* @author Quentin Devos <quentin@devos.pm>
|
||||
*/
|
||||
class ReadOnlyFilesystemCache extends FilesystemCache
|
||||
{
|
||||
public function write(string $key, string $content): void
|
||||
{
|
||||
// Do nothing with the content, it's a read-only filesystem.
|
||||
}
|
||||
}
|
||||
20
vendor/twig/twig/src/Cache/RemovableCacheInterface.php
vendored
Normal file
20
vendor/twig/twig/src/Cache/RemovableCacheInterface.php
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
<?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\Cache;
|
||||
|
||||
/**
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
interface RemovableCacheInterface
|
||||
{
|
||||
public function remove(string $name, string $cls): void;
|
||||
}
|
||||
257
vendor/twig/twig/src/Compiler.php
vendored
Normal file
257
vendor/twig/twig/src/Compiler.php
vendored
Normal file
@@ -0,0 +1,257 @@
|
||||
<?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 Twig;
|
||||
|
||||
use Twig\Node\Node;
|
||||
|
||||
/**
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
class Compiler
|
||||
{
|
||||
private $lastLine;
|
||||
private $source;
|
||||
private $indentation;
|
||||
private $debugInfo = [];
|
||||
private $sourceOffset;
|
||||
private $sourceLine;
|
||||
private $varNameSalt = 0;
|
||||
private $didUseEcho = false;
|
||||
private $didUseEchoStack = [];
|
||||
|
||||
public function __construct(
|
||||
private Environment $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);
|
||||
$this->didUseEchoStack[] = $this->didUseEcho;
|
||||
|
||||
try {
|
||||
$this->didUseEcho = false;
|
||||
$node->compile($this);
|
||||
|
||||
if ($this->didUseEcho) {
|
||||
trigger_deprecation('twig/twig', '3.9', 'Using "%s" is deprecated, use "yield" instead in "%s", then flag the class with #[\Twig\Attribute\YieldReady].', $this->didUseEcho, $node::class);
|
||||
}
|
||||
|
||||
return $this;
|
||||
} finally {
|
||||
$this->didUseEcho = array_pop($this->didUseEchoStack);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function subcompile(Node $node, bool $raw = true)
|
||||
{
|
||||
if (!$raw) {
|
||||
$this->source .= str_repeat(' ', $this->indentation * 4);
|
||||
}
|
||||
|
||||
$this->didUseEchoStack[] = $this->didUseEcho;
|
||||
|
||||
try {
|
||||
$this->didUseEcho = false;
|
||||
$node->compile($this);
|
||||
|
||||
if ($this->didUseEcho) {
|
||||
trigger_deprecation('twig/twig', '3.9', 'Using "%s" is deprecated, use "yield" instead in "%s", then flag the class with #[\Twig\Attribute\YieldReady].', $this->didUseEcho, $node::class);
|
||||
}
|
||||
|
||||
return $this;
|
||||
} finally {
|
||||
$this->didUseEcho = array_pop($this->didUseEchoStack);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a raw string to the compiled code.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function raw(string $string)
|
||||
{
|
||||
$this->checkForEcho($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->checkForEcho($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, "\0\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('[');
|
||||
$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('_v%d', $this->varNameSalt++);
|
||||
}
|
||||
|
||||
private function checkForEcho(string $string): void
|
||||
{
|
||||
if ($this->didUseEcho) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->didUseEcho = preg_match('/^\s*+(echo|print)\b/', $string, $m) ? $m[1] : false;
|
||||
}
|
||||
}
|
||||
67
vendor/twig/twig/src/DeprecatedCallableInfo.php
vendored
Normal file
67
vendor/twig/twig/src/DeprecatedCallableInfo.php
vendored
Normal file
@@ -0,0 +1,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;
|
||||
|
||||
/**
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
final class DeprecatedCallableInfo
|
||||
{
|
||||
private string $type;
|
||||
private string $name;
|
||||
|
||||
public function __construct(
|
||||
private string $package,
|
||||
private string $version,
|
||||
private ?string $altName = null,
|
||||
private ?string $altPackage = null,
|
||||
private ?string $altVersion = null,
|
||||
) {
|
||||
}
|
||||
|
||||
public function setType(string $type): void
|
||||
{
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
public function setName(string $name): void
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
public function triggerDeprecation(?string $file = null, ?int $line = null): void
|
||||
{
|
||||
$message = \sprintf('Twig %s "%s" is deprecated', ucfirst($this->type), $this->name);
|
||||
|
||||
if ($this->altName) {
|
||||
$message .= \sprintf('; use "%s"', $this->altName);
|
||||
if ($this->altPackage) {
|
||||
$message .= \sprintf(' from the "%s" package', $this->altPackage);
|
||||
}
|
||||
if ($this->altVersion) {
|
||||
$message .= \sprintf(' (available since version %s)', $this->altVersion);
|
||||
}
|
||||
$message .= ' instead';
|
||||
}
|
||||
|
||||
if ($file) {
|
||||
$message .= \sprintf(' in %s', $file);
|
||||
if ($line) {
|
||||
$message .= \sprintf(' at line %d', $line);
|
||||
}
|
||||
}
|
||||
|
||||
$message .= '.';
|
||||
|
||||
trigger_deprecation($this->package, $this->version, $message);
|
||||
}
|
||||
}
|
||||
953
vendor/twig/twig/src/Environment.php
vendored
Normal file
953
vendor/twig/twig/src/Environment.php
vendored
Normal file
@@ -0,0 +1,953 @@
|
||||
<?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;
|
||||
|
||||
use Twig\Cache\CacheInterface;
|
||||
use Twig\Cache\FilesystemCache;
|
||||
use Twig\Cache\NullCache;
|
||||
use Twig\Cache\RemovableCacheInterface;
|
||||
use Twig\Error\Error;
|
||||
use Twig\Error\LoaderError;
|
||||
use Twig\Error\RuntimeError;
|
||||
use Twig\Error\SyntaxError;
|
||||
use Twig\ExpressionParser\ExpressionParsers;
|
||||
use Twig\Extension\CoreExtension;
|
||||
use Twig\Extension\EscaperExtension;
|
||||
use Twig\Extension\ExtensionInterface;
|
||||
use Twig\Extension\OptimizerExtension;
|
||||
use Twig\Extension\YieldNotReadyExtension;
|
||||
use Twig\Loader\ArrayLoader;
|
||||
use Twig\Loader\ChainLoader;
|
||||
use Twig\Loader\LoaderInterface;
|
||||
use Twig\Node\ModuleNode;
|
||||
use Twig\Node\Node;
|
||||
use Twig\NodeVisitor\NodeVisitorInterface;
|
||||
use Twig\Runtime\EscaperRuntime;
|
||||
use Twig\RuntimeLoader\FactoryRuntimeLoader;
|
||||
use Twig\RuntimeLoader\RuntimeLoaderInterface;
|
||||
use Twig\TokenParser\TokenParserInterface;
|
||||
|
||||
/**
|
||||
* Stores the Twig configuration and renders templates.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
class Environment
|
||||
{
|
||||
public const VERSION = '3.23.0';
|
||||
public const VERSION_ID = 32300;
|
||||
public const MAJOR_VERSION = 3;
|
||||
public const MINOR_VERSION = 23;
|
||||
public const RELEASE_VERSION = 0;
|
||||
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 $originalCache;
|
||||
private $extensionSet;
|
||||
private $runtimeLoaders = [];
|
||||
private $runtimes = [];
|
||||
private $optionsHash;
|
||||
/** @var bool */
|
||||
private $useYield;
|
||||
private $defaultRuntimeLoader;
|
||||
private array $hotCache = [];
|
||||
|
||||
/**
|
||||
* 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).
|
||||
*
|
||||
* * use_yield: true: forces templates to exclusively use "yield" instead of "echo" (all extensions must be yield ready)
|
||||
* false (default): allows templates to use a mix of "yield" and "echo" calls to allow for a progressive migration
|
||||
* Switch to "true" when possible as this will be the only supported mode in Twig 4.0
|
||||
*/
|
||||
public function __construct(LoaderInterface $loader, array $options = [])
|
||||
{
|
||||
$this->setLoader($loader);
|
||||
|
||||
$options = array_merge([
|
||||
'debug' => false,
|
||||
'charset' => 'UTF-8',
|
||||
'strict_variables' => false,
|
||||
'autoescape' => 'html',
|
||||
'cache' => false,
|
||||
'auto_reload' => null,
|
||||
'optimizations' => -1,
|
||||
'use_yield' => false,
|
||||
], $options);
|
||||
|
||||
$this->useYield = (bool) $options['use_yield'];
|
||||
$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->defaultRuntimeLoader = new FactoryRuntimeLoader([
|
||||
EscaperRuntime::class => function () { return new EscaperRuntime($this->charset); },
|
||||
]);
|
||||
|
||||
$this->addExtension(new CoreExtension());
|
||||
$escaperExt = new EscaperExtension($options['autoescape']);
|
||||
$escaperExt->setEnvironment($this, false);
|
||||
$this->addExtension($escaperExt);
|
||||
if (\PHP_VERSION_ID >= 80000) {
|
||||
$this->addExtension(new YieldNotReadyExtension($this->useYield));
|
||||
}
|
||||
$this->addExtension(new OptimizerExtension($options['optimizations']));
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public function useYield(): bool
|
||||
{
|
||||
return $this->useYield;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables debugging mode.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function enableDebug()
|
||||
{
|
||||
$this->debug = true;
|
||||
$this->updateOptionsHash();
|
||||
}
|
||||
|
||||
/**
|
||||
* Disables debugging mode.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
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.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function enableAutoReload()
|
||||
{
|
||||
$this->autoReload = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disables the auto_reload option.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
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.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function enableStrictVariables()
|
||||
{
|
||||
$this->strictVariables = true;
|
||||
$this->updateOptionsHash();
|
||||
}
|
||||
|
||||
/**
|
||||
* Disables the strict_variables option.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
public function removeCache(string $name): void
|
||||
{
|
||||
$cls = $this->getTemplateClass($name);
|
||||
$this->hotCache[$name] = $cls.'_'.bin2hex(random_bytes(16));
|
||||
|
||||
if ($this->cache instanceof RemovableCacheInterface) {
|
||||
$this->cache->remove($name, $cls);
|
||||
} else {
|
||||
throw new \LogicException(\sprintf('The "%s" cache class does not support removing template cache as it does not implement the "RemovableCacheInterface" interface.', \get_class($this->cache)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
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;
|
||||
* * 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->hotCache[$name] ?? $this->getLoader()->getCacheKey($name)).$this->optionsHash;
|
||||
|
||||
return '__TwigTemplate_'.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;
|
||||
}
|
||||
if ($name instanceof Template) {
|
||||
trigger_deprecation('twig/twig', '3.9', 'Passing a "%s" instance to "%s" is deprecated.', self::class, __METHOD__);
|
||||
|
||||
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|null $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);
|
||||
}
|
||||
|
||||
if (!class_exists($cls, false)) {
|
||||
$source = $this->getLoader()->getSourceContext($name);
|
||||
$content = $this->compileSource($source);
|
||||
if (!isset($this->hotCache[$name])) {
|
||||
$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|null $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\TemplateWrapper
|
||||
* and an array of templates where each is tried to be loaded.
|
||||
*
|
||||
* @param string|TemplateWrapper|array<string|TemplateWrapper> $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) {
|
||||
trigger_deprecation('twig/twig', '3.9', 'Passing a "%s" instance to "%s" is deprecated.', Template::class, __METHOD__);
|
||||
|
||||
return new TemplateWrapper($this, $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)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function setLoader(LoaderInterface $loader)
|
||||
{
|
||||
$this->loader = $loader;
|
||||
}
|
||||
|
||||
public function getLoader(): LoaderInterface
|
||||
{
|
||||
return $this->loader;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function setCharset(string $charset)
|
||||
{
|
||||
if ('UTF8' === $charset = 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
if (null !== $runtime = $this->defaultRuntimeLoader->load($class)) {
|
||||
return $this->runtimes[$class] = $runtime;
|
||||
}
|
||||
|
||||
throw new RuntimeError(\sprintf('Unable to load the "%s" runtime.', $class));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function addExtension(ExtensionInterface $extension)
|
||||
{
|
||||
$this->extensionSet->addExtension($extension);
|
||||
$this->updateOptionsHash();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ExtensionInterface[] $extensions An array of extensions
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
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();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param callable(string): (TokenParserInterface|false) $callable
|
||||
*/
|
||||
public function registerUndefinedTokenParserCallback(callable $callable): void
|
||||
{
|
||||
$this->extensionSet->registerUndefinedTokenParserCallback($callable);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function addNodeVisitor(NodeVisitorInterface $visitor)
|
||||
{
|
||||
$this->extensionSet->addNodeVisitor($visitor);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return NodeVisitorInterface[]
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
public function getNodeVisitors(): array
|
||||
{
|
||||
return $this->extensionSet->getNodeVisitors();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function addFilter(TwigFilter $filter)
|
||||
{
|
||||
$this->extensionSet->addFilter($filter);
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public function getFilter(string $name): ?TwigFilter
|
||||
{
|
||||
return $this->extensionSet->getFilter($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param callable(string): (TwigFilter|false) $callable
|
||||
*/
|
||||
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();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param callable(string): (TwigTest|false) $callable
|
||||
*/
|
||||
public function registerUndefinedTestCallback(callable $callable): void
|
||||
{
|
||||
$this->extensionSet->registerUndefinedTestCallback($callable);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function addFunction(TwigFunction $function)
|
||||
{
|
||||
$this->extensionSet->addFunction($function);
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public function getFunction(string $name): ?TwigFunction
|
||||
{
|
||||
return $this->extensionSet->getFunction($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param callable(string): (TwigFunction|false) $callable
|
||||
*/
|
||||
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
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @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 resetGlobals(): void
|
||||
{
|
||||
$this->resolvedGlobals = null;
|
||||
$this->extensionSet->resetGlobals();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since Twig 3.14
|
||||
*/
|
||||
public function mergeGlobals(array $context): array
|
||||
{
|
||||
trigger_deprecation('twig/twig', '3.14', 'The "%s" method is deprecated.', __METHOD__);
|
||||
|
||||
return $context + $this->getGlobals();
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public function getExpressionParsers(): ExpressionParsers
|
||||
{
|
||||
return $this->extensionSet->getExpressionParsers();
|
||||
}
|
||||
|
||||
private function updateOptionsHash(): void
|
||||
{
|
||||
$this->optionsHash = implode(':', [
|
||||
$this->extensionSet->getSignature(),
|
||||
\PHP_MAJOR_VERSION,
|
||||
\PHP_MINOR_VERSION,
|
||||
self::VERSION,
|
||||
(int) $this->debug,
|
||||
(int) $this->strictVariables,
|
||||
$this->useYield ? '1' : '0',
|
||||
]);
|
||||
}
|
||||
}
|
||||
BIN
vendor/twig/twig/src/Error/@eaDir/Error.php@SynoEAStream
vendored
Normal file
BIN
vendor/twig/twig/src/Error/@eaDir/Error.php@SynoEAStream
vendored
Normal file
Binary file not shown.
BIN
vendor/twig/twig/src/Error/@eaDir/LoaderError.php@SynoEAStream
vendored
Normal file
BIN
vendor/twig/twig/src/Error/@eaDir/LoaderError.php@SynoEAStream
vendored
Normal file
Binary file not shown.
BIN
vendor/twig/twig/src/Error/@eaDir/RuntimeError.php@SynoEAStream
vendored
Normal file
BIN
vendor/twig/twig/src/Error/@eaDir/RuntimeError.php@SynoEAStream
vendored
Normal file
Binary file not shown.
BIN
vendor/twig/twig/src/Error/@eaDir/SyntaxError.php@SynoEAStream
vendored
Normal file
BIN
vendor/twig/twig/src/Error/@eaDir/SyntaxError.php@SynoEAStream
vendored
Normal file
Binary file not shown.
182
vendor/twig/twig/src/Error/Error.php
vendored
Normal file
182
vendor/twig/twig/src/Error/Error.php
vendored
Normal file
@@ -0,0 +1,182 @@
|
||||
<?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\Error;
|
||||
|
||||
use Twig\Source;
|
||||
use Twig\Template;
|
||||
|
||||
/**
|
||||
* Twig base exception.
|
||||
*
|
||||
* This exception class and its children must only be used when
|
||||
* an error occurs during the loading of a template, when a syntax error
|
||||
* is detected in a template, or when rendering a template. Other
|
||||
* errors must use regular PHP exception classes (like when the template
|
||||
* cache directory is not writable for instance).
|
||||
*
|
||||
* To help debugging template issues, this class tracks the original template
|
||||
* name and line where the error occurred.
|
||||
*
|
||||
* Whenever possible, you must set these information (original template name
|
||||
* and line number) yourself by passing them to the constructor. If some or all
|
||||
* these information are not available from where you throw the exception, then
|
||||
* this class will guess them automatically.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
class Error extends \Exception
|
||||
{
|
||||
private $lineno;
|
||||
private $rawMessage;
|
||||
private ?Source $source;
|
||||
private string $phpFile;
|
||||
private int $phpLine;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* By default, automatic guessing is enabled.
|
||||
*
|
||||
* @param string $message The error message
|
||||
* @param int $lineno The template line where the error occurred
|
||||
* @param Source|null $source The source context where the error occurred
|
||||
*/
|
||||
public function __construct(string $message, int $lineno = -1, ?Source $source = null, ?\Throwable $previous = null)
|
||||
{
|
||||
parent::__construct('', 0, $previous);
|
||||
|
||||
$this->phpFile = $this->getFile();
|
||||
$this->phpLine = $this->getLine();
|
||||
$this->lineno = $lineno;
|
||||
$this->source = $source;
|
||||
$this->rawMessage = $message;
|
||||
$this->updateRepr();
|
||||
}
|
||||
|
||||
public function getRawMessage(): string
|
||||
{
|
||||
return $this->rawMessage;
|
||||
}
|
||||
|
||||
public function getTemplateLine(): int
|
||||
{
|
||||
return $this->lineno;
|
||||
}
|
||||
|
||||
public function setTemplateLine(int $lineno): void
|
||||
{
|
||||
$this->lineno = $lineno;
|
||||
$this->updateRepr();
|
||||
}
|
||||
|
||||
public function getSourceContext(): ?Source
|
||||
{
|
||||
return $this->source;
|
||||
}
|
||||
|
||||
public function setSourceContext(?Source $source = null): void
|
||||
{
|
||||
$this->source = $source;
|
||||
$this->updateRepr();
|
||||
}
|
||||
|
||||
public function guess(): void
|
||||
{
|
||||
if ($this->lineno > -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->guessTemplateInfo();
|
||||
$this->updateRepr();
|
||||
}
|
||||
|
||||
public function appendMessage($rawMessage): void
|
||||
{
|
||||
$this->rawMessage .= $rawMessage;
|
||||
$this->updateRepr();
|
||||
}
|
||||
|
||||
private function updateRepr(): void
|
||||
{
|
||||
if ($this->source && $this->source->getPath()) {
|
||||
// we only update the file and the line together
|
||||
$this->file = $this->source->getPath();
|
||||
if ($this->lineno > 0) {
|
||||
$this->line = $this->lineno;
|
||||
} else {
|
||||
$this->line = -1;
|
||||
}
|
||||
}
|
||||
|
||||
$this->message = $this->rawMessage;
|
||||
$last = substr($this->message, -1);
|
||||
if ($punctuation = '.' === $last || '?' === $last ? $last : '') {
|
||||
$this->message = substr($this->message, 0, -1);
|
||||
}
|
||||
if ($this->source && $this->source->getName()) {
|
||||
$this->message .= \sprintf(' in "%s"', $this->source->getName());
|
||||
}
|
||||
if ($this->lineno > 0) {
|
||||
$this->message .= \sprintf(' at line %d', $this->lineno);
|
||||
}
|
||||
if ($punctuation) {
|
||||
$this->message .= $punctuation;
|
||||
}
|
||||
}
|
||||
|
||||
private function guessTemplateInfo(): void
|
||||
{
|
||||
// $this->source is never null here (see guess() usage in Template)
|
||||
|
||||
$this->lineno = 0;
|
||||
$template = null;
|
||||
$backtrace = debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS | \DEBUG_BACKTRACE_PROVIDE_OBJECT);
|
||||
foreach ($backtrace as $trace) {
|
||||
if (isset($trace['object']) && $trace['object'] instanceof Template && $this->source->getName() === $trace['object']->getTemplateName()) {
|
||||
$template = $trace['object'];
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (null === $template) {
|
||||
return; // Impossible to guess the info as the template was not found in the backtrace
|
||||
}
|
||||
|
||||
$r = new \ReflectionObject($template);
|
||||
$file = $r->getFileName();
|
||||
|
||||
$exceptions = [$e = $this];
|
||||
while ($e = $e->getPrevious()) {
|
||||
$exceptions[] = $e;
|
||||
}
|
||||
|
||||
while ($e = array_pop($exceptions)) {
|
||||
$traces = $e->getTrace();
|
||||
array_unshift($traces, ['file' => $e instanceof self ? $e->phpFile : $e->getFile(), 'line' => $e instanceof self ? $e->phpLine : $e->getLine()]);
|
||||
while ($trace = array_shift($traces)) {
|
||||
if (!isset($trace['file']) || !isset($trace['line']) || $file != $trace['file']) {
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ($template->getDebugInfo() as $codeLine => $templateLine) {
|
||||
if ($codeLine <= $trace['line']) {
|
||||
// update template line
|
||||
$this->lineno = $templateLine;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
21
vendor/twig/twig/src/Error/LoaderError.php
vendored
Normal file
21
vendor/twig/twig/src/Error/LoaderError.php
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
<?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\Error;
|
||||
|
||||
/**
|
||||
* Exception thrown when an error occurs during template loading.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
class LoaderError extends Error
|
||||
{
|
||||
}
|
||||
22
vendor/twig/twig/src/Error/RuntimeError.php
vendored
Normal file
22
vendor/twig/twig/src/Error/RuntimeError.php
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
<?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 Twig\Error;
|
||||
|
||||
/**
|
||||
* Exception thrown when an error occurs at runtime.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
class RuntimeError extends Error
|
||||
{
|
||||
}
|
||||
46
vendor/twig/twig/src/Error/SyntaxError.php
vendored
Normal file
46
vendor/twig/twig/src/Error/SyntaxError.php
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
<?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 Twig\Error;
|
||||
|
||||
/**
|
||||
* \Exception thrown when a syntax error occurs during lexing or parsing of a template.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
class SyntaxError extends Error
|
||||
{
|
||||
/**
|
||||
* Tweaks the error message to include suggestions.
|
||||
*
|
||||
* @param string $name The original name of the item that does not exist
|
||||
* @param array $items An array of possible items
|
||||
*/
|
||||
public function addSuggestions(string $name, array $items): void
|
||||
{
|
||||
$alternatives = [];
|
||||
foreach ($items as $item) {
|
||||
$lev = levenshtein($name, $item);
|
||||
if ($lev <= \strlen($name) / 3 || str_contains($item, $name)) {
|
||||
$alternatives[$item] = $lev;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$alternatives) {
|
||||
return;
|
||||
}
|
||||
|
||||
asort($alternatives);
|
||||
|
||||
$this->appendMessage(\sprintf(' Did you mean "%s"?', implode('", "', array_keys($alternatives))));
|
||||
}
|
||||
}
|
||||
369
vendor/twig/twig/src/ExpressionParser.php
vendored
Normal file
369
vendor/twig/twig/src/ExpressionParser.php
vendored
Normal file
@@ -0,0 +1,369 @@
|
||||
<?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 Twig;
|
||||
|
||||
use Twig\Error\SyntaxError;
|
||||
use Twig\ExpressionParser\Infix\DotExpressionParser;
|
||||
use Twig\ExpressionParser\Infix\FilterExpressionParser;
|
||||
use Twig\ExpressionParser\Infix\SquareBracketExpressionParser;
|
||||
use Twig\Node\Expression\ArrayExpression;
|
||||
use Twig\Node\Expression\ConstantExpression;
|
||||
use Twig\Node\Expression\Unary\NegUnary;
|
||||
use Twig\Node\Expression\Unary\PosUnary;
|
||||
use Twig\Node\Expression\Unary\SpreadUnary;
|
||||
use Twig\Node\Expression\Variable\AssignContextVariable;
|
||||
use Twig\Node\Expression\Variable\ContextVariable;
|
||||
use Twig\Node\Node;
|
||||
use Twig\Node\Nodes;
|
||||
|
||||
/**
|
||||
* Parses expressions.
|
||||
*
|
||||
* This parser implements a "Precedence climbing" algorithm.
|
||||
*
|
||||
* @see https://www.engr.mun.ca/~theo/Misc/exp_parsing.htm
|
||||
* @see https://en.wikipedia.org/wiki/Operator-precedence_parser
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @deprecated since Twig 3.21
|
||||
*/
|
||||
class ExpressionParser
|
||||
{
|
||||
/**
|
||||
* @deprecated since Twig 3.21
|
||||
*/
|
||||
public const OPERATOR_LEFT = 1;
|
||||
/**
|
||||
* @deprecated since Twig 3.21
|
||||
*/
|
||||
public const OPERATOR_RIGHT = 2;
|
||||
|
||||
public function __construct(
|
||||
private Parser $parser,
|
||||
private Environment $env,
|
||||
) {
|
||||
trigger_deprecation('twig/twig', '3.21', 'Class "%s" is deprecated, use "Parser::parseExpression()" instead.', __CLASS__);
|
||||
}
|
||||
|
||||
public function parseExpression($precedence = 0)
|
||||
{
|
||||
if (\func_num_args() > 1) {
|
||||
trigger_deprecation('twig/twig', '3.15', 'Passing a second argument ($allowArrow) to "%s()" is deprecated.', __METHOD__);
|
||||
}
|
||||
|
||||
trigger_deprecation('twig/twig', '3.21', 'The "%s()" method is deprecated, use "Parser::parseExpression()" instead.', __METHOD__);
|
||||
|
||||
return $this->parser->parseExpression((int) $precedence);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since Twig 3.21
|
||||
*/
|
||||
public function parsePrimaryExpression()
|
||||
{
|
||||
trigger_deprecation('twig/twig', '3.21', 'The "%s()" method is deprecated.', __METHOD__);
|
||||
|
||||
return $this->parseExpression();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since Twig 3.21
|
||||
*/
|
||||
public function parseStringExpression()
|
||||
{
|
||||
trigger_deprecation('twig/twig', '3.21', 'The "%s()" method is deprecated.', __METHOD__);
|
||||
|
||||
return $this->parseExpression();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since Twig 3.11, use parseExpression() instead
|
||||
*/
|
||||
public function parseArrayExpression()
|
||||
{
|
||||
trigger_deprecation('twig/twig', '3.11', 'Calling "%s()" is deprecated, use "parseExpression()" instead.', __METHOD__);
|
||||
|
||||
return $this->parseExpression();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since Twig 3.21
|
||||
*/
|
||||
public function parseSequenceExpression()
|
||||
{
|
||||
trigger_deprecation('twig/twig', '3.21', 'The "%s()" method is deprecated.', __METHOD__);
|
||||
|
||||
return $this->parseExpression();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since Twig 3.11, use parseExpression() instead
|
||||
*/
|
||||
public function parseHashExpression()
|
||||
{
|
||||
trigger_deprecation('twig/twig', '3.11', 'Calling "%s()" is deprecated, use "parseExpression()" instead.', __METHOD__);
|
||||
|
||||
return $this->parseExpression();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since Twig 3.21
|
||||
*/
|
||||
public function parseMappingExpression()
|
||||
{
|
||||
trigger_deprecation('twig/twig', '3.21', 'The "%s()" method is deprecated.', __METHOD__);
|
||||
|
||||
return $this->parseExpression();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since Twig 3.21
|
||||
*/
|
||||
public function parsePostfixExpression($node)
|
||||
{
|
||||
trigger_deprecation('twig/twig', '3.21', 'The "%s()" method is deprecated.', __METHOD__);
|
||||
|
||||
while (true) {
|
||||
$token = $this->parser->getCurrentToken();
|
||||
if ($token->test(Token::PUNCTUATION_TYPE)) {
|
||||
if ('.' == $token->getValue() || '[' == $token->getValue()) {
|
||||
$node = $this->parseSubscriptExpression($node);
|
||||
} elseif ('|' == $token->getValue()) {
|
||||
$node = $this->parseFilterExpression($node);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $node;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since Twig 3.21
|
||||
*/
|
||||
public function parseSubscriptExpression($node)
|
||||
{
|
||||
trigger_deprecation('twig/twig', '3.21', 'The "%s()" method is deprecated.', __METHOD__);
|
||||
|
||||
$parsers = new \ReflectionProperty($this->parser, 'parsers');
|
||||
|
||||
if ('.' === $this->parser->getStream()->next()->getValue()) {
|
||||
return $parsers->getValue($this->parser)->getByClass(DotExpressionParser::class)->parse($this->parser, $node, $this->parser->getCurrentToken());
|
||||
}
|
||||
|
||||
return $parsers->getValue($this->parser)->getByClass(SquareBracketExpressionParser::class)->parse($this->parser, $node, $this->parser->getCurrentToken());
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since Twig 3.21
|
||||
*/
|
||||
public function parseFilterExpression($node)
|
||||
{
|
||||
trigger_deprecation('twig/twig', '3.21', 'The "%s()" method is deprecated.', __METHOD__);
|
||||
|
||||
$this->parser->getStream()->next();
|
||||
|
||||
return $this->parseFilterExpressionRaw($node);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since Twig 3.21
|
||||
*/
|
||||
public function parseFilterExpressionRaw($node)
|
||||
{
|
||||
trigger_deprecation('twig/twig', '3.21', 'The "%s()" method is deprecated.', __METHOD__);
|
||||
|
||||
$parsers = new \ReflectionProperty($this->parser, 'parsers');
|
||||
|
||||
$op = $parsers->getValue($this->parser)->getByClass(FilterExpressionParser::class);
|
||||
while (true) {
|
||||
$node = $op->parse($this->parser, $node, $this->parser->getCurrentToken());
|
||||
if (!$this->parser->getStream()->test(Token::OPERATOR_TYPE, '|')) {
|
||||
break;
|
||||
}
|
||||
$this->parser->getStream()->next();
|
||||
}
|
||||
|
||||
return $node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses arguments.
|
||||
*
|
||||
* @return Node
|
||||
*
|
||||
* @throws SyntaxError
|
||||
*
|
||||
* @deprecated since Twig 3.19 Use Twig\ExpressionParser\Infix\ArgumentsTrait::parseNamedArguments() instead
|
||||
*/
|
||||
public function parseArguments()
|
||||
{
|
||||
trigger_deprecation('twig/twig', '3.19', \sprintf('The "%s()" method is deprecated, use "Twig\ExpressionParser\Infix\ArgumentsTrait::parseNamedArguments()" instead.', __METHOD__));
|
||||
|
||||
$parsePrimaryExpression = new \ReflectionMethod($this->parser, 'parsePrimaryExpression');
|
||||
|
||||
$namedArguments = false;
|
||||
$definition = false;
|
||||
if (\func_num_args() > 1) {
|
||||
$definition = func_get_arg(1);
|
||||
}
|
||||
if (\func_num_args() > 0) {
|
||||
trigger_deprecation('twig/twig', '3.15', 'Passing arguments to "%s()" is deprecated.', __METHOD__);
|
||||
$namedArguments = func_get_arg(0);
|
||||
}
|
||||
|
||||
$args = [];
|
||||
$stream = $this->parser->getStream();
|
||||
|
||||
$stream->expect(Token::OPERATOR_TYPE, '(', 'A list of arguments must begin with an opening parenthesis');
|
||||
$hasSpread = false;
|
||||
while (!$stream->test(Token::PUNCTUATION_TYPE, ')')) {
|
||||
if ($args) {
|
||||
$stream->expect(Token::PUNCTUATION_TYPE, ',', 'Arguments must be separated by a comma');
|
||||
|
||||
// if the comma above was a trailing comma, early exit the argument parse loop
|
||||
if ($stream->test(Token::PUNCTUATION_TYPE, ')')) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($definition) {
|
||||
$token = $stream->expect(Token::NAME_TYPE, null, 'An argument must be a name');
|
||||
$value = new ContextVariable($token->getValue(), $this->parser->getCurrentToken()->getLine());
|
||||
} else {
|
||||
if ($stream->nextIf(Token::SPREAD_TYPE)) {
|
||||
$hasSpread = true;
|
||||
$value = new SpreadUnary($this->parseExpression(), $stream->getCurrent()->getLine());
|
||||
} elseif ($hasSpread) {
|
||||
throw new SyntaxError('Normal arguments must be placed before argument unpacking.', $stream->getCurrent()->getLine(), $stream->getSourceContext());
|
||||
} else {
|
||||
$value = $this->parseExpression();
|
||||
}
|
||||
}
|
||||
|
||||
$name = null;
|
||||
if ($namedArguments && (($token = $stream->nextIf(Token::OPERATOR_TYPE, '=')) || (!$definition && $token = $stream->nextIf(Token::PUNCTUATION_TYPE, ':')))) {
|
||||
if (!$value instanceof ContextVariable) {
|
||||
throw new SyntaxError(\sprintf('A parameter name must be a string, "%s" given.', $value::class), $token->getLine(), $stream->getSourceContext());
|
||||
}
|
||||
$name = $value->getAttribute('name');
|
||||
|
||||
if ($definition) {
|
||||
$value = $parsePrimaryExpression->invoke($this->parser);
|
||||
|
||||
if (!$this->checkConstantExpression($value)) {
|
||||
throw new SyntaxError('A default value for an argument must be a constant (a boolean, a string, a number, a sequence, or a mapping).', $token->getLine(), $stream->getSourceContext());
|
||||
}
|
||||
} else {
|
||||
$value = $this->parseExpression();
|
||||
}
|
||||
}
|
||||
|
||||
if ($definition) {
|
||||
if (null === $name) {
|
||||
$name = $value->getAttribute('name');
|
||||
$value = new ConstantExpression(null, $this->parser->getCurrentToken()->getLine());
|
||||
$value->setAttribute('is_implicit', true);
|
||||
}
|
||||
$args[$name] = $value;
|
||||
} else {
|
||||
if (null === $name) {
|
||||
$args[] = $value;
|
||||
} else {
|
||||
$args[$name] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
$stream->expect(Token::PUNCTUATION_TYPE, ')', 'A list of arguments must be closed by a parenthesis');
|
||||
|
||||
return new Nodes($args);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since Twig 3.21, use "AbstractTokenParser::parseAssignmentExpression()" instead
|
||||
*/
|
||||
public function parseAssignmentExpression()
|
||||
{
|
||||
trigger_deprecation('twig/twig', '3.21', 'The "%s()" method is deprecated, use "AbstractTokenParser::parseAssignmentExpression()" instead.', __METHOD__);
|
||||
|
||||
$stream = $this->parser->getStream();
|
||||
$targets = [];
|
||||
while (true) {
|
||||
$token = $this->parser->getCurrentToken();
|
||||
if ($stream->test(Token::OPERATOR_TYPE) && preg_match(Lexer::REGEX_NAME, $token->getValue())) {
|
||||
// in this context, string operators are variable names
|
||||
$this->parser->getStream()->next();
|
||||
} else {
|
||||
$stream->expect(Token::NAME_TYPE, null, 'Only variables can be assigned to');
|
||||
}
|
||||
$targets[] = new AssignContextVariable($token->getValue(), $token->getLine());
|
||||
|
||||
if (!$stream->nextIf(Token::PUNCTUATION_TYPE, ',')) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return new Nodes($targets);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since Twig 3.21
|
||||
*/
|
||||
public function parseMultitargetExpression()
|
||||
{
|
||||
trigger_deprecation('twig/twig', '3.21', 'The "%s()" method is deprecated.', __METHOD__);
|
||||
|
||||
$targets = [];
|
||||
while (true) {
|
||||
$targets[] = $this->parseExpression();
|
||||
if (!$this->parser->getStream()->nextIf(Token::PUNCTUATION_TYPE, ',')) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return new Nodes($targets);
|
||||
}
|
||||
|
||||
// checks that the node only contains "constant" elements
|
||||
// to be removed in 4.0
|
||||
private function checkConstantExpression(Node $node): bool
|
||||
{
|
||||
if (!($node instanceof ConstantExpression || $node instanceof ArrayExpression
|
||||
|| $node instanceof NegUnary || $node instanceof PosUnary
|
||||
)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($node as $n) {
|
||||
if (!$this->checkConstantExpression($n)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since Twig 3.19 Use Twig\ExpressionParser\Infix\ArgumentsTrait::parseNamedArguments() instead
|
||||
*/
|
||||
public function parseOnlyArguments()
|
||||
{
|
||||
trigger_deprecation('twig/twig', '3.19', \sprintf('The "%s()" method is deprecated, use "Twig\ExpressionParser\Infix\ArgumentsTrait::parseNamedArguments()" instead.', __METHOD__));
|
||||
|
||||
return $this->parseArguments();
|
||||
}
|
||||
}
|
||||
BIN
vendor/twig/twig/src/ExpressionParser/@eaDir/AbstractExpressionParser.php@SynoEAStream
vendored
Normal file
BIN
vendor/twig/twig/src/ExpressionParser/@eaDir/AbstractExpressionParser.php@SynoEAStream
vendored
Normal file
Binary file not shown.
BIN
vendor/twig/twig/src/ExpressionParser/@eaDir/ExpressionParserDescriptionInterface.php@SynoEAStream
vendored
Normal file
BIN
vendor/twig/twig/src/ExpressionParser/@eaDir/ExpressionParserDescriptionInterface.php@SynoEAStream
vendored
Normal file
Binary file not shown.
BIN
vendor/twig/twig/src/ExpressionParser/@eaDir/ExpressionParserInterface.php@SynoEAStream
vendored
Normal file
BIN
vendor/twig/twig/src/ExpressionParser/@eaDir/ExpressionParserInterface.php@SynoEAStream
vendored
Normal file
Binary file not shown.
BIN
vendor/twig/twig/src/ExpressionParser/@eaDir/ExpressionParserType.php@SynoEAStream
vendored
Normal file
BIN
vendor/twig/twig/src/ExpressionParser/@eaDir/ExpressionParserType.php@SynoEAStream
vendored
Normal file
Binary file not shown.
BIN
vendor/twig/twig/src/ExpressionParser/@eaDir/ExpressionParsers.php@SynoEAStream
vendored
Normal file
BIN
vendor/twig/twig/src/ExpressionParser/@eaDir/ExpressionParsers.php@SynoEAStream
vendored
Normal file
Binary file not shown.
BIN
vendor/twig/twig/src/ExpressionParser/@eaDir/Infix@SynoEAStream
vendored
Normal file
BIN
vendor/twig/twig/src/ExpressionParser/@eaDir/Infix@SynoEAStream
vendored
Normal file
Binary file not shown.
BIN
vendor/twig/twig/src/ExpressionParser/@eaDir/InfixAssociativity.php@SynoEAStream
vendored
Normal file
BIN
vendor/twig/twig/src/ExpressionParser/@eaDir/InfixAssociativity.php@SynoEAStream
vendored
Normal file
Binary file not shown.
BIN
vendor/twig/twig/src/ExpressionParser/@eaDir/InfixExpressionParserInterface.php@SynoEAStream
vendored
Normal file
BIN
vendor/twig/twig/src/ExpressionParser/@eaDir/InfixExpressionParserInterface.php@SynoEAStream
vendored
Normal file
Binary file not shown.
BIN
vendor/twig/twig/src/ExpressionParser/@eaDir/PrecedenceChange.php@SynoEAStream
vendored
Normal file
BIN
vendor/twig/twig/src/ExpressionParser/@eaDir/PrecedenceChange.php@SynoEAStream
vendored
Normal file
Binary file not shown.
BIN
vendor/twig/twig/src/ExpressionParser/@eaDir/Prefix@SynoEAStream
vendored
Normal file
BIN
vendor/twig/twig/src/ExpressionParser/@eaDir/Prefix@SynoEAStream
vendored
Normal file
Binary file not shown.
BIN
vendor/twig/twig/src/ExpressionParser/@eaDir/PrefixExpressionParserInterface.php@SynoEAStream
vendored
Normal file
BIN
vendor/twig/twig/src/ExpressionParser/@eaDir/PrefixExpressionParserInterface.php@SynoEAStream
vendored
Normal file
Binary file not shown.
30
vendor/twig/twig/src/ExpressionParser/AbstractExpressionParser.php
vendored
Normal file
30
vendor/twig/twig/src/ExpressionParser/AbstractExpressionParser.php
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
<?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\ExpressionParser;
|
||||
|
||||
abstract class AbstractExpressionParser implements ExpressionParserInterface
|
||||
{
|
||||
public function __toString(): string
|
||||
{
|
||||
return \sprintf('%s(%s)', ExpressionParserType::getType($this)->value, $this->getName());
|
||||
}
|
||||
|
||||
public function getPrecedenceChange(): ?PrecedenceChange
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getAliases(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
17
vendor/twig/twig/src/ExpressionParser/ExpressionParserDescriptionInterface.php
vendored
Normal file
17
vendor/twig/twig/src/ExpressionParser/ExpressionParserDescriptionInterface.php
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
<?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\ExpressionParser;
|
||||
|
||||
interface ExpressionParserDescriptionInterface
|
||||
{
|
||||
public function getDescription(): string;
|
||||
}
|
||||
28
vendor/twig/twig/src/ExpressionParser/ExpressionParserInterface.php
vendored
Normal file
28
vendor/twig/twig/src/ExpressionParser/ExpressionParserInterface.php
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
<?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\ExpressionParser;
|
||||
|
||||
interface ExpressionParserInterface
|
||||
{
|
||||
public function __toString(): string;
|
||||
|
||||
public function getName(): string;
|
||||
|
||||
public function getPrecedence(): int;
|
||||
|
||||
public function getPrecedenceChange(): ?PrecedenceChange;
|
||||
|
||||
/**
|
||||
* @return array<string>
|
||||
*/
|
||||
public function getAliases(): array;
|
||||
}
|
||||
33
vendor/twig/twig/src/ExpressionParser/ExpressionParserType.php
vendored
Normal file
33
vendor/twig/twig/src/ExpressionParser/ExpressionParserType.php
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
<?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\ExpressionParser;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
enum ExpressionParserType: string
|
||||
{
|
||||
case Prefix = 'prefix';
|
||||
case Infix = 'infix';
|
||||
|
||||
public static function getType(object $object): ExpressionParserType
|
||||
{
|
||||
if ($object instanceof PrefixExpressionParserInterface) {
|
||||
return self::Prefix;
|
||||
}
|
||||
if ($object instanceof InfixExpressionParserInterface) {
|
||||
return self::Infix;
|
||||
}
|
||||
|
||||
throw new \InvalidArgumentException(\sprintf('Unsupported expression parser type: %s', $object::class));
|
||||
}
|
||||
}
|
||||
127
vendor/twig/twig/src/ExpressionParser/ExpressionParsers.php
vendored
Normal file
127
vendor/twig/twig/src/ExpressionParser/ExpressionParsers.php
vendored
Normal file
@@ -0,0 +1,127 @@
|
||||
<?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\ExpressionParser;
|
||||
|
||||
/**
|
||||
* @template-implements \IteratorAggregate<ExpressionParserInterface>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
final class ExpressionParsers implements \IteratorAggregate
|
||||
{
|
||||
/**
|
||||
* @var array<class-string<ExpressionParserInterface>, array<string, ExpressionParserInterface>>
|
||||
*/
|
||||
private array $parsersByName = [];
|
||||
|
||||
/**
|
||||
* @var array<class-string<ExpressionParserInterface>, ExpressionParserInterface>
|
||||
*/
|
||||
private array $parsersByClass = [];
|
||||
|
||||
/**
|
||||
* @var \WeakMap<ExpressionParserInterface, array<ExpressionParserInterface>>|null
|
||||
*/
|
||||
private ?\WeakMap $precedenceChanges = null;
|
||||
|
||||
/**
|
||||
* @param array<ExpressionParserInterface> $parsers
|
||||
*/
|
||||
public function __construct(array $parsers = [])
|
||||
{
|
||||
$this->add($parsers);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<ExpressionParserInterface> $parsers
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function add(array $parsers): static
|
||||
{
|
||||
foreach ($parsers as $parser) {
|
||||
if ($parser->getPrecedence() > 512 || $parser->getPrecedence() < 0) {
|
||||
trigger_deprecation('twig/twig', '3.21', 'Precedence for "%s" must be between 0 and 512, got %d.', $parser->getName(), $parser->getPrecedence());
|
||||
// throw new \InvalidArgumentException(\sprintf('Precedence for "%s" must be between 0 and 512, got %d.', $parser->getName(), $parser->getPrecedence()));
|
||||
}
|
||||
$interface = $parser instanceof PrefixExpressionParserInterface ? PrefixExpressionParserInterface::class : InfixExpressionParserInterface::class;
|
||||
$this->parsersByName[$interface][$parser->getName()] = $parser;
|
||||
$this->parsersByClass[$parser::class] = $parser;
|
||||
foreach ($parser->getAliases() as $alias) {
|
||||
$this->parsersByName[$interface][$alias] = $parser;
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @template T of ExpressionParserInterface
|
||||
*
|
||||
* @param class-string<T> $class
|
||||
*
|
||||
* @return T|null
|
||||
*/
|
||||
public function getByClass(string $class): ?ExpressionParserInterface
|
||||
{
|
||||
return $this->parsersByClass[$class] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @template T of ExpressionParserInterface
|
||||
*
|
||||
* @param class-string<T> $interface
|
||||
*
|
||||
* @return T|null
|
||||
*/
|
||||
public function getByName(string $interface, string $name): ?ExpressionParserInterface
|
||||
{
|
||||
return $this->parsersByName[$interface][$name] ?? null;
|
||||
}
|
||||
|
||||
public function getIterator(): \Traversable
|
||||
{
|
||||
foreach ($this->parsersByName as $parsers) {
|
||||
// we don't yield the keys
|
||||
yield from $parsers;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @return \WeakMap<ExpressionParserInterface, array<ExpressionParserInterface>>
|
||||
*/
|
||||
public function getPrecedenceChanges(): \WeakMap
|
||||
{
|
||||
if (null === $this->precedenceChanges) {
|
||||
$this->precedenceChanges = new \WeakMap();
|
||||
foreach ($this as $ep) {
|
||||
if (!$ep->getPrecedenceChange()) {
|
||||
continue;
|
||||
}
|
||||
$min = min($ep->getPrecedenceChange()->getNewPrecedence(), $ep->getPrecedence());
|
||||
$max = max($ep->getPrecedenceChange()->getNewPrecedence(), $ep->getPrecedence());
|
||||
foreach ($this as $e) {
|
||||
if ($e->getPrecedence() > $min && $e->getPrecedence() < $max) {
|
||||
if (!isset($this->precedenceChanges[$e])) {
|
||||
$this->precedenceChanges[$e] = [];
|
||||
}
|
||||
$this->precedenceChanges[$e][] = $ep;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->precedenceChanges;
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user