Version Description
- 2019-03-07 =
- Fixed: Autoloader compatibility
Download this release
Release Info
Developer | themefusecom |
Plugin | Brizy – Page Builder |
Version | 1.0.64 |
Comparing to | |
See all releases |
Code changes from version 1.0.63 to 1.0.64
- README.md +4 -1
- autoload.php +1 -4
- brizy.php +2 -3
- editor.php +0 -5
- editor/crop-cache-media.php +6 -8
- readme.txt +4 -1
- vendor/autoload.php +1 -1
- vendor/composer/ClassLoader.php +2 -2
- vendor/composer/autoload_files.php +0 -10
- vendor/composer/autoload_psr4.php +0 -2
- vendor/composer/autoload_real.php +4 -22
- vendor/composer/autoload_static.php +2 -30
- vendor/composer/installed.json +13 -77
- vendor/symfony/polyfill-ctype +0 -1
- vendor/twig/twig/.php_cs.dist +5 -8
- vendor/twig/twig/.travis.yml +11 -11
- vendor/twig/twig/CHANGELOG +2 -98
- vendor/twig/twig/LICENSE +1 -1
- vendor/twig/twig/README.rst +1 -1
- vendor/twig/twig/composer.json +9 -10
- vendor/twig/twig/lib/Twig/Autoloader.php +6 -2
- vendor/twig/twig/lib/Twig/BaseNodeVisitor.php +11 -19
- vendor/twig/twig/lib/Twig/Cache/Filesystem.php +12 -14
- vendor/twig/twig/lib/Twig/Cache/Null.php +1 -5
- vendor/twig/twig/lib/Twig/CacheInterface.php +0 -2
- vendor/twig/twig/lib/Twig/Compiler.php +18 -25
- vendor/twig/twig/lib/Twig/ContainerRuntimeLoader.php +1 -4
- vendor/twig/twig/lib/Twig/Environment.php +197 -282
- vendor/twig/twig/lib/Twig/Error.php +55 -26
- vendor/twig/twig/lib/Twig/Error/Loader.php +10 -10
- vendor/twig/twig/lib/Twig/Error/Runtime.php +1 -5
- vendor/twig/twig/lib/Twig/Error/Syntax.php +4 -8
- vendor/twig/twig/lib/Twig/ExistsLoaderInterface.php +0 -2
- vendor/twig/twig/lib/Twig/ExpressionParser.php +146 -175
- vendor/twig/twig/lib/Twig/Extension.php +10 -17
- vendor/twig/twig/lib/Twig/Extension/Core.php +477 -511
- vendor/twig/twig/lib/Twig/Extension/Debug.php +9 -15
- vendor/twig/twig/lib/Twig/Extension/Escaper.php +9 -16
- vendor/twig/twig/lib/Twig/Extension/GlobalsInterface.php +1 -3
- vendor/twig/twig/lib/Twig/Extension/InitRuntimeInterface.php +1 -3
- vendor/twig/twig/lib/Twig/Extension/Optimizer.php +2 -7
- vendor/twig/twig/lib/Twig/Extension/Profiler.php +7 -14
- vendor/twig/twig/lib/Twig/Extension/Sandbox.php +6 -13
- vendor/twig/twig/lib/Twig/Extension/Staging.php +9 -15
- vendor/twig/twig/lib/Twig/Extension/StringLoader.php +10 -13
- vendor/twig/twig/lib/Twig/ExtensionInterface.php +6 -16
- vendor/twig/twig/lib/Twig/FactoryRuntimeLoader.php +2 -6
- vendor/twig/twig/lib/Twig/FileExtensionEscapingStrategy.php +1 -3
- vendor/twig/twig/lib/Twig/Filter.php +6 -8
- vendor/twig/twig/lib/Twig/Filter/Function.php +1 -1
- vendor/twig/twig/lib/Twig/Filter/Method.php +3 -5
- vendor/twig/twig/lib/Twig/Filter/Node.php +1 -1
- vendor/twig/twig/lib/Twig/FilterInterface.php +1 -3
- vendor/twig/twig/lib/Twig/Function.php +7 -9
- vendor/twig/twig/lib/Twig/Function/Function.php +1 -1
- vendor/twig/twig/lib/Twig/Function/Method.php +3 -5
- vendor/twig/twig/lib/Twig/Function/Node.php +1 -1
- vendor/twig/twig/lib/Twig/FunctionInterface.php +1 -3
- vendor/twig/twig/lib/Twig/Lexer.php +56 -67
- vendor/twig/twig/lib/Twig/LexerInterface.php +4 -8
- vendor/twig/twig/lib/Twig/Loader/Array.php +10 -16
- vendor/twig/twig/lib/Twig/Loader/Chain.php +31 -47
- vendor/twig/twig/lib/Twig/Loader/Filesystem.php +35 -49
- vendor/twig/twig/lib/Twig/Loader/String.php +4 -7
- vendor/twig/twig/lib/Twig/LoaderInterface.php +3 -7
- vendor/twig/twig/lib/Twig/Markup.php +2 -4
- vendor/twig/twig/lib/Twig/Node.php +20 -26
- vendor/twig/twig/lib/Twig/Node/AutoEscape.php +3 -8
- vendor/twig/twig/lib/Twig/Node/Block.php +4 -9
- vendor/twig/twig/lib/Twig/Node/BlockReference.php +3 -9
- vendor/twig/twig/lib/Twig/Node/Body.php +1 -5
- vendor/twig/twig/lib/Twig/Node/CheckSecurity.php +13 -18
- vendor/twig/twig/lib/Twig/Node/Deprecated.php +0 -54
- vendor/twig/twig/lib/Twig/Node/Do.php +4 -10
- vendor/twig/twig/lib/Twig/Node/Embed.php +4 -11
- vendor/twig/twig/lib/Twig/Node/Expression.php +1 -5
- vendor/twig/twig/lib/Twig/Node/Expression/Array.php +12 -19
- vendor/twig/twig/lib/Twig/Node/Expression/AssignName.php +2 -7
- vendor/twig/twig/lib/Twig/Node/Expression/Binary.php +4 -10
- vendor/twig/twig/lib/Twig/Node/Expression/Binary/Add.php +2 -8
- vendor/twig/twig/lib/Twig/Node/Expression/Binary/And.php +2 -8
- vendor/twig/twig/lib/Twig/Node/Expression/Binary/BitwiseAnd.php +2 -8
- vendor/twig/twig/lib/Twig/Node/Expression/Binary/BitwiseOr.php +2 -8
- vendor/twig/twig/lib/Twig/Node/Expression/Binary/BitwiseXor.php +2 -8
- vendor/twig/twig/lib/Twig/Node/Expression/Binary/Concat.php +2 -8
- vendor/twig/twig/lib/Twig/Node/Expression/Binary/Div.php +2 -8
- vendor/twig/twig/lib/Twig/Node/Expression/Binary/EndsWith.php +3 -9
- vendor/twig/twig/lib/Twig/Node/Expression/Binary/Equal.php +2 -8
- vendor/twig/twig/lib/Twig/Node/Expression/Binary/FloorDiv.php +3 -9
- vendor/twig/twig/lib/Twig/Node/Expression/Binary/Greater.php +2 -8
- vendor/twig/twig/lib/Twig/Node/Expression/Binary/GreaterEqual.php +2 -8
- vendor/twig/twig/lib/Twig/Node/Expression/Binary/In.php +3 -9
- vendor/twig/twig/lib/Twig/Node/Expression/Binary/Less.php +2 -8
- vendor/twig/twig/lib/Twig/Node/Expression/Binary/LessEqual.php +2 -8
- vendor/twig/twig/lib/Twig/Node/Expression/Binary/Matches.php +3 -9
- vendor/twig/twig/lib/Twig/Node/Expression/Binary/Mod.php +2 -8
- vendor/twig/twig/lib/Twig/Node/Expression/Binary/Mul.php +2 -8
- vendor/twig/twig/lib/Twig/Node/Expression/Binary/NotEqual.php +2 -8
- vendor/twig/twig/lib/Twig/Node/Expression/Binary/NotIn.php +3 -9
- vendor/twig/twig/lib/Twig/Node/Expression/Binary/Or.php +2 -8
- vendor/twig/twig/lib/Twig/Node/Expression/Binary/Power.php +3 -9
- vendor/twig/twig/lib/Twig/Node/Expression/Binary/Range.php +3 -9
- vendor/twig/twig/lib/Twig/Node/Expression/Binary/StartsWith.php +3 -9
- vendor/twig/twig/lib/Twig/Node/Expression/Binary/Sub.php +2 -8
- vendor/twig/twig/lib/Twig/Node/Expression/BlockReference.php +8 -14
- vendor/twig/twig/lib/Twig/Node/Expression/Call.php +55 -68
- vendor/twig/twig/lib/Twig/Node/Expression/Conditional.php +4 -10
- vendor/twig/twig/lib/Twig/Node/Expression/Constant.php +3 -9
- vendor/twig/twig/lib/Twig/Node/Expression/ExtensionReference.php +3 -6
- vendor/twig/twig/lib/Twig/Node/Expression/Filter.php +6 -14
- vendor/twig/twig/lib/Twig/Node/Expression/Filter/Default.php +10 -19
- vendor/twig/twig/lib/Twig/Node/Expression/Function.php +5 -12
- vendor/twig/twig/lib/Twig/Node/Expression/GetAttr.php +8 -15
- vendor/twig/twig/lib/Twig/Node/Expression/MethodCall.php +5 -13
- vendor/twig/twig/lib/Twig/Node/Expression/Name.php +6 -17
- vendor/twig/twig/lib/Twig/Node/Expression/NullCoalesce.php +6 -18
- vendor/twig/twig/lib/Twig/Node/Expression/Parent.php +3 -8
- vendor/twig/twig/lib/Twig/Node/Expression/TempName.php +3 -9
- vendor/twig/twig/lib/Twig/Node/Expression/Test.php +6 -16
- vendor/twig/twig/lib/Twig/Node/Expression/Test/Constant.php +7 -10
- vendor/twig/twig/lib/Twig/Node/Expression/Test/Defined.php +17 -27
- vendor/twig/twig/lib/Twig/Node/Expression/Test/Divisibleby.php +4 -7
- vendor/twig/twig/lib/Twig/Node/Expression/Test/Even.php +4 -7
- vendor/twig/twig/lib/Twig/Node/Expression/Test/Null.php +4 -7
- vendor/twig/twig/lib/Twig/Node/Expression/Test/Odd.php +4 -7
- vendor/twig/twig/lib/Twig/Node/Expression/Test/Sameas.php +2 -7
- vendor/twig/twig/lib/Twig/Node/Expression/Unary.php +4 -10
- vendor/twig/twig/lib/Twig/Node/Expression/Unary/Neg.php +2 -8
- vendor/twig/twig/lib/Twig/Node/Expression/Unary/Not.php +2 -8
- vendor/twig/twig/lib/Twig/Node/Expression/Unary/Pos.php +2 -8
- vendor/twig/twig/lib/Twig/Node/Flush.php +3 -8
- vendor/twig/twig/lib/Twig/Node/For.php +10 -19
- vendor/twig/twig/lib/Twig/Node/ForLoop.php +3 -8
- vendor/twig/twig/lib/Twig/Node/If.php +5 -10
- vendor/twig/twig/lib/Twig/Node/Import.php +5 -12
- vendor/twig/twig/lib/Twig/Node/Include.php +9 -16
- vendor/twig/twig/lib/Twig/Node/Macro.php +12 -18
- vendor/twig/twig/lib/Twig/Node/Module.php +56 -88
- vendor/twig/twig/lib/Twig/Node/Print.php +4 -11
- vendor/twig/twig/lib/Twig/Node/Sandbox.php +4 -9
- vendor/twig/twig/lib/Twig/Node/SandboxedPrint.php +6 -13
- vendor/twig/twig/lib/Twig/Node/Set.php +12 -20
- vendor/twig/twig/lib/Twig/Node/SetTemp.php +3 -11
- vendor/twig/twig/lib/Twig/Node/Spaceless.php +3 -8
- vendor/twig/twig/lib/Twig/Node/Text.php +3 -9
- vendor/twig/twig/lib/Twig/Node/With.php +7 -12
- vendor/twig/twig/lib/Twig/NodeCaptureInterface.php +0 -2
- vendor/twig/twig/lib/Twig/NodeInterface.php +2 -4
- vendor/twig/twig/lib/Twig/NodeOutputInterface.php +0 -2
- vendor/twig/twig/lib/Twig/NodeTraverser.php +9 -15
- vendor/twig/twig/lib/Twig/NodeVisitor/Escaper.php +32 -48
- vendor/twig/twig/lib/Twig/NodeVisitor/Optimizer.php +41 -62
- vendor/twig/twig/lib/Twig/NodeVisitor/SafeAnalysis.php +30 -45
- vendor/twig/twig/lib/Twig/NodeVisitor/Sandbox.php +13 -31
- vendor/twig/twig/lib/Twig/NodeVisitorInterface.php +2 -8
- vendor/twig/twig/lib/Twig/Parser.php +60 -90
- vendor/twig/twig/lib/Twig/ParserInterface.php +3 -7
- vendor/twig/twig/lib/Twig/Profiler/Dumper/Base.php +0 -64
- vendor/twig/twig/lib/Twig/Profiler/Dumper/Blackfire.php +8 -12
- vendor/twig/twig/lib/Twig/Profiler/Dumper/Html.php +7 -12
- vendor/twig/twig/lib/Twig/Profiler/Dumper/Text.php +41 -9
- vendor/twig/twig/lib/Twig/Profiler/Node/EnterProfile.php +4 -9
- vendor/twig/twig/lib/Twig/Profiler/Node/LeaveProfile.php +3 -8
- vendor/twig/twig/lib/Twig/Profiler/NodeVisitor/Profiler.php +17 -30
- vendor/twig/twig/lib/Twig/Profiler/Profile.php +11 -19
- vendor/twig/twig/lib/Twig/RuntimeLoaderInterface.php +0 -2
- vendor/twig/twig/lib/Twig/Sandbox/SecurityError.php +1 -5
- vendor/twig/twig/lib/Twig/Sandbox/SecurityNotAllowedFilterError.php +2 -6
- vendor/twig/twig/lib/Twig/Sandbox/SecurityNotAllowedFunctionError.php +2 -6
- vendor/twig/twig/lib/Twig/Sandbox/SecurityNotAllowedMethodError.php +2 -6
- vendor/twig/twig/lib/Twig/Sandbox/SecurityNotAllowedPropertyError.php +2 -6
- vendor/twig/twig/lib/Twig/Sandbox/SecurityNotAllowedTagError.php +2 -6
- vendor/twig/twig/lib/Twig/Sandbox/SecurityPolicy.php +17 -27
- vendor/twig/twig/lib/Twig/Sandbox/SecurityPolicyInterface.php +0 -2
- vendor/twig/twig/lib/Twig/SimpleFilter.php +7 -11
- vendor/twig/twig/lib/Twig/SimpleFunction.php +8 -12
- vendor/twig/twig/lib/Twig/SimpleTest.php +4 -18
- vendor/twig/twig/lib/Twig/Source.php +0 -2
- vendor/twig/twig/lib/Twig/SourceContextLoaderInterface.php +2 -7
- vendor/twig/twig/lib/Twig/Template.php +76 -87
- vendor/twig/twig/lib/Twig/TemplateInterface.php +2 -4
- vendor/twig/twig/lib/Twig/TemplateWrapper.php +13 -23
- vendor/twig/twig/lib/Twig/Test.php +4 -4
- vendor/twig/twig/lib/Twig/Test/Function.php +1 -1
- vendor/twig/twig/lib/Twig/Test/IntegrationTestCase.php +39 -62
- vendor/twig/twig/lib/Twig/Test/Method.php +3 -5
- vendor/twig/twig/lib/Twig/Test/Node.php +1 -1
- vendor/twig/twig/lib/Twig/Test/NodeTestCase.php +6 -17
- vendor/twig/twig/lib/Twig/Token.php +6 -8
- vendor/twig/twig/lib/Twig/TokenParser.php +2 -7
- vendor/twig/twig/lib/Twig/TokenParser/AutoEscape.php +24 -30
- vendor/twig/twig/lib/Twig/TokenParser/Block.php +17 -25
- vendor/twig/twig/lib/Twig/TokenParser/Deprecated.php +0 -43
- vendor/twig/twig/lib/Twig/TokenParser/Do.php +4 -10
- vendor/twig/twig/lib/Twig/TokenParser/Embed.php +16 -24
- vendor/twig/twig/lib/Twig/TokenParser/Extends.php +7 -11
- vendor/twig/twig/lib/Twig/TokenParser/Filter.php +14 -21
- vendor/twig/twig/lib/Twig/TokenParser/Flush.php +4 -10
- vendor/twig/twig/lib/Twig/TokenParser/For.php +34 -44
- vendor/twig/twig/lib/Twig/TokenParser/From.php +11 -17
- vendor/twig/twig/lib/Twig/TokenParser/If.php +25 -31
- vendor/twig/twig/lib/Twig/TokenParser/Import.php +7 -12
- vendor/twig/twig/lib/Twig/TokenParser/Include.php +13 -15
- vendor/twig/twig/lib/Twig/TokenParser/Macro.php +15 -21
- vendor/twig/twig/lib/Twig/TokenParser/Sandbox.php +17 -24
- vendor/twig/twig/lib/Twig/TokenParser/Set.php +20 -20
- vendor/twig/twig/lib/Twig/TokenParser/Spaceless.php +13 -16
- vendor/twig/twig/lib/Twig/TokenParser/Use.php +18 -26
- vendor/twig/twig/lib/Twig/TokenParser/With.php +9 -15
- vendor/twig/twig/lib/Twig/TokenParserBroker.php +14 -16
- vendor/twig/twig/lib/Twig/TokenParserBrokerInterface.php +3 -5
- vendor/twig/twig/lib/Twig/TokenParserInterface.php +3 -11
- vendor/twig/twig/lib/Twig/TokenStream.php +15 -21
- vendor/twig/twig/lib/Twig/Util/DeprecationCollector.php +12 -19
- vendor/twig/twig/lib/Twig/Util/TemplateDirIterator.php +0 -2
- vendor/twig/twig/phpunit.xml.dist +1 -1
- vendor/twig/twig/src/Cache/CacheInterface.php +0 -11
- vendor/twig/twig/src/Cache/FilesystemCache.php +0 -11
- vendor/twig/twig/src/Cache/NullCache.php +0 -11
- vendor/twig/twig/src/Compiler.php +0 -11
- vendor/twig/twig/src/Environment.php +0 -11
- vendor/twig/twig/src/Error/Error.php +0 -11
- vendor/twig/twig/src/Error/LoaderError.php +0 -11
- vendor/twig/twig/src/Error/RuntimeError.php +0 -11
- vendor/twig/twig/src/Error/SyntaxError.php +0 -11
- vendor/twig/twig/src/ExpressionParser.php +0 -11
- vendor/twig/twig/src/Extension/AbstractExtension.php +0 -11
- vendor/twig/twig/src/Extension/CoreExtension.php +0 -11
- vendor/twig/twig/src/Extension/DebugExtension.php +0 -11
- vendor/twig/twig/src/Extension/EscaperExtension.php +0 -11
- vendor/twig/twig/src/Extension/ExtensionInterface.php +0 -11
- vendor/twig/twig/src/Extension/GlobalsInterface.php +0 -11
- vendor/twig/twig/src/Extension/InitRuntimeInterface.php +0 -11
- vendor/twig/twig/src/Extension/OptimizerExtension.php +0 -11
- vendor/twig/twig/src/Extension/ProfilerExtension.php +0 -11
- vendor/twig/twig/src/Extension/RuntimeExtensionInterface.php +0 -19
- vendor/twig/twig/src/Extension/SandboxExtension.php +0 -11
- vendor/twig/twig/src/Extension/StagingExtension.php +0 -11
- vendor/twig/twig/src/Extension/StringLoaderExtension.php +0 -11
- vendor/twig/twig/src/FileExtensionEscapingStrategy.php +0 -11
- vendor/twig/twig/src/Lexer.php +0 -11
- vendor/twig/twig/src/Loader/ArrayLoader.php +0 -11
- vendor/twig/twig/src/Loader/ChainLoader.php +0 -11
- vendor/twig/twig/src/Loader/ExistsLoaderInterface.php +0 -11
- vendor/twig/twig/src/Loader/FilesystemLoader.php +0 -11
- vendor/twig/twig/src/Loader/LoaderInterface.php +0 -11
- vendor/twig/twig/src/Loader/SourceContextLoaderInterface.php +0 -11
- vendor/twig/twig/src/Markup.php +0 -11
- vendor/twig/twig/src/Node/AutoEscapeNode.php +0 -11
- vendor/twig/twig/src/Node/BlockNode.php +0 -11
- vendor/twig/twig/src/Node/BlockReferenceNode.php +0 -11
- vendor/twig/twig/src/Node/BodyNode.php +0 -11
- vendor/twig/twig/src/Node/CheckSecurityNode.php +0 -11
- vendor/twig/twig/src/Node/DeprecatedNode.php +0 -11
- vendor/twig/twig/src/Node/DoNode.php +0 -11
- vendor/twig/twig/src/Node/EmbedNode.php +0 -11
- vendor/twig/twig/src/Node/Expression/AbstractExpression.php +0 -11
- vendor/twig/twig/src/Node/Expression/ArrayExpression.php +0 -11
- vendor/twig/twig/src/Node/Expression/AssignNameExpression.php +0 -11
- vendor/twig/twig/src/Node/Expression/Binary/AbstractBinary.php +0 -11
- vendor/twig/twig/src/Node/Expression/Binary/AddBinary.php +0 -11
- vendor/twig/twig/src/Node/Expression/Binary/AndBinary.php +0 -11
- vendor/twig/twig/src/Node/Expression/Binary/BitwiseAndBinary.php +0 -11
- vendor/twig/twig/src/Node/Expression/Binary/BitwiseOrBinary.php +0 -11
- vendor/twig/twig/src/Node/Expression/Binary/BitwiseXorBinary.php +0 -11
- vendor/twig/twig/src/Node/Expression/Binary/ConcatBinary.php +0 -11
- vendor/twig/twig/src/Node/Expression/Binary/DivBinary.php +0 -11
- vendor/twig/twig/src/Node/Expression/Binary/EndsWithBinary.php +0 -11
- vendor/twig/twig/src/Node/Expression/Binary/EqualBinary.php +0 -11
- vendor/twig/twig/src/Node/Expression/Binary/FloorDivBinary.php +0 -11
- vendor/twig/twig/src/Node/Expression/Binary/GreaterBinary.php +0 -11
- vendor/twig/twig/src/Node/Expression/Binary/GreaterEqualBinary.php +0 -11
- vendor/twig/twig/src/Node/Expression/Binary/InBinary.php +0 -11
- vendor/twig/twig/src/Node/Expression/Binary/LessBinary.php +0 -11
- vendor/twig/twig/src/Node/Expression/Binary/LessEqualBinary.php +0 -11
- vendor/twig/twig/src/Node/Expression/Binary/MatchesBinary.php +0 -11
- vendor/twig/twig/src/Node/Expression/Binary/ModBinary.php +0 -11
- vendor/twig/twig/src/Node/Expression/Binary/MulBinary.php +0 -11
- vendor/twig/twig/src/Node/Expression/Binary/NotEqualBinary.php +0 -11
- vendor/twig/twig/src/Node/Expression/Binary/NotInBinary.php +0 -11
- vendor/twig/twig/src/Node/Expression/Binary/OrBinary.php +0 -11
- vendor/twig/twig/src/Node/Expression/Binary/PowerBinary.php +0 -11
- vendor/twig/twig/src/Node/Expression/Binary/RangeBinary.php +0 -11
- vendor/twig/twig/src/Node/Expression/Binary/StartsWithBinary.php +0 -11
- vendor/twig/twig/src/Node/Expression/Binary/SubBinary.php +0 -11
- vendor/twig/twig/src/Node/Expression/BlockReferenceExpression.php +0 -11
- vendor/twig/twig/src/Node/Expression/CallExpression.php +0 -11
- vendor/twig/twig/src/Node/Expression/ConditionalExpression.php +0 -11
- vendor/twig/twig/src/Node/Expression/ConstantExpression.php +0 -11
- vendor/twig/twig/src/Node/Expression/Filter/DefaultFilter.php +0 -11
- vendor/twig/twig/src/Node/Expression/FilterExpression.php +0 -11
- vendor/twig/twig/src/Node/Expression/FunctionExpression.php +0 -11
- vendor/twig/twig/src/Node/Expression/GetAttrExpression.php +0 -11
- vendor/twig/twig/src/Node/Expression/MethodCallExpression.php +0 -11
- vendor/twig/twig/src/Node/Expression/NameExpression.php +0 -11
- vendor/twig/twig/src/Node/Expression/NullCoalesceExpression.php +0 -11
- vendor/twig/twig/src/Node/Expression/ParentExpression.php +0 -11
- vendor/twig/twig/src/Node/Expression/TempNameExpression.php +0 -11
- vendor/twig/twig/src/Node/Expression/Test/ConstantTest.php +0 -11
- vendor/twig/twig/src/Node/Expression/Test/DefinedTest.php +0 -11
- vendor/twig/twig/src/Node/Expression/Test/DivisiblebyTest.php +0 -11
- vendor/twig/twig/src/Node/Expression/Test/EvenTest.php +0 -11
- vendor/twig/twig/src/Node/Expression/Test/NullTest.php +0 -11
- vendor/twig/twig/src/Node/Expression/Test/OddTest.php +0 -11
- vendor/twig/twig/src/Node/Expression/Test/SameasTest.php +0 -11
- vendor/twig/twig/src/Node/Expression/TestExpression.php +0 -11
- vendor/twig/twig/src/Node/Expression/Unary/AbstractUnary.php +0 -11
- vendor/twig/twig/src/Node/Expression/Unary/NegUnary.php +0 -11
- vendor/twig/twig/src/Node/Expression/Unary/NotUnary.php +0 -11
- vendor/twig/twig/src/Node/Expression/Unary/PosUnary.php +0 -11
- vendor/twig/twig/src/Node/FlushNode.php +0 -11
- vendor/twig/twig/src/Node/ForLoopNode.php +0 -11
- vendor/twig/twig/src/Node/ForNode.php +0 -11
- vendor/twig/twig/src/Node/IfNode.php +0 -11
- vendor/twig/twig/src/Node/ImportNode.php +0 -11
- vendor/twig/twig/src/Node/IncludeNode.php +0 -11
- vendor/twig/twig/src/Node/MacroNode.php +0 -11
- vendor/twig/twig/src/Node/ModuleNode.php +0 -11
- vendor/twig/twig/src/Node/Node.php +0 -11
- vendor/twig/twig/src/Node/NodeCaptureInterface.php +0 -11
- vendor/twig/twig/src/Node/NodeOutputInterface.php +0 -11
- vendor/twig/twig/src/Node/PrintNode.php +0 -11
- vendor/twig/twig/src/Node/SandboxNode.php +0 -11
- vendor/twig/twig/src/Node/SandboxedPrintNode.php +0 -11
- vendor/twig/twig/src/Node/SetNode.php +0 -11
- vendor/twig/twig/src/Node/SetTempNode.php +0 -11
- vendor/twig/twig/src/Node/SpacelessNode.php +0 -11
- vendor/twig/twig/src/Node/TextNode.php +0 -11
- vendor/twig/twig/src/Node/WithNode.php +0 -11
- vendor/twig/twig/src/NodeTraverser.php +0 -11
- vendor/twig/twig/src/NodeVisitor/AbstractNodeVisitor.php +0 -11
- vendor/twig/twig/src/NodeVisitor/EscaperNodeVisitor.php +0 -11
- vendor/twig/twig/src/NodeVisitor/NodeVisitorInterface.php +0 -11
- vendor/twig/twig/src/NodeVisitor/OptimizerNodeVisitor.php +0 -11
- vendor/twig/twig/src/NodeVisitor/SafeAnalysisNodeVisitor.php +0 -11
- vendor/twig/twig/src/NodeVisitor/SandboxNodeVisitor.php +0 -11
- vendor/twig/twig/src/Parser.php +0 -11
- vendor/twig/twig/src/Profiler/Dumper/BaseDumper.php +0 -11
- vendor/twig/twig/src/Profiler/Dumper/BlackfireDumper.php +0 -11
- vendor/twig/twig/src/Profiler/Dumper/HtmlDumper.php +0 -11
- vendor/twig/twig/src/Profiler/Dumper/TextDumper.php +0 -11
- vendor/twig/twig/src/Profiler/Node/EnterProfileNode.php +0 -11
- vendor/twig/twig/src/Profiler/Node/LeaveProfileNode.php +0 -11
- vendor/twig/twig/src/Profiler/NodeVisitor/ProfilerNodeVisitor.php +0 -11
- vendor/twig/twig/src/Profiler/Profile.php +0 -11
- vendor/twig/twig/src/RuntimeLoader/ContainerRuntimeLoader.php +0 -11
- vendor/twig/twig/src/RuntimeLoader/FactoryRuntimeLoader.php +0 -11
- vendor/twig/twig/src/RuntimeLoader/RuntimeLoaderInterface.php +0 -11
- vendor/twig/twig/src/Sandbox/SecurityError.php +0 -11
- vendor/twig/twig/src/Sandbox/SecurityNotAllowedFilterError.php +0 -11
- vendor/twig/twig/src/Sandbox/SecurityNotAllowedFunctionError.php +0 -11
- vendor/twig/twig/src/Sandbox/SecurityNotAllowedMethodError.php +0 -11
- vendor/twig/twig/src/Sandbox/SecurityNotAllowedPropertyError.php +0 -11
- vendor/twig/twig/src/Sandbox/SecurityNotAllowedTagError.php +0 -11
- vendor/twig/twig/src/Sandbox/SecurityPolicy.php +0 -11
- vendor/twig/twig/src/Sandbox/SecurityPolicyInterface.php +0 -11
- vendor/twig/twig/src/Source.php +0 -11
- vendor/twig/twig/src/Template.php +0 -11
- vendor/twig/twig/src/TemplateWrapper.php +0 -11
- vendor/twig/twig/src/Test/IntegrationTestCase.php +0 -11
- vendor/twig/twig/src/Test/NodeTestCase.php +0 -11
- vendor/twig/twig/src/Token.php +0 -11
- vendor/twig/twig/src/TokenParser/AbstractTokenParser.php +0 -11
- vendor/twig/twig/src/TokenParser/AutoEscapeTokenParser.php +0 -11
- vendor/twig/twig/src/TokenParser/BlockTokenParser.php +0 -11
- vendor/twig/twig/src/TokenParser/DeprecatedTokenParser.php +0 -11
- vendor/twig/twig/src/TokenParser/DoTokenParser.php +0 -11
- vendor/twig/twig/src/TokenParser/EmbedTokenParser.php +0 -11
- vendor/twig/twig/src/TokenParser/ExtendsTokenParser.php +0 -11
- vendor/twig/twig/src/TokenParser/FilterTokenParser.php +0 -11
- vendor/twig/twig/src/TokenParser/FlushTokenParser.php +0 -11
- vendor/twig/twig/src/TokenParser/ForTokenParser.php +0 -11
- vendor/twig/twig/src/TokenParser/FromTokenParser.php +0 -11
- vendor/twig/twig/src/TokenParser/IfTokenParser.php +0 -11
- vendor/twig/twig/src/TokenParser/ImportTokenParser.php +0 -11
- vendor/twig/twig/src/TokenParser/IncludeTokenParser.php +0 -11
- vendor/twig/twig/src/TokenParser/MacroTokenParser.php +0 -11
- vendor/twig/twig/src/TokenParser/SandboxTokenParser.php +0 -11
- vendor/twig/twig/src/TokenParser/SetTokenParser.php +0 -11
- vendor/twig/twig/src/TokenParser/SpacelessTokenParser.php +0 -11
- vendor/twig/twig/src/TokenParser/TokenParserInterface.php +0 -11
- vendor/twig/twig/src/TokenParser/UseTokenParser.php +0 -11
- vendor/twig/twig/src/TokenParser/WithTokenParser.php +0 -11
- vendor/twig/twig/src/TokenStream.php +0 -11
- vendor/twig/twig/src/TwigFilter.php +0 -11
- vendor/twig/twig/src/TwigFunction.php +0 -11
- vendor/twig/twig/src/TwigTest.php +0 -11
- vendor/twig/twig/src/Util/DeprecationCollector.php +0 -11
- vendor/twig/twig/src/Util/TemplateDirIterator.php +0 -11
README.md
CHANGED
@@ -3,7 +3,7 @@ Contributors: themefuse<br>
|
|
3 |
Requires at least: 4.5<br>
|
4 |
Tested up to: 4.9<br>
|
5 |
Requires PHP: 5.4<br>
|
6 |
-
Stable tag: 1.0.
|
7 |
License: GPLv3<br>
|
8 |
License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
9 |
|
@@ -118,6 +118,9 @@ $bodyHtml = apply_filters( 'brizy_content', $html->get_body(), Brizy_Editor_Proj
|
|
118 |
|
119 |
## Changelog
|
120 |
|
|
|
|
|
|
|
121 |
### 1.0.63 - 2019-03-06 ###
|
122 |
* Fixed: Fixed the image cropper
|
123 |
|
3 |
Requires at least: 4.5<br>
|
4 |
Tested up to: 4.9<br>
|
5 |
Requires PHP: 5.4<br>
|
6 |
+
Stable tag: 1.0.64<br>
|
7 |
License: GPLv3<br>
|
8 |
License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
9 |
|
118 |
|
119 |
## Changelog
|
120 |
|
121 |
+
### 1.0.64 - 2019-03-07 ###
|
122 |
+
* Fixed: Autoloader compatibility
|
123 |
+
|
124 |
### 1.0.63 - 2019-03-06 ###
|
125 |
* Fixed: Fixed the image cropper
|
126 |
|
autoload.php
CHANGED
@@ -1,9 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
include_once "vendor/autoload.php";
|
4 |
-
include_once "vendor/twig/twig/lib/Twig/Autoloader.php";
|
5 |
-
|
6 |
-
Twig_Autoloader::register(true);
|
7 |
|
8 |
/**.
|
9 |
* @param $class_name
|
1 |
<?php
|
2 |
|
3 |
+
include_once dirname( __FILE__ ) . "/vendor/autoload.php";
|
|
|
|
|
|
|
4 |
|
5 |
/**.
|
6 |
* @param $class_name
|
brizy.php
CHANGED
@@ -5,12 +5,11 @@
|
|
5 |
* Plugin URI: https://brizy.io/
|
6 |
* Author: Brizy.io
|
7 |
* Author URI: https://brizy.io/
|
8 |
-
* Version: 1.0.
|
9 |
* Text Domain: brizy
|
10 |
* License: GPLv3
|
11 |
* Domain Path: /languages
|
12 |
*/
|
13 |
-
|
14 |
/**
|
15 |
* This will fix the url protocol for websites that are working behind a load balancer
|
16 |
*/
|
@@ -20,7 +19,7 @@ if ( isset( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) && stripos( $_SERVER['HTTP_X_FO
|
|
20 |
|
21 |
define( 'BRIZY_DEVELOPMENT', false );
|
22 |
define( 'BRIZY_LOG', false );
|
23 |
-
define( 'BRIZY_VERSION', '1.0.
|
24 |
define( 'BRIZY_EDITOR_VERSION', '1.0.87' );
|
25 |
define( 'BRIZY_FILE', __FILE__ );
|
26 |
define( 'BRIZY_PLUGIN_BASE', plugin_basename( BRIZY_FILE ) );
|
5 |
* Plugin URI: https://brizy.io/
|
6 |
* Author: Brizy.io
|
7 |
* Author URI: https://brizy.io/
|
8 |
+
* Version: 1.0.64
|
9 |
* Text Domain: brizy
|
10 |
* License: GPLv3
|
11 |
* Domain Path: /languages
|
12 |
*/
|
|
|
13 |
/**
|
14 |
* This will fix the url protocol for websites that are working behind a load balancer
|
15 |
*/
|
19 |
|
20 |
define( 'BRIZY_DEVELOPMENT', false );
|
21 |
define( 'BRIZY_LOG', false );
|
22 |
+
define( 'BRIZY_VERSION', '1.0.64' );
|
23 |
define( 'BRIZY_EDITOR_VERSION', '1.0.87' );
|
24 |
define( 'BRIZY_FILE', __FILE__ );
|
25 |
define( 'BRIZY_PLUGIN_BASE', plugin_basename( BRIZY_FILE ) );
|
editor.php
CHANGED
@@ -63,11 +63,6 @@ class Brizy_Editor {
|
|
63 |
$supported_post_types[] = Brizy_Admin_Templates::CP_TEMPLATE;
|
64 |
|
65 |
foreach ( $supported_post_types as $type ) {
|
66 |
-
|
67 |
-
if ( $type == 'post' ) {
|
68 |
-
continue;
|
69 |
-
}
|
70 |
-
|
71 |
add_filter( "theme_{$type}_templates", array( $this, 'registerPageTemplates' ) );
|
72 |
}
|
73 |
}
|
63 |
$supported_post_types[] = Brizy_Admin_Templates::CP_TEMPLATE;
|
64 |
|
65 |
foreach ( $supported_post_types as $type ) {
|
|
|
|
|
|
|
|
|
|
|
66 |
add_filter( "theme_{$type}_templates", array( $this, 'registerPageTemplates' ) );
|
67 |
}
|
68 |
}
|
editor/crop-cache-media.php
CHANGED
@@ -51,8 +51,8 @@ class Brizy_Editor_CropCacheMedia extends Brizy_Editor_Asset_StaticFile {
|
|
51 |
|
52 |
if ( ! ( $attachmentId = $this->getAttachmentByMediaName( $madia_name ) ) ) {
|
53 |
|
54 |
-
|
55 |
-
|
56 |
|
57 |
if ( ! file_exists( $original_asset_path ) ) {
|
58 |
// I assume that the media was already attached.
|
@@ -111,7 +111,7 @@ class Brizy_Editor_CropCacheMedia extends Brizy_Editor_Asset_StaticFile {
|
|
111 |
// resize image
|
112 |
if ( $media_filter ) {
|
113 |
|
114 |
-
if (
|
115 |
|
116 |
@mkdir( $resized_page_asset_path, 0755, true );
|
117 |
|
@@ -121,20 +121,18 @@ class Brizy_Editor_CropCacheMedia extends Brizy_Editor_Asset_StaticFile {
|
|
121 |
$closure = function ( $arg ) {
|
122 |
return 100;
|
123 |
};
|
124 |
-
|
125 |
|
126 |
$imagine = $this->crop( $original_asset_path, $media_filter );
|
127 |
|
128 |
if ( $imagine ) {
|
129 |
$imagine->save( $resized_image_path );
|
130 |
unset( $imagine );
|
131 |
-
|
132 |
-
return $resized_image_path;
|
133 |
}
|
134 |
-
|
135 |
-
//remove_filter('jpeg_quality', $closure );
|
136 |
}
|
137 |
}
|
|
|
138 |
return $resized_image_path;
|
139 |
}
|
140 |
|
51 |
|
52 |
if ( ! ( $attachmentId = $this->getAttachmentByMediaName( $madia_name ) ) ) {
|
53 |
|
54 |
+
$original_asset_path = $this->url_builder->page_upload_path( "/assets/images/" . $madia_name );
|
55 |
+
$original_asset_path_relative = $this->url_builder->page_upload_relative_path( "/assets/images/" . $madia_name );
|
56 |
|
57 |
if ( ! file_exists( $original_asset_path ) ) {
|
58 |
// I assume that the media was already attached.
|
111 |
// resize image
|
112 |
if ( $media_filter ) {
|
113 |
|
114 |
+
if ( ! file_exists( $resized_image_path ) ) {
|
115 |
|
116 |
@mkdir( $resized_page_asset_path, 0755, true );
|
117 |
|
121 |
$closure = function ( $arg ) {
|
122 |
return 100;
|
123 |
};
|
124 |
+
add_filter( 'jpeg_quality', $closure );
|
125 |
|
126 |
$imagine = $this->crop( $original_asset_path, $media_filter );
|
127 |
|
128 |
if ( $imagine ) {
|
129 |
$imagine->save( $resized_image_path );
|
130 |
unset( $imagine );
|
|
|
|
|
131 |
}
|
132 |
+
remove_filter( 'jpeg_quality', $closure );
|
|
|
133 |
}
|
134 |
}
|
135 |
+
|
136 |
return $resized_image_path;
|
137 |
}
|
138 |
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Tags: brizy, page builder, editor, visual editor, unyson, wysiwyg, landing page,
|
|
4 |
Requires at least: 4.5
|
5 |
Tested up to: 4.9
|
6 |
Requires PHP: 5.4
|
7 |
-
Stable tag: 1.0.
|
8 |
License: GPLv3
|
9 |
License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
@@ -139,6 +139,9 @@ The progress you're making while building your page is always backed up in the c
|
|
139 |
|
140 |
== Changelog ==
|
141 |
|
|
|
|
|
|
|
142 |
= 1.0.63 - 2019-03-06 =
|
143 |
* Fixed: Fixed the image cropper
|
144 |
|
4 |
Requires at least: 4.5
|
5 |
Tested up to: 4.9
|
6 |
Requires PHP: 5.4
|
7 |
+
Stable tag: 1.0.64
|
8 |
License: GPLv3
|
9 |
License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
139 |
|
140 |
== Changelog ==
|
141 |
|
142 |
+
= 1.0.64 - 2019-03-07 =
|
143 |
+
* Fixed: Autoloader compatibility
|
144 |
+
|
145 |
= 1.0.63 - 2019-03-06 =
|
146 |
* Fixed: Fixed the image cropper
|
147 |
|
vendor/autoload.php
CHANGED
@@ -4,4 +4,4 @@
|
|
4 |
|
5 |
require_once __DIR__ . '/composer/autoload_real.php';
|
6 |
|
7 |
-
return
|
4 |
|
5 |
require_once __DIR__ . '/composer/autoload_real.php';
|
6 |
|
7 |
+
return ComposerAutoloaderInit28c4863b05cfc42661b81ed48065ebcf::getLoader();
|
vendor/composer/ClassLoader.php
CHANGED
@@ -279,7 +279,7 @@ class ClassLoader
|
|
279 |
*/
|
280 |
public function setApcuPrefix($apcuPrefix)
|
281 |
{
|
282 |
-
$this->apcuPrefix = function_exists('apcu_fetch') &&
|
283 |
}
|
284 |
|
285 |
/**
|
@@ -377,7 +377,7 @@ class ClassLoader
|
|
377 |
$subPath = $class;
|
378 |
while (false !== $lastPos = strrpos($subPath, '\\')) {
|
379 |
$subPath = substr($subPath, 0, $lastPos);
|
380 |
-
$search = $subPath
|
381 |
if (isset($this->prefixDirsPsr4[$search])) {
|
382 |
$pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
|
383 |
foreach ($this->prefixDirsPsr4[$search] as $dir) {
|
279 |
*/
|
280 |
public function setApcuPrefix($apcuPrefix)
|
281 |
{
|
282 |
+
$this->apcuPrefix = function_exists('apcu_fetch') && ini_get('apc.enabled') ? $apcuPrefix : null;
|
283 |
}
|
284 |
|
285 |
/**
|
377 |
$subPath = $class;
|
378 |
while (false !== $lastPos = strrpos($subPath, '\\')) {
|
379 |
$subPath = substr($subPath, 0, $lastPos);
|
380 |
+
$search = $subPath.'\\';
|
381 |
if (isset($this->prefixDirsPsr4[$search])) {
|
382 |
$pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
|
383 |
foreach ($this->prefixDirsPsr4[$search] as $dir) {
|
vendor/composer/autoload_files.php
DELETED
@@ -1,10 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
// autoload_files.php @generated by Composer
|
4 |
-
|
5 |
-
$vendorDir = dirname(dirname(__FILE__));
|
6 |
-
$baseDir = dirname($vendorDir);
|
7 |
-
|
8 |
-
return array(
|
9 |
-
'320cde22f66dd4f5d3fd621d3e88b98f' => $vendorDir . '/symfony/polyfill-ctype/bootstrap.php',
|
10 |
-
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/composer/autoload_psr4.php
CHANGED
@@ -6,6 +6,4 @@ $vendorDir = dirname(dirname(__FILE__));
|
|
6 |
$baseDir = dirname($vendorDir);
|
7 |
|
8 |
return array(
|
9 |
-
'Twig\\' => array($vendorDir . '/twig/twig/src'),
|
10 |
-
'Symfony\\Polyfill\\Ctype\\' => array($vendorDir . '/symfony/polyfill-ctype'),
|
11 |
);
|
6 |
$baseDir = dirname($vendorDir);
|
7 |
|
8 |
return array(
|
|
|
|
|
9 |
);
|
vendor/composer/autoload_real.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
|
3 |
// autoload_real.php @generated by Composer
|
4 |
|
5 |
-
class
|
6 |
{
|
7 |
private static $loader;
|
8 |
|
@@ -19,15 +19,15 @@ class ComposerAutoloaderInit974dd796c48f993e9f1fa76ba43f0a15
|
|
19 |
return self::$loader;
|
20 |
}
|
21 |
|
22 |
-
spl_autoload_register(array('
|
23 |
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
24 |
-
spl_autoload_unregister(array('
|
25 |
|
26 |
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
27 |
if ($useStaticLoader) {
|
28 |
require_once __DIR__ . '/autoload_static.php';
|
29 |
|
30 |
-
call_user_func(\Composer\Autoload\
|
31 |
} else {
|
32 |
$map = require __DIR__ . '/autoload_namespaces.php';
|
33 |
foreach ($map as $namespace => $path) {
|
@@ -47,24 +47,6 @@ class ComposerAutoloaderInit974dd796c48f993e9f1fa76ba43f0a15
|
|
47 |
|
48 |
$loader->register(true);
|
49 |
|
50 |
-
if ($useStaticLoader) {
|
51 |
-
$includeFiles = Composer\Autoload\ComposerStaticInit974dd796c48f993e9f1fa76ba43f0a15::$files;
|
52 |
-
} else {
|
53 |
-
$includeFiles = require __DIR__ . '/autoload_files.php';
|
54 |
-
}
|
55 |
-
foreach ($includeFiles as $fileIdentifier => $file) {
|
56 |
-
composerRequire974dd796c48f993e9f1fa76ba43f0a15($fileIdentifier, $file);
|
57 |
-
}
|
58 |
-
|
59 |
return $loader;
|
60 |
}
|
61 |
}
|
62 |
-
|
63 |
-
function composerRequire974dd796c48f993e9f1fa76ba43f0a15($fileIdentifier, $file)
|
64 |
-
{
|
65 |
-
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
66 |
-
require $file;
|
67 |
-
|
68 |
-
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
69 |
-
}
|
70 |
-
}
|
2 |
|
3 |
// autoload_real.php @generated by Composer
|
4 |
|
5 |
+
class ComposerAutoloaderInit28c4863b05cfc42661b81ed48065ebcf
|
6 |
{
|
7 |
private static $loader;
|
8 |
|
19 |
return self::$loader;
|
20 |
}
|
21 |
|
22 |
+
spl_autoload_register(array('ComposerAutoloaderInit28c4863b05cfc42661b81ed48065ebcf', 'loadClassLoader'), true, true);
|
23 |
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
24 |
+
spl_autoload_unregister(array('ComposerAutoloaderInit28c4863b05cfc42661b81ed48065ebcf', 'loadClassLoader'));
|
25 |
|
26 |
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
27 |
if ($useStaticLoader) {
|
28 |
require_once __DIR__ . '/autoload_static.php';
|
29 |
|
30 |
+
call_user_func(\Composer\Autoload\ComposerStaticInit28c4863b05cfc42661b81ed48065ebcf::getInitializer($loader));
|
31 |
} else {
|
32 |
$map = require __DIR__ . '/autoload_namespaces.php';
|
33 |
foreach ($map as $namespace => $path) {
|
47 |
|
48 |
$loader->register(true);
|
49 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
return $loader;
|
51 |
}
|
52 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/composer/autoload_static.php
CHANGED
@@ -4,34 +4,8 @@
|
|
4 |
|
5 |
namespace Composer\Autoload;
|
6 |
|
7 |
-
class
|
8 |
{
|
9 |
-
public static $files = array (
|
10 |
-
'320cde22f66dd4f5d3fd621d3e88b98f' => __DIR__ . '/..' . '/symfony/polyfill-ctype/bootstrap.php',
|
11 |
-
);
|
12 |
-
|
13 |
-
public static $prefixLengthsPsr4 = array (
|
14 |
-
'T' =>
|
15 |
-
array (
|
16 |
-
'Twig\\' => 5,
|
17 |
-
),
|
18 |
-
'S' =>
|
19 |
-
array (
|
20 |
-
'Symfony\\Polyfill\\Ctype\\' => 23,
|
21 |
-
),
|
22 |
-
);
|
23 |
-
|
24 |
-
public static $prefixDirsPsr4 = array (
|
25 |
-
'Twig\\' =>
|
26 |
-
array (
|
27 |
-
0 => __DIR__ . '/..' . '/twig/twig/src',
|
28 |
-
),
|
29 |
-
'Symfony\\Polyfill\\Ctype\\' =>
|
30 |
-
array (
|
31 |
-
0 => __DIR__ . '/..' . '/symfony/polyfill-ctype',
|
32 |
-
),
|
33 |
-
);
|
34 |
-
|
35 |
public static $prefixesPsr0 = array (
|
36 |
'T' =>
|
37 |
array (
|
@@ -45,9 +19,7 @@ class ComposerStaticInit974dd796c48f993e9f1fa76ba43f0a15
|
|
45 |
public static function getInitializer(ClassLoader $loader)
|
46 |
{
|
47 |
return \Closure::bind(function () use ($loader) {
|
48 |
-
$loader->
|
49 |
-
$loader->prefixDirsPsr4 = ComposerStaticInit974dd796c48f993e9f1fa76ba43f0a15::$prefixDirsPsr4;
|
50 |
-
$loader->prefixesPsr0 = ComposerStaticInit974dd796c48f993e9f1fa76ba43f0a15::$prefixesPsr0;
|
51 |
|
52 |
}, null, ClassLoader::class);
|
53 |
}
|
4 |
|
5 |
namespace Composer\Autoload;
|
6 |
|
7 |
+
class ComposerStaticInit28c4863b05cfc42661b81ed48065ebcf
|
8 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
public static $prefixesPsr0 = array (
|
10 |
'T' =>
|
11 |
array (
|
19 |
public static function getInitializer(ClassLoader $loader)
|
20 |
{
|
21 |
return \Closure::bind(function () use ($loader) {
|
22 |
+
$loader->prefixesPsr0 = ComposerStaticInit28c4863b05cfc42661b81ed48065ebcf::$prefixesPsr0;
|
|
|
|
|
23 |
|
24 |
}, null, ClassLoader::class);
|
25 |
}
|
vendor/composer/installed.json
CHANGED
@@ -1,102 +1,38 @@
|
|
1 |
[
|
2 |
-
{
|
3 |
-
"name": "symfony/polyfill-ctype",
|
4 |
-
"version": "dev-master",
|
5 |
-
"version_normalized": "9999999-dev",
|
6 |
-
"source": {
|
7 |
-
"type": "git",
|
8 |
-
"url": "https://github.com/symfony/polyfill-ctype.git",
|
9 |
-
"reference": "82ebae02209c21113908c229e9883c419720738a"
|
10 |
-
},
|
11 |
-
"dist": {
|
12 |
-
"type": "zip",
|
13 |
-
"url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/82ebae02209c21113908c229e9883c419720738a",
|
14 |
-
"reference": "82ebae02209c21113908c229e9883c419720738a",
|
15 |
-
"shasum": ""
|
16 |
-
},
|
17 |
-
"require": {
|
18 |
-
"php": ">=5.3.3"
|
19 |
-
},
|
20 |
-
"suggest": {
|
21 |
-
"ext-ctype": "For best performance"
|
22 |
-
},
|
23 |
-
"time": "2019-02-06T07:57:58+00:00",
|
24 |
-
"type": "library",
|
25 |
-
"extra": {
|
26 |
-
"branch-alias": {
|
27 |
-
"dev-master": "1.11-dev"
|
28 |
-
}
|
29 |
-
},
|
30 |
-
"installation-source": "source",
|
31 |
-
"autoload": {
|
32 |
-
"psr-4": {
|
33 |
-
"Symfony\\Polyfill\\Ctype\\": ""
|
34 |
-
},
|
35 |
-
"files": [
|
36 |
-
"bootstrap.php"
|
37 |
-
]
|
38 |
-
},
|
39 |
-
"notification-url": "https://packagist.org/downloads/",
|
40 |
-
"license": [
|
41 |
-
"MIT"
|
42 |
-
],
|
43 |
-
"authors": [
|
44 |
-
{
|
45 |
-
"name": "Symfony Community",
|
46 |
-
"homepage": "https://symfony.com/contributors"
|
47 |
-
},
|
48 |
-
{
|
49 |
-
"name": "Gert de Pagter",
|
50 |
-
"email": "BackEndTea@gmail.com"
|
51 |
-
}
|
52 |
-
],
|
53 |
-
"description": "Symfony polyfill for ctype functions",
|
54 |
-
"homepage": "https://symfony.com",
|
55 |
-
"keywords": [
|
56 |
-
"compatibility",
|
57 |
-
"ctype",
|
58 |
-
"polyfill",
|
59 |
-
"portable"
|
60 |
-
]
|
61 |
-
},
|
62 |
{
|
63 |
"name": "twig/twig",
|
64 |
-
"version": "
|
65 |
-
"version_normalized": "1.
|
66 |
"source": {
|
67 |
"type": "git",
|
68 |
"url": "https://github.com/twigphp/Twig.git",
|
69 |
-
"reference": "
|
70 |
},
|
71 |
"dist": {
|
72 |
"type": "zip",
|
73 |
-
"url": "https://api.github.com/repos/twigphp/Twig/zipball/
|
74 |
-
"reference": "
|
75 |
"shasum": ""
|
76 |
},
|
77 |
"require": {
|
78 |
-
"php": ">=5.
|
79 |
-
"symfony/polyfill-ctype": "^1.8"
|
80 |
},
|
81 |
"require-dev": {
|
82 |
"psr/container": "^1.0",
|
83 |
-
"symfony/debug": "
|
84 |
-
"symfony/phpunit-bridge": "
|
85 |
},
|
86 |
-
"time": "
|
87 |
"type": "library",
|
88 |
"extra": {
|
89 |
"branch-alias": {
|
90 |
-
"dev-master": "1.
|
91 |
}
|
92 |
},
|
93 |
-
"installation-source": "
|
94 |
"autoload": {
|
95 |
"psr-0": {
|
96 |
"Twig_": "lib/"
|
97 |
-
},
|
98 |
-
"psr-4": {
|
99 |
-
"Twig\\": "src/"
|
100 |
}
|
101 |
},
|
102 |
"notification-url": "https://packagist.org/downloads/",
|
@@ -117,12 +53,12 @@
|
|
117 |
},
|
118 |
{
|
119 |
"name": "Twig Team",
|
120 |
-
"homepage": "
|
121 |
"role": "Contributors"
|
122 |
}
|
123 |
],
|
124 |
"description": "Twig, the flexible, fast, and secure template language for PHP",
|
125 |
-
"homepage": "
|
126 |
"keywords": [
|
127 |
"templating"
|
128 |
]
|
1 |
[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
{
|
3 |
"name": "twig/twig",
|
4 |
+
"version": "v1.33.0",
|
5 |
+
"version_normalized": "1.33.0.0",
|
6 |
"source": {
|
7 |
"type": "git",
|
8 |
"url": "https://github.com/twigphp/Twig.git",
|
9 |
+
"reference": "05cf49921b13f6f01d3cfdf9018cfa7a8086fd5a"
|
10 |
},
|
11 |
"dist": {
|
12 |
"type": "zip",
|
13 |
+
"url": "https://api.github.com/repos/twigphp/Twig/zipball/05cf49921b13f6f01d3cfdf9018cfa7a8086fd5a",
|
14 |
+
"reference": "05cf49921b13f6f01d3cfdf9018cfa7a8086fd5a",
|
15 |
"shasum": ""
|
16 |
},
|
17 |
"require": {
|
18 |
+
"php": ">=5.2.7"
|
|
|
19 |
},
|
20 |
"require-dev": {
|
21 |
"psr/container": "^1.0",
|
22 |
+
"symfony/debug": "~2.7",
|
23 |
+
"symfony/phpunit-bridge": "~3.3@dev"
|
24 |
},
|
25 |
+
"time": "2017-03-22T15:40:09+00:00",
|
26 |
"type": "library",
|
27 |
"extra": {
|
28 |
"branch-alias": {
|
29 |
+
"dev-master": "1.33-dev"
|
30 |
}
|
31 |
},
|
32 |
+
"installation-source": "dist",
|
33 |
"autoload": {
|
34 |
"psr-0": {
|
35 |
"Twig_": "lib/"
|
|
|
|
|
|
|
36 |
}
|
37 |
},
|
38 |
"notification-url": "https://packagist.org/downloads/",
|
53 |
},
|
54 |
{
|
55 |
"name": "Twig Team",
|
56 |
+
"homepage": "http://twig.sensiolabs.org/contributors",
|
57 |
"role": "Contributors"
|
58 |
}
|
59 |
],
|
60 |
"description": "Twig, the flexible, fast, and secure template language for PHP",
|
61 |
+
"homepage": "http://twig.sensiolabs.org",
|
62 |
"keywords": [
|
63 |
"templating"
|
64 |
]
|
vendor/symfony/polyfill-ctype
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
Subproject commit 82ebae02209c21113908c229e9883c419720738a
|
|
vendor/twig/twig/.php_cs.dist
CHANGED
@@ -1,18 +1,15 @@
|
|
1 |
<?php
|
2 |
|
3 |
return PhpCsFixer\Config::create()
|
4 |
-
->setRules(
|
5 |
'@Symfony' => true,
|
6 |
'@Symfony:risky' => true,
|
7 |
-
'array_syntax' =>
|
8 |
-
'php_unit_fqcn_annotation' =>
|
9 |
'no_unreachable_default_argument_value' => false,
|
10 |
-
'braces' =>
|
11 |
'heredoc_to_nowdoc' => false,
|
12 |
-
|
13 |
-
'phpdoc_types_order' => ['null_adjustment' => 'always_last', 'sort_algorithm' => 'none'],
|
14 |
-
'native_function_invocation' => ['include' => ['@compiler_optimized'], 'scope' => 'all'],
|
15 |
-
])
|
16 |
->setRiskyAllowed(true)
|
17 |
->setFinder(PhpCsFixer\Finder::create()->in(__DIR__))
|
18 |
;
|
1 |
<?php
|
2 |
|
3 |
return PhpCsFixer\Config::create()
|
4 |
+
->setRules(array(
|
5 |
'@Symfony' => true,
|
6 |
'@Symfony:risky' => true,
|
7 |
+
'array_syntax' => array('syntax' => 'long'),
|
8 |
+
'php_unit_fqcn_annotation' => false,
|
9 |
'no_unreachable_default_argument_value' => false,
|
10 |
+
'braces' => array('allow_single_line_closure' => true),
|
11 |
'heredoc_to_nowdoc' => false,
|
12 |
+
))
|
|
|
|
|
|
|
13 |
->setRiskyAllowed(true)
|
14 |
->setFinder(PhpCsFixer\Finder::create()->in(__DIR__))
|
15 |
;
|
vendor/twig/twig/.travis.yml
CHANGED
@@ -8,36 +8,36 @@ cache:
|
|
8 |
- $HOME/.composer/cache/files
|
9 |
|
10 |
php:
|
|
|
|
|
11 |
- 5.4
|
12 |
- 5.5
|
13 |
- 5.6
|
14 |
- 7.0
|
15 |
- 7.1
|
16 |
-
-
|
17 |
-
- 7.3
|
18 |
|
19 |
env:
|
20 |
- TWIG_EXT=no
|
|
|
21 |
|
22 |
before_install:
|
23 |
-
|
24 |
-
- phpenv config-rm xdebug.ini || return 0
|
25 |
|
26 |
install:
|
27 |
-
|
|
|
28 |
|
29 |
before_script:
|
30 |
- if [ "$TWIG_EXT" == "yes" ]; then sh -c "cd ext/twig && phpize && ./configure --enable-twig && make && make install"; fi
|
31 |
- if [ "$TWIG_EXT" == "yes" ]; then echo "extension=twig.so" >> `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"`; fi
|
32 |
|
33 |
-
script: ./vendor/bin/simple-phpunit
|
34 |
-
|
35 |
matrix:
|
36 |
fast_finish: true
|
37 |
-
|
38 |
-
- php:
|
39 |
env: TWIG_EXT=yes
|
40 |
-
- php:
|
41 |
env: TWIG_EXT=yes
|
42 |
-
- php:
|
43 |
env: TWIG_EXT=yes
|
8 |
- $HOME/.composer/cache/files
|
9 |
|
10 |
php:
|
11 |
+
- 5.2
|
12 |
+
- 5.3
|
13 |
- 5.4
|
14 |
- 5.5
|
15 |
- 5.6
|
16 |
- 7.0
|
17 |
- 7.1
|
18 |
+
- hhvm
|
|
|
19 |
|
20 |
env:
|
21 |
- TWIG_EXT=no
|
22 |
+
- TWIG_EXT=yes
|
23 |
|
24 |
before_install:
|
25 |
+
- if [[ ! $TRAVIS_PHP_VERSION = hhvm* ]]; then phpenv config-rm xdebug.ini || echo "xdebug not available"; fi
|
|
|
26 |
|
27 |
install:
|
28 |
+
# Composer is not available on PHP 5.2
|
29 |
+
- if [ ${TRAVIS_PHP_VERSION:0:3} != "5.2" ]; then travis_retry composer install; fi
|
30 |
|
31 |
before_script:
|
32 |
- if [ "$TWIG_EXT" == "yes" ]; then sh -c "cd ext/twig && phpize && ./configure --enable-twig && make && make install"; fi
|
33 |
- if [ "$TWIG_EXT" == "yes" ]; then echo "extension=twig.so" >> `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"`; fi
|
34 |
|
|
|
|
|
35 |
matrix:
|
36 |
fast_finish: true
|
37 |
+
exclude:
|
38 |
+
- php: hhvm
|
39 |
env: TWIG_EXT=yes
|
40 |
+
- php: 7.0
|
41 |
env: TWIG_EXT=yes
|
42 |
+
- php: 7.1
|
43 |
env: TWIG_EXT=yes
|
vendor/twig/twig/CHANGELOG
CHANGED
@@ -1,99 +1,3 @@
|
|
1 |
-
* 1.38.0 (2019-XX-XX)
|
2 |
-
|
3 |
-
* added Twig\Loader\ChainLoader::getLoaders()
|
4 |
-
* changed internal code to use the namespaced classes as much as possible
|
5 |
-
|
6 |
-
* 1.37.1 (2019-01-14)
|
7 |
-
|
8 |
-
* fixed regression (key exists check for non ArrayObject objects)
|
9 |
-
* fixed logic in TemplateWrapper
|
10 |
-
|
11 |
-
* 1.37.0 (2019-01-14)
|
12 |
-
|
13 |
-
* fixed ArrayObject access with a null value
|
14 |
-
* fixed embedded templates starting with a BOM
|
15 |
-
* fixed using a Twig_TemplateWrapper instance as an argument to extends
|
16 |
-
* switched generated code to use the PHP short array notation
|
17 |
-
* dropped PHP 5.3 support
|
18 |
-
* fixed float representation in compiled templates
|
19 |
-
* added a second argument to the join filter (last separator configuration)
|
20 |
-
|
21 |
-
* 1.36.0 (2018-12-16)
|
22 |
-
|
23 |
-
* made sure twig_include returns a string
|
24 |
-
* fixed multi-byte UFT-8 in escape('html_attr')
|
25 |
-
* added the "deprecated" tag
|
26 |
-
* added support for dynamically named tests
|
27 |
-
* fixed GlobalsInterface extended class
|
28 |
-
* fixed filesystem loader throwing an exception instead of returning false
|
29 |
-
|
30 |
-
* 1.35.4 (2018-07-13)
|
31 |
-
|
32 |
-
* ensured that syntax errors are triggered with the right line
|
33 |
-
* added the Symfony ctype polyfill as a dependency
|
34 |
-
* "js" filter now produces valid JSON
|
35 |
-
|
36 |
-
* 1.35.3 (2018-03-20)
|
37 |
-
|
38 |
-
* fixed block names unicity
|
39 |
-
* fixed counting children of SimpleXMLElement objects
|
40 |
-
* added missing else clause to avoid infinite loops
|
41 |
-
* fixed .. (range operator) in sandbox policy
|
42 |
-
|
43 |
-
* 1.35.2 (2018-03-03)
|
44 |
-
|
45 |
-
* fixed a regression in the way the profiler is registered in templates
|
46 |
-
|
47 |
-
* 1.35.1 (2018-03-02)
|
48 |
-
|
49 |
-
* added an exception when using "===" instead of "same as"
|
50 |
-
* fixed possible array to string conversion concealing actual error
|
51 |
-
* made variable names deterministic in compiled templates
|
52 |
-
* fixed length filter when passing an instance of IteratorAggregate
|
53 |
-
* fixed Environment::resolveTemplate to accept instances of TemplateWrapper
|
54 |
-
|
55 |
-
* 1.35.0 (2017-09-27)
|
56 |
-
|
57 |
-
* added Twig_Profiler_Profile::reset()
|
58 |
-
* fixed use TokenParser to return an empty Node
|
59 |
-
* added RuntimeExtensionInterface
|
60 |
-
* added circular reference detection when loading templates
|
61 |
-
|
62 |
-
* 1.34.4 (2017-07-04)
|
63 |
-
|
64 |
-
* added support for runtime loaders in IntegrationTestCase
|
65 |
-
* fixed deprecation when using Twig_Profiler_Dumper_Html
|
66 |
-
|
67 |
-
* 1.34.3 (2017-06-07)
|
68 |
-
|
69 |
-
* fixed namespaces introduction
|
70 |
-
|
71 |
-
* 1.34.2 (2017-06-05)
|
72 |
-
|
73 |
-
* fixed namespaces introduction
|
74 |
-
|
75 |
-
* 1.34.1 (2017-06-05)
|
76 |
-
|
77 |
-
* fixed namespaces introduction
|
78 |
-
|
79 |
-
* 1.34.0 (2017-06-05)
|
80 |
-
|
81 |
-
* added support for PHPUnit 6 when testing extensions
|
82 |
-
* fixed PHP 7.2 compatibility
|
83 |
-
* fixed template name generation in Twig_Environment::createTemplate()
|
84 |
-
* removed final tag on Twig_TokenParser_Include
|
85 |
-
* added namespaced aliases for all (non-deprecated) classes and interfaces
|
86 |
-
* dropped HHVM support
|
87 |
-
* dropped PHP 5.2 support
|
88 |
-
|
89 |
-
* 1.33.2 (2017-04-20)
|
90 |
-
|
91 |
-
* fixed edge case in the method cache for Twig attributes
|
92 |
-
|
93 |
-
* 1.33.1 (2017-04-18)
|
94 |
-
|
95 |
-
* fixed the empty() test
|
96 |
-
|
97 |
* 1.33.0 (2017-03-22)
|
98 |
|
99 |
* fixed a race condition handling when writing cache files
|
@@ -203,7 +107,7 @@
|
|
203 |
|
204 |
* fixed reserved keywords (forbids true, false, null and none keywords for variables names)
|
205 |
* fixed support for PHP7 (Throwable support)
|
206 |
-
* marked the following methods as being internals on Twig_Environment:
|
207 |
getFunctions(), getFilters(), getTests(), getFunction(), getFilter(), getTest(),
|
208 |
getTokenParsers(), getTags(), getNodeVisitors(), getUnaryOperators(), getBinaryOperators(),
|
209 |
getFunctions(), getFilters(), getGlobals(), initGlobals(), initExtensions(), and initExtension()
|
@@ -287,7 +191,7 @@
|
|
287 |
* fixed limited RCEs when in sandbox mode
|
288 |
* deprecated Twig_Template::getEnvironment()
|
289 |
* deprecated the _self variable for usage outside of the from and import tags
|
290 |
-
* added Twig_BaseNodeVisitor to ease the compatibility of node visitors
|
291 |
between 1.x and 2.x
|
292 |
|
293 |
* 1.19.0 (2015-07-31)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
* 1.33.0 (2017-03-22)
|
2 |
|
3 |
* fixed a race condition handling when writing cache files
|
107 |
|
108 |
* fixed reserved keywords (forbids true, false, null and none keywords for variables names)
|
109 |
* fixed support for PHP7 (Throwable support)
|
110 |
+
* marked the following methods as being internals on Twig_Environment:
|
111 |
getFunctions(), getFilters(), getTests(), getFunction(), getFilter(), getTest(),
|
112 |
getTokenParsers(), getTags(), getNodeVisitors(), getUnaryOperators(), getBinaryOperators(),
|
113 |
getFunctions(), getFilters(), getGlobals(), initGlobals(), initExtensions(), and initExtension()
|
191 |
* fixed limited RCEs when in sandbox mode
|
192 |
* deprecated Twig_Template::getEnvironment()
|
193 |
* deprecated the _self variable for usage outside of the from and import tags
|
194 |
+
* added Twig_BaseNodeVisitor to ease the compatibility of node visitors
|
195 |
between 1.x and 2.x
|
196 |
|
197 |
* 1.19.0 (2015-07-31)
|
vendor/twig/twig/LICENSE
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
Copyright (c) 2009-
|
2 |
|
3 |
Some rights reserved.
|
4 |
|
1 |
+
Copyright (c) 2009-2017 by the Twig Team.
|
2 |
|
3 |
Some rights reserved.
|
4 |
|
vendor/twig/twig/README.rst
CHANGED
@@ -12,4 +12,4 @@ More Information
|
|
12 |
|
13 |
Read the `documentation`_ for more information.
|
14 |
|
15 |
-
.. _documentation:
|
12 |
|
13 |
Read the `documentation`_ for more information.
|
14 |
|
15 |
+
.. _documentation: http://twig.sensiolabs.org/documentation
|
vendor/twig/twig/composer.json
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
"type": "library",
|
4 |
"description": "Twig, the flexible, fast, and secure template language for PHP",
|
5 |
"keywords": ["templating"],
|
6 |
-
"homepage": "
|
7 |
"license": "BSD-3-Clause",
|
8 |
"authors": [
|
9 |
{
|
@@ -14,7 +14,7 @@
|
|
14 |
},
|
15 |
{
|
16 |
"name": "Twig Team",
|
17 |
-
"homepage": "
|
18 |
"role": "Contributors"
|
19 |
},
|
20 |
{
|
@@ -23,26 +23,25 @@
|
|
23 |
"role": "Project Founder"
|
24 |
}
|
25 |
],
|
|
|
|
|
|
|
26 |
"require": {
|
27 |
-
"php": ">=5.
|
28 |
-
"symfony/polyfill-ctype": "^1.8"
|
29 |
},
|
30 |
"require-dev": {
|
31 |
-
"symfony/phpunit-bridge": "
|
32 |
-
"symfony/debug": "
|
33 |
"psr/container": "^1.0"
|
34 |
},
|
35 |
"autoload": {
|
36 |
"psr-0" : {
|
37 |
"Twig_" : "lib/"
|
38 |
-
},
|
39 |
-
"psr-4" : {
|
40 |
-
"Twig\\" : "src/"
|
41 |
}
|
42 |
},
|
43 |
"extra": {
|
44 |
"branch-alias": {
|
45 |
-
"dev-master": "1.
|
46 |
}
|
47 |
}
|
48 |
}
|
3 |
"type": "library",
|
4 |
"description": "Twig, the flexible, fast, and secure template language for PHP",
|
5 |
"keywords": ["templating"],
|
6 |
+
"homepage": "http://twig.sensiolabs.org",
|
7 |
"license": "BSD-3-Clause",
|
8 |
"authors": [
|
9 |
{
|
14 |
},
|
15 |
{
|
16 |
"name": "Twig Team",
|
17 |
+
"homepage": "http://twig.sensiolabs.org/contributors",
|
18 |
"role": "Contributors"
|
19 |
},
|
20 |
{
|
23 |
"role": "Project Founder"
|
24 |
}
|
25 |
],
|
26 |
+
"support": {
|
27 |
+
"forum": "https://groups.google.com/forum/#!forum/twig-users"
|
28 |
+
},
|
29 |
"require": {
|
30 |
+
"php": ">=5.2.7"
|
|
|
31 |
},
|
32 |
"require-dev": {
|
33 |
+
"symfony/phpunit-bridge": "~3.3@dev",
|
34 |
+
"symfony/debug": "~2.7",
|
35 |
"psr/container": "^1.0"
|
36 |
},
|
37 |
"autoload": {
|
38 |
"psr-0" : {
|
39 |
"Twig_" : "lib/"
|
|
|
|
|
|
|
40 |
}
|
41 |
},
|
42 |
"extra": {
|
43 |
"branch-alias": {
|
44 |
+
"dev-master": "1.33-dev"
|
45 |
}
|
46 |
}
|
47 |
}
|
vendor/twig/twig/lib/Twig/Autoloader.php
CHANGED
@@ -29,7 +29,11 @@ class Twig_Autoloader
|
|
29 |
{
|
30 |
@trigger_error('Using Twig_Autoloader is deprecated since version 1.21. Use Composer instead.', E_USER_DEPRECATED);
|
31 |
|
32 |
-
|
|
|
|
|
|
|
|
|
33 |
}
|
34 |
|
35 |
/**
|
@@ -43,7 +47,7 @@ class Twig_Autoloader
|
|
43 |
return;
|
44 |
}
|
45 |
|
46 |
-
if (is_file($file =
|
47 |
require $file;
|
48 |
}
|
49 |
}
|
29 |
{
|
30 |
@trigger_error('Using Twig_Autoloader is deprecated since version 1.21. Use Composer instead.', E_USER_DEPRECATED);
|
31 |
|
32 |
+
if (PHP_VERSION_ID < 50300) {
|
33 |
+
spl_autoload_register(array(__CLASS__, 'autoload'));
|
34 |
+
} else {
|
35 |
+
spl_autoload_register(array(__CLASS__, 'autoload'), true, $prepend);
|
36 |
+
}
|
37 |
}
|
38 |
|
39 |
/**
|
47 |
return;
|
48 |
}
|
49 |
|
50 |
+
if (is_file($file = dirname(__FILE__).'/../'.str_replace(array('_', "\0"), array('/', ''), $class).'.php')) {
|
51 |
require $file;
|
52 |
}
|
53 |
}
|
vendor/twig/twig/lib/Twig/BaseNodeVisitor.php
CHANGED
@@ -9,30 +9,26 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Environment;
|
13 |
-
use Twig\Node\Node;
|
14 |
-
use Twig\NodeVisitor\NodeVisitorInterface;
|
15 |
-
|
16 |
/**
|
17 |
* Twig_BaseNodeVisitor can be used to make node visitors compatible with Twig 1.x and 2.x.
|
18 |
*
|
19 |
* @author Fabien Potencier <fabien@symfony.com>
|
20 |
*/
|
21 |
-
abstract class Twig_BaseNodeVisitor implements
|
22 |
{
|
23 |
-
final public function enterNode(Twig_NodeInterface $node,
|
24 |
{
|
25 |
-
if (!$node instanceof
|
26 |
-
throw new
|
27 |
}
|
28 |
|
29 |
return $this->doEnterNode($node, $env);
|
30 |
}
|
31 |
|
32 |
-
final public function leaveNode(Twig_NodeInterface $node,
|
33 |
{
|
34 |
-
if (!$node instanceof
|
35 |
-
throw new
|
36 |
}
|
37 |
|
38 |
return $this->doLeaveNode($node, $env);
|
@@ -41,18 +37,14 @@ abstract class Twig_BaseNodeVisitor implements NodeVisitorInterface
|
|
41 |
/**
|
42 |
* Called before child nodes are visited.
|
43 |
*
|
44 |
-
* @return
|
45 |
*/
|
46 |
-
abstract protected function doEnterNode(
|
47 |
|
48 |
/**
|
49 |
* Called after child nodes are visited.
|
50 |
*
|
51 |
-
* @return
|
52 |
*/
|
53 |
-
abstract protected function doLeaveNode(
|
54 |
}
|
55 |
-
|
56 |
-
class_alias('Twig_BaseNodeVisitor', 'Twig\NodeVisitor\AbstractNodeVisitor', false);
|
57 |
-
class_exists('Twig_Environment');
|
58 |
-
class_exists('Twig_Node');
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
|
|
|
|
12 |
/**
|
13 |
* Twig_BaseNodeVisitor can be used to make node visitors compatible with Twig 1.x and 2.x.
|
14 |
*
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
+
abstract class Twig_BaseNodeVisitor implements Twig_NodeVisitorInterface
|
18 |
{
|
19 |
+
final public function enterNode(Twig_NodeInterface $node, Twig_Environment $env)
|
20 |
{
|
21 |
+
if (!$node instanceof Twig_Node) {
|
22 |
+
throw new LogicException('Twig_BaseNodeVisitor only supports Twig_Node instances.');
|
23 |
}
|
24 |
|
25 |
return $this->doEnterNode($node, $env);
|
26 |
}
|
27 |
|
28 |
+
final public function leaveNode(Twig_NodeInterface $node, Twig_Environment $env)
|
29 |
{
|
30 |
+
if (!$node instanceof Twig_Node) {
|
31 |
+
throw new LogicException('Twig_BaseNodeVisitor only supports Twig_Node instances.');
|
32 |
}
|
33 |
|
34 |
return $this->doLeaveNode($node, $env);
|
37 |
/**
|
38 |
* Called before child nodes are visited.
|
39 |
*
|
40 |
+
* @return Twig_Node The modified node
|
41 |
*/
|
42 |
+
abstract protected function doEnterNode(Twig_Node $node, Twig_Environment $env);
|
43 |
|
44 |
/**
|
45 |
* Called after child nodes are visited.
|
46 |
*
|
47 |
+
* @return Twig_Node|false The modified node or false if the node must be removed
|
48 |
*/
|
49 |
+
abstract protected function doLeaveNode(Twig_Node $node, Twig_Environment $env);
|
50 |
}
|
|
|
|
|
|
|
|
vendor/twig/twig/lib/Twig/Cache/Filesystem.php
CHANGED
@@ -9,14 +9,12 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Cache\CacheInterface;
|
13 |
-
|
14 |
/**
|
15 |
* Implements a cache on the filesystem.
|
16 |
*
|
17 |
* @author Andrew Tch <andrew@noop.lv>
|
18 |
*/
|
19 |
-
class Twig_Cache_Filesystem implements
|
20 |
{
|
21 |
const FORCE_BYTECODE_INVALIDATION = 1;
|
22 |
|
@@ -24,8 +22,8 @@ class Twig_Cache_Filesystem implements CacheInterface
|
|
24 |
private $options;
|
25 |
|
26 |
/**
|
27 |
-
* @param
|
28 |
-
* @param
|
29 |
*/
|
30 |
public function __construct($directory, $options = 0)
|
31 |
{
|
@@ -49,16 +47,18 @@ class Twig_Cache_Filesystem implements CacheInterface
|
|
49 |
|
50 |
public function write($key, $content)
|
51 |
{
|
52 |
-
$dir =
|
53 |
if (!is_dir($dir)) {
|
54 |
if (false === @mkdir($dir, 0777, true)) {
|
55 |
-
|
|
|
|
|
56 |
if (!is_dir($dir)) {
|
57 |
-
throw new
|
58 |
}
|
59 |
}
|
60 |
} elseif (!is_writable($dir)) {
|
61 |
-
throw new
|
62 |
}
|
63 |
|
64 |
$tmpFile = tempnam($dir, basename($key));
|
@@ -67,9 +67,9 @@ class Twig_Cache_Filesystem implements CacheInterface
|
|
67 |
|
68 |
if (self::FORCE_BYTECODE_INVALIDATION == ($this->options & self::FORCE_BYTECODE_INVALIDATION)) {
|
69 |
// Compile cached file into bytecode cache
|
70 |
-
if (
|
71 |
opcache_invalidate($key, true);
|
72 |
-
} elseif (
|
73 |
apc_compile_file($key);
|
74 |
}
|
75 |
}
|
@@ -77,7 +77,7 @@ class Twig_Cache_Filesystem implements CacheInterface
|
|
77 |
return;
|
78 |
}
|
79 |
|
80 |
-
throw new
|
81 |
}
|
82 |
|
83 |
public function getTimestamp($key)
|
@@ -89,5 +89,3 @@ class Twig_Cache_Filesystem implements CacheInterface
|
|
89 |
return (int) @filemtime($key);
|
90 |
}
|
91 |
}
|
92 |
-
|
93 |
-
class_alias('Twig_Cache_Filesystem', 'Twig\Cache\FilesystemCache', false);
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
12 |
/**
|
13 |
* Implements a cache on the filesystem.
|
14 |
*
|
15 |
* @author Andrew Tch <andrew@noop.lv>
|
16 |
*/
|
17 |
+
class Twig_Cache_Filesystem implements Twig_CacheInterface
|
18 |
{
|
19 |
const FORCE_BYTECODE_INVALIDATION = 1;
|
20 |
|
22 |
private $options;
|
23 |
|
24 |
/**
|
25 |
+
* @param $directory string The root cache directory
|
26 |
+
* @param $options int A set of options
|
27 |
*/
|
28 |
public function __construct($directory, $options = 0)
|
29 |
{
|
47 |
|
48 |
public function write($key, $content)
|
49 |
{
|
50 |
+
$dir = dirname($key);
|
51 |
if (!is_dir($dir)) {
|
52 |
if (false === @mkdir($dir, 0777, true)) {
|
53 |
+
if (PHP_VERSION_ID >= 50300) {
|
54 |
+
clearstatcache(true, $dir);
|
55 |
+
}
|
56 |
if (!is_dir($dir)) {
|
57 |
+
throw new RuntimeException(sprintf('Unable to create the cache directory (%s).', $dir));
|
58 |
}
|
59 |
}
|
60 |
} elseif (!is_writable($dir)) {
|
61 |
+
throw new RuntimeException(sprintf('Unable to write in the cache directory (%s).', $dir));
|
62 |
}
|
63 |
|
64 |
$tmpFile = tempnam($dir, basename($key));
|
67 |
|
68 |
if (self::FORCE_BYTECODE_INVALIDATION == ($this->options & self::FORCE_BYTECODE_INVALIDATION)) {
|
69 |
// Compile cached file into bytecode cache
|
70 |
+
if (function_exists('opcache_invalidate')) {
|
71 |
opcache_invalidate($key, true);
|
72 |
+
} elseif (function_exists('apc_compile_file')) {
|
73 |
apc_compile_file($key);
|
74 |
}
|
75 |
}
|
77 |
return;
|
78 |
}
|
79 |
|
80 |
+
throw new RuntimeException(sprintf('Failed to write cache file "%s".', $key));
|
81 |
}
|
82 |
|
83 |
public function getTimestamp($key)
|
89 |
return (int) @filemtime($key);
|
90 |
}
|
91 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Cache/Null.php
CHANGED
@@ -9,8 +9,6 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Cache\CacheInterface;
|
13 |
-
|
14 |
/**
|
15 |
* Implements a no-cache strategy.
|
16 |
*
|
@@ -18,7 +16,7 @@ use Twig\Cache\CacheInterface;
|
|
18 |
*
|
19 |
* @author Fabien Potencier <fabien@symfony.com>
|
20 |
*/
|
21 |
-
class Twig_Cache_Null implements
|
22 |
{
|
23 |
public function generateKey($name, $className)
|
24 |
{
|
@@ -38,5 +36,3 @@ class Twig_Cache_Null implements CacheInterface
|
|
38 |
return 0;
|
39 |
}
|
40 |
}
|
41 |
-
|
42 |
-
class_alias('Twig_Cache_Null', 'Twig\Cache\NullCache', false);
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
12 |
/**
|
13 |
* Implements a no-cache strategy.
|
14 |
*
|
16 |
*
|
17 |
* @author Fabien Potencier <fabien@symfony.com>
|
18 |
*/
|
19 |
+
class Twig_Cache_Null implements Twig_CacheInterface
|
20 |
{
|
21 |
public function generateKey($name, $className)
|
22 |
{
|
36 |
return 0;
|
37 |
}
|
38 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/CacheInterface.php
CHANGED
@@ -54,5 +54,3 @@ interface Twig_CacheInterface
|
|
54 |
*/
|
55 |
public function getTimestamp($key);
|
56 |
}
|
57 |
-
|
58 |
-
class_alias('Twig_CacheInterface', 'Twig\Cache\CacheInterface', false);
|
54 |
*/
|
55 |
public function getTimestamp($key);
|
56 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Compiler.php
CHANGED
@@ -10,9 +10,6 @@
|
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
|
13 |
-
use Twig\Environment;
|
14 |
-
use Twig\Node\ModuleNode;
|
15 |
-
|
16 |
/**
|
17 |
* Compiles a node to PHP code.
|
18 |
*
|
@@ -24,13 +21,12 @@ class Twig_Compiler implements Twig_CompilerInterface
|
|
24 |
protected $source;
|
25 |
protected $indentation;
|
26 |
protected $env;
|
27 |
-
protected $debugInfo =
|
28 |
protected $sourceOffset;
|
29 |
protected $sourceLine;
|
30 |
protected $filename;
|
31 |
-
private $varNameSalt = 0;
|
32 |
|
33 |
-
public function __construct(
|
34 |
{
|
35 |
$this->env = $env;
|
36 |
}
|
@@ -48,7 +44,7 @@ class Twig_Compiler implements Twig_CompilerInterface
|
|
48 |
/**
|
49 |
* Returns the environment instance related to this compiler.
|
50 |
*
|
51 |
-
* @return
|
52 |
*/
|
53 |
public function getEnvironment()
|
54 |
{
|
@@ -68,7 +64,8 @@ class Twig_Compiler implements Twig_CompilerInterface
|
|
68 |
/**
|
69 |
* Compiles a node.
|
70 |
*
|
71 |
-
* @param
|
|
|
72 |
*
|
73 |
* @return $this
|
74 |
*/
|
@@ -76,14 +73,13 @@ class Twig_Compiler implements Twig_CompilerInterface
|
|
76 |
{
|
77 |
$this->lastLine = null;
|
78 |
$this->source = '';
|
79 |
-
$this->debugInfo =
|
80 |
$this->sourceOffset = 0;
|
81 |
// source code starts at 1 (as we then increment it when we encounter new lines)
|
82 |
$this->sourceLine = 1;
|
83 |
$this->indentation = $indentation;
|
84 |
-
$this->varNameSalt = 0;
|
85 |
|
86 |
-
if ($node instanceof
|
87 |
// to be removed in 2.0
|
88 |
$this->filename = $node->getTemplateName();
|
89 |
}
|
@@ -125,7 +121,7 @@ class Twig_Compiler implements Twig_CompilerInterface
|
|
125 |
*/
|
126 |
public function write()
|
127 |
{
|
128 |
-
$strings =
|
129 |
foreach ($strings as $string) {
|
130 |
$this->source .= str_repeat(' ', $this->indentation * 4).$string;
|
131 |
}
|
@@ -172,22 +168,22 @@ class Twig_Compiler implements Twig_CompilerInterface
|
|
172 |
*/
|
173 |
public function repr($value)
|
174 |
{
|
175 |
-
if (
|
176 |
if (false !== $locale = setlocale(LC_NUMERIC, '0')) {
|
177 |
setlocale(LC_NUMERIC, 'C');
|
178 |
}
|
179 |
|
180 |
-
$this->raw(
|
181 |
|
182 |
if (false !== $locale) {
|
183 |
setlocale(LC_NUMERIC, $locale);
|
184 |
}
|
185 |
} elseif (null === $value) {
|
186 |
$this->raw('null');
|
187 |
-
} elseif (
|
188 |
$this->raw($value ? 'true' : 'false');
|
189 |
-
} elseif (
|
190 |
-
$this->raw('
|
191 |
$first = true;
|
192 |
foreach ($value as $key => $v) {
|
193 |
if (!$first) {
|
@@ -198,7 +194,7 @@ class Twig_Compiler implements Twig_CompilerInterface
|
|
198 |
$this->raw(' => ');
|
199 |
$this->repr($v);
|
200 |
}
|
201 |
-
$this->raw('
|
202 |
} else {
|
203 |
$this->string($value);
|
204 |
}
|
@@ -227,7 +223,7 @@ class Twig_Compiler implements Twig_CompilerInterface
|
|
227 |
} else {
|
228 |
$this->sourceLine += substr_count($this->source, "\n", $this->sourceOffset);
|
229 |
}
|
230 |
-
$this->sourceOffset =
|
231 |
$this->debugInfo[$this->sourceLine] = $node->getTemplateLine();
|
232 |
|
233 |
$this->lastLine = $node->getTemplateLine();
|
@@ -264,13 +260,13 @@ class Twig_Compiler implements Twig_CompilerInterface
|
|
264 |
*
|
265 |
* @return $this
|
266 |
*
|
267 |
-
* @throws
|
268 |
*/
|
269 |
public function outdent($step = 1)
|
270 |
{
|
271 |
// can't outdent by more steps than the current indentation level
|
272 |
if ($this->indentation < $step) {
|
273 |
-
throw new
|
274 |
}
|
275 |
|
276 |
$this->indentation -= $step;
|
@@ -280,9 +276,6 @@ class Twig_Compiler implements Twig_CompilerInterface
|
|
280 |
|
281 |
public function getVarName()
|
282 |
{
|
283 |
-
return sprintf('__internal_%s', hash('sha256',
|
284 |
}
|
285 |
}
|
286 |
-
|
287 |
-
class_alias('Twig_Compiler', 'Twig\Compiler', false);
|
288 |
-
class_exists('Twig_Node');
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
|
|
|
|
|
|
|
13 |
/**
|
14 |
* Compiles a node to PHP code.
|
15 |
*
|
21 |
protected $source;
|
22 |
protected $indentation;
|
23 |
protected $env;
|
24 |
+
protected $debugInfo = array();
|
25 |
protected $sourceOffset;
|
26 |
protected $sourceLine;
|
27 |
protected $filename;
|
|
|
28 |
|
29 |
+
public function __construct(Twig_Environment $env)
|
30 |
{
|
31 |
$this->env = $env;
|
32 |
}
|
44 |
/**
|
45 |
* Returns the environment instance related to this compiler.
|
46 |
*
|
47 |
+
* @return Twig_Environment
|
48 |
*/
|
49 |
public function getEnvironment()
|
50 |
{
|
64 |
/**
|
65 |
* Compiles a node.
|
66 |
*
|
67 |
+
* @param Twig_NodeInterface $node The node to compile
|
68 |
+
* @param int $indentation The current indentation
|
69 |
*
|
70 |
* @return $this
|
71 |
*/
|
73 |
{
|
74 |
$this->lastLine = null;
|
75 |
$this->source = '';
|
76 |
+
$this->debugInfo = array();
|
77 |
$this->sourceOffset = 0;
|
78 |
// source code starts at 1 (as we then increment it when we encounter new lines)
|
79 |
$this->sourceLine = 1;
|
80 |
$this->indentation = $indentation;
|
|
|
81 |
|
82 |
+
if ($node instanceof Twig_Node_Module) {
|
83 |
// to be removed in 2.0
|
84 |
$this->filename = $node->getTemplateName();
|
85 |
}
|
121 |
*/
|
122 |
public function write()
|
123 |
{
|
124 |
+
$strings = func_get_args();
|
125 |
foreach ($strings as $string) {
|
126 |
$this->source .= str_repeat(' ', $this->indentation * 4).$string;
|
127 |
}
|
168 |
*/
|
169 |
public function repr($value)
|
170 |
{
|
171 |
+
if (is_int($value) || is_float($value)) {
|
172 |
if (false !== $locale = setlocale(LC_NUMERIC, '0')) {
|
173 |
setlocale(LC_NUMERIC, 'C');
|
174 |
}
|
175 |
|
176 |
+
$this->raw($value);
|
177 |
|
178 |
if (false !== $locale) {
|
179 |
setlocale(LC_NUMERIC, $locale);
|
180 |
}
|
181 |
} elseif (null === $value) {
|
182 |
$this->raw('null');
|
183 |
+
} elseif (is_bool($value)) {
|
184 |
$this->raw($value ? 'true' : 'false');
|
185 |
+
} elseif (is_array($value)) {
|
186 |
+
$this->raw('array(');
|
187 |
$first = true;
|
188 |
foreach ($value as $key => $v) {
|
189 |
if (!$first) {
|
194 |
$this->raw(' => ');
|
195 |
$this->repr($v);
|
196 |
}
|
197 |
+
$this->raw(')');
|
198 |
} else {
|
199 |
$this->string($value);
|
200 |
}
|
223 |
} else {
|
224 |
$this->sourceLine += substr_count($this->source, "\n", $this->sourceOffset);
|
225 |
}
|
226 |
+
$this->sourceOffset = strlen($this->source);
|
227 |
$this->debugInfo[$this->sourceLine] = $node->getTemplateLine();
|
228 |
|
229 |
$this->lastLine = $node->getTemplateLine();
|
260 |
*
|
261 |
* @return $this
|
262 |
*
|
263 |
+
* @throws LogicException When trying to outdent too much so the indentation would become negative
|
264 |
*/
|
265 |
public function outdent($step = 1)
|
266 |
{
|
267 |
// can't outdent by more steps than the current indentation level
|
268 |
if ($this->indentation < $step) {
|
269 |
+
throw new LogicException('Unable to call outdent() as the indentation would become negative.');
|
270 |
}
|
271 |
|
272 |
$this->indentation -= $step;
|
276 |
|
277 |
public function getVarName()
|
278 |
{
|
279 |
+
return sprintf('__internal_%s', hash('sha256', uniqid(mt_rand(), true), false));
|
280 |
}
|
281 |
}
|
|
|
|
|
|
vendor/twig/twig/lib/Twig/ContainerRuntimeLoader.php
CHANGED
@@ -10,7 +10,6 @@
|
|
10 |
*/
|
11 |
|
12 |
use Psr\Container\ContainerInterface;
|
13 |
-
use Twig\RuntimeLoader\RuntimeLoaderInterface;
|
14 |
|
15 |
/**
|
16 |
* Lazily loads Twig runtime implementations from a PSR-11 container.
|
@@ -20,7 +19,7 @@ use Twig\RuntimeLoader\RuntimeLoaderInterface;
|
|
20 |
* @author Fabien Potencier <fabien@symfony.com>
|
21 |
* @author Robin Chalas <robin.chalas@gmail.com>
|
22 |
*/
|
23 |
-
class Twig_ContainerRuntimeLoader implements
|
24 |
{
|
25 |
private $container;
|
26 |
|
@@ -36,5 +35,3 @@ class Twig_ContainerRuntimeLoader implements RuntimeLoaderInterface
|
|
36 |
}
|
37 |
}
|
38 |
}
|
39 |
-
|
40 |
-
class_alias('Twig_ContainerRuntimeLoader', 'Twig\RuntimeLoader\ContainerRuntimeLoader', false);
|
10 |
*/
|
11 |
|
12 |
use Psr\Container\ContainerInterface;
|
|
|
13 |
|
14 |
/**
|
15 |
* Lazily loads Twig runtime implementations from a PSR-11 container.
|
19 |
* @author Fabien Potencier <fabien@symfony.com>
|
20 |
* @author Robin Chalas <robin.chalas@gmail.com>
|
21 |
*/
|
22 |
+
class Twig_ContainerRuntimeLoader implements Twig_RuntimeLoaderInterface
|
23 |
{
|
24 |
private $container;
|
25 |
|
35 |
}
|
36 |
}
|
37 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Environment.php
CHANGED
@@ -9,39 +9,6 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Cache\CacheInterface;
|
13 |
-
use Twig\Cache\FilesystemCache;
|
14 |
-
use Twig\Cache\NullCache;
|
15 |
-
use Twig\Compiler;
|
16 |
-
use Twig\Error\Error;
|
17 |
-
use Twig\Error\LoaderError;
|
18 |
-
use Twig\Error\RuntimeError;
|
19 |
-
use Twig\Error\SyntaxError;
|
20 |
-
use Twig\Extension\CoreExtension;
|
21 |
-
use Twig\Extension\EscaperExtension;
|
22 |
-
use Twig\Extension\ExtensionInterface;
|
23 |
-
use Twig\Extension\GlobalsInterface;
|
24 |
-
use Twig\Extension\InitRuntimeInterface;
|
25 |
-
use Twig\Extension\OptimizerExtension;
|
26 |
-
use Twig\Extension\StagingExtension;
|
27 |
-
use Twig\Lexer;
|
28 |
-
use Twig\Loader\ArrayLoader;
|
29 |
-
use Twig\Loader\ChainLoader;
|
30 |
-
use Twig\Loader\LoaderInterface;
|
31 |
-
use Twig\Loader\SourceContextLoaderInterface;
|
32 |
-
use Twig\Node\ModuleNode;
|
33 |
-
use Twig\NodeVisitor\NodeVisitorInterface;
|
34 |
-
use Twig\Parser;
|
35 |
-
use Twig\RuntimeLoader\RuntimeLoaderInterface;
|
36 |
-
use Twig\Source;
|
37 |
-
use Twig\Template;
|
38 |
-
use Twig\TemplateWrapper;
|
39 |
-
use Twig\TokenParser\TokenParserInterface;
|
40 |
-
use Twig\TokenStream;
|
41 |
-
use Twig\TwigFilter;
|
42 |
-
use Twig\TwigFunction;
|
43 |
-
use Twig\TwigTest;
|
44 |
-
|
45 |
/**
|
46 |
* Stores the Twig configuration.
|
47 |
*
|
@@ -49,12 +16,12 @@ use Twig\TwigTest;
|
|
49 |
*/
|
50 |
class Twig_Environment
|
51 |
{
|
52 |
-
const VERSION = '1.
|
53 |
-
const VERSION_ID =
|
54 |
const MAJOR_VERSION = 1;
|
55 |
-
const MINOR_VERSION =
|
56 |
const RELEASE_VERSION = 0;
|
57 |
-
const EXTRA_VERSION = '
|
58 |
|
59 |
protected $charset;
|
60 |
protected $loader;
|
@@ -79,19 +46,18 @@ class Twig_Environment
|
|
79 |
protected $unaryOperators;
|
80 |
protected $binaryOperators;
|
81 |
protected $templateClassPrefix = '__TwigTemplate_';
|
82 |
-
protected $functionCallbacks =
|
83 |
-
protected $filterCallbacks =
|
84 |
protected $staging;
|
85 |
|
86 |
private $originalCache;
|
87 |
private $bcWriteCacheFile = false;
|
88 |
private $bcGetCacheFilename = false;
|
89 |
private $lastModifiedExtension = 0;
|
90 |
-
private $extensionsByClass =
|
91 |
-
private $runtimeLoaders =
|
92 |
-
private $runtimes =
|
93 |
private $optionsHash;
|
94 |
-
private $loading = [];
|
95 |
|
96 |
/**
|
97 |
* Constructor.
|
@@ -127,25 +93,28 @@ class Twig_Environment
|
|
127 |
* * optimizations: A flag that indicates which optimizations to apply
|
128 |
* (default to -1 which means that all optimizations are enabled;
|
129 |
* set it to 0 to disable).
|
|
|
|
|
|
|
130 |
*/
|
131 |
-
public function __construct(
|
132 |
{
|
133 |
if (null !== $loader) {
|
134 |
$this->setLoader($loader);
|
135 |
} else {
|
136 |
-
@trigger_error('Not passing a
|
137 |
}
|
138 |
|
139 |
-
$options = array_merge(
|
140 |
'debug' => false,
|
141 |
'charset' => 'UTF-8',
|
142 |
-
'base_template_class' => '
|
143 |
'strict_variables' => false,
|
144 |
'autoescape' => 'html',
|
145 |
'cache' => false,
|
146 |
'auto_reload' => null,
|
147 |
'optimizations' => -1,
|
148 |
-
|
149 |
|
150 |
$this->debug = (bool) $options['debug'];
|
151 |
$this->charset = strtoupper($options['charset']);
|
@@ -154,23 +123,23 @@ class Twig_Environment
|
|
154 |
$this->strictVariables = (bool) $options['strict_variables'];
|
155 |
$this->setCache($options['cache']);
|
156 |
|
157 |
-
$this->addExtension(new
|
158 |
-
$this->addExtension(new
|
159 |
-
$this->addExtension(new
|
160 |
-
$this->staging = new
|
161 |
|
162 |
// For BC
|
163 |
-
if (
|
164 |
-
$r = new
|
165 |
-
if (
|
166 |
-
@trigger_error('The
|
167 |
|
168 |
$this->bcWriteCacheFile = true;
|
169 |
}
|
170 |
|
171 |
-
$r = new
|
172 |
-
if (
|
173 |
-
@trigger_error('The
|
174 |
|
175 |
$this->bcGetCacheFilename = true;
|
176 |
}
|
@@ -285,9 +254,9 @@ class Twig_Environment
|
|
285 |
*
|
286 |
* @param bool $original Whether to return the original cache option or the real cache instance
|
287 |
*
|
288 |
-
* @return
|
289 |
-
*
|
290 |
-
*
|
291 |
*/
|
292 |
public function getCache($original = true)
|
293 |
{
|
@@ -297,26 +266,26 @@ class Twig_Environment
|
|
297 |
/**
|
298 |
* Sets the current cache implementation.
|
299 |
*
|
300 |
-
* @param
|
301 |
-
*
|
302 |
-
*
|
303 |
*/
|
304 |
public function setCache($cache)
|
305 |
{
|
306 |
-
if (
|
307 |
$this->originalCache = $cache;
|
308 |
-
$this->cache = new
|
309 |
} elseif (false === $cache) {
|
310 |
$this->originalCache = $cache;
|
311 |
-
$this->cache = new
|
312 |
} elseif (null === $cache) {
|
313 |
@trigger_error('Using "null" as the cache strategy is deprecated since version 1.23 and will be removed in Twig 2.0.', E_USER_DEPRECATED);
|
314 |
$this->originalCache = false;
|
315 |
-
$this->cache = new
|
316 |
-
} elseif ($cache instanceof
|
317 |
$this->originalCache = $this->cache = $cache;
|
318 |
} else {
|
319 |
-
throw new
|
320 |
}
|
321 |
}
|
322 |
|
@@ -384,11 +353,11 @@ class Twig_Environment
|
|
384 |
*
|
385 |
* @return string The rendered template
|
386 |
*
|
387 |
-
* @throws
|
388 |
-
* @throws
|
389 |
-
* @throws
|
390 |
*/
|
391 |
-
public function render($name, array $context =
|
392 |
{
|
393 |
return $this->loadTemplate($name)->render($context);
|
394 |
}
|
@@ -399,11 +368,11 @@ class Twig_Environment
|
|
399 |
* @param string $name The template name
|
400 |
* @param array $context An array of parameters to pass to the template
|
401 |
*
|
402 |
-
* @throws
|
403 |
-
* @throws
|
404 |
-
* @throws
|
405 |
*/
|
406 |
-
public function display($name, array $context =
|
407 |
{
|
408 |
$this->loadTemplate($name)->display($context);
|
409 |
}
|
@@ -411,25 +380,21 @@ class Twig_Environment
|
|
411 |
/**
|
412 |
* Loads a template.
|
413 |
*
|
414 |
-
* @param string|
|
415 |
-
*
|
416 |
-
* @throws LoaderError When the template cannot be found
|
417 |
-
* @throws RuntimeError When a previously generated cache is corrupted
|
418 |
-
* @throws SyntaxError When an error occurred during compilation
|
419 |
*
|
420 |
-
* @return
|
421 |
*/
|
422 |
public function load($name)
|
423 |
{
|
424 |
-
if ($name instanceof
|
425 |
return $name;
|
426 |
}
|
427 |
|
428 |
-
if ($name instanceof
|
429 |
-
return new
|
430 |
}
|
431 |
|
432 |
-
return new
|
433 |
}
|
434 |
|
435 |
/**
|
@@ -443,9 +408,9 @@ class Twig_Environment
|
|
443 |
*
|
444 |
* @return Twig_TemplateInterface A template instance representing the given template name
|
445 |
*
|
446 |
-
* @throws
|
447 |
-
* @throws
|
448 |
-
* @throws
|
449 |
*
|
450 |
* @internal
|
451 |
*/
|
@@ -473,8 +438,8 @@ class Twig_Environment
|
|
473 |
|
474 |
if (!class_exists($cls, false)) {
|
475 |
$loader = $this->getLoader();
|
476 |
-
if (!$loader instanceof
|
477 |
-
$source = new
|
478 |
} else {
|
479 |
$source = $loader->getSourceContext($name);
|
480 |
}
|
@@ -499,7 +464,7 @@ class Twig_Environment
|
|
499 |
}
|
500 |
|
501 |
if (!class_exists($cls, false)) {
|
502 |
-
throw new
|
503 |
}
|
504 |
}
|
505 |
|
@@ -507,22 +472,7 @@ class Twig_Environment
|
|
507 |
$this->initRuntime();
|
508 |
}
|
509 |
|
510 |
-
|
511 |
-
throw new RuntimeError(sprintf('Circular reference detected for Twig template "%s", path: %s.', $name, implode(' -> ', array_merge($this->loading, [$name]))));
|
512 |
-
}
|
513 |
-
|
514 |
-
$this->loading[$cls] = $name;
|
515 |
-
|
516 |
-
try {
|
517 |
-
$this->loadedTemplates[$cls] = new $cls($this);
|
518 |
-
unset($this->loading[$cls]);
|
519 |
-
} catch (\Exception $e) {
|
520 |
-
unset($this->loading[$cls]);
|
521 |
-
|
522 |
-
throw $e;
|
523 |
-
}
|
524 |
-
|
525 |
-
return $this->loadedTemplates[$cls];
|
526 |
}
|
527 |
|
528 |
/**
|
@@ -532,28 +482,28 @@ class Twig_Environment
|
|
532 |
*
|
533 |
* @param string $template The template name
|
534 |
*
|
535 |
-
* @return
|
536 |
*
|
537 |
-
* @throws
|
538 |
-
* @throws
|
539 |
*/
|
540 |
public function createTemplate($template)
|
541 |
{
|
542 |
-
$name = sprintf('__string_template__%s', hash('sha256',
|
543 |
|
544 |
-
$loader = new
|
545 |
-
new
|
546 |
$current = $this->getLoader(),
|
547 |
-
|
548 |
|
549 |
$this->setLoader($loader);
|
550 |
try {
|
551 |
$template = $this->loadTemplate($name);
|
552 |
-
} catch (
|
553 |
$this->setLoader($current);
|
554 |
|
555 |
throw $e;
|
556 |
-
} catch (
|
557 |
$this->setLoader($current);
|
558 |
|
559 |
throw $e;
|
@@ -579,7 +529,7 @@ class Twig_Environment
|
|
579 |
{
|
580 |
if (0 === $this->lastModifiedExtension) {
|
581 |
foreach ($this->extensions as $extension) {
|
582 |
-
$r = new
|
583 |
if (file_exists($r->getFileName()) && ($extensionTime = filemtime($r->getFileName())) > $this->lastModifiedExtension) {
|
584 |
$this->lastModifiedExtension = $extensionTime;
|
585 |
}
|
@@ -592,41 +542,38 @@ class Twig_Environment
|
|
592 |
/**
|
593 |
* Tries to load a template consecutively from an array.
|
594 |
*
|
595 |
-
* Similar to loadTemplate() but it also accepts instances
|
596 |
-
*
|
597 |
*
|
598 |
-
* @param string|
|
599 |
*
|
600 |
-
* @return
|
601 |
*
|
602 |
-
* @throws
|
603 |
-
* @throws
|
604 |
*/
|
605 |
public function resolveTemplate($names)
|
606 |
{
|
607 |
-
if (
|
608 |
-
$names =
|
609 |
}
|
610 |
|
611 |
foreach ($names as $name) {
|
612 |
-
if ($name instanceof
|
613 |
-
return $name;
|
614 |
-
}
|
615 |
-
|
616 |
-
if ($name instanceof TemplateWrapper) {
|
617 |
return $name;
|
618 |
}
|
619 |
|
620 |
try {
|
621 |
return $this->loadTemplate($name);
|
622 |
-
} catch (
|
623 |
-
if (1 === \count($names)) {
|
624 |
-
throw $e;
|
625 |
-
}
|
626 |
}
|
627 |
}
|
628 |
|
629 |
-
|
|
|
|
|
|
|
|
|
630 |
}
|
631 |
|
632 |
/**
|
@@ -638,7 +585,7 @@ class Twig_Environment
|
|
638 |
{
|
639 |
@trigger_error(sprintf('The %s method is deprecated since version 1.18.3 and will be removed in Twig 2.0.', __METHOD__), E_USER_DEPRECATED);
|
640 |
|
641 |
-
$this->loadedTemplates =
|
642 |
}
|
643 |
|
644 |
/**
|
@@ -650,8 +597,8 @@ class Twig_Environment
|
|
650 |
{
|
651 |
@trigger_error(sprintf('The %s method is deprecated since version 1.22 and will be removed in Twig 2.0.', __METHOD__), E_USER_DEPRECATED);
|
652 |
|
653 |
-
if (
|
654 |
-
foreach (new
|
655 |
if ($file->isFile()) {
|
656 |
@unlink($file->getPathname());
|
657 |
}
|
@@ -671,7 +618,7 @@ class Twig_Environment
|
|
671 |
@trigger_error(sprintf('The %s() method is deprecated since version 1.25 and will be removed in 2.0.', __FUNCTION__), E_USER_DEPRECATED);
|
672 |
|
673 |
if (null === $this->lexer) {
|
674 |
-
$this->lexer = new
|
675 |
}
|
676 |
|
677 |
return $this->lexer;
|
@@ -685,22 +632,22 @@ class Twig_Environment
|
|
685 |
/**
|
686 |
* Tokenizes a source code.
|
687 |
*
|
688 |
-
* @param string|
|
689 |
-
* @param string
|
690 |
*
|
691 |
-
* @return
|
692 |
*
|
693 |
-
* @throws
|
694 |
*/
|
695 |
public function tokenize($source, $name = null)
|
696 |
{
|
697 |
-
if (!$source instanceof
|
698 |
-
@trigger_error(sprintf('Passing a string as the $source argument of %s() is deprecated since version 1.27. Pass a
|
699 |
-
$source = new
|
700 |
}
|
701 |
|
702 |
if (null === $this->lexer) {
|
703 |
-
$this->lexer = new
|
704 |
}
|
705 |
|
706 |
return $this->lexer->tokenize($source);
|
@@ -718,7 +665,7 @@ class Twig_Environment
|
|
718 |
@trigger_error(sprintf('The %s() method is deprecated since version 1.25 and will be removed in 2.0.', __FUNCTION__), E_USER_DEPRECATED);
|
719 |
|
720 |
if (null === $this->parser) {
|
721 |
-
$this->parser = new
|
722 |
}
|
723 |
|
724 |
return $this->parser;
|
@@ -732,14 +679,14 @@ class Twig_Environment
|
|
732 |
/**
|
733 |
* Converts a token stream to a node tree.
|
734 |
*
|
735 |
-
* @return
|
736 |
*
|
737 |
-
* @throws
|
738 |
*/
|
739 |
-
public function parse(
|
740 |
{
|
741 |
if (null === $this->parser) {
|
742 |
-
$this->parser = new
|
743 |
}
|
744 |
|
745 |
return $this->parser->parse($stream);
|
@@ -757,7 +704,7 @@ class Twig_Environment
|
|
757 |
@trigger_error(sprintf('The %s() method is deprecated since version 1.25 and will be removed in 2.0.', __FUNCTION__), E_USER_DEPRECATED);
|
758 |
|
759 |
if (null === $this->compiler) {
|
760 |
-
$this->compiler = new
|
761 |
}
|
762 |
|
763 |
return $this->compiler;
|
@@ -776,7 +723,7 @@ class Twig_Environment
|
|
776 |
public function compile(Twig_NodeInterface $node)
|
777 |
{
|
778 |
if (null === $this->compiler) {
|
779 |
-
$this->compiler = new
|
780 |
}
|
781 |
|
782 |
return $this->compiler->compile($node)->getSource();
|
@@ -785,34 +732,34 @@ class Twig_Environment
|
|
785 |
/**
|
786 |
* Compiles a template source code.
|
787 |
*
|
788 |
-
* @param string|
|
789 |
-
* @param string
|
790 |
*
|
791 |
* @return string The compiled PHP source code
|
792 |
*
|
793 |
-
* @throws
|
794 |
*/
|
795 |
public function compileSource($source, $name = null)
|
796 |
{
|
797 |
-
if (!$source instanceof
|
798 |
-
@trigger_error(sprintf('Passing a string as the $source argument of %s() is deprecated since version 1.27. Pass a
|
799 |
-
$source = new
|
800 |
}
|
801 |
|
802 |
try {
|
803 |
return $this->compile($this->parse($this->tokenize($source)));
|
804 |
-
} catch (
|
805 |
$e->setSourceContext($source);
|
806 |
throw $e;
|
807 |
-
} catch (
|
808 |
-
throw new
|
809 |
}
|
810 |
}
|
811 |
|
812 |
-
public function setLoader(
|
813 |
{
|
814 |
-
if (!$loader instanceof
|
815 |
-
@trigger_error(sprintf('Twig loader "%s" should implement Twig_SourceContextLoaderInterface since version 1.27.',
|
816 |
}
|
817 |
|
818 |
$this->loader = $loader;
|
@@ -821,12 +768,12 @@ class Twig_Environment
|
|
821 |
/**
|
822 |
* Gets the Loader instance.
|
823 |
*
|
824 |
-
* @return
|
825 |
*/
|
826 |
public function getLoader()
|
827 |
{
|
828 |
if (null === $this->loader) {
|
829 |
-
throw new
|
830 |
}
|
831 |
|
832 |
return $this->loader;
|
@@ -862,11 +809,11 @@ class Twig_Environment
|
|
862 |
$this->runtimeInitialized = true;
|
863 |
|
864 |
foreach ($this->getExtensions() as $name => $extension) {
|
865 |
-
if (!$extension instanceof
|
866 |
-
$m = new
|
867 |
|
868 |
if ('Twig_Extension' !== $m->getDeclaringClass()->getName()) {
|
869 |
-
@trigger_error(sprintf('Defining the initRuntime() method in the "%s" extension is deprecated since version 1.23. Use the `needs_environment` option to get the Twig_Environment instance in filters, functions, or tests; or explicitly implement
|
870 |
}
|
871 |
}
|
872 |
|
@@ -884,14 +831,8 @@ class Twig_Environment
|
|
884 |
public function hasExtension($class)
|
885 |
{
|
886 |
$class = ltrim($class, '\\');
|
887 |
-
if (!isset($this->extensionsByClass[$class]) && class_exists($class, false)) {
|
888 |
-
// For BC/FC with namespaced aliases
|
889 |
-
$class = new \ReflectionClass($class);
|
890 |
-
$class = $class->name;
|
891 |
-
}
|
892 |
-
|
893 |
if (isset($this->extensions[$class])) {
|
894 |
-
if ($class !==
|
895 |
@trigger_error(sprintf('Referencing the "%s" extension by its name (defined by getName()) is deprecated since 1.26 and will be removed in Twig 2.0. Use the Fully Qualified Extension Class Name instead.', $class), E_USER_DEPRECATED);
|
896 |
}
|
897 |
|
@@ -904,7 +845,7 @@ class Twig_Environment
|
|
904 |
/**
|
905 |
* Adds a runtime loader.
|
906 |
*/
|
907 |
-
public function addRuntimeLoader(
|
908 |
{
|
909 |
$this->runtimeLoaders[] = $loader;
|
910 |
}
|
@@ -914,19 +855,14 @@ class Twig_Environment
|
|
914 |
*
|
915 |
* @param string $class The extension class name
|
916 |
*
|
917 |
-
* @return
|
918 |
*/
|
919 |
public function getExtension($class)
|
920 |
{
|
921 |
$class = ltrim($class, '\\');
|
922 |
-
if (!isset($this->extensionsByClass[$class]) && class_exists($class, false)) {
|
923 |
-
// For BC/FC with namespaced aliases
|
924 |
-
$class = new \ReflectionClass($class);
|
925 |
-
$class = $class->name;
|
926 |
-
}
|
927 |
|
928 |
if (isset($this->extensions[$class])) {
|
929 |
-
if ($class !==
|
930 |
@trigger_error(sprintf('Referencing the "%s" extension by its name (defined by getName()) is deprecated since 1.26 and will be removed in Twig 2.0. Use the Fully Qualified Extension Class Name instead.', $class), E_USER_DEPRECATED);
|
931 |
}
|
932 |
|
@@ -934,7 +870,7 @@ class Twig_Environment
|
|
934 |
}
|
935 |
|
936 |
if (!isset($this->extensionsByClass[$class])) {
|
937 |
-
throw new
|
938 |
}
|
939 |
|
940 |
return $this->extensionsByClass[$class];
|
@@ -947,7 +883,7 @@ class Twig_Environment
|
|
947 |
*
|
948 |
* @return object The runtime implementation
|
949 |
*
|
950 |
-
* @throws
|
951 |
*/
|
952 |
public function getRuntime($class)
|
953 |
{
|
@@ -961,16 +897,16 @@ class Twig_Environment
|
|
961 |
}
|
962 |
}
|
963 |
|
964 |
-
throw new
|
965 |
}
|
966 |
|
967 |
-
public function addExtension(
|
968 |
{
|
969 |
if ($this->extensionInitialized) {
|
970 |
-
throw new
|
971 |
}
|
972 |
|
973 |
-
$class =
|
974 |
if ($class !== $extension->getName()) {
|
975 |
if (isset($this->extensions[$extension->getName()])) {
|
976 |
unset($this->extensions[$extension->getName()], $this->extensionsByClass[$class]);
|
@@ -998,18 +934,12 @@ class Twig_Environment
|
|
998 |
@trigger_error(sprintf('The %s method is deprecated since version 1.12 and will be removed in Twig 2.0.', __METHOD__), E_USER_DEPRECATED);
|
999 |
|
1000 |
if ($this->extensionInitialized) {
|
1001 |
-
throw new
|
1002 |
}
|
1003 |
|
1004 |
$class = ltrim($name, '\\');
|
1005 |
-
if (!isset($this->extensionsByClass[$class]) && class_exists($class, false)) {
|
1006 |
-
// For BC/FC with namespaced aliases
|
1007 |
-
$class = new \ReflectionClass($class);
|
1008 |
-
$class = $class->name;
|
1009 |
-
}
|
1010 |
-
|
1011 |
if (isset($this->extensions[$class])) {
|
1012 |
-
if ($class !==
|
1013 |
@trigger_error(sprintf('Referencing the "%s" extension by its name (defined by getName()) is deprecated since 1.26 and will be removed in Twig 2.0. Use the Fully Qualified Extension Class Name instead.', $class), E_USER_DEPRECATED);
|
1014 |
}
|
1015 |
|
@@ -1035,17 +965,17 @@ class Twig_Environment
|
|
1035 |
/**
|
1036 |
* Returns all registered extensions.
|
1037 |
*
|
1038 |
-
* @return
|
1039 |
*/
|
1040 |
public function getExtensions()
|
1041 |
{
|
1042 |
return $this->extensions;
|
1043 |
}
|
1044 |
|
1045 |
-
public function addTokenParser(
|
1046 |
{
|
1047 |
if ($this->extensionInitialized) {
|
1048 |
-
throw new
|
1049 |
}
|
1050 |
|
1051 |
$this->staging->addTokenParser($parser);
|
@@ -1072,15 +1002,15 @@ class Twig_Environment
|
|
1072 |
*
|
1073 |
* Be warned that this method cannot return tags defined by Twig_TokenParserBrokerInterface classes.
|
1074 |
*
|
1075 |
-
* @return
|
1076 |
*
|
1077 |
* @internal
|
1078 |
*/
|
1079 |
public function getTags()
|
1080 |
{
|
1081 |
-
$tags =
|
1082 |
foreach ($this->getTokenParsers()->getParsers() as $parser) {
|
1083 |
-
if ($parser instanceof
|
1084 |
$tags[$parser->getTag()] = $parser;
|
1085 |
}
|
1086 |
}
|
@@ -1088,10 +1018,10 @@ class Twig_Environment
|
|
1088 |
return $tags;
|
1089 |
}
|
1090 |
|
1091 |
-
public function addNodeVisitor(
|
1092 |
{
|
1093 |
if ($this->extensionInitialized) {
|
1094 |
-
throw new
|
1095 |
}
|
1096 |
|
1097 |
$this->staging->addNodeVisitor($visitor);
|
@@ -1100,7 +1030,7 @@ class Twig_Environment
|
|
1100 |
/**
|
1101 |
* Gets the registered Node Visitors.
|
1102 |
*
|
1103 |
-
* @return
|
1104 |
*
|
1105 |
* @internal
|
1106 |
*/
|
@@ -1116,16 +1046,16 @@ class Twig_Environment
|
|
1116 |
/**
|
1117 |
* Registers a Filter.
|
1118 |
*
|
1119 |
-
* @param string|
|
1120 |
-
* @param Twig_FilterInterface|
|
1121 |
*/
|
1122 |
public function addFilter($name, $filter = null)
|
1123 |
{
|
1124 |
-
if (!$name instanceof
|
1125 |
-
throw new
|
1126 |
}
|
1127 |
|
1128 |
-
if ($name instanceof
|
1129 |
$filter = $name;
|
1130 |
$name = $filter->getName();
|
1131 |
} else {
|
@@ -1133,7 +1063,7 @@ class Twig_Environment
|
|
1133 |
}
|
1134 |
|
1135 |
if ($this->extensionInitialized) {
|
1136 |
-
throw new
|
1137 |
}
|
1138 |
|
1139 |
$this->staging->addFilter($name, $filter);
|
@@ -1175,7 +1105,7 @@ class Twig_Environment
|
|
1175 |
}
|
1176 |
|
1177 |
foreach ($this->filterCallbacks as $callback) {
|
1178 |
-
if (false !== $filter =
|
1179 |
return $filter;
|
1180 |
}
|
1181 |
}
|
@@ -1211,16 +1141,16 @@ class Twig_Environment
|
|
1211 |
/**
|
1212 |
* Registers a Test.
|
1213 |
*
|
1214 |
-
* @param string|
|
1215 |
-
* @param Twig_TestInterface|
|
1216 |
*/
|
1217 |
public function addTest($name, $test = null)
|
1218 |
{
|
1219 |
-
if (!$name instanceof
|
1220 |
-
throw new
|
1221 |
}
|
1222 |
|
1223 |
-
if ($name instanceof
|
1224 |
$test = $name;
|
1225 |
$name = $test->getName();
|
1226 |
} else {
|
@@ -1228,7 +1158,7 @@ class Twig_Environment
|
|
1228 |
}
|
1229 |
|
1230 |
if ($this->extensionInitialized) {
|
1231 |
-
throw new
|
1232 |
}
|
1233 |
|
1234 |
$this->staging->addTest($name, $test);
|
@@ -1269,35 +1199,22 @@ class Twig_Environment
|
|
1269 |
return $this->tests[$name];
|
1270 |
}
|
1271 |
|
1272 |
-
foreach ($this->tests as $pattern => $test) {
|
1273 |
-
$pattern = str_replace('\\*', '(.*?)', preg_quote($pattern, '#'), $count);
|
1274 |
-
|
1275 |
-
if ($count) {
|
1276 |
-
if (preg_match('#^'.$pattern.'$#', $name, $matches)) {
|
1277 |
-
array_shift($matches);
|
1278 |
-
$test->setArguments($matches);
|
1279 |
-
|
1280 |
-
return $test;
|
1281 |
-
}
|
1282 |
-
}
|
1283 |
-
}
|
1284 |
-
|
1285 |
return false;
|
1286 |
}
|
1287 |
|
1288 |
/**
|
1289 |
* Registers a Function.
|
1290 |
*
|
1291 |
-
* @param string|
|
1292 |
-
* @param Twig_FunctionInterface|
|
1293 |
*/
|
1294 |
public function addFunction($name, $function = null)
|
1295 |
{
|
1296 |
-
if (!$name instanceof
|
1297 |
-
throw new
|
1298 |
}
|
1299 |
|
1300 |
-
if ($name instanceof
|
1301 |
$function = $name;
|
1302 |
$name = $function->getName();
|
1303 |
} else {
|
@@ -1305,7 +1222,7 @@ class Twig_Environment
|
|
1305 |
}
|
1306 |
|
1307 |
if ($this->extensionInitialized) {
|
1308 |
-
throw new
|
1309 |
}
|
1310 |
|
1311 |
$this->staging->addFunction($name, $function);
|
@@ -1347,7 +1264,7 @@ class Twig_Environment
|
|
1347 |
}
|
1348 |
|
1349 |
foreach ($this->functionCallbacks as $callback) {
|
1350 |
-
if (false !== $function =
|
1351 |
return $function;
|
1352 |
}
|
1353 |
}
|
@@ -1396,10 +1313,10 @@ class Twig_Environment
|
|
1396 |
$this->globals = $this->initGlobals();
|
1397 |
}
|
1398 |
|
1399 |
-
if (
|
1400 |
// The deprecation notice must be turned into the following exception in Twig 2.0
|
1401 |
@trigger_error(sprintf('Registering global variable "%s" at runtime or when the extensions have already been initialized is deprecated since version 1.21.', $name), E_USER_DEPRECATED);
|
1402 |
-
//throw new
|
1403 |
}
|
1404 |
}
|
1405 |
|
@@ -1443,7 +1360,7 @@ class Twig_Environment
|
|
1443 |
// we don't use array_merge as the context being generally
|
1444 |
// bigger than globals, this code is faster.
|
1445 |
foreach ($this->getGlobals() as $key => $value) {
|
1446 |
-
if (
|
1447 |
$context[$key] = $value;
|
1448 |
}
|
1449 |
}
|
@@ -1490,7 +1407,7 @@ class Twig_Environment
|
|
1490 |
{
|
1491 |
@trigger_error(sprintf('The %s method is deprecated since version 1.23 and will be removed in Twig 2.0.', __METHOD__), E_USER_DEPRECATED);
|
1492 |
|
1493 |
-
return
|
1494 |
}
|
1495 |
|
1496 |
/**
|
@@ -1498,19 +1415,19 @@ class Twig_Environment
|
|
1498 |
*/
|
1499 |
protected function initGlobals()
|
1500 |
{
|
1501 |
-
$globals =
|
1502 |
foreach ($this->extensions as $name => $extension) {
|
1503 |
-
if (!$extension instanceof
|
1504 |
-
$m = new
|
1505 |
|
1506 |
if ('Twig_Extension' !== $m->getDeclaringClass()->getName()) {
|
1507 |
-
@trigger_error(sprintf('Defining the getGlobals() method in the "%s" extension without explicitly implementing
|
1508 |
}
|
1509 |
}
|
1510 |
|
1511 |
$extGlob = $extension->getGlobals();
|
1512 |
-
if (
|
1513 |
-
throw new
|
1514 |
}
|
1515 |
|
1516 |
$globals[] = $extGlob;
|
@@ -1518,7 +1435,7 @@ class Twig_Environment
|
|
1518 |
|
1519 |
$globals[] = $this->staging->getGlobals();
|
1520 |
|
1521 |
-
return
|
1522 |
}
|
1523 |
|
1524 |
/**
|
@@ -1530,13 +1447,13 @@ class Twig_Environment
|
|
1530 |
return;
|
1531 |
}
|
1532 |
|
1533 |
-
$this->parsers = new Twig_TokenParserBroker(
|
1534 |
-
$this->filters =
|
1535 |
-
$this->functions =
|
1536 |
-
$this->tests =
|
1537 |
-
$this->visitors =
|
1538 |
-
$this->unaryOperators =
|
1539 |
-
$this->binaryOperators =
|
1540 |
|
1541 |
foreach ($this->extensions as $extension) {
|
1542 |
$this->initExtension($extension);
|
@@ -1549,14 +1466,14 @@ class Twig_Environment
|
|
1549 |
/**
|
1550 |
* @internal
|
1551 |
*/
|
1552 |
-
protected function initExtension(
|
1553 |
{
|
1554 |
// filters
|
1555 |
foreach ($extension->getFilters() as $name => $filter) {
|
1556 |
-
if ($filter instanceof
|
1557 |
$name = $filter->getName();
|
1558 |
} else {
|
1559 |
-
@trigger_error(sprintf('Using an instance of "%s" for filter "%s" is deprecated since version 1.21. Use Twig_SimpleFilter instead.',
|
1560 |
}
|
1561 |
|
1562 |
$this->filters[$name] = $filter;
|
@@ -1564,10 +1481,10 @@ class Twig_Environment
|
|
1564 |
|
1565 |
// functions
|
1566 |
foreach ($extension->getFunctions() as $name => $function) {
|
1567 |
-
if ($function instanceof
|
1568 |
$name = $function->getName();
|
1569 |
} else {
|
1570 |
-
@trigger_error(sprintf('Using an instance of "%s" for function "%s" is deprecated since version 1.21. Use Twig_SimpleFunction instead.',
|
1571 |
}
|
1572 |
|
1573 |
$this->functions[$name] = $function;
|
@@ -1575,10 +1492,10 @@ class Twig_Environment
|
|
1575 |
|
1576 |
// tests
|
1577 |
foreach ($extension->getTests() as $name => $test) {
|
1578 |
-
if ($test instanceof
|
1579 |
$name = $test->getName();
|
1580 |
} else {
|
1581 |
-
@trigger_error(sprintf('Using an instance of "%s" for test "%s" is deprecated since version 1.21. Use Twig_SimpleTest instead.',
|
1582 |
}
|
1583 |
|
1584 |
$this->tests[$name] = $test;
|
@@ -1586,14 +1503,14 @@ class Twig_Environment
|
|
1586 |
|
1587 |
// token parsers
|
1588 |
foreach ($extension->getTokenParsers() as $parser) {
|
1589 |
-
if ($parser instanceof
|
1590 |
$this->parsers->addTokenParser($parser);
|
1591 |
} elseif ($parser instanceof Twig_TokenParserBrokerInterface) {
|
1592 |
@trigger_error('Registering a Twig_TokenParserBrokerInterface instance is deprecated since version 1.21.', E_USER_DEPRECATED);
|
1593 |
|
1594 |
$this->parsers->addTokenParserBroker($parser);
|
1595 |
} else {
|
1596 |
-
throw new
|
1597 |
}
|
1598 |
}
|
1599 |
|
@@ -1604,12 +1521,12 @@ class Twig_Environment
|
|
1604 |
|
1605 |
// operators
|
1606 |
if ($operators = $extension->getOperators()) {
|
1607 |
-
if (
|
1608 |
-
throw new
|
1609 |
}
|
1610 |
|
1611 |
-
if (2 !==
|
1612 |
-
throw new
|
1613 |
}
|
1614 |
|
1615 |
$this->unaryOperators = array_merge($this->unaryOperators, $operators[0]);
|
@@ -1629,18 +1546,16 @@ class Twig_Environment
|
|
1629 |
{
|
1630 |
$hashParts = array_merge(
|
1631 |
array_keys($this->extensions),
|
1632 |
-
|
1633 |
-
(int)
|
1634 |
PHP_MAJOR_VERSION,
|
1635 |
PHP_MINOR_VERSION,
|
1636 |
self::VERSION,
|
1637 |
(int) $this->debug,
|
1638 |
$this->baseTemplateClass,
|
1639 |
(int) $this->strictVariables,
|
1640 |
-
|
1641 |
);
|
1642 |
$this->optionsHash = implode(':', $hashParts);
|
1643 |
}
|
1644 |
}
|
1645 |
-
|
1646 |
-
class_alias('Twig_Environment', 'Twig\Environment', false);
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
/**
|
13 |
* Stores the Twig configuration.
|
14 |
*
|
16 |
*/
|
17 |
class Twig_Environment
|
18 |
{
|
19 |
+
const VERSION = '1.33.0';
|
20 |
+
const VERSION_ID = 13300;
|
21 |
const MAJOR_VERSION = 1;
|
22 |
+
const MINOR_VERSION = 33;
|
23 |
const RELEASE_VERSION = 0;
|
24 |
+
const EXTRA_VERSION = '';
|
25 |
|
26 |
protected $charset;
|
27 |
protected $loader;
|
46 |
protected $unaryOperators;
|
47 |
protected $binaryOperators;
|
48 |
protected $templateClassPrefix = '__TwigTemplate_';
|
49 |
+
protected $functionCallbacks = array();
|
50 |
+
protected $filterCallbacks = array();
|
51 |
protected $staging;
|
52 |
|
53 |
private $originalCache;
|
54 |
private $bcWriteCacheFile = false;
|
55 |
private $bcGetCacheFilename = false;
|
56 |
private $lastModifiedExtension = 0;
|
57 |
+
private $extensionsByClass = array();
|
58 |
+
private $runtimeLoaders = array();
|
59 |
+
private $runtimes = array();
|
60 |
private $optionsHash;
|
|
|
61 |
|
62 |
/**
|
63 |
* Constructor.
|
93 |
* * optimizations: A flag that indicates which optimizations to apply
|
94 |
* (default to -1 which means that all optimizations are enabled;
|
95 |
* set it to 0 to disable).
|
96 |
+
*
|
97 |
+
* @param Twig_LoaderInterface $loader
|
98 |
+
* @param array $options An array of options
|
99 |
*/
|
100 |
+
public function __construct(Twig_LoaderInterface $loader = null, $options = array())
|
101 |
{
|
102 |
if (null !== $loader) {
|
103 |
$this->setLoader($loader);
|
104 |
} else {
|
105 |
+
@trigger_error('Not passing a Twig_LoaderInterface as the first constructor argument of Twig_Environment is deprecated since version 1.21.', E_USER_DEPRECATED);
|
106 |
}
|
107 |
|
108 |
+
$options = array_merge(array(
|
109 |
'debug' => false,
|
110 |
'charset' => 'UTF-8',
|
111 |
+
'base_template_class' => 'Twig_Template',
|
112 |
'strict_variables' => false,
|
113 |
'autoescape' => 'html',
|
114 |
'cache' => false,
|
115 |
'auto_reload' => null,
|
116 |
'optimizations' => -1,
|
117 |
+
), $options);
|
118 |
|
119 |
$this->debug = (bool) $options['debug'];
|
120 |
$this->charset = strtoupper($options['charset']);
|
123 |
$this->strictVariables = (bool) $options['strict_variables'];
|
124 |
$this->setCache($options['cache']);
|
125 |
|
126 |
+
$this->addExtension(new Twig_Extension_Core());
|
127 |
+
$this->addExtension(new Twig_Extension_Escaper($options['autoescape']));
|
128 |
+
$this->addExtension(new Twig_Extension_Optimizer($options['optimizations']));
|
129 |
+
$this->staging = new Twig_Extension_Staging();
|
130 |
|
131 |
// For BC
|
132 |
+
if (is_string($this->originalCache)) {
|
133 |
+
$r = new ReflectionMethod($this, 'writeCacheFile');
|
134 |
+
if ($r->getDeclaringClass()->getName() !== __CLASS__) {
|
135 |
+
@trigger_error('The Twig_Environment::writeCacheFile method is deprecated since version 1.22 and will be removed in Twig 2.0.', E_USER_DEPRECATED);
|
136 |
|
137 |
$this->bcWriteCacheFile = true;
|
138 |
}
|
139 |
|
140 |
+
$r = new ReflectionMethod($this, 'getCacheFilename');
|
141 |
+
if ($r->getDeclaringClass()->getName() !== __CLASS__) {
|
142 |
+
@trigger_error('The Twig_Environment::getCacheFilename method is deprecated since version 1.22 and will be removed in Twig 2.0.', E_USER_DEPRECATED);
|
143 |
|
144 |
$this->bcGetCacheFilename = true;
|
145 |
}
|
254 |
*
|
255 |
* @param bool $original Whether to return the original cache option or the real cache instance
|
256 |
*
|
257 |
+
* @return Twig_CacheInterface|string|false A Twig_CacheInterface implementation,
|
258 |
+
* an absolute path to the compiled templates,
|
259 |
+
* or false to disable cache
|
260 |
*/
|
261 |
public function getCache($original = true)
|
262 |
{
|
266 |
/**
|
267 |
* Sets the current cache implementation.
|
268 |
*
|
269 |
+
* @param Twig_CacheInterface|string|false $cache A Twig_CacheInterface implementation,
|
270 |
+
* an absolute path to the compiled templates,
|
271 |
+
* or false to disable cache
|
272 |
*/
|
273 |
public function setCache($cache)
|
274 |
{
|
275 |
+
if (is_string($cache)) {
|
276 |
$this->originalCache = $cache;
|
277 |
+
$this->cache = new Twig_Cache_Filesystem($cache);
|
278 |
} elseif (false === $cache) {
|
279 |
$this->originalCache = $cache;
|
280 |
+
$this->cache = new Twig_Cache_Null();
|
281 |
} elseif (null === $cache) {
|
282 |
@trigger_error('Using "null" as the cache strategy is deprecated since version 1.23 and will be removed in Twig 2.0.', E_USER_DEPRECATED);
|
283 |
$this->originalCache = false;
|
284 |
+
$this->cache = new Twig_Cache_Null();
|
285 |
+
} elseif ($cache instanceof Twig_CacheInterface) {
|
286 |
$this->originalCache = $this->cache = $cache;
|
287 |
} else {
|
288 |
+
throw new LogicException(sprintf('Cache can only be a string, false, or a Twig_CacheInterface implementation.'));
|
289 |
}
|
290 |
}
|
291 |
|
353 |
*
|
354 |
* @return string The rendered template
|
355 |
*
|
356 |
+
* @throws Twig_Error_Loader When the template cannot be found
|
357 |
+
* @throws Twig_Error_Syntax When an error occurred during compilation
|
358 |
+
* @throws Twig_Error_Runtime When an error occurred during rendering
|
359 |
*/
|
360 |
+
public function render($name, array $context = array())
|
361 |
{
|
362 |
return $this->loadTemplate($name)->render($context);
|
363 |
}
|
368 |
* @param string $name The template name
|
369 |
* @param array $context An array of parameters to pass to the template
|
370 |
*
|
371 |
+
* @throws Twig_Error_Loader When the template cannot be found
|
372 |
+
* @throws Twig_Error_Syntax When an error occurred during compilation
|
373 |
+
* @throws Twig_Error_Runtime When an error occurred during rendering
|
374 |
*/
|
375 |
+
public function display($name, array $context = array())
|
376 |
{
|
377 |
$this->loadTemplate($name)->display($context);
|
378 |
}
|
380 |
/**
|
381 |
* Loads a template.
|
382 |
*
|
383 |
+
* @param string|Twig_TemplateWrapper|Twig_Template $name The template name
|
|
|
|
|
|
|
|
|
384 |
*
|
385 |
+
* @return Twig_TemplateWrapper
|
386 |
*/
|
387 |
public function load($name)
|
388 |
{
|
389 |
+
if ($name instanceof Twig_TemplateWrapper) {
|
390 |
return $name;
|
391 |
}
|
392 |
|
393 |
+
if ($name instanceof Twig_Template) {
|
394 |
+
return new Twig_TemplateWrapper($this, $name);
|
395 |
}
|
396 |
|
397 |
+
return new Twig_TemplateWrapper($this, $this->loadTemplate($name));
|
398 |
}
|
399 |
|
400 |
/**
|
408 |
*
|
409 |
* @return Twig_TemplateInterface A template instance representing the given template name
|
410 |
*
|
411 |
+
* @throws Twig_Error_Loader When the template cannot be found
|
412 |
+
* @throws Twig_Error_Runtime When a previously generated cache is corrupted
|
413 |
+
* @throws Twig_Error_Syntax When an error occurred during compilation
|
414 |
*
|
415 |
* @internal
|
416 |
*/
|
438 |
|
439 |
if (!class_exists($cls, false)) {
|
440 |
$loader = $this->getLoader();
|
441 |
+
if (!$loader instanceof Twig_SourceContextLoaderInterface) {
|
442 |
+
$source = new Twig_Source($loader->getSource($name), $name);
|
443 |
} else {
|
444 |
$source = $loader->getSourceContext($name);
|
445 |
}
|
464 |
}
|
465 |
|
466 |
if (!class_exists($cls, false)) {
|
467 |
+
throw new Twig_Error_Runtime(sprintf('Failed to load Twig template "%s", index "%s": cache is corrupted.', $name, $index), -1, $source);
|
468 |
}
|
469 |
}
|
470 |
|
472 |
$this->initRuntime();
|
473 |
}
|
474 |
|
475 |
+
return $this->loadedTemplates[$cls] = new $cls($this);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
476 |
}
|
477 |
|
478 |
/**
|
482 |
*
|
483 |
* @param string $template The template name
|
484 |
*
|
485 |
+
* @return Twig_Template A template instance representing the given template name
|
486 |
*
|
487 |
+
* @throws Twig_Error_Loader When the template cannot be found
|
488 |
+
* @throws Twig_Error_Syntax When an error occurred during compilation
|
489 |
*/
|
490 |
public function createTemplate($template)
|
491 |
{
|
492 |
+
$name = sprintf('__string_template__%s', hash('sha256', uniqid(mt_rand(), true), false));
|
493 |
|
494 |
+
$loader = new Twig_Loader_Chain(array(
|
495 |
+
new Twig_Loader_Array(array($name => $template)),
|
496 |
$current = $this->getLoader(),
|
497 |
+
));
|
498 |
|
499 |
$this->setLoader($loader);
|
500 |
try {
|
501 |
$template = $this->loadTemplate($name);
|
502 |
+
} catch (Exception $e) {
|
503 |
$this->setLoader($current);
|
504 |
|
505 |
throw $e;
|
506 |
+
} catch (Throwable $e) {
|
507 |
$this->setLoader($current);
|
508 |
|
509 |
throw $e;
|
529 |
{
|
530 |
if (0 === $this->lastModifiedExtension) {
|
531 |
foreach ($this->extensions as $extension) {
|
532 |
+
$r = new ReflectionObject($extension);
|
533 |
if (file_exists($r->getFileName()) && ($extensionTime = filemtime($r->getFileName())) > $this->lastModifiedExtension) {
|
534 |
$this->lastModifiedExtension = $extensionTime;
|
535 |
}
|
542 |
/**
|
543 |
* Tries to load a template consecutively from an array.
|
544 |
*
|
545 |
+
* Similar to loadTemplate() but it also accepts Twig_TemplateInterface instances and an array
|
546 |
+
* of templates where each is tried to be loaded.
|
547 |
*
|
548 |
+
* @param string|Twig_Template|array $names A template or an array of templates to try consecutively
|
549 |
*
|
550 |
+
* @return Twig_Template
|
551 |
*
|
552 |
+
* @throws Twig_Error_Loader When none of the templates can be found
|
553 |
+
* @throws Twig_Error_Syntax When an error occurred during compilation
|
554 |
*/
|
555 |
public function resolveTemplate($names)
|
556 |
{
|
557 |
+
if (!is_array($names)) {
|
558 |
+
$names = array($names);
|
559 |
}
|
560 |
|
561 |
foreach ($names as $name) {
|
562 |
+
if ($name instanceof Twig_Template) {
|
|
|
|
|
|
|
|
|
563 |
return $name;
|
564 |
}
|
565 |
|
566 |
try {
|
567 |
return $this->loadTemplate($name);
|
568 |
+
} catch (Twig_Error_Loader $e) {
|
|
|
|
|
|
|
569 |
}
|
570 |
}
|
571 |
|
572 |
+
if (1 === count($names)) {
|
573 |
+
throw $e;
|
574 |
+
}
|
575 |
+
|
576 |
+
throw new Twig_Error_Loader(sprintf('Unable to find one of the following templates: "%s".', implode('", "', $names)));
|
577 |
}
|
578 |
|
579 |
/**
|
585 |
{
|
586 |
@trigger_error(sprintf('The %s method is deprecated since version 1.18.3 and will be removed in Twig 2.0.', __METHOD__), E_USER_DEPRECATED);
|
587 |
|
588 |
+
$this->loadedTemplates = array();
|
589 |
}
|
590 |
|
591 |
/**
|
597 |
{
|
598 |
@trigger_error(sprintf('The %s method is deprecated since version 1.22 and will be removed in Twig 2.0.', __METHOD__), E_USER_DEPRECATED);
|
599 |
|
600 |
+
if (is_string($this->originalCache)) {
|
601 |
+
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($this->originalCache), RecursiveIteratorIterator::LEAVES_ONLY) as $file) {
|
602 |
if ($file->isFile()) {
|
603 |
@unlink($file->getPathname());
|
604 |
}
|
618 |
@trigger_error(sprintf('The %s() method is deprecated since version 1.25 and will be removed in 2.0.', __FUNCTION__), E_USER_DEPRECATED);
|
619 |
|
620 |
if (null === $this->lexer) {
|
621 |
+
$this->lexer = new Twig_Lexer($this);
|
622 |
}
|
623 |
|
624 |
return $this->lexer;
|
632 |
/**
|
633 |
* Tokenizes a source code.
|
634 |
*
|
635 |
+
* @param string|Twig_Source $source The template source code
|
636 |
+
* @param string $name The template name (deprecated)
|
637 |
*
|
638 |
+
* @return Twig_TokenStream
|
639 |
*
|
640 |
+
* @throws Twig_Error_Syntax When the code is syntactically wrong
|
641 |
*/
|
642 |
public function tokenize($source, $name = null)
|
643 |
{
|
644 |
+
if (!$source instanceof Twig_Source) {
|
645 |
+
@trigger_error(sprintf('Passing a string as the $source argument of %s() is deprecated since version 1.27. Pass a Twig_Source instance instead.', __METHOD__), E_USER_DEPRECATED);
|
646 |
+
$source = new Twig_Source($source, $name);
|
647 |
}
|
648 |
|
649 |
if (null === $this->lexer) {
|
650 |
+
$this->lexer = new Twig_Lexer($this);
|
651 |
}
|
652 |
|
653 |
return $this->lexer->tokenize($source);
|
665 |
@trigger_error(sprintf('The %s() method is deprecated since version 1.25 and will be removed in 2.0.', __FUNCTION__), E_USER_DEPRECATED);
|
666 |
|
667 |
if (null === $this->parser) {
|
668 |
+
$this->parser = new Twig_Parser($this);
|
669 |
}
|
670 |
|
671 |
return $this->parser;
|
679 |
/**
|
680 |
* Converts a token stream to a node tree.
|
681 |
*
|
682 |
+
* @return Twig_Node_Module
|
683 |
*
|
684 |
+
* @throws Twig_Error_Syntax When the token stream is syntactically or semantically wrong
|
685 |
*/
|
686 |
+
public function parse(Twig_TokenStream $stream)
|
687 |
{
|
688 |
if (null === $this->parser) {
|
689 |
+
$this->parser = new Twig_Parser($this);
|
690 |
}
|
691 |
|
692 |
return $this->parser->parse($stream);
|
704 |
@trigger_error(sprintf('The %s() method is deprecated since version 1.25 and will be removed in 2.0.', __FUNCTION__), E_USER_DEPRECATED);
|
705 |
|
706 |
if (null === $this->compiler) {
|
707 |
+
$this->compiler = new Twig_Compiler($this);
|
708 |
}
|
709 |
|
710 |
return $this->compiler;
|
723 |
public function compile(Twig_NodeInterface $node)
|
724 |
{
|
725 |
if (null === $this->compiler) {
|
726 |
+
$this->compiler = new Twig_Compiler($this);
|
727 |
}
|
728 |
|
729 |
return $this->compiler->compile($node)->getSource();
|
732 |
/**
|
733 |
* Compiles a template source code.
|
734 |
*
|
735 |
+
* @param string|Twig_Source $source The template source code
|
736 |
+
* @param string $name The template name (deprecated)
|
737 |
*
|
738 |
* @return string The compiled PHP source code
|
739 |
*
|
740 |
+
* @throws Twig_Error_Syntax When there was an error during tokenizing, parsing or compiling
|
741 |
*/
|
742 |
public function compileSource($source, $name = null)
|
743 |
{
|
744 |
+
if (!$source instanceof Twig_Source) {
|
745 |
+
@trigger_error(sprintf('Passing a string as the $source argument of %s() is deprecated since version 1.27. Pass a Twig_Source instance instead.', __METHOD__), E_USER_DEPRECATED);
|
746 |
+
$source = new Twig_Source($source, $name);
|
747 |
}
|
748 |
|
749 |
try {
|
750 |
return $this->compile($this->parse($this->tokenize($source)));
|
751 |
+
} catch (Twig_Error $e) {
|
752 |
$e->setSourceContext($source);
|
753 |
throw $e;
|
754 |
+
} catch (Exception $e) {
|
755 |
+
throw new Twig_Error_Syntax(sprintf('An exception has been thrown during the compilation of a template ("%s").', $e->getMessage()), -1, $source, $e);
|
756 |
}
|
757 |
}
|
758 |
|
759 |
+
public function setLoader(Twig_LoaderInterface $loader)
|
760 |
{
|
761 |
+
if (!$loader instanceof Twig_SourceContextLoaderInterface && 0 !== strpos(get_class($loader), 'Mock_Twig_LoaderInterface')) {
|
762 |
+
@trigger_error(sprintf('Twig loader "%s" should implement Twig_SourceContextLoaderInterface since version 1.27.', get_class($loader)), E_USER_DEPRECATED);
|
763 |
}
|
764 |
|
765 |
$this->loader = $loader;
|
768 |
/**
|
769 |
* Gets the Loader instance.
|
770 |
*
|
771 |
+
* @return Twig_LoaderInterface
|
772 |
*/
|
773 |
public function getLoader()
|
774 |
{
|
775 |
if (null === $this->loader) {
|
776 |
+
throw new LogicException('You must set a loader first.');
|
777 |
}
|
778 |
|
779 |
return $this->loader;
|
809 |
$this->runtimeInitialized = true;
|
810 |
|
811 |
foreach ($this->getExtensions() as $name => $extension) {
|
812 |
+
if (!$extension instanceof Twig_Extension_InitRuntimeInterface) {
|
813 |
+
$m = new ReflectionMethod($extension, 'initRuntime');
|
814 |
|
815 |
if ('Twig_Extension' !== $m->getDeclaringClass()->getName()) {
|
816 |
+
@trigger_error(sprintf('Defining the initRuntime() method in the "%s" extension is deprecated since version 1.23. Use the `needs_environment` option to get the Twig_Environment instance in filters, functions, or tests; or explicitly implement Twig_Extension_InitRuntimeInterface if needed (not recommended).', $name), E_USER_DEPRECATED);
|
817 |
}
|
818 |
}
|
819 |
|
831 |
public function hasExtension($class)
|
832 |
{
|
833 |
$class = ltrim($class, '\\');
|
|
|
|
|
|
|
|
|
|
|
|
|
834 |
if (isset($this->extensions[$class])) {
|
835 |
+
if ($class !== get_class($this->extensions[$class])) {
|
836 |
@trigger_error(sprintf('Referencing the "%s" extension by its name (defined by getName()) is deprecated since 1.26 and will be removed in Twig 2.0. Use the Fully Qualified Extension Class Name instead.', $class), E_USER_DEPRECATED);
|
837 |
}
|
838 |
|
845 |
/**
|
846 |
* Adds a runtime loader.
|
847 |
*/
|
848 |
+
public function addRuntimeLoader(Twig_RuntimeLoaderInterface $loader)
|
849 |
{
|
850 |
$this->runtimeLoaders[] = $loader;
|
851 |
}
|
855 |
*
|
856 |
* @param string $class The extension class name
|
857 |
*
|
858 |
+
* @return Twig_ExtensionInterface
|
859 |
*/
|
860 |
public function getExtension($class)
|
861 |
{
|
862 |
$class = ltrim($class, '\\');
|
|
|
|
|
|
|
|
|
|
|
863 |
|
864 |
if (isset($this->extensions[$class])) {
|
865 |
+
if ($class !== get_class($this->extensions[$class])) {
|
866 |
@trigger_error(sprintf('Referencing the "%s" extension by its name (defined by getName()) is deprecated since 1.26 and will be removed in Twig 2.0. Use the Fully Qualified Extension Class Name instead.', $class), E_USER_DEPRECATED);
|
867 |
}
|
868 |
|
870 |
}
|
871 |
|
872 |
if (!isset($this->extensionsByClass[$class])) {
|
873 |
+
throw new Twig_Error_Runtime(sprintf('The "%s" extension is not enabled.', $class));
|
874 |
}
|
875 |
|
876 |
return $this->extensionsByClass[$class];
|
883 |
*
|
884 |
* @return object The runtime implementation
|
885 |
*
|
886 |
+
* @throws Twig_Error_Runtime When the template cannot be found
|
887 |
*/
|
888 |
public function getRuntime($class)
|
889 |
{
|
897 |
}
|
898 |
}
|
899 |
|
900 |
+
throw new Twig_Error_Runtime(sprintf('Unable to load the "%s" runtime.', $class));
|
901 |
}
|
902 |
|
903 |
+
public function addExtension(Twig_ExtensionInterface $extension)
|
904 |
{
|
905 |
if ($this->extensionInitialized) {
|
906 |
+
throw new LogicException(sprintf('Unable to register extension "%s" as extensions have already been initialized.', $extension->getName()));
|
907 |
}
|
908 |
|
909 |
+
$class = get_class($extension);
|
910 |
if ($class !== $extension->getName()) {
|
911 |
if (isset($this->extensions[$extension->getName()])) {
|
912 |
unset($this->extensions[$extension->getName()], $this->extensionsByClass[$class]);
|
934 |
@trigger_error(sprintf('The %s method is deprecated since version 1.12 and will be removed in Twig 2.0.', __METHOD__), E_USER_DEPRECATED);
|
935 |
|
936 |
if ($this->extensionInitialized) {
|
937 |
+
throw new LogicException(sprintf('Unable to remove extension "%s" as extensions have already been initialized.', $name));
|
938 |
}
|
939 |
|
940 |
$class = ltrim($name, '\\');
|
|
|
|
|
|
|
|
|
|
|
|
|
941 |
if (isset($this->extensions[$class])) {
|
942 |
+
if ($class !== get_class($this->extensions[$class])) {
|
943 |
@trigger_error(sprintf('Referencing the "%s" extension by its name (defined by getName()) is deprecated since 1.26 and will be removed in Twig 2.0. Use the Fully Qualified Extension Class Name instead.', $class), E_USER_DEPRECATED);
|
944 |
}
|
945 |
|
965 |
/**
|
966 |
* Returns all registered extensions.
|
967 |
*
|
968 |
+
* @return Twig_ExtensionInterface[] An array of extensions (keys are for internal usage only and should not be relied on)
|
969 |
*/
|
970 |
public function getExtensions()
|
971 |
{
|
972 |
return $this->extensions;
|
973 |
}
|
974 |
|
975 |
+
public function addTokenParser(Twig_TokenParserInterface $parser)
|
976 |
{
|
977 |
if ($this->extensionInitialized) {
|
978 |
+
throw new LogicException('Unable to add a token parser as extensions have already been initialized.');
|
979 |
}
|
980 |
|
981 |
$this->staging->addTokenParser($parser);
|
1002 |
*
|
1003 |
* Be warned that this method cannot return tags defined by Twig_TokenParserBrokerInterface classes.
|
1004 |
*
|
1005 |
+
* @return Twig_TokenParserInterface[]
|
1006 |
*
|
1007 |
* @internal
|
1008 |
*/
|
1009 |
public function getTags()
|
1010 |
{
|
1011 |
+
$tags = array();
|
1012 |
foreach ($this->getTokenParsers()->getParsers() as $parser) {
|
1013 |
+
if ($parser instanceof Twig_TokenParserInterface) {
|
1014 |
$tags[$parser->getTag()] = $parser;
|
1015 |
}
|
1016 |
}
|
1018 |
return $tags;
|
1019 |
}
|
1020 |
|
1021 |
+
public function addNodeVisitor(Twig_NodeVisitorInterface $visitor)
|
1022 |
{
|
1023 |
if ($this->extensionInitialized) {
|
1024 |
+
throw new LogicException('Unable to add a node visitor as extensions have already been initialized.');
|
1025 |
}
|
1026 |
|
1027 |
$this->staging->addNodeVisitor($visitor);
|
1030 |
/**
|
1031 |
* Gets the registered Node Visitors.
|
1032 |
*
|
1033 |
+
* @return Twig_NodeVisitorInterface[]
|
1034 |
*
|
1035 |
* @internal
|
1036 |
*/
|
1046 |
/**
|
1047 |
* Registers a Filter.
|
1048 |
*
|
1049 |
+
* @param string|Twig_SimpleFilter $name The filter name or a Twig_SimpleFilter instance
|
1050 |
+
* @param Twig_FilterInterface|Twig_SimpleFilter $filter
|
1051 |
*/
|
1052 |
public function addFilter($name, $filter = null)
|
1053 |
{
|
1054 |
+
if (!$name instanceof Twig_SimpleFilter && !($filter instanceof Twig_SimpleFilter || $filter instanceof Twig_FilterInterface)) {
|
1055 |
+
throw new LogicException('A filter must be an instance of Twig_FilterInterface or Twig_SimpleFilter.');
|
1056 |
}
|
1057 |
|
1058 |
+
if ($name instanceof Twig_SimpleFilter) {
|
1059 |
$filter = $name;
|
1060 |
$name = $filter->getName();
|
1061 |
} else {
|
1063 |
}
|
1064 |
|
1065 |
if ($this->extensionInitialized) {
|
1066 |
+
throw new LogicException(sprintf('Unable to add filter "%s" as extensions have already been initialized.', $name));
|
1067 |
}
|
1068 |
|
1069 |
$this->staging->addFilter($name, $filter);
|
1105 |
}
|
1106 |
|
1107 |
foreach ($this->filterCallbacks as $callback) {
|
1108 |
+
if (false !== $filter = call_user_func($callback, $name)) {
|
1109 |
return $filter;
|
1110 |
}
|
1111 |
}
|
1141 |
/**
|
1142 |
* Registers a Test.
|
1143 |
*
|
1144 |
+
* @param string|Twig_SimpleTest $name The test name or a Twig_SimpleTest instance
|
1145 |
+
* @param Twig_TestInterface|Twig_SimpleTest $test A Twig_TestInterface instance or a Twig_SimpleTest instance
|
1146 |
*/
|
1147 |
public function addTest($name, $test = null)
|
1148 |
{
|
1149 |
+
if (!$name instanceof Twig_SimpleTest && !($test instanceof Twig_SimpleTest || $test instanceof Twig_TestInterface)) {
|
1150 |
+
throw new LogicException('A test must be an instance of Twig_TestInterface or Twig_SimpleTest.');
|
1151 |
}
|
1152 |
|
1153 |
+
if ($name instanceof Twig_SimpleTest) {
|
1154 |
$test = $name;
|
1155 |
$name = $test->getName();
|
1156 |
} else {
|
1158 |
}
|
1159 |
|
1160 |
if ($this->extensionInitialized) {
|
1161 |
+
throw new LogicException(sprintf('Unable to add test "%s" as extensions have already been initialized.', $name));
|
1162 |
}
|
1163 |
|
1164 |
$this->staging->addTest($name, $test);
|
1199 |
return $this->tests[$name];
|
1200 |
}
|
1201 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1202 |
return false;
|
1203 |
}
|
1204 |
|
1205 |
/**
|
1206 |
* Registers a Function.
|
1207 |
*
|
1208 |
+
* @param string|Twig_SimpleFunction $name The function name or a Twig_SimpleFunction instance
|
1209 |
+
* @param Twig_FunctionInterface|Twig_SimpleFunction $function
|
1210 |
*/
|
1211 |
public function addFunction($name, $function = null)
|
1212 |
{
|
1213 |
+
if (!$name instanceof Twig_SimpleFunction && !($function instanceof Twig_SimpleFunction || $function instanceof Twig_FunctionInterface)) {
|
1214 |
+
throw new LogicException('A function must be an instance of Twig_FunctionInterface or Twig_SimpleFunction.');
|
1215 |
}
|
1216 |
|
1217 |
+
if ($name instanceof Twig_SimpleFunction) {
|
1218 |
$function = $name;
|
1219 |
$name = $function->getName();
|
1220 |
} else {
|
1222 |
}
|
1223 |
|
1224 |
if ($this->extensionInitialized) {
|
1225 |
+
throw new LogicException(sprintf('Unable to add function "%s" as extensions have already been initialized.', $name));
|
1226 |
}
|
1227 |
|
1228 |
$this->staging->addFunction($name, $function);
|
1264 |
}
|
1265 |
|
1266 |
foreach ($this->functionCallbacks as $callback) {
|
1267 |
+
if (false !== $function = call_user_func($callback, $name)) {
|
1268 |
return $function;
|
1269 |
}
|
1270 |
}
|
1313 |
$this->globals = $this->initGlobals();
|
1314 |
}
|
1315 |
|
1316 |
+
if (!array_key_exists($name, $this->globals)) {
|
1317 |
// The deprecation notice must be turned into the following exception in Twig 2.0
|
1318 |
@trigger_error(sprintf('Registering global variable "%s" at runtime or when the extensions have already been initialized is deprecated since version 1.21.', $name), E_USER_DEPRECATED);
|
1319 |
+
//throw new LogicException(sprintf('Unable to add global "%s" as the runtime or the extensions have already been initialized.', $name));
|
1320 |
}
|
1321 |
}
|
1322 |
|
1360 |
// we don't use array_merge as the context being generally
|
1361 |
// bigger than globals, this code is faster.
|
1362 |
foreach ($this->getGlobals() as $key => $value) {
|
1363 |
+
if (!array_key_exists($key, $context)) {
|
1364 |
$context[$key] = $value;
|
1365 |
}
|
1366 |
}
|
1407 |
{
|
1408 |
@trigger_error(sprintf('The %s method is deprecated since version 1.23 and will be removed in Twig 2.0.', __METHOD__), E_USER_DEPRECATED);
|
1409 |
|
1410 |
+
return Twig_Error_Syntax::computeAlternatives($name, $items);
|
1411 |
}
|
1412 |
|
1413 |
/**
|
1415 |
*/
|
1416 |
protected function initGlobals()
|
1417 |
{
|
1418 |
+
$globals = array();
|
1419 |
foreach ($this->extensions as $name => $extension) {
|
1420 |
+
if (!$extension instanceof Twig_Extension_GlobalsInterface) {
|
1421 |
+
$m = new ReflectionMethod($extension, 'getGlobals');
|
1422 |
|
1423 |
if ('Twig_Extension' !== $m->getDeclaringClass()->getName()) {
|
1424 |
+
@trigger_error(sprintf('Defining the getGlobals() method in the "%s" extension without explicitly implementing Twig_Extension_GlobalsInterface is deprecated since version 1.23.', $name), E_USER_DEPRECATED);
|
1425 |
}
|
1426 |
}
|
1427 |
|
1428 |
$extGlob = $extension->getGlobals();
|
1429 |
+
if (!is_array($extGlob)) {
|
1430 |
+
throw new UnexpectedValueException(sprintf('"%s::getGlobals()" must return an array of globals.', get_class($extension)));
|
1431 |
}
|
1432 |
|
1433 |
$globals[] = $extGlob;
|
1435 |
|
1436 |
$globals[] = $this->staging->getGlobals();
|
1437 |
|
1438 |
+
return call_user_func_array('array_merge', $globals);
|
1439 |
}
|
1440 |
|
1441 |
/**
|
1447 |
return;
|
1448 |
}
|
1449 |
|
1450 |
+
$this->parsers = new Twig_TokenParserBroker(array(), array(), false);
|
1451 |
+
$this->filters = array();
|
1452 |
+
$this->functions = array();
|
1453 |
+
$this->tests = array();
|
1454 |
+
$this->visitors = array();
|
1455 |
+
$this->unaryOperators = array();
|
1456 |
+
$this->binaryOperators = array();
|
1457 |
|
1458 |
foreach ($this->extensions as $extension) {
|
1459 |
$this->initExtension($extension);
|
1466 |
/**
|
1467 |
* @internal
|
1468 |
*/
|
1469 |
+
protected function initExtension(Twig_ExtensionInterface $extension)
|
1470 |
{
|
1471 |
// filters
|
1472 |
foreach ($extension->getFilters() as $name => $filter) {
|
1473 |
+
if ($filter instanceof Twig_SimpleFilter) {
|
1474 |
$name = $filter->getName();
|
1475 |
} else {
|
1476 |
+
@trigger_error(sprintf('Using an instance of "%s" for filter "%s" is deprecated since version 1.21. Use Twig_SimpleFilter instead.', get_class($filter), $name), E_USER_DEPRECATED);
|
1477 |
}
|
1478 |
|
1479 |
$this->filters[$name] = $filter;
|
1481 |
|
1482 |
// functions
|
1483 |
foreach ($extension->getFunctions() as $name => $function) {
|
1484 |
+
if ($function instanceof Twig_SimpleFunction) {
|
1485 |
$name = $function->getName();
|
1486 |
} else {
|
1487 |
+
@trigger_error(sprintf('Using an instance of "%s" for function "%s" is deprecated since version 1.21. Use Twig_SimpleFunction instead.', get_class($function), $name), E_USER_DEPRECATED);
|
1488 |
}
|
1489 |
|
1490 |
$this->functions[$name] = $function;
|
1492 |
|
1493 |
// tests
|
1494 |
foreach ($extension->getTests() as $name => $test) {
|
1495 |
+
if ($test instanceof Twig_SimpleTest) {
|
1496 |
$name = $test->getName();
|
1497 |
} else {
|
1498 |
+
@trigger_error(sprintf('Using an instance of "%s" for test "%s" is deprecated since version 1.21. Use Twig_SimpleTest instead.', get_class($test), $name), E_USER_DEPRECATED);
|
1499 |
}
|
1500 |
|
1501 |
$this->tests[$name] = $test;
|
1503 |
|
1504 |
// token parsers
|
1505 |
foreach ($extension->getTokenParsers() as $parser) {
|
1506 |
+
if ($parser instanceof Twig_TokenParserInterface) {
|
1507 |
$this->parsers->addTokenParser($parser);
|
1508 |
} elseif ($parser instanceof Twig_TokenParserBrokerInterface) {
|
1509 |
@trigger_error('Registering a Twig_TokenParserBrokerInterface instance is deprecated since version 1.21.', E_USER_DEPRECATED);
|
1510 |
|
1511 |
$this->parsers->addTokenParserBroker($parser);
|
1512 |
} else {
|
1513 |
+
throw new LogicException('getTokenParsers() must return an array of Twig_TokenParserInterface or Twig_TokenParserBrokerInterface instances.');
|
1514 |
}
|
1515 |
}
|
1516 |
|
1521 |
|
1522 |
// operators
|
1523 |
if ($operators = $extension->getOperators()) {
|
1524 |
+
if (!is_array($operators)) {
|
1525 |
+
throw new InvalidArgumentException(sprintf('"%s::getOperators()" must return an array with operators, got "%s".', get_class($extension), is_object($operators) ? get_class($operators) : gettype($operators).(is_resource($operators) ? '' : '#'.$operators)));
|
1526 |
}
|
1527 |
|
1528 |
+
if (2 !== count($operators)) {
|
1529 |
+
throw new InvalidArgumentException(sprintf('"%s::getOperators()" must return an array of 2 elements, got %d.', get_class($extension), count($operators)));
|
1530 |
}
|
1531 |
|
1532 |
$this->unaryOperators = array_merge($this->unaryOperators, $operators[0]);
|
1546 |
{
|
1547 |
$hashParts = array_merge(
|
1548 |
array_keys($this->extensions),
|
1549 |
+
array(
|
1550 |
+
(int) function_exists('twig_template_get_attributes'),
|
1551 |
PHP_MAJOR_VERSION,
|
1552 |
PHP_MINOR_VERSION,
|
1553 |
self::VERSION,
|
1554 |
(int) $this->debug,
|
1555 |
$this->baseTemplateClass,
|
1556 |
(int) $this->strictVariables,
|
1557 |
+
)
|
1558 |
);
|
1559 |
$this->optionsHash = implode(':', $hashParts);
|
1560 |
}
|
1561 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Error.php
CHANGED
@@ -9,9 +9,6 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Source;
|
13 |
-
use Twig\Template;
|
14 |
-
|
15 |
/**
|
16 |
* Twig base exception.
|
17 |
*
|
@@ -34,12 +31,13 @@ use Twig\Template;
|
|
34 |
*
|
35 |
* @author Fabien Potencier <fabien@symfony.com>
|
36 |
*/
|
37 |
-
class Twig_Error extends
|
38 |
{
|
39 |
protected $lineno;
|
40 |
// to be renamed to name in 2.0
|
41 |
protected $filename;
|
42 |
protected $rawMessage;
|
|
|
43 |
|
44 |
private $sourcePath;
|
45 |
private $sourceCode;
|
@@ -56,16 +54,16 @@ class Twig_Error extends \Exception
|
|
56 |
*
|
57 |
* By default, automatic guessing is enabled.
|
58 |
*
|
59 |
-
* @param string
|
60 |
-
* @param int
|
61 |
-
* @param
|
62 |
-
* @param
|
63 |
*/
|
64 |
-
public function __construct($message, $lineno = -1, $source = null,
|
65 |
{
|
66 |
if (null === $source) {
|
67 |
$name = null;
|
68 |
-
} elseif (!$source instanceof
|
69 |
// for compat with the Twig C ext., passing the template name as string is accepted
|
70 |
$name = $source;
|
71 |
} else {
|
@@ -73,7 +71,12 @@ class Twig_Error extends \Exception
|
|
73 |
$this->sourceCode = $source->getCode();
|
74 |
$this->sourcePath = $source->getPath();
|
75 |
}
|
76 |
-
|
|
|
|
|
|
|
|
|
|
|
77 |
|
78 |
$this->lineno = $lineno;
|
79 |
$this->filename = $name;
|
@@ -183,17 +186,17 @@ class Twig_Error extends \Exception
|
|
183 |
/**
|
184 |
* Gets the source context of the Twig template where the error occurred.
|
185 |
*
|
186 |
-
* @return
|
187 |
*/
|
188 |
public function getSourceContext()
|
189 |
{
|
190 |
-
return $this->filename ? new
|
191 |
}
|
192 |
|
193 |
/**
|
194 |
* Sets the source context of the Twig template where the error occurred.
|
195 |
*/
|
196 |
-
public function setSourceContext(
|
197 |
{
|
198 |
if (null === $source) {
|
199 |
$this->sourceCode = $this->filename = $this->sourcePath = null;
|
@@ -212,6 +215,25 @@ class Twig_Error extends \Exception
|
|
212 |
$this->updateRepr();
|
213 |
}
|
214 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
215 |
public function appendMessage($rawMessage)
|
216 |
{
|
217 |
$this->rawMessage .= $rawMessage;
|
@@ -245,7 +267,7 @@ class Twig_Error extends \Exception
|
|
245 |
}
|
246 |
|
247 |
if ($this->filename) {
|
248 |
-
if (
|
249 |
$name = sprintf('"%s"', $this->filename);
|
250 |
} else {
|
251 |
$name = json_encode($this->filename);
|
@@ -274,14 +296,19 @@ class Twig_Error extends \Exception
|
|
274 |
$template = null;
|
275 |
$templateClass = null;
|
276 |
|
277 |
-
|
|
|
|
|
|
|
|
|
|
|
278 |
foreach ($backtrace as $trace) {
|
279 |
-
if (isset($trace['object']) && $trace['object'] instanceof
|
280 |
-
$currentClass =
|
281 |
$isEmbedContainer = 0 === strpos($templateClass, $currentClass);
|
282 |
if (null === $this->filename || ($this->filename == $trace['object']->getTemplateName() && !$isEmbedContainer)) {
|
283 |
$template = $trace['object'];
|
284 |
-
$templateClass =
|
285 |
}
|
286 |
}
|
287 |
}
|
@@ -302,17 +329,22 @@ class Twig_Error extends \Exception
|
|
302 |
return;
|
303 |
}
|
304 |
|
305 |
-
$r = new
|
306 |
$file = $r->getFileName();
|
307 |
|
308 |
-
|
309 |
-
|
|
|
|
|
|
|
|
|
|
|
310 |
$exceptions[] = $e;
|
311 |
}
|
312 |
|
313 |
while ($e = array_pop($exceptions)) {
|
314 |
$traces = $e->getTrace();
|
315 |
-
array_unshift($traces,
|
316 |
|
317 |
while ($trace = array_shift($traces)) {
|
318 |
if (!isset($trace['file']) || !isset($trace['line']) || $file != $trace['file']) {
|
@@ -331,6 +363,3 @@ class Twig_Error extends \Exception
|
|
331 |
}
|
332 |
}
|
333 |
}
|
334 |
-
|
335 |
-
class_alias('Twig_Error', 'Twig\Error\Error', false);
|
336 |
-
class_exists('Twig_Source');
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
|
|
12 |
/**
|
13 |
* Twig base exception.
|
14 |
*
|
31 |
*
|
32 |
* @author Fabien Potencier <fabien@symfony.com>
|
33 |
*/
|
34 |
+
class Twig_Error extends Exception
|
35 |
{
|
36 |
protected $lineno;
|
37 |
// to be renamed to name in 2.0
|
38 |
protected $filename;
|
39 |
protected $rawMessage;
|
40 |
+
protected $previous;
|
41 |
|
42 |
private $sourcePath;
|
43 |
private $sourceCode;
|
54 |
*
|
55 |
* By default, automatic guessing is enabled.
|
56 |
*
|
57 |
+
* @param string $message The error message
|
58 |
+
* @param int $lineno The template line where the error occurred
|
59 |
+
* @param Twig_Source|string|null $source The source context where the error occurred
|
60 |
+
* @param Exception $previous The previous exception
|
61 |
*/
|
62 |
+
public function __construct($message, $lineno = -1, $source = null, Exception $previous = null)
|
63 |
{
|
64 |
if (null === $source) {
|
65 |
$name = null;
|
66 |
+
} elseif (!$source instanceof Twig_Source) {
|
67 |
// for compat with the Twig C ext., passing the template name as string is accepted
|
68 |
$name = $source;
|
69 |
} else {
|
71 |
$this->sourceCode = $source->getCode();
|
72 |
$this->sourcePath = $source->getPath();
|
73 |
}
|
74 |
+
if (PHP_VERSION_ID < 50300) {
|
75 |
+
$this->previous = $previous;
|
76 |
+
parent::__construct('');
|
77 |
+
} else {
|
78 |
+
parent::__construct('', 0, $previous);
|
79 |
+
}
|
80 |
|
81 |
$this->lineno = $lineno;
|
82 |
$this->filename = $name;
|
186 |
/**
|
187 |
* Gets the source context of the Twig template where the error occurred.
|
188 |
*
|
189 |
+
* @return Twig_Source|null
|
190 |
*/
|
191 |
public function getSourceContext()
|
192 |
{
|
193 |
+
return $this->filename ? new Twig_Source($this->sourceCode, $this->filename, $this->sourcePath) : null;
|
194 |
}
|
195 |
|
196 |
/**
|
197 |
* Sets the source context of the Twig template where the error occurred.
|
198 |
*/
|
199 |
+
public function setSourceContext(Twig_Source $source = null)
|
200 |
{
|
201 |
if (null === $source) {
|
202 |
$this->sourceCode = $this->filename = $this->sourcePath = null;
|
215 |
$this->updateRepr();
|
216 |
}
|
217 |
|
218 |
+
/**
|
219 |
+
* For PHP < 5.3.0, provides access to the getPrevious() method.
|
220 |
+
*
|
221 |
+
* @param string $method The method name
|
222 |
+
* @param array $arguments The parameters to be passed to the method
|
223 |
+
*
|
224 |
+
* @return Exception The previous exception or null
|
225 |
+
*
|
226 |
+
* @throws BadMethodCallException
|
227 |
+
*/
|
228 |
+
public function __call($method, $arguments)
|
229 |
+
{
|
230 |
+
if ('getprevious' == strtolower($method)) {
|
231 |
+
return $this->previous;
|
232 |
+
}
|
233 |
+
|
234 |
+
throw new BadMethodCallException(sprintf('Method "Twig_Error::%s()" does not exist.', $method));
|
235 |
+
}
|
236 |
+
|
237 |
public function appendMessage($rawMessage)
|
238 |
{
|
239 |
$this->rawMessage .= $rawMessage;
|
267 |
}
|
268 |
|
269 |
if ($this->filename) {
|
270 |
+
if (is_string($this->filename) || (is_object($this->filename) && method_exists($this->filename, '__toString'))) {
|
271 |
$name = sprintf('"%s"', $this->filename);
|
272 |
} else {
|
273 |
$name = json_encode($this->filename);
|
296 |
$template = null;
|
297 |
$templateClass = null;
|
298 |
|
299 |
+
if (PHP_VERSION_ID >= 50306) {
|
300 |
+
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS | DEBUG_BACKTRACE_PROVIDE_OBJECT);
|
301 |
+
} else {
|
302 |
+
$backtrace = debug_backtrace();
|
303 |
+
}
|
304 |
+
|
305 |
foreach ($backtrace as $trace) {
|
306 |
+
if (isset($trace['object']) && $trace['object'] instanceof Twig_Template && 'Twig_Template' !== get_class($trace['object'])) {
|
307 |
+
$currentClass = get_class($trace['object']);
|
308 |
$isEmbedContainer = 0 === strpos($templateClass, $currentClass);
|
309 |
if (null === $this->filename || ($this->filename == $trace['object']->getTemplateName() && !$isEmbedContainer)) {
|
310 |
$template = $trace['object'];
|
311 |
+
$templateClass = get_class($trace['object']);
|
312 |
}
|
313 |
}
|
314 |
}
|
329 |
return;
|
330 |
}
|
331 |
|
332 |
+
$r = new ReflectionObject($template);
|
333 |
$file = $r->getFileName();
|
334 |
|
335 |
+
// hhvm has a bug where eval'ed files comes out as the current directory
|
336 |
+
if (is_dir($file)) {
|
337 |
+
$file = '';
|
338 |
+
}
|
339 |
+
|
340 |
+
$exceptions = array($e = $this);
|
341 |
+
while (($e instanceof self || method_exists($e, 'getPrevious')) && $e = $e->getPrevious()) {
|
342 |
$exceptions[] = $e;
|
343 |
}
|
344 |
|
345 |
while ($e = array_pop($exceptions)) {
|
346 |
$traces = $e->getTrace();
|
347 |
+
array_unshift($traces, array('file' => $e->getFile(), 'line' => $e->getLine()));
|
348 |
|
349 |
while ($trace = array_shift($traces)) {
|
350 |
if (!isset($trace['file']) || !isset($trace['line']) || $file != $trace['file']) {
|
363 |
}
|
364 |
}
|
365 |
}
|
|
|
|
|
|
vendor/twig/twig/lib/Twig/Error/Loader.php
CHANGED
@@ -9,8 +9,6 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Error\Error;
|
13 |
-
|
14 |
/**
|
15 |
* Exception thrown when an error occurs during template loading.
|
16 |
*
|
@@ -18,21 +16,23 @@ use Twig\Error\Error;
|
|
18 |
* if a template cannot be loaded, there is nothing to guess.
|
19 |
* However, when a template is loaded from another one, then, we need
|
20 |
* to find the current context and this is automatically done by
|
21 |
-
*
|
22 |
*
|
23 |
-
* This strategy makes
|
24 |
*
|
25 |
* @author Fabien Potencier <fabien@symfony.com>
|
26 |
*/
|
27 |
-
class Twig_Error_Loader extends
|
28 |
{
|
29 |
-
public function __construct($message, $lineno = -1, $source = null,
|
30 |
{
|
31 |
-
|
32 |
-
|
|
|
|
|
|
|
|
|
33 |
$this->appendMessage($message);
|
34 |
$this->setTemplateLine(false);
|
35 |
}
|
36 |
}
|
37 |
-
|
38 |
-
class_alias('Twig_Error_Loader', 'Twig\Error\LoaderError', false);
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
12 |
/**
|
13 |
* Exception thrown when an error occurs during template loading.
|
14 |
*
|
16 |
* if a template cannot be loaded, there is nothing to guess.
|
17 |
* However, when a template is loaded from another one, then, we need
|
18 |
* to find the current context and this is automatically done by
|
19 |
+
* Twig_Template::displayWithErrorHandling().
|
20 |
*
|
21 |
+
* This strategy makes Twig_Environment::resolveTemplate() much faster.
|
22 |
*
|
23 |
* @author Fabien Potencier <fabien@symfony.com>
|
24 |
*/
|
25 |
+
class Twig_Error_Loader extends Twig_Error
|
26 |
{
|
27 |
+
public function __construct($message, $lineno = -1, $source = null, Exception $previous = null)
|
28 |
{
|
29 |
+
if (PHP_VERSION_ID < 50300) {
|
30 |
+
$this->previous = $previous;
|
31 |
+
Exception::__construct('');
|
32 |
+
} else {
|
33 |
+
Exception::__construct('', 0, $previous);
|
34 |
+
}
|
35 |
$this->appendMessage($message);
|
36 |
$this->setTemplateLine(false);
|
37 |
}
|
38 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Error/Runtime.php
CHANGED
@@ -10,15 +10,11 @@
|
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
|
13 |
-
use Twig\Error\Error;
|
14 |
-
|
15 |
/**
|
16 |
* Exception thrown when an error occurs at runtime.
|
17 |
*
|
18 |
* @author Fabien Potencier <fabien@symfony.com>
|
19 |
*/
|
20 |
-
class Twig_Error_Runtime extends
|
21 |
{
|
22 |
}
|
23 |
-
|
24 |
-
class_alias('Twig_Error_Runtime', 'Twig\Error\RuntimeError', false);
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
|
|
|
|
|
13 |
/**
|
14 |
* Exception thrown when an error occurs at runtime.
|
15 |
*
|
16 |
* @author Fabien Potencier <fabien@symfony.com>
|
17 |
*/
|
18 |
+
class Twig_Error_Runtime extends Twig_Error
|
19 |
{
|
20 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Error/Syntax.php
CHANGED
@@ -10,14 +10,12 @@
|
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
|
13 |
-
use Twig\Error\Error;
|
14 |
-
|
15 |
/**
|
16 |
-
*
|
17 |
*
|
18 |
* @author Fabien Potencier <fabien@symfony.com>
|
19 |
*/
|
20 |
-
class Twig_Error_Syntax extends
|
21 |
{
|
22 |
/**
|
23 |
* Tweaks the error message to include suggestions.
|
@@ -41,10 +39,10 @@ class Twig_Error_Syntax extends Error
|
|
41 |
*/
|
42 |
public static function computeAlternatives($name, $items)
|
43 |
{
|
44 |
-
$alternatives =
|
45 |
foreach ($items as $item) {
|
46 |
$lev = levenshtein($name, $item);
|
47 |
-
if ($lev <=
|
48 |
$alternatives[$item] = $lev;
|
49 |
}
|
50 |
}
|
@@ -53,5 +51,3 @@ class Twig_Error_Syntax extends Error
|
|
53 |
return array_keys($alternatives);
|
54 |
}
|
55 |
}
|
56 |
-
|
57 |
-
class_alias('Twig_Error_Syntax', 'Twig\Error\SyntaxError', false);
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
|
|
|
|
|
13 |
/**
|
14 |
+
* Exception thrown when a syntax error occurs during lexing or parsing of a template.
|
15 |
*
|
16 |
* @author Fabien Potencier <fabien@symfony.com>
|
17 |
*/
|
18 |
+
class Twig_Error_Syntax extends Twig_Error
|
19 |
{
|
20 |
/**
|
21 |
* Tweaks the error message to include suggestions.
|
39 |
*/
|
40 |
public static function computeAlternatives($name, $items)
|
41 |
{
|
42 |
+
$alternatives = array();
|
43 |
foreach ($items as $item) {
|
44 |
$lev = levenshtein($name, $item);
|
45 |
+
if ($lev <= strlen($name) / 3 || false !== strpos($item, $name)) {
|
46 |
$alternatives[$item] = $lev;
|
47 |
}
|
48 |
}
|
51 |
return array_keys($alternatives);
|
52 |
}
|
53 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/ExistsLoaderInterface.php
CHANGED
@@ -27,5 +27,3 @@ interface Twig_ExistsLoaderInterface
|
|
27 |
*/
|
28 |
public function exists($name);
|
29 |
}
|
30 |
-
|
31 |
-
class_alias('Twig_ExistsLoaderInterface', 'Twig\Loader\ExistsLoaderInterface', false);
|
27 |
*/
|
28 |
public function exists($name);
|
29 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/ExpressionParser.php
CHANGED
@@ -10,37 +10,13 @@
|
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
|
13 |
-
use Twig\Environment;
|
14 |
-
use Twig\Error\SyntaxError;
|
15 |
-
use Twig\Lexer;
|
16 |
-
use Twig\Node\Expression\ArrayExpression;
|
17 |
-
use Twig\Node\Expression\AssignNameExpression;
|
18 |
-
use Twig\Node\Expression\Binary\ConcatBinary;
|
19 |
-
use Twig\Node\Expression\BlockReferenceExpression;
|
20 |
-
use Twig\Node\Expression\ConditionalExpression;
|
21 |
-
use Twig\Node\Expression\ConstantExpression;
|
22 |
-
use Twig\Node\Expression\GetAttrExpression;
|
23 |
-
use Twig\Node\Expression\MethodCallExpression;
|
24 |
-
use Twig\Node\Expression\NameExpression;
|
25 |
-
use Twig\Node\Expression\ParentExpression;
|
26 |
-
use Twig\Node\Expression\Unary\NegUnary;
|
27 |
-
use Twig\Node\Expression\Unary\NotUnary;
|
28 |
-
use Twig\Node\Expression\Unary\PosUnary;
|
29 |
-
use Twig\Node\Node;
|
30 |
-
use Twig\Parser;
|
31 |
-
use Twig\Template;
|
32 |
-
use Twig\Token;
|
33 |
-
use Twig\TwigFilter;
|
34 |
-
use Twig\TwigFunction;
|
35 |
-
use Twig\TwigTest;
|
36 |
-
|
37 |
/**
|
38 |
* Parses expressions.
|
39 |
*
|
40 |
* This parser implements a "Precedence climbing" algorithm.
|
41 |
*
|
42 |
-
* @see
|
43 |
-
* @see
|
44 |
*
|
45 |
* @author Fabien Potencier <fabien@symfony.com>
|
46 |
*
|
@@ -57,11 +33,11 @@ class Twig_ExpressionParser
|
|
57 |
|
58 |
private $env;
|
59 |
|
60 |
-
public function __construct(
|
61 |
{
|
62 |
$this->parser = $parser;
|
63 |
|
64 |
-
if ($env instanceof
|
65 |
$this->env = $env;
|
66 |
$this->unaryOperators = $env->getUnaryOperators();
|
67 |
$this->binaryOperators = $env->getBinaryOperators();
|
@@ -87,7 +63,7 @@ class Twig_ExpressionParser
|
|
87 |
} elseif ('is' === $token->getValue()) {
|
88 |
$expr = $this->parseTestExpression($expr);
|
89 |
} elseif (isset($op['callable'])) {
|
90 |
-
$expr =
|
91 |
} else {
|
92 |
$expr1 = $this->parseExpression(self::OPERATOR_LEFT === $op['associativity'] ? $op['precedence'] + 1 : $op['precedence']);
|
93 |
$class = $op['class'];
|
@@ -115,10 +91,10 @@ class Twig_ExpressionParser
|
|
115 |
$class = $operator['class'];
|
116 |
|
117 |
return $this->parsePostfixExpression(new $class($expr, $token->getLine()));
|
118 |
-
} elseif ($token->test(
|
119 |
$this->parser->getStream()->next();
|
120 |
$expr = $this->parseExpression();
|
121 |
-
$this->parser->getStream()->expect(
|
122 |
|
123 |
return $this->parsePostfixExpression($expr);
|
124 |
}
|
@@ -128,92 +104,92 @@ class Twig_ExpressionParser
|
|
128 |
|
129 |
protected function parseConditionalExpression($expr)
|
130 |
{
|
131 |
-
while ($this->parser->getStream()->nextIf(
|
132 |
-
if (!$this->parser->getStream()->nextIf(
|
133 |
$expr2 = $this->parseExpression();
|
134 |
-
if ($this->parser->getStream()->nextIf(
|
135 |
$expr3 = $this->parseExpression();
|
136 |
} else {
|
137 |
-
$expr3 = new
|
138 |
}
|
139 |
} else {
|
140 |
$expr2 = $expr;
|
141 |
$expr3 = $this->parseExpression();
|
142 |
}
|
143 |
|
144 |
-
$expr = new
|
145 |
}
|
146 |
|
147 |
return $expr;
|
148 |
}
|
149 |
|
150 |
-
protected function isUnary(
|
151 |
{
|
152 |
-
return $token->test(
|
153 |
}
|
154 |
|
155 |
-
protected function isBinary(
|
156 |
{
|
157 |
-
return $token->test(
|
158 |
}
|
159 |
|
160 |
public function parsePrimaryExpression()
|
161 |
{
|
162 |
$token = $this->parser->getCurrentToken();
|
163 |
switch ($token->getType()) {
|
164 |
-
case
|
165 |
$this->parser->getStream()->next();
|
166 |
switch ($token->getValue()) {
|
167 |
case 'true':
|
168 |
case 'TRUE':
|
169 |
-
$node = new
|
170 |
break;
|
171 |
|
172 |
case 'false':
|
173 |
case 'FALSE':
|
174 |
-
$node = new
|
175 |
break;
|
176 |
|
177 |
case 'none':
|
178 |
case 'NONE':
|
179 |
case 'null':
|
180 |
case 'NULL':
|
181 |
-
$node = new
|
182 |
break;
|
183 |
|
184 |
default:
|
185 |
if ('(' === $this->parser->getCurrentToken()->getValue()) {
|
186 |
$node = $this->getFunctionNode($token->getValue(), $token->getLine());
|
187 |
} else {
|
188 |
-
$node = new
|
189 |
}
|
190 |
}
|
191 |
break;
|
192 |
|
193 |
-
case
|
194 |
$this->parser->getStream()->next();
|
195 |
-
$node = new
|
196 |
break;
|
197 |
|
198 |
-
case
|
199 |
-
case
|
200 |
$node = $this->parseStringExpression();
|
201 |
break;
|
202 |
|
203 |
-
case
|
204 |
-
if (preg_match(
|
205 |
// in this context, string operators are variable names
|
206 |
$this->parser->getStream()->next();
|
207 |
-
$node = new
|
208 |
break;
|
209 |
} elseif (isset($this->unaryOperators[$token->getValue()])) {
|
210 |
$class = $this->unaryOperators[$token->getValue()]['class'];
|
211 |
|
212 |
-
$ref = new
|
213 |
$negClass = 'Twig_Node_Expression_Unary_Neg';
|
214 |
$posClass = 'Twig_Node_Expression_Unary_Pos';
|
215 |
-
if (!(
|
216 |
-
throw new
|
217 |
}
|
218 |
|
219 |
$this->parser->getStream()->next();
|
@@ -223,16 +199,13 @@ class Twig_ExpressionParser
|
|
223 |
break;
|
224 |
}
|
225 |
|
226 |
-
// no break
|
227 |
default:
|
228 |
-
if ($token->test(
|
229 |
$node = $this->parseArrayExpression();
|
230 |
-
} elseif ($token->test(
|
231 |
$node = $this->parseHashExpression();
|
232 |
-
} elseif ($token->test(Token::OPERATOR_TYPE, '=') && ('==' === $this->parser->getStream()->look(-1)->getValue() || '!=' === $this->parser->getStream()->look(-1)->getValue())) {
|
233 |
-
throw new SyntaxError(sprintf('Unexpected operator of value "%s". Did you try to use "===" or "!==" for strict comparison? Use "is same as(value)" instead.', $token->getValue()), $token->getLine(), $this->parser->getStream()->getSourceContext());
|
234 |
} else {
|
235 |
-
throw new
|
236 |
}
|
237 |
}
|
238 |
|
@@ -243,16 +216,16 @@ class Twig_ExpressionParser
|
|
243 |
{
|
244 |
$stream = $this->parser->getStream();
|
245 |
|
246 |
-
$nodes =
|
247 |
// a string cannot be followed by another string in a single expression
|
248 |
$nextCanBeString = true;
|
249 |
while (true) {
|
250 |
-
if ($nextCanBeString && $token = $stream->nextIf(
|
251 |
-
$nodes[] = new
|
252 |
$nextCanBeString = false;
|
253 |
-
} elseif ($stream->nextIf(
|
254 |
$nodes[] = $this->parseExpression();
|
255 |
-
$stream->expect(
|
256 |
$nextCanBeString = true;
|
257 |
} else {
|
258 |
break;
|
@@ -261,7 +234,7 @@ class Twig_ExpressionParser
|
|
261 |
|
262 |
$expr = array_shift($nodes);
|
263 |
foreach ($nodes as $node) {
|
264 |
-
$expr = new
|
265 |
}
|
266 |
|
267 |
return $expr;
|
@@ -270,16 +243,16 @@ class Twig_ExpressionParser
|
|
270 |
public function parseArrayExpression()
|
271 |
{
|
272 |
$stream = $this->parser->getStream();
|
273 |
-
$stream->expect(
|
274 |
|
275 |
-
$node = new
|
276 |
$first = true;
|
277 |
-
while (!$stream->test(
|
278 |
if (!$first) {
|
279 |
-
$stream->expect(
|
280 |
|
281 |
// trailing ,?
|
282 |
-
if ($stream->test(
|
283 |
break;
|
284 |
}
|
285 |
}
|
@@ -287,7 +260,7 @@ class Twig_ExpressionParser
|
|
287 |
|
288 |
$node->addElement($this->parseExpression());
|
289 |
}
|
290 |
-
$stream->expect(
|
291 |
|
292 |
return $node;
|
293 |
}
|
@@ -295,16 +268,16 @@ class Twig_ExpressionParser
|
|
295 |
public function parseHashExpression()
|
296 |
{
|
297 |
$stream = $this->parser->getStream();
|
298 |
-
$stream->expect(
|
299 |
|
300 |
-
$node = new
|
301 |
$first = true;
|
302 |
-
while (!$stream->test(
|
303 |
if (!$first) {
|
304 |
-
$stream->expect(
|
305 |
|
306 |
// trailing ,?
|
307 |
-
if ($stream->test(
|
308 |
break;
|
309 |
}
|
310 |
}
|
@@ -316,22 +289,22 @@ class Twig_ExpressionParser
|
|
316 |
// * a string -- 'a'
|
317 |
// * a name, which is equivalent to a string -- a
|
318 |
// * an expression, which must be enclosed in parentheses -- (1 + 2)
|
319 |
-
if (($token = $stream->nextIf(
|
320 |
-
$key = new
|
321 |
-
} elseif ($stream->test(
|
322 |
$key = $this->parseExpression();
|
323 |
} else {
|
324 |
$current = $stream->getCurrent();
|
325 |
|
326 |
-
throw new
|
327 |
}
|
328 |
|
329 |
-
$stream->expect(
|
330 |
$value = $this->parseExpression();
|
331 |
|
332 |
$node->addElement($value, $key);
|
333 |
}
|
334 |
-
$stream->expect(
|
335 |
|
336 |
return $node;
|
337 |
}
|
@@ -340,7 +313,7 @@ class Twig_ExpressionParser
|
|
340 |
{
|
341 |
while (true) {
|
342 |
$token = $this->parser->getCurrentToken();
|
343 |
-
if (
|
344 |
if ('.' == $token->getValue() || '[' == $token->getValue()) {
|
345 |
$node = $this->parseSubscriptExpression($node);
|
346 |
} elseif ('|' == $token->getValue()) {
|
@@ -361,37 +334,37 @@ class Twig_ExpressionParser
|
|
361 |
switch ($name) {
|
362 |
case 'parent':
|
363 |
$this->parseArguments();
|
364 |
-
if (
|
365 |
-
throw new
|
366 |
}
|
367 |
|
368 |
if (!$this->parser->getParent() && !$this->parser->hasTraits()) {
|
369 |
-
throw new
|
370 |
}
|
371 |
|
372 |
-
return new
|
373 |
case 'block':
|
374 |
$args = $this->parseArguments();
|
375 |
-
if (
|
376 |
-
throw new
|
377 |
}
|
378 |
|
379 |
-
return new
|
380 |
case 'attribute':
|
381 |
$args = $this->parseArguments();
|
382 |
-
if (
|
383 |
-
throw new
|
384 |
}
|
385 |
|
386 |
-
return new
|
387 |
default:
|
388 |
if (null !== $alias = $this->parser->getImportedSymbol('function', $name)) {
|
389 |
-
$arguments = new
|
390 |
foreach ($this->parseArguments() as $n) {
|
391 |
$arguments->addElement($n);
|
392 |
}
|
393 |
|
394 |
-
$node = new
|
395 |
$node->setAttribute('safe', true);
|
396 |
|
397 |
return $node;
|
@@ -409,81 +382,81 @@ class Twig_ExpressionParser
|
|
409 |
$stream = $this->parser->getStream();
|
410 |
$token = $stream->next();
|
411 |
$lineno = $token->getLine();
|
412 |
-
$arguments = new
|
413 |
-
$type =
|
414 |
-
if (
|
415 |
$token = $stream->next();
|
416 |
if (
|
417 |
-
|
418 |
||
|
419 |
-
|
420 |
||
|
421 |
-
(
|
422 |
) {
|
423 |
-
$arg = new
|
424 |
|
425 |
-
if ($stream->test(
|
426 |
-
$type =
|
427 |
foreach ($this->parseArguments() as $n) {
|
428 |
$arguments->addElement($n);
|
429 |
}
|
430 |
}
|
431 |
} else {
|
432 |
-
throw new
|
433 |
}
|
434 |
|
435 |
-
if ($node instanceof
|
436 |
-
if (!$arg instanceof
|
437 |
-
throw new
|
438 |
}
|
439 |
|
440 |
$name = $arg->getAttribute('value');
|
441 |
|
442 |
if ($this->parser->isReservedMacroName($name)) {
|
443 |
-
throw new
|
444 |
}
|
445 |
|
446 |
-
$node = new
|
447 |
$node->setAttribute('safe', true);
|
448 |
|
449 |
return $node;
|
450 |
}
|
451 |
} else {
|
452 |
-
$type =
|
453 |
|
454 |
// slice?
|
455 |
$slice = false;
|
456 |
-
if ($stream->test(
|
457 |
$slice = true;
|
458 |
-
$arg = new
|
459 |
} else {
|
460 |
$arg = $this->parseExpression();
|
461 |
}
|
462 |
|
463 |
-
if ($stream->nextIf(
|
464 |
$slice = true;
|
465 |
}
|
466 |
|
467 |
if ($slice) {
|
468 |
-
if ($stream->test(
|
469 |
-
$length = new
|
470 |
} else {
|
471 |
$length = $this->parseExpression();
|
472 |
}
|
473 |
|
474 |
$class = $this->getFilterNodeClass('slice', $token->getLine());
|
475 |
-
$arguments = new
|
476 |
-
$filter = new $class($node, new
|
477 |
|
478 |
-
$stream->expect(
|
479 |
|
480 |
return $filter;
|
481 |
}
|
482 |
|
483 |
-
$stream->expect(
|
484 |
}
|
485 |
|
486 |
-
return new
|
487 |
}
|
488 |
|
489 |
public function parseFilterExpression($node)
|
@@ -496,11 +469,11 @@ class Twig_ExpressionParser
|
|
496 |
public function parseFilterExpressionRaw($node, $tag = null)
|
497 |
{
|
498 |
while (true) {
|
499 |
-
$token = $this->parser->getStream()->expect(
|
500 |
|
501 |
-
$name = new
|
502 |
-
if (!$this->parser->getStream()->test(
|
503 |
-
$arguments = new
|
504 |
} else {
|
505 |
$arguments = $this->parseArguments(true);
|
506 |
}
|
@@ -509,7 +482,7 @@ class Twig_ExpressionParser
|
|
509 |
|
510 |
$node = new $class($node, $name, $arguments, $token->getLine(), $tag);
|
511 |
|
512 |
-
if (!$this->parser->getStream()->test(
|
513 |
break;
|
514 |
}
|
515 |
|
@@ -525,32 +498,32 @@ class Twig_ExpressionParser
|
|
525 |
* @param bool $namedArguments Whether to allow named arguments or not
|
526 |
* @param bool $definition Whether we are parsing arguments for a function definition
|
527 |
*
|
528 |
-
* @return
|
529 |
*
|
530 |
-
* @throws
|
531 |
*/
|
532 |
public function parseArguments($namedArguments = false, $definition = false)
|
533 |
{
|
534 |
-
$args =
|
535 |
$stream = $this->parser->getStream();
|
536 |
|
537 |
-
$stream->expect(
|
538 |
-
while (!$stream->test(
|
539 |
if (!empty($args)) {
|
540 |
-
$stream->expect(
|
541 |
}
|
542 |
|
543 |
if ($definition) {
|
544 |
-
$token = $stream->expect(
|
545 |
-
$value = new
|
546 |
} else {
|
547 |
$value = $this->parseExpression();
|
548 |
}
|
549 |
|
550 |
$name = null;
|
551 |
-
if ($namedArguments && $token = $stream->nextIf(
|
552 |
-
if (!$value instanceof
|
553 |
-
throw new
|
554 |
}
|
555 |
$name = $value->getAttribute('name');
|
556 |
|
@@ -558,7 +531,7 @@ class Twig_ExpressionParser
|
|
558 |
$value = $this->parsePrimaryExpression();
|
559 |
|
560 |
if (!$this->checkConstantExpression($value)) {
|
561 |
-
throw new
|
562 |
}
|
563 |
} else {
|
564 |
$value = $this->parseExpression();
|
@@ -568,7 +541,7 @@ class Twig_ExpressionParser
|
|
568 |
if ($definition) {
|
569 |
if (null === $name) {
|
570 |
$name = $value->getAttribute('name');
|
571 |
-
$value = new
|
572 |
}
|
573 |
$args[$name] = $value;
|
574 |
} else {
|
@@ -579,47 +552,47 @@ class Twig_ExpressionParser
|
|
579 |
}
|
580 |
}
|
581 |
}
|
582 |
-
$stream->expect(
|
583 |
|
584 |
-
return new
|
585 |
}
|
586 |
|
587 |
public function parseAssignmentExpression()
|
588 |
{
|
589 |
$stream = $this->parser->getStream();
|
590 |
-
$targets =
|
591 |
while (true) {
|
592 |
-
$token = $stream->expect(
|
593 |
$value = $token->getValue();
|
594 |
-
if (
|
595 |
-
throw new
|
596 |
}
|
597 |
-
$targets[] = new
|
598 |
|
599 |
-
if (!$stream->nextIf(
|
600 |
break;
|
601 |
}
|
602 |
}
|
603 |
|
604 |
-
return new
|
605 |
}
|
606 |
|
607 |
public function parseMultitargetExpression()
|
608 |
{
|
609 |
-
$targets =
|
610 |
while (true) {
|
611 |
$targets[] = $this->parseExpression();
|
612 |
-
if (!$this->parser->getStream()->nextIf(
|
613 |
break;
|
614 |
}
|
615 |
}
|
616 |
|
617 |
-
return new
|
618 |
}
|
619 |
|
620 |
private function parseNotTestExpression(Twig_NodeInterface $node)
|
621 |
{
|
622 |
-
return new
|
623 |
}
|
624 |
|
625 |
private function parseTestExpression(Twig_NodeInterface $node)
|
@@ -629,7 +602,7 @@ class Twig_ExpressionParser
|
|
629 |
|
630 |
$class = $this->getTestNodeClass($test);
|
631 |
$arguments = null;
|
632 |
-
if ($stream->test(
|
633 |
$arguments = $this->parser->getExpressionParser()->parseArguments(true);
|
634 |
}
|
635 |
|
@@ -639,24 +612,24 @@ class Twig_ExpressionParser
|
|
639 |
private function getTest($line)
|
640 |
{
|
641 |
$stream = $this->parser->getStream();
|
642 |
-
$name = $stream->expect(
|
643 |
|
644 |
if ($test = $this->env->getTest($name)) {
|
645 |
-
return
|
646 |
}
|
647 |
|
648 |
-
if ($stream->test(
|
649 |
// try 2-words tests
|
650 |
$name = $name.' '.$this->parser->getCurrentToken()->getValue();
|
651 |
|
652 |
if ($test = $this->env->getTest($name)) {
|
653 |
$stream->next();
|
654 |
|
655 |
-
return
|
656 |
}
|
657 |
}
|
658 |
|
659 |
-
$e = new
|
660 |
$e->addSuggestions($name, array_keys($this->env->getTests()));
|
661 |
|
662 |
throw $e;
|
@@ -664,10 +637,10 @@ class Twig_ExpressionParser
|
|
664 |
|
665 |
private function getTestNodeClass($test)
|
666 |
{
|
667 |
-
if ($test instanceof
|
668 |
$stream = $this->parser->getStream();
|
669 |
$message = sprintf('Twig Test "%s" is deprecated', $test->getName());
|
670 |
-
if (
|
671 |
$message .= sprintf(' since version %s', $test->getDeprecatedVersion());
|
672 |
}
|
673 |
if ($test->getAlternative()) {
|
@@ -679,7 +652,7 @@ class Twig_ExpressionParser
|
|
679 |
@trigger_error($message, E_USER_DEPRECATED);
|
680 |
}
|
681 |
|
682 |
-
if ($test instanceof
|
683 |
return $test->getNodeClass();
|
684 |
}
|
685 |
|
@@ -689,15 +662,15 @@ class Twig_ExpressionParser
|
|
689 |
protected function getFunctionNodeClass($name, $line)
|
690 |
{
|
691 |
if (false === $function = $this->env->getFunction($name)) {
|
692 |
-
$e = new
|
693 |
$e->addSuggestions($name, array_keys($this->env->getFunctions()));
|
694 |
|
695 |
throw $e;
|
696 |
}
|
697 |
|
698 |
-
if ($function instanceof
|
699 |
$message = sprintf('Twig Function "%s" is deprecated', $function->getName());
|
700 |
-
if (
|
701 |
$message .= sprintf(' since version %s', $function->getDeprecatedVersion());
|
702 |
}
|
703 |
if ($function->getAlternative()) {
|
@@ -709,7 +682,7 @@ class Twig_ExpressionParser
|
|
709 |
@trigger_error($message, E_USER_DEPRECATED);
|
710 |
}
|
711 |
|
712 |
-
if ($function instanceof
|
713 |
return $function->getNodeClass();
|
714 |
}
|
715 |
|
@@ -719,15 +692,15 @@ class Twig_ExpressionParser
|
|
719 |
protected function getFilterNodeClass($name, $line)
|
720 |
{
|
721 |
if (false === $filter = $this->env->getFilter($name)) {
|
722 |
-
$e = new
|
723 |
$e->addSuggestions($name, array_keys($this->env->getFilters()));
|
724 |
|
725 |
throw $e;
|
726 |
}
|
727 |
|
728 |
-
if ($filter instanceof
|
729 |
$message = sprintf('Twig Filter "%s" is deprecated', $filter->getName());
|
730 |
-
if (
|
731 |
$message .= sprintf(' since version %s', $filter->getDeprecatedVersion());
|
732 |
}
|
733 |
if ($filter->getAlternative()) {
|
@@ -739,7 +712,7 @@ class Twig_ExpressionParser
|
|
739 |
@trigger_error($message, E_USER_DEPRECATED);
|
740 |
}
|
741 |
|
742 |
-
if ($filter instanceof
|
743 |
return $filter->getNodeClass();
|
744 |
}
|
745 |
|
@@ -749,8 +722,8 @@ class Twig_ExpressionParser
|
|
749 |
// checks that the node only contains "constant" elements
|
750 |
protected function checkConstantExpression(Twig_NodeInterface $node)
|
751 |
{
|
752 |
-
if (!($node instanceof
|
753 |
-
|| $node instanceof
|
754 |
)) {
|
755 |
return false;
|
756 |
}
|
@@ -764,5 +737,3 @@ class Twig_ExpressionParser
|
|
764 |
return true;
|
765 |
}
|
766 |
}
|
767 |
-
|
768 |
-
class_alias('Twig_ExpressionParser', 'Twig\ExpressionParser', false);
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
/**
|
14 |
* Parses expressions.
|
15 |
*
|
16 |
* This parser implements a "Precedence climbing" algorithm.
|
17 |
*
|
18 |
+
* @see http://www.engr.mun.ca/~theo/Misc/exp_parsing.htm
|
19 |
+
* @see http://en.wikipedia.org/wiki/Operator-precedence_parser
|
20 |
*
|
21 |
* @author Fabien Potencier <fabien@symfony.com>
|
22 |
*
|
33 |
|
34 |
private $env;
|
35 |
|
36 |
+
public function __construct(Twig_Parser $parser, $env = null)
|
37 |
{
|
38 |
$this->parser = $parser;
|
39 |
|
40 |
+
if ($env instanceof Twig_Environment) {
|
41 |
$this->env = $env;
|
42 |
$this->unaryOperators = $env->getUnaryOperators();
|
43 |
$this->binaryOperators = $env->getBinaryOperators();
|
63 |
} elseif ('is' === $token->getValue()) {
|
64 |
$expr = $this->parseTestExpression($expr);
|
65 |
} elseif (isset($op['callable'])) {
|
66 |
+
$expr = call_user_func($op['callable'], $this->parser, $expr);
|
67 |
} else {
|
68 |
$expr1 = $this->parseExpression(self::OPERATOR_LEFT === $op['associativity'] ? $op['precedence'] + 1 : $op['precedence']);
|
69 |
$class = $op['class'];
|
91 |
$class = $operator['class'];
|
92 |
|
93 |
return $this->parsePostfixExpression(new $class($expr, $token->getLine()));
|
94 |
+
} elseif ($token->test(Twig_Token::PUNCTUATION_TYPE, '(')) {
|
95 |
$this->parser->getStream()->next();
|
96 |
$expr = $this->parseExpression();
|
97 |
+
$this->parser->getStream()->expect(Twig_Token::PUNCTUATION_TYPE, ')', 'An opened parenthesis is not properly closed');
|
98 |
|
99 |
return $this->parsePostfixExpression($expr);
|
100 |
}
|
104 |
|
105 |
protected function parseConditionalExpression($expr)
|
106 |
{
|
107 |
+
while ($this->parser->getStream()->nextIf(Twig_Token::PUNCTUATION_TYPE, '?')) {
|
108 |
+
if (!$this->parser->getStream()->nextIf(Twig_Token::PUNCTUATION_TYPE, ':')) {
|
109 |
$expr2 = $this->parseExpression();
|
110 |
+
if ($this->parser->getStream()->nextIf(Twig_Token::PUNCTUATION_TYPE, ':')) {
|
111 |
$expr3 = $this->parseExpression();
|
112 |
} else {
|
113 |
+
$expr3 = new Twig_Node_Expression_Constant('', $this->parser->getCurrentToken()->getLine());
|
114 |
}
|
115 |
} else {
|
116 |
$expr2 = $expr;
|
117 |
$expr3 = $this->parseExpression();
|
118 |
}
|
119 |
|
120 |
+
$expr = new Twig_Node_Expression_Conditional($expr, $expr2, $expr3, $this->parser->getCurrentToken()->getLine());
|
121 |
}
|
122 |
|
123 |
return $expr;
|
124 |
}
|
125 |
|
126 |
+
protected function isUnary(Twig_Token $token)
|
127 |
{
|
128 |
+
return $token->test(Twig_Token::OPERATOR_TYPE) && isset($this->unaryOperators[$token->getValue()]);
|
129 |
}
|
130 |
|
131 |
+
protected function isBinary(Twig_Token $token)
|
132 |
{
|
133 |
+
return $token->test(Twig_Token::OPERATOR_TYPE) && isset($this->binaryOperators[$token->getValue()]);
|
134 |
}
|
135 |
|
136 |
public function parsePrimaryExpression()
|
137 |
{
|
138 |
$token = $this->parser->getCurrentToken();
|
139 |
switch ($token->getType()) {
|
140 |
+
case Twig_Token::NAME_TYPE:
|
141 |
$this->parser->getStream()->next();
|
142 |
switch ($token->getValue()) {
|
143 |
case 'true':
|
144 |
case 'TRUE':
|
145 |
+
$node = new Twig_Node_Expression_Constant(true, $token->getLine());
|
146 |
break;
|
147 |
|
148 |
case 'false':
|
149 |
case 'FALSE':
|
150 |
+
$node = new Twig_Node_Expression_Constant(false, $token->getLine());
|
151 |
break;
|
152 |
|
153 |
case 'none':
|
154 |
case 'NONE':
|
155 |
case 'null':
|
156 |
case 'NULL':
|
157 |
+
$node = new Twig_Node_Expression_Constant(null, $token->getLine());
|
158 |
break;
|
159 |
|
160 |
default:
|
161 |
if ('(' === $this->parser->getCurrentToken()->getValue()) {
|
162 |
$node = $this->getFunctionNode($token->getValue(), $token->getLine());
|
163 |
} else {
|
164 |
+
$node = new Twig_Node_Expression_Name($token->getValue(), $token->getLine());
|
165 |
}
|
166 |
}
|
167 |
break;
|
168 |
|
169 |
+
case Twig_Token::NUMBER_TYPE:
|
170 |
$this->parser->getStream()->next();
|
171 |
+
$node = new Twig_Node_Expression_Constant($token->getValue(), $token->getLine());
|
172 |
break;
|
173 |
|
174 |
+
case Twig_Token::STRING_TYPE:
|
175 |
+
case Twig_Token::INTERPOLATION_START_TYPE:
|
176 |
$node = $this->parseStringExpression();
|
177 |
break;
|
178 |
|
179 |
+
case Twig_Token::OPERATOR_TYPE:
|
180 |
+
if (preg_match(Twig_Lexer::REGEX_NAME, $token->getValue(), $matches) && $matches[0] == $token->getValue()) {
|
181 |
// in this context, string operators are variable names
|
182 |
$this->parser->getStream()->next();
|
183 |
+
$node = new Twig_Node_Expression_Name($token->getValue(), $token->getLine());
|
184 |
break;
|
185 |
} elseif (isset($this->unaryOperators[$token->getValue()])) {
|
186 |
$class = $this->unaryOperators[$token->getValue()]['class'];
|
187 |
|
188 |
+
$ref = new ReflectionClass($class);
|
189 |
$negClass = 'Twig_Node_Expression_Unary_Neg';
|
190 |
$posClass = 'Twig_Node_Expression_Unary_Pos';
|
191 |
+
if (!(in_array($ref->getName(), array($negClass, $posClass)) || $ref->isSubclassOf($negClass) || $ref->isSubclassOf($posClass))) {
|
192 |
+
throw new Twig_Error_Syntax(sprintf('Unexpected unary operator "%s".', $token->getValue()), $token->getLine(), $this->parser->getStream()->getSourceContext());
|
193 |
}
|
194 |
|
195 |
$this->parser->getStream()->next();
|
199 |
break;
|
200 |
}
|
201 |
|
|
|
202 |
default:
|
203 |
+
if ($token->test(Twig_Token::PUNCTUATION_TYPE, '[')) {
|
204 |
$node = $this->parseArrayExpression();
|
205 |
+
} elseif ($token->test(Twig_Token::PUNCTUATION_TYPE, '{')) {
|
206 |
$node = $this->parseHashExpression();
|
|
|
|
|
207 |
} else {
|
208 |
+
throw new Twig_Error_Syntax(sprintf('Unexpected token "%s" of value "%s".', Twig_Token::typeToEnglish($token->getType()), $token->getValue()), $token->getLine(), $this->parser->getStream()->getSourceContext());
|
209 |
}
|
210 |
}
|
211 |
|
216 |
{
|
217 |
$stream = $this->parser->getStream();
|
218 |
|
219 |
+
$nodes = array();
|
220 |
// a string cannot be followed by another string in a single expression
|
221 |
$nextCanBeString = true;
|
222 |
while (true) {
|
223 |
+
if ($nextCanBeString && $token = $stream->nextIf(Twig_Token::STRING_TYPE)) {
|
224 |
+
$nodes[] = new Twig_Node_Expression_Constant($token->getValue(), $token->getLine());
|
225 |
$nextCanBeString = false;
|
226 |
+
} elseif ($stream->nextIf(Twig_Token::INTERPOLATION_START_TYPE)) {
|
227 |
$nodes[] = $this->parseExpression();
|
228 |
+
$stream->expect(Twig_Token::INTERPOLATION_END_TYPE);
|
229 |
$nextCanBeString = true;
|
230 |
} else {
|
231 |
break;
|
234 |
|
235 |
$expr = array_shift($nodes);
|
236 |
foreach ($nodes as $node) {
|
237 |
+
$expr = new Twig_Node_Expression_Binary_Concat($expr, $node, $node->getTemplateLine());
|
238 |
}
|
239 |
|
240 |
return $expr;
|
243 |
public function parseArrayExpression()
|
244 |
{
|
245 |
$stream = $this->parser->getStream();
|
246 |
+
$stream->expect(Twig_Token::PUNCTUATION_TYPE, '[', 'An array element was expected');
|
247 |
|
248 |
+
$node = new Twig_Node_Expression_Array(array(), $stream->getCurrent()->getLine());
|
249 |
$first = true;
|
250 |
+
while (!$stream->test(Twig_Token::PUNCTUATION_TYPE, ']')) {
|
251 |
if (!$first) {
|
252 |
+
$stream->expect(Twig_Token::PUNCTUATION_TYPE, ',', 'An array element must be followed by a comma');
|
253 |
|
254 |
// trailing ,?
|
255 |
+
if ($stream->test(Twig_Token::PUNCTUATION_TYPE, ']')) {
|
256 |
break;
|
257 |
}
|
258 |
}
|
260 |
|
261 |
$node->addElement($this->parseExpression());
|
262 |
}
|
263 |
+
$stream->expect(Twig_Token::PUNCTUATION_TYPE, ']', 'An opened array is not properly closed');
|
264 |
|
265 |
return $node;
|
266 |
}
|
268 |
public function parseHashExpression()
|
269 |
{
|
270 |
$stream = $this->parser->getStream();
|
271 |
+
$stream->expect(Twig_Token::PUNCTUATION_TYPE, '{', 'A hash element was expected');
|
272 |
|
273 |
+
$node = new Twig_Node_Expression_Array(array(), $stream->getCurrent()->getLine());
|
274 |
$first = true;
|
275 |
+
while (!$stream->test(Twig_Token::PUNCTUATION_TYPE, '}')) {
|
276 |
if (!$first) {
|
277 |
+
$stream->expect(Twig_Token::PUNCTUATION_TYPE, ',', 'A hash value must be followed by a comma');
|
278 |
|
279 |
// trailing ,?
|
280 |
+
if ($stream->test(Twig_Token::PUNCTUATION_TYPE, '}')) {
|
281 |
break;
|
282 |
}
|
283 |
}
|
289 |
// * a string -- 'a'
|
290 |
// * a name, which is equivalent to a string -- a
|
291 |
// * an expression, which must be enclosed in parentheses -- (1 + 2)
|
292 |
+
if (($token = $stream->nextIf(Twig_Token::STRING_TYPE)) || ($token = $stream->nextIf(Twig_Token::NAME_TYPE)) || $token = $stream->nextIf(Twig_Token::NUMBER_TYPE)) {
|
293 |
+
$key = new Twig_Node_Expression_Constant($token->getValue(), $token->getLine());
|
294 |
+
} elseif ($stream->test(Twig_Token::PUNCTUATION_TYPE, '(')) {
|
295 |
$key = $this->parseExpression();
|
296 |
} else {
|
297 |
$current = $stream->getCurrent();
|
298 |
|
299 |
+
throw new Twig_Error_Syntax(sprintf('A hash key must be a quoted string, a number, a name, or an expression enclosed in parentheses (unexpected token "%s" of value "%s".', Twig_Token::typeToEnglish($current->getType()), $current->getValue()), $current->getLine(), $stream->getSourceContext());
|
300 |
}
|
301 |
|
302 |
+
$stream->expect(Twig_Token::PUNCTUATION_TYPE, ':', 'A hash key must be followed by a colon (:)');
|
303 |
$value = $this->parseExpression();
|
304 |
|
305 |
$node->addElement($value, $key);
|
306 |
}
|
307 |
+
$stream->expect(Twig_Token::PUNCTUATION_TYPE, '}', 'An opened hash is not properly closed');
|
308 |
|
309 |
return $node;
|
310 |
}
|
313 |
{
|
314 |
while (true) {
|
315 |
$token = $this->parser->getCurrentToken();
|
316 |
+
if ($token->getType() == Twig_Token::PUNCTUATION_TYPE) {
|
317 |
if ('.' == $token->getValue() || '[' == $token->getValue()) {
|
318 |
$node = $this->parseSubscriptExpression($node);
|
319 |
} elseif ('|' == $token->getValue()) {
|
334 |
switch ($name) {
|
335 |
case 'parent':
|
336 |
$this->parseArguments();
|
337 |
+
if (!count($this->parser->getBlockStack())) {
|
338 |
+
throw new Twig_Error_Syntax('Calling "parent" outside a block is forbidden.', $line, $this->parser->getStream()->getSourceContext());
|
339 |
}
|
340 |
|
341 |
if (!$this->parser->getParent() && !$this->parser->hasTraits()) {
|
342 |
+
throw new Twig_Error_Syntax('Calling "parent" on a template that does not extend nor "use" another template is forbidden.', $line, $this->parser->getStream()->getSourceContext());
|
343 |
}
|
344 |
|
345 |
+
return new Twig_Node_Expression_Parent($this->parser->peekBlockStack(), $line);
|
346 |
case 'block':
|
347 |
$args = $this->parseArguments();
|
348 |
+
if (count($args) < 1) {
|
349 |
+
throw new Twig_Error_Syntax('The "block" function takes one argument (the block name).', $line, $this->parser->getStream()->getSourceContext());
|
350 |
}
|
351 |
|
352 |
+
return new Twig_Node_Expression_BlockReference($args->getNode(0), count($args) > 1 ? $args->getNode(1) : null, $line);
|
353 |
case 'attribute':
|
354 |
$args = $this->parseArguments();
|
355 |
+
if (count($args) < 2) {
|
356 |
+
throw new Twig_Error_Syntax('The "attribute" function takes at least two arguments (the variable and the attributes).', $line, $this->parser->getStream()->getSourceContext());
|
357 |
}
|
358 |
|
359 |
+
return new Twig_Node_Expression_GetAttr($args->getNode(0), $args->getNode(1), count($args) > 2 ? $args->getNode(2) : null, Twig_Template::ANY_CALL, $line);
|
360 |
default:
|
361 |
if (null !== $alias = $this->parser->getImportedSymbol('function', $name)) {
|
362 |
+
$arguments = new Twig_Node_Expression_Array(array(), $line);
|
363 |
foreach ($this->parseArguments() as $n) {
|
364 |
$arguments->addElement($n);
|
365 |
}
|
366 |
|
367 |
+
$node = new Twig_Node_Expression_MethodCall($alias['node'], $alias['name'], $arguments, $line);
|
368 |
$node->setAttribute('safe', true);
|
369 |
|
370 |
return $node;
|
382 |
$stream = $this->parser->getStream();
|
383 |
$token = $stream->next();
|
384 |
$lineno = $token->getLine();
|
385 |
+
$arguments = new Twig_Node_Expression_Array(array(), $lineno);
|
386 |
+
$type = Twig_Template::ANY_CALL;
|
387 |
+
if ($token->getValue() == '.') {
|
388 |
$token = $stream->next();
|
389 |
if (
|
390 |
+
$token->getType() == Twig_Token::NAME_TYPE
|
391 |
||
|
392 |
+
$token->getType() == Twig_Token::NUMBER_TYPE
|
393 |
||
|
394 |
+
($token->getType() == Twig_Token::OPERATOR_TYPE && preg_match(Twig_Lexer::REGEX_NAME, $token->getValue()))
|
395 |
) {
|
396 |
+
$arg = new Twig_Node_Expression_Constant($token->getValue(), $lineno);
|
397 |
|
398 |
+
if ($stream->test(Twig_Token::PUNCTUATION_TYPE, '(')) {
|
399 |
+
$type = Twig_Template::METHOD_CALL;
|
400 |
foreach ($this->parseArguments() as $n) {
|
401 |
$arguments->addElement($n);
|
402 |
}
|
403 |
}
|
404 |
} else {
|
405 |
+
throw new Twig_Error_Syntax('Expected name or number.', $lineno, $stream->getSourceContext());
|
406 |
}
|
407 |
|
408 |
+
if ($node instanceof Twig_Node_Expression_Name && null !== $this->parser->getImportedSymbol('template', $node->getAttribute('name'))) {
|
409 |
+
if (!$arg instanceof Twig_Node_Expression_Constant) {
|
410 |
+
throw new Twig_Error_Syntax(sprintf('Dynamic macro names are not supported (called on "%s").', $node->getAttribute('name')), $token->getLine(), $stream->getSourceContext());
|
411 |
}
|
412 |
|
413 |
$name = $arg->getAttribute('value');
|
414 |
|
415 |
if ($this->parser->isReservedMacroName($name)) {
|
416 |
+
throw new Twig_Error_Syntax(sprintf('"%s" cannot be called as macro as it is a reserved keyword.', $name), $token->getLine(), $stream->getSourceContext());
|
417 |
}
|
418 |
|
419 |
+
$node = new Twig_Node_Expression_MethodCall($node, 'get'.$name, $arguments, $lineno);
|
420 |
$node->setAttribute('safe', true);
|
421 |
|
422 |
return $node;
|
423 |
}
|
424 |
} else {
|
425 |
+
$type = Twig_Template::ARRAY_CALL;
|
426 |
|
427 |
// slice?
|
428 |
$slice = false;
|
429 |
+
if ($stream->test(Twig_Token::PUNCTUATION_TYPE, ':')) {
|
430 |
$slice = true;
|
431 |
+
$arg = new Twig_Node_Expression_Constant(0, $token->getLine());
|
432 |
} else {
|
433 |
$arg = $this->parseExpression();
|
434 |
}
|
435 |
|
436 |
+
if ($stream->nextIf(Twig_Token::PUNCTUATION_TYPE, ':')) {
|
437 |
$slice = true;
|
438 |
}
|
439 |
|
440 |
if ($slice) {
|
441 |
+
if ($stream->test(Twig_Token::PUNCTUATION_TYPE, ']')) {
|
442 |
+
$length = new Twig_Node_Expression_Constant(null, $token->getLine());
|
443 |
} else {
|
444 |
$length = $this->parseExpression();
|
445 |
}
|
446 |
|
447 |
$class = $this->getFilterNodeClass('slice', $token->getLine());
|
448 |
+
$arguments = new Twig_Node(array($arg, $length));
|
449 |
+
$filter = new $class($node, new Twig_Node_Expression_Constant('slice', $token->getLine()), $arguments, $token->getLine());
|
450 |
|
451 |
+
$stream->expect(Twig_Token::PUNCTUATION_TYPE, ']');
|
452 |
|
453 |
return $filter;
|
454 |
}
|
455 |
|
456 |
+
$stream->expect(Twig_Token::PUNCTUATION_TYPE, ']');
|
457 |
}
|
458 |
|
459 |
+
return new Twig_Node_Expression_GetAttr($node, $arg, $arguments, $type, $lineno);
|
460 |
}
|
461 |
|
462 |
public function parseFilterExpression($node)
|
469 |
public function parseFilterExpressionRaw($node, $tag = null)
|
470 |
{
|
471 |
while (true) {
|
472 |
+
$token = $this->parser->getStream()->expect(Twig_Token::NAME_TYPE);
|
473 |
|
474 |
+
$name = new Twig_Node_Expression_Constant($token->getValue(), $token->getLine());
|
475 |
+
if (!$this->parser->getStream()->test(Twig_Token::PUNCTUATION_TYPE, '(')) {
|
476 |
+
$arguments = new Twig_Node();
|
477 |
} else {
|
478 |
$arguments = $this->parseArguments(true);
|
479 |
}
|
482 |
|
483 |
$node = new $class($node, $name, $arguments, $token->getLine(), $tag);
|
484 |
|
485 |
+
if (!$this->parser->getStream()->test(Twig_Token::PUNCTUATION_TYPE, '|')) {
|
486 |
break;
|
487 |
}
|
488 |
|
498 |
* @param bool $namedArguments Whether to allow named arguments or not
|
499 |
* @param bool $definition Whether we are parsing arguments for a function definition
|
500 |
*
|
501 |
+
* @return Twig_Node
|
502 |
*
|
503 |
+
* @throws Twig_Error_Syntax
|
504 |
*/
|
505 |
public function parseArguments($namedArguments = false, $definition = false)
|
506 |
{
|
507 |
+
$args = array();
|
508 |
$stream = $this->parser->getStream();
|
509 |
|
510 |
+
$stream->expect(Twig_Token::PUNCTUATION_TYPE, '(', 'A list of arguments must begin with an opening parenthesis');
|
511 |
+
while (!$stream->test(Twig_Token::PUNCTUATION_TYPE, ')')) {
|
512 |
if (!empty($args)) {
|
513 |
+
$stream->expect(Twig_Token::PUNCTUATION_TYPE, ',', 'Arguments must be separated by a comma');
|
514 |
}
|
515 |
|
516 |
if ($definition) {
|
517 |
+
$token = $stream->expect(Twig_Token::NAME_TYPE, null, 'An argument must be a name');
|
518 |
+
$value = new Twig_Node_Expression_Name($token->getValue(), $this->parser->getCurrentToken()->getLine());
|
519 |
} else {
|
520 |
$value = $this->parseExpression();
|
521 |
}
|
522 |
|
523 |
$name = null;
|
524 |
+
if ($namedArguments && $token = $stream->nextIf(Twig_Token::OPERATOR_TYPE, '=')) {
|
525 |
+
if (!$value instanceof Twig_Node_Expression_Name) {
|
526 |
+
throw new Twig_Error_Syntax(sprintf('A parameter name must be a string, "%s" given.', get_class($value)), $token->getLine(), $stream->getSourceContext());
|
527 |
}
|
528 |
$name = $value->getAttribute('name');
|
529 |
|
531 |
$value = $this->parsePrimaryExpression();
|
532 |
|
533 |
if (!$this->checkConstantExpression($value)) {
|
534 |
+
throw new Twig_Error_Syntax(sprintf('A default value for an argument must be a constant (a boolean, a string, a number, or an array).'), $token->getLine(), $stream->getSourceContext());
|
535 |
}
|
536 |
} else {
|
537 |
$value = $this->parseExpression();
|
541 |
if ($definition) {
|
542 |
if (null === $name) {
|
543 |
$name = $value->getAttribute('name');
|
544 |
+
$value = new Twig_Node_Expression_Constant(null, $this->parser->getCurrentToken()->getLine());
|
545 |
}
|
546 |
$args[$name] = $value;
|
547 |
} else {
|
552 |
}
|
553 |
}
|
554 |
}
|
555 |
+
$stream->expect(Twig_Token::PUNCTUATION_TYPE, ')', 'A list of arguments must be closed by a parenthesis');
|
556 |
|
557 |
+
return new Twig_Node($args);
|
558 |
}
|
559 |
|
560 |
public function parseAssignmentExpression()
|
561 |
{
|
562 |
$stream = $this->parser->getStream();
|
563 |
+
$targets = array();
|
564 |
while (true) {
|
565 |
+
$token = $stream->expect(Twig_Token::NAME_TYPE, null, 'Only variables can be assigned to');
|
566 |
$value = $token->getValue();
|
567 |
+
if (in_array(strtolower($value), array('true', 'false', 'none', 'null'))) {
|
568 |
+
throw new Twig_Error_Syntax(sprintf('You cannot assign a value to "%s".', $value), $token->getLine(), $stream->getSourceContext());
|
569 |
}
|
570 |
+
$targets[] = new Twig_Node_Expression_AssignName($value, $token->getLine());
|
571 |
|
572 |
+
if (!$stream->nextIf(Twig_Token::PUNCTUATION_TYPE, ',')) {
|
573 |
break;
|
574 |
}
|
575 |
}
|
576 |
|
577 |
+
return new Twig_Node($targets);
|
578 |
}
|
579 |
|
580 |
public function parseMultitargetExpression()
|
581 |
{
|
582 |
+
$targets = array();
|
583 |
while (true) {
|
584 |
$targets[] = $this->parseExpression();
|
585 |
+
if (!$this->parser->getStream()->nextIf(Twig_Token::PUNCTUATION_TYPE, ',')) {
|
586 |
break;
|
587 |
}
|
588 |
}
|
589 |
|
590 |
+
return new Twig_Node($targets);
|
591 |
}
|
592 |
|
593 |
private function parseNotTestExpression(Twig_NodeInterface $node)
|
594 |
{
|
595 |
+
return new Twig_Node_Expression_Unary_Not($this->parseTestExpression($node), $this->parser->getCurrentToken()->getLine());
|
596 |
}
|
597 |
|
598 |
private function parseTestExpression(Twig_NodeInterface $node)
|
602 |
|
603 |
$class = $this->getTestNodeClass($test);
|
604 |
$arguments = null;
|
605 |
+
if ($stream->test(Twig_Token::PUNCTUATION_TYPE, '(')) {
|
606 |
$arguments = $this->parser->getExpressionParser()->parseArguments(true);
|
607 |
}
|
608 |
|
612 |
private function getTest($line)
|
613 |
{
|
614 |
$stream = $this->parser->getStream();
|
615 |
+
$name = $stream->expect(Twig_Token::NAME_TYPE)->getValue();
|
616 |
|
617 |
if ($test = $this->env->getTest($name)) {
|
618 |
+
return array($name, $test);
|
619 |
}
|
620 |
|
621 |
+
if ($stream->test(Twig_Token::NAME_TYPE)) {
|
622 |
// try 2-words tests
|
623 |
$name = $name.' '.$this->parser->getCurrentToken()->getValue();
|
624 |
|
625 |
if ($test = $this->env->getTest($name)) {
|
626 |
$stream->next();
|
627 |
|
628 |
+
return array($name, $test);
|
629 |
}
|
630 |
}
|
631 |
|
632 |
+
$e = new Twig_Error_Syntax(sprintf('Unknown "%s" test.', $name), $line, $stream->getSourceContext());
|
633 |
$e->addSuggestions($name, array_keys($this->env->getTests()));
|
634 |
|
635 |
throw $e;
|
637 |
|
638 |
private function getTestNodeClass($test)
|
639 |
{
|
640 |
+
if ($test instanceof Twig_SimpleTest && $test->isDeprecated()) {
|
641 |
$stream = $this->parser->getStream();
|
642 |
$message = sprintf('Twig Test "%s" is deprecated', $test->getName());
|
643 |
+
if (!is_bool($test->getDeprecatedVersion())) {
|
644 |
$message .= sprintf(' since version %s', $test->getDeprecatedVersion());
|
645 |
}
|
646 |
if ($test->getAlternative()) {
|
652 |
@trigger_error($message, E_USER_DEPRECATED);
|
653 |
}
|
654 |
|
655 |
+
if ($test instanceof Twig_SimpleTest) {
|
656 |
return $test->getNodeClass();
|
657 |
}
|
658 |
|
662 |
protected function getFunctionNodeClass($name, $line)
|
663 |
{
|
664 |
if (false === $function = $this->env->getFunction($name)) {
|
665 |
+
$e = new Twig_Error_Syntax(sprintf('Unknown "%s" function.', $name), $line, $this->parser->getStream()->getSourceContext());
|
666 |
$e->addSuggestions($name, array_keys($this->env->getFunctions()));
|
667 |
|
668 |
throw $e;
|
669 |
}
|
670 |
|
671 |
+
if ($function instanceof Twig_SimpleFunction && $function->isDeprecated()) {
|
672 |
$message = sprintf('Twig Function "%s" is deprecated', $function->getName());
|
673 |
+
if (!is_bool($function->getDeprecatedVersion())) {
|
674 |
$message .= sprintf(' since version %s', $function->getDeprecatedVersion());
|
675 |
}
|
676 |
if ($function->getAlternative()) {
|
682 |
@trigger_error($message, E_USER_DEPRECATED);
|
683 |
}
|
684 |
|
685 |
+
if ($function instanceof Twig_SimpleFunction) {
|
686 |
return $function->getNodeClass();
|
687 |
}
|
688 |
|
692 |
protected function getFilterNodeClass($name, $line)
|
693 |
{
|
694 |
if (false === $filter = $this->env->getFilter($name)) {
|
695 |
+
$e = new Twig_Error_Syntax(sprintf('Unknown "%s" filter.', $name), $line, $this->parser->getStream()->getSourceContext());
|
696 |
$e->addSuggestions($name, array_keys($this->env->getFilters()));
|
697 |
|
698 |
throw $e;
|
699 |
}
|
700 |
|
701 |
+
if ($filter instanceof Twig_SimpleFilter && $filter->isDeprecated()) {
|
702 |
$message = sprintf('Twig Filter "%s" is deprecated', $filter->getName());
|
703 |
+
if (!is_bool($filter->getDeprecatedVersion())) {
|
704 |
$message .= sprintf(' since version %s', $filter->getDeprecatedVersion());
|
705 |
}
|
706 |
if ($filter->getAlternative()) {
|
712 |
@trigger_error($message, E_USER_DEPRECATED);
|
713 |
}
|
714 |
|
715 |
+
if ($filter instanceof Twig_SimpleFilter) {
|
716 |
return $filter->getNodeClass();
|
717 |
}
|
718 |
|
722 |
// checks that the node only contains "constant" elements
|
723 |
protected function checkConstantExpression(Twig_NodeInterface $node)
|
724 |
{
|
725 |
+
if (!($node instanceof Twig_Node_Expression_Constant || $node instanceof Twig_Node_Expression_Array
|
726 |
+
|| $node instanceof Twig_Node_Expression_Unary_Neg || $node instanceof Twig_Node_Expression_Unary_Pos
|
727 |
)) {
|
728 |
return false;
|
729 |
}
|
737 |
return true;
|
738 |
}
|
739 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Extension.php
CHANGED
@@ -8,47 +8,43 @@
|
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
-
|
12 |
-
use Twig\Environment;
|
13 |
-
use Twig\Extension\ExtensionInterface;
|
14 |
-
|
15 |
-
abstract class Twig_Extension implements ExtensionInterface
|
16 |
{
|
17 |
/**
|
18 |
* @deprecated since 1.23 (to be removed in 2.0), implement Twig_Extension_InitRuntimeInterface instead
|
19 |
*/
|
20 |
-
public function initRuntime(
|
21 |
{
|
22 |
}
|
23 |
|
24 |
public function getTokenParsers()
|
25 |
{
|
26 |
-
return
|
27 |
}
|
28 |
|
29 |
public function getNodeVisitors()
|
30 |
{
|
31 |
-
return
|
32 |
}
|
33 |
|
34 |
public function getFilters()
|
35 |
{
|
36 |
-
return
|
37 |
}
|
38 |
|
39 |
public function getTests()
|
40 |
{
|
41 |
-
return
|
42 |
}
|
43 |
|
44 |
public function getFunctions()
|
45 |
{
|
46 |
-
return
|
47 |
}
|
48 |
|
49 |
public function getOperators()
|
50 |
{
|
51 |
-
return
|
52 |
}
|
53 |
|
54 |
/**
|
@@ -56,7 +52,7 @@ abstract class Twig_Extension implements ExtensionInterface
|
|
56 |
*/
|
57 |
public function getGlobals()
|
58 |
{
|
59 |
-
return
|
60 |
}
|
61 |
|
62 |
/**
|
@@ -64,9 +60,6 @@ abstract class Twig_Extension implements ExtensionInterface
|
|
64 |
*/
|
65 |
public function getName()
|
66 |
{
|
67 |
-
return
|
68 |
}
|
69 |
}
|
70 |
-
|
71 |
-
class_alias('Twig_Extension', 'Twig\Extension\AbstractExtension', false);
|
72 |
-
class_exists('Twig_Environment');
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
+
abstract class Twig_Extension implements Twig_ExtensionInterface
|
|
|
|
|
|
|
|
|
12 |
{
|
13 |
/**
|
14 |
* @deprecated since 1.23 (to be removed in 2.0), implement Twig_Extension_InitRuntimeInterface instead
|
15 |
*/
|
16 |
+
public function initRuntime(Twig_Environment $environment)
|
17 |
{
|
18 |
}
|
19 |
|
20 |
public function getTokenParsers()
|
21 |
{
|
22 |
+
return array();
|
23 |
}
|
24 |
|
25 |
public function getNodeVisitors()
|
26 |
{
|
27 |
+
return array();
|
28 |
}
|
29 |
|
30 |
public function getFilters()
|
31 |
{
|
32 |
+
return array();
|
33 |
}
|
34 |
|
35 |
public function getTests()
|
36 |
{
|
37 |
+
return array();
|
38 |
}
|
39 |
|
40 |
public function getFunctions()
|
41 |
{
|
42 |
+
return array();
|
43 |
}
|
44 |
|
45 |
public function getOperators()
|
46 |
{
|
47 |
+
return array();
|
48 |
}
|
49 |
|
50 |
/**
|
52 |
*/
|
53 |
public function getGlobals()
|
54 |
{
|
55 |
+
return array();
|
56 |
}
|
57 |
|
58 |
/**
|
60 |
*/
|
61 |
public function getName()
|
62 |
{
|
63 |
+
return get_class($this);
|
64 |
}
|
65 |
}
|
|
|
|
|
|
vendor/twig/twig/lib/Twig/Extension/Core.php
CHANGED
@@ -1,7 +1,8 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
if (
|
4 |
-
|
|
|
5 |
}
|
6 |
|
7 |
/*
|
@@ -13,44 +14,15 @@ if (!\defined('ENT_SUBSTITUTE')) {
|
|
13 |
* file that was distributed with this source code.
|
14 |
*/
|
15 |
|
16 |
-
use Twig\Environment;
|
17 |
-
use Twig\Error\LoaderError;
|
18 |
-
use Twig\Error\RuntimeError;
|
19 |
-
use Twig\ExpressionParser;
|
20 |
-
use Twig\Extension\AbstractExtension;
|
21 |
-
use Twig\Loader\SourceContextLoaderInterface;
|
22 |
-
use Twig\Markup;
|
23 |
-
use Twig\Node\Expression\ConstantExpression;
|
24 |
-
use Twig\TokenParser\BlockTokenParser;
|
25 |
-
use Twig\TokenParser\DeprecatedTokenParser;
|
26 |
-
use Twig\TokenParser\DoTokenParser;
|
27 |
-
use Twig\TokenParser\EmbedTokenParser;
|
28 |
-
use Twig\TokenParser\ExtendsTokenParser;
|
29 |
-
use Twig\TokenParser\FilterTokenParser;
|
30 |
-
use Twig\TokenParser\FlushTokenParser;
|
31 |
-
use Twig\TokenParser\ForTokenParser;
|
32 |
-
use Twig\TokenParser\FromTokenParser;
|
33 |
-
use Twig\TokenParser\IfTokenParser;
|
34 |
-
use Twig\TokenParser\ImportTokenParser;
|
35 |
-
use Twig\TokenParser\IncludeTokenParser;
|
36 |
-
use Twig\TokenParser\MacroTokenParser;
|
37 |
-
use Twig\TokenParser\SetTokenParser;
|
38 |
-
use Twig\TokenParser\SpacelessTokenParser;
|
39 |
-
use Twig\TokenParser\UseTokenParser;
|
40 |
-
use Twig\TokenParser\WithTokenParser;
|
41 |
-
use Twig\TwigFilter;
|
42 |
-
use Twig\TwigFunction;
|
43 |
-
use Twig\TwigTest;
|
44 |
-
|
45 |
/**
|
46 |
* @final
|
47 |
*/
|
48 |
-
class Twig_Extension_Core extends
|
49 |
{
|
50 |
-
protected $dateFormats =
|
51 |
-
protected $numberFormat =
|
52 |
protected $timezone = null;
|
53 |
-
protected $escapers =
|
54 |
|
55 |
/**
|
56 |
* Defines a new escaper to be used via the escape filter.
|
@@ -103,22 +75,22 @@ class Twig_Extension_Core extends AbstractExtension
|
|
103 |
/**
|
104 |
* Sets the default timezone to be used by the date filter.
|
105 |
*
|
106 |
-
* @param
|
107 |
*/
|
108 |
public function setTimezone($timezone)
|
109 |
{
|
110 |
-
$this->timezone = $timezone instanceof
|
111 |
}
|
112 |
|
113 |
/**
|
114 |
* Gets the default timezone to be used by the date filter.
|
115 |
*
|
116 |
-
* @return
|
117 |
*/
|
118 |
public function getTimezone()
|
119 |
{
|
120 |
if (null === $this->timezone) {
|
121 |
-
$this->timezone = new
|
122 |
}
|
123 |
|
124 |
return $this->timezone;
|
@@ -133,7 +105,7 @@ class Twig_Extension_Core extends AbstractExtension
|
|
133 |
*/
|
134 |
public function setNumberFormat($decimal, $decimalPoint, $thousandSep)
|
135 |
{
|
136 |
-
$this->numberFormat =
|
137 |
}
|
138 |
|
139 |
/**
|
@@ -148,79 +120,78 @@ class Twig_Extension_Core extends AbstractExtension
|
|
148 |
|
149 |
public function getTokenParsers()
|
150 |
{
|
151 |
-
return
|
152 |
-
new
|
153 |
-
new
|
154 |
-
new
|
155 |
-
new
|
156 |
-
new
|
157 |
-
new
|
158 |
-
new
|
159 |
-
new
|
160 |
-
new
|
161 |
-
new
|
162 |
-
new
|
163 |
-
new
|
164 |
-
new
|
165 |
-
new
|
166 |
-
new
|
167 |
-
new
|
168 |
-
|
169 |
-
];
|
170 |
}
|
171 |
|
172 |
public function getFilters()
|
173 |
{
|
174 |
-
$filters =
|
175 |
// formatting filters
|
176 |
-
new
|
177 |
-
new
|
178 |
-
new
|
179 |
-
new
|
180 |
-
new
|
181 |
-
new
|
182 |
-
new
|
183 |
|
184 |
// encoding
|
185 |
-
new
|
186 |
-
new
|
187 |
-
new
|
188 |
|
189 |
// string filters
|
190 |
-
new
|
191 |
-
new
|
192 |
-
new
|
193 |
-
new
|
194 |
-
new
|
195 |
-
new
|
196 |
-
new
|
197 |
|
198 |
// array helpers
|
199 |
-
new
|
200 |
-
new
|
201 |
-
new
|
202 |
-
new
|
203 |
-
new
|
204 |
|
205 |
// string/array filters
|
206 |
-
new
|
207 |
-
new
|
208 |
-
new
|
209 |
-
new
|
210 |
-
new
|
211 |
|
212 |
// iteration and runtime
|
213 |
-
new
|
214 |
-
new
|
215 |
|
216 |
// escaping
|
217 |
-
new
|
218 |
-
new
|
219 |
-
|
220 |
|
221 |
-
if (
|
222 |
-
$filters[] = new
|
223 |
-
$filters[] = new
|
224 |
}
|
225 |
|
226 |
return $filters;
|
@@ -228,76 +199,76 @@ class Twig_Extension_Core extends AbstractExtension
|
|
228 |
|
229 |
public function getFunctions()
|
230 |
{
|
231 |
-
return
|
232 |
-
new
|
233 |
-
new
|
234 |
-
new
|
235 |
-
new
|
236 |
-
new
|
237 |
-
new
|
238 |
-
new
|
239 |
-
new
|
240 |
-
new
|
241 |
-
|
242 |
}
|
243 |
|
244 |
public function getTests()
|
245 |
{
|
246 |
-
return
|
247 |
-
new
|
248 |
-
new
|
249 |
-
new
|
250 |
-
new
|
251 |
-
new
|
252 |
-
new
|
253 |
-
new
|
254 |
-
new
|
255 |
-
new
|
256 |
-
new
|
257 |
-
new
|
258 |
-
new
|
259 |
-
|
260 |
}
|
261 |
|
262 |
public function getOperators()
|
263 |
{
|
264 |
-
return
|
265 |
-
|
266 |
-
'not' =>
|
267 |
-
'-' =>
|
268 |
-
'+' =>
|
269 |
-
|
270 |
-
|
271 |
-
'or' =>
|
272 |
-
'and' =>
|
273 |
-
'b-or' =>
|
274 |
-
'b-xor' =>
|
275 |
-
'b-and' =>
|
276 |
-
'==' =>
|
277 |
-
'!=' =>
|
278 |
-
'<' =>
|
279 |
-
'>' =>
|
280 |
-
'>=' =>
|
281 |
-
'<=' =>
|
282 |
-
'not in' =>
|
283 |
-
'in' =>
|
284 |
-
'matches' =>
|
285 |
-
'starts with' =>
|
286 |
-
'ends with' =>
|
287 |
-
'..' =>
|
288 |
-
'+' =>
|
289 |
-
'-' =>
|
290 |
-
'~' =>
|
291 |
-
'*' =>
|
292 |
-
'/' =>
|
293 |
-
'//' =>
|
294 |
-
'%' =>
|
295 |
-
'is' =>
|
296 |
-
'is not' =>
|
297 |
-
'**' =>
|
298 |
-
'??' =>
|
299 |
-
|
300 |
-
|
301 |
}
|
302 |
|
303 |
public function getName()
|
@@ -316,22 +287,23 @@ class Twig_Extension_Core extends AbstractExtension
|
|
316 |
*/
|
317 |
function twig_cycle($values, $position)
|
318 |
{
|
319 |
-
if (
|
320 |
return $values;
|
321 |
}
|
322 |
|
323 |
-
return $values[$position %
|
324 |
}
|
325 |
|
326 |
/**
|
327 |
* Returns a random value depending on the supplied parameter type:
|
328 |
-
* - a random item from a
|
329 |
* - a random character from a string
|
330 |
* - a random integer between 0 and the integer parameter.
|
331 |
*
|
332 |
-
* @param
|
|
|
333 |
*
|
334 |
-
* @throws
|
335 |
*
|
336 |
* @return mixed A random value from the given sequence
|
337 |
*/
|
@@ -341,13 +313,13 @@ function twig_random(Twig_Environment $env, $values = null)
|
|
341 |
return mt_rand();
|
342 |
}
|
343 |
|
344 |
-
if (
|
345 |
return $values < 0 ? mt_rand($values, 0) : mt_rand(0, $values);
|
346 |
}
|
347 |
|
348 |
-
if ($values instanceof
|
349 |
$values = iterator_to_array($values);
|
350 |
-
} elseif (
|
351 |
if ('' === $values) {
|
352 |
return '';
|
353 |
}
|
@@ -366,16 +338,16 @@ function twig_random(Twig_Environment $env, $values = null)
|
|
366 |
}
|
367 |
}
|
368 |
} else {
|
369 |
-
return $values[mt_rand(0,
|
370 |
}
|
371 |
}
|
372 |
|
373 |
-
if (
|
374 |
return $values;
|
375 |
}
|
376 |
|
377 |
-
if (0 ===
|
378 |
-
throw new
|
379 |
}
|
380 |
|
381 |
return $values[array_rand($values, 1)];
|
@@ -384,22 +356,25 @@ function twig_random(Twig_Environment $env, $values = null)
|
|
384 |
/**
|
385 |
* Converts a date to the given format.
|
386 |
*
|
|
|
387 |
* {{ post.published_at|date("m/d/Y") }}
|
|
|
388 |
*
|
389 |
-
* @param
|
390 |
-
* @param string
|
391 |
-
* @param
|
|
|
392 |
*
|
393 |
* @return string The formatted date
|
394 |
*/
|
395 |
function twig_date_format_filter(Twig_Environment $env, $date, $format = null, $timezone = null)
|
396 |
{
|
397 |
if (null === $format) {
|
398 |
-
$formats = $env->getExtension('
|
399 |
-
$format = $date instanceof
|
400 |
}
|
401 |
|
402 |
-
if ($date instanceof
|
403 |
return $date->format($format);
|
404 |
}
|
405 |
|
@@ -409,53 +384,59 @@ function twig_date_format_filter(Twig_Environment $env, $date, $format = null, $
|
|
409 |
/**
|
410 |
* Returns a new date object modified.
|
411 |
*
|
|
|
412 |
* {{ post.published_at|date_modify("-1day")|date("m/d/Y") }}
|
|
|
413 |
*
|
414 |
-
* @param
|
|
|
415 |
* @param string $modifier A modifier string
|
416 |
*
|
417 |
-
* @return
|
418 |
*/
|
419 |
function twig_date_modify_filter(Twig_Environment $env, $date, $modifier)
|
420 |
{
|
421 |
$date = twig_date_converter($env, $date, false);
|
422 |
$resultDate = $date->modify($modifier);
|
423 |
|
424 |
-
// This is a hack to ensure PHP 5.2 support and support for
|
425 |
-
//
|
426 |
-
// and
|
427 |
return null === $resultDate ? $date : $resultDate;
|
428 |
}
|
429 |
|
430 |
/**
|
431 |
-
* Converts an input to a
|
432 |
*
|
|
|
433 |
* {% if date(user.created_at) < date('+2days') %}
|
434 |
* {# do something #}
|
435 |
* {% endif %}
|
|
|
436 |
*
|
437 |
-
* @param
|
438 |
-
* @param
|
|
|
439 |
*
|
440 |
-
* @return
|
441 |
*/
|
442 |
function twig_date_converter(Twig_Environment $env, $date = null, $timezone = null)
|
443 |
{
|
444 |
// determine the timezone
|
445 |
if (false !== $timezone) {
|
446 |
if (null === $timezone) {
|
447 |
-
$timezone = $env->getExtension('
|
448 |
-
} elseif (!$timezone instanceof
|
449 |
-
$timezone = new
|
450 |
}
|
451 |
}
|
452 |
|
453 |
// immutable dates
|
454 |
-
if ($date instanceof
|
455 |
return false !== $timezone ? $date->setTimezone($timezone) : $date;
|
456 |
}
|
457 |
|
458 |
-
if ($date instanceof
|
459 |
$date = clone $date;
|
460 |
if (false !== $timezone) {
|
461 |
$date->setTimezone($timezone);
|
@@ -465,14 +446,14 @@ function twig_date_converter(Twig_Environment $env, $date = null, $timezone = nu
|
|
465 |
}
|
466 |
|
467 |
if (null === $date || 'now' === $date) {
|
468 |
-
return new
|
469 |
}
|
470 |
|
471 |
$asString = (string) $date;
|
472 |
if (ctype_digit($asString) || (!empty($asString) && '-' === $asString[0] && ctype_digit(substr($asString, 1)))) {
|
473 |
-
$date = new
|
474 |
} else {
|
475 |
-
$date = new
|
476 |
}
|
477 |
|
478 |
if (false !== $timezone) {
|
@@ -485,22 +466,22 @@ function twig_date_converter(Twig_Environment $env, $date = null, $timezone = nu
|
|
485 |
/**
|
486 |
* Replaces strings within a string.
|
487 |
*
|
488 |
-
* @param string
|
489 |
-
* @param array
|
490 |
-
* @param string|null
|
491 |
*
|
492 |
* @return string
|
493 |
*/
|
494 |
function twig_replace_filter($str, $from, $to = null)
|
495 |
{
|
496 |
-
if ($from instanceof
|
497 |
$from = iterator_to_array($from);
|
498 |
-
} elseif (
|
499 |
@trigger_error('Using "replace" with character by character replacement is deprecated since version 1.22 and will be removed in Twig 2.0', E_USER_DEPRECATED);
|
500 |
|
501 |
return strtr($str, $from, $to);
|
502 |
-
} elseif (
|
503 |
-
throw new
|
504 |
}
|
505 |
|
506 |
return strtr($str, $from);
|
@@ -522,7 +503,7 @@ function twig_round($value, $precision = 0, $method = 'common')
|
|
522 |
}
|
523 |
|
524 |
if ('ceil' != $method && 'floor' != $method) {
|
525 |
-
throw new
|
526 |
}
|
527 |
|
528 |
return $method($value * pow(10, $precision)) / pow(10, $precision);
|
@@ -535,16 +516,17 @@ function twig_round($value, $precision = 0, $method = 'common')
|
|
535 |
* be used. Supplying any of the parameters will override the defaults set in the
|
536 |
* environment object.
|
537 |
*
|
538 |
-
* @param
|
539 |
-
* @param
|
540 |
-
* @param
|
541 |
-
* @param string
|
|
|
542 |
*
|
543 |
* @return string The formatted number
|
544 |
*/
|
545 |
function twig_number_format_filter(Twig_Environment $env, $number, $decimal = null, $decimalPoint = null, $thousandSep = null)
|
546 |
{
|
547 |
-
$defaults = $env->getExtension('
|
548 |
if (null === $decimal) {
|
549 |
$decimal = $defaults[0];
|
550 |
}
|
@@ -569,8 +551,8 @@ function twig_number_format_filter(Twig_Environment $env, $number, $decimal = nu
|
|
569 |
*/
|
570 |
function twig_urlencode_filter($url)
|
571 |
{
|
572 |
-
if (
|
573 |
-
if (
|
574 |
return http_build_query($url, '', '&', PHP_QUERY_RFC3986);
|
575 |
}
|
576 |
|
@@ -580,28 +562,49 @@ function twig_urlencode_filter($url)
|
|
580 |
return rawurlencode($url);
|
581 |
}
|
582 |
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
$value
|
595 |
-
|
596 |
-
|
|
|
|
|
|
|
|
|
597 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
598 |
|
599 |
-
|
|
|
600 |
}
|
601 |
|
602 |
function _twig_markup2string(&$value)
|
603 |
{
|
604 |
-
if ($value instanceof
|
605 |
$value = (string) $value;
|
606 |
}
|
607 |
}
|
@@ -609,29 +612,31 @@ function _twig_markup2string(&$value)
|
|
609 |
/**
|
610 |
* Merges an array with another one.
|
611 |
*
|
|
|
612 |
* {% set items = { 'apple': 'fruit', 'orange': 'fruit' } %}
|
613 |
*
|
614 |
* {% set items = items|merge({ 'peugeot': 'car' }) %}
|
615 |
*
|
616 |
* {# items now contains { 'apple': 'fruit', 'orange': 'fruit', 'peugeot': 'car' } #}
|
|
|
617 |
*
|
618 |
-
* @param array
|
619 |
-
* @param array
|
620 |
*
|
621 |
* @return array The merged array
|
622 |
*/
|
623 |
function twig_array_merge($arr1, $arr2)
|
624 |
{
|
625 |
-
if ($arr1 instanceof
|
626 |
$arr1 = iterator_to_array($arr1);
|
627 |
-
} elseif (
|
628 |
-
throw new
|
629 |
}
|
630 |
|
631 |
-
if ($arr2 instanceof
|
632 |
$arr2 = iterator_to_array($arr2);
|
633 |
-
} elseif (
|
634 |
-
throw new
|
635 |
}
|
636 |
|
637 |
return array_merge($arr1, $arr2);
|
@@ -640,38 +645,39 @@ function twig_array_merge($arr1, $arr2)
|
|
640 |
/**
|
641 |
* Slices a variable.
|
642 |
*
|
643 |
-
* @param
|
644 |
-
* @param
|
645 |
-
* @param int
|
646 |
-
* @param
|
|
|
647 |
*
|
648 |
* @return mixed The sliced variable
|
649 |
*/
|
650 |
function twig_slice(Twig_Environment $env, $item, $start, $length = null, $preserveKeys = false)
|
651 |
{
|
652 |
-
if ($item instanceof
|
653 |
-
while ($item instanceof
|
654 |
$item = $item->getIterator();
|
655 |
}
|
656 |
|
657 |
-
if ($start >= 0 && $length >= 0 && $item instanceof
|
658 |
try {
|
659 |
-
return iterator_to_array(new
|
660 |
-
} catch (
|
661 |
-
return
|
662 |
}
|
663 |
}
|
664 |
|
665 |
$item = iterator_to_array($item, $preserveKeys);
|
666 |
}
|
667 |
|
668 |
-
if (
|
669 |
-
return
|
670 |
}
|
671 |
|
672 |
$item = (string) $item;
|
673 |
|
674 |
-
if (
|
675 |
return (string) mb_substr($item, $start, null === $length ? mb_strlen($item, $charset) - $start : $length, $charset);
|
676 |
}
|
677 |
|
@@ -681,7 +687,8 @@ function twig_slice(Twig_Environment $env, $item, $start, $length = null, $prese
|
|
681 |
/**
|
682 |
* Returns the first element of the item.
|
683 |
*
|
684 |
-
* @param
|
|
|
685 |
*
|
686 |
* @return mixed The first element of the item
|
687 |
*/
|
@@ -689,13 +696,14 @@ function twig_first(Twig_Environment $env, $item)
|
|
689 |
{
|
690 |
$elements = twig_slice($env, $item, 0, 1, false);
|
691 |
|
692 |
-
return
|
693 |
}
|
694 |
|
695 |
/**
|
696 |
* Returns the last element of the item.
|
697 |
*
|
698 |
-
* @param
|
|
|
699 |
*
|
700 |
* @return mixed The last element of the item
|
701 |
*/
|
@@ -703,56 +711,40 @@ function twig_last(Twig_Environment $env, $item)
|
|
703 |
{
|
704 |
$elements = twig_slice($env, $item, -1, 1, false);
|
705 |
|
706 |
-
return
|
707 |
}
|
708 |
|
709 |
/**
|
710 |
* Joins the values to a string.
|
711 |
*
|
712 |
-
* The
|
713 |
-
*
|
714 |
-
* {{ [1, 2, 3]|join(', ', ' and ') }}
|
715 |
-
* {# returns 1, 2 and 3 #}
|
716 |
*
|
|
|
717 |
* {{ [1, 2, 3]|join('|') }}
|
718 |
* {# returns 1|2|3 #}
|
719 |
*
|
720 |
* {{ [1, 2, 3]|join }}
|
721 |
* {# returns 123 #}
|
|
|
722 |
*
|
723 |
-
* @param array
|
724 |
-
* @param string
|
725 |
-
* @param string|null $and The separator for the last pair
|
726 |
*
|
727 |
* @return string The concatenated string
|
728 |
*/
|
729 |
-
function twig_join_filter($value, $glue = ''
|
730 |
{
|
731 |
-
if ($value instanceof
|
732 |
$value = iterator_to_array($value, false);
|
733 |
-
} else {
|
734 |
-
$value = (array) $value;
|
735 |
-
}
|
736 |
-
|
737 |
-
if (0 === \count($value)) {
|
738 |
-
return '';
|
739 |
}
|
740 |
|
741 |
-
|
742 |
-
return implode($glue, $value);
|
743 |
-
}
|
744 |
-
|
745 |
-
$v = array_values($value);
|
746 |
-
if (1 === \count($v)) {
|
747 |
-
return $v[0];
|
748 |
-
}
|
749 |
-
|
750 |
-
return implode($glue, \array_slice($value, 0, -1)).$and.$v[\count($v) - 1];
|
751 |
}
|
752 |
|
753 |
/**
|
754 |
* Splits the string into an array.
|
755 |
*
|
|
|
756 |
* {{ "one,two,three"|split(',') }}
|
757 |
* {# returns [one, two, three] #}
|
758 |
*
|
@@ -764,10 +756,12 @@ function twig_join_filter($value, $glue = '', $and = null)
|
|
764 |
*
|
765 |
* {{ "aabbcc"|split('', 2) }}
|
766 |
* {# returns [aa, bb, cc] #}
|
|
|
767 |
*
|
768 |
-
* @param
|
769 |
-
* @param string
|
770 |
-
* @param
|
|
|
771 |
*
|
772 |
* @return array The split string as an array
|
773 |
*/
|
@@ -777,7 +771,7 @@ function twig_split_filter(Twig_Environment $env, $value, $delimiter, $limit = n
|
|
777 |
return null === $limit ? explode($delimiter, $value) : explode($delimiter, $value, $limit);
|
778 |
}
|
779 |
|
780 |
-
if (
|
781 |
return str_split($value, null === $limit ? 1 : $limit);
|
782 |
}
|
783 |
|
@@ -787,10 +781,10 @@ function twig_split_filter(Twig_Environment $env, $value, $delimiter, $limit = n
|
|
787 |
|
788 |
$length = mb_strlen($value, $charset);
|
789 |
if ($length < $limit) {
|
790 |
-
return
|
791 |
}
|
792 |
|
793 |
-
$r =
|
794 |
for ($i = 0; $i < $length; $i += $limit) {
|
795 |
$r[] = mb_substr($value, $i, $limit, $charset);
|
796 |
}
|
@@ -818,9 +812,11 @@ function _twig_default_filter($value, $default = '')
|
|
818 |
*
|
819 |
* It is useful when you want to iterate over the keys of an array:
|
820 |
*
|
|
|
821 |
* {% for key in array|keys %}
|
822 |
* {# ... #}
|
823 |
* {% endfor %}
|
|
|
824 |
*
|
825 |
* @param array $array An array
|
826 |
*
|
@@ -828,13 +824,13 @@ function _twig_default_filter($value, $default = '')
|
|
828 |
*/
|
829 |
function twig_get_array_keys_filter($array)
|
830 |
{
|
831 |
-
if ($array instanceof
|
832 |
-
while ($array instanceof
|
833 |
$array = $array->getIterator();
|
834 |
}
|
835 |
|
836 |
-
if ($array instanceof
|
837 |
-
$keys =
|
838 |
$array->rewind();
|
839 |
while ($array->valid()) {
|
840 |
$keys[] = $array->key();
|
@@ -844,7 +840,7 @@ function twig_get_array_keys_filter($array)
|
|
844 |
return $keys;
|
845 |
}
|
846 |
|
847 |
-
$keys =
|
848 |
foreach ($array as $key => $item) {
|
849 |
$keys[] = $key;
|
850 |
}
|
@@ -852,8 +848,8 @@ function twig_get_array_keys_filter($array)
|
|
852 |
return $keys;
|
853 |
}
|
854 |
|
855 |
-
if (
|
856 |
-
return
|
857 |
}
|
858 |
|
859 |
return array_keys($array);
|
@@ -862,18 +858,19 @@ function twig_get_array_keys_filter($array)
|
|
862 |
/**
|
863 |
* Reverses a variable.
|
864 |
*
|
865 |
-
* @param
|
866 |
-
* @param
|
|
|
867 |
*
|
868 |
* @return mixed The reversed input
|
869 |
*/
|
870 |
function twig_reverse_filter(Twig_Environment $env, $item, $preserveKeys = false)
|
871 |
{
|
872 |
-
if ($item instanceof
|
873 |
return array_reverse(iterator_to_array($item), $preserveKeys);
|
874 |
}
|
875 |
|
876 |
-
if (
|
877 |
return array_reverse($item, $preserveKeys);
|
878 |
}
|
879 |
|
@@ -901,16 +898,16 @@ function twig_reverse_filter(Twig_Environment $env, $item, $preserveKeys = false
|
|
901 |
/**
|
902 |
* Sorts an array.
|
903 |
*
|
904 |
-
* @param array
|
905 |
*
|
906 |
* @return array
|
907 |
*/
|
908 |
function twig_sort_filter($array)
|
909 |
{
|
910 |
-
if ($array instanceof
|
911 |
$array = iterator_to_array($array);
|
912 |
-
} elseif (
|
913 |
-
throw new
|
914 |
}
|
915 |
|
916 |
asort($array);
|
@@ -923,12 +920,12 @@ function twig_sort_filter($array)
|
|
923 |
*/
|
924 |
function twig_in_filter($value, $compare)
|
925 |
{
|
926 |
-
if (
|
927 |
-
return
|
928 |
-
} elseif (
|
929 |
return '' === $value || false !== strpos($compare, (string) $value);
|
930 |
-
} elseif ($compare instanceof
|
931 |
-
if (
|
932 |
foreach ($compare as $item) {
|
933 |
if ($item === $value) {
|
934 |
return true;
|
@@ -953,7 +950,7 @@ function twig_in_filter($value, $compare)
|
|
953 |
*
|
954 |
* @return string
|
955 |
*
|
956 |
-
* @throws
|
957 |
*/
|
958 |
function twig_trim_filter($string, $characterMask = null, $side = 'both')
|
959 |
{
|
@@ -969,65 +966,70 @@ function twig_trim_filter($string, $characterMask = null, $side = 'both')
|
|
969 |
case 'right':
|
970 |
return rtrim($string, $characterMask);
|
971 |
default:
|
972 |
-
throw new
|
973 |
}
|
974 |
}
|
975 |
|
976 |
/**
|
977 |
* Escapes a string.
|
978 |
*
|
979 |
-
* @param
|
980 |
-
* @param string
|
981 |
-
* @param string
|
982 |
-
* @param
|
|
|
983 |
*
|
984 |
* @return string
|
985 |
*/
|
986 |
function twig_escape_filter(Twig_Environment $env, $string, $strategy = 'html', $charset = null, $autoescape = false)
|
987 |
{
|
988 |
-
if ($autoescape && $string instanceof
|
989 |
return $string;
|
990 |
}
|
991 |
|
992 |
-
if (
|
993 |
-
if (
|
994 |
$string = (string) $string;
|
995 |
-
} elseif (
|
996 |
return $string;
|
997 |
}
|
998 |
}
|
999 |
|
1000 |
-
if ('' === $string) {
|
1001 |
-
return '';
|
1002 |
-
}
|
1003 |
-
|
1004 |
if (null === $charset) {
|
1005 |
$charset = $env->getCharset();
|
1006 |
}
|
1007 |
|
1008 |
switch ($strategy) {
|
1009 |
case 'html':
|
1010 |
-
// see
|
1011 |
|
1012 |
// Using a static variable to avoid initializing the array
|
1013 |
// each time the function is called. Moving the declaration on the
|
1014 |
// top of the function slow downs other escaping strategies.
|
1015 |
-
static $htmlspecialcharsCharsets
|
1016 |
-
|
1017 |
-
|
1018 |
-
|
1019 |
-
|
1020 |
-
|
1021 |
-
|
1022 |
-
|
1023 |
-
|
1024 |
-
|
1025 |
-
|
1026 |
-
|
1027 |
-
|
1028 |
-
|
1029 |
-
|
1030 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1031 |
|
1032 |
if (isset($htmlspecialcharsCharsets[$charset])) {
|
1033 |
return htmlspecialchars($string, ENT_QUOTES | ENT_SUBSTITUTE, $charset);
|
@@ -1047,13 +1049,13 @@ function twig_escape_filter(Twig_Environment $env, $string, $strategy = 'html',
|
|
1047 |
|
1048 |
case 'js':
|
1049 |
// escape all non-alphanumeric characters
|
1050 |
-
// into their \
|
1051 |
if ('UTF-8' !== $charset) {
|
1052 |
$string = twig_convert_encoding($string, 'UTF-8', $charset);
|
1053 |
}
|
1054 |
|
1055 |
-
if (
|
1056 |
-
throw new
|
1057 |
}
|
1058 |
|
1059 |
$string = preg_replace_callback('#[^a-zA-Z0-9,\._]#Su', '_twig_escape_js_callback', $string);
|
@@ -1069,8 +1071,8 @@ function twig_escape_filter(Twig_Environment $env, $string, $strategy = 'html',
|
|
1069 |
$string = twig_convert_encoding($string, 'UTF-8', $charset);
|
1070 |
}
|
1071 |
|
1072 |
-
if (
|
1073 |
-
throw new
|
1074 |
}
|
1075 |
|
1076 |
$string = preg_replace_callback('#[^a-zA-Z0-9]#Su', '_twig_escape_css_callback', $string);
|
@@ -1086,8 +1088,8 @@ function twig_escape_filter(Twig_Environment $env, $string, $strategy = 'html',
|
|
1086 |
$string = twig_convert_encoding($string, 'UTF-8', $charset);
|
1087 |
}
|
1088 |
|
1089 |
-
if (
|
1090 |
-
throw new
|
1091 |
}
|
1092 |
|
1093 |
$string = preg_replace_callback('#[^a-zA-Z0-9,\.\-_]#Su', '_twig_escape_html_attr_callback', $string);
|
@@ -1099,22 +1101,26 @@ function twig_escape_filter(Twig_Environment $env, $string, $strategy = 'html',
|
|
1099 |
return $string;
|
1100 |
|
1101 |
case 'url':
|
|
|
|
|
|
|
|
|
1102 |
return rawurlencode($string);
|
1103 |
|
1104 |
default:
|
1105 |
static $escapers;
|
1106 |
|
1107 |
if (null === $escapers) {
|
1108 |
-
$escapers = $env->getExtension('
|
1109 |
}
|
1110 |
|
1111 |
if (isset($escapers[$strategy])) {
|
1112 |
-
return
|
1113 |
}
|
1114 |
|
1115 |
-
$validStrategies = implode(', ', array_merge(
|
1116 |
|
1117 |
-
throw new
|
1118 |
}
|
1119 |
}
|
1120 |
|
@@ -1124,22 +1130,22 @@ function twig_escape_filter(Twig_Environment $env, $string, $strategy = 'html',
|
|
1124 |
function twig_escape_filter_is_safe(Twig_Node $filterArgs)
|
1125 |
{
|
1126 |
foreach ($filterArgs as $arg) {
|
1127 |
-
if ($arg instanceof
|
1128 |
-
return
|
1129 |
}
|
1130 |
|
1131 |
-
return
|
1132 |
}
|
1133 |
|
1134 |
-
return
|
1135 |
}
|
1136 |
|
1137 |
-
if (
|
1138 |
function twig_convert_encoding($string, $to, $from)
|
1139 |
{
|
1140 |
return mb_convert_encoding($string, $to, $from);
|
1141 |
}
|
1142 |
-
} elseif (
|
1143 |
function twig_convert_encoding($string, $to, $from)
|
1144 |
{
|
1145 |
return iconv($from, $to, $string);
|
@@ -1147,30 +1153,7 @@ if (\function_exists('mb_convert_encoding')) {
|
|
1147 |
} else {
|
1148 |
function twig_convert_encoding($string, $to, $from)
|
1149 |
{
|
1150 |
-
throw new
|
1151 |
-
}
|
1152 |
-
}
|
1153 |
-
|
1154 |
-
if (\function_exists('mb_ord')) {
|
1155 |
-
function twig_ord($string)
|
1156 |
-
{
|
1157 |
-
return mb_ord($string, 'UTF-8');
|
1158 |
-
}
|
1159 |
-
} else {
|
1160 |
-
function twig_ord($string)
|
1161 |
-
{
|
1162 |
-
$code = ($string = unpack('C*', substr($string, 0, 4))) ? $string[1] : 0;
|
1163 |
-
if (0xF0 <= $code) {
|
1164 |
-
return (($code - 0xF0) << 18) + (($string[2] - 0x80) << 12) + (($string[3] - 0x80) << 6) + $string[4] - 0x80;
|
1165 |
-
}
|
1166 |
-
if (0xE0 <= $code) {
|
1167 |
-
return (($code - 0xE0) << 12) + (($string[2] - 0x80) << 6) + $string[3] - 0x80;
|
1168 |
-
}
|
1169 |
-
if (0xC0 <= $code) {
|
1170 |
-
return (($code - 0xC0) << 6) + $string[2] - 0x80;
|
1171 |
-
}
|
1172 |
-
|
1173 |
-
return $code;
|
1174 |
}
|
1175 |
}
|
1176 |
|
@@ -1178,30 +1161,16 @@ function _twig_escape_js_callback($matches)
|
|
1178 |
{
|
1179 |
$char = $matches[0];
|
1180 |
|
1181 |
-
|
1182 |
-
|
1183 |
-
|
1184 |
-
* \" is also supported but omitted, because the resulting string is not HTML safe.
|
1185 |
-
*/
|
1186 |
-
static $shortMap = [
|
1187 |
-
'\\' => '\\\\',
|
1188 |
-
'/' => '\\/',
|
1189 |
-
"\x08" => '\b',
|
1190 |
-
"\x0C" => '\f',
|
1191 |
-
"\x0A" => '\n',
|
1192 |
-
"\x0D" => '\r',
|
1193 |
-
"\x09" => '\t',
|
1194 |
-
];
|
1195 |
-
|
1196 |
-
if (isset($shortMap[$char])) {
|
1197 |
-
return $shortMap[$char];
|
1198 |
}
|
1199 |
|
1200 |
// \uHHHH
|
1201 |
$char = twig_convert_encoding($char, 'UTF-16BE', 'UTF-8');
|
1202 |
$char = strtoupper(bin2hex($char));
|
1203 |
|
1204 |
-
if (4 >=
|
1205 |
return sprintf('\u%04s', $char);
|
1206 |
}
|
1207 |
|
@@ -1212,25 +1181,51 @@ function _twig_escape_css_callback($matches)
|
|
1212 |
{
|
1213 |
$char = $matches[0];
|
1214 |
|
1215 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1216 |
}
|
1217 |
|
1218 |
/**
|
1219 |
* This function is adapted from code coming from Zend Framework.
|
1220 |
*
|
1221 |
-
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (
|
1222 |
-
* @license
|
1223 |
*/
|
1224 |
function _twig_escape_html_attr_callback($matches)
|
1225 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1226 |
$chr = $matches[0];
|
1227 |
-
$ord =
|
1228 |
|
1229 |
/*
|
1230 |
* The following replaces characters undefined in HTML with the
|
1231 |
* hex entity for the Unicode replacement character.
|
1232 |
*/
|
1233 |
-
if (($ord <= 0x1f && "\t"
|
1234 |
return '�';
|
1235 |
}
|
1236 |
|
@@ -1238,80 +1233,57 @@ function _twig_escape_html_attr_callback($matches)
|
|
1238 |
* Check if the current character to escape has a name entity we should
|
1239 |
* replace it with while grabbing the hex value of the character.
|
1240 |
*/
|
1241 |
-
if (
|
1242 |
-
|
1243 |
-
|
1244 |
-
|
1245 |
-
|
1246 |
-
|
1247 |
-
*/
|
1248 |
-
static $entityMap = [
|
1249 |
-
34 => '"', /* quotation mark */
|
1250 |
-
38 => '&', /* ampersand */
|
1251 |
-
60 => '<', /* less-than sign */
|
1252 |
-
62 => '>', /* greater-than sign */
|
1253 |
-
];
|
1254 |
-
|
1255 |
-
if (isset($entityMap[$ord])) {
|
1256 |
-
return $entityMap[$ord];
|
1257 |
-
}
|
1258 |
|
1259 |
-
|
|
|
|
|
1260 |
}
|
1261 |
|
1262 |
/*
|
1263 |
* Per OWASP recommendations, we'll use hex entities for any other
|
1264 |
* characters where a named entity does not exist.
|
1265 |
*/
|
1266 |
-
return sprintf('&#x%
|
1267 |
}
|
1268 |
|
1269 |
// add multibyte extensions if possible
|
1270 |
-
if (
|
1271 |
/**
|
1272 |
* Returns the length of a variable.
|
1273 |
*
|
1274 |
-
* @param
|
|
|
1275 |
*
|
1276 |
* @return int The length of the value
|
1277 |
*/
|
1278 |
-
function twig_length_filter(
|
1279 |
{
|
1280 |
-
if (null === $thing) {
|
1281 |
-
return 0;
|
1282 |
-
}
|
1283 |
-
|
1284 |
if (is_scalar($thing)) {
|
1285 |
return mb_strlen($thing, $env->getCharset());
|
1286 |
}
|
1287 |
|
1288 |
-
if ($thing instanceof \
|
1289 |
-
return \count($thing);
|
1290 |
-
}
|
1291 |
-
|
1292 |
-
if (\is_object($thing) && method_exists($thing, '__toString') && !$thing instanceof \Countable) {
|
1293 |
return mb_strlen((string) $thing, $env->getCharset());
|
1294 |
}
|
1295 |
|
1296 |
-
|
1297 |
-
return \count($thing);
|
1298 |
-
}
|
1299 |
-
|
1300 |
-
if ($thing instanceof \IteratorAggregate) {
|
1301 |
-
return iterator_count($thing);
|
1302 |
-
}
|
1303 |
-
|
1304 |
-
return 1;
|
1305 |
}
|
1306 |
|
1307 |
/**
|
1308 |
* Converts a string to uppercase.
|
1309 |
*
|
1310 |
-
* @param
|
|
|
1311 |
*
|
1312 |
* @return string The uppercased string
|
1313 |
*/
|
1314 |
-
function twig_upper_filter(
|
1315 |
{
|
1316 |
if (null !== $charset = $env->getCharset()) {
|
1317 |
return mb_strtoupper($string, $charset);
|
@@ -1323,11 +1295,12 @@ if (\function_exists('mb_get_info')) {
|
|
1323 |
/**
|
1324 |
* Converts a string to lowercase.
|
1325 |
*
|
1326 |
-
* @param
|
|
|
1327 |
*
|
1328 |
* @return string The lowercased string
|
1329 |
*/
|
1330 |
-
function twig_lower_filter(
|
1331 |
{
|
1332 |
if (null !== $charset = $env->getCharset()) {
|
1333 |
return mb_strtolower($string, $charset);
|
@@ -1339,11 +1312,12 @@ if (\function_exists('mb_get_info')) {
|
|
1339 |
/**
|
1340 |
* Returns a titlecased string.
|
1341 |
*
|
1342 |
-
* @param
|
|
|
1343 |
*
|
1344 |
* @return string The titlecased string
|
1345 |
*/
|
1346 |
-
function twig_title_string_filter(
|
1347 |
{
|
1348 |
if (null !== $charset = $env->getCharset()) {
|
1349 |
return mb_convert_case($string, MB_CASE_TITLE, $charset);
|
@@ -1355,11 +1329,12 @@ if (\function_exists('mb_get_info')) {
|
|
1355 |
/**
|
1356 |
* Returns a capitalized string.
|
1357 |
*
|
1358 |
-
* @param
|
|
|
1359 |
*
|
1360 |
* @return string The capitalized string
|
1361 |
*/
|
1362 |
-
function twig_capitalize_string_filter(
|
1363 |
{
|
1364 |
if (null !== $charset = $env->getCharset()) {
|
1365 |
return mb_strtoupper(mb_substr($string, 0, 1, $charset), $charset).mb_strtolower(mb_substr($string, 1, mb_strlen($string, $charset), $charset), $charset);
|
@@ -1373,47 +1348,33 @@ else {
|
|
1373 |
/**
|
1374 |
* Returns the length of a variable.
|
1375 |
*
|
1376 |
-
* @param
|
|
|
1377 |
*
|
1378 |
* @return int The length of the value
|
1379 |
*/
|
1380 |
-
function twig_length_filter(
|
1381 |
{
|
1382 |
-
if (null === $thing) {
|
1383 |
-
return 0;
|
1384 |
-
}
|
1385 |
-
|
1386 |
if (is_scalar($thing)) {
|
1387 |
-
return
|
1388 |
-
}
|
1389 |
-
|
1390 |
-
if ($thing instanceof \SimpleXMLElement) {
|
1391 |
-
return \count($thing);
|
1392 |
-
}
|
1393 |
-
|
1394 |
-
if (\is_object($thing) && method_exists($thing, '__toString') && !$thing instanceof \Countable) {
|
1395 |
-
return \strlen((string) $thing);
|
1396 |
}
|
1397 |
|
1398 |
-
if ($thing instanceof \Countable
|
1399 |
-
return
|
1400 |
}
|
1401 |
|
1402 |
-
|
1403 |
-
return iterator_count($thing);
|
1404 |
-
}
|
1405 |
-
|
1406 |
-
return 1;
|
1407 |
}
|
1408 |
|
1409 |
/**
|
1410 |
* Returns a titlecased string.
|
1411 |
*
|
1412 |
-
* @param
|
|
|
1413 |
*
|
1414 |
* @return string The titlecased string
|
1415 |
*/
|
1416 |
-
function twig_title_string_filter(
|
1417 |
{
|
1418 |
return ucwords(strtolower($string));
|
1419 |
}
|
@@ -1421,11 +1382,12 @@ else {
|
|
1421 |
/**
|
1422 |
* Returns a capitalized string.
|
1423 |
*
|
1424 |
-
* @param
|
|
|
1425 |
*
|
1426 |
* @return string The capitalized string
|
1427 |
*/
|
1428 |
-
function twig_capitalize_string_filter(
|
1429 |
{
|
1430 |
return ucfirst(strtolower($string));
|
1431 |
}
|
@@ -1436,20 +1398,22 @@ else {
|
|
1436 |
*/
|
1437 |
function twig_ensure_traversable($seq)
|
1438 |
{
|
1439 |
-
if ($seq instanceof
|
1440 |
return $seq;
|
1441 |
}
|
1442 |
|
1443 |
-
return
|
1444 |
}
|
1445 |
|
1446 |
/**
|
1447 |
* Checks if a variable is empty.
|
1448 |
*
|
1449 |
-
*
|
1450 |
-
*
|
1451 |
-
*
|
1452 |
-
*
|
|
|
|
|
1453 |
*
|
1454 |
* @param mixed $value A variable
|
1455 |
*
|
@@ -1457,24 +1421,26 @@ function twig_ensure_traversable($seq)
|
|
1457 |
*/
|
1458 |
function twig_test_empty($value)
|
1459 |
{
|
1460 |
-
if ($value instanceof
|
1461 |
-
return 0 ==
|
1462 |
}
|
1463 |
|
1464 |
-
if (
|
1465 |
return '' === (string) $value;
|
1466 |
}
|
1467 |
|
1468 |
-
return '' === $value || false === $value || null === $value ||
|
1469 |
}
|
1470 |
|
1471 |
/**
|
1472 |
* Checks if a variable is traversable.
|
1473 |
*
|
1474 |
-
*
|
1475 |
-
*
|
1476 |
-
*
|
1477 |
-
*
|
|
|
|
|
1478 |
*
|
1479 |
* @param mixed $value A variable
|
1480 |
*
|
@@ -1482,22 +1448,23 @@ function twig_test_empty($value)
|
|
1482 |
*/
|
1483 |
function twig_test_iterable($value)
|
1484 |
{
|
1485 |
-
return $value instanceof
|
1486 |
}
|
1487 |
|
1488 |
/**
|
1489 |
* Renders a template.
|
1490 |
*
|
1491 |
-
* @param
|
1492 |
-
* @param
|
1493 |
-
* @param array
|
1494 |
-
* @param
|
1495 |
-
* @param bool
|
1496 |
-
* @param bool
|
|
|
1497 |
*
|
1498 |
* @return string The rendered template
|
1499 |
*/
|
1500 |
-
function twig_include(Twig_Environment $env, $context, $template, $variables =
|
1501 |
{
|
1502 |
$alreadySandboxed = false;
|
1503 |
$sandbox = null;
|
@@ -1505,17 +1472,17 @@ function twig_include(Twig_Environment $env, $context, $template, $variables = [
|
|
1505 |
$variables = array_merge($context, $variables);
|
1506 |
}
|
1507 |
|
1508 |
-
if ($isSandboxed = $sandboxed && $env->hasExtension('
|
1509 |
-
$sandbox = $env->getExtension('
|
1510 |
if (!$alreadySandboxed = $sandbox->isSandboxed()) {
|
1511 |
$sandbox->enableSandbox();
|
1512 |
}
|
1513 |
}
|
1514 |
|
1515 |
-
$result =
|
1516 |
try {
|
1517 |
$result = $env->resolveTemplate($template)->render($variables);
|
1518 |
-
} catch (
|
1519 |
if (!$ignoreMissing) {
|
1520 |
if ($isSandboxed && !$alreadySandboxed) {
|
1521 |
$sandbox->disableSandbox();
|
@@ -1523,13 +1490,13 @@ function twig_include(Twig_Environment $env, $context, $template, $variables = [
|
|
1523 |
|
1524 |
throw $e;
|
1525 |
}
|
1526 |
-
} catch (
|
1527 |
if ($isSandboxed && !$alreadySandboxed) {
|
1528 |
$sandbox->disableSandbox();
|
1529 |
}
|
1530 |
|
1531 |
throw $e;
|
1532 |
-
} catch (
|
1533 |
if ($isSandboxed && !$alreadySandboxed) {
|
1534 |
$sandbox->disableSandbox();
|
1535 |
}
|
@@ -1547,8 +1514,9 @@ function twig_include(Twig_Environment $env, $context, $template, $variables = [
|
|
1547 |
/**
|
1548 |
* Returns a template content without rendering it.
|
1549 |
*
|
1550 |
-
* @param
|
1551 |
-
* @param
|
|
|
1552 |
*
|
1553 |
* @return string The template source
|
1554 |
*/
|
@@ -1556,12 +1524,12 @@ function twig_source(Twig_Environment $env, $name, $ignoreMissing = false)
|
|
1556 |
{
|
1557 |
$loader = $env->getLoader();
|
1558 |
try {
|
1559 |
-
if (!$loader instanceof
|
1560 |
return $loader->getSource($name);
|
1561 |
} else {
|
1562 |
return $loader->getSourceContext($name)->getCode();
|
1563 |
}
|
1564 |
-
} catch (
|
1565 |
if (!$ignoreMissing) {
|
1566 |
throw $e;
|
1567 |
}
|
@@ -1572,34 +1540,34 @@ function twig_source(Twig_Environment $env, $name, $ignoreMissing = false)
|
|
1572 |
* Provides the ability to get constants from instances as well as class/global constants.
|
1573 |
*
|
1574 |
* @param string $constant The name of the constant
|
1575 |
-
* @param object
|
1576 |
*
|
1577 |
* @return string
|
1578 |
*/
|
1579 |
function twig_constant($constant, $object = null)
|
1580 |
{
|
1581 |
if (null !== $object) {
|
1582 |
-
$constant =
|
1583 |
}
|
1584 |
|
1585 |
-
return
|
1586 |
}
|
1587 |
|
1588 |
/**
|
1589 |
* Checks if a constant exists.
|
1590 |
*
|
1591 |
* @param string $constant The name of the constant
|
1592 |
-
* @param object
|
1593 |
*
|
1594 |
* @return bool
|
1595 |
*/
|
1596 |
function twig_constant_is_defined($constant, $object = null)
|
1597 |
{
|
1598 |
if (null !== $object) {
|
1599 |
-
$constant =
|
1600 |
}
|
1601 |
|
1602 |
-
return
|
1603 |
}
|
1604 |
|
1605 |
/**
|
@@ -1613,7 +1581,7 @@ function twig_constant_is_defined($constant, $object = null)
|
|
1613 |
*/
|
1614 |
function twig_array_batch($items, $size, $fill = null)
|
1615 |
{
|
1616 |
-
if ($items instanceof
|
1617 |
$items = iterator_to_array($items, false);
|
1618 |
}
|
1619 |
|
@@ -1622,8 +1590,8 @@ function twig_array_batch($items, $size, $fill = null)
|
|
1622 |
$result = array_chunk($items, $size, true);
|
1623 |
|
1624 |
if (null !== $fill && !empty($result)) {
|
1625 |
-
$last =
|
1626 |
-
if ($fillCount = $size -
|
1627 |
$result[$last] = array_merge(
|
1628 |
$result[$last],
|
1629 |
array_fill(0, $fillCount, $fill)
|
@@ -1633,5 +1601,3 @@ function twig_array_batch($items, $size, $fill = null)
|
|
1633 |
|
1634 |
return $result;
|
1635 |
}
|
1636 |
-
|
1637 |
-
class_alias('Twig_Extension_Core', 'Twig\Extension\CoreExtension', false);
|
1 |
<?php
|
2 |
|
3 |
+
if (!defined('ENT_SUBSTITUTE')) {
|
4 |
+
// use 0 as hhvm does not support several flags yet
|
5 |
+
define('ENT_SUBSTITUTE', 0);
|
6 |
}
|
7 |
|
8 |
/*
|
14 |
* file that was distributed with this source code.
|
15 |
*/
|
16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
/**
|
18 |
* @final
|
19 |
*/
|
20 |
+
class Twig_Extension_Core extends Twig_Extension
|
21 |
{
|
22 |
+
protected $dateFormats = array('F j, Y H:i', '%d days');
|
23 |
+
protected $numberFormat = array(0, '.', ',');
|
24 |
protected $timezone = null;
|
25 |
+
protected $escapers = array();
|
26 |
|
27 |
/**
|
28 |
* Defines a new escaper to be used via the escape filter.
|
75 |
/**
|
76 |
* Sets the default timezone to be used by the date filter.
|
77 |
*
|
78 |
+
* @param DateTimeZone|string $timezone The default timezone string or a DateTimeZone object
|
79 |
*/
|
80 |
public function setTimezone($timezone)
|
81 |
{
|
82 |
+
$this->timezone = $timezone instanceof DateTimeZone ? $timezone : new DateTimeZone($timezone);
|
83 |
}
|
84 |
|
85 |
/**
|
86 |
* Gets the default timezone to be used by the date filter.
|
87 |
*
|
88 |
+
* @return DateTimeZone The default timezone currently in use
|
89 |
*/
|
90 |
public function getTimezone()
|
91 |
{
|
92 |
if (null === $this->timezone) {
|
93 |
+
$this->timezone = new DateTimeZone(date_default_timezone_get());
|
94 |
}
|
95 |
|
96 |
return $this->timezone;
|
105 |
*/
|
106 |
public function setNumberFormat($decimal, $decimalPoint, $thousandSep)
|
107 |
{
|
108 |
+
$this->numberFormat = array($decimal, $decimalPoint, $thousandSep);
|
109 |
}
|
110 |
|
111 |
/**
|
120 |
|
121 |
public function getTokenParsers()
|
122 |
{
|
123 |
+
return array(
|
124 |
+
new Twig_TokenParser_For(),
|
125 |
+
new Twig_TokenParser_If(),
|
126 |
+
new Twig_TokenParser_Extends(),
|
127 |
+
new Twig_TokenParser_Include(),
|
128 |
+
new Twig_TokenParser_Block(),
|
129 |
+
new Twig_TokenParser_Use(),
|
130 |
+
new Twig_TokenParser_Filter(),
|
131 |
+
new Twig_TokenParser_Macro(),
|
132 |
+
new Twig_TokenParser_Import(),
|
133 |
+
new Twig_TokenParser_From(),
|
134 |
+
new Twig_TokenParser_Set(),
|
135 |
+
new Twig_TokenParser_Spaceless(),
|
136 |
+
new Twig_TokenParser_Flush(),
|
137 |
+
new Twig_TokenParser_Do(),
|
138 |
+
new Twig_TokenParser_Embed(),
|
139 |
+
new Twig_TokenParser_With(),
|
140 |
+
);
|
|
|
141 |
}
|
142 |
|
143 |
public function getFilters()
|
144 |
{
|
145 |
+
$filters = array(
|
146 |
// formatting filters
|
147 |
+
new Twig_SimpleFilter('date', 'twig_date_format_filter', array('needs_environment' => true)),
|
148 |
+
new Twig_SimpleFilter('date_modify', 'twig_date_modify_filter', array('needs_environment' => true)),
|
149 |
+
new Twig_SimpleFilter('format', 'sprintf'),
|
150 |
+
new Twig_SimpleFilter('replace', 'twig_replace_filter'),
|
151 |
+
new Twig_SimpleFilter('number_format', 'twig_number_format_filter', array('needs_environment' => true)),
|
152 |
+
new Twig_SimpleFilter('abs', 'abs'),
|
153 |
+
new Twig_SimpleFilter('round', 'twig_round'),
|
154 |
|
155 |
// encoding
|
156 |
+
new Twig_SimpleFilter('url_encode', 'twig_urlencode_filter'),
|
157 |
+
new Twig_SimpleFilter('json_encode', 'twig_jsonencode_filter'),
|
158 |
+
new Twig_SimpleFilter('convert_encoding', 'twig_convert_encoding'),
|
159 |
|
160 |
// string filters
|
161 |
+
new Twig_SimpleFilter('title', 'twig_title_string_filter', array('needs_environment' => true)),
|
162 |
+
new Twig_SimpleFilter('capitalize', 'twig_capitalize_string_filter', array('needs_environment' => true)),
|
163 |
+
new Twig_SimpleFilter('upper', 'strtoupper'),
|
164 |
+
new Twig_SimpleFilter('lower', 'strtolower'),
|
165 |
+
new Twig_SimpleFilter('striptags', 'strip_tags'),
|
166 |
+
new Twig_SimpleFilter('trim', 'twig_trim_filter'),
|
167 |
+
new Twig_SimpleFilter('nl2br', 'nl2br', array('pre_escape' => 'html', 'is_safe' => array('html'))),
|
168 |
|
169 |
// array helpers
|
170 |
+
new Twig_SimpleFilter('join', 'twig_join_filter'),
|
171 |
+
new Twig_SimpleFilter('split', 'twig_split_filter', array('needs_environment' => true)),
|
172 |
+
new Twig_SimpleFilter('sort', 'twig_sort_filter'),
|
173 |
+
new Twig_SimpleFilter('merge', 'twig_array_merge'),
|
174 |
+
new Twig_SimpleFilter('batch', 'twig_array_batch'),
|
175 |
|
176 |
// string/array filters
|
177 |
+
new Twig_SimpleFilter('reverse', 'twig_reverse_filter', array('needs_environment' => true)),
|
178 |
+
new Twig_SimpleFilter('length', 'twig_length_filter', array('needs_environment' => true)),
|
179 |
+
new Twig_SimpleFilter('slice', 'twig_slice', array('needs_environment' => true)),
|
180 |
+
new Twig_SimpleFilter('first', 'twig_first', array('needs_environment' => true)),
|
181 |
+
new Twig_SimpleFilter('last', 'twig_last', array('needs_environment' => true)),
|
182 |
|
183 |
// iteration and runtime
|
184 |
+
new Twig_SimpleFilter('default', '_twig_default_filter', array('node_class' => 'Twig_Node_Expression_Filter_Default')),
|
185 |
+
new Twig_SimpleFilter('keys', 'twig_get_array_keys_filter'),
|
186 |
|
187 |
// escaping
|
188 |
+
new Twig_SimpleFilter('escape', 'twig_escape_filter', array('needs_environment' => true, 'is_safe_callback' => 'twig_escape_filter_is_safe')),
|
189 |
+
new Twig_SimpleFilter('e', 'twig_escape_filter', array('needs_environment' => true, 'is_safe_callback' => 'twig_escape_filter_is_safe')),
|
190 |
+
);
|
191 |
|
192 |
+
if (function_exists('mb_get_info')) {
|
193 |
+
$filters[] = new Twig_SimpleFilter('upper', 'twig_upper_filter', array('needs_environment' => true));
|
194 |
+
$filters[] = new Twig_SimpleFilter('lower', 'twig_lower_filter', array('needs_environment' => true));
|
195 |
}
|
196 |
|
197 |
return $filters;
|
199 |
|
200 |
public function getFunctions()
|
201 |
{
|
202 |
+
return array(
|
203 |
+
new Twig_SimpleFunction('max', 'max'),
|
204 |
+
new Twig_SimpleFunction('min', 'min'),
|
205 |
+
new Twig_SimpleFunction('range', 'range'),
|
206 |
+
new Twig_SimpleFunction('constant', 'twig_constant'),
|
207 |
+
new Twig_SimpleFunction('cycle', 'twig_cycle'),
|
208 |
+
new Twig_SimpleFunction('random', 'twig_random', array('needs_environment' => true)),
|
209 |
+
new Twig_SimpleFunction('date', 'twig_date_converter', array('needs_environment' => true)),
|
210 |
+
new Twig_SimpleFunction('include', 'twig_include', array('needs_environment' => true, 'needs_context' => true, 'is_safe' => array('all'))),
|
211 |
+
new Twig_SimpleFunction('source', 'twig_source', array('needs_environment' => true, 'is_safe' => array('all'))),
|
212 |
+
);
|
213 |
}
|
214 |
|
215 |
public function getTests()
|
216 |
{
|
217 |
+
return array(
|
218 |
+
new Twig_SimpleTest('even', null, array('node_class' => 'Twig_Node_Expression_Test_Even')),
|
219 |
+
new Twig_SimpleTest('odd', null, array('node_class' => 'Twig_Node_Expression_Test_Odd')),
|
220 |
+
new Twig_SimpleTest('defined', null, array('node_class' => 'Twig_Node_Expression_Test_Defined')),
|
221 |
+
new Twig_SimpleTest('sameas', null, array('node_class' => 'Twig_Node_Expression_Test_Sameas', 'deprecated' => '1.21', 'alternative' => 'same as')),
|
222 |
+
new Twig_SimpleTest('same as', null, array('node_class' => 'Twig_Node_Expression_Test_Sameas')),
|
223 |
+
new Twig_SimpleTest('none', null, array('node_class' => 'Twig_Node_Expression_Test_Null')),
|
224 |
+
new Twig_SimpleTest('null', null, array('node_class' => 'Twig_Node_Expression_Test_Null')),
|
225 |
+
new Twig_SimpleTest('divisibleby', null, array('node_class' => 'Twig_Node_Expression_Test_Divisibleby', 'deprecated' => '1.21', 'alternative' => 'divisible by')),
|
226 |
+
new Twig_SimpleTest('divisible by', null, array('node_class' => 'Twig_Node_Expression_Test_Divisibleby')),
|
227 |
+
new Twig_SimpleTest('constant', null, array('node_class' => 'Twig_Node_Expression_Test_Constant')),
|
228 |
+
new Twig_SimpleTest('empty', 'twig_test_empty'),
|
229 |
+
new Twig_SimpleTest('iterable', 'twig_test_iterable'),
|
230 |
+
);
|
231 |
}
|
232 |
|
233 |
public function getOperators()
|
234 |
{
|
235 |
+
return array(
|
236 |
+
array(
|
237 |
+
'not' => array('precedence' => 50, 'class' => 'Twig_Node_Expression_Unary_Not'),
|
238 |
+
'-' => array('precedence' => 500, 'class' => 'Twig_Node_Expression_Unary_Neg'),
|
239 |
+
'+' => array('precedence' => 500, 'class' => 'Twig_Node_Expression_Unary_Pos'),
|
240 |
+
),
|
241 |
+
array(
|
242 |
+
'or' => array('precedence' => 10, 'class' => 'Twig_Node_Expression_Binary_Or', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
|
243 |
+
'and' => array('precedence' => 15, 'class' => 'Twig_Node_Expression_Binary_And', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
|
244 |
+
'b-or' => array('precedence' => 16, 'class' => 'Twig_Node_Expression_Binary_BitwiseOr', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
|
245 |
+
'b-xor' => array('precedence' => 17, 'class' => 'Twig_Node_Expression_Binary_BitwiseXor', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
|
246 |
+
'b-and' => array('precedence' => 18, 'class' => 'Twig_Node_Expression_Binary_BitwiseAnd', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
|
247 |
+
'==' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_Equal', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
|
248 |
+
'!=' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_NotEqual', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
|
249 |
+
'<' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_Less', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
|
250 |
+
'>' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_Greater', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
|
251 |
+
'>=' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_GreaterEqual', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
|
252 |
+
'<=' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_LessEqual', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
|
253 |
+
'not in' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_NotIn', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
|
254 |
+
'in' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_In', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
|
255 |
+
'matches' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_Matches', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
|
256 |
+
'starts with' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_StartsWith', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
|
257 |
+
'ends with' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_EndsWith', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
|
258 |
+
'..' => array('precedence' => 25, 'class' => 'Twig_Node_Expression_Binary_Range', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
|
259 |
+
'+' => array('precedence' => 30, 'class' => 'Twig_Node_Expression_Binary_Add', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
|
260 |
+
'-' => array('precedence' => 30, 'class' => 'Twig_Node_Expression_Binary_Sub', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
|
261 |
+
'~' => array('precedence' => 40, 'class' => 'Twig_Node_Expression_Binary_Concat', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
|
262 |
+
'*' => array('precedence' => 60, 'class' => 'Twig_Node_Expression_Binary_Mul', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
|
263 |
+
'/' => array('precedence' => 60, 'class' => 'Twig_Node_Expression_Binary_Div', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
|
264 |
+
'//' => array('precedence' => 60, 'class' => 'Twig_Node_Expression_Binary_FloorDiv', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
|
265 |
+
'%' => array('precedence' => 60, 'class' => 'Twig_Node_Expression_Binary_Mod', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
|
266 |
+
'is' => array('precedence' => 100, 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
|
267 |
+
'is not' => array('precedence' => 100, 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
|
268 |
+
'**' => array('precedence' => 200, 'class' => 'Twig_Node_Expression_Binary_Power', 'associativity' => Twig_ExpressionParser::OPERATOR_RIGHT),
|
269 |
+
'??' => array('precedence' => 300, 'class' => 'Twig_Node_Expression_NullCoalesce', 'associativity' => Twig_ExpressionParser::OPERATOR_RIGHT),
|
270 |
+
),
|
271 |
+
);
|
272 |
}
|
273 |
|
274 |
public function getName()
|
287 |
*/
|
288 |
function twig_cycle($values, $position)
|
289 |
{
|
290 |
+
if (!is_array($values) && !$values instanceof ArrayAccess) {
|
291 |
return $values;
|
292 |
}
|
293 |
|
294 |
+
return $values[$position % count($values)];
|
295 |
}
|
296 |
|
297 |
/**
|
298 |
* Returns a random value depending on the supplied parameter type:
|
299 |
+
* - a random item from a Traversable or array
|
300 |
* - a random character from a string
|
301 |
* - a random integer between 0 and the integer parameter.
|
302 |
*
|
303 |
+
* @param Twig_Environment $env
|
304 |
+
* @param Traversable|array|int|float|string $values The values to pick a random item from
|
305 |
*
|
306 |
+
* @throws Twig_Error_Runtime when $values is an empty array (does not apply to an empty string which is returned as is)
|
307 |
*
|
308 |
* @return mixed A random value from the given sequence
|
309 |
*/
|
313 |
return mt_rand();
|
314 |
}
|
315 |
|
316 |
+
if (is_int($values) || is_float($values)) {
|
317 |
return $values < 0 ? mt_rand($values, 0) : mt_rand(0, $values);
|
318 |
}
|
319 |
|
320 |
+
if ($values instanceof Traversable) {
|
321 |
$values = iterator_to_array($values);
|
322 |
+
} elseif (is_string($values)) {
|
323 |
if ('' === $values) {
|
324 |
return '';
|
325 |
}
|
338 |
}
|
339 |
}
|
340 |
} else {
|
341 |
+
return $values[mt_rand(0, strlen($values) - 1)];
|
342 |
}
|
343 |
}
|
344 |
|
345 |
+
if (!is_array($values)) {
|
346 |
return $values;
|
347 |
}
|
348 |
|
349 |
+
if (0 === count($values)) {
|
350 |
+
throw new Twig_Error_Runtime('The random function cannot pick from an empty array.');
|
351 |
}
|
352 |
|
353 |
return $values[array_rand($values, 1)];
|
356 |
/**
|
357 |
* Converts a date to the given format.
|
358 |
*
|
359 |
+
* <pre>
|
360 |
* {{ post.published_at|date("m/d/Y") }}
|
361 |
+
* </pre>
|
362 |
*
|
363 |
+
* @param Twig_Environment $env
|
364 |
+
* @param DateTime|DateTimeInterface|DateInterval|string $date A date
|
365 |
+
* @param string|null $format The target format, null to use the default
|
366 |
+
* @param DateTimeZone|string|null|false $timezone The target timezone, null to use the default, false to leave unchanged
|
367 |
*
|
368 |
* @return string The formatted date
|
369 |
*/
|
370 |
function twig_date_format_filter(Twig_Environment $env, $date, $format = null, $timezone = null)
|
371 |
{
|
372 |
if (null === $format) {
|
373 |
+
$formats = $env->getExtension('Twig_Extension_Core')->getDateFormat();
|
374 |
+
$format = $date instanceof DateInterval ? $formats[1] : $formats[0];
|
375 |
}
|
376 |
|
377 |
+
if ($date instanceof DateInterval) {
|
378 |
return $date->format($format);
|
379 |
}
|
380 |
|
384 |
/**
|
385 |
* Returns a new date object modified.
|
386 |
*
|
387 |
+
* <pre>
|
388 |
* {{ post.published_at|date_modify("-1day")|date("m/d/Y") }}
|
389 |
+
* </pre>
|
390 |
*
|
391 |
+
* @param Twig_Environment $env
|
392 |
+
* @param DateTime|string $date A date
|
393 |
* @param string $modifier A modifier string
|
394 |
*
|
395 |
+
* @return DateTime A new date object
|
396 |
*/
|
397 |
function twig_date_modify_filter(Twig_Environment $env, $date, $modifier)
|
398 |
{
|
399 |
$date = twig_date_converter($env, $date, false);
|
400 |
$resultDate = $date->modify($modifier);
|
401 |
|
402 |
+
// This is a hack to ensure PHP 5.2 support and support for DateTimeImmutable
|
403 |
+
// DateTime::modify does not return the modified DateTime object < 5.3.0
|
404 |
+
// and DateTimeImmutable does not modify $date.
|
405 |
return null === $resultDate ? $date : $resultDate;
|
406 |
}
|
407 |
|
408 |
/**
|
409 |
+
* Converts an input to a DateTime instance.
|
410 |
*
|
411 |
+
* <pre>
|
412 |
* {% if date(user.created_at) < date('+2days') %}
|
413 |
* {# do something #}
|
414 |
* {% endif %}
|
415 |
+
* </pre>
|
416 |
*
|
417 |
+
* @param Twig_Environment $env
|
418 |
+
* @param DateTime|DateTimeInterface|string|null $date A date
|
419 |
+
* @param DateTimeZone|string|null|false $timezone The target timezone, null to use the default, false to leave unchanged
|
420 |
*
|
421 |
+
* @return DateTime A DateTime instance
|
422 |
*/
|
423 |
function twig_date_converter(Twig_Environment $env, $date = null, $timezone = null)
|
424 |
{
|
425 |
// determine the timezone
|
426 |
if (false !== $timezone) {
|
427 |
if (null === $timezone) {
|
428 |
+
$timezone = $env->getExtension('Twig_Extension_Core')->getTimezone();
|
429 |
+
} elseif (!$timezone instanceof DateTimeZone) {
|
430 |
+
$timezone = new DateTimeZone($timezone);
|
431 |
}
|
432 |
}
|
433 |
|
434 |
// immutable dates
|
435 |
+
if ($date instanceof DateTimeImmutable) {
|
436 |
return false !== $timezone ? $date->setTimezone($timezone) : $date;
|
437 |
}
|
438 |
|
439 |
+
if ($date instanceof DateTime || $date instanceof DateTimeInterface) {
|
440 |
$date = clone $date;
|
441 |
if (false !== $timezone) {
|
442 |
$date->setTimezone($timezone);
|
446 |
}
|
447 |
|
448 |
if (null === $date || 'now' === $date) {
|
449 |
+
return new DateTime($date, false !== $timezone ? $timezone : $env->getExtension('Twig_Extension_Core')->getTimezone());
|
450 |
}
|
451 |
|
452 |
$asString = (string) $date;
|
453 |
if (ctype_digit($asString) || (!empty($asString) && '-' === $asString[0] && ctype_digit(substr($asString, 1)))) {
|
454 |
+
$date = new DateTime('@'.$date);
|
455 |
} else {
|
456 |
+
$date = new DateTime($date, $env->getExtension('Twig_Extension_Core')->getTimezone());
|
457 |
}
|
458 |
|
459 |
if (false !== $timezone) {
|
466 |
/**
|
467 |
* Replaces strings within a string.
|
468 |
*
|
469 |
+
* @param string $str String to replace in
|
470 |
+
* @param array|Traversable $from Replace values
|
471 |
+
* @param string|null $to Replace to, deprecated (@see http://php.net/manual/en/function.strtr.php)
|
472 |
*
|
473 |
* @return string
|
474 |
*/
|
475 |
function twig_replace_filter($str, $from, $to = null)
|
476 |
{
|
477 |
+
if ($from instanceof Traversable) {
|
478 |
$from = iterator_to_array($from);
|
479 |
+
} elseif (is_string($from) && is_string($to)) {
|
480 |
@trigger_error('Using "replace" with character by character replacement is deprecated since version 1.22 and will be removed in Twig 2.0', E_USER_DEPRECATED);
|
481 |
|
482 |
return strtr($str, $from, $to);
|
483 |
+
} elseif (!is_array($from)) {
|
484 |
+
throw new Twig_Error_Runtime(sprintf('The "replace" filter expects an array or "Traversable" as replace values, got "%s".', is_object($from) ? get_class($from) : gettype($from)));
|
485 |
}
|
486 |
|
487 |
return strtr($str, $from);
|
503 |
}
|
504 |
|
505 |
if ('ceil' != $method && 'floor' != $method) {
|
506 |
+
throw new Twig_Error_Runtime('The round filter only supports the "common", "ceil", and "floor" methods.');
|
507 |
}
|
508 |
|
509 |
return $method($value * pow(10, $precision)) / pow(10, $precision);
|
516 |
* be used. Supplying any of the parameters will override the defaults set in the
|
517 |
* environment object.
|
518 |
*
|
519 |
+
* @param Twig_Environment $env
|
520 |
+
* @param mixed $number A float/int/string of the number to format
|
521 |
+
* @param int $decimal the number of decimal points to display
|
522 |
+
* @param string $decimalPoint the character(s) to use for the decimal point
|
523 |
+
* @param string $thousandSep the character(s) to use for the thousands separator
|
524 |
*
|
525 |
* @return string The formatted number
|
526 |
*/
|
527 |
function twig_number_format_filter(Twig_Environment $env, $number, $decimal = null, $decimalPoint = null, $thousandSep = null)
|
528 |
{
|
529 |
+
$defaults = $env->getExtension('Twig_Extension_Core')->getNumberFormat();
|
530 |
if (null === $decimal) {
|
531 |
$decimal = $defaults[0];
|
532 |
}
|
551 |
*/
|
552 |
function twig_urlencode_filter($url)
|
553 |
{
|
554 |
+
if (is_array($url)) {
|
555 |
+
if (defined('PHP_QUERY_RFC3986')) {
|
556 |
return http_build_query($url, '', '&', PHP_QUERY_RFC3986);
|
557 |
}
|
558 |
|
562 |
return rawurlencode($url);
|
563 |
}
|
564 |
|
565 |
+
if (PHP_VERSION_ID < 50300) {
|
566 |
+
/**
|
567 |
+
* JSON encodes a variable.
|
568 |
+
*
|
569 |
+
* @param mixed $value the value to encode
|
570 |
+
* @param int $options Not used on PHP 5.2.x
|
571 |
+
*
|
572 |
+
* @return mixed The JSON encoded value
|
573 |
+
*/
|
574 |
+
function twig_jsonencode_filter($value, $options = 0)
|
575 |
+
{
|
576 |
+
if ($value instanceof Twig_Markup) {
|
577 |
+
$value = (string) $value;
|
578 |
+
} elseif (is_array($value)) {
|
579 |
+
array_walk_recursive($value, '_twig_markup2string');
|
580 |
+
}
|
581 |
+
|
582 |
+
return json_encode($value);
|
583 |
}
|
584 |
+
} else {
|
585 |
+
/**
|
586 |
+
* JSON encodes a variable.
|
587 |
+
*
|
588 |
+
* @param mixed $value the value to encode
|
589 |
+
* @param int $options Bitmask consisting of JSON_HEX_QUOT, JSON_HEX_TAG, JSON_HEX_AMP, JSON_HEX_APOS, JSON_NUMERIC_CHECK, JSON_PRETTY_PRINT, JSON_UNESCAPED_SLASHES, JSON_FORCE_OBJECT
|
590 |
+
*
|
591 |
+
* @return mixed The JSON encoded value
|
592 |
+
*/
|
593 |
+
function twig_jsonencode_filter($value, $options = 0)
|
594 |
+
{
|
595 |
+
if ($value instanceof Twig_Markup) {
|
596 |
+
$value = (string) $value;
|
597 |
+
} elseif (is_array($value)) {
|
598 |
+
array_walk_recursive($value, '_twig_markup2string');
|
599 |
+
}
|
600 |
|
601 |
+
return json_encode($value, $options);
|
602 |
+
}
|
603 |
}
|
604 |
|
605 |
function _twig_markup2string(&$value)
|
606 |
{
|
607 |
+
if ($value instanceof Twig_Markup) {
|
608 |
$value = (string) $value;
|
609 |
}
|
610 |
}
|
612 |
/**
|
613 |
* Merges an array with another one.
|
614 |
*
|
615 |
+
* <pre>
|
616 |
* {% set items = { 'apple': 'fruit', 'orange': 'fruit' } %}
|
617 |
*
|
618 |
* {% set items = items|merge({ 'peugeot': 'car' }) %}
|
619 |
*
|
620 |
* {# items now contains { 'apple': 'fruit', 'orange': 'fruit', 'peugeot': 'car' } #}
|
621 |
+
* </pre>
|
622 |
*
|
623 |
+
* @param array|Traversable $arr1 An array
|
624 |
+
* @param array|Traversable $arr2 An array
|
625 |
*
|
626 |
* @return array The merged array
|
627 |
*/
|
628 |
function twig_array_merge($arr1, $arr2)
|
629 |
{
|
630 |
+
if ($arr1 instanceof Traversable) {
|
631 |
$arr1 = iterator_to_array($arr1);
|
632 |
+
} elseif (!is_array($arr1)) {
|
633 |
+
throw new Twig_Error_Runtime(sprintf('The merge filter only works with arrays or "Traversable", got "%s" as first argument.', gettype($arr1)));
|
634 |
}
|
635 |
|
636 |
+
if ($arr2 instanceof Traversable) {
|
637 |
$arr2 = iterator_to_array($arr2);
|
638 |
+
} elseif (!is_array($arr2)) {
|
639 |
+
throw new Twig_Error_Runtime(sprintf('The merge filter only works with arrays or "Traversable", got "%s" as second argument.', gettype($arr2)));
|
640 |
}
|
641 |
|
642 |
return array_merge($arr1, $arr2);
|
645 |
/**
|
646 |
* Slices a variable.
|
647 |
*
|
648 |
+
* @param Twig_Environment $env
|
649 |
+
* @param mixed $item A variable
|
650 |
+
* @param int $start Start of the slice
|
651 |
+
* @param int $length Size of the slice
|
652 |
+
* @param bool $preserveKeys Whether to preserve key or not (when the input is an array)
|
653 |
*
|
654 |
* @return mixed The sliced variable
|
655 |
*/
|
656 |
function twig_slice(Twig_Environment $env, $item, $start, $length = null, $preserveKeys = false)
|
657 |
{
|
658 |
+
if ($item instanceof Traversable) {
|
659 |
+
while ($item instanceof IteratorAggregate) {
|
660 |
$item = $item->getIterator();
|
661 |
}
|
662 |
|
663 |
+
if ($start >= 0 && $length >= 0 && $item instanceof Iterator) {
|
664 |
try {
|
665 |
+
return iterator_to_array(new LimitIterator($item, $start, $length === null ? -1 : $length), $preserveKeys);
|
666 |
+
} catch (OutOfBoundsException $exception) {
|
667 |
+
return array();
|
668 |
}
|
669 |
}
|
670 |
|
671 |
$item = iterator_to_array($item, $preserveKeys);
|
672 |
}
|
673 |
|
674 |
+
if (is_array($item)) {
|
675 |
+
return array_slice($item, $start, $length, $preserveKeys);
|
676 |
}
|
677 |
|
678 |
$item = (string) $item;
|
679 |
|
680 |
+
if (function_exists('mb_get_info') && null !== $charset = $env->getCharset()) {
|
681 |
return (string) mb_substr($item, $start, null === $length ? mb_strlen($item, $charset) - $start : $length, $charset);
|
682 |
}
|
683 |
|
687 |
/**
|
688 |
* Returns the first element of the item.
|
689 |
*
|
690 |
+
* @param Twig_Environment $env
|
691 |
+
* @param mixed $item A variable
|
692 |
*
|
693 |
* @return mixed The first element of the item
|
694 |
*/
|
696 |
{
|
697 |
$elements = twig_slice($env, $item, 0, 1, false);
|
698 |
|
699 |
+
return is_string($elements) ? $elements : current($elements);
|
700 |
}
|
701 |
|
702 |
/**
|
703 |
* Returns the last element of the item.
|
704 |
*
|
705 |
+
* @param Twig_Environment $env
|
706 |
+
* @param mixed $item A variable
|
707 |
*
|
708 |
* @return mixed The last element of the item
|
709 |
*/
|
711 |
{
|
712 |
$elements = twig_slice($env, $item, -1, 1, false);
|
713 |
|
714 |
+
return is_string($elements) ? $elements : current($elements);
|
715 |
}
|
716 |
|
717 |
/**
|
718 |
* Joins the values to a string.
|
719 |
*
|
720 |
+
* The separator between elements is an empty string per default, you can define it with the optional parameter.
|
|
|
|
|
|
|
721 |
*
|
722 |
+
* <pre>
|
723 |
* {{ [1, 2, 3]|join('|') }}
|
724 |
* {# returns 1|2|3 #}
|
725 |
*
|
726 |
* {{ [1, 2, 3]|join }}
|
727 |
* {# returns 123 #}
|
728 |
+
* </pre>
|
729 |
*
|
730 |
+
* @param array $value An array
|
731 |
+
* @param string $glue The separator
|
|
|
732 |
*
|
733 |
* @return string The concatenated string
|
734 |
*/
|
735 |
+
function twig_join_filter($value, $glue = '')
|
736 |
{
|
737 |
+
if ($value instanceof Traversable) {
|
738 |
$value = iterator_to_array($value, false);
|
|
|
|
|
|
|
|
|
|
|
|
|
739 |
}
|
740 |
|
741 |
+
return implode($glue, (array) $value);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
742 |
}
|
743 |
|
744 |
/**
|
745 |
* Splits the string into an array.
|
746 |
*
|
747 |
+
* <pre>
|
748 |
* {{ "one,two,three"|split(',') }}
|
749 |
* {# returns [one, two, three] #}
|
750 |
*
|
756 |
*
|
757 |
* {{ "aabbcc"|split('', 2) }}
|
758 |
* {# returns [aa, bb, cc] #}
|
759 |
+
* </pre>
|
760 |
*
|
761 |
+
* @param Twig_Environment $env
|
762 |
+
* @param string $value A string
|
763 |
+
* @param string $delimiter The delimiter
|
764 |
+
* @param int $limit The limit
|
765 |
*
|
766 |
* @return array The split string as an array
|
767 |
*/
|
771 |
return null === $limit ? explode($delimiter, $value) : explode($delimiter, $value, $limit);
|
772 |
}
|
773 |
|
774 |
+
if (!function_exists('mb_get_info') || null === $charset = $env->getCharset()) {
|
775 |
return str_split($value, null === $limit ? 1 : $limit);
|
776 |
}
|
777 |
|
781 |
|
782 |
$length = mb_strlen($value, $charset);
|
783 |
if ($length < $limit) {
|
784 |
+
return array($value);
|
785 |
}
|
786 |
|
787 |
+
$r = array();
|
788 |
for ($i = 0; $i < $length; $i += $limit) {
|
789 |
$r[] = mb_substr($value, $i, $limit, $charset);
|
790 |
}
|
812 |
*
|
813 |
* It is useful when you want to iterate over the keys of an array:
|
814 |
*
|
815 |
+
* <pre>
|
816 |
* {% for key in array|keys %}
|
817 |
* {# ... #}
|
818 |
* {% endfor %}
|
819 |
+
* </pre>
|
820 |
*
|
821 |
* @param array $array An array
|
822 |
*
|
824 |
*/
|
825 |
function twig_get_array_keys_filter($array)
|
826 |
{
|
827 |
+
if ($array instanceof Traversable) {
|
828 |
+
while ($array instanceof IteratorAggregate) {
|
829 |
$array = $array->getIterator();
|
830 |
}
|
831 |
|
832 |
+
if ($array instanceof Iterator) {
|
833 |
+
$keys = array();
|
834 |
$array->rewind();
|
835 |
while ($array->valid()) {
|
836 |
$keys[] = $array->key();
|
840 |
return $keys;
|
841 |
}
|
842 |
|
843 |
+
$keys = array();
|
844 |
foreach ($array as $key => $item) {
|
845 |
$keys[] = $key;
|
846 |
}
|
848 |
return $keys;
|
849 |
}
|
850 |
|
851 |
+
if (!is_array($array)) {
|
852 |
+
return array();
|
853 |
}
|
854 |
|
855 |
return array_keys($array);
|
858 |
/**
|
859 |
* Reverses a variable.
|
860 |
*
|
861 |
+
* @param Twig_Environment $env
|
862 |
+
* @param array|Traversable|string $item An array, a Traversable instance, or a string
|
863 |
+
* @param bool $preserveKeys Whether to preserve key or not
|
864 |
*
|
865 |
* @return mixed The reversed input
|
866 |
*/
|
867 |
function twig_reverse_filter(Twig_Environment $env, $item, $preserveKeys = false)
|
868 |
{
|
869 |
+
if ($item instanceof Traversable) {
|
870 |
return array_reverse(iterator_to_array($item), $preserveKeys);
|
871 |
}
|
872 |
|
873 |
+
if (is_array($item)) {
|
874 |
return array_reverse($item, $preserveKeys);
|
875 |
}
|
876 |
|
898 |
/**
|
899 |
* Sorts an array.
|
900 |
*
|
901 |
+
* @param array|Traversable $array
|
902 |
*
|
903 |
* @return array
|
904 |
*/
|
905 |
function twig_sort_filter($array)
|
906 |
{
|
907 |
+
if ($array instanceof Traversable) {
|
908 |
$array = iterator_to_array($array);
|
909 |
+
} elseif (!is_array($array)) {
|
910 |
+
throw new Twig_Error_Runtime(sprintf('The sort filter only works with arrays or "Traversable", got "%s".', gettype($array)));
|
911 |
}
|
912 |
|
913 |
asort($array);
|
920 |
*/
|
921 |
function twig_in_filter($value, $compare)
|
922 |
{
|
923 |
+
if (is_array($compare)) {
|
924 |
+
return in_array($value, $compare, is_object($value) || is_resource($value));
|
925 |
+
} elseif (is_string($compare) && (is_string($value) || is_int($value) || is_float($value))) {
|
926 |
return '' === $value || false !== strpos($compare, (string) $value);
|
927 |
+
} elseif ($compare instanceof Traversable) {
|
928 |
+
if (is_object($value) || is_resource($value)) {
|
929 |
foreach ($compare as $item) {
|
930 |
if ($item === $value) {
|
931 |
return true;
|
950 |
*
|
951 |
* @return string
|
952 |
*
|
953 |
+
* @throws Twig_Error_Runtime When an invalid trimming side is used (not a string or not 'left', 'right', or 'both')
|
954 |
*/
|
955 |
function twig_trim_filter($string, $characterMask = null, $side = 'both')
|
956 |
{
|
966 |
case 'right':
|
967 |
return rtrim($string, $characterMask);
|
968 |
default:
|
969 |
+
throw new Twig_Error_Runtime('Trimming side must be "left", "right" or "both".');
|
970 |
}
|
971 |
}
|
972 |
|
973 |
/**
|
974 |
* Escapes a string.
|
975 |
*
|
976 |
+
* @param Twig_Environment $env
|
977 |
+
* @param mixed $string The value to be escaped
|
978 |
+
* @param string $strategy The escaping strategy
|
979 |
+
* @param string $charset The charset
|
980 |
+
* @param bool $autoescape Whether the function is called by the auto-escaping feature (true) or by the developer (false)
|
981 |
*
|
982 |
* @return string
|
983 |
*/
|
984 |
function twig_escape_filter(Twig_Environment $env, $string, $strategy = 'html', $charset = null, $autoescape = false)
|
985 |
{
|
986 |
+
if ($autoescape && $string instanceof Twig_Markup) {
|
987 |
return $string;
|
988 |
}
|
989 |
|
990 |
+
if (!is_string($string)) {
|
991 |
+
if (is_object($string) && method_exists($string, '__toString')) {
|
992 |
$string = (string) $string;
|
993 |
+
} elseif (in_array($strategy, array('html', 'js', 'css', 'html_attr', 'url'))) {
|
994 |
return $string;
|
995 |
}
|
996 |
}
|
997 |
|
|
|
|
|
|
|
|
|
998 |
if (null === $charset) {
|
999 |
$charset = $env->getCharset();
|
1000 |
}
|
1001 |
|
1002 |
switch ($strategy) {
|
1003 |
case 'html':
|
1004 |
+
// see http://php.net/htmlspecialchars
|
1005 |
|
1006 |
// Using a static variable to avoid initializing the array
|
1007 |
// each time the function is called. Moving the declaration on the
|
1008 |
// top of the function slow downs other escaping strategies.
|
1009 |
+
static $htmlspecialcharsCharsets;
|
1010 |
+
|
1011 |
+
if (null === $htmlspecialcharsCharsets) {
|
1012 |
+
if (defined('HHVM_VERSION')) {
|
1013 |
+
$htmlspecialcharsCharsets = array('utf-8' => true, 'UTF-8' => true);
|
1014 |
+
} else {
|
1015 |
+
$htmlspecialcharsCharsets = array(
|
1016 |
+
'ISO-8859-1' => true, 'ISO8859-1' => true,
|
1017 |
+
'ISO-8859-15' => true, 'ISO8859-15' => true,
|
1018 |
+
'utf-8' => true, 'UTF-8' => true,
|
1019 |
+
'CP866' => true, 'IBM866' => true, '866' => true,
|
1020 |
+
'CP1251' => true, 'WINDOWS-1251' => true, 'WIN-1251' => true,
|
1021 |
+
'1251' => true,
|
1022 |
+
'CP1252' => true, 'WINDOWS-1252' => true, '1252' => true,
|
1023 |
+
'KOI8-R' => true, 'KOI8-RU' => true, 'KOI8R' => true,
|
1024 |
+
'BIG5' => true, '950' => true,
|
1025 |
+
'GB2312' => true, '936' => true,
|
1026 |
+
'BIG5-HKSCS' => true,
|
1027 |
+
'SHIFT_JIS' => true, 'SJIS' => true, '932' => true,
|
1028 |
+
'EUC-JP' => true, 'EUCJP' => true,
|
1029 |
+
'ISO8859-5' => true, 'ISO-8859-5' => true, 'MACROMAN' => true,
|
1030 |
+
);
|
1031 |
+
}
|
1032 |
+
}
|
1033 |
|
1034 |
if (isset($htmlspecialcharsCharsets[$charset])) {
|
1035 |
return htmlspecialchars($string, ENT_QUOTES | ENT_SUBSTITUTE, $charset);
|
1049 |
|
1050 |
case 'js':
|
1051 |
// escape all non-alphanumeric characters
|
1052 |
+
// into their \xHH or \uHHHH representations
|
1053 |
if ('UTF-8' !== $charset) {
|
1054 |
$string = twig_convert_encoding($string, 'UTF-8', $charset);
|
1055 |
}
|
1056 |
|
1057 |
+
if (0 == strlen($string) ? false : 1 !== preg_match('/^./su', $string)) {
|
1058 |
+
throw new Twig_Error_Runtime('The string to escape is not a valid UTF-8 string.');
|
1059 |
}
|
1060 |
|
1061 |
$string = preg_replace_callback('#[^a-zA-Z0-9,\._]#Su', '_twig_escape_js_callback', $string);
|
1071 |
$string = twig_convert_encoding($string, 'UTF-8', $charset);
|
1072 |
}
|
1073 |
|
1074 |
+
if (0 == strlen($string) ? false : 1 !== preg_match('/^./su', $string)) {
|
1075 |
+
throw new Twig_Error_Runtime('The string to escape is not a valid UTF-8 string.');
|
1076 |
}
|
1077 |
|
1078 |
$string = preg_replace_callback('#[^a-zA-Z0-9]#Su', '_twig_escape_css_callback', $string);
|
1088 |
$string = twig_convert_encoding($string, 'UTF-8', $charset);
|
1089 |
}
|
1090 |
|
1091 |
+
if (0 == strlen($string) ? false : 1 !== preg_match('/^./su', $string)) {
|
1092 |
+
throw new Twig_Error_Runtime('The string to escape is not a valid UTF-8 string.');
|
1093 |
}
|
1094 |
|
1095 |
$string = preg_replace_callback('#[^a-zA-Z0-9,\.\-_]#Su', '_twig_escape_html_attr_callback', $string);
|
1101 |
return $string;
|
1102 |
|
1103 |
case 'url':
|
1104 |
+
if (PHP_VERSION_ID < 50300) {
|
1105 |
+
return str_replace('%7E', '~', rawurlencode($string));
|
1106 |
+
}
|
1107 |
+
|
1108 |
return rawurlencode($string);
|
1109 |
|
1110 |
default:
|
1111 |
static $escapers;
|
1112 |
|
1113 |
if (null === $escapers) {
|
1114 |
+
$escapers = $env->getExtension('Twig_Extension_Core')->getEscapers();
|
1115 |
}
|
1116 |
|
1117 |
if (isset($escapers[$strategy])) {
|
1118 |
+
return call_user_func($escapers[$strategy], $env, $string, $charset);
|
1119 |
}
|
1120 |
|
1121 |
+
$validStrategies = implode(', ', array_merge(array('html', 'js', 'url', 'css', 'html_attr'), array_keys($escapers)));
|
1122 |
|
1123 |
+
throw new Twig_Error_Runtime(sprintf('Invalid escaping strategy "%s" (valid ones: %s).', $strategy, $validStrategies));
|
1124 |
}
|
1125 |
}
|
1126 |
|
1130 |
function twig_escape_filter_is_safe(Twig_Node $filterArgs)
|
1131 |
{
|
1132 |
foreach ($filterArgs as $arg) {
|
1133 |
+
if ($arg instanceof Twig_Node_Expression_Constant) {
|
1134 |
+
return array($arg->getAttribute('value'));
|
1135 |
}
|
1136 |
|
1137 |
+
return array();
|
1138 |
}
|
1139 |
|
1140 |
+
return array('html');
|
1141 |
}
|
1142 |
|
1143 |
+
if (function_exists('mb_convert_encoding')) {
|
1144 |
function twig_convert_encoding($string, $to, $from)
|
1145 |
{
|
1146 |
return mb_convert_encoding($string, $to, $from);
|
1147 |
}
|
1148 |
+
} elseif (function_exists('iconv')) {
|
1149 |
function twig_convert_encoding($string, $to, $from)
|
1150 |
{
|
1151 |
return iconv($from, $to, $string);
|
1153 |
} else {
|
1154 |
function twig_convert_encoding($string, $to, $from)
|
1155 |
{
|
1156 |
+
throw new Twig_Error_Runtime('No suitable convert encoding function (use UTF-8 as your encoding or install the iconv or mbstring extension).');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1157 |
}
|
1158 |
}
|
1159 |
|
1161 |
{
|
1162 |
$char = $matches[0];
|
1163 |
|
1164 |
+
// \xHH
|
1165 |
+
if (!isset($char[1])) {
|
1166 |
+
return '\\x'.strtoupper(substr('00'.bin2hex($char), -2));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1167 |
}
|
1168 |
|
1169 |
// \uHHHH
|
1170 |
$char = twig_convert_encoding($char, 'UTF-16BE', 'UTF-8');
|
1171 |
$char = strtoupper(bin2hex($char));
|
1172 |
|
1173 |
+
if (4 >= strlen($char)) {
|
1174 |
return sprintf('\u%04s', $char);
|
1175 |
}
|
1176 |
|
1181 |
{
|
1182 |
$char = $matches[0];
|
1183 |
|
1184 |
+
// \xHH
|
1185 |
+
if (!isset($char[1])) {
|
1186 |
+
$hex = ltrim(strtoupper(bin2hex($char)), '0');
|
1187 |
+
if (0 === strlen($hex)) {
|
1188 |
+
$hex = '0';
|
1189 |
+
}
|
1190 |
+
|
1191 |
+
return '\\'.$hex.' ';
|
1192 |
+
}
|
1193 |
+
|
1194 |
+
// \uHHHH
|
1195 |
+
$char = twig_convert_encoding($char, 'UTF-16BE', 'UTF-8');
|
1196 |
+
|
1197 |
+
return '\\'.ltrim(strtoupper(bin2hex($char)), '0').' ';
|
1198 |
}
|
1199 |
|
1200 |
/**
|
1201 |
* This function is adapted from code coming from Zend Framework.
|
1202 |
*
|
1203 |
+
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
1204 |
+
* @license http://framework.zend.com/license/new-bsd New BSD License
|
1205 |
*/
|
1206 |
function _twig_escape_html_attr_callback($matches)
|
1207 |
{
|
1208 |
+
/*
|
1209 |
+
* While HTML supports far more named entities, the lowest common denominator
|
1210 |
+
* has become HTML5's XML Serialisation which is restricted to the those named
|
1211 |
+
* entities that XML supports. Using HTML entities would result in this error:
|
1212 |
+
* XML Parsing Error: undefined entity
|
1213 |
+
*/
|
1214 |
+
static $entityMap = array(
|
1215 |
+
34 => 'quot', /* quotation mark */
|
1216 |
+
38 => 'amp', /* ampersand */
|
1217 |
+
60 => 'lt', /* less-than sign */
|
1218 |
+
62 => 'gt', /* greater-than sign */
|
1219 |
+
);
|
1220 |
+
|
1221 |
$chr = $matches[0];
|
1222 |
+
$ord = ord($chr);
|
1223 |
|
1224 |
/*
|
1225 |
* The following replaces characters undefined in HTML with the
|
1226 |
* hex entity for the Unicode replacement character.
|
1227 |
*/
|
1228 |
+
if (($ord <= 0x1f && $chr != "\t" && $chr != "\n" && $chr != "\r") || ($ord >= 0x7f && $ord <= 0x9f)) {
|
1229 |
return '�';
|
1230 |
}
|
1231 |
|
1233 |
* Check if the current character to escape has a name entity we should
|
1234 |
* replace it with while grabbing the hex value of the character.
|
1235 |
*/
|
1236 |
+
if (strlen($chr) == 1) {
|
1237 |
+
$hex = strtoupper(substr('00'.bin2hex($chr), -2));
|
1238 |
+
} else {
|
1239 |
+
$chr = twig_convert_encoding($chr, 'UTF-16BE', 'UTF-8');
|
1240 |
+
$hex = strtoupper(substr('0000'.bin2hex($chr), -4));
|
1241 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1242 |
|
1243 |
+
$int = hexdec($hex);
|
1244 |
+
if (array_key_exists($int, $entityMap)) {
|
1245 |
+
return sprintf('&%s;', $entityMap[$int]);
|
1246 |
}
|
1247 |
|
1248 |
/*
|
1249 |
* Per OWASP recommendations, we'll use hex entities for any other
|
1250 |
* characters where a named entity does not exist.
|
1251 |
*/
|
1252 |
+
return sprintf('&#x%s;', $hex);
|
1253 |
}
|
1254 |
|
1255 |
// add multibyte extensions if possible
|
1256 |
+
if (function_exists('mb_get_info')) {
|
1257 |
/**
|
1258 |
* Returns the length of a variable.
|
1259 |
*
|
1260 |
+
* @param Twig_Environment $env
|
1261 |
+
* @param mixed $thing A variable
|
1262 |
*
|
1263 |
* @return int The length of the value
|
1264 |
*/
|
1265 |
+
function twig_length_filter(Twig_Environment $env, $thing)
|
1266 |
{
|
|
|
|
|
|
|
|
|
1267 |
if (is_scalar($thing)) {
|
1268 |
return mb_strlen($thing, $env->getCharset());
|
1269 |
}
|
1270 |
|
1271 |
+
if (method_exists($thing, '__toString') && !$thing instanceof \Countable) {
|
|
|
|
|
|
|
|
|
1272 |
return mb_strlen((string) $thing, $env->getCharset());
|
1273 |
}
|
1274 |
|
1275 |
+
return count($thing);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1276 |
}
|
1277 |
|
1278 |
/**
|
1279 |
* Converts a string to uppercase.
|
1280 |
*
|
1281 |
+
* @param Twig_Environment $env
|
1282 |
+
* @param string $string A string
|
1283 |
*
|
1284 |
* @return string The uppercased string
|
1285 |
*/
|
1286 |
+
function twig_upper_filter(Twig_Environment $env, $string)
|
1287 |
{
|
1288 |
if (null !== $charset = $env->getCharset()) {
|
1289 |
return mb_strtoupper($string, $charset);
|
1295 |
/**
|
1296 |
* Converts a string to lowercase.
|
1297 |
*
|
1298 |
+
* @param Twig_Environment $env
|
1299 |
+
* @param string $string A string
|
1300 |
*
|
1301 |
* @return string The lowercased string
|
1302 |
*/
|
1303 |
+
function twig_lower_filter(Twig_Environment $env, $string)
|
1304 |
{
|
1305 |
if (null !== $charset = $env->getCharset()) {
|
1306 |
return mb_strtolower($string, $charset);
|
1312 |
/**
|
1313 |
* Returns a titlecased string.
|
1314 |
*
|
1315 |
+
* @param Twig_Environment $env
|
1316 |
+
* @param string $string A string
|
1317 |
*
|
1318 |
* @return string The titlecased string
|
1319 |
*/
|
1320 |
+
function twig_title_string_filter(Twig_Environment $env, $string)
|
1321 |
{
|
1322 |
if (null !== $charset = $env->getCharset()) {
|
1323 |
return mb_convert_case($string, MB_CASE_TITLE, $charset);
|
1329 |
/**
|
1330 |
* Returns a capitalized string.
|
1331 |
*
|
1332 |
+
* @param Twig_Environment $env
|
1333 |
+
* @param string $string A string
|
1334 |
*
|
1335 |
* @return string The capitalized string
|
1336 |
*/
|
1337 |
+
function twig_capitalize_string_filter(Twig_Environment $env, $string)
|
1338 |
{
|
1339 |
if (null !== $charset = $env->getCharset()) {
|
1340 |
return mb_strtoupper(mb_substr($string, 0, 1, $charset), $charset).mb_strtolower(mb_substr($string, 1, mb_strlen($string, $charset), $charset), $charset);
|
1348 |
/**
|
1349 |
* Returns the length of a variable.
|
1350 |
*
|
1351 |
+
* @param Twig_Environment $env
|
1352 |
+
* @param mixed $thing A variable
|
1353 |
*
|
1354 |
* @return int The length of the value
|
1355 |
*/
|
1356 |
+
function twig_length_filter(Twig_Environment $env, $thing)
|
1357 |
{
|
|
|
|
|
|
|
|
|
1358 |
if (is_scalar($thing)) {
|
1359 |
+
return strlen($thing);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1360 |
}
|
1361 |
|
1362 |
+
if (method_exists($thing, '__toString') && !$thing instanceof \Countable) {
|
1363 |
+
return strlen((string) $thing);
|
1364 |
}
|
1365 |
|
1366 |
+
return count($thing);
|
|
|
|
|
|
|
|
|
1367 |
}
|
1368 |
|
1369 |
/**
|
1370 |
* Returns a titlecased string.
|
1371 |
*
|
1372 |
+
* @param Twig_Environment $env
|
1373 |
+
* @param string $string A string
|
1374 |
*
|
1375 |
* @return string The titlecased string
|
1376 |
*/
|
1377 |
+
function twig_title_string_filter(Twig_Environment $env, $string)
|
1378 |
{
|
1379 |
return ucwords(strtolower($string));
|
1380 |
}
|
1382 |
/**
|
1383 |
* Returns a capitalized string.
|
1384 |
*
|
1385 |
+
* @param Twig_Environment $env
|
1386 |
+
* @param string $string A string
|
1387 |
*
|
1388 |
* @return string The capitalized string
|
1389 |
*/
|
1390 |
+
function twig_capitalize_string_filter(Twig_Environment $env, $string)
|
1391 |
{
|
1392 |
return ucfirst(strtolower($string));
|
1393 |
}
|
1398 |
*/
|
1399 |
function twig_ensure_traversable($seq)
|
1400 |
{
|
1401 |
+
if ($seq instanceof Traversable || is_array($seq)) {
|
1402 |
return $seq;
|
1403 |
}
|
1404 |
|
1405 |
+
return array();
|
1406 |
}
|
1407 |
|
1408 |
/**
|
1409 |
* Checks if a variable is empty.
|
1410 |
*
|
1411 |
+
* <pre>
|
1412 |
+
* {# evaluates to true if the foo variable is null, false, or the empty string #}
|
1413 |
+
* {% if foo is empty %}
|
1414 |
+
* {# ... #}
|
1415 |
+
* {% endif %}
|
1416 |
+
* </pre>
|
1417 |
*
|
1418 |
* @param mixed $value A variable
|
1419 |
*
|
1421 |
*/
|
1422 |
function twig_test_empty($value)
|
1423 |
{
|
1424 |
+
if ($value instanceof Countable) {
|
1425 |
+
return 0 == count($value);
|
1426 |
}
|
1427 |
|
1428 |
+
if (method_exists($value, '__toString')) {
|
1429 |
return '' === (string) $value;
|
1430 |
}
|
1431 |
|
1432 |
+
return '' === $value || false === $value || null === $value || array() === $value;
|
1433 |
}
|
1434 |
|
1435 |
/**
|
1436 |
* Checks if a variable is traversable.
|
1437 |
*
|
1438 |
+
* <pre>
|
1439 |
+
* {# evaluates to true if the foo variable is an array or a traversable object #}
|
1440 |
+
* {% if foo is traversable %}
|
1441 |
+
* {# ... #}
|
1442 |
+
* {% endif %}
|
1443 |
+
* </pre>
|
1444 |
*
|
1445 |
* @param mixed $value A variable
|
1446 |
*
|
1448 |
*/
|
1449 |
function twig_test_iterable($value)
|
1450 |
{
|
1451 |
+
return $value instanceof Traversable || is_array($value);
|
1452 |
}
|
1453 |
|
1454 |
/**
|
1455 |
* Renders a template.
|
1456 |
*
|
1457 |
+
* @param Twig_Environment $env
|
1458 |
+
* @param array $context
|
1459 |
+
* @param string|array $template The template to render or an array of templates to try consecutively
|
1460 |
+
* @param array $variables The variables to pass to the template
|
1461 |
+
* @param bool $withContext
|
1462 |
+
* @param bool $ignoreMissing Whether to ignore missing templates or not
|
1463 |
+
* @param bool $sandboxed Whether to sandbox the template or not
|
1464 |
*
|
1465 |
* @return string The rendered template
|
1466 |
*/
|
1467 |
+
function twig_include(Twig_Environment $env, $context, $template, $variables = array(), $withContext = true, $ignoreMissing = false, $sandboxed = false)
|
1468 |
{
|
1469 |
$alreadySandboxed = false;
|
1470 |
$sandbox = null;
|
1472 |
$variables = array_merge($context, $variables);
|
1473 |
}
|
1474 |
|
1475 |
+
if ($isSandboxed = $sandboxed && $env->hasExtension('Twig_Extension_Sandbox')) {
|
1476 |
+
$sandbox = $env->getExtension('Twig_Extension_Sandbox');
|
1477 |
if (!$alreadySandboxed = $sandbox->isSandboxed()) {
|
1478 |
$sandbox->enableSandbox();
|
1479 |
}
|
1480 |
}
|
1481 |
|
1482 |
+
$result = null;
|
1483 |
try {
|
1484 |
$result = $env->resolveTemplate($template)->render($variables);
|
1485 |
+
} catch (Twig_Error_Loader $e) {
|
1486 |
if (!$ignoreMissing) {
|
1487 |
if ($isSandboxed && !$alreadySandboxed) {
|
1488 |
$sandbox->disableSandbox();
|
1490 |
|
1491 |
throw $e;
|
1492 |
}
|
1493 |
+
} catch (Throwable $e) {
|
1494 |
if ($isSandboxed && !$alreadySandboxed) {
|
1495 |
$sandbox->disableSandbox();
|
1496 |
}
|
1497 |
|
1498 |
throw $e;
|
1499 |
+
} catch (Exception $e) {
|
1500 |
if ($isSandboxed && !$alreadySandboxed) {
|
1501 |
$sandbox->disableSandbox();
|
1502 |
}
|
1514 |
/**
|
1515 |
* Returns a template content without rendering it.
|
1516 |
*
|
1517 |
+
* @param Twig_Environment $env
|
1518 |
+
* @param string $name The template name
|
1519 |
+
* @param bool $ignoreMissing Whether to ignore missing templates or not
|
1520 |
*
|
1521 |
* @return string The template source
|
1522 |
*/
|
1524 |
{
|
1525 |
$loader = $env->getLoader();
|
1526 |
try {
|
1527 |
+
if (!$loader instanceof Twig_SourceContextLoaderInterface) {
|
1528 |
return $loader->getSource($name);
|
1529 |
} else {
|
1530 |
return $loader->getSourceContext($name)->getCode();
|
1531 |
}
|
1532 |
+
} catch (Twig_Error_Loader $e) {
|
1533 |
if (!$ignoreMissing) {
|
1534 |
throw $e;
|
1535 |
}
|
1540 |
* Provides the ability to get constants from instances as well as class/global constants.
|
1541 |
*
|
1542 |
* @param string $constant The name of the constant
|
1543 |
+
* @param null|object $object The object to get the constant from
|
1544 |
*
|
1545 |
* @return string
|
1546 |
*/
|
1547 |
function twig_constant($constant, $object = null)
|
1548 |
{
|
1549 |
if (null !== $object) {
|
1550 |
+
$constant = get_class($object).'::'.$constant;
|
1551 |
}
|
1552 |
|
1553 |
+
return constant($constant);
|
1554 |
}
|
1555 |
|
1556 |
/**
|
1557 |
* Checks if a constant exists.
|
1558 |
*
|
1559 |
* @param string $constant The name of the constant
|
1560 |
+
* @param null|object $object The object to get the constant from
|
1561 |
*
|
1562 |
* @return bool
|
1563 |
*/
|
1564 |
function twig_constant_is_defined($constant, $object = null)
|
1565 |
{
|
1566 |
if (null !== $object) {
|
1567 |
+
$constant = get_class($object).'::'.$constant;
|
1568 |
}
|
1569 |
|
1570 |
+
return defined($constant);
|
1571 |
}
|
1572 |
|
1573 |
/**
|
1581 |
*/
|
1582 |
function twig_array_batch($items, $size, $fill = null)
|
1583 |
{
|
1584 |
+
if ($items instanceof Traversable) {
|
1585 |
$items = iterator_to_array($items, false);
|
1586 |
}
|
1587 |
|
1590 |
$result = array_chunk($items, $size, true);
|
1591 |
|
1592 |
if (null !== $fill && !empty($result)) {
|
1593 |
+
$last = count($result) - 1;
|
1594 |
+
if ($fillCount = $size - count($result[$last])) {
|
1595 |
$result[$last] = array_merge(
|
1596 |
$result[$last],
|
1597 |
array_fill(0, $fillCount, $fill)
|
1601 |
|
1602 |
return $result;
|
1603 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Extension/Debug.php
CHANGED
@@ -9,30 +9,26 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Extension\AbstractExtension;
|
13 |
-
use Twig\Template;
|
14 |
-
use Twig\TwigFunction;
|
15 |
-
|
16 |
/**
|
17 |
* @final
|
18 |
*/
|
19 |
-
class Twig_Extension_Debug extends
|
20 |
{
|
21 |
public function getFunctions()
|
22 |
{
|
23 |
// dump is safe if var_dump is overridden by xdebug
|
24 |
-
$isDumpOutputHtmlSafe =
|
25 |
// false means that it was not set (and the default is on) or it explicitly enabled
|
26 |
&& (false === ini_get('xdebug.overload_var_dump') || ini_get('xdebug.overload_var_dump'))
|
27 |
// false means that it was not set (and the default is on) or it explicitly enabled
|
28 |
// xdebug.overload_var_dump produces HTML only when html_errors is also enabled
|
29 |
&& (false === ini_get('html_errors') || ini_get('html_errors'))
|
30 |
-
|| 'cli' ===
|
31 |
;
|
32 |
|
33 |
-
return
|
34 |
-
new
|
35 |
-
|
36 |
}
|
37 |
|
38 |
public function getName()
|
@@ -49,11 +45,11 @@ function twig_var_dump(Twig_Environment $env, $context)
|
|
49 |
|
50 |
ob_start();
|
51 |
|
52 |
-
$count =
|
53 |
if (2 === $count) {
|
54 |
-
$vars =
|
55 |
foreach ($context as $key => $value) {
|
56 |
-
if (!$value instanceof
|
57 |
$vars[$key] = $value;
|
58 |
}
|
59 |
}
|
@@ -67,5 +63,3 @@ function twig_var_dump(Twig_Environment $env, $context)
|
|
67 |
|
68 |
return ob_get_clean();
|
69 |
}
|
70 |
-
|
71 |
-
class_alias('Twig_Extension_Debug', 'Twig\Extension\DebugExtension', false);
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
|
|
|
|
12 |
/**
|
13 |
* @final
|
14 |
*/
|
15 |
+
class Twig_Extension_Debug extends Twig_Extension
|
16 |
{
|
17 |
public function getFunctions()
|
18 |
{
|
19 |
// dump is safe if var_dump is overridden by xdebug
|
20 |
+
$isDumpOutputHtmlSafe = extension_loaded('xdebug')
|
21 |
// false means that it was not set (and the default is on) or it explicitly enabled
|
22 |
&& (false === ini_get('xdebug.overload_var_dump') || ini_get('xdebug.overload_var_dump'))
|
23 |
// false means that it was not set (and the default is on) or it explicitly enabled
|
24 |
// xdebug.overload_var_dump produces HTML only when html_errors is also enabled
|
25 |
&& (false === ini_get('html_errors') || ini_get('html_errors'))
|
26 |
+
|| 'cli' === php_sapi_name()
|
27 |
;
|
28 |
|
29 |
+
return array(
|
30 |
+
new Twig_SimpleFunction('dump', 'twig_var_dump', array('is_safe' => $isDumpOutputHtmlSafe ? array('html') : array(), 'needs_context' => true, 'needs_environment' => true)),
|
31 |
+
);
|
32 |
}
|
33 |
|
34 |
public function getName()
|
45 |
|
46 |
ob_start();
|
47 |
|
48 |
+
$count = func_num_args();
|
49 |
if (2 === $count) {
|
50 |
+
$vars = array();
|
51 |
foreach ($context as $key => $value) {
|
52 |
+
if (!$value instanceof Twig_Template) {
|
53 |
$vars[$key] = $value;
|
54 |
}
|
55 |
}
|
63 |
|
64 |
return ob_get_clean();
|
65 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Extension/Escaper.php
CHANGED
@@ -9,15 +9,10 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Extension\AbstractExtension;
|
13 |
-
use Twig\NodeVisitor\EscaperNodeVisitor;
|
14 |
-
use Twig\TokenParser\AutoEscapeTokenParser;
|
15 |
-
use Twig\TwigFilter;
|
16 |
-
|
17 |
/**
|
18 |
* @final
|
19 |
*/
|
20 |
-
class Twig_Extension_Escaper extends
|
21 |
{
|
22 |
protected $defaultStrategy;
|
23 |
|
@@ -33,19 +28,19 @@ class Twig_Extension_Escaper extends AbstractExtension
|
|
33 |
|
34 |
public function getTokenParsers()
|
35 |
{
|
36 |
-
return
|
37 |
}
|
38 |
|
39 |
public function getNodeVisitors()
|
40 |
{
|
41 |
-
return
|
42 |
}
|
43 |
|
44 |
public function getFilters()
|
45 |
{
|
46 |
-
return
|
47 |
-
new
|
48 |
-
|
49 |
}
|
50 |
|
51 |
/**
|
@@ -72,7 +67,7 @@ class Twig_Extension_Escaper extends AbstractExtension
|
|
72 |
}
|
73 |
|
74 |
if ('name' === $defaultStrategy) {
|
75 |
-
$defaultStrategy =
|
76 |
}
|
77 |
|
78 |
$this->defaultStrategy = $defaultStrategy;
|
@@ -89,8 +84,8 @@ class Twig_Extension_Escaper extends AbstractExtension
|
|
89 |
{
|
90 |
// disable string callables to avoid calling a function named html or js,
|
91 |
// or any other upcoming escaping strategy
|
92 |
-
if (
|
93 |
-
return
|
94 |
}
|
95 |
|
96 |
return $this->defaultStrategy;
|
@@ -113,5 +108,3 @@ function twig_raw_filter($string)
|
|
113 |
{
|
114 |
return $string;
|
115 |
}
|
116 |
-
|
117 |
-
class_alias('Twig_Extension_Escaper', 'Twig\Extension\EscaperExtension', false);
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
|
|
|
|
|
|
12 |
/**
|
13 |
* @final
|
14 |
*/
|
15 |
+
class Twig_Extension_Escaper extends Twig_Extension
|
16 |
{
|
17 |
protected $defaultStrategy;
|
18 |
|
28 |
|
29 |
public function getTokenParsers()
|
30 |
{
|
31 |
+
return array(new Twig_TokenParser_AutoEscape());
|
32 |
}
|
33 |
|
34 |
public function getNodeVisitors()
|
35 |
{
|
36 |
+
return array(new Twig_NodeVisitor_Escaper());
|
37 |
}
|
38 |
|
39 |
public function getFilters()
|
40 |
{
|
41 |
+
return array(
|
42 |
+
new Twig_SimpleFilter('raw', 'twig_raw_filter', array('is_safe' => array('all'))),
|
43 |
+
);
|
44 |
}
|
45 |
|
46 |
/**
|
67 |
}
|
68 |
|
69 |
if ('name' === $defaultStrategy) {
|
70 |
+
$defaultStrategy = array('Twig_FileExtensionEscapingStrategy', 'guess');
|
71 |
}
|
72 |
|
73 |
$this->defaultStrategy = $defaultStrategy;
|
84 |
{
|
85 |
// disable string callables to avoid calling a function named html or js,
|
86 |
// or any other upcoming escaping strategy
|
87 |
+
if (!is_string($this->defaultStrategy) && false !== $this->defaultStrategy) {
|
88 |
+
return call_user_func($this->defaultStrategy, $name);
|
89 |
}
|
90 |
|
91 |
return $this->defaultStrategy;
|
108 |
{
|
109 |
return $string;
|
110 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Extension/GlobalsInterface.php
CHANGED
@@ -10,7 +10,7 @@
|
|
10 |
*/
|
11 |
|
12 |
/**
|
13 |
-
* Enables usage of the deprecated
|
14 |
*
|
15 |
* Explicitly implement this interface if you really need to implement the
|
16 |
* deprecated getGlobals() method in your extensions.
|
@@ -20,5 +20,3 @@
|
|
20 |
interface Twig_Extension_GlobalsInterface
|
21 |
{
|
22 |
}
|
23 |
-
|
24 |
-
class_alias('Twig_Extension_GlobalsInterface', 'Twig\Extension\GlobalsInterface', false);
|
10 |
*/
|
11 |
|
12 |
/**
|
13 |
+
* Enables usage of the deprecated Twig_Extension::getGlobals() method.
|
14 |
*
|
15 |
* Explicitly implement this interface if you really need to implement the
|
16 |
* deprecated getGlobals() method in your extensions.
|
20 |
interface Twig_Extension_GlobalsInterface
|
21 |
{
|
22 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Extension/InitRuntimeInterface.php
CHANGED
@@ -10,7 +10,7 @@
|
|
10 |
*/
|
11 |
|
12 |
/**
|
13 |
-
* Enables usage of the deprecated
|
14 |
*
|
15 |
* Explicitly implement this interface if you really need to implement the
|
16 |
* deprecated initRuntime() method in your extensions.
|
@@ -20,5 +20,3 @@
|
|
20 |
interface Twig_Extension_InitRuntimeInterface
|
21 |
{
|
22 |
}
|
23 |
-
|
24 |
-
class_alias('Twig_Extension_InitRuntimeInterface', 'Twig\Extension\InitRuntimeInterface', false);
|
10 |
*/
|
11 |
|
12 |
/**
|
13 |
+
* Enables usage of the deprecated Twig_Extension::initRuntime() method.
|
14 |
*
|
15 |
* Explicitly implement this interface if you really need to implement the
|
16 |
* deprecated initRuntime() method in your extensions.
|
20 |
interface Twig_Extension_InitRuntimeInterface
|
21 |
{
|
22 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Extension/Optimizer.php
CHANGED
@@ -9,13 +9,10 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Extension\AbstractExtension;
|
13 |
-
use Twig\NodeVisitor\OptimizerNodeVisitor;
|
14 |
-
|
15 |
/**
|
16 |
* @final
|
17 |
*/
|
18 |
-
class Twig_Extension_Optimizer extends
|
19 |
{
|
20 |
protected $optimizers;
|
21 |
|
@@ -26,7 +23,7 @@ class Twig_Extension_Optimizer extends AbstractExtension
|
|
26 |
|
27 |
public function getNodeVisitors()
|
28 |
{
|
29 |
-
return
|
30 |
}
|
31 |
|
32 |
public function getName()
|
@@ -34,5 +31,3 @@ class Twig_Extension_Optimizer extends AbstractExtension
|
|
34 |
return 'optimizer';
|
35 |
}
|
36 |
}
|
37 |
-
|
38 |
-
class_alias('Twig_Extension_Optimizer', 'Twig\Extension\OptimizerExtension', false);
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
|
|
12 |
/**
|
13 |
* @final
|
14 |
*/
|
15 |
+
class Twig_Extension_Optimizer extends Twig_Extension
|
16 |
{
|
17 |
protected $optimizers;
|
18 |
|
23 |
|
24 |
public function getNodeVisitors()
|
25 |
{
|
26 |
+
return array(new Twig_NodeVisitor_Optimizer($this->optimizers));
|
27 |
}
|
28 |
|
29 |
public function getName()
|
31 |
return 'optimizer';
|
32 |
}
|
33 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Extension/Profiler.php
CHANGED
@@ -9,38 +9,34 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
|
13 |
-
use Twig\Profiler\NodeVisitor\ProfilerNodeVisitor;
|
14 |
-
use Twig\Profiler\Profile;
|
15 |
-
|
16 |
-
class Twig_Extension_Profiler extends AbstractExtension
|
17 |
{
|
18 |
-
private $actives =
|
19 |
|
20 |
-
public function __construct(
|
21 |
{
|
22 |
$this->actives[] = $profile;
|
23 |
}
|
24 |
|
25 |
-
public function enter(
|
26 |
{
|
27 |
$this->actives[0]->addProfile($profile);
|
28 |
array_unshift($this->actives, $profile);
|
29 |
}
|
30 |
|
31 |
-
public function leave(
|
32 |
{
|
33 |
$profile->leave();
|
34 |
array_shift($this->actives);
|
35 |
|
36 |
-
if (1 ===
|
37 |
$this->actives[0]->leave();
|
38 |
}
|
39 |
}
|
40 |
|
41 |
public function getNodeVisitors()
|
42 |
{
|
43 |
-
return
|
44 |
}
|
45 |
|
46 |
public function getName()
|
@@ -48,6 +44,3 @@ class Twig_Extension_Profiler extends AbstractExtension
|
|
48 |
return 'profiler';
|
49 |
}
|
50 |
}
|
51 |
-
|
52 |
-
class_alias('Twig_Extension_Profiler', 'Twig\Extension\ProfilerExtension', false);
|
53 |
-
class_exists('Twig_Profiler_Profile');
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
+
class Twig_Extension_Profiler extends Twig_Extension
|
|
|
|
|
|
|
|
|
13 |
{
|
14 |
+
private $actives = array();
|
15 |
|
16 |
+
public function __construct(Twig_Profiler_Profile $profile)
|
17 |
{
|
18 |
$this->actives[] = $profile;
|
19 |
}
|
20 |
|
21 |
+
public function enter(Twig_Profiler_Profile $profile)
|
22 |
{
|
23 |
$this->actives[0]->addProfile($profile);
|
24 |
array_unshift($this->actives, $profile);
|
25 |
}
|
26 |
|
27 |
+
public function leave(Twig_Profiler_Profile $profile)
|
28 |
{
|
29 |
$profile->leave();
|
30 |
array_shift($this->actives);
|
31 |
|
32 |
+
if (1 === count($this->actives)) {
|
33 |
$this->actives[0]->leave();
|
34 |
}
|
35 |
}
|
36 |
|
37 |
public function getNodeVisitors()
|
38 |
{
|
39 |
+
return array(new Twig_Profiler_NodeVisitor_Profiler(get_class($this)));
|
40 |
}
|
41 |
|
42 |
public function getName()
|
44 |
return 'profiler';
|
45 |
}
|
46 |
}
|
|
|
|
|
|
vendor/twig/twig/lib/Twig/Extension/Sandbox.php
CHANGED
@@ -9,21 +9,16 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Extension\AbstractExtension;
|
13 |
-
use Twig\NodeVisitor\SandboxNodeVisitor;
|
14 |
-
use Twig\Sandbox\SecurityPolicyInterface;
|
15 |
-
use Twig\TokenParser\SandboxTokenParser;
|
16 |
-
|
17 |
/**
|
18 |
* @final
|
19 |
*/
|
20 |
-
class Twig_Extension_Sandbox extends
|
21 |
{
|
22 |
protected $sandboxedGlobally;
|
23 |
protected $sandboxed;
|
24 |
protected $policy;
|
25 |
|
26 |
-
public function __construct(
|
27 |
{
|
28 |
$this->policy = $policy;
|
29 |
$this->sandboxedGlobally = $sandboxed;
|
@@ -31,12 +26,12 @@ class Twig_Extension_Sandbox extends AbstractExtension
|
|
31 |
|
32 |
public function getTokenParsers()
|
33 |
{
|
34 |
-
return
|
35 |
}
|
36 |
|
37 |
public function getNodeVisitors()
|
38 |
{
|
39 |
-
return
|
40 |
}
|
41 |
|
42 |
public function enableSandbox()
|
@@ -59,7 +54,7 @@ class Twig_Extension_Sandbox extends AbstractExtension
|
|
59 |
return $this->sandboxedGlobally;
|
60 |
}
|
61 |
|
62 |
-
public function setSecurityPolicy(
|
63 |
{
|
64 |
$this->policy = $policy;
|
65 |
}
|
@@ -92,7 +87,7 @@ class Twig_Extension_Sandbox extends AbstractExtension
|
|
92 |
|
93 |
public function ensureToStringAllowed($obj)
|
94 |
{
|
95 |
-
if ($this->isSandboxed() &&
|
96 |
$this->policy->checkMethodAllowed($obj, '__toString');
|
97 |
}
|
98 |
|
@@ -104,5 +99,3 @@ class Twig_Extension_Sandbox extends AbstractExtension
|
|
104 |
return 'sandbox';
|
105 |
}
|
106 |
}
|
107 |
-
|
108 |
-
class_alias('Twig_Extension_Sandbox', 'Twig\Extension\SandboxExtension', false);
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
|
|
|
|
|
|
12 |
/**
|
13 |
* @final
|
14 |
*/
|
15 |
+
class Twig_Extension_Sandbox extends Twig_Extension
|
16 |
{
|
17 |
protected $sandboxedGlobally;
|
18 |
protected $sandboxed;
|
19 |
protected $policy;
|
20 |
|
21 |
+
public function __construct(Twig_Sandbox_SecurityPolicyInterface $policy, $sandboxed = false)
|
22 |
{
|
23 |
$this->policy = $policy;
|
24 |
$this->sandboxedGlobally = $sandboxed;
|
26 |
|
27 |
public function getTokenParsers()
|
28 |
{
|
29 |
+
return array(new Twig_TokenParser_Sandbox());
|
30 |
}
|
31 |
|
32 |
public function getNodeVisitors()
|
33 |
{
|
34 |
+
return array(new Twig_NodeVisitor_Sandbox());
|
35 |
}
|
36 |
|
37 |
public function enableSandbox()
|
54 |
return $this->sandboxedGlobally;
|
55 |
}
|
56 |
|
57 |
+
public function setSecurityPolicy(Twig_Sandbox_SecurityPolicyInterface $policy)
|
58 |
{
|
59 |
$this->policy = $policy;
|
60 |
}
|
87 |
|
88 |
public function ensureToStringAllowed($obj)
|
89 |
{
|
90 |
+
if ($this->isSandboxed() && is_object($obj)) {
|
91 |
$this->policy->checkMethodAllowed($obj, '__toString');
|
92 |
}
|
93 |
|
99 |
return 'sandbox';
|
100 |
}
|
101 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Extension/Staging.php
CHANGED
@@ -9,10 +9,6 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Extension\AbstractExtension;
|
13 |
-
use Twig\NodeVisitor\NodeVisitorInterface;
|
14 |
-
use Twig\TokenParser\TokenParserInterface;
|
15 |
-
|
16 |
/**
|
17 |
* Internal class.
|
18 |
*
|
@@ -22,14 +18,14 @@ use Twig\TokenParser\TokenParserInterface;
|
|
22 |
*
|
23 |
* @internal
|
24 |
*/
|
25 |
-
class Twig_Extension_Staging extends
|
26 |
{
|
27 |
-
protected $functions =
|
28 |
-
protected $filters =
|
29 |
-
protected $visitors =
|
30 |
-
protected $tokenParsers =
|
31 |
-
protected $globals =
|
32 |
-
protected $tests =
|
33 |
|
34 |
public function addFunction($name, $function)
|
35 |
{
|
@@ -59,7 +55,7 @@ class Twig_Extension_Staging extends AbstractExtension
|
|
59 |
return $this->filters;
|
60 |
}
|
61 |
|
62 |
-
public function addNodeVisitor(
|
63 |
{
|
64 |
$this->visitors[] = $visitor;
|
65 |
}
|
@@ -69,7 +65,7 @@ class Twig_Extension_Staging extends AbstractExtension
|
|
69 |
return $this->visitors;
|
70 |
}
|
71 |
|
72 |
-
public function addTokenParser(
|
73 |
{
|
74 |
if (isset($this->tokenParsers[$parser->getTag()])) {
|
75 |
@trigger_error(sprintf('Overriding tag "%s" that is already registered is deprecated since version 1.30 and won\'t be possible anymore in 2.0.', $parser->getTag()), E_USER_DEPRECATED);
|
@@ -112,5 +108,3 @@ class Twig_Extension_Staging extends AbstractExtension
|
|
112 |
return 'staging';
|
113 |
}
|
114 |
}
|
115 |
-
|
116 |
-
class_alias('Twig_Extension_Staging', 'Twig\Extension\StagingExtension', false);
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
|
|
|
|
12 |
/**
|
13 |
* Internal class.
|
14 |
*
|
18 |
*
|
19 |
* @internal
|
20 |
*/
|
21 |
+
class Twig_Extension_Staging extends Twig_Extension
|
22 |
{
|
23 |
+
protected $functions = array();
|
24 |
+
protected $filters = array();
|
25 |
+
protected $visitors = array();
|
26 |
+
protected $tokenParsers = array();
|
27 |
+
protected $globals = array();
|
28 |
+
protected $tests = array();
|
29 |
|
30 |
public function addFunction($name, $function)
|
31 |
{
|
55 |
return $this->filters;
|
56 |
}
|
57 |
|
58 |
+
public function addNodeVisitor(Twig_NodeVisitorInterface $visitor)
|
59 |
{
|
60 |
$this->visitors[] = $visitor;
|
61 |
}
|
65 |
return $this->visitors;
|
66 |
}
|
67 |
|
68 |
+
public function addTokenParser(Twig_TokenParserInterface $parser)
|
69 |
{
|
70 |
if (isset($this->tokenParsers[$parser->getTag()])) {
|
71 |
@trigger_error(sprintf('Overriding tag "%s" that is already registered is deprecated since version 1.30 and won\'t be possible anymore in 2.0.', $parser->getTag()), E_USER_DEPRECATED);
|
108 |
return 'staging';
|
109 |
}
|
110 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Extension/StringLoader.php
CHANGED
@@ -9,20 +9,16 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Extension\AbstractExtension;
|
13 |
-
use Twig\Template;
|
14 |
-
use Twig\TwigFunction;
|
15 |
-
|
16 |
/**
|
17 |
* @final
|
18 |
*/
|
19 |
-
class Twig_Extension_StringLoader extends
|
20 |
{
|
21 |
public function getFunctions()
|
22 |
{
|
23 |
-
return
|
24 |
-
new
|
25 |
-
|
26 |
}
|
27 |
|
28 |
public function getName()
|
@@ -34,15 +30,16 @@ class Twig_Extension_StringLoader extends AbstractExtension
|
|
34 |
/**
|
35 |
* Loads a template from a string.
|
36 |
*
|
37 |
-
*
|
|
|
|
|
38 |
*
|
39 |
-
* @param
|
|
|
40 |
*
|
41 |
-
* @return
|
42 |
*/
|
43 |
function twig_template_from_string(Twig_Environment $env, $template)
|
44 |
{
|
45 |
return $env->createTemplate((string) $template);
|
46 |
}
|
47 |
-
|
48 |
-
class_alias('Twig_Extension_StringLoader', 'Twig\Extension\StringLoaderExtension', false);
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
|
|
|
|
12 |
/**
|
13 |
* @final
|
14 |
*/
|
15 |
+
class Twig_Extension_StringLoader extends Twig_Extension
|
16 |
{
|
17 |
public function getFunctions()
|
18 |
{
|
19 |
+
return array(
|
20 |
+
new Twig_SimpleFunction('template_from_string', 'twig_template_from_string', array('needs_environment' => true)),
|
21 |
+
);
|
22 |
}
|
23 |
|
24 |
public function getName()
|
30 |
/**
|
31 |
* Loads a template from a string.
|
32 |
*
|
33 |
+
* <pre>
|
34 |
+
* {{ include(template_from_string("Hello {{ name }}")) }}
|
35 |
+
* </pre>
|
36 |
*
|
37 |
+
* @param Twig_Environment $env A Twig_Environment instance
|
38 |
+
* @param string $template A template as a string or object implementing __toString()
|
39 |
*
|
40 |
+
* @return Twig_Template
|
41 |
*/
|
42 |
function twig_template_from_string(Twig_Environment $env, $template)
|
43 |
{
|
44 |
return $env->createTemplate((string) $template);
|
45 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/ExtensionInterface.php
CHANGED
@@ -9,13 +9,6 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Environment;
|
13 |
-
use Twig\NodeVisitor\NodeVisitorInterface;
|
14 |
-
use Twig\TokenParser\TokenParserInterface;
|
15 |
-
use Twig\TwigFilter;
|
16 |
-
use Twig\TwigFunction;
|
17 |
-
use Twig\TwigTest;
|
18 |
-
|
19 |
/**
|
20 |
* Interface implemented by extension classes.
|
21 |
*
|
@@ -30,40 +23,40 @@ interface Twig_ExtensionInterface
|
|
30 |
*
|
31 |
* @deprecated since 1.23 (to be removed in 2.0), implement Twig_Extension_InitRuntimeInterface instead
|
32 |
*/
|
33 |
-
public function initRuntime(
|
34 |
|
35 |
/**
|
36 |
* Returns the token parser instances to add to the existing list.
|
37 |
*
|
38 |
-
* @return
|
39 |
*/
|
40 |
public function getTokenParsers();
|
41 |
|
42 |
/**
|
43 |
* Returns the node visitor instances to add to the existing list.
|
44 |
*
|
45 |
-
* @return
|
46 |
*/
|
47 |
public function getNodeVisitors();
|
48 |
|
49 |
/**
|
50 |
* Returns a list of filters to add to the existing list.
|
51 |
*
|
52 |
-
* @return
|
53 |
*/
|
54 |
public function getFilters();
|
55 |
|
56 |
/**
|
57 |
* Returns a list of tests to add to the existing list.
|
58 |
*
|
59 |
-
* @return
|
60 |
*/
|
61 |
public function getTests();
|
62 |
|
63 |
/**
|
64 |
* Returns a list of functions to add to the existing list.
|
65 |
*
|
66 |
-
* @return
|
67 |
*/
|
68 |
public function getFunctions();
|
69 |
|
@@ -92,6 +85,3 @@ interface Twig_ExtensionInterface
|
|
92 |
*/
|
93 |
public function getName();
|
94 |
}
|
95 |
-
|
96 |
-
class_alias('Twig_ExtensionInterface', 'Twig\Extension\ExtensionInterface', false);
|
97 |
-
class_exists('Twig_Environment');
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
/**
|
13 |
* Interface implemented by extension classes.
|
14 |
*
|
23 |
*
|
24 |
* @deprecated since 1.23 (to be removed in 2.0), implement Twig_Extension_InitRuntimeInterface instead
|
25 |
*/
|
26 |
+
public function initRuntime(Twig_Environment $environment);
|
27 |
|
28 |
/**
|
29 |
* Returns the token parser instances to add to the existing list.
|
30 |
*
|
31 |
+
* @return Twig_TokenParserInterface[]
|
32 |
*/
|
33 |
public function getTokenParsers();
|
34 |
|
35 |
/**
|
36 |
* Returns the node visitor instances to add to the existing list.
|
37 |
*
|
38 |
+
* @return Twig_NodeVisitorInterface[]
|
39 |
*/
|
40 |
public function getNodeVisitors();
|
41 |
|
42 |
/**
|
43 |
* Returns a list of filters to add to the existing list.
|
44 |
*
|
45 |
+
* @return Twig_SimpleFilter[]
|
46 |
*/
|
47 |
public function getFilters();
|
48 |
|
49 |
/**
|
50 |
* Returns a list of tests to add to the existing list.
|
51 |
*
|
52 |
+
* @return Twig_SimpleTest[]
|
53 |
*/
|
54 |
public function getTests();
|
55 |
|
56 |
/**
|
57 |
* Returns a list of functions to add to the existing list.
|
58 |
*
|
59 |
+
* @return Twig_SimpleFunction[]
|
60 |
*/
|
61 |
public function getFunctions();
|
62 |
|
85 |
*/
|
86 |
public function getName();
|
87 |
}
|
|
|
|
|
|
vendor/twig/twig/lib/Twig/FactoryRuntimeLoader.php
CHANGED
@@ -9,21 +9,19 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\RuntimeLoader\RuntimeLoaderInterface;
|
13 |
-
|
14 |
/**
|
15 |
* Lazy loads the runtime implementations for a Twig element.
|
16 |
*
|
17 |
* @author Robin Chalas <robin.chalas@gmail.com>
|
18 |
*/
|
19 |
-
class Twig_FactoryRuntimeLoader implements
|
20 |
{
|
21 |
private $map;
|
22 |
|
23 |
/**
|
24 |
* @param array $map An array where keys are class names and values factory callables
|
25 |
*/
|
26 |
-
public function __construct($map =
|
27 |
{
|
28 |
$this->map = $map;
|
29 |
}
|
@@ -37,5 +35,3 @@ class Twig_FactoryRuntimeLoader implements RuntimeLoaderInterface
|
|
37 |
}
|
38 |
}
|
39 |
}
|
40 |
-
|
41 |
-
class_alias('Twig_FactoryRuntimeLoader', 'Twig\RuntimeLoader\FactoryRuntimeLoader', false);
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
12 |
/**
|
13 |
* Lazy loads the runtime implementations for a Twig element.
|
14 |
*
|
15 |
* @author Robin Chalas <robin.chalas@gmail.com>
|
16 |
*/
|
17 |
+
class Twig_FactoryRuntimeLoader implements Twig_RuntimeLoaderInterface
|
18 |
{
|
19 |
private $map;
|
20 |
|
21 |
/**
|
22 |
* @param array $map An array where keys are class names and values factory callables
|
23 |
*/
|
24 |
+
public function __construct($map = array())
|
25 |
{
|
26 |
$this->map = $map;
|
27 |
}
|
35 |
}
|
36 |
}
|
37 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/FileExtensionEscapingStrategy.php
CHANGED
@@ -31,7 +31,7 @@ class Twig_FileExtensionEscapingStrategy
|
|
31 |
*/
|
32 |
public static function guess($name)
|
33 |
{
|
34 |
-
if (
|
35 |
return 'html'; // return html for directories
|
36 |
}
|
37 |
|
@@ -56,5 +56,3 @@ class Twig_FileExtensionEscapingStrategy
|
|
56 |
}
|
57 |
}
|
58 |
}
|
59 |
-
|
60 |
-
class_alias('Twig_FileExtensionEscapingStrategy', 'Twig\FileExtensionEscapingStrategy', false);
|
31 |
*/
|
32 |
public static function guess($name)
|
33 |
{
|
34 |
+
if (in_array(substr($name, -1), array('/', '\\'))) {
|
35 |
return 'html'; // return html for directories
|
36 |
}
|
37 |
|
56 |
}
|
57 |
}
|
58 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Filter.php
CHANGED
@@ -9,8 +9,6 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Node\Node;
|
13 |
-
|
14 |
@trigger_error('The Twig_Filter class is deprecated since version 1.12 and will be removed in 2.0. Use Twig_SimpleFilter instead.', E_USER_DEPRECATED);
|
15 |
|
16 |
/**
|
@@ -25,17 +23,17 @@ use Twig\Node\Node;
|
|
25 |
abstract class Twig_Filter implements Twig_FilterInterface, Twig_FilterCallableInterface
|
26 |
{
|
27 |
protected $options;
|
28 |
-
protected $arguments =
|
29 |
|
30 |
-
public function __construct(array $options =
|
31 |
{
|
32 |
-
$this->options = array_merge(
|
33 |
'needs_environment' => false,
|
34 |
'needs_context' => false,
|
35 |
'pre_escape' => null,
|
36 |
'preserves_safety' => null,
|
37 |
'callable' => null,
|
38 |
-
|
39 |
}
|
40 |
|
41 |
public function setArguments($arguments)
|
@@ -58,14 +56,14 @@ abstract class Twig_Filter implements Twig_FilterInterface, Twig_FilterCallableI
|
|
58 |
return $this->options['needs_context'];
|
59 |
}
|
60 |
|
61 |
-
public function getSafe(
|
62 |
{
|
63 |
if (isset($this->options['is_safe'])) {
|
64 |
return $this->options['is_safe'];
|
65 |
}
|
66 |
|
67 |
if (isset($this->options['is_safe_callback'])) {
|
68 |
-
return
|
69 |
}
|
70 |
}
|
71 |
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
12 |
@trigger_error('The Twig_Filter class is deprecated since version 1.12 and will be removed in 2.0. Use Twig_SimpleFilter instead.', E_USER_DEPRECATED);
|
13 |
|
14 |
/**
|
23 |
abstract class Twig_Filter implements Twig_FilterInterface, Twig_FilterCallableInterface
|
24 |
{
|
25 |
protected $options;
|
26 |
+
protected $arguments = array();
|
27 |
|
28 |
+
public function __construct(array $options = array())
|
29 |
{
|
30 |
+
$this->options = array_merge(array(
|
31 |
'needs_environment' => false,
|
32 |
'needs_context' => false,
|
33 |
'pre_escape' => null,
|
34 |
'preserves_safety' => null,
|
35 |
'callable' => null,
|
36 |
+
), $options);
|
37 |
}
|
38 |
|
39 |
public function setArguments($arguments)
|
56 |
return $this->options['needs_context'];
|
57 |
}
|
58 |
|
59 |
+
public function getSafe(Twig_Node $filterArgs)
|
60 |
{
|
61 |
if (isset($this->options['is_safe'])) {
|
62 |
return $this->options['is_safe'];
|
63 |
}
|
64 |
|
65 |
if (isset($this->options['is_safe_callback'])) {
|
66 |
+
return call_user_func($this->options['is_safe_callback'], $filterArgs);
|
67 |
}
|
68 |
}
|
69 |
|
vendor/twig/twig/lib/Twig/Filter/Function.php
CHANGED
@@ -24,7 +24,7 @@ class Twig_Filter_Function extends Twig_Filter
|
|
24 |
{
|
25 |
protected $function;
|
26 |
|
27 |
-
public function __construct($function, array $options =
|
28 |
{
|
29 |
$options['callable'] = $function;
|
30 |
|
24 |
{
|
25 |
protected $function;
|
26 |
|
27 |
+
public function __construct($function, array $options = array())
|
28 |
{
|
29 |
$options['callable'] = $function;
|
30 |
|
vendor/twig/twig/lib/Twig/Filter/Method.php
CHANGED
@@ -9,8 +9,6 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Extension\ExtensionInterface;
|
13 |
-
|
14 |
@trigger_error('The Twig_Filter_Method class is deprecated since version 1.12 and will be removed in 2.0. Use Twig_SimpleFilter instead.', E_USER_DEPRECATED);
|
15 |
|
16 |
/**
|
@@ -27,9 +25,9 @@ class Twig_Filter_Method extends Twig_Filter
|
|
27 |
protected $extension;
|
28 |
protected $method;
|
29 |
|
30 |
-
public function __construct(
|
31 |
{
|
32 |
-
$options['callable'] =
|
33 |
|
34 |
parent::__construct($options);
|
35 |
|
@@ -39,6 +37,6 @@ class Twig_Filter_Method extends Twig_Filter
|
|
39 |
|
40 |
public function compile()
|
41 |
{
|
42 |
-
return sprintf('$this->env->getExtension(\'%s\')->%s',
|
43 |
}
|
44 |
}
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
12 |
@trigger_error('The Twig_Filter_Method class is deprecated since version 1.12 and will be removed in 2.0. Use Twig_SimpleFilter instead.', E_USER_DEPRECATED);
|
13 |
|
14 |
/**
|
25 |
protected $extension;
|
26 |
protected $method;
|
27 |
|
28 |
+
public function __construct(Twig_ExtensionInterface $extension, $method, array $options = array())
|
29 |
{
|
30 |
+
$options['callable'] = array($extension, $method);
|
31 |
|
32 |
parent::__construct($options);
|
33 |
|
37 |
|
38 |
public function compile()
|
39 |
{
|
40 |
+
return sprintf('$this->env->getExtension(\'%s\')->%s', get_class($this->extension), $this->method);
|
41 |
}
|
42 |
}
|
vendor/twig/twig/lib/Twig/Filter/Node.php
CHANGED
@@ -24,7 +24,7 @@ class Twig_Filter_Node extends Twig_Filter
|
|
24 |
{
|
25 |
protected $class;
|
26 |
|
27 |
-
public function __construct($class, array $options =
|
28 |
{
|
29 |
parent::__construct($options);
|
30 |
|
24 |
{
|
25 |
protected $class;
|
26 |
|
27 |
+
public function __construct($class, array $options = array())
|
28 |
{
|
29 |
parent::__construct($options);
|
30 |
|
vendor/twig/twig/lib/Twig/FilterInterface.php
CHANGED
@@ -9,8 +9,6 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Node\Node;
|
13 |
-
|
14 |
/**
|
15 |
* Represents a template filter.
|
16 |
*
|
@@ -33,7 +31,7 @@ interface Twig_FilterInterface
|
|
33 |
|
34 |
public function needsContext();
|
35 |
|
36 |
-
public function getSafe(
|
37 |
|
38 |
public function getPreservesSafety();
|
39 |
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
12 |
/**
|
13 |
* Represents a template filter.
|
14 |
*
|
31 |
|
32 |
public function needsContext();
|
33 |
|
34 |
+
public function getSafe(Twig_Node $filterArgs);
|
35 |
|
36 |
public function getPreservesSafety();
|
37 |
|
vendor/twig/twig/lib/Twig/Function.php
CHANGED
@@ -9,8 +9,6 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Node\Node;
|
13 |
-
|
14 |
@trigger_error('The Twig_Function class is deprecated since version 1.12 and will be removed in 2.0. Use Twig_SimpleFunction instead.', E_USER_DEPRECATED);
|
15 |
|
16 |
/**
|
@@ -25,15 +23,15 @@ use Twig\Node\Node;
|
|
25 |
abstract class Twig_Function implements Twig_FunctionInterface, Twig_FunctionCallableInterface
|
26 |
{
|
27 |
protected $options;
|
28 |
-
protected $arguments =
|
29 |
|
30 |
-
public function __construct(array $options =
|
31 |
{
|
32 |
-
$this->options = array_merge(
|
33 |
'needs_environment' => false,
|
34 |
'needs_context' => false,
|
35 |
'callable' => null,
|
36 |
-
|
37 |
}
|
38 |
|
39 |
public function setArguments($arguments)
|
@@ -56,17 +54,17 @@ abstract class Twig_Function implements Twig_FunctionInterface, Twig_FunctionCal
|
|
56 |
return $this->options['needs_context'];
|
57 |
}
|
58 |
|
59 |
-
public function getSafe(
|
60 |
{
|
61 |
if (isset($this->options['is_safe'])) {
|
62 |
return $this->options['is_safe'];
|
63 |
}
|
64 |
|
65 |
if (isset($this->options['is_safe_callback'])) {
|
66 |
-
return
|
67 |
}
|
68 |
|
69 |
-
return
|
70 |
}
|
71 |
|
72 |
public function getCallable()
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
12 |
@trigger_error('The Twig_Function class is deprecated since version 1.12 and will be removed in 2.0. Use Twig_SimpleFunction instead.', E_USER_DEPRECATED);
|
13 |
|
14 |
/**
|
23 |
abstract class Twig_Function implements Twig_FunctionInterface, Twig_FunctionCallableInterface
|
24 |
{
|
25 |
protected $options;
|
26 |
+
protected $arguments = array();
|
27 |
|
28 |
+
public function __construct(array $options = array())
|
29 |
{
|
30 |
+
$this->options = array_merge(array(
|
31 |
'needs_environment' => false,
|
32 |
'needs_context' => false,
|
33 |
'callable' => null,
|
34 |
+
), $options);
|
35 |
}
|
36 |
|
37 |
public function setArguments($arguments)
|
54 |
return $this->options['needs_context'];
|
55 |
}
|
56 |
|
57 |
+
public function getSafe(Twig_Node $functionArgs)
|
58 |
{
|
59 |
if (isset($this->options['is_safe'])) {
|
60 |
return $this->options['is_safe'];
|
61 |
}
|
62 |
|
63 |
if (isset($this->options['is_safe_callback'])) {
|
64 |
+
return call_user_func($this->options['is_safe_callback'], $functionArgs);
|
65 |
}
|
66 |
|
67 |
+
return array();
|
68 |
}
|
69 |
|
70 |
public function getCallable()
|
vendor/twig/twig/lib/Twig/Function/Function.php
CHANGED
@@ -25,7 +25,7 @@ class Twig_Function_Function extends Twig_Function
|
|
25 |
{
|
26 |
protected $function;
|
27 |
|
28 |
-
public function __construct($function, array $options =
|
29 |
{
|
30 |
$options['callable'] = $function;
|
31 |
|
25 |
{
|
26 |
protected $function;
|
27 |
|
28 |
+
public function __construct($function, array $options = array())
|
29 |
{
|
30 |
$options['callable'] = $function;
|
31 |
|
vendor/twig/twig/lib/Twig/Function/Method.php
CHANGED
@@ -10,8 +10,6 @@
|
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
|
13 |
-
use Twig\Extension\ExtensionInterface;
|
14 |
-
|
15 |
@trigger_error('The Twig_Function_Method class is deprecated since version 1.12 and will be removed in 2.0. Use Twig_SimpleFunction instead.', E_USER_DEPRECATED);
|
16 |
|
17 |
/**
|
@@ -28,9 +26,9 @@ class Twig_Function_Method extends Twig_Function
|
|
28 |
protected $extension;
|
29 |
protected $method;
|
30 |
|
31 |
-
public function __construct(
|
32 |
{
|
33 |
-
$options['callable'] =
|
34 |
|
35 |
parent::__construct($options);
|
36 |
|
@@ -40,6 +38,6 @@ class Twig_Function_Method extends Twig_Function
|
|
40 |
|
41 |
public function compile()
|
42 |
{
|
43 |
-
return sprintf('$this->env->getExtension(\'%s\')->%s',
|
44 |
}
|
45 |
}
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
|
|
|
|
|
13 |
@trigger_error('The Twig_Function_Method class is deprecated since version 1.12 and will be removed in 2.0. Use Twig_SimpleFunction instead.', E_USER_DEPRECATED);
|
14 |
|
15 |
/**
|
26 |
protected $extension;
|
27 |
protected $method;
|
28 |
|
29 |
+
public function __construct(Twig_ExtensionInterface $extension, $method, array $options = array())
|
30 |
{
|
31 |
+
$options['callable'] = array($extension, $method);
|
32 |
|
33 |
parent::__construct($options);
|
34 |
|
38 |
|
39 |
public function compile()
|
40 |
{
|
41 |
+
return sprintf('$this->env->getExtension(\'%s\')->%s', get_class($this->extension), $this->method);
|
42 |
}
|
43 |
}
|
vendor/twig/twig/lib/Twig/Function/Node.php
CHANGED
@@ -24,7 +24,7 @@ class Twig_Function_Node extends Twig_Function
|
|
24 |
{
|
25 |
protected $class;
|
26 |
|
27 |
-
public function __construct($class, array $options =
|
28 |
{
|
29 |
parent::__construct($options);
|
30 |
|
24 |
{
|
25 |
protected $class;
|
26 |
|
27 |
+
public function __construct($class, array $options = array())
|
28 |
{
|
29 |
parent::__construct($options);
|
30 |
|
vendor/twig/twig/lib/Twig/FunctionInterface.php
CHANGED
@@ -10,8 +10,6 @@
|
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
|
13 |
-
use Twig\Node\Node;
|
14 |
-
|
15 |
/**
|
16 |
* Represents a template function.
|
17 |
*
|
@@ -34,7 +32,7 @@ interface Twig_FunctionInterface
|
|
34 |
|
35 |
public function needsContext();
|
36 |
|
37 |
-
public function getSafe(
|
38 |
|
39 |
public function setArguments($arguments);
|
40 |
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
|
|
|
|
|
13 |
/**
|
14 |
* Represents a template function.
|
15 |
*
|
32 |
|
33 |
public function needsContext();
|
34 |
|
35 |
+
public function getSafe(Twig_Node $filterArgs);
|
36 |
|
37 |
public function setArguments($arguments);
|
38 |
|
vendor/twig/twig/lib/Twig/Lexer.php
CHANGED
@@ -10,12 +10,6 @@
|
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
|
13 |
-
use Twig\Environment;
|
14 |
-
use Twig\Error\SyntaxError;
|
15 |
-
use Twig\Source;
|
16 |
-
use Twig\Token;
|
17 |
-
use Twig\TokenStream;
|
18 |
-
|
19 |
/**
|
20 |
* Lexes a template string.
|
21 |
*
|
@@ -55,19 +49,19 @@ class Twig_Lexer implements Twig_LexerInterface
|
|
55 |
const REGEX_DQ_STRING_PART = '/[^#"\\\\]*(?:(?:\\\\.|#(?!\{))[^#"\\\\]*)*/As';
|
56 |
const PUNCTUATION = '()[]{}?:.,|';
|
57 |
|
58 |
-
public function __construct(
|
59 |
{
|
60 |
$this->env = $env;
|
61 |
|
62 |
-
$this->options = array_merge(
|
63 |
-
'tag_comment' =>
|
64 |
-
'tag_block' =>
|
65 |
-
'tag_variable' =>
|
66 |
'whitespace_trim' => '-',
|
67 |
-
'interpolation' =>
|
68 |
-
|
69 |
|
70 |
-
$this->regexes =
|
71 |
'lex_var' => '/\s*'.preg_quote($this->options['whitespace_trim'].$this->options['tag_variable'][1], '/').'\s*|\s*'.preg_quote($this->options['tag_variable'][1], '/').'/A',
|
72 |
'lex_block' => '/\s*(?:'.preg_quote($this->options['whitespace_trim'].$this->options['tag_block'][1], '/').'\s*|\s*'.preg_quote($this->options['tag_block'][1], '/').')\n?/A',
|
73 |
'lex_raw_data' => '/('.preg_quote($this->options['tag_block'][0].$this->options['whitespace_trim'], '/').'|'.preg_quote($this->options['tag_block'][0], '/').')\s*(?:end%s)\s*(?:'.preg_quote($this->options['whitespace_trim'].$this->options['tag_block'][1], '/').'\s*|\s*'.preg_quote($this->options['tag_block'][1], '/').')/s',
|
@@ -78,14 +72,14 @@ class Twig_Lexer implements Twig_LexerInterface
|
|
78 |
'lex_tokens_start' => '/('.preg_quote($this->options['tag_variable'][0], '/').'|'.preg_quote($this->options['tag_block'][0], '/').'|'.preg_quote($this->options['tag_comment'][0], '/').')('.preg_quote($this->options['whitespace_trim'], '/').')?/s',
|
79 |
'interpolation_start' => '/'.preg_quote($this->options['interpolation'][0], '/').'\s*/A',
|
80 |
'interpolation_end' => '/\s*'.preg_quote($this->options['interpolation'][1], '/').'/A',
|
81 |
-
|
82 |
}
|
83 |
|
84 |
public function tokenize($code, $name = null)
|
85 |
{
|
86 |
-
if (!$code instanceof
|
87 |
@trigger_error(sprintf('Passing a string as the $code argument of %s() is deprecated since version 1.27 and will be removed in 2.0. Pass a Twig_Source instance instead.', __METHOD__), E_USER_DEPRECATED);
|
88 |
-
$this->source = new
|
89 |
} else {
|
90 |
$this->source = $code;
|
91 |
}
|
@@ -94,22 +88,22 @@ class Twig_Lexer implements Twig_LexerInterface
|
|
94 |
@trigger_error('Support for having "mbstring.func_overload" different from 0 is deprecated version 1.29 and will be removed in 2.0.', E_USER_DEPRECATED);
|
95 |
}
|
96 |
|
97 |
-
if (
|
98 |
$mbEncoding = mb_internal_encoding();
|
99 |
mb_internal_encoding('ASCII');
|
100 |
} else {
|
101 |
$mbEncoding = null;
|
102 |
}
|
103 |
|
104 |
-
$this->code = str_replace(
|
105 |
$this->filename = $this->source->getName();
|
106 |
$this->cursor = 0;
|
107 |
$this->lineno = 1;
|
108 |
-
$this->end =
|
109 |
-
$this->tokens =
|
110 |
$this->state = self::STATE_DATA;
|
111 |
-
$this->states =
|
112 |
-
$this->brackets =
|
113 |
$this->position = -1;
|
114 |
|
115 |
// find all token starts in one go
|
@@ -142,25 +136,25 @@ class Twig_Lexer implements Twig_LexerInterface
|
|
142 |
}
|
143 |
}
|
144 |
|
145 |
-
$this->pushToken(
|
146 |
|
147 |
if (!empty($this->brackets)) {
|
148 |
list($expect, $lineno) = array_pop($this->brackets);
|
149 |
-
throw new
|
150 |
}
|
151 |
|
152 |
if ($mbEncoding) {
|
153 |
mb_internal_encoding($mbEncoding);
|
154 |
}
|
155 |
|
156 |
-
return new
|
157 |
}
|
158 |
|
159 |
protected function lexData()
|
160 |
{
|
161 |
// if no matches are left we return the rest of the template as simple text token
|
162 |
-
if ($this->position ==
|
163 |
-
$this->pushToken(
|
164 |
$this->cursor = $this->end;
|
165 |
|
166 |
return;
|
@@ -169,7 +163,7 @@ class Twig_Lexer implements Twig_LexerInterface
|
|
169 |
// Find the first token after the current cursor
|
170 |
$position = $this->positions[0][++$this->position];
|
171 |
while ($position[1] < $this->cursor) {
|
172 |
-
if ($this->position ==
|
173 |
return;
|
174 |
}
|
175 |
$position = $this->positions[0][++$this->position];
|
@@ -180,7 +174,7 @@ class Twig_Lexer implements Twig_LexerInterface
|
|
180 |
if (isset($this->positions[2][$this->position][0])) {
|
181 |
$text = rtrim($text);
|
182 |
}
|
183 |
-
$this->pushToken(
|
184 |
$this->moveCursor($textContent.$position[0]);
|
185 |
|
186 |
switch ($this->positions[1][$this->position][0]) {
|
@@ -198,14 +192,14 @@ class Twig_Lexer implements Twig_LexerInterface
|
|
198 |
$this->moveCursor($match[0]);
|
199 |
$this->lineno = (int) $match[1];
|
200 |
} else {
|
201 |
-
$this->pushToken(
|
202 |
$this->pushState(self::STATE_BLOCK);
|
203 |
$this->currentVarBlockLine = $this->lineno;
|
204 |
}
|
205 |
break;
|
206 |
|
207 |
case $this->options['tag_variable'][0]:
|
208 |
-
$this->pushToken(
|
209 |
$this->pushState(self::STATE_VAR);
|
210 |
$this->currentVarBlockLine = $this->lineno;
|
211 |
break;
|
@@ -215,7 +209,7 @@ class Twig_Lexer implements Twig_LexerInterface
|
|
215 |
protected function lexBlock()
|
216 |
{
|
217 |
if (empty($this->brackets) && preg_match($this->regexes['lex_block'], $this->code, $match, null, $this->cursor)) {
|
218 |
-
$this->pushToken(
|
219 |
$this->moveCursor($match[0]);
|
220 |
$this->popState();
|
221 |
} else {
|
@@ -226,7 +220,7 @@ class Twig_Lexer implements Twig_LexerInterface
|
|
226 |
protected function lexVar()
|
227 |
{
|
228 |
if (empty($this->brackets) && preg_match($this->regexes['lex_var'], $this->code, $match, null, $this->cursor)) {
|
229 |
-
$this->pushToken(
|
230 |
$this->moveCursor($match[0]);
|
231 |
$this->popState();
|
232 |
} else {
|
@@ -241,18 +235,18 @@ class Twig_Lexer implements Twig_LexerInterface
|
|
241 |
$this->moveCursor($match[0]);
|
242 |
|
243 |
if ($this->cursor >= $this->end) {
|
244 |
-
throw new
|
245 |
}
|
246 |
}
|
247 |
|
248 |
// operators
|
249 |
if (preg_match($this->regexes['operator'], $this->code, $match, null, $this->cursor)) {
|
250 |
-
$this->pushToken(
|
251 |
$this->moveCursor($match[0]);
|
252 |
}
|
253 |
// names
|
254 |
elseif (preg_match(self::REGEX_NAME, $this->code, $match, null, $this->cursor)) {
|
255 |
-
$this->pushToken(
|
256 |
$this->moveCursor($match[0]);
|
257 |
}
|
258 |
// numbers
|
@@ -261,44 +255,44 @@ class Twig_Lexer implements Twig_LexerInterface
|
|
261 |
if (ctype_digit($match[0]) && $number <= PHP_INT_MAX) {
|
262 |
$number = (int) $match[0]; // integers lower than the maximum
|
263 |
}
|
264 |
-
$this->pushToken(
|
265 |
$this->moveCursor($match[0]);
|
266 |
}
|
267 |
// punctuation
|
268 |
elseif (false !== strpos(self::PUNCTUATION, $this->code[$this->cursor])) {
|
269 |
// opening bracket
|
270 |
if (false !== strpos('([{', $this->code[$this->cursor])) {
|
271 |
-
$this->brackets[] =
|
272 |
}
|
273 |
// closing bracket
|
274 |
elseif (false !== strpos(')]}', $this->code[$this->cursor])) {
|
275 |
if (empty($this->brackets)) {
|
276 |
-
throw new
|
277 |
}
|
278 |
|
279 |
list($expect, $lineno) = array_pop($this->brackets);
|
280 |
if ($this->code[$this->cursor] != strtr($expect, '([{', ')]}')) {
|
281 |
-
throw new
|
282 |
}
|
283 |
}
|
284 |
|
285 |
-
$this->pushToken(
|
286 |
++$this->cursor;
|
287 |
}
|
288 |
// strings
|
289 |
elseif (preg_match(self::REGEX_STRING, $this->code, $match, null, $this->cursor)) {
|
290 |
-
$this->pushToken(
|
291 |
$this->moveCursor($match[0]);
|
292 |
}
|
293 |
// opening double quoted string
|
294 |
elseif (preg_match(self::REGEX_DQ_STRING_DELIM, $this->code, $match, null, $this->cursor)) {
|
295 |
-
$this->brackets[] =
|
296 |
$this->pushState(self::STATE_STRING);
|
297 |
$this->moveCursor($match[0]);
|
298 |
}
|
299 |
// unlexable
|
300 |
else {
|
301 |
-
throw new
|
302 |
}
|
303 |
}
|
304 |
|
@@ -309,7 +303,7 @@ class Twig_Lexer implements Twig_LexerInterface
|
|
309 |
}
|
310 |
|
311 |
if (!preg_match(str_replace('%s', $tag, $this->regexes['lex_raw_data']), $this->code, $match, PREG_OFFSET_CAPTURE, $this->cursor)) {
|
312 |
-
throw new
|
313 |
}
|
314 |
|
315 |
$text = substr($this->code, $this->cursor, $match[0][1] - $this->cursor);
|
@@ -319,13 +313,13 @@ class Twig_Lexer implements Twig_LexerInterface
|
|
319 |
$text = rtrim($text);
|
320 |
}
|
321 |
|
322 |
-
$this->pushToken(
|
323 |
}
|
324 |
|
325 |
protected function lexComment()
|
326 |
{
|
327 |
if (!preg_match($this->regexes['lex_comment'], $this->code, $match, PREG_OFFSET_CAPTURE, $this->cursor)) {
|
328 |
-
throw new
|
329 |
}
|
330 |
|
331 |
$this->moveCursor(substr($this->code, $this->cursor, $match[0][1] - $this->cursor).$match[0][0]);
|
@@ -334,24 +328,21 @@ class Twig_Lexer implements Twig_LexerInterface
|
|
334 |
protected function lexString()
|
335 |
{
|
336 |
if (preg_match($this->regexes['interpolation_start'], $this->code, $match, null, $this->cursor)) {
|
337 |
-
$this->brackets[] =
|
338 |
-
$this->pushToken(
|
339 |
$this->moveCursor($match[0]);
|
340 |
$this->pushState(self::STATE_INTERPOLATION);
|
341 |
-
} elseif (preg_match(self::REGEX_DQ_STRING_PART, $this->code, $match, null, $this->cursor) &&
|
342 |
-
$this->pushToken(
|
343 |
$this->moveCursor($match[0]);
|
344 |
} elseif (preg_match(self::REGEX_DQ_STRING_DELIM, $this->code, $match, null, $this->cursor)) {
|
345 |
list($expect, $lineno) = array_pop($this->brackets);
|
346 |
-
if (
|
347 |
-
throw new
|
348 |
}
|
349 |
|
350 |
$this->popState();
|
351 |
++$this->cursor;
|
352 |
-
} else {
|
353 |
-
// unlexable
|
354 |
-
throw new SyntaxError(sprintf('Unexpected character "%s".', $this->code[$this->cursor]), $this->lineno, $this->source);
|
355 |
}
|
356 |
}
|
357 |
|
@@ -360,7 +351,7 @@ class Twig_Lexer implements Twig_LexerInterface
|
|
360 |
$bracket = end($this->brackets);
|
361 |
if ($this->options['interpolation'][0] === $bracket[0] && preg_match($this->regexes['interpolation_end'], $this->code, $match, null, $this->cursor)) {
|
362 |
array_pop($this->brackets);
|
363 |
-
$this->pushToken(
|
364 |
$this->moveCursor($match[0]);
|
365 |
$this->popState();
|
366 |
} else {
|
@@ -371,23 +362,23 @@ class Twig_Lexer implements Twig_LexerInterface
|
|
371 |
protected function pushToken($type, $value = '')
|
372 |
{
|
373 |
// do not push empty text tokens
|
374 |
-
if (
|
375 |
return;
|
376 |
}
|
377 |
|
378 |
-
$this->tokens[] = new
|
379 |
}
|
380 |
|
381 |
protected function moveCursor($text)
|
382 |
{
|
383 |
-
$this->cursor +=
|
384 |
$this->lineno += substr_count($text, "\n");
|
385 |
}
|
386 |
|
387 |
protected function getOperatorRegex()
|
388 |
{
|
389 |
$operators = array_merge(
|
390 |
-
|
391 |
array_keys($this->env->getUnaryOperators()),
|
392 |
array_keys($this->env->getBinaryOperators())
|
393 |
);
|
@@ -395,7 +386,7 @@ class Twig_Lexer implements Twig_LexerInterface
|
|
395 |
$operators = array_combine($operators, array_map('strlen', $operators));
|
396 |
arsort($operators);
|
397 |
|
398 |
-
$regex =
|
399 |
foreach ($operators as $operator => $length) {
|
400 |
// an operator that ends with a character must be followed by
|
401 |
// a whitespace or a parenthesis
|
@@ -422,12 +413,10 @@ class Twig_Lexer implements Twig_LexerInterface
|
|
422 |
|
423 |
protected function popState()
|
424 |
{
|
425 |
-
if (0 ===
|
426 |
-
throw new
|
427 |
}
|
428 |
|
429 |
$this->state = array_pop($this->states);
|
430 |
}
|
431 |
}
|
432 |
-
|
433 |
-
class_alias('Twig_Lexer', 'Twig\Lexer', false);
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
/**
|
14 |
* Lexes a template string.
|
15 |
*
|
49 |
const REGEX_DQ_STRING_PART = '/[^#"\\\\]*(?:(?:\\\\.|#(?!\{))[^#"\\\\]*)*/As';
|
50 |
const PUNCTUATION = '()[]{}?:.,|';
|
51 |
|
52 |
+
public function __construct(Twig_Environment $env, array $options = array())
|
53 |
{
|
54 |
$this->env = $env;
|
55 |
|
56 |
+
$this->options = array_merge(array(
|
57 |
+
'tag_comment' => array('{#', '#}'),
|
58 |
+
'tag_block' => array('{%', '%}'),
|
59 |
+
'tag_variable' => array('{{', '}}'),
|
60 |
'whitespace_trim' => '-',
|
61 |
+
'interpolation' => array('#{', '}'),
|
62 |
+
), $options);
|
63 |
|
64 |
+
$this->regexes = array(
|
65 |
'lex_var' => '/\s*'.preg_quote($this->options['whitespace_trim'].$this->options['tag_variable'][1], '/').'\s*|\s*'.preg_quote($this->options['tag_variable'][1], '/').'/A',
|
66 |
'lex_block' => '/\s*(?:'.preg_quote($this->options['whitespace_trim'].$this->options['tag_block'][1], '/').'\s*|\s*'.preg_quote($this->options['tag_block'][1], '/').')\n?/A',
|
67 |
'lex_raw_data' => '/('.preg_quote($this->options['tag_block'][0].$this->options['whitespace_trim'], '/').'|'.preg_quote($this->options['tag_block'][0], '/').')\s*(?:end%s)\s*(?:'.preg_quote($this->options['whitespace_trim'].$this->options['tag_block'][1], '/').'\s*|\s*'.preg_quote($this->options['tag_block'][1], '/').')/s',
|
72 |
'lex_tokens_start' => '/('.preg_quote($this->options['tag_variable'][0], '/').'|'.preg_quote($this->options['tag_block'][0], '/').'|'.preg_quote($this->options['tag_comment'][0], '/').')('.preg_quote($this->options['whitespace_trim'], '/').')?/s',
|
73 |
'interpolation_start' => '/'.preg_quote($this->options['interpolation'][0], '/').'\s*/A',
|
74 |
'interpolation_end' => '/\s*'.preg_quote($this->options['interpolation'][1], '/').'/A',
|
75 |
+
);
|
76 |
}
|
77 |
|
78 |
public function tokenize($code, $name = null)
|
79 |
{
|
80 |
+
if (!$code instanceof Twig_Source) {
|
81 |
@trigger_error(sprintf('Passing a string as the $code argument of %s() is deprecated since version 1.27 and will be removed in 2.0. Pass a Twig_Source instance instead.', __METHOD__), E_USER_DEPRECATED);
|
82 |
+
$this->source = new Twig_Source($code, $name);
|
83 |
} else {
|
84 |
$this->source = $code;
|
85 |
}
|
88 |
@trigger_error('Support for having "mbstring.func_overload" different from 0 is deprecated version 1.29 and will be removed in 2.0.', E_USER_DEPRECATED);
|
89 |
}
|
90 |
|
91 |
+
if (function_exists('mb_internal_encoding') && ((int) ini_get('mbstring.func_overload')) & 2) {
|
92 |
$mbEncoding = mb_internal_encoding();
|
93 |
mb_internal_encoding('ASCII');
|
94 |
} else {
|
95 |
$mbEncoding = null;
|
96 |
}
|
97 |
|
98 |
+
$this->code = str_replace(array("\r\n", "\r"), "\n", $this->source->getCode());
|
99 |
$this->filename = $this->source->getName();
|
100 |
$this->cursor = 0;
|
101 |
$this->lineno = 1;
|
102 |
+
$this->end = strlen($this->code);
|
103 |
+
$this->tokens = array();
|
104 |
$this->state = self::STATE_DATA;
|
105 |
+
$this->states = array();
|
106 |
+
$this->brackets = array();
|
107 |
$this->position = -1;
|
108 |
|
109 |
// find all token starts in one go
|
136 |
}
|
137 |
}
|
138 |
|
139 |
+
$this->pushToken(Twig_Token::EOF_TYPE);
|
140 |
|
141 |
if (!empty($this->brackets)) {
|
142 |
list($expect, $lineno) = array_pop($this->brackets);
|
143 |
+
throw new Twig_Error_Syntax(sprintf('Unclosed "%s".', $expect), $lineno, $this->source);
|
144 |
}
|
145 |
|
146 |
if ($mbEncoding) {
|
147 |
mb_internal_encoding($mbEncoding);
|
148 |
}
|
149 |
|
150 |
+
return new Twig_TokenStream($this->tokens, $this->source);
|
151 |
}
|
152 |
|
153 |
protected function lexData()
|
154 |
{
|
155 |
// if no matches are left we return the rest of the template as simple text token
|
156 |
+
if ($this->position == count($this->positions[0]) - 1) {
|
157 |
+
$this->pushToken(Twig_Token::TEXT_TYPE, substr($this->code, $this->cursor));
|
158 |
$this->cursor = $this->end;
|
159 |
|
160 |
return;
|
163 |
// Find the first token after the current cursor
|
164 |
$position = $this->positions[0][++$this->position];
|
165 |
while ($position[1] < $this->cursor) {
|
166 |
+
if ($this->position == count($this->positions[0]) - 1) {
|
167 |
return;
|
168 |
}
|
169 |
$position = $this->positions[0][++$this->position];
|
174 |
if (isset($this->positions[2][$this->position][0])) {
|
175 |
$text = rtrim($text);
|
176 |
}
|
177 |
+
$this->pushToken(Twig_Token::TEXT_TYPE, $text);
|
178 |
$this->moveCursor($textContent.$position[0]);
|
179 |
|
180 |
switch ($this->positions[1][$this->position][0]) {
|
192 |
$this->moveCursor($match[0]);
|
193 |
$this->lineno = (int) $match[1];
|
194 |
} else {
|
195 |
+
$this->pushToken(Twig_Token::BLOCK_START_TYPE);
|
196 |
$this->pushState(self::STATE_BLOCK);
|
197 |
$this->currentVarBlockLine = $this->lineno;
|
198 |
}
|
199 |
break;
|
200 |
|
201 |
case $this->options['tag_variable'][0]:
|
202 |
+
$this->pushToken(Twig_Token::VAR_START_TYPE);
|
203 |
$this->pushState(self::STATE_VAR);
|
204 |
$this->currentVarBlockLine = $this->lineno;
|
205 |
break;
|
209 |
protected function lexBlock()
|
210 |
{
|
211 |
if (empty($this->brackets) && preg_match($this->regexes['lex_block'], $this->code, $match, null, $this->cursor)) {
|
212 |
+
$this->pushToken(Twig_Token::BLOCK_END_TYPE);
|
213 |
$this->moveCursor($match[0]);
|
214 |
$this->popState();
|
215 |
} else {
|
220 |
protected function lexVar()
|
221 |
{
|
222 |
if (empty($this->brackets) && preg_match($this->regexes['lex_var'], $this->code, $match, null, $this->cursor)) {
|
223 |
+
$this->pushToken(Twig_Token::VAR_END_TYPE);
|
224 |
$this->moveCursor($match[0]);
|
225 |
$this->popState();
|
226 |
} else {
|
235 |
$this->moveCursor($match[0]);
|
236 |
|
237 |
if ($this->cursor >= $this->end) {
|
238 |
+
throw new Twig_Error_Syntax(sprintf('Unclosed "%s".', $this->state === self::STATE_BLOCK ? 'block' : 'variable'), $this->currentVarBlockLine, $this->source);
|
239 |
}
|
240 |
}
|
241 |
|
242 |
// operators
|
243 |
if (preg_match($this->regexes['operator'], $this->code, $match, null, $this->cursor)) {
|
244 |
+
$this->pushToken(Twig_Token::OPERATOR_TYPE, preg_replace('/\s+/', ' ', $match[0]));
|
245 |
$this->moveCursor($match[0]);
|
246 |
}
|
247 |
// names
|
248 |
elseif (preg_match(self::REGEX_NAME, $this->code, $match, null, $this->cursor)) {
|
249 |
+
$this->pushToken(Twig_Token::NAME_TYPE, $match[0]);
|
250 |
$this->moveCursor($match[0]);
|
251 |
}
|
252 |
// numbers
|
255 |
if (ctype_digit($match[0]) && $number <= PHP_INT_MAX) {
|
256 |
$number = (int) $match[0]; // integers lower than the maximum
|
257 |
}
|
258 |
+
$this->pushToken(Twig_Token::NUMBER_TYPE, $number);
|
259 |
$this->moveCursor($match[0]);
|
260 |
}
|
261 |
// punctuation
|
262 |
elseif (false !== strpos(self::PUNCTUATION, $this->code[$this->cursor])) {
|
263 |
// opening bracket
|
264 |
if (false !== strpos('([{', $this->code[$this->cursor])) {
|
265 |
+
$this->brackets[] = array($this->code[$this->cursor], $this->lineno);
|
266 |
}
|
267 |
// closing bracket
|
268 |
elseif (false !== strpos(')]}', $this->code[$this->cursor])) {
|
269 |
if (empty($this->brackets)) {
|
270 |
+
throw new Twig_Error_Syntax(sprintf('Unexpected "%s".', $this->code[$this->cursor]), $this->lineno, $this->source);
|
271 |
}
|
272 |
|
273 |
list($expect, $lineno) = array_pop($this->brackets);
|
274 |
if ($this->code[$this->cursor] != strtr($expect, '([{', ')]}')) {
|
275 |
+
throw new Twig_Error_Syntax(sprintf('Unclosed "%s".', $expect), $lineno, $this->source);
|
276 |
}
|
277 |
}
|
278 |
|
279 |
+
$this->pushToken(Twig_Token::PUNCTUATION_TYPE, $this->code[$this->cursor]);
|
280 |
++$this->cursor;
|
281 |
}
|
282 |
// strings
|
283 |
elseif (preg_match(self::REGEX_STRING, $this->code, $match, null, $this->cursor)) {
|
284 |
+
$this->pushToken(Twig_Token::STRING_TYPE, stripcslashes(substr($match[0], 1, -1)));
|
285 |
$this->moveCursor($match[0]);
|
286 |
}
|
287 |
// opening double quoted string
|
288 |
elseif (preg_match(self::REGEX_DQ_STRING_DELIM, $this->code, $match, null, $this->cursor)) {
|
289 |
+
$this->brackets[] = array('"', $this->lineno);
|
290 |
$this->pushState(self::STATE_STRING);
|
291 |
$this->moveCursor($match[0]);
|
292 |
}
|
293 |
// unlexable
|
294 |
else {
|
295 |
+
throw new Twig_Error_Syntax(sprintf('Unexpected character "%s".', $this->code[$this->cursor]), $this->lineno, $this->source);
|
296 |
}
|
297 |
}
|
298 |
|
303 |
}
|
304 |
|
305 |
if (!preg_match(str_replace('%s', $tag, $this->regexes['lex_raw_data']), $this->code, $match, PREG_OFFSET_CAPTURE, $this->cursor)) {
|
306 |
+
throw new Twig_Error_Syntax(sprintf('Unexpected end of file: Unclosed "%s" block.', $tag), $this->lineno, $this->source);
|
307 |
}
|
308 |
|
309 |
$text = substr($this->code, $this->cursor, $match[0][1] - $this->cursor);
|
313 |
$text = rtrim($text);
|
314 |
}
|
315 |
|
316 |
+
$this->pushToken(Twig_Token::TEXT_TYPE, $text);
|
317 |
}
|
318 |
|
319 |
protected function lexComment()
|
320 |
{
|
321 |
if (!preg_match($this->regexes['lex_comment'], $this->code, $match, PREG_OFFSET_CAPTURE, $this->cursor)) {
|
322 |
+
throw new Twig_Error_Syntax('Unclosed comment.', $this->lineno, $this->source);
|
323 |
}
|
324 |
|
325 |
$this->moveCursor(substr($this->code, $this->cursor, $match[0][1] - $this->cursor).$match[0][0]);
|
328 |
protected function lexString()
|
329 |
{
|
330 |
if (preg_match($this->regexes['interpolation_start'], $this->code, $match, null, $this->cursor)) {
|
331 |
+
$this->brackets[] = array($this->options['interpolation'][0], $this->lineno);
|
332 |
+
$this->pushToken(Twig_Token::INTERPOLATION_START_TYPE);
|
333 |
$this->moveCursor($match[0]);
|
334 |
$this->pushState(self::STATE_INTERPOLATION);
|
335 |
+
} elseif (preg_match(self::REGEX_DQ_STRING_PART, $this->code, $match, null, $this->cursor) && strlen($match[0]) > 0) {
|
336 |
+
$this->pushToken(Twig_Token::STRING_TYPE, stripcslashes($match[0]));
|
337 |
$this->moveCursor($match[0]);
|
338 |
} elseif (preg_match(self::REGEX_DQ_STRING_DELIM, $this->code, $match, null, $this->cursor)) {
|
339 |
list($expect, $lineno) = array_pop($this->brackets);
|
340 |
+
if ($this->code[$this->cursor] != '"') {
|
341 |
+
throw new Twig_Error_Syntax(sprintf('Unclosed "%s".', $expect), $lineno, $this->source);
|
342 |
}
|
343 |
|
344 |
$this->popState();
|
345 |
++$this->cursor;
|
|
|
|
|
|
|
346 |
}
|
347 |
}
|
348 |
|
351 |
$bracket = end($this->brackets);
|
352 |
if ($this->options['interpolation'][0] === $bracket[0] && preg_match($this->regexes['interpolation_end'], $this->code, $match, null, $this->cursor)) {
|
353 |
array_pop($this->brackets);
|
354 |
+
$this->pushToken(Twig_Token::INTERPOLATION_END_TYPE);
|
355 |
$this->moveCursor($match[0]);
|
356 |
$this->popState();
|
357 |
} else {
|
362 |
protected function pushToken($type, $value = '')
|
363 |
{
|
364 |
// do not push empty text tokens
|
365 |
+
if (Twig_Token::TEXT_TYPE === $type && '' === $value) {
|
366 |
return;
|
367 |
}
|
368 |
|
369 |
+
$this->tokens[] = new Twig_Token($type, $value, $this->lineno);
|
370 |
}
|
371 |
|
372 |
protected function moveCursor($text)
|
373 |
{
|
374 |
+
$this->cursor += strlen($text);
|
375 |
$this->lineno += substr_count($text, "\n");
|
376 |
}
|
377 |
|
378 |
protected function getOperatorRegex()
|
379 |
{
|
380 |
$operators = array_merge(
|
381 |
+
array('='),
|
382 |
array_keys($this->env->getUnaryOperators()),
|
383 |
array_keys($this->env->getBinaryOperators())
|
384 |
);
|
386 |
$operators = array_combine($operators, array_map('strlen', $operators));
|
387 |
arsort($operators);
|
388 |
|
389 |
+
$regex = array();
|
390 |
foreach ($operators as $operator => $length) {
|
391 |
// an operator that ends with a character must be followed by
|
392 |
// a whitespace or a parenthesis
|
413 |
|
414 |
protected function popState()
|
415 |
{
|
416 |
+
if (0 === count($this->states)) {
|
417 |
+
throw new Exception('Cannot pop state without a previous state.');
|
418 |
}
|
419 |
|
420 |
$this->state = array_pop($this->states);
|
421 |
}
|
422 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/LexerInterface.php
CHANGED
@@ -9,10 +9,6 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Error\SyntaxError;
|
13 |
-
use Twig\Source;
|
14 |
-
use Twig\TokenStream;
|
15 |
-
|
16 |
/**
|
17 |
* Interface implemented by lexer classes.
|
18 |
*
|
@@ -25,12 +21,12 @@ interface Twig_LexerInterface
|
|
25 |
/**
|
26 |
* Tokenizes a source code.
|
27 |
*
|
28 |
-
* @param string|
|
29 |
-
* @param string
|
30 |
*
|
31 |
-
* @return
|
32 |
*
|
33 |
-
* @throws
|
34 |
*/
|
35 |
public function tokenize($code, $name = null);
|
36 |
}
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
|
|
|
|
12 |
/**
|
13 |
* Interface implemented by lexer classes.
|
14 |
*
|
21 |
/**
|
22 |
* Tokenizes a source code.
|
23 |
*
|
24 |
+
* @param string|Twig_Source $code The source code
|
25 |
+
* @param string $name A unique identifier for the source code
|
26 |
*
|
27 |
+
* @return Twig_TokenStream
|
28 |
*
|
29 |
+
* @throws Twig_Error_Syntax When the code is syntactically wrong
|
30 |
*/
|
31 |
public function tokenize($code, $name = null);
|
32 |
}
|
vendor/twig/twig/lib/Twig/Loader/Array.php
CHANGED
@@ -9,10 +9,6 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Error\LoaderError;
|
13 |
-
use Twig\Loader\LoaderInterface;
|
14 |
-
use Twig\Source;
|
15 |
-
|
16 |
/**
|
17 |
* Loads a template from an array.
|
18 |
*
|
@@ -27,14 +23,14 @@ use Twig\Source;
|
|
27 |
*
|
28 |
* @author Fabien Potencier <fabien@symfony.com>
|
29 |
*/
|
30 |
-
class Twig_Loader_Array implements
|
31 |
{
|
32 |
-
protected $templates =
|
33 |
|
34 |
/**
|
35 |
* @param array $templates An array of templates (keys are the names, and values are the source code)
|
36 |
*/
|
37 |
-
public function __construct(array $templates =
|
38 |
{
|
39 |
$this->templates = $templates;
|
40 |
}
|
@@ -52,11 +48,11 @@ class Twig_Loader_Array implements LoaderInterface, Twig_ExistsLoaderInterface,
|
|
52 |
|
53 |
public function getSource($name)
|
54 |
{
|
55 |
-
@trigger_error(sprintf('Calling "getSource" on "%s" is deprecated since 1.27. Use getSourceContext() instead.',
|
56 |
|
57 |
$name = (string) $name;
|
58 |
if (!isset($this->templates[$name])) {
|
59 |
-
throw new
|
60 |
}
|
61 |
|
62 |
return $this->templates[$name];
|
@@ -66,10 +62,10 @@ class Twig_Loader_Array implements LoaderInterface, Twig_ExistsLoaderInterface,
|
|
66 |
{
|
67 |
$name = (string) $name;
|
68 |
if (!isset($this->templates[$name])) {
|
69 |
-
throw new
|
70 |
}
|
71 |
|
72 |
-
return new
|
73 |
}
|
74 |
|
75 |
public function exists($name)
|
@@ -81,21 +77,19 @@ class Twig_Loader_Array implements LoaderInterface, Twig_ExistsLoaderInterface,
|
|
81 |
{
|
82 |
$name = (string) $name;
|
83 |
if (!isset($this->templates[$name])) {
|
84 |
-
throw new
|
85 |
}
|
86 |
|
87 |
-
return $
|
88 |
}
|
89 |
|
90 |
public function isFresh($name, $time)
|
91 |
{
|
92 |
$name = (string) $name;
|
93 |
if (!isset($this->templates[$name])) {
|
94 |
-
throw new
|
95 |
}
|
96 |
|
97 |
return true;
|
98 |
}
|
99 |
}
|
100 |
-
|
101 |
-
class_alias('Twig_Loader_Array', 'Twig\Loader\ArrayLoader', false);
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
|
|
|
|
12 |
/**
|
13 |
* Loads a template from an array.
|
14 |
*
|
23 |
*
|
24 |
* @author Fabien Potencier <fabien@symfony.com>
|
25 |
*/
|
26 |
+
class Twig_Loader_Array implements Twig_LoaderInterface, Twig_ExistsLoaderInterface, Twig_SourceContextLoaderInterface
|
27 |
{
|
28 |
+
protected $templates = array();
|
29 |
|
30 |
/**
|
31 |
* @param array $templates An array of templates (keys are the names, and values are the source code)
|
32 |
*/
|
33 |
+
public function __construct(array $templates = array())
|
34 |
{
|
35 |
$this->templates = $templates;
|
36 |
}
|
48 |
|
49 |
public function getSource($name)
|
50 |
{
|
51 |
+
@trigger_error(sprintf('Calling "getSource" on "%s" is deprecated since 1.27. Use getSourceContext() instead.', get_class($this)), E_USER_DEPRECATED);
|
52 |
|
53 |
$name = (string) $name;
|
54 |
if (!isset($this->templates[$name])) {
|
55 |
+
throw new Twig_Error_Loader(sprintf('Template "%s" is not defined.', $name));
|
56 |
}
|
57 |
|
58 |
return $this->templates[$name];
|
62 |
{
|
63 |
$name = (string) $name;
|
64 |
if (!isset($this->templates[$name])) {
|
65 |
+
throw new Twig_Error_Loader(sprintf('Template "%s" is not defined.', $name));
|
66 |
}
|
67 |
|
68 |
+
return new Twig_Source($this->templates[$name], $name);
|
69 |
}
|
70 |
|
71 |
public function exists($name)
|
77 |
{
|
78 |
$name = (string) $name;
|
79 |
if (!isset($this->templates[$name])) {
|
80 |
+
throw new Twig_Error_Loader(sprintf('Template "%s" is not defined.', $name));
|
81 |
}
|
82 |
|
83 |
+
return $this->templates[$name];
|
84 |
}
|
85 |
|
86 |
public function isFresh($name, $time)
|
87 |
{
|
88 |
$name = (string) $name;
|
89 |
if (!isset($this->templates[$name])) {
|
90 |
+
throw new Twig_Error_Loader(sprintf('Template "%s" is not defined.', $name));
|
91 |
}
|
92 |
|
93 |
return true;
|
94 |
}
|
95 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Loader/Chain.php
CHANGED
@@ -9,12 +9,6 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Error\LoaderError;
|
13 |
-
use Twig\Loader\ExistsLoaderInterface;
|
14 |
-
use Twig\Loader\LoaderInterface;
|
15 |
-
use Twig\Loader\SourceContextLoaderInterface;
|
16 |
-
use Twig\Source;
|
17 |
-
|
18 |
/**
|
19 |
* Loads templates from other loaders.
|
20 |
*
|
@@ -22,75 +16,67 @@ use Twig\Source;
|
|
22 |
*
|
23 |
* @author Fabien Potencier <fabien@symfony.com>
|
24 |
*/
|
25 |
-
class Twig_Loader_Chain implements
|
26 |
{
|
27 |
-
private $hasSourceCache =
|
28 |
-
protected $loaders =
|
29 |
|
30 |
/**
|
31 |
-
* @param
|
32 |
*/
|
33 |
-
public function __construct(array $loaders =
|
34 |
{
|
35 |
foreach ($loaders as $loader) {
|
36 |
$this->addLoader($loader);
|
37 |
}
|
38 |
}
|
39 |
|
40 |
-
public function addLoader(
|
41 |
{
|
42 |
$this->loaders[] = $loader;
|
43 |
-
$this->hasSourceCache =
|
44 |
-
}
|
45 |
-
|
46 |
-
/**
|
47 |
-
* @return LoaderInterface[]
|
48 |
-
*/
|
49 |
-
public function getLoaders()
|
50 |
-
{
|
51 |
-
return $this->loaders;
|
52 |
}
|
53 |
|
54 |
public function getSource($name)
|
55 |
{
|
56 |
-
@trigger_error(sprintf('Calling "getSource" on "%s" is deprecated since 1.27. Use getSourceContext() instead.',
|
57 |
|
58 |
-
$exceptions =
|
59 |
foreach ($this->loaders as $loader) {
|
60 |
-
if ($loader instanceof
|
61 |
continue;
|
62 |
}
|
63 |
|
64 |
try {
|
65 |
return $loader->getSource($name);
|
66 |
-
} catch (
|
67 |
$exceptions[] = $e->getMessage();
|
68 |
}
|
69 |
}
|
70 |
|
71 |
-
throw new
|
72 |
}
|
73 |
|
74 |
public function getSourceContext($name)
|
75 |
{
|
76 |
-
$exceptions =
|
77 |
foreach ($this->loaders as $loader) {
|
78 |
-
if ($loader instanceof
|
79 |
continue;
|
80 |
}
|
81 |
|
82 |
try {
|
83 |
-
if ($loader instanceof
|
84 |
return $loader->getSourceContext($name);
|
85 |
}
|
86 |
|
87 |
-
return new
|
88 |
-
} catch (
|
89 |
$exceptions[] = $e->getMessage();
|
90 |
}
|
91 |
}
|
92 |
|
93 |
-
throw new
|
94 |
}
|
95 |
|
96 |
public function exists($name)
|
@@ -102,7 +88,7 @@ class Twig_Loader_Chain implements LoaderInterface, Twig_ExistsLoaderInterface,
|
|
102 |
}
|
103 |
|
104 |
foreach ($this->loaders as $loader) {
|
105 |
-
if ($loader instanceof
|
106 |
if ($loader->exists($name)) {
|
107 |
return $this->hasSourceCache[$name] = true;
|
108 |
}
|
@@ -111,14 +97,14 @@ class Twig_Loader_Chain implements LoaderInterface, Twig_ExistsLoaderInterface,
|
|
111 |
}
|
112 |
|
113 |
try {
|
114 |
-
if ($loader instanceof
|
115 |
$loader->getSourceContext($name);
|
116 |
} else {
|
117 |
$loader->getSource($name);
|
118 |
}
|
119 |
|
120 |
return $this->hasSourceCache[$name] = true;
|
121 |
-
} catch (
|
122 |
}
|
123 |
}
|
124 |
|
@@ -127,39 +113,37 @@ class Twig_Loader_Chain implements LoaderInterface, Twig_ExistsLoaderInterface,
|
|
127 |
|
128 |
public function getCacheKey($name)
|
129 |
{
|
130 |
-
$exceptions =
|
131 |
foreach ($this->loaders as $loader) {
|
132 |
-
if ($loader instanceof
|
133 |
continue;
|
134 |
}
|
135 |
|
136 |
try {
|
137 |
return $loader->getCacheKey($name);
|
138 |
-
} catch (
|
139 |
-
$exceptions[] =
|
140 |
}
|
141 |
}
|
142 |
|
143 |
-
throw new
|
144 |
}
|
145 |
|
146 |
public function isFresh($name, $time)
|
147 |
{
|
148 |
-
$exceptions =
|
149 |
foreach ($this->loaders as $loader) {
|
150 |
-
if ($loader instanceof
|
151 |
continue;
|
152 |
}
|
153 |
|
154 |
try {
|
155 |
return $loader->isFresh($name, $time);
|
156 |
-
} catch (
|
157 |
-
$exceptions[] =
|
158 |
}
|
159 |
}
|
160 |
|
161 |
-
throw new
|
162 |
}
|
163 |
}
|
164 |
-
|
165 |
-
class_alias('Twig_Loader_Chain', 'Twig\Loader\ChainLoader', false);
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
/**
|
13 |
* Loads templates from other loaders.
|
14 |
*
|
16 |
*
|
17 |
* @author Fabien Potencier <fabien@symfony.com>
|
18 |
*/
|
19 |
+
class Twig_Loader_Chain implements Twig_LoaderInterface, Twig_ExistsLoaderInterface, Twig_SourceContextLoaderInterface
|
20 |
{
|
21 |
+
private $hasSourceCache = array();
|
22 |
+
protected $loaders = array();
|
23 |
|
24 |
/**
|
25 |
+
* @param Twig_LoaderInterface[] $loaders
|
26 |
*/
|
27 |
+
public function __construct(array $loaders = array())
|
28 |
{
|
29 |
foreach ($loaders as $loader) {
|
30 |
$this->addLoader($loader);
|
31 |
}
|
32 |
}
|
33 |
|
34 |
+
public function addLoader(Twig_LoaderInterface $loader)
|
35 |
{
|
36 |
$this->loaders[] = $loader;
|
37 |
+
$this->hasSourceCache = array();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
}
|
39 |
|
40 |
public function getSource($name)
|
41 |
{
|
42 |
+
@trigger_error(sprintf('Calling "getSource" on "%s" is deprecated since 1.27. Use getSourceContext() instead.', get_class($this)), E_USER_DEPRECATED);
|
43 |
|
44 |
+
$exceptions = array();
|
45 |
foreach ($this->loaders as $loader) {
|
46 |
+
if ($loader instanceof Twig_ExistsLoaderInterface && !$loader->exists($name)) {
|
47 |
continue;
|
48 |
}
|
49 |
|
50 |
try {
|
51 |
return $loader->getSource($name);
|
52 |
+
} catch (Twig_Error_Loader $e) {
|
53 |
$exceptions[] = $e->getMessage();
|
54 |
}
|
55 |
}
|
56 |
|
57 |
+
throw new Twig_Error_Loader(sprintf('Template "%s" is not defined%s.', $name, $exceptions ? ' ('.implode(', ', $exceptions).')' : ''));
|
58 |
}
|
59 |
|
60 |
public function getSourceContext($name)
|
61 |
{
|
62 |
+
$exceptions = array();
|
63 |
foreach ($this->loaders as $loader) {
|
64 |
+
if ($loader instanceof Twig_ExistsLoaderInterface && !$loader->exists($name)) {
|
65 |
continue;
|
66 |
}
|
67 |
|
68 |
try {
|
69 |
+
if ($loader instanceof Twig_SourceContextLoaderInterface) {
|
70 |
return $loader->getSourceContext($name);
|
71 |
}
|
72 |
|
73 |
+
return new Twig_Source($loader->getSource($name), $name);
|
74 |
+
} catch (Twig_Error_Loader $e) {
|
75 |
$exceptions[] = $e->getMessage();
|
76 |
}
|
77 |
}
|
78 |
|
79 |
+
throw new Twig_Error_Loader(sprintf('Template "%s" is not defined%s.', $name, $exceptions ? ' ('.implode(', ', $exceptions).')' : ''));
|
80 |
}
|
81 |
|
82 |
public function exists($name)
|
88 |
}
|
89 |
|
90 |
foreach ($this->loaders as $loader) {
|
91 |
+
if ($loader instanceof Twig_ExistsLoaderInterface) {
|
92 |
if ($loader->exists($name)) {
|
93 |
return $this->hasSourceCache[$name] = true;
|
94 |
}
|
97 |
}
|
98 |
|
99 |
try {
|
100 |
+
if ($loader instanceof Twig_SourceContextLoaderInterface) {
|
101 |
$loader->getSourceContext($name);
|
102 |
} else {
|
103 |
$loader->getSource($name);
|
104 |
}
|
105 |
|
106 |
return $this->hasSourceCache[$name] = true;
|
107 |
+
} catch (Twig_Error_Loader $e) {
|
108 |
}
|
109 |
}
|
110 |
|
113 |
|
114 |
public function getCacheKey($name)
|
115 |
{
|
116 |
+
$exceptions = array();
|
117 |
foreach ($this->loaders as $loader) {
|
118 |
+
if ($loader instanceof Twig_ExistsLoaderInterface && !$loader->exists($name)) {
|
119 |
continue;
|
120 |
}
|
121 |
|
122 |
try {
|
123 |
return $loader->getCacheKey($name);
|
124 |
+
} catch (Twig_Error_Loader $e) {
|
125 |
+
$exceptions[] = get_class($loader).': '.$e->getMessage();
|
126 |
}
|
127 |
}
|
128 |
|
129 |
+
throw new Twig_Error_Loader(sprintf('Template "%s" is not defined%s.', $name, $exceptions ? ' ('.implode(', ', $exceptions).')' : ''));
|
130 |
}
|
131 |
|
132 |
public function isFresh($name, $time)
|
133 |
{
|
134 |
+
$exceptions = array();
|
135 |
foreach ($this->loaders as $loader) {
|
136 |
+
if ($loader instanceof Twig_ExistsLoaderInterface && !$loader->exists($name)) {
|
137 |
continue;
|
138 |
}
|
139 |
|
140 |
try {
|
141 |
return $loader->isFresh($name, $time);
|
142 |
+
} catch (Twig_Error_Loader $e) {
|
143 |
+
$exceptions[] = get_class($loader).': '.$e->getMessage();
|
144 |
}
|
145 |
}
|
146 |
|
147 |
+
throw new Twig_Error_Loader(sprintf('Template "%s" is not defined%s.', $name, $exceptions ? ' ('.implode(', ', $exceptions).')' : ''));
|
148 |
}
|
149 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Loader/Filesystem.php
CHANGED
@@ -9,23 +9,19 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Error\LoaderError;
|
13 |
-
use Twig\Loader\LoaderInterface;
|
14 |
-
use Twig\Source;
|
15 |
-
|
16 |
/**
|
17 |
* Loads template from the filesystem.
|
18 |
*
|
19 |
* @author Fabien Potencier <fabien@symfony.com>
|
20 |
*/
|
21 |
-
class Twig_Loader_Filesystem implements
|
22 |
{
|
23 |
/** Identifier of the main namespace. */
|
24 |
const MAIN_NAMESPACE = '__main__';
|
25 |
|
26 |
-
protected $paths =
|
27 |
-
protected $cache =
|
28 |
-
protected $errorCache =
|
29 |
|
30 |
private $rootPath;
|
31 |
|
@@ -33,7 +29,7 @@ class Twig_Loader_Filesystem implements LoaderInterface, Twig_ExistsLoaderInterf
|
|
33 |
* @param string|array $paths A path or an array of paths where to look for templates
|
34 |
* @param string|null $rootPath The root path common to all relative paths (null for getcwd())
|
35 |
*/
|
36 |
-
public function __construct($paths =
|
37 |
{
|
38 |
$this->rootPath = (null === $rootPath ? getcwd() : $rootPath).DIRECTORY_SEPARATOR;
|
39 |
if (false !== $realPath = realpath($rootPath)) {
|
@@ -54,7 +50,7 @@ class Twig_Loader_Filesystem implements LoaderInterface, Twig_ExistsLoaderInterf
|
|
54 |
*/
|
55 |
public function getPaths($namespace = self::MAIN_NAMESPACE)
|
56 |
{
|
57 |
-
return isset($this->paths[$namespace]) ? $this->paths[$namespace] :
|
58 |
}
|
59 |
|
60 |
/**
|
@@ -77,11 +73,11 @@ class Twig_Loader_Filesystem implements LoaderInterface, Twig_ExistsLoaderInterf
|
|
77 |
*/
|
78 |
public function setPaths($paths, $namespace = self::MAIN_NAMESPACE)
|
79 |
{
|
80 |
-
if (
|
81 |
-
$paths =
|
82 |
}
|
83 |
|
84 |
-
$this->paths[$namespace] =
|
85 |
foreach ($paths as $path) {
|
86 |
$this->addPath($path, $namespace);
|
87 |
}
|
@@ -93,16 +89,16 @@ class Twig_Loader_Filesystem implements LoaderInterface, Twig_ExistsLoaderInterf
|
|
93 |
* @param string $path A path where to look for templates
|
94 |
* @param string $namespace A path namespace
|
95 |
*
|
96 |
-
* @throws
|
97 |
*/
|
98 |
public function addPath($path, $namespace = self::MAIN_NAMESPACE)
|
99 |
{
|
100 |
// invalidate the cache
|
101 |
-
$this->cache = $this->errorCache =
|
102 |
|
103 |
$checkPath = $this->isAbsolutePath($path) ? $path : $this->rootPath.$path;
|
104 |
if (!is_dir($checkPath)) {
|
105 |
-
throw new
|
106 |
}
|
107 |
|
108 |
$this->paths[$namespace][] = rtrim($path, '/\\');
|
@@ -114,16 +110,16 @@ class Twig_Loader_Filesystem implements LoaderInterface, Twig_ExistsLoaderInterf
|
|
114 |
* @param string $path A path where to look for templates
|
115 |
* @param string $namespace A path namespace
|
116 |
*
|
117 |
-
* @throws
|
118 |
*/
|
119 |
public function prependPath($path, $namespace = self::MAIN_NAMESPACE)
|
120 |
{
|
121 |
// invalidate the cache
|
122 |
-
$this->cache = $this->errorCache =
|
123 |
|
124 |
$checkPath = $this->isAbsolutePath($path) ? $path : $this->rootPath.$path;
|
125 |
if (!is_dir($checkPath)) {
|
126 |
-
throw new
|
127 |
}
|
128 |
|
129 |
$path = rtrim($path, '/\\');
|
@@ -137,7 +133,7 @@ class Twig_Loader_Filesystem implements LoaderInterface, Twig_ExistsLoaderInterf
|
|
137 |
|
138 |
public function getSource($name)
|
139 |
{
|
140 |
-
@trigger_error(sprintf('Calling "getSource" on "%s" is deprecated since 1.27. Use getSourceContext() instead.',
|
141 |
|
142 |
return file_get_contents($this->findTemplate($name));
|
143 |
}
|
@@ -146,13 +142,13 @@ class Twig_Loader_Filesystem implements LoaderInterface, Twig_ExistsLoaderInterf
|
|
146 |
{
|
147 |
$path = $this->findTemplate($name);
|
148 |
|
149 |
-
return new
|
150 |
}
|
151 |
|
152 |
public function getCacheKey($name)
|
153 |
{
|
154 |
$path = $this->findTemplate($name);
|
155 |
-
$len =
|
156 |
if (0 === strncmp($this->rootPath, $path, $len)) {
|
157 |
return substr($path, $len);
|
158 |
}
|
@@ -170,8 +166,8 @@ class Twig_Loader_Filesystem implements LoaderInterface, Twig_ExistsLoaderInterf
|
|
170 |
|
171 |
try {
|
172 |
return false !== $this->findTemplate($name, false);
|
173 |
-
} catch (
|
174 |
-
@trigger_error(sprintf('In %s::findTemplate(), you must accept a second argument that when set to "false" returns "false" instead of throwing an exception. Not supporting this argument is deprecated since version 1.27.',
|
175 |
|
176 |
return false;
|
177 |
}
|
@@ -179,12 +175,12 @@ class Twig_Loader_Filesystem implements LoaderInterface, Twig_ExistsLoaderInterf
|
|
179 |
|
180 |
public function isFresh($name, $time)
|
181 |
{
|
182 |
-
return filemtime($this->findTemplate($name))
|
183 |
}
|
184 |
|
185 |
protected function findTemplate($name)
|
186 |
{
|
187 |
-
$throw =
|
188 |
$name = $this->normalizeName($name);
|
189 |
|
190 |
if (isset($this->cache[$name])) {
|
@@ -196,20 +192,12 @@ class Twig_Loader_Filesystem implements LoaderInterface, Twig_ExistsLoaderInterf
|
|
196 |
return false;
|
197 |
}
|
198 |
|
199 |
-
throw new
|
200 |
}
|
201 |
|
202 |
-
|
203 |
-
$this->validateName($name);
|
204 |
-
|
205 |
-
list($namespace, $shortname) = $this->parseName($name);
|
206 |
-
} catch (LoaderError $e) {
|
207 |
-
if (!$throw) {
|
208 |
-
return false;
|
209 |
-
}
|
210 |
|
211 |
-
|
212 |
-
}
|
213 |
|
214 |
if (!isset($this->paths[$namespace])) {
|
215 |
$this->errorCache[$name] = sprintf('There are no registered paths for namespace "%s".', $namespace);
|
@@ -218,12 +206,12 @@ class Twig_Loader_Filesystem implements LoaderInterface, Twig_ExistsLoaderInterf
|
|
218 |
return false;
|
219 |
}
|
220 |
|
221 |
-
throw new
|
222 |
}
|
223 |
|
224 |
foreach ($this->paths[$namespace] as $path) {
|
225 |
if (!$this->isAbsolutePath($path)) {
|
226 |
-
$path = $this->rootPath.$path;
|
227 |
}
|
228 |
|
229 |
if (is_file($path.'/'.$shortname)) {
|
@@ -241,23 +229,23 @@ class Twig_Loader_Filesystem implements LoaderInterface, Twig_ExistsLoaderInterf
|
|
241 |
return false;
|
242 |
}
|
243 |
|
244 |
-
throw new
|
245 |
}
|
246 |
|
247 |
protected function parseName($name, $default = self::MAIN_NAMESPACE)
|
248 |
{
|
249 |
if (isset($name[0]) && '@' == $name[0]) {
|
250 |
if (false === $pos = strpos($name, '/')) {
|
251 |
-
throw new
|
252 |
}
|
253 |
|
254 |
$namespace = substr($name, 1, $pos - 1);
|
255 |
$shortname = substr($name, $pos + 1);
|
256 |
|
257 |
-
return
|
258 |
}
|
259 |
|
260 |
-
return
|
261 |
}
|
262 |
|
263 |
protected function normalizeName($name)
|
@@ -268,7 +256,7 @@ class Twig_Loader_Filesystem implements LoaderInterface, Twig_ExistsLoaderInterf
|
|
268 |
protected function validateName($name)
|
269 |
{
|
270 |
if (false !== strpos($name, "\0")) {
|
271 |
-
throw new
|
272 |
}
|
273 |
|
274 |
$name = ltrim($name, '/');
|
@@ -282,7 +270,7 @@ class Twig_Loader_Filesystem implements LoaderInterface, Twig_ExistsLoaderInterf
|
|
282 |
}
|
283 |
|
284 |
if ($level < 0) {
|
285 |
-
throw new
|
286 |
}
|
287 |
}
|
288 |
}
|
@@ -290,13 +278,11 @@ class Twig_Loader_Filesystem implements LoaderInterface, Twig_ExistsLoaderInterf
|
|
290 |
private function isAbsolutePath($file)
|
291 |
{
|
292 |
return strspn($file, '/\\', 0, 1)
|
293 |
-
|| (
|
294 |
-
&&
|
295 |
&& strspn($file, '/\\', 2, 1)
|
296 |
)
|
297 |
|| null !== parse_url($file, PHP_URL_SCHEME)
|
298 |
;
|
299 |
}
|
300 |
}
|
301 |
-
|
302 |
-
class_alias('Twig_Loader_Filesystem', 'Twig\Loader\FilesystemLoader', false);
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
|
|
|
|
12 |
/**
|
13 |
* Loads template from the filesystem.
|
14 |
*
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
+
class Twig_Loader_Filesystem implements Twig_LoaderInterface, Twig_ExistsLoaderInterface, Twig_SourceContextLoaderInterface
|
18 |
{
|
19 |
/** Identifier of the main namespace. */
|
20 |
const MAIN_NAMESPACE = '__main__';
|
21 |
|
22 |
+
protected $paths = array();
|
23 |
+
protected $cache = array();
|
24 |
+
protected $errorCache = array();
|
25 |
|
26 |
private $rootPath;
|
27 |
|
29 |
* @param string|array $paths A path or an array of paths where to look for templates
|
30 |
* @param string|null $rootPath The root path common to all relative paths (null for getcwd())
|
31 |
*/
|
32 |
+
public function __construct($paths = array(), $rootPath = null)
|
33 |
{
|
34 |
$this->rootPath = (null === $rootPath ? getcwd() : $rootPath).DIRECTORY_SEPARATOR;
|
35 |
if (false !== $realPath = realpath($rootPath)) {
|
50 |
*/
|
51 |
public function getPaths($namespace = self::MAIN_NAMESPACE)
|
52 |
{
|
53 |
+
return isset($this->paths[$namespace]) ? $this->paths[$namespace] : array();
|
54 |
}
|
55 |
|
56 |
/**
|
73 |
*/
|
74 |
public function setPaths($paths, $namespace = self::MAIN_NAMESPACE)
|
75 |
{
|
76 |
+
if (!is_array($paths)) {
|
77 |
+
$paths = array($paths);
|
78 |
}
|
79 |
|
80 |
+
$this->paths[$namespace] = array();
|
81 |
foreach ($paths as $path) {
|
82 |
$this->addPath($path, $namespace);
|
83 |
}
|
89 |
* @param string $path A path where to look for templates
|
90 |
* @param string $namespace A path namespace
|
91 |
*
|
92 |
+
* @throws Twig_Error_Loader
|
93 |
*/
|
94 |
public function addPath($path, $namespace = self::MAIN_NAMESPACE)
|
95 |
{
|
96 |
// invalidate the cache
|
97 |
+
$this->cache = $this->errorCache = array();
|
98 |
|
99 |
$checkPath = $this->isAbsolutePath($path) ? $path : $this->rootPath.$path;
|
100 |
if (!is_dir($checkPath)) {
|
101 |
+
throw new Twig_Error_Loader(sprintf('The "%s" directory does not exist ("%s").', $path, $checkPath));
|
102 |
}
|
103 |
|
104 |
$this->paths[$namespace][] = rtrim($path, '/\\');
|
110 |
* @param string $path A path where to look for templates
|
111 |
* @param string $namespace A path namespace
|
112 |
*
|
113 |
+
* @throws Twig_Error_Loader
|
114 |
*/
|
115 |
public function prependPath($path, $namespace = self::MAIN_NAMESPACE)
|
116 |
{
|
117 |
// invalidate the cache
|
118 |
+
$this->cache = $this->errorCache = array();
|
119 |
|
120 |
$checkPath = $this->isAbsolutePath($path) ? $path : $this->rootPath.$path;
|
121 |
if (!is_dir($checkPath)) {
|
122 |
+
throw new Twig_Error_Loader(sprintf('The "%s" directory does not exist ("%s").', $path, $checkPath));
|
123 |
}
|
124 |
|
125 |
$path = rtrim($path, '/\\');
|
133 |
|
134 |
public function getSource($name)
|
135 |
{
|
136 |
+
@trigger_error(sprintf('Calling "getSource" on "%s" is deprecated since 1.27. Use getSourceContext() instead.', get_class($this)), E_USER_DEPRECATED);
|
137 |
|
138 |
return file_get_contents($this->findTemplate($name));
|
139 |
}
|
142 |
{
|
143 |
$path = $this->findTemplate($name);
|
144 |
|
145 |
+
return new Twig_Source(file_get_contents($path), $name, $path);
|
146 |
}
|
147 |
|
148 |
public function getCacheKey($name)
|
149 |
{
|
150 |
$path = $this->findTemplate($name);
|
151 |
+
$len = strlen($this->rootPath);
|
152 |
if (0 === strncmp($this->rootPath, $path, $len)) {
|
153 |
return substr($path, $len);
|
154 |
}
|
166 |
|
167 |
try {
|
168 |
return false !== $this->findTemplate($name, false);
|
169 |
+
} catch (Twig_Error_Loader $exception) {
|
170 |
+
@trigger_error(sprintf('In %s::findTemplate(), you must accept a second argument that when set to "false" returns "false" instead of throwing an exception. Not supporting this argument is deprecated since version 1.27.', get_class($this)), E_USER_DEPRECATED);
|
171 |
|
172 |
return false;
|
173 |
}
|
175 |
|
176 |
public function isFresh($name, $time)
|
177 |
{
|
178 |
+
return filemtime($this->findTemplate($name)) <= $time;
|
179 |
}
|
180 |
|
181 |
protected function findTemplate($name)
|
182 |
{
|
183 |
+
$throw = func_num_args() > 1 ? func_get_arg(1) : true;
|
184 |
$name = $this->normalizeName($name);
|
185 |
|
186 |
if (isset($this->cache[$name])) {
|
192 |
return false;
|
193 |
}
|
194 |
|
195 |
+
throw new Twig_Error_Loader($this->errorCache[$name]);
|
196 |
}
|
197 |
|
198 |
+
$this->validateName($name);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
199 |
|
200 |
+
list($namespace, $shortname) = $this->parseName($name);
|
|
|
201 |
|
202 |
if (!isset($this->paths[$namespace])) {
|
203 |
$this->errorCache[$name] = sprintf('There are no registered paths for namespace "%s".', $namespace);
|
206 |
return false;
|
207 |
}
|
208 |
|
209 |
+
throw new Twig_Error_Loader($this->errorCache[$name]);
|
210 |
}
|
211 |
|
212 |
foreach ($this->paths[$namespace] as $path) {
|
213 |
if (!$this->isAbsolutePath($path)) {
|
214 |
+
$path = $this->rootPath.'/'.$path;
|
215 |
}
|
216 |
|
217 |
if (is_file($path.'/'.$shortname)) {
|
229 |
return false;
|
230 |
}
|
231 |
|
232 |
+
throw new Twig_Error_Loader($this->errorCache[$name]);
|
233 |
}
|
234 |
|
235 |
protected function parseName($name, $default = self::MAIN_NAMESPACE)
|
236 |
{
|
237 |
if (isset($name[0]) && '@' == $name[0]) {
|
238 |
if (false === $pos = strpos($name, '/')) {
|
239 |
+
throw new Twig_Error_Loader(sprintf('Malformed namespaced template name "%s" (expecting "@namespace/template_name").', $name));
|
240 |
}
|
241 |
|
242 |
$namespace = substr($name, 1, $pos - 1);
|
243 |
$shortname = substr($name, $pos + 1);
|
244 |
|
245 |
+
return array($namespace, $shortname);
|
246 |
}
|
247 |
|
248 |
+
return array($default, $name);
|
249 |
}
|
250 |
|
251 |
protected function normalizeName($name)
|
256 |
protected function validateName($name)
|
257 |
{
|
258 |
if (false !== strpos($name, "\0")) {
|
259 |
+
throw new Twig_Error_Loader('A template name cannot contain NUL bytes.');
|
260 |
}
|
261 |
|
262 |
$name = ltrim($name, '/');
|
270 |
}
|
271 |
|
272 |
if ($level < 0) {
|
273 |
+
throw new Twig_Error_Loader(sprintf('Looks like you try to load a template outside configured directories (%s).', $name));
|
274 |
}
|
275 |
}
|
276 |
}
|
278 |
private function isAbsolutePath($file)
|
279 |
{
|
280 |
return strspn($file, '/\\', 0, 1)
|
281 |
+
|| (strlen($file) > 3 && ctype_alpha($file[0])
|
282 |
+
&& substr($file, 1, 1) === ':'
|
283 |
&& strspn($file, '/\\', 2, 1)
|
284 |
)
|
285 |
|| null !== parse_url($file, PHP_URL_SCHEME)
|
286 |
;
|
287 |
}
|
288 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Loader/String.php
CHANGED
@@ -9,10 +9,7 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
|
13 |
-
use Twig\Source;
|
14 |
-
|
15 |
-
@trigger_error('The Twig_Loader_String class is deprecated since version 1.18.1 and will be removed in 2.0. Use "Twig\Loader\ArrayLoader" instead or "Twig\Environment::createTemplate()".', E_USER_DEPRECATED);
|
16 |
|
17 |
/**
|
18 |
* Loads a template from a string.
|
@@ -30,18 +27,18 @@ use Twig\Source;
|
|
30 |
*
|
31 |
* @author Fabien Potencier <fabien@symfony.com>
|
32 |
*/
|
33 |
-
class Twig_Loader_String implements
|
34 |
{
|
35 |
public function getSource($name)
|
36 |
{
|
37 |
-
@trigger_error(sprintf('Calling "getSource" on "%s" is deprecated since 1.27. Use getSourceContext() instead.',
|
38 |
|
39 |
return $name;
|
40 |
}
|
41 |
|
42 |
public function getSourceContext($name)
|
43 |
{
|
44 |
-
return new
|
45 |
}
|
46 |
|
47 |
public function exists($name)
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
+
@trigger_error('The Twig_Loader_String class is deprecated since version 1.18.1 and will be removed in 2.0. Use Twig_Loader_Array instead or Twig_Environment::createTemplate().', E_USER_DEPRECATED);
|
|
|
|
|
|
|
13 |
|
14 |
/**
|
15 |
* Loads a template from a string.
|
27 |
*
|
28 |
* @author Fabien Potencier <fabien@symfony.com>
|
29 |
*/
|
30 |
+
class Twig_Loader_String implements Twig_LoaderInterface, Twig_ExistsLoaderInterface, Twig_SourceContextLoaderInterface
|
31 |
{
|
32 |
public function getSource($name)
|
33 |
{
|
34 |
+
@trigger_error(sprintf('Calling "getSource" on "%s" is deprecated since 1.27. Use getSourceContext() instead.', get_class($this)), E_USER_DEPRECATED);
|
35 |
|
36 |
return $name;
|
37 |
}
|
38 |
|
39 |
public function getSourceContext($name)
|
40 |
{
|
41 |
+
return new Twig_Source($name, $name);
|
42 |
}
|
43 |
|
44 |
public function exists($name)
|
vendor/twig/twig/lib/Twig/LoaderInterface.php
CHANGED
@@ -9,8 +9,6 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Error\LoaderError;
|
13 |
-
|
14 |
/**
|
15 |
* Interface all loaders must implement.
|
16 |
*
|
@@ -25,7 +23,7 @@ interface Twig_LoaderInterface
|
|
25 |
*
|
26 |
* @return string The template source code
|
27 |
*
|
28 |
-
* @throws
|
29 |
*
|
30 |
* @deprecated since 1.27 (to be removed in 2.0), implement Twig_SourceContextLoaderInterface
|
31 |
*/
|
@@ -38,7 +36,7 @@ interface Twig_LoaderInterface
|
|
38 |
*
|
39 |
* @return string The cache key
|
40 |
*
|
41 |
-
* @throws
|
42 |
*/
|
43 |
public function getCacheKey($name);
|
44 |
|
@@ -51,9 +49,7 @@ interface Twig_LoaderInterface
|
|
51 |
*
|
52 |
* @return bool true if the template is fresh, false otherwise
|
53 |
*
|
54 |
-
* @throws
|
55 |
*/
|
56 |
public function isFresh($name, $time);
|
57 |
}
|
58 |
-
|
59 |
-
class_alias('Twig_LoaderInterface', 'Twig\Loader\LoaderInterface', false);
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
12 |
/**
|
13 |
* Interface all loaders must implement.
|
14 |
*
|
23 |
*
|
24 |
* @return string The template source code
|
25 |
*
|
26 |
+
* @throws Twig_Error_Loader When $name is not found
|
27 |
*
|
28 |
* @deprecated since 1.27 (to be removed in 2.0), implement Twig_SourceContextLoaderInterface
|
29 |
*/
|
36 |
*
|
37 |
* @return string The cache key
|
38 |
*
|
39 |
+
* @throws Twig_Error_Loader When $name is not found
|
40 |
*/
|
41 |
public function getCacheKey($name);
|
42 |
|
49 |
*
|
50 |
* @return bool true if the template is fresh, false otherwise
|
51 |
*
|
52 |
+
* @throws Twig_Error_Loader When $name is not found
|
53 |
*/
|
54 |
public function isFresh($name, $time);
|
55 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Markup.php
CHANGED
@@ -14,7 +14,7 @@
|
|
14 |
*
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
-
class Twig_Markup implements
|
18 |
{
|
19 |
protected $content;
|
20 |
protected $charset;
|
@@ -32,8 +32,6 @@ class Twig_Markup implements \Countable
|
|
32 |
|
33 |
public function count()
|
34 |
{
|
35 |
-
return
|
36 |
}
|
37 |
}
|
38 |
-
|
39 |
-
class_alias('Twig_Markup', 'Twig\Markup', false);
|
14 |
*
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
+
class Twig_Markup implements Countable
|
18 |
{
|
19 |
protected $content;
|
20 |
protected $charset;
|
32 |
|
33 |
public function count()
|
34 |
{
|
35 |
+
return function_exists('mb_get_info') ? mb_strlen($this->content, $this->charset) : strlen($this->content);
|
36 |
}
|
37 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Node.php
CHANGED
@@ -10,9 +10,6 @@
|
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
|
13 |
-
use Twig\Compiler;
|
14 |
-
use Twig\Node\Node;
|
15 |
-
|
16 |
/**
|
17 |
* Represents a node in the AST.
|
18 |
*
|
@@ -38,11 +35,11 @@ class Twig_Node implements Twig_NodeInterface
|
|
38 |
* @param int $lineno The line number
|
39 |
* @param string $tag The tag name associated with the Node
|
40 |
*/
|
41 |
-
public function __construct(array $nodes =
|
42 |
{
|
43 |
foreach ($nodes as $name => $node) {
|
44 |
if (!$node instanceof Twig_NodeInterface) {
|
45 |
-
@trigger_error(sprintf('Using "%s" for the value of node "%s" of "%s" is deprecated since version 1.25 and will be removed in 2.0.',
|
46 |
}
|
47 |
}
|
48 |
$this->nodes = $nodes;
|
@@ -53,17 +50,17 @@ class Twig_Node implements Twig_NodeInterface
|
|
53 |
|
54 |
public function __toString()
|
55 |
{
|
56 |
-
$attributes =
|
57 |
foreach ($this->attributes as $name => $value) {
|
58 |
$attributes[] = sprintf('%s: %s', $name, str_replace("\n", '', var_export($value, true)));
|
59 |
}
|
60 |
|
61 |
-
$repr =
|
62 |
|
63 |
-
if (
|
64 |
foreach ($this->nodes as $name => $node) {
|
65 |
-
$len =
|
66 |
-
$noderepr =
|
67 |
foreach (explode("\n", (string) $node) as $line) {
|
68 |
$noderepr[] = str_repeat(' ', $len).$line;
|
69 |
}
|
@@ -86,12 +83,12 @@ class Twig_Node implements Twig_NodeInterface
|
|
86 |
{
|
87 |
@trigger_error(sprintf('%s is deprecated since version 1.16.1 and will be removed in 2.0.', __METHOD__), E_USER_DEPRECATED);
|
88 |
|
89 |
-
$dom = new
|
90 |
$dom->formatOutput = true;
|
91 |
$dom->appendChild($xml = $dom->createElement('twig'));
|
92 |
|
93 |
$xml->appendChild($node = $dom->createElement('node'));
|
94 |
-
$node->setAttribute('class',
|
95 |
|
96 |
foreach ($this->attributes as $name => $value) {
|
97 |
$node->appendChild($attribute = $dom->createElement('attribute'));
|
@@ -114,7 +111,7 @@ class Twig_Node implements Twig_NodeInterface
|
|
114 |
return $asDom ? $dom : $dom->saveXML();
|
115 |
}
|
116 |
|
117 |
-
public function compile(
|
118 |
{
|
119 |
foreach ($this->nodes as $node) {
|
120 |
$node->compile($compiler);
|
@@ -146,7 +143,7 @@ class Twig_Node implements Twig_NodeInterface
|
|
146 |
*/
|
147 |
public function hasAttribute($name)
|
148 |
{
|
149 |
-
return
|
150 |
}
|
151 |
|
152 |
/**
|
@@ -154,8 +151,8 @@ class Twig_Node implements Twig_NodeInterface
|
|
154 |
*/
|
155 |
public function getAttribute($name)
|
156 |
{
|
157 |
-
if (
|
158 |
-
throw new
|
159 |
}
|
160 |
|
161 |
return $this->attributes[$name];
|
@@ -180,16 +177,16 @@ class Twig_Node implements Twig_NodeInterface
|
|
180 |
*/
|
181 |
public function hasNode($name)
|
182 |
{
|
183 |
-
return
|
184 |
}
|
185 |
|
186 |
/**
|
187 |
-
* @return
|
188 |
*/
|
189 |
public function getNode($name)
|
190 |
{
|
191 |
-
if (
|
192 |
-
throw new
|
193 |
}
|
194 |
|
195 |
return $this->nodes[$name];
|
@@ -198,7 +195,7 @@ class Twig_Node implements Twig_NodeInterface
|
|
198 |
public function setNode($name, $node = null)
|
199 |
{
|
200 |
if (!$node instanceof Twig_NodeInterface) {
|
201 |
-
@trigger_error(sprintf('Using "%s" for the value of node "%s" of "%s" is deprecated since version 1.25 and will be removed in 2.0.',
|
202 |
}
|
203 |
|
204 |
$this->nodes[$name] = $node;
|
@@ -211,12 +208,12 @@ class Twig_Node implements Twig_NodeInterface
|
|
211 |
|
212 |
public function count()
|
213 |
{
|
214 |
-
return
|
215 |
}
|
216 |
|
217 |
public function getIterator()
|
218 |
{
|
219 |
-
return new
|
220 |
}
|
221 |
|
222 |
public function setTemplateName($name)
|
@@ -254,6 +251,3 @@ class Twig_Node implements Twig_NodeInterface
|
|
254 |
return $this->name;
|
255 |
}
|
256 |
}
|
257 |
-
|
258 |
-
class_alias('Twig_Node', 'Twig\Node\Node', false);
|
259 |
-
class_exists('Twig_Compiler');
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
|
|
|
|
|
|
|
13 |
/**
|
14 |
* Represents a node in the AST.
|
15 |
*
|
35 |
* @param int $lineno The line number
|
36 |
* @param string $tag The tag name associated with the Node
|
37 |
*/
|
38 |
+
public function __construct(array $nodes = array(), array $attributes = array(), $lineno = 0, $tag = null)
|
39 |
{
|
40 |
foreach ($nodes as $name => $node) {
|
41 |
if (!$node instanceof Twig_NodeInterface) {
|
42 |
+
@trigger_error(sprintf('Using "%s" for the value of node "%s" of "%s" is deprecated since version 1.25 and will be removed in 2.0.', is_object($node) ? get_class($node) : null === $node ? 'null' : gettype($node), $name, get_class($this)), E_USER_DEPRECATED);
|
43 |
}
|
44 |
}
|
45 |
$this->nodes = $nodes;
|
50 |
|
51 |
public function __toString()
|
52 |
{
|
53 |
+
$attributes = array();
|
54 |
foreach ($this->attributes as $name => $value) {
|
55 |
$attributes[] = sprintf('%s: %s', $name, str_replace("\n", '', var_export($value, true)));
|
56 |
}
|
57 |
|
58 |
+
$repr = array(get_class($this).'('.implode(', ', $attributes));
|
59 |
|
60 |
+
if (count($this->nodes)) {
|
61 |
foreach ($this->nodes as $name => $node) {
|
62 |
+
$len = strlen($name) + 4;
|
63 |
+
$noderepr = array();
|
64 |
foreach (explode("\n", (string) $node) as $line) {
|
65 |
$noderepr[] = str_repeat(' ', $len).$line;
|
66 |
}
|
83 |
{
|
84 |
@trigger_error(sprintf('%s is deprecated since version 1.16.1 and will be removed in 2.0.', __METHOD__), E_USER_DEPRECATED);
|
85 |
|
86 |
+
$dom = new DOMDocument('1.0', 'UTF-8');
|
87 |
$dom->formatOutput = true;
|
88 |
$dom->appendChild($xml = $dom->createElement('twig'));
|
89 |
|
90 |
$xml->appendChild($node = $dom->createElement('node'));
|
91 |
+
$node->setAttribute('class', get_class($this));
|
92 |
|
93 |
foreach ($this->attributes as $name => $value) {
|
94 |
$node->appendChild($attribute = $dom->createElement('attribute'));
|
111 |
return $asDom ? $dom : $dom->saveXML();
|
112 |
}
|
113 |
|
114 |
+
public function compile(Twig_Compiler $compiler)
|
115 |
{
|
116 |
foreach ($this->nodes as $node) {
|
117 |
$node->compile($compiler);
|
143 |
*/
|
144 |
public function hasAttribute($name)
|
145 |
{
|
146 |
+
return array_key_exists($name, $this->attributes);
|
147 |
}
|
148 |
|
149 |
/**
|
151 |
*/
|
152 |
public function getAttribute($name)
|
153 |
{
|
154 |
+
if (!array_key_exists($name, $this->attributes)) {
|
155 |
+
throw new LogicException(sprintf('Attribute "%s" does not exist for Node "%s".', $name, get_class($this)));
|
156 |
}
|
157 |
|
158 |
return $this->attributes[$name];
|
177 |
*/
|
178 |
public function hasNode($name)
|
179 |
{
|
180 |
+
return array_key_exists($name, $this->nodes);
|
181 |
}
|
182 |
|
183 |
/**
|
184 |
+
* @return Twig_Node
|
185 |
*/
|
186 |
public function getNode($name)
|
187 |
{
|
188 |
+
if (!array_key_exists($name, $this->nodes)) {
|
189 |
+
throw new LogicException(sprintf('Node "%s" does not exist for Node "%s".', $name, get_class($this)));
|
190 |
}
|
191 |
|
192 |
return $this->nodes[$name];
|
195 |
public function setNode($name, $node = null)
|
196 |
{
|
197 |
if (!$node instanceof Twig_NodeInterface) {
|
198 |
+
@trigger_error(sprintf('Using "%s" for the value of node "%s" of "%s" is deprecated since version 1.25 and will be removed in 2.0.', is_object($node) ? get_class($node) : null === $node ? 'null' : gettype($node), $name, get_class($this)), E_USER_DEPRECATED);
|
199 |
}
|
200 |
|
201 |
$this->nodes[$name] = $node;
|
208 |
|
209 |
public function count()
|
210 |
{
|
211 |
+
return count($this->nodes);
|
212 |
}
|
213 |
|
214 |
public function getIterator()
|
215 |
{
|
216 |
+
return new ArrayIterator($this->nodes);
|
217 |
}
|
218 |
|
219 |
public function setTemplateName($name)
|
251 |
return $this->name;
|
252 |
}
|
253 |
}
|
|
|
|
|
|
vendor/twig/twig/lib/Twig/Node/AutoEscape.php
CHANGED
@@ -9,9 +9,6 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Compiler;
|
13 |
-
use Twig\Node\Node;
|
14 |
-
|
15 |
/**
|
16 |
* Represents an autoescape node.
|
17 |
*
|
@@ -23,17 +20,15 @@ use Twig\Node\Node;
|
|
23 |
*
|
24 |
* @author Fabien Potencier <fabien@symfony.com>
|
25 |
*/
|
26 |
-
class Twig_Node_AutoEscape extends
|
27 |
{
|
28 |
public function __construct($value, Twig_NodeInterface $body, $lineno, $tag = 'autoescape')
|
29 |
{
|
30 |
-
parent::__construct(
|
31 |
}
|
32 |
|
33 |
-
public function compile(
|
34 |
{
|
35 |
$compiler->subcompile($this->getNode('body'));
|
36 |
}
|
37 |
}
|
38 |
-
|
39 |
-
class_alias('Twig_Node_AutoEscape', 'Twig\Node\AutoEscapeNode', false);
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
|
|
12 |
/**
|
13 |
* Represents an autoescape node.
|
14 |
*
|
20 |
*
|
21 |
* @author Fabien Potencier <fabien@symfony.com>
|
22 |
*/
|
23 |
+
class Twig_Node_AutoEscape extends Twig_Node
|
24 |
{
|
25 |
public function __construct($value, Twig_NodeInterface $body, $lineno, $tag = 'autoescape')
|
26 |
{
|
27 |
+
parent::__construct(array('body' => $body), array('value' => $value), $lineno, $tag);
|
28 |
}
|
29 |
|
30 |
+
public function compile(Twig_Compiler $compiler)
|
31 |
{
|
32 |
$compiler->subcompile($this->getNode('body'));
|
33 |
}
|
34 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Node/Block.php
CHANGED
@@ -10,26 +10,23 @@
|
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
|
13 |
-
use Twig\Compiler;
|
14 |
-
use Twig\Node\Node;
|
15 |
-
|
16 |
/**
|
17 |
* Represents a block node.
|
18 |
*
|
19 |
* @author Fabien Potencier <fabien@symfony.com>
|
20 |
*/
|
21 |
-
class Twig_Node_Block extends
|
22 |
{
|
23 |
public function __construct($name, Twig_NodeInterface $body, $lineno, $tag = null)
|
24 |
{
|
25 |
-
parent::__construct(
|
26 |
}
|
27 |
|
28 |
-
public function compile(
|
29 |
{
|
30 |
$compiler
|
31 |
->addDebugInfo($this)
|
32 |
-
->write(sprintf("public function block_%s(\$context, array \$blocks =
|
33 |
->indent()
|
34 |
;
|
35 |
|
@@ -40,5 +37,3 @@ class Twig_Node_Block extends Node
|
|
40 |
;
|
41 |
}
|
42 |
}
|
43 |
-
|
44 |
-
class_alias('Twig_Node_Block', 'Twig\Node\BlockNode', false);
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
|
|
|
|
|
|
|
13 |
/**
|
14 |
* Represents a block node.
|
15 |
*
|
16 |
* @author Fabien Potencier <fabien@symfony.com>
|
17 |
*/
|
18 |
+
class Twig_Node_Block extends Twig_Node
|
19 |
{
|
20 |
public function __construct($name, Twig_NodeInterface $body, $lineno, $tag = null)
|
21 |
{
|
22 |
+
parent::__construct(array('body' => $body), array('name' => $name), $lineno, $tag);
|
23 |
}
|
24 |
|
25 |
+
public function compile(Twig_Compiler $compiler)
|
26 |
{
|
27 |
$compiler
|
28 |
->addDebugInfo($this)
|
29 |
+
->write(sprintf("public function block_%s(\$context, array \$blocks = array())\n", $this->getAttribute('name')), "{\n")
|
30 |
->indent()
|
31 |
;
|
32 |
|
37 |
;
|
38 |
}
|
39 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Node/BlockReference.php
CHANGED
@@ -10,23 +10,19 @@
|
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
|
13 |
-
use Twig\Compiler;
|
14 |
-
use Twig\Node\Node;
|
15 |
-
use Twig\Node\NodeOutputInterface;
|
16 |
-
|
17 |
/**
|
18 |
* Represents a block call node.
|
19 |
*
|
20 |
* @author Fabien Potencier <fabien@symfony.com>
|
21 |
*/
|
22 |
-
class Twig_Node_BlockReference extends
|
23 |
{
|
24 |
public function __construct($name, $lineno, $tag = null)
|
25 |
{
|
26 |
-
parent::__construct(
|
27 |
}
|
28 |
|
29 |
-
public function compile(
|
30 |
{
|
31 |
$compiler
|
32 |
->addDebugInfo($this)
|
@@ -34,5 +30,3 @@ class Twig_Node_BlockReference extends Node implements NodeOutputInterface
|
|
34 |
;
|
35 |
}
|
36 |
}
|
37 |
-
|
38 |
-
class_alias('Twig_Node_BlockReference', 'Twig\Node\BlockReferenceNode', false);
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
|
|
|
|
|
|
|
|
|
13 |
/**
|
14 |
* Represents a block call node.
|
15 |
*
|
16 |
* @author Fabien Potencier <fabien@symfony.com>
|
17 |
*/
|
18 |
+
class Twig_Node_BlockReference extends Twig_Node implements Twig_NodeOutputInterface
|
19 |
{
|
20 |
public function __construct($name, $lineno, $tag = null)
|
21 |
{
|
22 |
+
parent::__construct(array(), array('name' => $name), $lineno, $tag);
|
23 |
}
|
24 |
|
25 |
+
public function compile(Twig_Compiler $compiler)
|
26 |
{
|
27 |
$compiler
|
28 |
->addDebugInfo($this)
|
30 |
;
|
31 |
}
|
32 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Node/Body.php
CHANGED
@@ -9,15 +9,11 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Node\Node;
|
13 |
-
|
14 |
/**
|
15 |
* Represents a body node.
|
16 |
*
|
17 |
* @author Fabien Potencier <fabien@symfony.com>
|
18 |
*/
|
19 |
-
class Twig_Node_Body extends
|
20 |
{
|
21 |
}
|
22 |
-
|
23 |
-
class_alias('Twig_Node_Body', 'Twig\Node\BodyNode', false);
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
12 |
/**
|
13 |
* Represents a body node.
|
14 |
*
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
+
class Twig_Node_Body extends Twig_Node
|
18 |
{
|
19 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Node/CheckSecurity.php
CHANGED
@@ -9,13 +9,10 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Compiler;
|
13 |
-
use Twig\Node\Node;
|
14 |
-
|
15 |
/**
|
16 |
* @author Fabien Potencier <fabien@symfony.com>
|
17 |
*/
|
18 |
-
class Twig_Node_CheckSecurity extends
|
19 |
{
|
20 |
protected $usedFilters;
|
21 |
protected $usedTags;
|
@@ -30,12 +27,12 @@ class Twig_Node_CheckSecurity extends Node
|
|
30 |
parent::__construct();
|
31 |
}
|
32 |
|
33 |
-
public function compile(
|
34 |
{
|
35 |
-
$tags = $filters = $functions =
|
36 |
-
foreach (
|
37 |
foreach ($this->{'used'.ucfirst($type)} as $name => $node) {
|
38 |
-
if ($node instanceof
|
39 |
${$type}[$name] = $node->getTemplateLine();
|
40 |
} else {
|
41 |
${$type}[$node] = null;
|
@@ -49,26 +46,26 @@ class Twig_Node_CheckSecurity extends Node
|
|
49 |
->write('$functions = ')->repr(array_filter($functions))->raw(";\n\n")
|
50 |
->write("try {\n")
|
51 |
->indent()
|
52 |
-
->write("\$this->env->getExtension('
|
53 |
->indent()
|
54 |
-
->write(!$tags ? "
|
55 |
-
->write(!$filters ? "
|
56 |
-
->write(!$functions ? "
|
57 |
->outdent()
|
58 |
->write(");\n")
|
59 |
->outdent()
|
60 |
-
->write("} catch (
|
61 |
->indent()
|
62 |
->write("\$e->setSourceContext(\$this->getSourceContext());\n\n")
|
63 |
-
->write("if (\$e instanceof
|
64 |
->indent()
|
65 |
->write("\$e->setTemplateLine(\$tags[\$e->getTagName()]);\n")
|
66 |
->outdent()
|
67 |
-
->write("} elseif (\$e instanceof
|
68 |
->indent()
|
69 |
->write("\$e->setTemplateLine(\$filters[\$e->getFilterName()]);\n")
|
70 |
->outdent()
|
71 |
-
->write("} elseif (\$e instanceof
|
72 |
->indent()
|
73 |
->write("\$e->setTemplateLine(\$functions[\$e->getFunctionName()]);\n")
|
74 |
->outdent()
|
@@ -79,5 +76,3 @@ class Twig_Node_CheckSecurity extends Node
|
|
79 |
;
|
80 |
}
|
81 |
}
|
82 |
-
|
83 |
-
class_alias('Twig_Node_CheckSecurity', 'Twig\Node\CheckSecurityNode', false);
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
|
|
12 |
/**
|
13 |
* @author Fabien Potencier <fabien@symfony.com>
|
14 |
*/
|
15 |
+
class Twig_Node_CheckSecurity extends Twig_Node
|
16 |
{
|
17 |
protected $usedFilters;
|
18 |
protected $usedTags;
|
27 |
parent::__construct();
|
28 |
}
|
29 |
|
30 |
+
public function compile(Twig_Compiler $compiler)
|
31 |
{
|
32 |
+
$tags = $filters = $functions = array();
|
33 |
+
foreach (array('tags', 'filters', 'functions') as $type) {
|
34 |
foreach ($this->{'used'.ucfirst($type)} as $name => $node) {
|
35 |
+
if ($node instanceof Twig_Node) {
|
36 |
${$type}[$name] = $node->getTemplateLine();
|
37 |
} else {
|
38 |
${$type}[$node] = null;
|
46 |
->write('$functions = ')->repr(array_filter($functions))->raw(";\n\n")
|
47 |
->write("try {\n")
|
48 |
->indent()
|
49 |
+
->write("\$this->env->getExtension('Twig_Extension_Sandbox')->checkSecurity(\n")
|
50 |
->indent()
|
51 |
+
->write(!$tags ? "array(),\n" : "array('".implode("', '", array_keys($tags))."'),\n")
|
52 |
+
->write(!$filters ? "array(),\n" : "array('".implode("', '", array_keys($filters))."'),\n")
|
53 |
+
->write(!$functions ? "array()\n" : "array('".implode("', '", array_keys($functions))."')\n")
|
54 |
->outdent()
|
55 |
->write(");\n")
|
56 |
->outdent()
|
57 |
+
->write("} catch (Twig_Sandbox_SecurityError \$e) {\n")
|
58 |
->indent()
|
59 |
->write("\$e->setSourceContext(\$this->getSourceContext());\n\n")
|
60 |
+
->write("if (\$e instanceof Twig_Sandbox_SecurityNotAllowedTagError && isset(\$tags[\$e->getTagName()])) {\n")
|
61 |
->indent()
|
62 |
->write("\$e->setTemplateLine(\$tags[\$e->getTagName()]);\n")
|
63 |
->outdent()
|
64 |
+
->write("} elseif (\$e instanceof Twig_Sandbox_SecurityNotAllowedFilterError && isset(\$filters[\$e->getFilterName()])) {\n")
|
65 |
->indent()
|
66 |
->write("\$e->setTemplateLine(\$filters[\$e->getFilterName()]);\n")
|
67 |
->outdent()
|
68 |
+
->write("} elseif (\$e instanceof Twig_Sandbox_SecurityNotAllowedFunctionError && isset(\$functions[\$e->getFunctionName()])) {\n")
|
69 |
->indent()
|
70 |
->write("\$e->setTemplateLine(\$functions[\$e->getFunctionName()]);\n")
|
71 |
->outdent()
|
76 |
;
|
77 |
}
|
78 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Node/Deprecated.php
DELETED
@@ -1,54 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of Twig.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
use Twig\Compiler;
|
13 |
-
use Twig\Node\Expression\AbstractExpression;
|
14 |
-
use Twig\Node\Expression\ConstantExpression;
|
15 |
-
use Twig\Node\Node;
|
16 |
-
|
17 |
-
/**
|
18 |
-
* Represents a deprecated node.
|
19 |
-
*
|
20 |
-
* @author Yonel Ceruto <yonelceruto@gmail.com>
|
21 |
-
*/
|
22 |
-
class Twig_Node_Deprecated extends Node
|
23 |
-
{
|
24 |
-
public function __construct(AbstractExpression $expr, $lineno, $tag = null)
|
25 |
-
{
|
26 |
-
parent::__construct(['expr' => $expr], [], $lineno, $tag);
|
27 |
-
}
|
28 |
-
|
29 |
-
public function compile(Compiler $compiler)
|
30 |
-
{
|
31 |
-
$compiler->addDebugInfo($this);
|
32 |
-
|
33 |
-
$expr = $this->getNode('expr');
|
34 |
-
|
35 |
-
if ($expr instanceof ConstantExpression) {
|
36 |
-
$compiler->write('@trigger_error(')
|
37 |
-
->subcompile($expr);
|
38 |
-
} else {
|
39 |
-
$varName = $compiler->getVarName();
|
40 |
-
$compiler->write(sprintf('$%s = ', $varName))
|
41 |
-
->subcompile($expr)
|
42 |
-
->raw(";\n")
|
43 |
-
->write(sprintf('@trigger_error($%s', $varName));
|
44 |
-
}
|
45 |
-
|
46 |
-
$compiler
|
47 |
-
->raw('.')
|
48 |
-
->string(sprintf(' ("%s" at line %d).', $this->getTemplateName(), $this->getTemplateLine()))
|
49 |
-
->raw(", E_USER_DEPRECATED);\n")
|
50 |
-
;
|
51 |
-
}
|
52 |
-
}
|
53 |
-
|
54 |
-
class_alias('Twig_Node_Deprecated', 'Twig\Node\DeprecatedNode', false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/lib/Twig/Node/Do.php
CHANGED
@@ -9,23 +9,19 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Compiler;
|
13 |
-
use Twig\Node\Expression\AbstractExpression;
|
14 |
-
use Twig\Node\Node;
|
15 |
-
|
16 |
/**
|
17 |
* Represents a do node.
|
18 |
*
|
19 |
* @author Fabien Potencier <fabien@symfony.com>
|
20 |
*/
|
21 |
-
class Twig_Node_Do extends
|
22 |
{
|
23 |
-
public function __construct(
|
24 |
{
|
25 |
-
parent::__construct(
|
26 |
}
|
27 |
|
28 |
-
public function compile(
|
29 |
{
|
30 |
$compiler
|
31 |
->addDebugInfo($this)
|
@@ -35,5 +31,3 @@ class Twig_Node_Do extends Node
|
|
35 |
;
|
36 |
}
|
37 |
}
|
38 |
-
|
39 |
-
class_alias('Twig_Node_Do', 'Twig\Node\DoNode', false);
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
|
|
|
|
12 |
/**
|
13 |
* Represents a do node.
|
14 |
*
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
+
class Twig_Node_Do extends Twig_Node
|
18 |
{
|
19 |
+
public function __construct(Twig_Node_Expression $expr, $lineno, $tag = null)
|
20 |
{
|
21 |
+
parent::__construct(array('expr' => $expr), array(), $lineno, $tag);
|
22 |
}
|
23 |
|
24 |
+
public function compile(Twig_Compiler $compiler)
|
25 |
{
|
26 |
$compiler
|
27 |
->addDebugInfo($this)
|
31 |
;
|
32 |
}
|
33 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Node/Embed.php
CHANGED
@@ -9,22 +9,17 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Compiler;
|
13 |
-
use Twig\Node\Expression\AbstractExpression;
|
14 |
-
use Twig\Node\Expression\ConstantExpression;
|
15 |
-
use Twig\Node\IncludeNode;
|
16 |
-
|
17 |
/**
|
18 |
* Represents an embed node.
|
19 |
*
|
20 |
* @author Fabien Potencier <fabien@symfony.com>
|
21 |
*/
|
22 |
-
class Twig_Node_Embed extends
|
23 |
{
|
24 |
// we don't inject the module to avoid node visitors to traverse it twice (as it will be already visited in the main module)
|
25 |
-
public function __construct($name, $index,
|
26 |
{
|
27 |
-
parent::__construct(new
|
28 |
|
29 |
$this->setAttribute('name', $name);
|
30 |
// to be removed in 2.0, used name instead
|
@@ -32,7 +27,7 @@ class Twig_Node_Embed extends IncludeNode
|
|
32 |
$this->setAttribute('index', $index);
|
33 |
}
|
34 |
|
35 |
-
protected function addGetTemplate(
|
36 |
{
|
37 |
$compiler
|
38 |
->write('$this->loadTemplate(')
|
@@ -47,5 +42,3 @@ class Twig_Node_Embed extends IncludeNode
|
|
47 |
;
|
48 |
}
|
49 |
}
|
50 |
-
|
51 |
-
class_alias('Twig_Node_Embed', 'Twig\Node\EmbedNode', false);
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
|
|
|
|
|
|
12 |
/**
|
13 |
* Represents an embed node.
|
14 |
*
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
+
class Twig_Node_Embed extends Twig_Node_Include
|
18 |
{
|
19 |
// we don't inject the module to avoid node visitors to traverse it twice (as it will be already visited in the main module)
|
20 |
+
public function __construct($name, $index, Twig_Node_Expression $variables = null, $only = false, $ignoreMissing = false, $lineno, $tag = null)
|
21 |
{
|
22 |
+
parent::__construct(new Twig_Node_Expression_Constant('not_used', $lineno), $variables, $only, $ignoreMissing, $lineno, $tag);
|
23 |
|
24 |
$this->setAttribute('name', $name);
|
25 |
// to be removed in 2.0, used name instead
|
27 |
$this->setAttribute('index', $index);
|
28 |
}
|
29 |
|
30 |
+
protected function addGetTemplate(Twig_Compiler $compiler)
|
31 |
{
|
32 |
$compiler
|
33 |
->write('$this->loadTemplate(')
|
42 |
;
|
43 |
}
|
44 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Node/Expression.php
CHANGED
@@ -10,15 +10,11 @@
|
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
|
13 |
-
use Twig\Node\Node;
|
14 |
-
|
15 |
/**
|
16 |
* Abstract class for all nodes that represents an expression.
|
17 |
*
|
18 |
* @author Fabien Potencier <fabien@symfony.com>
|
19 |
*/
|
20 |
-
abstract class Twig_Node_Expression extends
|
21 |
{
|
22 |
}
|
23 |
-
|
24 |
-
class_alias('Twig_Node_Expression', 'Twig\Node\Expression\AbstractExpression', false);
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
|
|
|
|
|
13 |
/**
|
14 |
* Abstract class for all nodes that represents an expression.
|
15 |
*
|
16 |
* @author Fabien Potencier <fabien@symfony.com>
|
17 |
*/
|
18 |
+
abstract class Twig_Node_Expression extends Twig_Node
|
19 |
{
|
20 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Node/Expression/Array.php
CHANGED
@@ -8,22 +8,17 @@
|
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
-
|
12 |
-
use Twig\Compiler;
|
13 |
-
use Twig\Node\Expression\AbstractExpression;
|
14 |
-
use Twig\Node\Expression\ConstantExpression;
|
15 |
-
|
16 |
-
class Twig_Node_Expression_Array extends AbstractExpression
|
17 |
{
|
18 |
protected $index;
|
19 |
|
20 |
public function __construct(array $elements, $lineno)
|
21 |
{
|
22 |
-
parent::__construct($elements,
|
23 |
|
24 |
$this->index = -1;
|
25 |
foreach ($this->getKeyValuePairs() as $pair) {
|
26 |
-
if ($pair['key'] instanceof
|
27 |
$this->index = $pair['key']->getAttribute('value');
|
28 |
}
|
29 |
}
|
@@ -31,19 +26,19 @@ class Twig_Node_Expression_Array extends AbstractExpression
|
|
31 |
|
32 |
public function getKeyValuePairs()
|
33 |
{
|
34 |
-
$pairs =
|
35 |
|
36 |
foreach (array_chunk($this->nodes, 2) as $pair) {
|
37 |
-
$pairs[] =
|
38 |
'key' => $pair[0],
|
39 |
'value' => $pair[1],
|
40 |
-
|
41 |
}
|
42 |
|
43 |
return $pairs;
|
44 |
}
|
45 |
|
46 |
-
public function hasElement(
|
47 |
{
|
48 |
foreach ($this->getKeyValuePairs() as $pair) {
|
49 |
// we compare the string representation of the keys
|
@@ -56,18 +51,18 @@ class Twig_Node_Expression_Array extends AbstractExpression
|
|
56 |
return false;
|
57 |
}
|
58 |
|
59 |
-
public function addElement(
|
60 |
{
|
61 |
if (null === $key) {
|
62 |
-
$key = new
|
63 |
}
|
64 |
|
65 |
array_push($this->nodes, $key, $value);
|
66 |
}
|
67 |
|
68 |
-
public function compile(
|
69 |
{
|
70 |
-
$compiler->raw('
|
71 |
$first = true;
|
72 |
foreach ($this->getKeyValuePairs() as $pair) {
|
73 |
if (!$first) {
|
@@ -81,8 +76,6 @@ class Twig_Node_Expression_Array extends AbstractExpression
|
|
81 |
->subcompile($pair['value'])
|
82 |
;
|
83 |
}
|
84 |
-
$compiler->raw('
|
85 |
}
|
86 |
}
|
87 |
-
|
88 |
-
class_alias('Twig_Node_Expression_Array', 'Twig\Node\Expression\ArrayExpression', false);
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
+
class Twig_Node_Expression_Array extends Twig_Node_Expression
|
|
|
|
|
|
|
|
|
|
|
12 |
{
|
13 |
protected $index;
|
14 |
|
15 |
public function __construct(array $elements, $lineno)
|
16 |
{
|
17 |
+
parent::__construct($elements, array(), $lineno);
|
18 |
|
19 |
$this->index = -1;
|
20 |
foreach ($this->getKeyValuePairs() as $pair) {
|
21 |
+
if ($pair['key'] instanceof Twig_Node_Expression_Constant && ctype_digit((string) $pair['key']->getAttribute('value')) && $pair['key']->getAttribute('value') > $this->index) {
|
22 |
$this->index = $pair['key']->getAttribute('value');
|
23 |
}
|
24 |
}
|
26 |
|
27 |
public function getKeyValuePairs()
|
28 |
{
|
29 |
+
$pairs = array();
|
30 |
|
31 |
foreach (array_chunk($this->nodes, 2) as $pair) {
|
32 |
+
$pairs[] = array(
|
33 |
'key' => $pair[0],
|
34 |
'value' => $pair[1],
|
35 |
+
);
|
36 |
}
|
37 |
|
38 |
return $pairs;
|
39 |
}
|
40 |
|
41 |
+
public function hasElement(Twig_Node_Expression $key)
|
42 |
{
|
43 |
foreach ($this->getKeyValuePairs() as $pair) {
|
44 |
// we compare the string representation of the keys
|
51 |
return false;
|
52 |
}
|
53 |
|
54 |
+
public function addElement(Twig_Node_Expression $value, Twig_Node_Expression $key = null)
|
55 |
{
|
56 |
if (null === $key) {
|
57 |
+
$key = new Twig_Node_Expression_Constant(++$this->index, $value->getTemplateLine());
|
58 |
}
|
59 |
|
60 |
array_push($this->nodes, $key, $value);
|
61 |
}
|
62 |
|
63 |
+
public function compile(Twig_Compiler $compiler)
|
64 |
{
|
65 |
+
$compiler->raw('array(');
|
66 |
$first = true;
|
67 |
foreach ($this->getKeyValuePairs() as $pair) {
|
68 |
if (!$first) {
|
76 |
->subcompile($pair['value'])
|
77 |
;
|
78 |
}
|
79 |
+
$compiler->raw(')');
|
80 |
}
|
81 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Node/Expression/AssignName.php
CHANGED
@@ -10,12 +10,9 @@
|
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
|
13 |
-
|
14 |
-
use Twig\Node\Expression\NameExpression;
|
15 |
-
|
16 |
-
class Twig_Node_Expression_AssignName extends NameExpression
|
17 |
{
|
18 |
-
public function compile(
|
19 |
{
|
20 |
$compiler
|
21 |
->raw('$context[')
|
@@ -24,5 +21,3 @@ class Twig_Node_Expression_AssignName extends NameExpression
|
|
24 |
;
|
25 |
}
|
26 |
}
|
27 |
-
|
28 |
-
class_alias('Twig_Node_Expression_AssignName', 'Twig\Node\Expression\AssignNameExpression', false);
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
|
13 |
+
class Twig_Node_Expression_AssignName extends Twig_Node_Expression_Name
|
|
|
|
|
|
|
14 |
{
|
15 |
+
public function compile(Twig_Compiler $compiler)
|
16 |
{
|
17 |
$compiler
|
18 |
->raw('$context[')
|
21 |
;
|
22 |
}
|
23 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Node/Expression/Binary.php
CHANGED
@@ -9,18 +9,14 @@
|
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
-
|
13 |
-
use Twig\Compiler;
|
14 |
-
use Twig\Node\Expression\AbstractExpression;
|
15 |
-
|
16 |
-
abstract class Twig_Node_Expression_Binary extends AbstractExpression
|
17 |
{
|
18 |
public function __construct(Twig_NodeInterface $left, Twig_NodeInterface $right, $lineno)
|
19 |
{
|
20 |
-
parent::__construct(
|
21 |
}
|
22 |
|
23 |
-
public function compile(
|
24 |
{
|
25 |
$compiler
|
26 |
->raw('(')
|
@@ -35,7 +31,5 @@ abstract class Twig_Node_Expression_Binary extends AbstractExpression
|
|
35 |
;
|
36 |
}
|
37 |
|
38 |
-
abstract public function operator(
|
39 |
}
|
40 |
-
|
41 |
-
class_alias('Twig_Node_Expression_Binary', 'Twig\Node\Expression\Binary\AbstractBinary', false);
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
+
abstract class Twig_Node_Expression_Binary extends Twig_Node_Expression
|
|
|
|
|
|
|
|
|
13 |
{
|
14 |
public function __construct(Twig_NodeInterface $left, Twig_NodeInterface $right, $lineno)
|
15 |
{
|
16 |
+
parent::__construct(array('left' => $left, 'right' => $right), array(), $lineno);
|
17 |
}
|
18 |
|
19 |
+
public function compile(Twig_Compiler $compiler)
|
20 |
{
|
21 |
$compiler
|
22 |
->raw('(')
|
31 |
;
|
32 |
}
|
33 |
|
34 |
+
abstract public function operator(Twig_Compiler $compiler);
|
35 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Node/Expression/Binary/Add.php
CHANGED
@@ -9,16 +9,10 @@
|
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
-
|
13 |
-
use Twig\Compiler;
|
14 |
-
use Twig\Node\Expression\Binary\AbstractBinary;
|
15 |
-
|
16 |
-
class Twig_Node_Expression_Binary_Add extends AbstractBinary
|
17 |
{
|
18 |
-
public function operator(
|
19 |
{
|
20 |
return $compiler->raw('+');
|
21 |
}
|
22 |
}
|
23 |
-
|
24 |
-
class_alias('Twig_Node_Expression_Binary_Add', 'Twig\Node\Expression\Binary\AddBinary', false);
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
+
class Twig_Node_Expression_Binary_Add extends Twig_Node_Expression_Binary
|
|
|
|
|
|
|
|
|
13 |
{
|
14 |
+
public function operator(Twig_Compiler $compiler)
|
15 |
{
|
16 |
return $compiler->raw('+');
|
17 |
}
|
18 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Node/Expression/Binary/And.php
CHANGED
@@ -9,16 +9,10 @@
|
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
-
|
13 |
-
use Twig\Compiler;
|
14 |
-
use Twig\Node\Expression\Binary\AbstractBinary;
|
15 |
-
|
16 |
-
class Twig_Node_Expression_Binary_And extends AbstractBinary
|
17 |
{
|
18 |
-
public function operator(
|
19 |
{
|
20 |
return $compiler->raw('&&');
|
21 |
}
|
22 |
}
|
23 |
-
|
24 |
-
class_alias('Twig_Node_Expression_Binary_And', 'Twig\Node\Expression\Binary\AndBinary', false);
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
+
class Twig_Node_Expression_Binary_And extends Twig_Node_Expression_Binary
|
|
|
|
|
|
|
|
|
13 |
{
|
14 |
+
public function operator(Twig_Compiler $compiler)
|
15 |
{
|
16 |
return $compiler->raw('&&');
|
17 |
}
|
18 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Node/Expression/Binary/BitwiseAnd.php
CHANGED
@@ -9,16 +9,10 @@
|
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
-
|
13 |
-
use Twig\Compiler;
|
14 |
-
use Twig\Node\Expression\Binary\AbstractBinary;
|
15 |
-
|
16 |
-
class Twig_Node_Expression_Binary_BitwiseAnd extends AbstractBinary
|
17 |
{
|
18 |
-
public function operator(
|
19 |
{
|
20 |
return $compiler->raw('&');
|
21 |
}
|
22 |
}
|
23 |
-
|
24 |
-
class_alias('Twig_Node_Expression_Binary_BitwiseAnd', 'Twig\Node\Expression\Binary\BitwiseAndBinary', false);
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
+
class Twig_Node_Expression_Binary_BitwiseAnd extends Twig_Node_Expression_Binary
|
|
|
|
|
|
|
|
|
13 |
{
|
14 |
+
public function operator(Twig_Compiler $compiler)
|
15 |
{
|
16 |
return $compiler->raw('&');
|
17 |
}
|
18 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Node/Expression/Binary/BitwiseOr.php
CHANGED
@@ -9,16 +9,10 @@
|
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
-
|
13 |
-
use Twig\Compiler;
|
14 |
-
use Twig\Node\Expression\Binary\AbstractBinary;
|
15 |
-
|
16 |
-
class Twig_Node_Expression_Binary_BitwiseOr extends AbstractBinary
|
17 |
{
|
18 |
-
public function operator(
|
19 |
{
|
20 |
return $compiler->raw('|');
|
21 |
}
|
22 |
}
|
23 |
-
|
24 |
-
class_alias('Twig_Node_Expression_Binary_BitwiseOr', 'Twig\Node\Expression\Binary\BitwiseOrBinary', false);
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
+
class Twig_Node_Expression_Binary_BitwiseOr extends Twig_Node_Expression_Binary
|
|
|
|
|
|
|
|
|
13 |
{
|
14 |
+
public function operator(Twig_Compiler $compiler)
|
15 |
{
|
16 |
return $compiler->raw('|');
|
17 |
}
|
18 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Node/Expression/Binary/BitwiseXor.php
CHANGED
@@ -9,16 +9,10 @@
|
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
-
|
13 |
-
use Twig\Compiler;
|
14 |
-
use Twig\Node\Expression\Binary\AbstractBinary;
|
15 |
-
|
16 |
-
class Twig_Node_Expression_Binary_BitwiseXor extends AbstractBinary
|
17 |
{
|
18 |
-
public function operator(
|
19 |
{
|
20 |
return $compiler->raw('^');
|
21 |
}
|
22 |
}
|
23 |
-
|
24 |
-
class_alias('Twig_Node_Expression_Binary_BitwiseXor', 'Twig\Node\Expression\Binary\BitwiseXorBinary', false);
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
+
class Twig_Node_Expression_Binary_BitwiseXor extends Twig_Node_Expression_Binary
|
|
|
|
|
|
|
|
|
13 |
{
|
14 |
+
public function operator(Twig_Compiler $compiler)
|
15 |
{
|
16 |
return $compiler->raw('^');
|
17 |
}
|
18 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Node/Expression/Binary/Concat.php
CHANGED
@@ -9,16 +9,10 @@
|
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
-
|
13 |
-
use Twig\Compiler;
|
14 |
-
use Twig\Node\Expression\Binary\AbstractBinary;
|
15 |
-
|
16 |
-
class Twig_Node_Expression_Binary_Concat extends AbstractBinary
|
17 |
{
|
18 |
-
public function operator(
|
19 |
{
|
20 |
return $compiler->raw('.');
|
21 |
}
|
22 |
}
|
23 |
-
|
24 |
-
class_alias('Twig_Node_Expression_Binary_Concat', 'Twig\Node\Expression\Binary\ConcatBinary', false);
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
+
class Twig_Node_Expression_Binary_Concat extends Twig_Node_Expression_Binary
|
|
|
|
|
|
|
|
|
13 |
{
|
14 |
+
public function operator(Twig_Compiler $compiler)
|
15 |
{
|
16 |
return $compiler->raw('.');
|
17 |
}
|
18 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Node/Expression/Binary/Div.php
CHANGED
@@ -9,16 +9,10 @@
|
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
-
|
13 |
-
use Twig\Compiler;
|
14 |
-
use Twig\Node\Expression\Binary\AbstractBinary;
|
15 |
-
|
16 |
-
class Twig_Node_Expression_Binary_Div extends AbstractBinary
|
17 |
{
|
18 |
-
public function operator(
|
19 |
{
|
20 |
return $compiler->raw('/');
|
21 |
}
|
22 |
}
|
23 |
-
|
24 |
-
class_alias('Twig_Node_Expression_Binary_Div', 'Twig\Node\Expression\Binary\DivBinary', false);
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
+
class Twig_Node_Expression_Binary_Div extends Twig_Node_Expression_Binary
|
|
|
|
|
|
|
|
|
13 |
{
|
14 |
+
public function operator(Twig_Compiler $compiler)
|
15 |
{
|
16 |
return $compiler->raw('/');
|
17 |
}
|
18 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Node/Expression/Binary/EndsWith.php
CHANGED
@@ -8,13 +8,9 @@
|
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
-
|
12 |
-
use Twig\Compiler;
|
13 |
-
use Twig\Node\Expression\Binary\AbstractBinary;
|
14 |
-
|
15 |
-
class Twig_Node_Expression_Binary_EndsWith extends AbstractBinary
|
16 |
{
|
17 |
-
public function compile(
|
18 |
{
|
19 |
$left = $compiler->getVarName();
|
20 |
$right = $compiler->getVarName();
|
@@ -27,10 +23,8 @@ class Twig_Node_Expression_Binary_EndsWith extends AbstractBinary
|
|
27 |
;
|
28 |
}
|
29 |
|
30 |
-
public function operator(
|
31 |
{
|
32 |
return $compiler->raw('');
|
33 |
}
|
34 |
}
|
35 |
-
|
36 |
-
class_alias('Twig_Node_Expression_Binary_EndsWith', 'Twig\Node\Expression\Binary\EndsWithBinary', false);
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
+
class Twig_Node_Expression_Binary_EndsWith extends Twig_Node_Expression_Binary
|
|
|
|
|
|
|
|
|
12 |
{
|
13 |
+
public function compile(Twig_Compiler $compiler)
|
14 |
{
|
15 |
$left = $compiler->getVarName();
|
16 |
$right = $compiler->getVarName();
|
23 |
;
|
24 |
}
|
25 |
|
26 |
+
public function operator(Twig_Compiler $compiler)
|
27 |
{
|
28 |
return $compiler->raw('');
|
29 |
}
|
30 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Node/Expression/Binary/Equal.php
CHANGED
@@ -8,16 +8,10 @@
|
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
-
|
12 |
-
use Twig\Compiler;
|
13 |
-
use Twig\Node\Expression\Binary\AbstractBinary;
|
14 |
-
|
15 |
-
class Twig_Node_Expression_Binary_Equal extends AbstractBinary
|
16 |
{
|
17 |
-
public function operator(
|
18 |
{
|
19 |
return $compiler->raw('==');
|
20 |
}
|
21 |
}
|
22 |
-
|
23 |
-
class_alias('Twig_Node_Expression_Binary_Equal', 'Twig\Node\Expression\Binary\EqualBinary', false);
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
+
class Twig_Node_Expression_Binary_Equal extends Twig_Node_Expression_Binary
|
|
|
|
|
|
|
|
|
12 |
{
|
13 |
+
public function operator(Twig_Compiler $compiler)
|
14 |
{
|
15 |
return $compiler->raw('==');
|
16 |
}
|
17 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Node/Expression/Binary/FloorDiv.php
CHANGED
@@ -8,23 +8,17 @@
|
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
-
|
12 |
-
use Twig\Compiler;
|
13 |
-
use Twig\Node\Expression\Binary\AbstractBinary;
|
14 |
-
|
15 |
-
class Twig_Node_Expression_Binary_FloorDiv extends AbstractBinary
|
16 |
{
|
17 |
-
public function compile(
|
18 |
{
|
19 |
$compiler->raw('(int) floor(');
|
20 |
parent::compile($compiler);
|
21 |
$compiler->raw(')');
|
22 |
}
|
23 |
|
24 |
-
public function operator(
|
25 |
{
|
26 |
return $compiler->raw('/');
|
27 |
}
|
28 |
}
|
29 |
-
|
30 |
-
class_alias('Twig_Node_Expression_Binary_FloorDiv', 'Twig\Node\Expression\Binary\FloorDivBinary', false);
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
+
class Twig_Node_Expression_Binary_FloorDiv extends Twig_Node_Expression_Binary
|
|
|
|
|
|
|
|
|
12 |
{
|
13 |
+
public function compile(Twig_Compiler $compiler)
|
14 |
{
|
15 |
$compiler->raw('(int) floor(');
|
16 |
parent::compile($compiler);
|
17 |
$compiler->raw(')');
|
18 |
}
|
19 |
|
20 |
+
public function operator(Twig_Compiler $compiler)
|
21 |
{
|
22 |
return $compiler->raw('/');
|
23 |
}
|
24 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Node/Expression/Binary/Greater.php
CHANGED
@@ -8,16 +8,10 @@
|
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
-
|
12 |
-
use Twig\Compiler;
|
13 |
-
use Twig\Node\Expression\Binary\AbstractBinary;
|
14 |
-
|
15 |
-
class Twig_Node_Expression_Binary_Greater extends AbstractBinary
|
16 |
{
|
17 |
-
public function operator(
|
18 |
{
|
19 |
return $compiler->raw('>');
|
20 |
}
|
21 |
}
|
22 |
-
|
23 |
-
class_alias('Twig_Node_Expression_Binary_Greater', 'Twig\Node\Expression\Binary\GreaterBinary', false);
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
+
class Twig_Node_Expression_Binary_Greater extends Twig_Node_Expression_Binary
|
|
|
|
|
|
|
|
|
12 |
{
|
13 |
+
public function operator(Twig_Compiler $compiler)
|
14 |
{
|
15 |
return $compiler->raw('>');
|
16 |
}
|
17 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Node/Expression/Binary/GreaterEqual.php
CHANGED
@@ -8,16 +8,10 @@
|
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
-
|
12 |
-
use Twig\Compiler;
|
13 |
-
use Twig\Node\Expression\Binary\AbstractBinary;
|
14 |
-
|
15 |
-
class Twig_Node_Expression_Binary_GreaterEqual extends AbstractBinary
|
16 |
{
|
17 |
-
public function operator(
|
18 |
{
|
19 |
return $compiler->raw('>=');
|
20 |
}
|
21 |
}
|
22 |
-
|
23 |
-
class_alias('Twig_Node_Expression_Binary_GreaterEqual', 'Twig\Node\Expression\Binary\GreaterEqualBinary', false);
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
+
class Twig_Node_Expression_Binary_GreaterEqual extends Twig_Node_Expression_Binary
|
|
|
|
|
|
|
|
|
12 |
{
|
13 |
+
public function operator(Twig_Compiler $compiler)
|
14 |
{
|
15 |
return $compiler->raw('>=');
|
16 |
}
|
17 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Node/Expression/Binary/In.php
CHANGED
@@ -8,13 +8,9 @@
|
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
-
|
12 |
-
use Twig\Compiler;
|
13 |
-
use Twig\Node\Expression\Binary\AbstractBinary;
|
14 |
-
|
15 |
-
class Twig_Node_Expression_Binary_In extends AbstractBinary
|
16 |
{
|
17 |
-
public function compile(
|
18 |
{
|
19 |
$compiler
|
20 |
->raw('twig_in_filter(')
|
@@ -25,10 +21,8 @@ class Twig_Node_Expression_Binary_In extends AbstractBinary
|
|
25 |
;
|
26 |
}
|
27 |
|
28 |
-
public function operator(
|
29 |
{
|
30 |
return $compiler->raw('in');
|
31 |
}
|
32 |
}
|
33 |
-
|
34 |
-
class_alias('Twig_Node_Expression_Binary_In', 'Twig\Node\Expression\Binary\InBinary', false);
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
+
class Twig_Node_Expression_Binary_In extends Twig_Node_Expression_Binary
|
|
|
|
|
|
|
|
|
12 |
{
|
13 |
+
public function compile(Twig_Compiler $compiler)
|
14 |
{
|
15 |
$compiler
|
16 |
->raw('twig_in_filter(')
|
21 |
;
|
22 |
}
|
23 |
|
24 |
+
public function operator(Twig_Compiler $compiler)
|
25 |
{
|
26 |
return $compiler->raw('in');
|
27 |
}
|
28 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Node/Expression/Binary/Less.php
CHANGED
@@ -8,16 +8,10 @@
|
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
-
|
12 |
-
use Twig\Compiler;
|
13 |
-
use Twig\Node\Expression\Binary\AbstractBinary;
|
14 |
-
|
15 |
-
class Twig_Node_Expression_Binary_Less extends AbstractBinary
|
16 |
{
|
17 |
-
public function operator(
|
18 |
{
|
19 |
return $compiler->raw('<');
|
20 |
}
|
21 |
}
|
22 |
-
|
23 |
-
class_alias('Twig_Node_Expression_Binary_Less', 'Twig\Node\Expression\Binary\LessBinary', false);
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
+
class Twig_Node_Expression_Binary_Less extends Twig_Node_Expression_Binary
|
|
|
|
|
|
|
|
|
12 |
{
|
13 |
+
public function operator(Twig_Compiler $compiler)
|
14 |
{
|
15 |
return $compiler->raw('<');
|
16 |
}
|
17 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Node/Expression/Binary/LessEqual.php
CHANGED
@@ -8,16 +8,10 @@
|
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
-
|
12 |
-
use Twig\Compiler;
|
13 |
-
use Twig\Node\Expression\Binary\AbstractBinary;
|
14 |
-
|
15 |
-
class Twig_Node_Expression_Binary_LessEqual extends AbstractBinary
|
16 |
{
|
17 |
-
public function operator(
|
18 |
{
|
19 |
return $compiler->raw('<=');
|
20 |
}
|
21 |
}
|
22 |
-
|
23 |
-
class_alias('Twig_Node_Expression_Binary_LessEqual', 'Twig\Node\Expression\Binary\LessEqualBinary', false);
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
+
class Twig_Node_Expression_Binary_LessEqual extends Twig_Node_Expression_Binary
|
|
|
|
|
|
|
|
|
12 |
{
|
13 |
+
public function operator(Twig_Compiler $compiler)
|
14 |
{
|
15 |
return $compiler->raw('<=');
|
16 |
}
|
17 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Node/Expression/Binary/Matches.php
CHANGED
@@ -8,13 +8,9 @@
|
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
-
|
12 |
-
use Twig\Compiler;
|
13 |
-
use Twig\Node\Expression\Binary\AbstractBinary;
|
14 |
-
|
15 |
-
class Twig_Node_Expression_Binary_Matches extends AbstractBinary
|
16 |
{
|
17 |
-
public function compile(
|
18 |
{
|
19 |
$compiler
|
20 |
->raw('preg_match(')
|
@@ -25,10 +21,8 @@ class Twig_Node_Expression_Binary_Matches extends AbstractBinary
|
|
25 |
;
|
26 |
}
|
27 |
|
28 |
-
public function operator(
|
29 |
{
|
30 |
return $compiler->raw('');
|
31 |
}
|
32 |
}
|
33 |
-
|
34 |
-
class_alias('Twig_Node_Expression_Binary_Matches', 'Twig\Node\Expression\Binary\MatchesBinary', false);
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
+
class Twig_Node_Expression_Binary_Matches extends Twig_Node_Expression_Binary
|
|
|
|
|
|
|
|
|
12 |
{
|
13 |
+
public function compile(Twig_Compiler $compiler)
|
14 |
{
|
15 |
$compiler
|
16 |
->raw('preg_match(')
|
21 |
;
|
22 |
}
|
23 |
|
24 |
+
public function operator(Twig_Compiler $compiler)
|
25 |
{
|
26 |
return $compiler->raw('');
|
27 |
}
|
28 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Node/Expression/Binary/Mod.php
CHANGED
@@ -9,16 +9,10 @@
|
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
-
|
13 |
-
use Twig\Compiler;
|
14 |
-
use Twig\Node\Expression\Binary\AbstractBinary;
|
15 |
-
|
16 |
-
class Twig_Node_Expression_Binary_Mod extends AbstractBinary
|
17 |
{
|
18 |
-
public function operator(
|
19 |
{
|
20 |
return $compiler->raw('%');
|
21 |
}
|
22 |
}
|
23 |
-
|
24 |
-
class_alias('Twig_Node_Expression_Binary_Mod', 'Twig\Node\Expression\Binary\ModBinary', false);
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
+
class Twig_Node_Expression_Binary_Mod extends Twig_Node_Expression_Binary
|
|
|
|
|
|
|
|
|
13 |
{
|
14 |
+
public function operator(Twig_Compiler $compiler)
|
15 |
{
|
16 |
return $compiler->raw('%');
|
17 |
}
|
18 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Node/Expression/Binary/Mul.php
CHANGED
@@ -9,16 +9,10 @@
|
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
-
|
13 |
-
use Twig\Compiler;
|
14 |
-
use Twig\Node\Expression\Binary\AbstractBinary;
|
15 |
-
|
16 |
-
class Twig_Node_Expression_Binary_Mul extends AbstractBinary
|
17 |
{
|
18 |
-
public function operator(
|
19 |
{
|
20 |
return $compiler->raw('*');
|
21 |
}
|
22 |
}
|
23 |
-
|
24 |
-
class_alias('Twig_Node_Expression_Binary_Mul', 'Twig\Node\Expression\Binary\MulBinary', false);
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
+
class Twig_Node_Expression_Binary_Mul extends Twig_Node_Expression_Binary
|
|
|
|
|
|
|
|
|
13 |
{
|
14 |
+
public function operator(Twig_Compiler $compiler)
|
15 |
{
|
16 |
return $compiler->raw('*');
|
17 |
}
|
18 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Node/Expression/Binary/NotEqual.php
CHANGED
@@ -8,16 +8,10 @@
|
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
-
|
12 |
-
use Twig\Compiler;
|
13 |
-
use Twig\Node\Expression\Binary\AbstractBinary;
|
14 |
-
|
15 |
-
class Twig_Node_Expression_Binary_NotEqual extends AbstractBinary
|
16 |
{
|
17 |
-
public function operator(
|
18 |
{
|
19 |
return $compiler->raw('!=');
|
20 |
}
|
21 |
}
|
22 |
-
|
23 |
-
class_alias('Twig_Node_Expression_Binary_NotEqual', 'Twig\Node\Expression\Binary\NotEqualBinary', false);
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
+
class Twig_Node_Expression_Binary_NotEqual extends Twig_Node_Expression_Binary
|
|
|
|
|
|
|
|
|
12 |
{
|
13 |
+
public function operator(Twig_Compiler $compiler)
|
14 |
{
|
15 |
return $compiler->raw('!=');
|
16 |
}
|
17 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Node/Expression/Binary/NotIn.php
CHANGED
@@ -8,13 +8,9 @@
|
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
-
|
12 |
-
use Twig\Compiler;
|
13 |
-
use Twig\Node\Expression\Binary\AbstractBinary;
|
14 |
-
|
15 |
-
class Twig_Node_Expression_Binary_NotIn extends AbstractBinary
|
16 |
{
|
17 |
-
public function compile(
|
18 |
{
|
19 |
$compiler
|
20 |
->raw('!twig_in_filter(')
|
@@ -25,10 +21,8 @@ class Twig_Node_Expression_Binary_NotIn extends AbstractBinary
|
|
25 |
;
|
26 |
}
|
27 |
|
28 |
-
public function operator(
|
29 |
{
|
30 |
return $compiler->raw('not in');
|
31 |
}
|
32 |
}
|
33 |
-
|
34 |
-
class_alias('Twig_Node_Expression_Binary_NotIn', 'Twig\Node\Expression\Binary\NotInBinary', false);
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
+
class Twig_Node_Expression_Binary_NotIn extends Twig_Node_Expression_Binary
|
|
|
|
|
|
|
|
|
12 |
{
|
13 |
+
public function compile(Twig_Compiler $compiler)
|
14 |
{
|
15 |
$compiler
|
16 |
->raw('!twig_in_filter(')
|
21 |
;
|
22 |
}
|
23 |
|
24 |
+
public function operator(Twig_Compiler $compiler)
|
25 |
{
|
26 |
return $compiler->raw('not in');
|
27 |
}
|
28 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Node/Expression/Binary/Or.php
CHANGED
@@ -9,16 +9,10 @@
|
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
-
|
13 |
-
use Twig\Compiler;
|
14 |
-
use Twig\Node\Expression\Binary\AbstractBinary;
|
15 |
-
|
16 |
-
class Twig_Node_Expression_Binary_Or extends AbstractBinary
|
17 |
{
|
18 |
-
public function operator(
|
19 |
{
|
20 |
return $compiler->raw('||');
|
21 |
}
|
22 |
}
|
23 |
-
|
24 |
-
class_alias('Twig_Node_Expression_Binary_Or', 'Twig\Node\Expression\Binary\OrBinary', false);
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
+
class Twig_Node_Expression_Binary_Or extends Twig_Node_Expression_Binary
|
|
|
|
|
|
|
|
|
13 |
{
|
14 |
+
public function operator(Twig_Compiler $compiler)
|
15 |
{
|
16 |
return $compiler->raw('||');
|
17 |
}
|
18 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Node/Expression/Binary/Power.php
CHANGED
@@ -8,13 +8,9 @@
|
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
-
|
12 |
-
use Twig\Compiler;
|
13 |
-
use Twig\Node\Expression\Binary\AbstractBinary;
|
14 |
-
|
15 |
-
class Twig_Node_Expression_Binary_Power extends AbstractBinary
|
16 |
{
|
17 |
-
public function compile(
|
18 |
{
|
19 |
if (PHP_VERSION_ID >= 50600) {
|
20 |
return parent::compile($compiler);
|
@@ -29,10 +25,8 @@ class Twig_Node_Expression_Binary_Power extends AbstractBinary
|
|
29 |
;
|
30 |
}
|
31 |
|
32 |
-
public function operator(
|
33 |
{
|
34 |
return $compiler->raw('**');
|
35 |
}
|
36 |
}
|
37 |
-
|
38 |
-
class_alias('Twig_Node_Expression_Binary_Power', 'Twig\Node\Expression\Binary\PowerBinary', false);
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
+
class Twig_Node_Expression_Binary_Power extends Twig_Node_Expression_Binary
|
|
|
|
|
|
|
|
|
12 |
{
|
13 |
+
public function compile(Twig_Compiler $compiler)
|
14 |
{
|
15 |
if (PHP_VERSION_ID >= 50600) {
|
16 |
return parent::compile($compiler);
|
25 |
;
|
26 |
}
|
27 |
|
28 |
+
public function operator(Twig_Compiler $compiler)
|
29 |
{
|
30 |
return $compiler->raw('**');
|
31 |
}
|
32 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Node/Expression/Binary/Range.php
CHANGED
@@ -8,13 +8,9 @@
|
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
-
|
12 |
-
use Twig\Compiler;
|
13 |
-
use Twig\Node\Expression\Binary\AbstractBinary;
|
14 |
-
|
15 |
-
class Twig_Node_Expression_Binary_Range extends AbstractBinary
|
16 |
{
|
17 |
-
public function compile(
|
18 |
{
|
19 |
$compiler
|
20 |
->raw('range(')
|
@@ -25,10 +21,8 @@ class Twig_Node_Expression_Binary_Range extends AbstractBinary
|
|
25 |
;
|
26 |
}
|
27 |
|
28 |
-
public function operator(
|
29 |
{
|
30 |
return $compiler->raw('..');
|
31 |
}
|
32 |
}
|
33 |
-
|
34 |
-
class_alias('Twig_Node_Expression_Binary_Range', 'Twig\Node\Expression\Binary\RangeBinary', false);
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
+
class Twig_Node_Expression_Binary_Range extends Twig_Node_Expression_Binary
|
|
|
|
|
|
|
|
|
12 |
{
|
13 |
+
public function compile(Twig_Compiler $compiler)
|
14 |
{
|
15 |
$compiler
|
16 |
->raw('range(')
|
21 |
;
|
22 |
}
|
23 |
|
24 |
+
public function operator(Twig_Compiler $compiler)
|
25 |
{
|
26 |
return $compiler->raw('..');
|
27 |
}
|
28 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Node/Expression/Binary/StartsWith.php
CHANGED
@@ -8,13 +8,9 @@
|
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
-
|
12 |
-
use Twig\Compiler;
|
13 |
-
use Twig\Node\Expression\Binary\AbstractBinary;
|
14 |
-
|
15 |
-
class Twig_Node_Expression_Binary_StartsWith extends AbstractBinary
|
16 |
{
|
17 |
-
public function compile(
|
18 |
{
|
19 |
$left = $compiler->getVarName();
|
20 |
$right = $compiler->getVarName();
|
@@ -27,10 +23,8 @@ class Twig_Node_Expression_Binary_StartsWith extends AbstractBinary
|
|
27 |
;
|
28 |
}
|
29 |
|
30 |
-
public function operator(
|
31 |
{
|
32 |
return $compiler->raw('');
|
33 |
}
|
34 |
}
|
35 |
-
|
36 |
-
class_alias('Twig_Node_Expression_Binary_StartsWith', 'Twig\Node\Expression\Binary\StartsWithBinary', false);
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
+
class Twig_Node_Expression_Binary_StartsWith extends Twig_Node_Expression_Binary
|
|
|
|
|
|
|
|
|
12 |
{
|
13 |
+
public function compile(Twig_Compiler $compiler)
|
14 |
{
|
15 |
$left = $compiler->getVarName();
|
16 |
$right = $compiler->getVarName();
|
23 |
;
|
24 |
}
|
25 |
|
26 |
+
public function operator(Twig_Compiler $compiler)
|
27 |
{
|
28 |
return $compiler->raw('');
|
29 |
}
|
30 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Node/Expression/Binary/Sub.php
CHANGED
@@ -9,16 +9,10 @@
|
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
-
|
13 |
-
use Twig\Compiler;
|
14 |
-
use Twig\Node\Expression\Binary\AbstractBinary;
|
15 |
-
|
16 |
-
class Twig_Node_Expression_Binary_Sub extends AbstractBinary
|
17 |
{
|
18 |
-
public function operator(
|
19 |
{
|
20 |
return $compiler->raw('-');
|
21 |
}
|
22 |
}
|
23 |
-
|
24 |
-
class_alias('Twig_Node_Expression_Binary_Sub', 'Twig\Node\Expression\Binary\SubBinary', false);
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
+
class Twig_Node_Expression_Binary_Sub extends Twig_Node_Expression_Binary
|
|
|
|
|
|
|
|
|
13 |
{
|
14 |
+
public function operator(Twig_Compiler $compiler)
|
15 |
{
|
16 |
return $compiler->raw('-');
|
17 |
}
|
18 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Node/Expression/BlockReference.php
CHANGED
@@ -10,37 +10,33 @@
|
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
|
13 |
-
use Twig\Compiler;
|
14 |
-
use Twig\Node\Expression\AbstractExpression;
|
15 |
-
use Twig\Node\Node;
|
16 |
-
|
17 |
/**
|
18 |
* Represents a block call node.
|
19 |
*
|
20 |
* @author Fabien Potencier <fabien@symfony.com>
|
21 |
*/
|
22 |
-
class Twig_Node_Expression_BlockReference extends
|
23 |
{
|
24 |
/**
|
25 |
-
* @param
|
26 |
*/
|
27 |
public function __construct(Twig_NodeInterface $name, $template = null, $lineno, $tag = null)
|
28 |
{
|
29 |
-
if (
|
30 |
@trigger_error(sprintf('The %s method "$asString" argument is deprecated since version 1.28 and will be removed in 2.0.', __METHOD__), E_USER_DEPRECATED);
|
31 |
|
32 |
$template = null;
|
33 |
}
|
34 |
|
35 |
-
$nodes =
|
36 |
if (null !== $template) {
|
37 |
$nodes['template'] = $template;
|
38 |
}
|
39 |
|
40 |
-
parent::__construct($nodes,
|
41 |
}
|
42 |
|
43 |
-
public function compile(
|
44 |
{
|
45 |
if ($this->getAttribute('is_defined_test')) {
|
46 |
$this->compileTemplateCall($compiler, 'hasBlock');
|
@@ -57,7 +53,7 @@ class Twig_Node_Expression_BlockReference extends AbstractExpression
|
|
57 |
}
|
58 |
}
|
59 |
|
60 |
-
private function compileTemplateCall(
|
61 |
{
|
62 |
if (!$this->hasNode('template')) {
|
63 |
$compiler->write('$this');
|
@@ -79,7 +75,7 @@ class Twig_Node_Expression_BlockReference extends AbstractExpression
|
|
79 |
return $compiler;
|
80 |
}
|
81 |
|
82 |
-
private function compileBlockArguments(
|
83 |
{
|
84 |
$compiler
|
85 |
->raw('(')
|
@@ -93,5 +89,3 @@ class Twig_Node_Expression_BlockReference extends AbstractExpression
|
|
93 |
return $compiler->raw(')');
|
94 |
}
|
95 |
}
|
96 |
-
|
97 |
-
class_alias('Twig_Node_Expression_BlockReference', 'Twig\Node\Expression\BlockReferenceExpression', false);
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
|
|
|
|
|
|
|
|
|
13 |
/**
|
14 |
* Represents a block call node.
|
15 |
*
|
16 |
* @author Fabien Potencier <fabien@symfony.com>
|
17 |
*/
|
18 |
+
class Twig_Node_Expression_BlockReference extends Twig_Node_Expression
|
19 |
{
|
20 |
/**
|
21 |
+
* @param Twig_Node|null $template
|
22 |
*/
|
23 |
public function __construct(Twig_NodeInterface $name, $template = null, $lineno, $tag = null)
|
24 |
{
|
25 |
+
if (is_bool($template)) {
|
26 |
@trigger_error(sprintf('The %s method "$asString" argument is deprecated since version 1.28 and will be removed in 2.0.', __METHOD__), E_USER_DEPRECATED);
|
27 |
|
28 |
$template = null;
|
29 |
}
|
30 |
|
31 |
+
$nodes = array('name' => $name);
|
32 |
if (null !== $template) {
|
33 |
$nodes['template'] = $template;
|
34 |
}
|
35 |
|
36 |
+
parent::__construct($nodes, array('is_defined_test' => false, 'output' => false), $lineno, $tag);
|
37 |
}
|
38 |
|
39 |
+
public function compile(Twig_Compiler $compiler)
|
40 |
{
|
41 |
if ($this->getAttribute('is_defined_test')) {
|
42 |
$this->compileTemplateCall($compiler, 'hasBlock');
|
53 |
}
|
54 |
}
|
55 |
|
56 |
+
private function compileTemplateCall(Twig_Compiler $compiler, $method)
|
57 |
{
|
58 |
if (!$this->hasNode('template')) {
|
59 |
$compiler->write('$this');
|
75 |
return $compiler;
|
76 |
}
|
77 |
|
78 |
+
private function compileBlockArguments(Twig_Compiler $compiler)
|
79 |
{
|
80 |
$compiler
|
81 |
->raw('(')
|
89 |
return $compiler->raw(')');
|
90 |
}
|
91 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Node/Expression/Call.php
CHANGED
@@ -8,57 +8,46 @@
|
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
-
|
12 |
-
use Twig\Compiler;
|
13 |
-
use Twig\Error\SyntaxError;
|
14 |
-
use Twig\Extension\ExtensionInterface;
|
15 |
-
use Twig\Node\Expression\AbstractExpression;
|
16 |
-
use Twig\Node\Expression\ArrayExpression;
|
17 |
-
use Twig\Node\Expression\ConstantExpression;
|
18 |
-
use Twig\Node\Node;
|
19 |
-
|
20 |
-
abstract class Twig_Node_Expression_Call extends AbstractExpression
|
21 |
{
|
22 |
private $reflector;
|
23 |
|
24 |
-
protected function compileCallable(
|
25 |
{
|
26 |
$closingParenthesis = false;
|
27 |
-
$isArray = false;
|
28 |
if ($this->hasAttribute('callable') && $callable = $this->getAttribute('callable')) {
|
29 |
-
if (
|
30 |
$compiler->raw($callable);
|
31 |
} else {
|
32 |
list($r, $callable) = $this->reflectCallable($callable);
|
33 |
-
if ($r instanceof
|
34 |
if ($r->isStatic()) {
|
35 |
$compiler->raw(sprintf('%s::%s', $callable[0], $callable[1]));
|
36 |
} else {
|
37 |
$compiler->raw(sprintf('$this->env->getRuntime(\'%s\')->%s', $callable[0], $callable[1]));
|
38 |
}
|
39 |
-
} elseif ($r instanceof
|
40 |
-
$compiler->raw(sprintf('$this->env->getExtension(\'%s\')->%s',
|
41 |
} else {
|
42 |
$type = ucfirst($this->getAttribute('type'));
|
43 |
-
$compiler->raw(sprintf('call_user_func_array($this->env->get%s(\'%s\')->getCallable(), ', $type, $this->getAttribute('name')));
|
44 |
$closingParenthesis = true;
|
45 |
-
$isArray = true;
|
46 |
}
|
47 |
}
|
48 |
} else {
|
49 |
$compiler->raw($this->getAttribute('thing')->compile());
|
50 |
}
|
51 |
|
52 |
-
$this->compileArguments($compiler
|
53 |
|
54 |
if ($closingParenthesis) {
|
55 |
$compiler->raw(')');
|
56 |
}
|
57 |
}
|
58 |
|
59 |
-
protected function compileArguments(
|
60 |
{
|
61 |
-
$compiler->raw(
|
62 |
|
63 |
$first = true;
|
64 |
|
@@ -107,7 +96,7 @@ abstract class Twig_Node_Expression_Call extends AbstractExpression
|
|
107 |
}
|
108 |
}
|
109 |
|
110 |
-
$compiler->raw(
|
111 |
}
|
112 |
|
113 |
protected function getArguments($callable, $arguments)
|
@@ -115,14 +104,14 @@ abstract class Twig_Node_Expression_Call extends AbstractExpression
|
|
115 |
$callType = $this->getAttribute('type');
|
116 |
$callName = $this->getAttribute('name');
|
117 |
|
118 |
-
$parameters =
|
119 |
$named = false;
|
120 |
foreach ($arguments as $name => $node) {
|
121 |
-
if (
|
122 |
$named = true;
|
123 |
$name = $this->normalizeName($name);
|
124 |
} elseif ($named) {
|
125 |
-
throw new
|
126 |
}
|
127 |
|
128 |
$parameters[$name] = $node;
|
@@ -140,42 +129,42 @@ abstract class Twig_Node_Expression_Call extends AbstractExpression
|
|
140 |
$message = sprintf('Arbitrary positional arguments are not supported for %s "%s".', $callType, $callName);
|
141 |
}
|
142 |
|
143 |
-
throw new
|
144 |
}
|
145 |
|
146 |
$callableParameters = $this->getCallableParameters($callable, $isVariadic);
|
147 |
-
$arguments =
|
148 |
-
$names =
|
149 |
-
$missingArguments =
|
150 |
-
$optionalArguments =
|
151 |
$pos = 0;
|
152 |
foreach ($callableParameters as $callableParameter) {
|
153 |
$names[] = $name = $this->normalizeName($callableParameter->name);
|
154 |
|
155 |
-
if (
|
156 |
-
if (
|
157 |
-
throw new
|
158 |
}
|
159 |
|
160 |
-
if (
|
161 |
-
throw new
|
162 |
'Argument "%s" could not be assigned for %s "%s(%s)" because it is mapped to an internal PHP function which cannot determine default value for optional argument%s "%s".',
|
163 |
-
$name, $callType, $callName, implode(', ', $names),
|
164 |
-
)
|
165 |
}
|
166 |
|
167 |
$arguments = array_merge($arguments, $optionalArguments);
|
168 |
$arguments[] = $parameters[$name];
|
169 |
unset($parameters[$name]);
|
170 |
-
$optionalArguments =
|
171 |
-
} elseif (
|
172 |
$arguments = array_merge($arguments, $optionalArguments);
|
173 |
$arguments[] = $parameters[$pos];
|
174 |
unset($parameters[$pos]);
|
175 |
-
$optionalArguments =
|
176 |
++$pos;
|
177 |
} elseif ($callableParameter->isDefaultValueAvailable()) {
|
178 |
-
$optionalArguments[] = new
|
179 |
} elseif ($callableParameter->isOptional()) {
|
180 |
if (empty($parameters)) {
|
181 |
break;
|
@@ -183,17 +172,17 @@ abstract class Twig_Node_Expression_Call extends AbstractExpression
|
|
183 |
$missingArguments[] = $name;
|
184 |
}
|
185 |
} else {
|
186 |
-
throw new
|
187 |
}
|
188 |
}
|
189 |
|
190 |
if ($isVariadic) {
|
191 |
-
$arbitraryArguments = new
|
192 |
foreach ($parameters as $key => $value) {
|
193 |
-
if (
|
194 |
$arbitraryArguments->addElement($value);
|
195 |
} else {
|
196 |
-
$arbitraryArguments->addElement($value, new
|
197 |
}
|
198 |
unset($parameters[$key]);
|
199 |
}
|
@@ -207,16 +196,16 @@ abstract class Twig_Node_Expression_Call extends AbstractExpression
|
|
207 |
if (!empty($parameters)) {
|
208 |
$unknownParameter = null;
|
209 |
foreach ($parameters as $parameter) {
|
210 |
-
if ($parameter instanceof
|
211 |
$unknownParameter = $parameter;
|
212 |
break;
|
213 |
}
|
214 |
}
|
215 |
|
216 |
-
throw new
|
217 |
'Unknown argument%s "%s" for %s "%s(%s)".',
|
218 |
-
|
219 |
-
), $unknownParameter ? $unknownParameter->getTemplateLine() :
|
220 |
}
|
221 |
|
222 |
return $arguments;
|
@@ -224,14 +213,14 @@ abstract class Twig_Node_Expression_Call extends AbstractExpression
|
|
224 |
|
225 |
protected function normalizeName($name)
|
226 |
{
|
227 |
-
return strtolower(preg_replace(
|
228 |
}
|
229 |
|
230 |
private function getCallableParameters($callable, $isVariadic)
|
231 |
{
|
232 |
list($r) = $this->reflectCallable($callable);
|
233 |
if (null === $r) {
|
234 |
-
return
|
235 |
}
|
236 |
|
237 |
$parameters = $r->getParameters();
|
@@ -251,15 +240,15 @@ abstract class Twig_Node_Expression_Call extends AbstractExpression
|
|
251 |
}
|
252 |
if ($isVariadic) {
|
253 |
$argument = end($parameters);
|
254 |
-
if ($argument && $argument->isArray() && $argument->isDefaultValueAvailable() &&
|
255 |
array_pop($parameters);
|
256 |
} else {
|
257 |
$callableName = $r->name;
|
258 |
-
if ($r instanceof
|
259 |
$callableName = $r->getDeclaringClass()->name.'::'.$callableName;
|
260 |
}
|
261 |
|
262 |
-
throw new
|
263 |
}
|
264 |
}
|
265 |
|
@@ -272,31 +261,29 @@ abstract class Twig_Node_Expression_Call extends AbstractExpression
|
|
272 |
return $this->reflector;
|
273 |
}
|
274 |
|
275 |
-
if (
|
276 |
if (!method_exists($callable[0], $callable[1])) {
|
277 |
// __call()
|
278 |
-
return
|
279 |
}
|
280 |
-
$r = new
|
281 |
-
} elseif (
|
282 |
-
$r = new
|
283 |
$r = $r->getMethod('__invoke');
|
284 |
-
$callable =
|
285 |
-
} elseif (
|
286 |
$class = substr($callable, 0, $pos);
|
287 |
$method = substr($callable, $pos + 2);
|
288 |
if (!method_exists($class, $method)) {
|
289 |
// __staticCall()
|
290 |
-
return
|
291 |
}
|
292 |
-
$r = new
|
293 |
-
$callable =
|
294 |
} else {
|
295 |
-
$r = new
|
296 |
}
|
297 |
|
298 |
-
return $this->reflector =
|
299 |
}
|
300 |
}
|
301 |
-
|
302 |
-
class_alias('Twig_Node_Expression_Call', 'Twig\Node\Expression\CallExpression', false);
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
+
abstract class Twig_Node_Expression_Call extends Twig_Node_Expression
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
{
|
13 |
private $reflector;
|
14 |
|
15 |
+
protected function compileCallable(Twig_Compiler $compiler)
|
16 |
{
|
17 |
$closingParenthesis = false;
|
|
|
18 |
if ($this->hasAttribute('callable') && $callable = $this->getAttribute('callable')) {
|
19 |
+
if (is_string($callable) && false === strpos($callable, '::')) {
|
20 |
$compiler->raw($callable);
|
21 |
} else {
|
22 |
list($r, $callable) = $this->reflectCallable($callable);
|
23 |
+
if ($r instanceof ReflectionMethod && is_string($callable[0])) {
|
24 |
if ($r->isStatic()) {
|
25 |
$compiler->raw(sprintf('%s::%s', $callable[0], $callable[1]));
|
26 |
} else {
|
27 |
$compiler->raw(sprintf('$this->env->getRuntime(\'%s\')->%s', $callable[0], $callable[1]));
|
28 |
}
|
29 |
+
} elseif ($r instanceof ReflectionMethod && $callable[0] instanceof Twig_ExtensionInterface) {
|
30 |
+
$compiler->raw(sprintf('$this->env->getExtension(\'%s\')->%s', get_class($callable[0]), $callable[1]));
|
31 |
} else {
|
32 |
$type = ucfirst($this->getAttribute('type'));
|
33 |
+
$compiler->raw(sprintf('call_user_func_array($this->env->get%s(\'%s\')->getCallable(), array', $type, $this->getAttribute('name')));
|
34 |
$closingParenthesis = true;
|
|
|
35 |
}
|
36 |
}
|
37 |
} else {
|
38 |
$compiler->raw($this->getAttribute('thing')->compile());
|
39 |
}
|
40 |
|
41 |
+
$this->compileArguments($compiler);
|
42 |
|
43 |
if ($closingParenthesis) {
|
44 |
$compiler->raw(')');
|
45 |
}
|
46 |
}
|
47 |
|
48 |
+
protected function compileArguments(Twig_Compiler $compiler)
|
49 |
{
|
50 |
+
$compiler->raw('(');
|
51 |
|
52 |
$first = true;
|
53 |
|
96 |
}
|
97 |
}
|
98 |
|
99 |
+
$compiler->raw(')');
|
100 |
}
|
101 |
|
102 |
protected function getArguments($callable, $arguments)
|
104 |
$callType = $this->getAttribute('type');
|
105 |
$callName = $this->getAttribute('name');
|
106 |
|
107 |
+
$parameters = array();
|
108 |
$named = false;
|
109 |
foreach ($arguments as $name => $node) {
|
110 |
+
if (!is_int($name)) {
|
111 |
$named = true;
|
112 |
$name = $this->normalizeName($name);
|
113 |
} elseif ($named) {
|
114 |
+
throw new Twig_Error_Syntax(sprintf('Positional arguments cannot be used after named arguments for %s "%s".', $callType, $callName));
|
115 |
}
|
116 |
|
117 |
$parameters[$name] = $node;
|
129 |
$message = sprintf('Arbitrary positional arguments are not supported for %s "%s".', $callType, $callName);
|
130 |
}
|
131 |
|
132 |
+
throw new LogicException($message);
|
133 |
}
|
134 |
|
135 |
$callableParameters = $this->getCallableParameters($callable, $isVariadic);
|
136 |
+
$arguments = array();
|
137 |
+
$names = array();
|
138 |
+
$missingArguments = array();
|
139 |
+
$optionalArguments = array();
|
140 |
$pos = 0;
|
141 |
foreach ($callableParameters as $callableParameter) {
|
142 |
$names[] = $name = $this->normalizeName($callableParameter->name);
|
143 |
|
144 |
+
if (array_key_exists($name, $parameters)) {
|
145 |
+
if (array_key_exists($pos, $parameters)) {
|
146 |
+
throw new Twig_Error_Syntax(sprintf('Argument "%s" is defined twice for %s "%s".', $name, $callType, $callName));
|
147 |
}
|
148 |
|
149 |
+
if (count($missingArguments)) {
|
150 |
+
throw new Twig_Error_Syntax(sprintf(
|
151 |
'Argument "%s" could not be assigned for %s "%s(%s)" because it is mapped to an internal PHP function which cannot determine default value for optional argument%s "%s".',
|
152 |
+
$name, $callType, $callName, implode(', ', $names), count($missingArguments) > 1 ? 's' : '', implode('", "', $missingArguments))
|
153 |
+
);
|
154 |
}
|
155 |
|
156 |
$arguments = array_merge($arguments, $optionalArguments);
|
157 |
$arguments[] = $parameters[$name];
|
158 |
unset($parameters[$name]);
|
159 |
+
$optionalArguments = array();
|
160 |
+
} elseif (array_key_exists($pos, $parameters)) {
|
161 |
$arguments = array_merge($arguments, $optionalArguments);
|
162 |
$arguments[] = $parameters[$pos];
|
163 |
unset($parameters[$pos]);
|
164 |
+
$optionalArguments = array();
|
165 |
++$pos;
|
166 |
} elseif ($callableParameter->isDefaultValueAvailable()) {
|
167 |
+
$optionalArguments[] = new Twig_Node_Expression_Constant($callableParameter->getDefaultValue(), -1);
|
168 |
} elseif ($callableParameter->isOptional()) {
|
169 |
if (empty($parameters)) {
|
170 |
break;
|
172 |
$missingArguments[] = $name;
|
173 |
}
|
174 |
} else {
|
175 |
+
throw new Twig_Error_Syntax(sprintf('Value for argument "%s" is required for %s "%s".', $name, $callType, $callName));
|
176 |
}
|
177 |
}
|
178 |
|
179 |
if ($isVariadic) {
|
180 |
+
$arbitraryArguments = new Twig_Node_Expression_Array(array(), -1);
|
181 |
foreach ($parameters as $key => $value) {
|
182 |
+
if (is_int($key)) {
|
183 |
$arbitraryArguments->addElement($value);
|
184 |
} else {
|
185 |
+
$arbitraryArguments->addElement($value, new Twig_Node_Expression_Constant($key, -1));
|
186 |
}
|
187 |
unset($parameters[$key]);
|
188 |
}
|
196 |
if (!empty($parameters)) {
|
197 |
$unknownParameter = null;
|
198 |
foreach ($parameters as $parameter) {
|
199 |
+
if ($parameter instanceof Twig_Node) {
|
200 |
$unknownParameter = $parameter;
|
201 |
break;
|
202 |
}
|
203 |
}
|
204 |
|
205 |
+
throw new Twig_Error_Syntax(sprintf(
|
206 |
'Unknown argument%s "%s" for %s "%s(%s)".',
|
207 |
+
count($parameters) > 1 ? 's' : '', implode('", "', array_keys($parameters)), $callType, $callName, implode(', ', $names)
|
208 |
+
), $unknownParameter ? $unknownParameter->getTemplateLine() : -1);
|
209 |
}
|
210 |
|
211 |
return $arguments;
|
213 |
|
214 |
protected function normalizeName($name)
|
215 |
{
|
216 |
+
return strtolower(preg_replace(array('/([A-Z]+)([A-Z][a-z])/', '/([a-z\d])([A-Z])/'), array('\\1_\\2', '\\1_\\2'), $name));
|
217 |
}
|
218 |
|
219 |
private function getCallableParameters($callable, $isVariadic)
|
220 |
{
|
221 |
list($r) = $this->reflectCallable($callable);
|
222 |
if (null === $r) {
|
223 |
+
return array();
|
224 |
}
|
225 |
|
226 |
$parameters = $r->getParameters();
|
240 |
}
|
241 |
if ($isVariadic) {
|
242 |
$argument = end($parameters);
|
243 |
+
if ($argument && $argument->isArray() && $argument->isDefaultValueAvailable() && array() === $argument->getDefaultValue()) {
|
244 |
array_pop($parameters);
|
245 |
} else {
|
246 |
$callableName = $r->name;
|
247 |
+
if ($r instanceof ReflectionMethod) {
|
248 |
$callableName = $r->getDeclaringClass()->name.'::'.$callableName;
|
249 |
}
|
250 |
|
251 |
+
throw new LogicException(sprintf('The last parameter of "%s" for %s "%s" must be an array with default value, eg. "array $arg = array()".', $callableName, $this->getAttribute('type'), $this->getAttribute('name')));
|
252 |
}
|
253 |
}
|
254 |
|
261 |
return $this->reflector;
|
262 |
}
|
263 |
|
264 |
+
if (is_array($callable)) {
|
265 |
if (!method_exists($callable[0], $callable[1])) {
|
266 |
// __call()
|
267 |
+
return array(null, array());
|
268 |
}
|
269 |
+
$r = new ReflectionMethod($callable[0], $callable[1]);
|
270 |
+
} elseif (is_object($callable) && !$callable instanceof Closure) {
|
271 |
+
$r = new ReflectionObject($callable);
|
272 |
$r = $r->getMethod('__invoke');
|
273 |
+
$callable = array($callable, '__invoke');
|
274 |
+
} elseif (is_string($callable) && false !== $pos = strpos($callable, '::')) {
|
275 |
$class = substr($callable, 0, $pos);
|
276 |
$method = substr($callable, $pos + 2);
|
277 |
if (!method_exists($class, $method)) {
|
278 |
// __staticCall()
|
279 |
+
return array(null, array());
|
280 |
}
|
281 |
+
$r = new ReflectionMethod($callable);
|
282 |
+
$callable = array($class, $method);
|
283 |
} else {
|
284 |
+
$r = new ReflectionFunction($callable);
|
285 |
}
|
286 |
|
287 |
+
return $this->reflector = array($r, $callable);
|
288 |
}
|
289 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Node/Expression/Conditional.php
CHANGED
@@ -9,18 +9,14 @@
|
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
-
|
13 |
-
use Twig\Compiler;
|
14 |
-
use Twig\Node\Expression\AbstractExpression;
|
15 |
-
|
16 |
-
class Twig_Node_Expression_Conditional extends AbstractExpression
|
17 |
{
|
18 |
-
public function __construct(
|
19 |
{
|
20 |
-
parent::__construct(
|
21 |
}
|
22 |
|
23 |
-
public function compile(
|
24 |
{
|
25 |
$compiler
|
26 |
->raw('((')
|
@@ -33,5 +29,3 @@ class Twig_Node_Expression_Conditional extends AbstractExpression
|
|
33 |
;
|
34 |
}
|
35 |
}
|
36 |
-
|
37 |
-
class_alias('Twig_Node_Expression_Conditional', 'Twig\Node\Expression\ConditionalExpression', false);
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
+
class Twig_Node_Expression_Conditional extends Twig_Node_Expression
|
|
|
|
|
|
|
|
|
13 |
{
|
14 |
+
public function __construct(Twig_Node_Expression $expr1, Twig_Node_Expression $expr2, Twig_Node_Expression $expr3, $lineno)
|
15 |
{
|
16 |
+
parent::__construct(array('expr1' => $expr1, 'expr2' => $expr2, 'expr3' => $expr3), array(), $lineno);
|
17 |
}
|
18 |
|
19 |
+
public function compile(Twig_Compiler $compiler)
|
20 |
{
|
21 |
$compiler
|
22 |
->raw('((')
|
29 |
;
|
30 |
}
|
31 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Node/Expression/Constant.php
CHANGED
@@ -9,21 +9,15 @@
|
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
-
|
13 |
-
use Twig\Compiler;
|
14 |
-
use Twig\Node\Expression\AbstractExpression;
|
15 |
-
|
16 |
-
class Twig_Node_Expression_Constant extends AbstractExpression
|
17 |
{
|
18 |
public function __construct($value, $lineno)
|
19 |
{
|
20 |
-
parent::__construct(
|
21 |
}
|
22 |
|
23 |
-
public function compile(
|
24 |
{
|
25 |
$compiler->repr($this->getAttribute('value'));
|
26 |
}
|
27 |
}
|
28 |
-
|
29 |
-
class_alias('Twig_Node_Expression_Constant', 'Twig\Node\Expression\ConstantExpression', false);
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
+
class Twig_Node_Expression_Constant extends Twig_Node_Expression
|
|
|
|
|
|
|
|
|
13 |
{
|
14 |
public function __construct($value, $lineno)
|
15 |
{
|
16 |
+
parent::__construct(array(), array('value' => $value), $lineno);
|
17 |
}
|
18 |
|
19 |
+
public function compile(Twig_Compiler $compiler)
|
20 |
{
|
21 |
$compiler->repr($this->getAttribute('value'));
|
22 |
}
|
23 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Node/Expression/ExtensionReference.php
CHANGED
@@ -9,9 +9,6 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Compiler;
|
13 |
-
use Twig\Node\Expression\AbstractExpression;
|
14 |
-
|
15 |
@trigger_error('The Twig_Node_Expression_ExtensionReference class is deprecated since version 1.23 and will be removed in 2.0.', E_USER_DEPRECATED);
|
16 |
|
17 |
/**
|
@@ -21,14 +18,14 @@ use Twig\Node\Expression\AbstractExpression;
|
|
21 |
*
|
22 |
* @deprecated since 1.23 and will be removed in 2.0.
|
23 |
*/
|
24 |
-
class Twig_Node_Expression_ExtensionReference extends
|
25 |
{
|
26 |
public function __construct($name, $lineno, $tag = null)
|
27 |
{
|
28 |
-
parent::__construct(
|
29 |
}
|
30 |
|
31 |
-
public function compile(
|
32 |
{
|
33 |
$compiler->raw(sprintf("\$this->env->getExtension('%s')", $this->getAttribute('name')));
|
34 |
}
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
|
|
12 |
@trigger_error('The Twig_Node_Expression_ExtensionReference class is deprecated since version 1.23 and will be removed in 2.0.', E_USER_DEPRECATED);
|
13 |
|
14 |
/**
|
18 |
*
|
19 |
* @deprecated since 1.23 and will be removed in 2.0.
|
20 |
*/
|
21 |
+
class Twig_Node_Expression_ExtensionReference extends Twig_Node_Expression
|
22 |
{
|
23 |
public function __construct($name, $lineno, $tag = null)
|
24 |
{
|
25 |
+
parent::__construct(array(), array('name' => $name), $lineno, $tag);
|
26 |
}
|
27 |
|
28 |
+
public function compile(Twig_Compiler $compiler)
|
29 |
{
|
30 |
$compiler->raw(sprintf("\$this->env->getExtension('%s')", $this->getAttribute('name')));
|
31 |
}
|
vendor/twig/twig/lib/Twig/Node/Expression/Filter.php
CHANGED
@@ -9,20 +9,14 @@
|
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
-
|
13 |
-
use Twig\Compiler;
|
14 |
-
use Twig\Node\Expression\CallExpression;
|
15 |
-
use Twig\Node\Expression\ConstantExpression;
|
16 |
-
use Twig\TwigFilter;
|
17 |
-
|
18 |
-
class Twig_Node_Expression_Filter extends CallExpression
|
19 |
{
|
20 |
-
public function __construct(Twig_NodeInterface $node,
|
21 |
{
|
22 |
-
parent::__construct(
|
23 |
}
|
24 |
|
25 |
-
public function compile(
|
26 |
{
|
27 |
$name = $this->getNode('filter')->getAttribute('value');
|
28 |
$filter = $compiler->getEnvironment()->getFilter($name);
|
@@ -33,15 +27,13 @@ class Twig_Node_Expression_Filter extends CallExpression
|
|
33 |
$this->setAttribute('needs_environment', $filter->needsEnvironment());
|
34 |
$this->setAttribute('needs_context', $filter->needsContext());
|
35 |
$this->setAttribute('arguments', $filter->getArguments());
|
36 |
-
if ($filter instanceof Twig_FilterCallableInterface || $filter instanceof
|
37 |
$this->setAttribute('callable', $filter->getCallable());
|
38 |
}
|
39 |
-
if ($filter instanceof
|
40 |
$this->setAttribute('is_variadic', $filter->isVariadic());
|
41 |
}
|
42 |
|
43 |
$this->compileCallable($compiler);
|
44 |
}
|
45 |
}
|
46 |
-
|
47 |
-
class_alias('Twig_Node_Expression_Filter', 'Twig\Node\Expression\FilterExpression', false);
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
+
class Twig_Node_Expression_Filter extends Twig_Node_Expression_Call
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
{
|
14 |
+
public function __construct(Twig_NodeInterface $node, Twig_Node_Expression_Constant $filterName, Twig_NodeInterface $arguments, $lineno, $tag = null)
|
15 |
{
|
16 |
+
parent::__construct(array('node' => $node, 'filter' => $filterName, 'arguments' => $arguments), array(), $lineno, $tag);
|
17 |
}
|
18 |
|
19 |
+
public function compile(Twig_Compiler $compiler)
|
20 |
{
|
21 |
$name = $this->getNode('filter')->getAttribute('value');
|
22 |
$filter = $compiler->getEnvironment()->getFilter($name);
|
27 |
$this->setAttribute('needs_environment', $filter->needsEnvironment());
|
28 |
$this->setAttribute('needs_context', $filter->needsContext());
|
29 |
$this->setAttribute('arguments', $filter->getArguments());
|
30 |
+
if ($filter instanceof Twig_FilterCallableInterface || $filter instanceof Twig_SimpleFilter) {
|
31 |
$this->setAttribute('callable', $filter->getCallable());
|
32 |
}
|
33 |
+
if ($filter instanceof Twig_SimpleFilter) {
|
34 |
$this->setAttribute('is_variadic', $filter->isVariadic());
|
35 |
}
|
36 |
|
37 |
$this->compileCallable($compiler);
|
38 |
}
|
39 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Node/Expression/Filter/Default.php
CHANGED
@@ -9,33 +9,26 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Compiler;
|
13 |
-
use Twig\Node\Expression\ConditionalExpression;
|
14 |
-
use Twig\Node\Expression\ConstantExpression;
|
15 |
-
use Twig\Node\Expression\FilterExpression;
|
16 |
-
use Twig\Node\Expression\GetAttrExpression;
|
17 |
-
use Twig\Node\Expression\NameExpression;
|
18 |
-
use Twig\Node\Expression\Test\DefinedTest;
|
19 |
-
use Twig\Node\Node;
|
20 |
-
|
21 |
/**
|
22 |
* Returns the value or the default value when it is undefined or empty.
|
23 |
*
|
|
|
24 |
* {{ var.foo|default('foo item on var is not defined') }}
|
|
|
25 |
*
|
26 |
* @author Fabien Potencier <fabien@symfony.com>
|
27 |
*/
|
28 |
-
class Twig_Node_Expression_Filter_Default extends
|
29 |
{
|
30 |
-
public function __construct(Twig_NodeInterface $node,
|
31 |
{
|
32 |
-
$default = new
|
33 |
|
34 |
-
if ('default' === $filterName->getAttribute('value') && ($node instanceof
|
35 |
-
$test = new
|
36 |
-
$false =
|
37 |
|
38 |
-
$node = new
|
39 |
} else {
|
40 |
$node = $default;
|
41 |
}
|
@@ -43,10 +36,8 @@ class Twig_Node_Expression_Filter_Default extends FilterExpression
|
|
43 |
parent::__construct($node, $filterName, $arguments, $lineno, $tag);
|
44 |
}
|
45 |
|
46 |
-
public function compile(
|
47 |
{
|
48 |
$compiler->subcompile($this->getNode('node'));
|
49 |
}
|
50 |
}
|
51 |
-
|
52 |
-
class_alias('Twig_Node_Expression_Filter_Default', 'Twig\Node\Expression\Filter\DefaultFilter', false);
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
/**
|
13 |
* Returns the value or the default value when it is undefined or empty.
|
14 |
*
|
15 |
+
* <pre>
|
16 |
* {{ var.foo|default('foo item on var is not defined') }}
|
17 |
+
* </pre>
|
18 |
*
|
19 |
* @author Fabien Potencier <fabien@symfony.com>
|
20 |
*/
|
21 |
+
class Twig_Node_Expression_Filter_Default extends Twig_Node_Expression_Filter
|
22 |
{
|
23 |
+
public function __construct(Twig_NodeInterface $node, Twig_Node_Expression_Constant $filterName, Twig_NodeInterface $arguments, $lineno, $tag = null)
|
24 |
{
|
25 |
+
$default = new Twig_Node_Expression_Filter($node, new Twig_Node_Expression_Constant('default', $node->getTemplateLine()), $arguments, $node->getTemplateLine());
|
26 |
|
27 |
+
if ('default' === $filterName->getAttribute('value') && ($node instanceof Twig_Node_Expression_Name || $node instanceof Twig_Node_Expression_GetAttr)) {
|
28 |
+
$test = new Twig_Node_Expression_Test_Defined(clone $node, 'defined', new Twig_Node(), $node->getTemplateLine());
|
29 |
+
$false = count($arguments) ? $arguments->getNode(0) : new Twig_Node_Expression_Constant('', $node->getTemplateLine());
|
30 |
|
31 |
+
$node = new Twig_Node_Expression_Conditional($test, $default, $false, $node->getTemplateLine());
|
32 |
} else {
|
33 |
$node = $default;
|
34 |
}
|
36 |
parent::__construct($node, $filterName, $arguments, $lineno, $tag);
|
37 |
}
|
38 |
|
39 |
+
public function compile(Twig_Compiler $compiler)
|
40 |
{
|
41 |
$compiler->subcompile($this->getNode('node'));
|
42 |
}
|
43 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Node/Expression/Function.php
CHANGED
@@ -8,19 +8,14 @@
|
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
-
|
12 |
-
use Twig\Compiler;
|
13 |
-
use Twig\Node\Expression\CallExpression;
|
14 |
-
use Twig\TwigFunction;
|
15 |
-
|
16 |
-
class Twig_Node_Expression_Function extends CallExpression
|
17 |
{
|
18 |
public function __construct($name, Twig_NodeInterface $arguments, $lineno)
|
19 |
{
|
20 |
-
parent::__construct(
|
21 |
}
|
22 |
|
23 |
-
public function compile(
|
24 |
{
|
25 |
$name = $this->getAttribute('name');
|
26 |
$function = $compiler->getEnvironment()->getFunction($name);
|
@@ -31,7 +26,7 @@ class Twig_Node_Expression_Function extends CallExpression
|
|
31 |
$this->setAttribute('needs_environment', $function->needsEnvironment());
|
32 |
$this->setAttribute('needs_context', $function->needsContext());
|
33 |
$this->setAttribute('arguments', $function->getArguments());
|
34 |
-
if ($function instanceof Twig_FunctionCallableInterface || $function instanceof
|
35 |
$callable = $function->getCallable();
|
36 |
if ('constant' === $name && $this->getAttribute('is_defined_test')) {
|
37 |
$callable = 'twig_constant_is_defined';
|
@@ -39,12 +34,10 @@ class Twig_Node_Expression_Function extends CallExpression
|
|
39 |
|
40 |
$this->setAttribute('callable', $callable);
|
41 |
}
|
42 |
-
if ($function instanceof
|
43 |
$this->setAttribute('is_variadic', $function->isVariadic());
|
44 |
}
|
45 |
|
46 |
$this->compileCallable($compiler);
|
47 |
}
|
48 |
}
|
49 |
-
|
50 |
-
class_alias('Twig_Node_Expression_Function', 'Twig\Node\Expression\FunctionExpression', false);
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
+
class Twig_Node_Expression_Function extends Twig_Node_Expression_Call
|
|
|
|
|
|
|
|
|
|
|
12 |
{
|
13 |
public function __construct($name, Twig_NodeInterface $arguments, $lineno)
|
14 |
{
|
15 |
+
parent::__construct(array('arguments' => $arguments), array('name' => $name, 'is_defined_test' => false), $lineno);
|
16 |
}
|
17 |
|
18 |
+
public function compile(Twig_Compiler $compiler)
|
19 |
{
|
20 |
$name = $this->getAttribute('name');
|
21 |
$function = $compiler->getEnvironment()->getFunction($name);
|
26 |
$this->setAttribute('needs_environment', $function->needsEnvironment());
|
27 |
$this->setAttribute('needs_context', $function->needsContext());
|
28 |
$this->setAttribute('arguments', $function->getArguments());
|
29 |
+
if ($function instanceof Twig_FunctionCallableInterface || $function instanceof Twig_SimpleFunction) {
|
30 |
$callable = $function->getCallable();
|
31 |
if ('constant' === $name && $this->getAttribute('is_defined_test')) {
|
32 |
$callable = 'twig_constant_is_defined';
|
34 |
|
35 |
$this->setAttribute('callable', $callable);
|
36 |
}
|
37 |
+
if ($function instanceof Twig_SimpleFunction) {
|
38 |
$this->setAttribute('is_variadic', $function->isVariadic());
|
39 |
}
|
40 |
|
41 |
$this->compileCallable($compiler);
|
42 |
}
|
43 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Node/Expression/GetAttr.php
CHANGED
@@ -9,30 +9,25 @@
|
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
-
|
13 |
-
use Twig\Compiler;
|
14 |
-
use Twig\Node\Expression\AbstractExpression;
|
15 |
-
use Twig\Template;
|
16 |
-
|
17 |
-
class Twig_Node_Expression_GetAttr extends AbstractExpression
|
18 |
{
|
19 |
-
public function __construct(
|
20 |
{
|
21 |
-
$nodes =
|
22 |
if (null !== $arguments) {
|
23 |
$nodes['arguments'] = $arguments;
|
24 |
}
|
25 |
|
26 |
-
parent::__construct($nodes,
|
27 |
}
|
28 |
|
29 |
-
public function compile(
|
30 |
{
|
31 |
if ($this->getAttribute('disable_c_ext')) {
|
32 |
@trigger_error(sprintf('Using the "disable_c_ext" attribute on %s is deprecated since version 1.30 and will be removed in 2.0.', __CLASS__), E_USER_DEPRECATED);
|
33 |
}
|
34 |
|
35 |
-
if (
|
36 |
$compiler->raw('twig_template_get_attributes($this, ');
|
37 |
} else {
|
38 |
$compiler->raw('$this->getAttribute(');
|
@@ -49,14 +44,14 @@ class Twig_Node_Expression_GetAttr extends AbstractExpression
|
|
49 |
// only generate optional arguments when needed (to make generated code more readable)
|
50 |
$needFourth = $this->getAttribute('ignore_strict_check');
|
51 |
$needThird = $needFourth || $this->getAttribute('is_defined_test');
|
52 |
-
$needSecond = $needThird ||
|
53 |
$needFirst = $needSecond || $this->hasNode('arguments');
|
54 |
|
55 |
if ($needFirst) {
|
56 |
if ($this->hasNode('arguments')) {
|
57 |
$compiler->raw(', ')->subcompile($this->getNode('arguments'));
|
58 |
} else {
|
59 |
-
$compiler->raw(',
|
60 |
}
|
61 |
}
|
62 |
|
@@ -75,5 +70,3 @@ class Twig_Node_Expression_GetAttr extends AbstractExpression
|
|
75 |
$compiler->raw(')');
|
76 |
}
|
77 |
}
|
78 |
-
|
79 |
-
class_alias('Twig_Node_Expression_GetAttr', 'Twig\Node\Expression\GetAttrExpression', false);
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
+
class Twig_Node_Expression_GetAttr extends Twig_Node_Expression
|
|
|
|
|
|
|
|
|
|
|
13 |
{
|
14 |
+
public function __construct(Twig_Node_Expression $node, Twig_Node_Expression $attribute, Twig_Node_Expression $arguments = null, $type, $lineno)
|
15 |
{
|
16 |
+
$nodes = array('node' => $node, 'attribute' => $attribute);
|
17 |
if (null !== $arguments) {
|
18 |
$nodes['arguments'] = $arguments;
|
19 |
}
|
20 |
|
21 |
+
parent::__construct($nodes, array('type' => $type, 'is_defined_test' => false, 'ignore_strict_check' => false, 'disable_c_ext' => false), $lineno);
|
22 |
}
|
23 |
|
24 |
+
public function compile(Twig_Compiler $compiler)
|
25 |
{
|
26 |
if ($this->getAttribute('disable_c_ext')) {
|
27 |
@trigger_error(sprintf('Using the "disable_c_ext" attribute on %s is deprecated since version 1.30 and will be removed in 2.0.', __CLASS__), E_USER_DEPRECATED);
|
28 |
}
|
29 |
|
30 |
+
if (function_exists('twig_template_get_attributes') && !$this->getAttribute('disable_c_ext')) {
|
31 |
$compiler->raw('twig_template_get_attributes($this, ');
|
32 |
} else {
|
33 |
$compiler->raw('$this->getAttribute(');
|
44 |
// only generate optional arguments when needed (to make generated code more readable)
|
45 |
$needFourth = $this->getAttribute('ignore_strict_check');
|
46 |
$needThird = $needFourth || $this->getAttribute('is_defined_test');
|
47 |
+
$needSecond = $needThird || Twig_Template::ANY_CALL !== $this->getAttribute('type');
|
48 |
$needFirst = $needSecond || $this->hasNode('arguments');
|
49 |
|
50 |
if ($needFirst) {
|
51 |
if ($this->hasNode('arguments')) {
|
52 |
$compiler->raw(', ')->subcompile($this->getNode('arguments'));
|
53 |
} else {
|
54 |
+
$compiler->raw(', array()');
|
55 |
}
|
56 |
}
|
57 |
|
70 |
$compiler->raw(')');
|
71 |
}
|
72 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Node/Expression/MethodCall.php
CHANGED
@@ -8,24 +8,18 @@
|
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
-
|
12 |
-
use Twig\Compiler;
|
13 |
-
use Twig\Node\Expression\AbstractExpression;
|
14 |
-
use Twig\Node\Expression\ArrayExpression;
|
15 |
-
use Twig\Node\Expression\NameExpression;
|
16 |
-
|
17 |
-
class Twig_Node_Expression_MethodCall extends AbstractExpression
|
18 |
{
|
19 |
-
public function __construct(
|
20 |
{
|
21 |
-
parent::__construct(
|
22 |
|
23 |
-
if ($node instanceof
|
24 |
$node->setAttribute('always_defined', true);
|
25 |
}
|
26 |
}
|
27 |
|
28 |
-
public function compile(
|
29 |
{
|
30 |
$compiler
|
31 |
->subcompile($this->getNode('node'))
|
@@ -45,5 +39,3 @@ class Twig_Node_Expression_MethodCall extends AbstractExpression
|
|
45 |
$compiler->raw(')');
|
46 |
}
|
47 |
}
|
48 |
-
|
49 |
-
class_alias('Twig_Node_Expression_MethodCall', 'Twig\Node\Expression\MethodCallExpression', false);
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
+
class Twig_Node_Expression_MethodCall extends Twig_Node_Expression
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
{
|
13 |
+
public function __construct(Twig_Node_Expression $node, $method, Twig_Node_Expression_Array $arguments, $lineno)
|
14 |
{
|
15 |
+
parent::__construct(array('node' => $node, 'arguments' => $arguments), array('method' => $method, 'safe' => false), $lineno);
|
16 |
|
17 |
+
if ($node instanceof Twig_Node_Expression_Name) {
|
18 |
$node->setAttribute('always_defined', true);
|
19 |
}
|
20 |
}
|
21 |
|
22 |
+
public function compile(Twig_Compiler $compiler)
|
23 |
{
|
24 |
$compiler
|
25 |
->subcompile($this->getNode('node'))
|
39 |
$compiler->raw(')');
|
40 |
}
|
41 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Node/Expression/Name.php
CHANGED
@@ -9,24 +9,20 @@
|
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
-
|
13 |
-
use Twig\Compiler;
|
14 |
-
use Twig\Node\Expression\AbstractExpression;
|
15 |
-
|
16 |
-
class Twig_Node_Expression_Name extends AbstractExpression
|
17 |
{
|
18 |
-
protected $specialVars =
|
19 |
'_self' => '$this',
|
20 |
'_context' => '$context',
|
21 |
'_charset' => '$this->env->getCharset()',
|
22 |
-
|
23 |
|
24 |
public function __construct($name, $lineno)
|
25 |
{
|
26 |
-
parent::__construct(
|
27 |
}
|
28 |
|
29 |
-
public function compile(
|
30 |
{
|
31 |
$name = $this->getAttribute('name');
|
32 |
|
@@ -36,12 +32,7 @@ class Twig_Node_Expression_Name extends AbstractExpression
|
|
36 |
if ($this->isSpecial()) {
|
37 |
$compiler->repr(true);
|
38 |
} else {
|
39 |
-
$compiler
|
40 |
-
->raw('(isset($context[')
|
41 |
-
->string($name)
|
42 |
-
->raw(']) || array_key_exists(')
|
43 |
-
->string($name)
|
44 |
-
->raw(', $context))');
|
45 |
}
|
46 |
} elseif ($this->isSpecial()) {
|
47 |
$compiler->raw($this->specialVars[$name]);
|
@@ -107,5 +98,3 @@ class Twig_Node_Expression_Name extends AbstractExpression
|
|
107 |
return !$this->isSpecial() && !$this->getAttribute('is_defined_test');
|
108 |
}
|
109 |
}
|
110 |
-
|
111 |
-
class_alias('Twig_Node_Expression_Name', 'Twig\Node\Expression\NameExpression', false);
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
+
class Twig_Node_Expression_Name extends Twig_Node_Expression
|
|
|
|
|
|
|
|
|
13 |
{
|
14 |
+
protected $specialVars = array(
|
15 |
'_self' => '$this',
|
16 |
'_context' => '$context',
|
17 |
'_charset' => '$this->env->getCharset()',
|
18 |
+
);
|
19 |
|
20 |
public function __construct($name, $lineno)
|
21 |
{
|
22 |
+
parent::__construct(array(), array('name' => $name, 'is_defined_test' => false, 'ignore_strict_check' => false, 'always_defined' => false), $lineno);
|
23 |
}
|
24 |
|
25 |
+
public function compile(Twig_Compiler $compiler)
|
26 |
{
|
27 |
$name = $this->getAttribute('name');
|
28 |
|
32 |
if ($this->isSpecial()) {
|
33 |
$compiler->repr(true);
|
34 |
} else {
|
35 |
+
$compiler->raw('array_key_exists(')->repr($name)->raw(', $context)');
|
|
|
|
|
|
|
|
|
|
|
36 |
}
|
37 |
} elseif ($this->isSpecial()) {
|
38 |
$compiler->raw($this->specialVars[$name]);
|
98 |
return !$this->isSpecial() && !$this->getAttribute('is_defined_test');
|
99 |
}
|
100 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Node/Expression/NullCoalesce.php
CHANGED
@@ -8,30 +8,20 @@
|
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
-
|
12 |
-
use Twig\Compiler;
|
13 |
-
use Twig\Node\Expression\Binary\AndBinary;
|
14 |
-
use Twig\Node\Expression\ConditionalExpression;
|
15 |
-
use Twig\Node\Expression\NameExpression;
|
16 |
-
use Twig\Node\Expression\Test\DefinedTest;
|
17 |
-
use Twig\Node\Expression\Test\NullTest;
|
18 |
-
use Twig\Node\Expression\Unary\NotUnary;
|
19 |
-
use Twig\Node\Node;
|
20 |
-
|
21 |
-
class Twig_Node_Expression_NullCoalesce extends ConditionalExpression
|
22 |
{
|
23 |
public function __construct(Twig_NodeInterface $left, Twig_NodeInterface $right, $lineno)
|
24 |
{
|
25 |
-
$test = new
|
26 |
-
new
|
27 |
-
new
|
28 |
$left->getTemplateLine()
|
29 |
);
|
30 |
|
31 |
parent::__construct($test, $left, $right, $lineno);
|
32 |
}
|
33 |
|
34 |
-
public function compile(
|
35 |
{
|
36 |
/*
|
37 |
* This optimizes only one case. PHP 7 also supports more complex expressions
|
@@ -40,7 +30,7 @@ class Twig_Node_Expression_NullCoalesce extends ConditionalExpression
|
|
40 |
* cases might be implemented as an optimizer node visitor, but has not been done
|
41 |
* as benefits are probably not worth the added complexity.
|
42 |
*/
|
43 |
-
if (PHP_VERSION_ID >= 70000 && $this->getNode('expr2') instanceof
|
44 |
$this->getNode('expr2')->setAttribute('always_defined', true);
|
45 |
$compiler
|
46 |
->raw('((')
|
@@ -54,5 +44,3 @@ class Twig_Node_Expression_NullCoalesce extends ConditionalExpression
|
|
54 |
}
|
55 |
}
|
56 |
}
|
57 |
-
|
58 |
-
class_alias('Twig_Node_Expression_NullCoalesce', 'Twig\Node\Expression\NullCoalesceExpression', false);
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
+
class Twig_Node_Expression_NullCoalesce extends Twig_Node_Expression_Conditional
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
{
|
13 |
public function __construct(Twig_NodeInterface $left, Twig_NodeInterface $right, $lineno)
|
14 |
{
|
15 |
+
$test = new Twig_Node_Expression_Binary_And(
|
16 |
+
new Twig_Node_Expression_Test_Defined(clone $left, 'defined', new Twig_Node(), $left->getTemplateLine()),
|
17 |
+
new Twig_Node_Expression_Unary_Not(new Twig_Node_Expression_Test_Null($left, 'null', new Twig_Node(), $left->getTemplateLine()), $left->getTemplateLine()),
|
18 |
$left->getTemplateLine()
|
19 |
);
|
20 |
|
21 |
parent::__construct($test, $left, $right, $lineno);
|
22 |
}
|
23 |
|
24 |
+
public function compile(Twig_Compiler $compiler)
|
25 |
{
|
26 |
/*
|
27 |
* This optimizes only one case. PHP 7 also supports more complex expressions
|
30 |
* cases might be implemented as an optimizer node visitor, but has not been done
|
31 |
* as benefits are probably not worth the added complexity.
|
32 |
*/
|
33 |
+
if (PHP_VERSION_ID >= 70000 && $this->getNode('expr2') instanceof Twig_Node_Expression_Name) {
|
34 |
$this->getNode('expr2')->setAttribute('always_defined', true);
|
35 |
$compiler
|
36 |
->raw('((')
|
44 |
}
|
45 |
}
|
46 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Node/Expression/Parent.php
CHANGED
@@ -10,22 +10,19 @@
|
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
|
13 |
-
use Twig\Compiler;
|
14 |
-
use Twig\Node\Expression\AbstractExpression;
|
15 |
-
|
16 |
/**
|
17 |
* Represents a parent node.
|
18 |
*
|
19 |
* @author Fabien Potencier <fabien@symfony.com>
|
20 |
*/
|
21 |
-
class Twig_Node_Expression_Parent extends
|
22 |
{
|
23 |
public function __construct($name, $lineno, $tag = null)
|
24 |
{
|
25 |
-
parent::__construct(
|
26 |
}
|
27 |
|
28 |
-
public function compile(
|
29 |
{
|
30 |
if ($this->getAttribute('output')) {
|
31 |
$compiler
|
@@ -43,5 +40,3 @@ class Twig_Node_Expression_Parent extends AbstractExpression
|
|
43 |
}
|
44 |
}
|
45 |
}
|
46 |
-
|
47 |
-
class_alias('Twig_Node_Expression_Parent', 'Twig\Node\Expression\ParentExpression', false);
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
|
|
|
|
|
|
|
13 |
/**
|
14 |
* Represents a parent node.
|
15 |
*
|
16 |
* @author Fabien Potencier <fabien@symfony.com>
|
17 |
*/
|
18 |
+
class Twig_Node_Expression_Parent extends Twig_Node_Expression
|
19 |
{
|
20 |
public function __construct($name, $lineno, $tag = null)
|
21 |
{
|
22 |
+
parent::__construct(array(), array('output' => false, 'name' => $name), $lineno, $tag);
|
23 |
}
|
24 |
|
25 |
+
public function compile(Twig_Compiler $compiler)
|
26 |
{
|
27 |
if ($this->getAttribute('output')) {
|
28 |
$compiler
|
40 |
}
|
41 |
}
|
42 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Node/Expression/TempName.php
CHANGED
@@ -8,18 +8,14 @@
|
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
-
|
12 |
-
use Twig\Compiler;
|
13 |
-
use Twig\Node\Expression\AbstractExpression;
|
14 |
-
|
15 |
-
class Twig_Node_Expression_TempName extends AbstractExpression
|
16 |
{
|
17 |
public function __construct($name, $lineno)
|
18 |
{
|
19 |
-
parent::__construct(
|
20 |
}
|
21 |
|
22 |
-
public function compile(
|
23 |
{
|
24 |
$compiler
|
25 |
->raw('$_')
|
@@ -28,5 +24,3 @@ class Twig_Node_Expression_TempName extends AbstractExpression
|
|
28 |
;
|
29 |
}
|
30 |
}
|
31 |
-
|
32 |
-
class_alias('Twig_Node_Expression_TempName', 'Twig\Node\Expression\TempNameExpression', false);
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
+
class Twig_Node_Expression_TempName extends Twig_Node_Expression
|
|
|
|
|
|
|
|
|
12 |
{
|
13 |
public function __construct($name, $lineno)
|
14 |
{
|
15 |
+
parent::__construct(array(), array('name' => $name), $lineno);
|
16 |
}
|
17 |
|
18 |
+
public function compile(Twig_Compiler $compiler)
|
19 |
{
|
20 |
$compiler
|
21 |
->raw('$_')
|
24 |
;
|
25 |
}
|
26 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Node/Expression/Test.php
CHANGED
@@ -8,24 +8,19 @@
|
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
-
|
12 |
-
use Twig\Compiler;
|
13 |
-
use Twig\Node\Expression\CallExpression;
|
14 |
-
use Twig\TwigTest;
|
15 |
-
|
16 |
-
class Twig_Node_Expression_Test extends CallExpression
|
17 |
{
|
18 |
public function __construct(Twig_NodeInterface $node, $name, Twig_NodeInterface $arguments = null, $lineno)
|
19 |
{
|
20 |
-
$nodes =
|
21 |
if (null !== $arguments) {
|
22 |
$nodes['arguments'] = $arguments;
|
23 |
}
|
24 |
|
25 |
-
parent::__construct($nodes,
|
26 |
}
|
27 |
|
28 |
-
public function compile(
|
29 |
{
|
30 |
$name = $this->getAttribute('name');
|
31 |
$test = $compiler->getEnvironment()->getTest($name);
|
@@ -33,18 +28,13 @@ class Twig_Node_Expression_Test extends CallExpression
|
|
33 |
$this->setAttribute('name', $name);
|
34 |
$this->setAttribute('type', 'test');
|
35 |
$this->setAttribute('thing', $test);
|
36 |
-
if ($test instanceof
|
37 |
-
$this->setAttribute('arguments', $test->getArguments());
|
38 |
-
}
|
39 |
-
if ($test instanceof Twig_TestCallableInterface || $test instanceof TwigTest) {
|
40 |
$this->setAttribute('callable', $test->getCallable());
|
41 |
}
|
42 |
-
if ($test instanceof
|
43 |
$this->setAttribute('is_variadic', $test->isVariadic());
|
44 |
}
|
45 |
|
46 |
$this->compileCallable($compiler);
|
47 |
}
|
48 |
}
|
49 |
-
|
50 |
-
class_alias('Twig_Node_Expression_Test', 'Twig\Node\Expression\TestExpression', false);
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
+
class Twig_Node_Expression_Test extends Twig_Node_Expression_Call
|
|
|
|
|
|
|
|
|
|
|
12 |
{
|
13 |
public function __construct(Twig_NodeInterface $node, $name, Twig_NodeInterface $arguments = null, $lineno)
|
14 |
{
|
15 |
+
$nodes = array('node' => $node);
|
16 |
if (null !== $arguments) {
|
17 |
$nodes['arguments'] = $arguments;
|
18 |
}
|
19 |
|
20 |
+
parent::__construct($nodes, array('name' => $name), $lineno);
|
21 |
}
|
22 |
|
23 |
+
public function compile(Twig_Compiler $compiler)
|
24 |
{
|
25 |
$name = $this->getAttribute('name');
|
26 |
$test = $compiler->getEnvironment()->getTest($name);
|
28 |
$this->setAttribute('name', $name);
|
29 |
$this->setAttribute('type', 'test');
|
30 |
$this->setAttribute('thing', $test);
|
31 |
+
if ($test instanceof Twig_TestCallableInterface || $test instanceof Twig_SimpleTest) {
|
|
|
|
|
|
|
32 |
$this->setAttribute('callable', $test->getCallable());
|
33 |
}
|
34 |
+
if ($test instanceof Twig_SimpleTest) {
|
35 |
$this->setAttribute('is_variadic', $test->isVariadic());
|
36 |
}
|
37 |
|
38 |
$this->compileCallable($compiler);
|
39 |
}
|
40 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Node/Expression/Test/Constant.php
CHANGED
@@ -9,21 +9,20 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Compiler;
|
13 |
-
use Twig\Node\Expression\TestExpression;
|
14 |
-
|
15 |
/**
|
16 |
* Checks if a variable is the exact same value as a constant.
|
17 |
*
|
18 |
-
*
|
19 |
-
*
|
20 |
-
*
|
|
|
|
|
21 |
*
|
22 |
* @author Fabien Potencier <fabien@symfony.com>
|
23 |
*/
|
24 |
-
class Twig_Node_Expression_Test_Constant extends
|
25 |
{
|
26 |
-
public function compile(
|
27 |
{
|
28 |
$compiler
|
29 |
->raw('(')
|
@@ -45,5 +44,3 @@ class Twig_Node_Expression_Test_Constant extends TestExpression
|
|
45 |
;
|
46 |
}
|
47 |
}
|
48 |
-
|
49 |
-
class_alias('Twig_Node_Expression_Test_Constant', 'Twig\Node\Expression\Test\ConstantTest', false);
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
|
|
12 |
/**
|
13 |
* Checks if a variable is the exact same value as a constant.
|
14 |
*
|
15 |
+
* <pre>
|
16 |
+
* {% if post.status is constant('Post::PUBLISHED') %}
|
17 |
+
* the status attribute is exactly the same as Post::PUBLISHED
|
18 |
+
* {% endif %}
|
19 |
+
* </pre>
|
20 |
*
|
21 |
* @author Fabien Potencier <fabien@symfony.com>
|
22 |
*/
|
23 |
+
class Twig_Node_Expression_Test_Constant extends Twig_Node_Expression_Test
|
24 |
{
|
25 |
+
public function compile(Twig_Compiler $compiler)
|
26 |
{
|
27 |
$compiler
|
28 |
->raw('(')
|
44 |
;
|
45 |
}
|
46 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Node/Expression/Test/Defined.php
CHANGED
@@ -9,61 +9,51 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Compiler;
|
13 |
-
use Twig\Error\SyntaxError;
|
14 |
-
use Twig\Node\Expression\ArrayExpression;
|
15 |
-
use Twig\Node\Expression\BlockReferenceExpression;
|
16 |
-
use Twig\Node\Expression\ConstantExpression;
|
17 |
-
use Twig\Node\Expression\FunctionExpression;
|
18 |
-
use Twig\Node\Expression\GetAttrExpression;
|
19 |
-
use Twig\Node\Expression\NameExpression;
|
20 |
-
use Twig\Node\Expression\TestExpression;
|
21 |
-
|
22 |
/**
|
23 |
* Checks if a variable is defined in the current context.
|
24 |
*
|
25 |
-
*
|
26 |
-
*
|
27 |
-
*
|
28 |
-
*
|
|
|
|
|
29 |
*
|
30 |
* @author Fabien Potencier <fabien@symfony.com>
|
31 |
*/
|
32 |
-
class Twig_Node_Expression_Test_Defined extends
|
33 |
{
|
34 |
public function __construct(Twig_NodeInterface $node, $name, Twig_NodeInterface $arguments = null, $lineno)
|
35 |
{
|
36 |
-
if ($node instanceof
|
37 |
$node->setAttribute('is_defined_test', true);
|
38 |
-
} elseif ($node instanceof
|
39 |
$node->setAttribute('is_defined_test', true);
|
40 |
$this->changeIgnoreStrictCheck($node);
|
41 |
-
} elseif ($node instanceof
|
42 |
$node->setAttribute('is_defined_test', true);
|
43 |
-
} elseif ($node instanceof
|
44 |
$node->setAttribute('is_defined_test', true);
|
45 |
-
} elseif ($node instanceof
|
46 |
-
$node = new
|
47 |
} else {
|
48 |
-
throw new
|
49 |
}
|
50 |
|
51 |
parent::__construct($node, $name, $arguments, $lineno);
|
52 |
}
|
53 |
|
54 |
-
protected function changeIgnoreStrictCheck(
|
55 |
{
|
56 |
$node->setAttribute('ignore_strict_check', true);
|
57 |
|
58 |
-
if ($node->getNode('node') instanceof
|
59 |
$this->changeIgnoreStrictCheck($node->getNode('node'));
|
60 |
}
|
61 |
}
|
62 |
|
63 |
-
public function compile(
|
64 |
{
|
65 |
$compiler->subcompile($this->getNode('node'));
|
66 |
}
|
67 |
}
|
68 |
-
|
69 |
-
class_alias('Twig_Node_Expression_Test_Defined', 'Twig\Node\Expression\Test\DefinedTest', false);
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
/**
|
13 |
* Checks if a variable is defined in the current context.
|
14 |
*
|
15 |
+
* <pre>
|
16 |
+
* {# defined works with variable names and variable attributes #}
|
17 |
+
* {% if foo is defined %}
|
18 |
+
* {# ... #}
|
19 |
+
* {% endif %}
|
20 |
+
* </pre>
|
21 |
*
|
22 |
* @author Fabien Potencier <fabien@symfony.com>
|
23 |
*/
|
24 |
+
class Twig_Node_Expression_Test_Defined extends Twig_Node_Expression_Test
|
25 |
{
|
26 |
public function __construct(Twig_NodeInterface $node, $name, Twig_NodeInterface $arguments = null, $lineno)
|
27 |
{
|
28 |
+
if ($node instanceof Twig_Node_Expression_Name) {
|
29 |
$node->setAttribute('is_defined_test', true);
|
30 |
+
} elseif ($node instanceof Twig_Node_Expression_GetAttr) {
|
31 |
$node->setAttribute('is_defined_test', true);
|
32 |
$this->changeIgnoreStrictCheck($node);
|
33 |
+
} elseif ($node instanceof Twig_Node_Expression_BlockReference) {
|
34 |
$node->setAttribute('is_defined_test', true);
|
35 |
+
} elseif ($node instanceof Twig_Node_Expression_Function && 'constant' === $node->getAttribute('name')) {
|
36 |
$node->setAttribute('is_defined_test', true);
|
37 |
+
} elseif ($node instanceof Twig_Node_Expression_Constant || $node instanceof Twig_Node_Expression_Array) {
|
38 |
+
$node = new Twig_Node_Expression_Constant(true, $node->getTemplateLine());
|
39 |
} else {
|
40 |
+
throw new Twig_Error_Syntax('The "defined" test only works with simple variables.', $this->getTemplateLine());
|
41 |
}
|
42 |
|
43 |
parent::__construct($node, $name, $arguments, $lineno);
|
44 |
}
|
45 |
|
46 |
+
protected function changeIgnoreStrictCheck(Twig_Node_Expression_GetAttr $node)
|
47 |
{
|
48 |
$node->setAttribute('ignore_strict_check', true);
|
49 |
|
50 |
+
if ($node->getNode('node') instanceof Twig_Node_Expression_GetAttr) {
|
51 |
$this->changeIgnoreStrictCheck($node->getNode('node'));
|
52 |
}
|
53 |
}
|
54 |
|
55 |
+
public function compile(Twig_Compiler $compiler)
|
56 |
{
|
57 |
$compiler->subcompile($this->getNode('node'));
|
58 |
}
|
59 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Node/Expression/Test/Divisibleby.php
CHANGED
@@ -9,19 +9,18 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Compiler;
|
13 |
-
use Twig\Node\Expression\TestExpression;
|
14 |
-
|
15 |
/**
|
16 |
* Checks if a variable is divisible by a number.
|
17 |
*
|
|
|
18 |
* {% if loop.index is divisible by(3) %}
|
|
|
19 |
*
|
20 |
* @author Fabien Potencier <fabien@symfony.com>
|
21 |
*/
|
22 |
-
class Twig_Node_Expression_Test_Divisibleby extends
|
23 |
{
|
24 |
-
public function compile(
|
25 |
{
|
26 |
$compiler
|
27 |
->raw('(0 == ')
|
@@ -32,5 +31,3 @@ class Twig_Node_Expression_Test_Divisibleby extends TestExpression
|
|
32 |
;
|
33 |
}
|
34 |
}
|
35 |
-
|
36 |
-
class_alias('Twig_Node_Expression_Test_Divisibleby', 'Twig\Node\Expression\Test\DivisiblebyTest', false);
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
|
|
12 |
/**
|
13 |
* Checks if a variable is divisible by a number.
|
14 |
*
|
15 |
+
* <pre>
|
16 |
* {% if loop.index is divisible by(3) %}
|
17 |
+
* </pre>
|
18 |
*
|
19 |
* @author Fabien Potencier <fabien@symfony.com>
|
20 |
*/
|
21 |
+
class Twig_Node_Expression_Test_Divisibleby extends Twig_Node_Expression_Test
|
22 |
{
|
23 |
+
public function compile(Twig_Compiler $compiler)
|
24 |
{
|
25 |
$compiler
|
26 |
->raw('(0 == ')
|
31 |
;
|
32 |
}
|
33 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Node/Expression/Test/Even.php
CHANGED
@@ -9,19 +9,18 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Compiler;
|
13 |
-
use Twig\Node\Expression\TestExpression;
|
14 |
-
|
15 |
/**
|
16 |
* Checks if a number is even.
|
17 |
*
|
|
|
18 |
* {{ var is even }}
|
|
|
19 |
*
|
20 |
* @author Fabien Potencier <fabien@symfony.com>
|
21 |
*/
|
22 |
-
class Twig_Node_Expression_Test_Even extends
|
23 |
{
|
24 |
-
public function compile(
|
25 |
{
|
26 |
$compiler
|
27 |
->raw('(')
|
@@ -31,5 +30,3 @@ class Twig_Node_Expression_Test_Even extends TestExpression
|
|
31 |
;
|
32 |
}
|
33 |
}
|
34 |
-
|
35 |
-
class_alias('Twig_Node_Expression_Test_Even', 'Twig\Node\Expression\Test\EvenTest', false);
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
|
|
12 |
/**
|
13 |
* Checks if a number is even.
|
14 |
*
|
15 |
+
* <pre>
|
16 |
* {{ var is even }}
|
17 |
+
* </pre>
|
18 |
*
|
19 |
* @author Fabien Potencier <fabien@symfony.com>
|
20 |
*/
|
21 |
+
class Twig_Node_Expression_Test_Even extends Twig_Node_Expression_Test
|
22 |
{
|
23 |
+
public function compile(Twig_Compiler $compiler)
|
24 |
{
|
25 |
$compiler
|
26 |
->raw('(')
|
30 |
;
|
31 |
}
|
32 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Node/Expression/Test/Null.php
CHANGED
@@ -9,19 +9,18 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Compiler;
|
13 |
-
use Twig\Node\Expression\TestExpression;
|
14 |
-
|
15 |
/**
|
16 |
* Checks that a variable is null.
|
17 |
*
|
|
|
18 |
* {{ var is none }}
|
|
|
19 |
*
|
20 |
* @author Fabien Potencier <fabien@symfony.com>
|
21 |
*/
|
22 |
-
class Twig_Node_Expression_Test_Null extends
|
23 |
{
|
24 |
-
public function compile(
|
25 |
{
|
26 |
$compiler
|
27 |
->raw('(null === ')
|
@@ -30,5 +29,3 @@ class Twig_Node_Expression_Test_Null extends TestExpression
|
|
30 |
;
|
31 |
}
|
32 |
}
|
33 |
-
|
34 |
-
class_alias('Twig_Node_Expression_Test_Null', 'Twig\Node\Expression\Test\NullTest', false);
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
|
|
12 |
/**
|
13 |
* Checks that a variable is null.
|
14 |
*
|
15 |
+
* <pre>
|
16 |
* {{ var is none }}
|
17 |
+
* </pre>
|
18 |
*
|
19 |
* @author Fabien Potencier <fabien@symfony.com>
|
20 |
*/
|
21 |
+
class Twig_Node_Expression_Test_Null extends Twig_Node_Expression_Test
|
22 |
{
|
23 |
+
public function compile(Twig_Compiler $compiler)
|
24 |
{
|
25 |
$compiler
|
26 |
->raw('(null === ')
|
29 |
;
|
30 |
}
|
31 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Node/Expression/Test/Odd.php
CHANGED
@@ -9,19 +9,18 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Compiler;
|
13 |
-
use Twig\Node\Expression\TestExpression;
|
14 |
-
|
15 |
/**
|
16 |
* Checks if a number is odd.
|
17 |
*
|
|
|
18 |
* {{ var is odd }}
|
|
|
19 |
*
|
20 |
* @author Fabien Potencier <fabien@symfony.com>
|
21 |
*/
|
22 |
-
class Twig_Node_Expression_Test_Odd extends
|
23 |
{
|
24 |
-
public function compile(
|
25 |
{
|
26 |
$compiler
|
27 |
->raw('(')
|
@@ -31,5 +30,3 @@ class Twig_Node_Expression_Test_Odd extends TestExpression
|
|
31 |
;
|
32 |
}
|
33 |
}
|
34 |
-
|
35 |
-
class_alias('Twig_Node_Expression_Test_Odd', 'Twig\Node\Expression\Test\OddTest', false);
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
|
|
12 |
/**
|
13 |
* Checks if a number is odd.
|
14 |
*
|
15 |
+
* <pre>
|
16 |
* {{ var is odd }}
|
17 |
+
* </pre>
|
18 |
*
|
19 |
* @author Fabien Potencier <fabien@symfony.com>
|
20 |
*/
|
21 |
+
class Twig_Node_Expression_Test_Odd extends Twig_Node_Expression_Test
|
22 |
{
|
23 |
+
public function compile(Twig_Compiler $compiler)
|
24 |
{
|
25 |
$compiler
|
26 |
->raw('(')
|
30 |
;
|
31 |
}
|
32 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Node/Expression/Test/Sameas.php
CHANGED
@@ -9,17 +9,14 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Compiler;
|
13 |
-
use Twig\Node\Expression\TestExpression;
|
14 |
-
|
15 |
/**
|
16 |
* Checks if a variable is the same as another one (=== in PHP).
|
17 |
*
|
18 |
* @author Fabien Potencier <fabien@symfony.com>
|
19 |
*/
|
20 |
-
class Twig_Node_Expression_Test_Sameas extends
|
21 |
{
|
22 |
-
public function compile(
|
23 |
{
|
24 |
$compiler
|
25 |
->raw('(')
|
@@ -30,5 +27,3 @@ class Twig_Node_Expression_Test_Sameas extends TestExpression
|
|
30 |
;
|
31 |
}
|
32 |
}
|
33 |
-
|
34 |
-
class_alias('Twig_Node_Expression_Test_Sameas', 'Twig\Node\Expression\Test\SameasTest', false);
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
|
|
12 |
/**
|
13 |
* Checks if a variable is the same as another one (=== in PHP).
|
14 |
*
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
+
class Twig_Node_Expression_Test_Sameas extends Twig_Node_Expression_Test
|
18 |
{
|
19 |
+
public function compile(Twig_Compiler $compiler)
|
20 |
{
|
21 |
$compiler
|
22 |
->raw('(')
|
27 |
;
|
28 |
}
|
29 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Node/Expression/Unary.php
CHANGED
@@ -9,25 +9,19 @@
|
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
-
|
13 |
-
use Twig\Compiler;
|
14 |
-
use Twig\Node\Expression\AbstractExpression;
|
15 |
-
|
16 |
-
abstract class Twig_Node_Expression_Unary extends AbstractExpression
|
17 |
{
|
18 |
public function __construct(Twig_NodeInterface $node, $lineno)
|
19 |
{
|
20 |
-
parent::__construct(
|
21 |
}
|
22 |
|
23 |
-
public function compile(
|
24 |
{
|
25 |
$compiler->raw(' ');
|
26 |
$this->operator($compiler);
|
27 |
$compiler->subcompile($this->getNode('node'));
|
28 |
}
|
29 |
|
30 |
-
abstract public function operator(
|
31 |
}
|
32 |
-
|
33 |
-
class_alias('Twig_Node_Expression_Unary', 'Twig\Node\Expression\Unary\AbstractUnary', false);
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
+
abstract class Twig_Node_Expression_Unary extends Twig_Node_Expression
|
|
|
|
|
|
|
|
|
13 |
{
|
14 |
public function __construct(Twig_NodeInterface $node, $lineno)
|
15 |
{
|
16 |
+
parent::__construct(array('node' => $node), array(), $lineno);
|
17 |
}
|
18 |
|
19 |
+
public function compile(Twig_Compiler $compiler)
|
20 |
{
|
21 |
$compiler->raw(' ');
|
22 |
$this->operator($compiler);
|
23 |
$compiler->subcompile($this->getNode('node'));
|
24 |
}
|
25 |
|
26 |
+
abstract public function operator(Twig_Compiler $compiler);
|
27 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Node/Expression/Unary/Neg.php
CHANGED
@@ -9,16 +9,10 @@
|
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
-
|
13 |
-
use Twig\Compiler;
|
14 |
-
use Twig\Node\Expression\Unary\AbstractUnary;
|
15 |
-
|
16 |
-
class Twig_Node_Expression_Unary_Neg extends AbstractUnary
|
17 |
{
|
18 |
-
public function operator(
|
19 |
{
|
20 |
$compiler->raw('-');
|
21 |
}
|
22 |
}
|
23 |
-
|
24 |
-
class_alias('Twig_Node_Expression_Unary_Neg', 'Twig\Node\Expression\Unary\NegUnary', false);
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
+
class Twig_Node_Expression_Unary_Neg extends Twig_Node_Expression_Unary
|
|
|
|
|
|
|
|
|
13 |
{
|
14 |
+
public function operator(Twig_Compiler $compiler)
|
15 |
{
|
16 |
$compiler->raw('-');
|
17 |
}
|
18 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Node/Expression/Unary/Not.php
CHANGED
@@ -9,16 +9,10 @@
|
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
-
|
13 |
-
use Twig\Compiler;
|
14 |
-
use Twig\Node\Expression\Unary\AbstractUnary;
|
15 |
-
|
16 |
-
class Twig_Node_Expression_Unary_Not extends AbstractUnary
|
17 |
{
|
18 |
-
public function operator(
|
19 |
{
|
20 |
$compiler->raw('!');
|
21 |
}
|
22 |
}
|
23 |
-
|
24 |
-
class_alias('Twig_Node_Expression_Unary_Not', 'Twig\Node\Expression\Unary\NotUnary', false);
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
+
class Twig_Node_Expression_Unary_Not extends Twig_Node_Expression_Unary
|
|
|
|
|
|
|
|
|
13 |
{
|
14 |
+
public function operator(Twig_Compiler $compiler)
|
15 |
{
|
16 |
$compiler->raw('!');
|
17 |
}
|
18 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Node/Expression/Unary/Pos.php
CHANGED
@@ -9,16 +9,10 @@
|
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
-
|
13 |
-
use Twig\Compiler;
|
14 |
-
use Twig\Node\Expression\Unary\AbstractUnary;
|
15 |
-
|
16 |
-
class Twig_Node_Expression_Unary_Pos extends AbstractUnary
|
17 |
{
|
18 |
-
public function operator(
|
19 |
{
|
20 |
$compiler->raw('+');
|
21 |
}
|
22 |
}
|
23 |
-
|
24 |
-
class_alias('Twig_Node_Expression_Unary_Pos', 'Twig\Node\Expression\Unary\PosUnary', false);
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
+
class Twig_Node_Expression_Unary_Pos extends Twig_Node_Expression_Unary
|
|
|
|
|
|
|
|
|
13 |
{
|
14 |
+
public function operator(Twig_Compiler $compiler)
|
15 |
{
|
16 |
$compiler->raw('+');
|
17 |
}
|
18 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Node/Flush.php
CHANGED
@@ -9,22 +9,19 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Compiler;
|
13 |
-
use Twig\Node\Node;
|
14 |
-
|
15 |
/**
|
16 |
* Represents a flush node.
|
17 |
*
|
18 |
* @author Fabien Potencier <fabien@symfony.com>
|
19 |
*/
|
20 |
-
class Twig_Node_Flush extends
|
21 |
{
|
22 |
public function __construct($lineno, $tag)
|
23 |
{
|
24 |
-
parent::__construct(
|
25 |
}
|
26 |
|
27 |
-
public function compile(
|
28 |
{
|
29 |
$compiler
|
30 |
->addDebugInfo($this)
|
@@ -32,5 +29,3 @@ class Twig_Node_Flush extends Node
|
|
32 |
;
|
33 |
}
|
34 |
}
|
35 |
-
|
36 |
-
class_alias('Twig_Node_Flush', 'Twig\Node\FlushNode', false);
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
|
|
12 |
/**
|
13 |
* Represents a flush node.
|
14 |
*
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
+
class Twig_Node_Flush extends Twig_Node
|
18 |
{
|
19 |
public function __construct($lineno, $tag)
|
20 |
{
|
21 |
+
parent::__construct(array(), array(), $lineno, $tag);
|
22 |
}
|
23 |
|
24 |
+
public function compile(Twig_Compiler $compiler)
|
25 |
{
|
26 |
$compiler
|
27 |
->addDebugInfo($this)
|
29 |
;
|
30 |
}
|
31 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Node/For.php
CHANGED
@@ -10,39 +10,32 @@
|
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
|
13 |
-
use Twig\Compiler;
|
14 |
-
use Twig\Node\Expression\AbstractExpression;
|
15 |
-
use Twig\Node\Expression\AssignNameExpression;
|
16 |
-
use Twig\Node\ForLoopNode;
|
17 |
-
use Twig\Node\IfNode;
|
18 |
-
use Twig\Node\Node;
|
19 |
-
|
20 |
/**
|
21 |
* Represents a for node.
|
22 |
*
|
23 |
* @author Fabien Potencier <fabien@symfony.com>
|
24 |
*/
|
25 |
-
class Twig_Node_For extends
|
26 |
{
|
27 |
protected $loop;
|
28 |
|
29 |
-
public function __construct(
|
30 |
{
|
31 |
-
$body = new
|
32 |
|
33 |
if (null !== $ifexpr) {
|
34 |
-
$body = new
|
35 |
}
|
36 |
|
37 |
-
$nodes =
|
38 |
if (null !== $else) {
|
39 |
$nodes['else'] = $else;
|
40 |
}
|
41 |
|
42 |
-
parent::__construct($nodes,
|
43 |
}
|
44 |
|
45 |
-
public function compile(
|
46 |
{
|
47 |
$compiler
|
48 |
->addDebugInfo($this)
|
@@ -58,17 +51,17 @@ class Twig_Node_For extends Node
|
|
58 |
|
59 |
if ($this->getAttribute('with_loop')) {
|
60 |
$compiler
|
61 |
-
->write("\$context['loop'] =
|
62 |
->write(" 'parent' => \$context['_parent'],\n")
|
63 |
->write(" 'index0' => 0,\n")
|
64 |
->write(" 'index' => 1,\n")
|
65 |
->write(" 'first' => true,\n")
|
66 |
-
->write("
|
67 |
;
|
68 |
|
69 |
if (!$this->getAttribute('ifexpr')) {
|
70 |
$compiler
|
71 |
-
->write("if (is_array(\$context['_seq']) || (is_object(\$context['_seq']) && \$context['_seq'] instanceof
|
72 |
->indent()
|
73 |
->write("\$length = count(\$context['_seq']);\n")
|
74 |
->write("\$context['loop']['revindex0'] = \$length - 1;\n")
|
@@ -116,5 +109,3 @@ class Twig_Node_For extends Node
|
|
116 |
$compiler->write("\$context = array_intersect_key(\$context, \$_parent) + \$_parent;\n");
|
117 |
}
|
118 |
}
|
119 |
-
|
120 |
-
class_alias('Twig_Node_For', 'Twig\Node\ForNode', false);
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
/**
|
14 |
* Represents a for node.
|
15 |
*
|
16 |
* @author Fabien Potencier <fabien@symfony.com>
|
17 |
*/
|
18 |
+
class Twig_Node_For extends Twig_Node
|
19 |
{
|
20 |
protected $loop;
|
21 |
|
22 |
+
public function __construct(Twig_Node_Expression_AssignName $keyTarget, Twig_Node_Expression_AssignName $valueTarget, Twig_Node_Expression $seq, Twig_Node_Expression $ifexpr = null, Twig_NodeInterface $body, Twig_NodeInterface $else = null, $lineno, $tag = null)
|
23 |
{
|
24 |
+
$body = new Twig_Node(array($body, $this->loop = new Twig_Node_ForLoop($lineno, $tag)));
|
25 |
|
26 |
if (null !== $ifexpr) {
|
27 |
+
$body = new Twig_Node_If(new Twig_Node(array($ifexpr, $body)), null, $lineno, $tag);
|
28 |
}
|
29 |
|
30 |
+
$nodes = array('key_target' => $keyTarget, 'value_target' => $valueTarget, 'seq' => $seq, 'body' => $body);
|
31 |
if (null !== $else) {
|
32 |
$nodes['else'] = $else;
|
33 |
}
|
34 |
|
35 |
+
parent::__construct($nodes, array('with_loop' => true, 'ifexpr' => null !== $ifexpr), $lineno, $tag);
|
36 |
}
|
37 |
|
38 |
+
public function compile(Twig_Compiler $compiler)
|
39 |
{
|
40 |
$compiler
|
41 |
->addDebugInfo($this)
|
51 |
|
52 |
if ($this->getAttribute('with_loop')) {
|
53 |
$compiler
|
54 |
+
->write("\$context['loop'] = array(\n")
|
55 |
->write(" 'parent' => \$context['_parent'],\n")
|
56 |
->write(" 'index0' => 0,\n")
|
57 |
->write(" 'index' => 1,\n")
|
58 |
->write(" 'first' => true,\n")
|
59 |
+
->write(");\n")
|
60 |
;
|
61 |
|
62 |
if (!$this->getAttribute('ifexpr')) {
|
63 |
$compiler
|
64 |
+
->write("if (is_array(\$context['_seq']) || (is_object(\$context['_seq']) && \$context['_seq'] instanceof Countable)) {\n")
|
65 |
->indent()
|
66 |
->write("\$length = count(\$context['_seq']);\n")
|
67 |
->write("\$context['loop']['revindex0'] = \$length - 1;\n")
|
109 |
$compiler->write("\$context = array_intersect_key(\$context, \$_parent) + \$_parent;\n");
|
110 |
}
|
111 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Node/ForLoop.php
CHANGED
@@ -9,22 +9,19 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Compiler;
|
13 |
-
use Twig\Node\Node;
|
14 |
-
|
15 |
/**
|
16 |
* Internal node used by the for node.
|
17 |
*
|
18 |
* @author Fabien Potencier <fabien@symfony.com>
|
19 |
*/
|
20 |
-
class Twig_Node_ForLoop extends
|
21 |
{
|
22 |
public function __construct($lineno, $tag = null)
|
23 |
{
|
24 |
-
parent::__construct(
|
25 |
}
|
26 |
|
27 |
-
public function compile(
|
28 |
{
|
29 |
if ($this->getAttribute('else')) {
|
30 |
$compiler->write("\$context['_iterated'] = true;\n");
|
@@ -51,5 +48,3 @@ class Twig_Node_ForLoop extends Node
|
|
51 |
}
|
52 |
}
|
53 |
}
|
54 |
-
|
55 |
-
class_alias('Twig_Node_ForLoop', 'Twig\Node\ForLoopNode', false);
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
|
|
12 |
/**
|
13 |
* Internal node used by the for node.
|
14 |
*
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
+
class Twig_Node_ForLoop extends Twig_Node
|
18 |
{
|
19 |
public function __construct($lineno, $tag = null)
|
20 |
{
|
21 |
+
parent::__construct(array(), array('with_loop' => false, 'ifexpr' => false, 'else' => false), $lineno, $tag);
|
22 |
}
|
23 |
|
24 |
+
public function compile(Twig_Compiler $compiler)
|
25 |
{
|
26 |
if ($this->getAttribute('else')) {
|
27 |
$compiler->write("\$context['_iterated'] = true;\n");
|
48 |
}
|
49 |
}
|
50 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Node/If.php
CHANGED
@@ -10,30 +10,27 @@
|
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
|
13 |
-
use Twig\Compiler;
|
14 |
-
use Twig\Node\Node;
|
15 |
-
|
16 |
/**
|
17 |
* Represents an if node.
|
18 |
*
|
19 |
* @author Fabien Potencier <fabien@symfony.com>
|
20 |
*/
|
21 |
-
class Twig_Node_If extends
|
22 |
{
|
23 |
public function __construct(Twig_NodeInterface $tests, Twig_NodeInterface $else = null, $lineno, $tag = null)
|
24 |
{
|
25 |
-
$nodes =
|
26 |
if (null !== $else) {
|
27 |
$nodes['else'] = $else;
|
28 |
}
|
29 |
|
30 |
-
parent::__construct($nodes,
|
31 |
}
|
32 |
|
33 |
-
public function compile(
|
34 |
{
|
35 |
$compiler->addDebugInfo($this);
|
36 |
-
for ($i = 0, $count =
|
37 |
if ($i > 0) {
|
38 |
$compiler
|
39 |
->outdent()
|
@@ -67,5 +64,3 @@ class Twig_Node_If extends Node
|
|
67 |
->write("}\n");
|
68 |
}
|
69 |
}
|
70 |
-
|
71 |
-
class_alias('Twig_Node_If', 'Twig\Node\IfNode', false);
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
|
|
|
|
|
|
|
13 |
/**
|
14 |
* Represents an if node.
|
15 |
*
|
16 |
* @author Fabien Potencier <fabien@symfony.com>
|
17 |
*/
|
18 |
+
class Twig_Node_If extends Twig_Node
|
19 |
{
|
20 |
public function __construct(Twig_NodeInterface $tests, Twig_NodeInterface $else = null, $lineno, $tag = null)
|
21 |
{
|
22 |
+
$nodes = array('tests' => $tests);
|
23 |
if (null !== $else) {
|
24 |
$nodes['else'] = $else;
|
25 |
}
|
26 |
|
27 |
+
parent::__construct($nodes, array(), $lineno, $tag);
|
28 |
}
|
29 |
|
30 |
+
public function compile(Twig_Compiler $compiler)
|
31 |
{
|
32 |
$compiler->addDebugInfo($this);
|
33 |
+
for ($i = 0, $count = count($this->getNode('tests')); $i < $count; $i += 2) {
|
34 |
if ($i > 0) {
|
35 |
$compiler
|
36 |
->outdent()
|
64 |
->write("}\n");
|
65 |
}
|
66 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Node/Import.php
CHANGED
@@ -9,24 +9,19 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Compiler;
|
13 |
-
use Twig\Node\Expression\AbstractExpression;
|
14 |
-
use Twig\Node\Expression\NameExpression;
|
15 |
-
use Twig\Node\Node;
|
16 |
-
|
17 |
/**
|
18 |
* Represents an import node.
|
19 |
*
|
20 |
* @author Fabien Potencier <fabien@symfony.com>
|
21 |
*/
|
22 |
-
class Twig_Node_Import extends
|
23 |
{
|
24 |
-
public function __construct(
|
25 |
{
|
26 |
-
parent::__construct(
|
27 |
}
|
28 |
|
29 |
-
public function compile(
|
30 |
{
|
31 |
$compiler
|
32 |
->addDebugInfo($this)
|
@@ -35,7 +30,7 @@ class Twig_Node_Import extends Node
|
|
35 |
->raw(' = ')
|
36 |
;
|
37 |
|
38 |
-
if ($this->getNode('expr') instanceof
|
39 |
$compiler->raw('$this');
|
40 |
} else {
|
41 |
$compiler
|
@@ -52,5 +47,3 @@ class Twig_Node_Import extends Node
|
|
52 |
$compiler->raw(";\n");
|
53 |
}
|
54 |
}
|
55 |
-
|
56 |
-
class_alias('Twig_Node_Import', 'Twig\Node\ImportNode', false);
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
|
|
|
|
|
|
12 |
/**
|
13 |
* Represents an import node.
|
14 |
*
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
+
class Twig_Node_Import extends Twig_Node
|
18 |
{
|
19 |
+
public function __construct(Twig_Node_Expression $expr, Twig_Node_Expression $var, $lineno, $tag = null)
|
20 |
{
|
21 |
+
parent::__construct(array('expr' => $expr, 'var' => $var), array(), $lineno, $tag);
|
22 |
}
|
23 |
|
24 |
+
public function compile(Twig_Compiler $compiler)
|
25 |
{
|
26 |
$compiler
|
27 |
->addDebugInfo($this)
|
30 |
->raw(' = ')
|
31 |
;
|
32 |
|
33 |
+
if ($this->getNode('expr') instanceof Twig_Node_Expression_Name && '_self' === $this->getNode('expr')->getAttribute('name')) {
|
34 |
$compiler->raw('$this');
|
35 |
} else {
|
36 |
$compiler
|
47 |
$compiler->raw(";\n");
|
48 |
}
|
49 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Node/Include.php
CHANGED
@@ -10,29 +10,24 @@
|
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
|
13 |
-
use Twig\Compiler;
|
14 |
-
use Twig\Node\Expression\AbstractExpression;
|
15 |
-
use Twig\Node\Node;
|
16 |
-
use Twig\Node\NodeOutputInterface;
|
17 |
-
|
18 |
/**
|
19 |
* Represents an include node.
|
20 |
*
|
21 |
* @author Fabien Potencier <fabien@symfony.com>
|
22 |
*/
|
23 |
-
class Twig_Node_Include extends
|
24 |
{
|
25 |
-
public function __construct(
|
26 |
{
|
27 |
-
$nodes =
|
28 |
if (null !== $variables) {
|
29 |
$nodes['variables'] = $variables;
|
30 |
}
|
31 |
|
32 |
-
parent::__construct($nodes,
|
33 |
}
|
34 |
|
35 |
-
public function compile(
|
36 |
{
|
37 |
$compiler->addDebugInfo($this);
|
38 |
|
@@ -54,7 +49,7 @@ class Twig_Node_Include extends Node implements NodeOutputInterface
|
|
54 |
if ($this->getAttribute('ignore_missing')) {
|
55 |
$compiler
|
56 |
->outdent()
|
57 |
-
->write("} catch (
|
58 |
->indent()
|
59 |
->write("// ignore missing template\n")
|
60 |
->outdent()
|
@@ -63,7 +58,7 @@ class Twig_Node_Include extends Node implements NodeOutputInterface
|
|
63 |
}
|
64 |
}
|
65 |
|
66 |
-
protected function addGetTemplate(
|
67 |
{
|
68 |
$compiler
|
69 |
->write('$this->loadTemplate(')
|
@@ -76,10 +71,10 @@ class Twig_Node_Include extends Node implements NodeOutputInterface
|
|
76 |
;
|
77 |
}
|
78 |
|
79 |
-
protected function addTemplateArguments(
|
80 |
{
|
81 |
if (!$this->hasNode('variables')) {
|
82 |
-
$compiler->raw(false === $this->getAttribute('only') ? '$context' : '
|
83 |
} elseif (false === $this->getAttribute('only')) {
|
84 |
$compiler
|
85 |
->raw('array_merge($context, ')
|
@@ -91,5 +86,3 @@ class Twig_Node_Include extends Node implements NodeOutputInterface
|
|
91 |
}
|
92 |
}
|
93 |
}
|
94 |
-
|
95 |
-
class_alias('Twig_Node_Include', 'Twig\Node\IncludeNode', false);
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
|
|
|
|
|
|
|
|
|
|
|
13 |
/**
|
14 |
* Represents an include node.
|
15 |
*
|
16 |
* @author Fabien Potencier <fabien@symfony.com>
|
17 |
*/
|
18 |
+
class Twig_Node_Include extends Twig_Node implements Twig_NodeOutputInterface
|
19 |
{
|
20 |
+
public function __construct(Twig_Node_Expression $expr, Twig_Node_Expression $variables = null, $only = false, $ignoreMissing = false, $lineno, $tag = null)
|
21 |
{
|
22 |
+
$nodes = array('expr' => $expr);
|
23 |
if (null !== $variables) {
|
24 |
$nodes['variables'] = $variables;
|
25 |
}
|
26 |
|
27 |
+
parent::__construct($nodes, array('only' => (bool) $only, 'ignore_missing' => (bool) $ignoreMissing), $lineno, $tag);
|
28 |
}
|
29 |
|
30 |
+
public function compile(Twig_Compiler $compiler)
|
31 |
{
|
32 |
$compiler->addDebugInfo($this);
|
33 |
|
49 |
if ($this->getAttribute('ignore_missing')) {
|
50 |
$compiler
|
51 |
->outdent()
|
52 |
+
->write("} catch (Twig_Error_Loader \$e) {\n")
|
53 |
->indent()
|
54 |
->write("// ignore missing template\n")
|
55 |
->outdent()
|
58 |
}
|
59 |
}
|
60 |
|
61 |
+
protected function addGetTemplate(Twig_Compiler $compiler)
|
62 |
{
|
63 |
$compiler
|
64 |
->write('$this->loadTemplate(')
|
71 |
;
|
72 |
}
|
73 |
|
74 |
+
protected function addTemplateArguments(Twig_Compiler $compiler)
|
75 |
{
|
76 |
if (!$this->hasNode('variables')) {
|
77 |
+
$compiler->raw(false === $this->getAttribute('only') ? '$context' : 'array()');
|
78 |
} elseif (false === $this->getAttribute('only')) {
|
79 |
$compiler
|
80 |
->raw('array_merge($context, ')
|
86 |
}
|
87 |
}
|
88 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Node/Macro.php
CHANGED
@@ -9,16 +9,12 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Compiler;
|
13 |
-
use Twig\Error\SyntaxError;
|
14 |
-
use Twig\Node\Node;
|
15 |
-
|
16 |
/**
|
17 |
* Represents a macro node.
|
18 |
*
|
19 |
* @author Fabien Potencier <fabien@symfony.com>
|
20 |
*/
|
21 |
-
class Twig_Node_Macro extends
|
22 |
{
|
23 |
const VARARGS_NAME = 'varargs';
|
24 |
|
@@ -26,21 +22,21 @@ class Twig_Node_Macro extends Node
|
|
26 |
{
|
27 |
foreach ($arguments as $argumentName => $argument) {
|
28 |
if (self::VARARGS_NAME === $argumentName) {
|
29 |
-
throw new
|
30 |
}
|
31 |
}
|
32 |
|
33 |
-
parent::__construct(
|
34 |
}
|
35 |
|
36 |
-
public function compile(
|
37 |
{
|
38 |
$compiler
|
39 |
->addDebugInfo($this)
|
40 |
->write(sprintf('public function get%s(', $this->getAttribute('name')))
|
41 |
;
|
42 |
|
43 |
-
$count =
|
44 |
$pos = 0;
|
45 |
foreach ($this->getNode('arguments') as $name => $default) {
|
46 |
$compiler
|
@@ -68,7 +64,7 @@ class Twig_Node_Macro extends Node
|
|
68 |
;
|
69 |
|
70 |
$compiler
|
71 |
-
->write("\$context = \$this->env->mergeGlobals(
|
72 |
->indent()
|
73 |
;
|
74 |
|
@@ -95,35 +91,33 @@ class Twig_Node_Macro extends Node
|
|
95 |
->repr($count)
|
96 |
->raw(' ? array_slice(func_get_args(), ')
|
97 |
->repr($count)
|
98 |
-
->raw(") :
|
99 |
;
|
100 |
}
|
101 |
|
102 |
$compiler
|
103 |
->outdent()
|
104 |
-
->write("
|
105 |
-
->write("\$blocks =
|
106 |
->write("ob_start();\n")
|
107 |
->write("try {\n")
|
108 |
->indent()
|
109 |
->subcompile($this->getNode('body'))
|
110 |
->outdent()
|
111 |
-
->write("} catch (
|
112 |
->indent()
|
113 |
->write("ob_end_clean();\n\n")
|
114 |
->write("throw \$e;\n")
|
115 |
->outdent()
|
116 |
-
->write("} catch (
|
117 |
->indent()
|
118 |
->write("ob_end_clean();\n\n")
|
119 |
->write("throw \$e;\n")
|
120 |
->outdent()
|
121 |
->write("}\n\n")
|
122 |
-
->write("return ('' === \$tmp = ob_get_clean()) ? '' : new
|
123 |
->outdent()
|
124 |
->write("}\n\n")
|
125 |
;
|
126 |
}
|
127 |
}
|
128 |
-
|
129 |
-
class_alias('Twig_Node_Macro', 'Twig\Node\MacroNode', false);
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
|
|
|
|
12 |
/**
|
13 |
* Represents a macro node.
|
14 |
*
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
+
class Twig_Node_Macro extends Twig_Node
|
18 |
{
|
19 |
const VARARGS_NAME = 'varargs';
|
20 |
|
22 |
{
|
23 |
foreach ($arguments as $argumentName => $argument) {
|
24 |
if (self::VARARGS_NAME === $argumentName) {
|
25 |
+
throw new Twig_Error_Syntax(sprintf('The argument "%s" in macro "%s" cannot be defined because the variable "%s" is reserved for arbitrary arguments.', self::VARARGS_NAME, $name, self::VARARGS_NAME), $argument->getTemplateLine());
|
26 |
}
|
27 |
}
|
28 |
|
29 |
+
parent::__construct(array('body' => $body, 'arguments' => $arguments), array('name' => $name), $lineno, $tag);
|
30 |
}
|
31 |
|
32 |
+
public function compile(Twig_Compiler $compiler)
|
33 |
{
|
34 |
$compiler
|
35 |
->addDebugInfo($this)
|
36 |
->write(sprintf('public function get%s(', $this->getAttribute('name')))
|
37 |
;
|
38 |
|
39 |
+
$count = count($this->getNode('arguments'));
|
40 |
$pos = 0;
|
41 |
foreach ($this->getNode('arguments') as $name => $default) {
|
42 |
$compiler
|
64 |
;
|
65 |
|
66 |
$compiler
|
67 |
+
->write("\$context = \$this->env->mergeGlobals(array(\n")
|
68 |
->indent()
|
69 |
;
|
70 |
|
91 |
->repr($count)
|
92 |
->raw(' ? array_slice(func_get_args(), ')
|
93 |
->repr($count)
|
94 |
+
->raw(") : array(),\n")
|
95 |
;
|
96 |
}
|
97 |
|
98 |
$compiler
|
99 |
->outdent()
|
100 |
+
->write("));\n\n")
|
101 |
+
->write("\$blocks = array();\n\n")
|
102 |
->write("ob_start();\n")
|
103 |
->write("try {\n")
|
104 |
->indent()
|
105 |
->subcompile($this->getNode('body'))
|
106 |
->outdent()
|
107 |
+
->write("} catch (Exception \$e) {\n")
|
108 |
->indent()
|
109 |
->write("ob_end_clean();\n\n")
|
110 |
->write("throw \$e;\n")
|
111 |
->outdent()
|
112 |
+
->write("} catch (Throwable \$e) {\n")
|
113 |
->indent()
|
114 |
->write("ob_end_clean();\n\n")
|
115 |
->write("throw \$e;\n")
|
116 |
->outdent()
|
117 |
->write("}\n\n")
|
118 |
+
->write("return ('' === \$tmp = ob_get_clean()) ? '' : new Twig_Markup(\$tmp, \$this->env->getCharset());\n")
|
119 |
->outdent()
|
120 |
->write("}\n\n")
|
121 |
;
|
122 |
}
|
123 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Node/Module.php
CHANGED
@@ -10,15 +10,6 @@
|
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
|
13 |
-
use Twig\Compiler;
|
14 |
-
use Twig\Node\BlockReferenceNode;
|
15 |
-
use Twig\Node\BodyNode;
|
16 |
-
use Twig\Node\Expression\AbstractExpression;
|
17 |
-
use Twig\Node\Expression\ConstantExpression;
|
18 |
-
use Twig\Node\Node;
|
19 |
-
use Twig\Node\TextNode;
|
20 |
-
use Twig\Source;
|
21 |
-
|
22 |
/**
|
23 |
* Represents a module node.
|
24 |
*
|
@@ -28,43 +19,43 @@ use Twig\Source;
|
|
28 |
*
|
29 |
* @author Fabien Potencier <fabien@symfony.com>
|
30 |
*/
|
31 |
-
class Twig_Node_Module extends
|
32 |
{
|
33 |
private $source;
|
34 |
|
35 |
-
public function __construct(Twig_NodeInterface $body,
|
36 |
{
|
37 |
-
if (!$name instanceof
|
38 |
@trigger_error(sprintf('Passing a string as the $name argument of %s() is deprecated since version 1.27. Pass a Twig_Source instance instead.', __METHOD__), E_USER_DEPRECATED);
|
39 |
-
$this->source = new
|
40 |
} else {
|
41 |
$this->source = $name;
|
42 |
}
|
43 |
|
44 |
-
$nodes =
|
45 |
'body' => $body,
|
46 |
'blocks' => $blocks,
|
47 |
'macros' => $macros,
|
48 |
'traits' => $traits,
|
49 |
-
'display_start' => new
|
50 |
-
'display_end' => new
|
51 |
-
'constructor_start' => new
|
52 |
-
'constructor_end' => new
|
53 |
-
'class_end' => new
|
54 |
-
|
55 |
if (null !== $parent) {
|
56 |
$nodes['parent'] = $parent;
|
57 |
}
|
58 |
|
59 |
// embedded templates are set as attributes so that they are only visited once by the visitors
|
60 |
-
parent::__construct($nodes,
|
61 |
// source to be remove in 2.0
|
62 |
'source' => $this->source->getCode(),
|
63 |
// filename to be remove in 2.0 (use getTemplateName() instead)
|
64 |
'filename' => $this->source->getName(),
|
65 |
'index' => null,
|
66 |
'embedded_templates' => $embeddedTemplates,
|
67 |
-
|
68 |
|
69 |
// populate the template name of all node children
|
70 |
$this->setTemplateName($this->source->getName());
|
@@ -75,7 +66,7 @@ class Twig_Node_Module extends Node
|
|
75 |
$this->setAttribute('index', $index);
|
76 |
}
|
77 |
|
78 |
-
public function compile(
|
79 |
{
|
80 |
$this->compileTemplate($compiler);
|
81 |
|
@@ -84,7 +75,7 @@ class Twig_Node_Module extends Node
|
|
84 |
}
|
85 |
}
|
86 |
|
87 |
-
protected function compileTemplate(
|
88 |
{
|
89 |
if (!$this->getAttribute('index')) {
|
90 |
$compiler->write('<?php');
|
@@ -93,12 +84,12 @@ class Twig_Node_Module extends Node
|
|
93 |
$this->compileClassHeader($compiler);
|
94 |
|
95 |
if (
|
96 |
-
|
97 |
-
||
|
98 |
|| !$this->hasNode('parent')
|
99 |
-
|| $this->getNode('parent') instanceof
|
100 |
-
||
|
101 |
-
||
|
102 |
) {
|
103 |
$this->compileConstructor($compiler);
|
104 |
}
|
@@ -124,7 +115,7 @@ class Twig_Node_Module extends Node
|
|
124 |
$this->compileClassFooter($compiler);
|
125 |
}
|
126 |
|
127 |
-
protected function compileGetParent(
|
128 |
{
|
129 |
if (!$this->hasNode('parent')) {
|
130 |
return;
|
@@ -138,7 +129,7 @@ class Twig_Node_Module extends Node
|
|
138 |
->write('return ')
|
139 |
;
|
140 |
|
141 |
-
if ($parent instanceof
|
142 |
$compiler->subcompile($parent);
|
143 |
} else {
|
144 |
$compiler
|
@@ -159,26 +150,10 @@ class Twig_Node_Module extends Node
|
|
159 |
;
|
160 |
}
|
161 |
|
162 |
-
protected function compileClassHeader(
|
163 |
{
|
164 |
$compiler
|
165 |
->write("\n\n")
|
166 |
-
;
|
167 |
-
if (!$this->getAttribute('index')) {
|
168 |
-
$compiler
|
169 |
-
->write("use Twig\Environment;\n")
|
170 |
-
->write("use Twig\Error\LoaderError;\n")
|
171 |
-
->write("use Twig\Error\RuntimeError;\n")
|
172 |
-
->write("use Twig\Markup;\n")
|
173 |
-
->write("use Twig\Sandbox\SecurityError;\n")
|
174 |
-
->write("use Twig\Sandbox\SecurityNotAllowedTagError;\n")
|
175 |
-
->write("use Twig\Sandbox\SecurityNotAllowedFilterError;\n")
|
176 |
-
->write("use Twig\Sandbox\SecurityNotAllowedFunctionError;\n")
|
177 |
-
->write("use Twig\Source;\n")
|
178 |
-
->write("use Twig\Template;\n\n")
|
179 |
-
;
|
180 |
-
}
|
181 |
-
$compiler
|
182 |
// if the template name contains */, add a blank to avoid a PHP parse error
|
183 |
->write('/* '.str_replace('*/', '* /', $this->source->getName())." */\n")
|
184 |
->write('class '.$compiler->getEnvironment()->getTemplateClass($this->source->getName(), $this->getAttribute('index')))
|
@@ -188,10 +163,10 @@ class Twig_Node_Module extends Node
|
|
188 |
;
|
189 |
}
|
190 |
|
191 |
-
protected function compileConstructor(
|
192 |
{
|
193 |
$compiler
|
194 |
-
->write("public function __construct(
|
195 |
->indent()
|
196 |
->subcompile($this->getNode('constructor_start'))
|
197 |
->write("parent::__construct(\$env);\n\n")
|
@@ -200,7 +175,7 @@ class Twig_Node_Module extends Node
|
|
200 |
// parent
|
201 |
if (!$this->hasNode('parent')) {
|
202 |
$compiler->write("\$this->parent = false;\n\n");
|
203 |
-
} elseif (($parent = $this->getNode('parent')) && $parent instanceof
|
204 |
$compiler
|
205 |
->addDebugInfo($parent)
|
206 |
->write('$this->parent = $this->loadTemplate(')
|
@@ -213,7 +188,7 @@ class Twig_Node_Module extends Node
|
|
213 |
;
|
214 |
}
|
215 |
|
216 |
-
$countTraits =
|
217 |
if ($countTraits) {
|
218 |
// traits
|
219 |
foreach ($this->getNode('traits') as $i => $trait) {
|
@@ -223,7 +198,7 @@ class Twig_Node_Module extends Node
|
|
223 |
->addDebugInfo($trait->getNode('template'))
|
224 |
->write(sprintf("if (!\$_trait_%s->isTraitable()) {\n", $i))
|
225 |
->indent()
|
226 |
-
->write("throw new
|
227 |
->subcompile($trait->getNode('template'))
|
228 |
->raw(".'\" cannot be used as a trait.');\n")
|
229 |
->outdent()
|
@@ -237,7 +212,7 @@ class Twig_Node_Module extends Node
|
|
237 |
->string($key)
|
238 |
->raw("])) {\n")
|
239 |
->indent()
|
240 |
-
->write("throw new
|
241 |
->string($key)
|
242 |
->raw(' is not defined in trait ')
|
243 |
->subcompile($trait->getNode('template'))
|
@@ -282,11 +257,11 @@ class Twig_Node_Module extends Node
|
|
282 |
->write("\$this->blocks = array_merge(\n")
|
283 |
->indent()
|
284 |
->write("\$this->traits,\n")
|
285 |
-
->write("
|
286 |
;
|
287 |
} else {
|
288 |
$compiler
|
289 |
-
->write("\$this->blocks =
|
290 |
;
|
291 |
}
|
292 |
|
@@ -297,35 +272,30 @@ class Twig_Node_Module extends Node
|
|
297 |
|
298 |
foreach ($this->getNode('blocks') as $name => $node) {
|
299 |
$compiler
|
300 |
-
->write(sprintf("'%s' =>
|
301 |
;
|
302 |
}
|
303 |
|
304 |
if ($countTraits) {
|
305 |
$compiler
|
306 |
->outdent()
|
307 |
-
->write("
|
308 |
-
->outdent()
|
309 |
-
->write(");\n")
|
310 |
-
;
|
311 |
-
} else {
|
312 |
-
$compiler
|
313 |
-
->outdent()
|
314 |
-
->write("];\n")
|
315 |
;
|
316 |
}
|
317 |
|
318 |
$compiler
|
|
|
|
|
319 |
->outdent()
|
320 |
->subcompile($this->getNode('constructor_end'))
|
321 |
->write("}\n\n")
|
322 |
;
|
323 |
}
|
324 |
|
325 |
-
protected function compileDisplay(
|
326 |
{
|
327 |
$compiler
|
328 |
-
->write("protected function doDisplay(array \$context, array \$blocks =
|
329 |
->indent()
|
330 |
->subcompile($this->getNode('display_start'))
|
331 |
->subcompile($this->getNode('body'))
|
@@ -334,7 +304,7 @@ class Twig_Node_Module extends Node
|
|
334 |
if ($this->hasNode('parent')) {
|
335 |
$parent = $this->getNode('parent');
|
336 |
$compiler->addDebugInfo($parent);
|
337 |
-
if ($parent instanceof
|
338 |
$compiler->write('$this->parent');
|
339 |
} else {
|
340 |
$compiler->write('$this->getParent($context)');
|
@@ -349,7 +319,7 @@ class Twig_Node_Module extends Node
|
|
349 |
;
|
350 |
}
|
351 |
|
352 |
-
protected function compileClassFooter(
|
353 |
{
|
354 |
$compiler
|
355 |
->subcompile($this->getNode('class_end'))
|
@@ -358,12 +328,12 @@ class Twig_Node_Module extends Node
|
|
358 |
;
|
359 |
}
|
360 |
|
361 |
-
protected function compileMacros(
|
362 |
{
|
363 |
$compiler->subcompile($this->getNode('macros'));
|
364 |
}
|
365 |
|
366 |
-
protected function compileGetTemplateName(
|
367 |
{
|
368 |
$compiler
|
369 |
->write("public function getTemplateName()\n", "{\n")
|
@@ -376,7 +346,7 @@ class Twig_Node_Module extends Node
|
|
376 |
;
|
377 |
}
|
378 |
|
379 |
-
protected function compileIsTraitable(
|
380 |
{
|
381 |
// A template can be used as a trait if:
|
382 |
// * it has no parent
|
@@ -385,28 +355,28 @@ class Twig_Node_Module extends Node
|
|
385 |
//
|
386 |
// Put another way, a template can be used as a trait if it
|
387 |
// only contains blocks and use statements.
|
388 |
-
$traitable = !$this->hasNode('parent') && 0 ===
|
389 |
if ($traitable) {
|
390 |
-
if ($this->getNode('body') instanceof
|
391 |
$nodes = $this->getNode('body')->getNode(0);
|
392 |
} else {
|
393 |
$nodes = $this->getNode('body');
|
394 |
}
|
395 |
|
396 |
-
if (
|
397 |
-
$nodes = new
|
398 |
}
|
399 |
|
400 |
foreach ($nodes as $node) {
|
401 |
-
if (
|
402 |
continue;
|
403 |
}
|
404 |
|
405 |
-
if ($node instanceof
|
406 |
continue;
|
407 |
}
|
408 |
|
409 |
-
if ($node instanceof
|
410 |
continue;
|
411 |
}
|
412 |
|
@@ -428,7 +398,7 @@ class Twig_Node_Module extends Node
|
|
428 |
;
|
429 |
}
|
430 |
|
431 |
-
protected function compileDebugInfo(
|
432 |
{
|
433 |
$compiler
|
434 |
->write("public function getDebugInfo()\n", "{\n")
|
@@ -439,7 +409,7 @@ class Twig_Node_Module extends Node
|
|
439 |
;
|
440 |
}
|
441 |
|
442 |
-
protected function compileGetSource(
|
443 |
{
|
444 |
$compiler
|
445 |
->write("/** @deprecated since 1.27 (to be removed in 2.0). Use getSourceContext() instead */\n")
|
@@ -453,12 +423,12 @@ class Twig_Node_Module extends Node
|
|
453 |
;
|
454 |
}
|
455 |
|
456 |
-
protected function compileGetSourceContext(
|
457 |
{
|
458 |
$compiler
|
459 |
->write("public function getSourceContext()\n", "{\n")
|
460 |
->indent()
|
461 |
-
->write('return new
|
462 |
->string($compiler->getEnvironment()->isDebug() ? $this->source->getCode() : '')
|
463 |
->raw(', ')
|
464 |
->string($this->source->getName())
|
@@ -470,9 +440,9 @@ class Twig_Node_Module extends Node
|
|
470 |
;
|
471 |
}
|
472 |
|
473 |
-
protected function compileLoadTemplate(
|
474 |
{
|
475 |
-
if ($node instanceof
|
476 |
$compiler
|
477 |
->write(sprintf('%s = $this->loadTemplate(', $var))
|
478 |
->subcompile($node)
|
@@ -483,9 +453,7 @@ class Twig_Node_Module extends Node
|
|
483 |
->raw(");\n")
|
484 |
;
|
485 |
} else {
|
486 |
-
throw new
|
487 |
}
|
488 |
}
|
489 |
}
|
490 |
-
|
491 |
-
class_alias('Twig_Node_Module', 'Twig\Node\ModuleNode', false);
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
/**
|
14 |
* Represents a module node.
|
15 |
*
|
19 |
*
|
20 |
* @author Fabien Potencier <fabien@symfony.com>
|
21 |
*/
|
22 |
+
class Twig_Node_Module extends Twig_Node
|
23 |
{
|
24 |
private $source;
|
25 |
|
26 |
+
public function __construct(Twig_NodeInterface $body, Twig_Node_Expression $parent = null, Twig_NodeInterface $blocks, Twig_NodeInterface $macros, Twig_NodeInterface $traits, $embeddedTemplates, $name, $source = '')
|
27 |
{
|
28 |
+
if (!$name instanceof Twig_Source) {
|
29 |
@trigger_error(sprintf('Passing a string as the $name argument of %s() is deprecated since version 1.27. Pass a Twig_Source instance instead.', __METHOD__), E_USER_DEPRECATED);
|
30 |
+
$this->source = new Twig_Source($source, $name);
|
31 |
} else {
|
32 |
$this->source = $name;
|
33 |
}
|
34 |
|
35 |
+
$nodes = array(
|
36 |
'body' => $body,
|
37 |
'blocks' => $blocks,
|
38 |
'macros' => $macros,
|
39 |
'traits' => $traits,
|
40 |
+
'display_start' => new Twig_Node(),
|
41 |
+
'display_end' => new Twig_Node(),
|
42 |
+
'constructor_start' => new Twig_Node(),
|
43 |
+
'constructor_end' => new Twig_Node(),
|
44 |
+
'class_end' => new Twig_Node(),
|
45 |
+
);
|
46 |
if (null !== $parent) {
|
47 |
$nodes['parent'] = $parent;
|
48 |
}
|
49 |
|
50 |
// embedded templates are set as attributes so that they are only visited once by the visitors
|
51 |
+
parent::__construct($nodes, array(
|
52 |
// source to be remove in 2.0
|
53 |
'source' => $this->source->getCode(),
|
54 |
// filename to be remove in 2.0 (use getTemplateName() instead)
|
55 |
'filename' => $this->source->getName(),
|
56 |
'index' => null,
|
57 |
'embedded_templates' => $embeddedTemplates,
|
58 |
+
), 1);
|
59 |
|
60 |
// populate the template name of all node children
|
61 |
$this->setTemplateName($this->source->getName());
|
66 |
$this->setAttribute('index', $index);
|
67 |
}
|
68 |
|
69 |
+
public function compile(Twig_Compiler $compiler)
|
70 |
{
|
71 |
$this->compileTemplate($compiler);
|
72 |
|
75 |
}
|
76 |
}
|
77 |
|
78 |
+
protected function compileTemplate(Twig_Compiler $compiler)
|
79 |
{
|
80 |
if (!$this->getAttribute('index')) {
|
81 |
$compiler->write('<?php');
|
84 |
$this->compileClassHeader($compiler);
|
85 |
|
86 |
if (
|
87 |
+
count($this->getNode('blocks'))
|
88 |
+
|| count($this->getNode('traits'))
|
89 |
|| !$this->hasNode('parent')
|
90 |
+
|| $this->getNode('parent') instanceof Twig_Node_Expression_Constant
|
91 |
+
|| count($this->getNode('constructor_start'))
|
92 |
+
|| count($this->getNode('constructor_end'))
|
93 |
) {
|
94 |
$this->compileConstructor($compiler);
|
95 |
}
|
115 |
$this->compileClassFooter($compiler);
|
116 |
}
|
117 |
|
118 |
+
protected function compileGetParent(Twig_Compiler $compiler)
|
119 |
{
|
120 |
if (!$this->hasNode('parent')) {
|
121 |
return;
|
129 |
->write('return ')
|
130 |
;
|
131 |
|
132 |
+
if ($parent instanceof Twig_Node_Expression_Constant) {
|
133 |
$compiler->subcompile($parent);
|
134 |
} else {
|
135 |
$compiler
|
150 |
;
|
151 |
}
|
152 |
|
153 |
+
protected function compileClassHeader(Twig_Compiler $compiler)
|
154 |
{
|
155 |
$compiler
|
156 |
->write("\n\n")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
157 |
// if the template name contains */, add a blank to avoid a PHP parse error
|
158 |
->write('/* '.str_replace('*/', '* /', $this->source->getName())." */\n")
|
159 |
->write('class '.$compiler->getEnvironment()->getTemplateClass($this->source->getName(), $this->getAttribute('index')))
|
163 |
;
|
164 |
}
|
165 |
|
166 |
+
protected function compileConstructor(Twig_Compiler $compiler)
|
167 |
{
|
168 |
$compiler
|
169 |
+
->write("public function __construct(Twig_Environment \$env)\n", "{\n")
|
170 |
->indent()
|
171 |
->subcompile($this->getNode('constructor_start'))
|
172 |
->write("parent::__construct(\$env);\n\n")
|
175 |
// parent
|
176 |
if (!$this->hasNode('parent')) {
|
177 |
$compiler->write("\$this->parent = false;\n\n");
|
178 |
+
} elseif (($parent = $this->getNode('parent')) && $parent instanceof Twig_Node_Expression_Constant) {
|
179 |
$compiler
|
180 |
->addDebugInfo($parent)
|
181 |
->write('$this->parent = $this->loadTemplate(')
|
188 |
;
|
189 |
}
|
190 |
|
191 |
+
$countTraits = count($this->getNode('traits'));
|
192 |
if ($countTraits) {
|
193 |
// traits
|
194 |
foreach ($this->getNode('traits') as $i => $trait) {
|
198 |
->addDebugInfo($trait->getNode('template'))
|
199 |
->write(sprintf("if (!\$_trait_%s->isTraitable()) {\n", $i))
|
200 |
->indent()
|
201 |
+
->write("throw new Twig_Error_Runtime('Template \"'.")
|
202 |
->subcompile($trait->getNode('template'))
|
203 |
->raw(".'\" cannot be used as a trait.');\n")
|
204 |
->outdent()
|
212 |
->string($key)
|
213 |
->raw("])) {\n")
|
214 |
->indent()
|
215 |
+
->write("throw new Twig_Error_Runtime(sprintf('Block ")
|
216 |
->string($key)
|
217 |
->raw(' is not defined in trait ')
|
218 |
->subcompile($trait->getNode('template'))
|
257 |
->write("\$this->blocks = array_merge(\n")
|
258 |
->indent()
|
259 |
->write("\$this->traits,\n")
|
260 |
+
->write("array(\n")
|
261 |
;
|
262 |
} else {
|
263 |
$compiler
|
264 |
+
->write("\$this->blocks = array(\n")
|
265 |
;
|
266 |
}
|
267 |
|
272 |
|
273 |
foreach ($this->getNode('blocks') as $name => $node) {
|
274 |
$compiler
|
275 |
+
->write(sprintf("'%s' => array(\$this, 'block_%s'),\n", $name, $name))
|
276 |
;
|
277 |
}
|
278 |
|
279 |
if ($countTraits) {
|
280 |
$compiler
|
281 |
->outdent()
|
282 |
+
->write(")\n")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
283 |
;
|
284 |
}
|
285 |
|
286 |
$compiler
|
287 |
+
->outdent()
|
288 |
+
->write(");\n")
|
289 |
->outdent()
|
290 |
->subcompile($this->getNode('constructor_end'))
|
291 |
->write("}\n\n")
|
292 |
;
|
293 |
}
|
294 |
|
295 |
+
protected function compileDisplay(Twig_Compiler $compiler)
|
296 |
{
|
297 |
$compiler
|
298 |
+
->write("protected function doDisplay(array \$context, array \$blocks = array())\n", "{\n")
|
299 |
->indent()
|
300 |
->subcompile($this->getNode('display_start'))
|
301 |
->subcompile($this->getNode('body'))
|
304 |
if ($this->hasNode('parent')) {
|
305 |
$parent = $this->getNode('parent');
|
306 |
$compiler->addDebugInfo($parent);
|
307 |
+
if ($parent instanceof Twig_Node_Expression_Constant) {
|
308 |
$compiler->write('$this->parent');
|
309 |
} else {
|
310 |
$compiler->write('$this->getParent($context)');
|
319 |
;
|
320 |
}
|
321 |
|
322 |
+
protected function compileClassFooter(Twig_Compiler $compiler)
|
323 |
{
|
324 |
$compiler
|
325 |
->subcompile($this->getNode('class_end'))
|
328 |
;
|
329 |
}
|
330 |
|
331 |
+
protected function compileMacros(Twig_Compiler $compiler)
|
332 |
{
|
333 |
$compiler->subcompile($this->getNode('macros'));
|
334 |
}
|
335 |
|
336 |
+
protected function compileGetTemplateName(Twig_Compiler $compiler)
|
337 |
{
|
338 |
$compiler
|
339 |
->write("public function getTemplateName()\n", "{\n")
|
346 |
;
|
347 |
}
|
348 |
|
349 |
+
protected function compileIsTraitable(Twig_Compiler $compiler)
|
350 |
{
|
351 |
// A template can be used as a trait if:
|
352 |
// * it has no parent
|
355 |
//
|
356 |
// Put another way, a template can be used as a trait if it
|
357 |
// only contains blocks and use statements.
|
358 |
+
$traitable = !$this->hasNode('parent') && 0 === count($this->getNode('macros'));
|
359 |
if ($traitable) {
|
360 |
+
if ($this->getNode('body') instanceof Twig_Node_Body) {
|
361 |
$nodes = $this->getNode('body')->getNode(0);
|
362 |
} else {
|
363 |
$nodes = $this->getNode('body');
|
364 |
}
|
365 |
|
366 |
+
if (!count($nodes)) {
|
367 |
+
$nodes = new Twig_Node(array($nodes));
|
368 |
}
|
369 |
|
370 |
foreach ($nodes as $node) {
|
371 |
+
if (!count($node)) {
|
372 |
continue;
|
373 |
}
|
374 |
|
375 |
+
if ($node instanceof Twig_Node_Text && ctype_space($node->getAttribute('data'))) {
|
376 |
continue;
|
377 |
}
|
378 |
|
379 |
+
if ($node instanceof Twig_Node_BlockReference) {
|
380 |
continue;
|
381 |
}
|
382 |
|
398 |
;
|
399 |
}
|
400 |
|
401 |
+
protected function compileDebugInfo(Twig_Compiler $compiler)
|
402 |
{
|
403 |
$compiler
|
404 |
->write("public function getDebugInfo()\n", "{\n")
|
409 |
;
|
410 |
}
|
411 |
|
412 |
+
protected function compileGetSource(Twig_Compiler $compiler)
|
413 |
{
|
414 |
$compiler
|
415 |
->write("/** @deprecated since 1.27 (to be removed in 2.0). Use getSourceContext() instead */\n")
|
423 |
;
|
424 |
}
|
425 |
|
426 |
+
protected function compileGetSourceContext(Twig_Compiler $compiler)
|
427 |
{
|
428 |
$compiler
|
429 |
->write("public function getSourceContext()\n", "{\n")
|
430 |
->indent()
|
431 |
+
->write('return new Twig_Source(')
|
432 |
->string($compiler->getEnvironment()->isDebug() ? $this->source->getCode() : '')
|
433 |
->raw(', ')
|
434 |
->string($this->source->getName())
|
440 |
;
|
441 |
}
|
442 |
|
443 |
+
protected function compileLoadTemplate(Twig_Compiler $compiler, $node, $var)
|
444 |
{
|
445 |
+
if ($node instanceof Twig_Node_Expression_Constant) {
|
446 |
$compiler
|
447 |
->write(sprintf('%s = $this->loadTemplate(', $var))
|
448 |
->subcompile($node)
|
453 |
->raw(");\n")
|
454 |
;
|
455 |
} else {
|
456 |
+
throw new LogicException('Trait templates can only be constant nodes.');
|
457 |
}
|
458 |
}
|
459 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Node/Print.php
CHANGED
@@ -10,24 +10,19 @@
|
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
|
13 |
-
use Twig\Compiler;
|
14 |
-
use Twig\Node\Expression\AbstractExpression;
|
15 |
-
use Twig\Node\Node;
|
16 |
-
use Twig\Node\NodeOutputInterface;
|
17 |
-
|
18 |
/**
|
19 |
* Represents a node that outputs an expression.
|
20 |
*
|
21 |
* @author Fabien Potencier <fabien@symfony.com>
|
22 |
*/
|
23 |
-
class Twig_Node_Print extends
|
24 |
{
|
25 |
-
public function __construct(
|
26 |
{
|
27 |
-
parent::__construct(
|
28 |
}
|
29 |
|
30 |
-
public function compile(
|
31 |
{
|
32 |
$compiler
|
33 |
->addDebugInfo($this)
|
@@ -37,5 +32,3 @@ class Twig_Node_Print extends Node implements NodeOutputInterface
|
|
37 |
;
|
38 |
}
|
39 |
}
|
40 |
-
|
41 |
-
class_alias('Twig_Node_Print', 'Twig\Node\PrintNode', false);
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
|
|
|
|
|
|
|
|
|
|
|
13 |
/**
|
14 |
* Represents a node that outputs an expression.
|
15 |
*
|
16 |
* @author Fabien Potencier <fabien@symfony.com>
|
17 |
*/
|
18 |
+
class Twig_Node_Print extends Twig_Node implements Twig_NodeOutputInterface
|
19 |
{
|
20 |
+
public function __construct(Twig_Node_Expression $expr, $lineno, $tag = null)
|
21 |
{
|
22 |
+
parent::__construct(array('expr' => $expr), array(), $lineno, $tag);
|
23 |
}
|
24 |
|
25 |
+
public function compile(Twig_Compiler $compiler)
|
26 |
{
|
27 |
$compiler
|
28 |
->addDebugInfo($this)
|
32 |
;
|
33 |
}
|
34 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Node/Sandbox.php
CHANGED
@@ -9,26 +9,23 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Compiler;
|
13 |
-
use Twig\Node\Node;
|
14 |
-
|
15 |
/**
|
16 |
* Represents a sandbox node.
|
17 |
*
|
18 |
* @author Fabien Potencier <fabien@symfony.com>
|
19 |
*/
|
20 |
-
class Twig_Node_Sandbox extends
|
21 |
{
|
22 |
public function __construct(Twig_NodeInterface $body, $lineno, $tag = null)
|
23 |
{
|
24 |
-
parent::__construct(
|
25 |
}
|
26 |
|
27 |
-
public function compile(
|
28 |
{
|
29 |
$compiler
|
30 |
->addDebugInfo($this)
|
31 |
-
->write("\$sandbox = \$this->env->getExtension('
|
32 |
->write("if (!\$alreadySandboxed = \$sandbox->isSandboxed()) {\n")
|
33 |
->indent()
|
34 |
->write("\$sandbox->enableSandbox();\n")
|
@@ -43,5 +40,3 @@ class Twig_Node_Sandbox extends Node
|
|
43 |
;
|
44 |
}
|
45 |
}
|
46 |
-
|
47 |
-
class_alias('Twig_Node_Sandbox', 'Twig\Node\SandboxNode', false);
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
|
|
12 |
/**
|
13 |
* Represents a sandbox node.
|
14 |
*
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
+
class Twig_Node_Sandbox extends Twig_Node
|
18 |
{
|
19 |
public function __construct(Twig_NodeInterface $body, $lineno, $tag = null)
|
20 |
{
|
21 |
+
parent::__construct(array('body' => $body), array(), $lineno, $tag);
|
22 |
}
|
23 |
|
24 |
+
public function compile(Twig_Compiler $compiler)
|
25 |
{
|
26 |
$compiler
|
27 |
->addDebugInfo($this)
|
28 |
+
->write("\$sandbox = \$this->env->getExtension('Twig_Extension_Sandbox');\n")
|
29 |
->write("if (!\$alreadySandboxed = \$sandbox->isSandboxed()) {\n")
|
30 |
->indent()
|
31 |
->write("\$sandbox->enableSandbox();\n")
|
40 |
;
|
41 |
}
|
42 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Node/SandboxedPrint.php
CHANGED
@@ -9,11 +9,6 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Compiler;
|
13 |
-
use Twig\Node\Expression\FilterExpression;
|
14 |
-
use Twig\Node\Node;
|
15 |
-
use Twig\Node\PrintNode;
|
16 |
-
|
17 |
/**
|
18 |
* Twig_Node_SandboxedPrint adds a check for the __toString() method
|
19 |
* when the variable is an object and the sandbox is activated.
|
@@ -24,13 +19,13 @@ use Twig\Node\PrintNode;
|
|
24 |
*
|
25 |
* @author Fabien Potencier <fabien@symfony.com>
|
26 |
*/
|
27 |
-
class Twig_Node_SandboxedPrint extends
|
28 |
{
|
29 |
-
public function compile(
|
30 |
{
|
31 |
$compiler
|
32 |
->addDebugInfo($this)
|
33 |
-
->write('echo $this->env->getExtension(\'\
|
34 |
->subcompile($this->getNode('expr'))
|
35 |
->raw(");\n")
|
36 |
;
|
@@ -41,16 +36,14 @@ class Twig_Node_SandboxedPrint extends PrintNode
|
|
41 |
*
|
42 |
* This is mostly needed when another visitor adds filters (like the escaper one).
|
43 |
*
|
44 |
-
* @return
|
45 |
*/
|
46 |
-
protected function removeNodeFilter(
|
47 |
{
|
48 |
-
if ($node instanceof
|
49 |
return $this->removeNodeFilter($node->getNode('node'));
|
50 |
}
|
51 |
|
52 |
return $node;
|
53 |
}
|
54 |
}
|
55 |
-
|
56 |
-
class_alias('Twig_Node_SandboxedPrint', 'Twig\Node\SandboxedPrintNode', false);
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
|
|
|
|
|
|
12 |
/**
|
13 |
* Twig_Node_SandboxedPrint adds a check for the __toString() method
|
14 |
* when the variable is an object and the sandbox is activated.
|
19 |
*
|
20 |
* @author Fabien Potencier <fabien@symfony.com>
|
21 |
*/
|
22 |
+
class Twig_Node_SandboxedPrint extends Twig_Node_Print
|
23 |
{
|
24 |
+
public function compile(Twig_Compiler $compiler)
|
25 |
{
|
26 |
$compiler
|
27 |
->addDebugInfo($this)
|
28 |
+
->write('echo $this->env->getExtension(\'Twig_Extension_Sandbox\')->ensureToStringAllowed(')
|
29 |
->subcompile($this->getNode('expr'))
|
30 |
->raw(");\n")
|
31 |
;
|
36 |
*
|
37 |
* This is mostly needed when another visitor adds filters (like the escaper one).
|
38 |
*
|
39 |
+
* @return Twig_Node
|
40 |
*/
|
41 |
+
protected function removeNodeFilter(Twig_Node $node)
|
42 |
{
|
43 |
+
if ($node instanceof Twig_Node_Expression_Filter) {
|
44 |
return $this->removeNodeFilter($node->getNode('node'));
|
45 |
}
|
46 |
|
47 |
return $node;
|
48 |
}
|
49 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Node/Set.php
CHANGED
@@ -9,44 +9,38 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Compiler;
|
13 |
-
use Twig\Node\Expression\ConstantExpression;
|
14 |
-
use Twig\Node\Node;
|
15 |
-
use Twig\Node\NodeCaptureInterface;
|
16 |
-
use Twig\Node\TextNode;
|
17 |
-
|
18 |
/**
|
19 |
* Represents a set node.
|
20 |
*
|
21 |
* @author Fabien Potencier <fabien@symfony.com>
|
22 |
*/
|
23 |
-
class Twig_Node_Set extends
|
24 |
{
|
25 |
public function __construct($capture, Twig_NodeInterface $names, Twig_NodeInterface $values, $lineno, $tag = null)
|
26 |
{
|
27 |
-
parent::__construct(
|
28 |
|
29 |
/*
|
30 |
* Optimizes the node when capture is used for a large block of text.
|
31 |
*
|
32 |
-
* {% set foo %}foo{% endset %} is compiled to $context['foo'] = new
|
33 |
*/
|
34 |
if ($this->getAttribute('capture')) {
|
35 |
$this->setAttribute('safe', true);
|
36 |
|
37 |
$values = $this->getNode('values');
|
38 |
-
if ($values instanceof
|
39 |
-
$this->setNode('values', new
|
40 |
$this->setAttribute('capture', false);
|
41 |
}
|
42 |
}
|
43 |
}
|
44 |
|
45 |
-
public function compile(
|
46 |
{
|
47 |
$compiler->addDebugInfo($this);
|
48 |
|
49 |
-
if (
|
50 |
$compiler->write('list(');
|
51 |
foreach ($this->getNode('names') as $idx => $node) {
|
52 |
if ($idx) {
|
@@ -67,15 +61,15 @@ class Twig_Node_Set extends Node implements NodeCaptureInterface
|
|
67 |
$compiler->subcompile($this->getNode('names'), false);
|
68 |
|
69 |
if ($this->getAttribute('capture')) {
|
70 |
-
$compiler->raw(" = ('' === \$tmp = ob_get_clean()) ? '' : new
|
71 |
}
|
72 |
}
|
73 |
|
74 |
if (!$this->getAttribute('capture')) {
|
75 |
$compiler->raw(' = ');
|
76 |
|
77 |
-
if (
|
78 |
-
$compiler->write('
|
79 |
foreach ($this->getNode('values') as $idx => $value) {
|
80 |
if ($idx) {
|
81 |
$compiler->raw(', ');
|
@@ -83,13 +77,13 @@ class Twig_Node_Set extends Node implements NodeCaptureInterface
|
|
83 |
|
84 |
$compiler->subcompile($value);
|
85 |
}
|
86 |
-
$compiler->raw('
|
87 |
} else {
|
88 |
if ($this->getAttribute('safe')) {
|
89 |
$compiler
|
90 |
->raw("('' === \$tmp = ")
|
91 |
->subcompile($this->getNode('values'))
|
92 |
-
->raw(") ? '' : new
|
93 |
;
|
94 |
} else {
|
95 |
$compiler->subcompile($this->getNode('values'));
|
@@ -100,5 +94,3 @@ class Twig_Node_Set extends Node implements NodeCaptureInterface
|
|
100 |
$compiler->raw(";\n");
|
101 |
}
|
102 |
}
|
103 |
-
|
104 |
-
class_alias('Twig_Node_Set', 'Twig\Node\SetNode', false);
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
/**
|
13 |
* Represents a set node.
|
14 |
*
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
+
class Twig_Node_Set extends Twig_Node implements Twig_NodeCaptureInterface
|
18 |
{
|
19 |
public function __construct($capture, Twig_NodeInterface $names, Twig_NodeInterface $values, $lineno, $tag = null)
|
20 |
{
|
21 |
+
parent::__construct(array('names' => $names, 'values' => $values), array('capture' => $capture, 'safe' => false), $lineno, $tag);
|
22 |
|
23 |
/*
|
24 |
* Optimizes the node when capture is used for a large block of text.
|
25 |
*
|
26 |
+
* {% set foo %}foo{% endset %} is compiled to $context['foo'] = new Twig_Markup("foo");
|
27 |
*/
|
28 |
if ($this->getAttribute('capture')) {
|
29 |
$this->setAttribute('safe', true);
|
30 |
|
31 |
$values = $this->getNode('values');
|
32 |
+
if ($values instanceof Twig_Node_Text) {
|
33 |
+
$this->setNode('values', new Twig_Node_Expression_Constant($values->getAttribute('data'), $values->getTemplateLine()));
|
34 |
$this->setAttribute('capture', false);
|
35 |
}
|
36 |
}
|
37 |
}
|
38 |
|
39 |
+
public function compile(Twig_Compiler $compiler)
|
40 |
{
|
41 |
$compiler->addDebugInfo($this);
|
42 |
|
43 |
+
if (count($this->getNode('names')) > 1) {
|
44 |
$compiler->write('list(');
|
45 |
foreach ($this->getNode('names') as $idx => $node) {
|
46 |
if ($idx) {
|
61 |
$compiler->subcompile($this->getNode('names'), false);
|
62 |
|
63 |
if ($this->getAttribute('capture')) {
|
64 |
+
$compiler->raw(" = ('' === \$tmp = ob_get_clean()) ? '' : new Twig_Markup(\$tmp, \$this->env->getCharset())");
|
65 |
}
|
66 |
}
|
67 |
|
68 |
if (!$this->getAttribute('capture')) {
|
69 |
$compiler->raw(' = ');
|
70 |
|
71 |
+
if (count($this->getNode('names')) > 1) {
|
72 |
+
$compiler->write('array(');
|
73 |
foreach ($this->getNode('values') as $idx => $value) {
|
74 |
if ($idx) {
|
75 |
$compiler->raw(', ');
|
77 |
|
78 |
$compiler->subcompile($value);
|
79 |
}
|
80 |
+
$compiler->raw(')');
|
81 |
} else {
|
82 |
if ($this->getAttribute('safe')) {
|
83 |
$compiler
|
84 |
->raw("('' === \$tmp = ")
|
85 |
->subcompile($this->getNode('values'))
|
86 |
+
->raw(") ? '' : new Twig_Markup(\$tmp, \$this->env->getCharset())")
|
87 |
;
|
88 |
} else {
|
89 |
$compiler->subcompile($this->getNode('values'));
|
94 |
$compiler->raw(";\n");
|
95 |
}
|
96 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Node/SetTemp.php
CHANGED
@@ -9,20 +9,14 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
|
13 |
-
use Twig\Node\Node;
|
14 |
-
|
15 |
-
/**
|
16 |
-
* @internal
|
17 |
-
*/
|
18 |
-
class Twig_Node_SetTemp extends Node
|
19 |
{
|
20 |
public function __construct($name, $lineno)
|
21 |
{
|
22 |
-
parent::__construct(
|
23 |
}
|
24 |
|
25 |
-
public function compile(
|
26 |
{
|
27 |
$name = $this->getAttribute('name');
|
28 |
$compiler
|
@@ -39,5 +33,3 @@ class Twig_Node_SetTemp extends Node
|
|
39 |
;
|
40 |
}
|
41 |
}
|
42 |
-
|
43 |
-
class_alias('Twig_Node_SetTemp', 'Twig\Node\SetTempNode', false);
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
+
class Twig_Node_SetTemp extends Twig_Node
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
{
|
14 |
public function __construct($name, $lineno)
|
15 |
{
|
16 |
+
parent::__construct(array(), array('name' => $name), $lineno);
|
17 |
}
|
18 |
|
19 |
+
public function compile(Twig_Compiler $compiler)
|
20 |
{
|
21 |
$name = $this->getAttribute('name');
|
22 |
$compiler
|
33 |
;
|
34 |
}
|
35 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Node/Spaceless.php
CHANGED
@@ -9,9 +9,6 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Compiler;
|
13 |
-
use Twig\Node\Node;
|
14 |
-
|
15 |
/**
|
16 |
* Represents a spaceless node.
|
17 |
*
|
@@ -19,14 +16,14 @@ use Twig\Node\Node;
|
|
19 |
*
|
20 |
* @author Fabien Potencier <fabien@symfony.com>
|
21 |
*/
|
22 |
-
class Twig_Node_Spaceless extends
|
23 |
{
|
24 |
public function __construct(Twig_NodeInterface $body, $lineno, $tag = 'spaceless')
|
25 |
{
|
26 |
-
parent::__construct(
|
27 |
}
|
28 |
|
29 |
-
public function compile(
|
30 |
{
|
31 |
$compiler
|
32 |
->addDebugInfo($this)
|
@@ -36,5 +33,3 @@ class Twig_Node_Spaceless extends Node
|
|
36 |
;
|
37 |
}
|
38 |
}
|
39 |
-
|
40 |
-
class_alias('Twig_Node_Spaceless', 'Twig\Node\SpacelessNode', false);
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
|
|
12 |
/**
|
13 |
* Represents a spaceless node.
|
14 |
*
|
16 |
*
|
17 |
* @author Fabien Potencier <fabien@symfony.com>
|
18 |
*/
|
19 |
+
class Twig_Node_Spaceless extends Twig_Node
|
20 |
{
|
21 |
public function __construct(Twig_NodeInterface $body, $lineno, $tag = 'spaceless')
|
22 |
{
|
23 |
+
parent::__construct(array('body' => $body), array(), $lineno, $tag);
|
24 |
}
|
25 |
|
26 |
+
public function compile(Twig_Compiler $compiler)
|
27 |
{
|
28 |
$compiler
|
29 |
->addDebugInfo($this)
|
33 |
;
|
34 |
}
|
35 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Node/Text.php
CHANGED
@@ -10,23 +10,19 @@
|
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
|
13 |
-
use Twig\Compiler;
|
14 |
-
use Twig\Node\Node;
|
15 |
-
use Twig\Node\NodeOutputInterface;
|
16 |
-
|
17 |
/**
|
18 |
* Represents a text node.
|
19 |
*
|
20 |
* @author Fabien Potencier <fabien@symfony.com>
|
21 |
*/
|
22 |
-
class Twig_Node_Text extends
|
23 |
{
|
24 |
public function __construct($data, $lineno)
|
25 |
{
|
26 |
-
parent::__construct(
|
27 |
}
|
28 |
|
29 |
-
public function compile(
|
30 |
{
|
31 |
$compiler
|
32 |
->addDebugInfo($this)
|
@@ -36,5 +32,3 @@ class Twig_Node_Text extends Node implements NodeOutputInterface
|
|
36 |
;
|
37 |
}
|
38 |
}
|
39 |
-
|
40 |
-
class_alias('Twig_Node_Text', 'Twig\Node\TextNode', false);
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
|
|
|
|
|
|
|
|
|
13 |
/**
|
14 |
* Represents a text node.
|
15 |
*
|
16 |
* @author Fabien Potencier <fabien@symfony.com>
|
17 |
*/
|
18 |
+
class Twig_Node_Text extends Twig_Node implements Twig_NodeOutputInterface
|
19 |
{
|
20 |
public function __construct($data, $lineno)
|
21 |
{
|
22 |
+
parent::__construct(array(), array('data' => $data), $lineno);
|
23 |
}
|
24 |
|
25 |
+
public function compile(Twig_Compiler $compiler)
|
26 |
{
|
27 |
$compiler
|
28 |
->addDebugInfo($this)
|
32 |
;
|
33 |
}
|
34 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Node/With.php
CHANGED
@@ -9,27 +9,24 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Compiler;
|
13 |
-
use Twig\Node\Node;
|
14 |
-
|
15 |
/**
|
16 |
* Represents a nested "with" scope.
|
17 |
*
|
18 |
* @author Fabien Potencier <fabien@symfony.com>
|
19 |
*/
|
20 |
-
class Twig_Node_With extends
|
21 |
{
|
22 |
-
public function __construct(
|
23 |
{
|
24 |
-
$nodes =
|
25 |
if (null !== $variables) {
|
26 |
$nodes['variables'] = $variables;
|
27 |
}
|
28 |
|
29 |
-
parent::__construct($nodes,
|
30 |
}
|
31 |
|
32 |
-
public function compile(
|
33 |
{
|
34 |
$compiler->addDebugInfo($this);
|
35 |
|
@@ -41,13 +38,13 @@ class Twig_Node_With extends Node
|
|
41 |
->raw(";\n")
|
42 |
->write(sprintf("if (!is_array(\$%s)) {\n", $varsName))
|
43 |
->indent()
|
44 |
-
->write("throw new
|
45 |
->outdent()
|
46 |
->write("}\n")
|
47 |
;
|
48 |
|
49 |
if ($this->getAttribute('only')) {
|
50 |
-
$compiler->write("\$context =
|
51 |
} else {
|
52 |
$compiler->write("\$context['_parent'] = \$context;\n");
|
53 |
}
|
@@ -63,5 +60,3 @@ class Twig_Node_With extends Node
|
|
63 |
;
|
64 |
}
|
65 |
}
|
66 |
-
|
67 |
-
class_alias('Twig_Node_With', 'Twig\Node\WithNode', false);
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
|
|
12 |
/**
|
13 |
* Represents a nested "with" scope.
|
14 |
*
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
+
class Twig_Node_With extends Twig_Node
|
18 |
{
|
19 |
+
public function __construct(Twig_Node $body, Twig_Node $variables = null, $only = false, $lineno, $tag = null)
|
20 |
{
|
21 |
+
$nodes = array('body' => $body);
|
22 |
if (null !== $variables) {
|
23 |
$nodes['variables'] = $variables;
|
24 |
}
|
25 |
|
26 |
+
parent::__construct($nodes, array('only' => (bool) $only), $lineno, $tag);
|
27 |
}
|
28 |
|
29 |
+
public function compile(Twig_Compiler $compiler)
|
30 |
{
|
31 |
$compiler->addDebugInfo($this);
|
32 |
|
38 |
->raw(";\n")
|
39 |
->write(sprintf("if (!is_array(\$%s)) {\n", $varsName))
|
40 |
->indent()
|
41 |
+
->write("throw new Twig_Error_Runtime('Variables passed to the \"with\" tag must be a hash.');\n")
|
42 |
->outdent()
|
43 |
->write("}\n")
|
44 |
;
|
45 |
|
46 |
if ($this->getAttribute('only')) {
|
47 |
+
$compiler->write("\$context = array('_parent' => \$context);\n");
|
48 |
} else {
|
49 |
$compiler->write("\$context['_parent'] = \$context;\n");
|
50 |
}
|
60 |
;
|
61 |
}
|
62 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/NodeCaptureInterface.php
CHANGED
@@ -17,5 +17,3 @@
|
|
17 |
interface Twig_NodeCaptureInterface
|
18 |
{
|
19 |
}
|
20 |
-
|
21 |
-
class_alias('Twig_NodeCaptureInterface', 'Twig\Node\NodeCaptureInterface', false);
|
17 |
interface Twig_NodeCaptureInterface
|
18 |
{
|
19 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/NodeInterface.php
CHANGED
@@ -9,8 +9,6 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Compiler;
|
13 |
-
|
14 |
/**
|
15 |
* Represents a node in the AST.
|
16 |
*
|
@@ -18,12 +16,12 @@ use Twig\Compiler;
|
|
18 |
*
|
19 |
* @deprecated since 1.12 (to be removed in 3.0)
|
20 |
*/
|
21 |
-
interface Twig_NodeInterface extends
|
22 |
{
|
23 |
/**
|
24 |
* Compiles the node to PHP.
|
25 |
*/
|
26 |
-
public function compile(
|
27 |
|
28 |
/**
|
29 |
* @deprecated since 1.27 (to be removed in 2.0)
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
12 |
/**
|
13 |
* Represents a node in the AST.
|
14 |
*
|
16 |
*
|
17 |
* @deprecated since 1.12 (to be removed in 3.0)
|
18 |
*/
|
19 |
+
interface Twig_NodeInterface extends Countable, IteratorAggregate
|
20 |
{
|
21 |
/**
|
22 |
* Compiles the node to PHP.
|
23 |
*/
|
24 |
+
public function compile(Twig_Compiler $compiler);
|
25 |
|
26 |
/**
|
27 |
* @deprecated since 1.27 (to be removed in 2.0)
|
vendor/twig/twig/lib/Twig/NodeOutputInterface.php
CHANGED
@@ -17,5 +17,3 @@
|
|
17 |
interface Twig_NodeOutputInterface
|
18 |
{
|
19 |
}
|
20 |
-
|
21 |
-
class_alias('Twig_NodeOutputInterface', 'Twig\Node\NodeOutputInterface', false);
|
17 |
interface Twig_NodeOutputInterface
|
18 |
{
|
19 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/NodeTraverser.php
CHANGED
@@ -9,9 +9,6 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Environment;
|
13 |
-
use Twig\NodeVisitor\NodeVisitorInterface;
|
14 |
-
|
15 |
/**
|
16 |
* Twig_NodeTraverser is a node traverser.
|
17 |
*
|
@@ -24,12 +21,13 @@ use Twig\NodeVisitor\NodeVisitorInterface;
|
|
24 |
class Twig_NodeTraverser
|
25 |
{
|
26 |
protected $env;
|
27 |
-
protected $visitors =
|
28 |
|
29 |
/**
|
30 |
-
* @param
|
|
|
31 |
*/
|
32 |
-
public function __construct(
|
33 |
{
|
34 |
$this->env = $env;
|
35 |
foreach ($visitors as $visitor) {
|
@@ -37,10 +35,10 @@ class Twig_NodeTraverser
|
|
37 |
}
|
38 |
}
|
39 |
|
40 |
-
public function addVisitor(
|
41 |
{
|
42 |
if (!isset($this->visitors[$visitor->getPriority()])) {
|
43 |
-
$this->visitors[$visitor->getPriority()] =
|
44 |
}
|
45 |
|
46 |
$this->visitors[$visitor->getPriority()][] = $visitor;
|
@@ -63,7 +61,7 @@ class Twig_NodeTraverser
|
|
63 |
return $node;
|
64 |
}
|
65 |
|
66 |
-
protected function traverseForVisitor(
|
67 |
{
|
68 |
if (null === $node) {
|
69 |
return;
|
@@ -72,10 +70,8 @@ class Twig_NodeTraverser
|
|
72 |
$node = $visitor->enterNode($node, $this->env);
|
73 |
|
74 |
foreach ($node as $k => $n) {
|
75 |
-
if (false !== $
|
76 |
-
|
77 |
-
$node->setNode($k, $m);
|
78 |
-
}
|
79 |
} else {
|
80 |
$node->removeNode($k);
|
81 |
}
|
@@ -84,5 +80,3 @@ class Twig_NodeTraverser
|
|
84 |
return $visitor->leaveNode($node, $this->env);
|
85 |
}
|
86 |
}
|
87 |
-
|
88 |
-
class_alias('Twig_NodeTraverser', 'Twig\NodeTraverser', false);
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
|
|
12 |
/**
|
13 |
* Twig_NodeTraverser is a node traverser.
|
14 |
*
|
21 |
class Twig_NodeTraverser
|
22 |
{
|
23 |
protected $env;
|
24 |
+
protected $visitors = array();
|
25 |
|
26 |
/**
|
27 |
+
* @param Twig_Environment $env
|
28 |
+
* @param Twig_NodeVisitorInterface[] $visitors
|
29 |
*/
|
30 |
+
public function __construct(Twig_Environment $env, array $visitors = array())
|
31 |
{
|
32 |
$this->env = $env;
|
33 |
foreach ($visitors as $visitor) {
|
35 |
}
|
36 |
}
|
37 |
|
38 |
+
public function addVisitor(Twig_NodeVisitorInterface $visitor)
|
39 |
{
|
40 |
if (!isset($this->visitors[$visitor->getPriority()])) {
|
41 |
+
$this->visitors[$visitor->getPriority()] = array();
|
42 |
}
|
43 |
|
44 |
$this->visitors[$visitor->getPriority()][] = $visitor;
|
61 |
return $node;
|
62 |
}
|
63 |
|
64 |
+
protected function traverseForVisitor(Twig_NodeVisitorInterface $visitor, Twig_NodeInterface $node = null)
|
65 |
{
|
66 |
if (null === $node) {
|
67 |
return;
|
70 |
$node = $visitor->enterNode($node, $this->env);
|
71 |
|
72 |
foreach ($node as $k => $n) {
|
73 |
+
if (false !== $n = $this->traverseForVisitor($visitor, $n)) {
|
74 |
+
$node->setNode($k, $n);
|
|
|
|
|
75 |
} else {
|
76 |
$node->removeNode($k);
|
77 |
}
|
80 |
return $visitor->leaveNode($node, $this->env);
|
81 |
}
|
82 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/NodeVisitor/Escaper.php
CHANGED
@@ -9,20 +9,6 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Environment;
|
13 |
-
use Twig\Node\AutoEscapeNode;
|
14 |
-
use Twig\Node\BlockNode;
|
15 |
-
use Twig\Node\BlockReferenceNode;
|
16 |
-
use Twig\Node\Expression\ConstantExpression;
|
17 |
-
use Twig\Node\Expression\FilterExpression;
|
18 |
-
use Twig\Node\ImportNode;
|
19 |
-
use Twig\Node\ModuleNode;
|
20 |
-
use Twig\Node\Node;
|
21 |
-
use Twig\Node\PrintNode;
|
22 |
-
use Twig\NodeTraverser;
|
23 |
-
use Twig\NodeVisitor\AbstractNodeVisitor;
|
24 |
-
use Twig\NodeVisitor\SafeAnalysisNodeVisitor;
|
25 |
-
|
26 |
/**
|
27 |
* Twig_NodeVisitor_Escaper implements output escaping.
|
28 |
*
|
@@ -30,61 +16,61 @@ use Twig\NodeVisitor\SafeAnalysisNodeVisitor;
|
|
30 |
*
|
31 |
* @author Fabien Potencier <fabien@symfony.com>
|
32 |
*/
|
33 |
-
class Twig_NodeVisitor_Escaper extends
|
34 |
{
|
35 |
-
protected $statusStack =
|
36 |
-
protected $blocks =
|
37 |
protected $safeAnalysis;
|
38 |
protected $traverser;
|
39 |
protected $defaultStrategy = false;
|
40 |
-
protected $safeVars =
|
41 |
|
42 |
public function __construct()
|
43 |
{
|
44 |
-
$this->safeAnalysis = new
|
45 |
}
|
46 |
|
47 |
-
protected function doEnterNode(
|
48 |
{
|
49 |
-
if ($node instanceof
|
50 |
-
if ($env->hasExtension('
|
51 |
$this->defaultStrategy = $defaultStrategy;
|
52 |
}
|
53 |
-
$this->safeVars =
|
54 |
-
$this->blocks =
|
55 |
-
} elseif ($node instanceof
|
56 |
$this->statusStack[] = $node->getAttribute('value');
|
57 |
-
} elseif ($node instanceof
|
58 |
$this->statusStack[] = isset($this->blocks[$node->getAttribute('name')]) ? $this->blocks[$node->getAttribute('name')] : $this->needEscaping($env);
|
59 |
-
} elseif ($node instanceof
|
60 |
$this->safeVars[] = $node->getNode('var')->getAttribute('name');
|
61 |
}
|
62 |
|
63 |
return $node;
|
64 |
}
|
65 |
|
66 |
-
protected function doLeaveNode(
|
67 |
{
|
68 |
-
if ($node instanceof
|
69 |
$this->defaultStrategy = false;
|
70 |
-
$this->safeVars =
|
71 |
-
$this->blocks =
|
72 |
-
} elseif ($node instanceof
|
73 |
return $this->preEscapeFilterNode($node, $env);
|
74 |
-
} elseif ($node instanceof
|
75 |
return $this->escapePrintNode($node, $env, $this->needEscaping($env));
|
76 |
}
|
77 |
|
78 |
-
if ($node instanceof
|
79 |
array_pop($this->statusStack);
|
80 |
-
} elseif ($node instanceof
|
81 |
$this->blocks[$node->getAttribute('name')] = $this->needEscaping($env);
|
82 |
}
|
83 |
|
84 |
return $node;
|
85 |
}
|
86 |
|
87 |
-
protected function escapePrintNode(
|
88 |
{
|
89 |
if (false === $type) {
|
90 |
return $node;
|
@@ -96,7 +82,7 @@ class Twig_NodeVisitor_Escaper extends AbstractNodeVisitor
|
|
96 |
return $node;
|
97 |
}
|
98 |
|
99 |
-
$class =
|
100 |
|
101 |
return new $class(
|
102 |
$this->getEscaperFilter($type, $expression),
|
@@ -104,7 +90,7 @@ class Twig_NodeVisitor_Escaper extends AbstractNodeVisitor
|
|
104 |
);
|
105 |
}
|
106 |
|
107 |
-
protected function preEscapeFilterNode(
|
108 |
{
|
109 |
$name = $filter->getNode('filter')->getAttribute('value');
|
110 |
|
@@ -129,7 +115,7 @@ class Twig_NodeVisitor_Escaper extends AbstractNodeVisitor
|
|
129 |
|
130 |
if (null === $safe) {
|
131 |
if (null === $this->traverser) {
|
132 |
-
$this->traverser = new
|
133 |
}
|
134 |
|
135 |
$this->safeAnalysis->setSafeVars($this->safeVars);
|
@@ -138,13 +124,13 @@ class Twig_NodeVisitor_Escaper extends AbstractNodeVisitor
|
|
138 |
$safe = $this->safeAnalysis->getSafe($expression);
|
139 |
}
|
140 |
|
141 |
-
return
|
142 |
}
|
143 |
|
144 |
-
protected function needEscaping(
|
145 |
{
|
146 |
-
if (
|
147 |
-
return $this->statusStack[
|
148 |
}
|
149 |
|
150 |
return $this->defaultStrategy ? $this->defaultStrategy : false;
|
@@ -153,10 +139,10 @@ class Twig_NodeVisitor_Escaper extends AbstractNodeVisitor
|
|
153 |
protected function getEscaperFilter($type, Twig_NodeInterface $node)
|
154 |
{
|
155 |
$line = $node->getTemplateLine();
|
156 |
-
$name = new
|
157 |
-
$args = new
|
158 |
|
159 |
-
return new
|
160 |
}
|
161 |
|
162 |
public function getPriority()
|
@@ -164,5 +150,3 @@ class Twig_NodeVisitor_Escaper extends AbstractNodeVisitor
|
|
164 |
return 0;
|
165 |
}
|
166 |
}
|
167 |
-
|
168 |
-
class_alias('Twig_NodeVisitor_Escaper', 'Twig\NodeVisitor\EscaperNodeVisitor', false);
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
/**
|
13 |
* Twig_NodeVisitor_Escaper implements output escaping.
|
14 |
*
|
16 |
*
|
17 |
* @author Fabien Potencier <fabien@symfony.com>
|
18 |
*/
|
19 |
+
class Twig_NodeVisitor_Escaper extends Twig_BaseNodeVisitor
|
20 |
{
|
21 |
+
protected $statusStack = array();
|
22 |
+
protected $blocks = array();
|
23 |
protected $safeAnalysis;
|
24 |
protected $traverser;
|
25 |
protected $defaultStrategy = false;
|
26 |
+
protected $safeVars = array();
|
27 |
|
28 |
public function __construct()
|
29 |
{
|
30 |
+
$this->safeAnalysis = new Twig_NodeVisitor_SafeAnalysis();
|
31 |
}
|
32 |
|
33 |
+
protected function doEnterNode(Twig_Node $node, Twig_Environment $env)
|
34 |
{
|
35 |
+
if ($node instanceof Twig_Node_Module) {
|
36 |
+
if ($env->hasExtension('Twig_Extension_Escaper') && $defaultStrategy = $env->getExtension('Twig_Extension_Escaper')->getDefaultStrategy($node->getTemplateName())) {
|
37 |
$this->defaultStrategy = $defaultStrategy;
|
38 |
}
|
39 |
+
$this->safeVars = array();
|
40 |
+
$this->blocks = array();
|
41 |
+
} elseif ($node instanceof Twig_Node_AutoEscape) {
|
42 |
$this->statusStack[] = $node->getAttribute('value');
|
43 |
+
} elseif ($node instanceof Twig_Node_Block) {
|
44 |
$this->statusStack[] = isset($this->blocks[$node->getAttribute('name')]) ? $this->blocks[$node->getAttribute('name')] : $this->needEscaping($env);
|
45 |
+
} elseif ($node instanceof Twig_Node_Import) {
|
46 |
$this->safeVars[] = $node->getNode('var')->getAttribute('name');
|
47 |
}
|
48 |
|
49 |
return $node;
|
50 |
}
|
51 |
|
52 |
+
protected function doLeaveNode(Twig_Node $node, Twig_Environment $env)
|
53 |
{
|
54 |
+
if ($node instanceof Twig_Node_Module) {
|
55 |
$this->defaultStrategy = false;
|
56 |
+
$this->safeVars = array();
|
57 |
+
$this->blocks = array();
|
58 |
+
} elseif ($node instanceof Twig_Node_Expression_Filter) {
|
59 |
return $this->preEscapeFilterNode($node, $env);
|
60 |
+
} elseif ($node instanceof Twig_Node_Print) {
|
61 |
return $this->escapePrintNode($node, $env, $this->needEscaping($env));
|
62 |
}
|
63 |
|
64 |
+
if ($node instanceof Twig_Node_AutoEscape || $node instanceof Twig_Node_Block) {
|
65 |
array_pop($this->statusStack);
|
66 |
+
} elseif ($node instanceof Twig_Node_BlockReference) {
|
67 |
$this->blocks[$node->getAttribute('name')] = $this->needEscaping($env);
|
68 |
}
|
69 |
|
70 |
return $node;
|
71 |
}
|
72 |
|
73 |
+
protected function escapePrintNode(Twig_Node_Print $node, Twig_Environment $env, $type)
|
74 |
{
|
75 |
if (false === $type) {
|
76 |
return $node;
|
82 |
return $node;
|
83 |
}
|
84 |
|
85 |
+
$class = get_class($node);
|
86 |
|
87 |
return new $class(
|
88 |
$this->getEscaperFilter($type, $expression),
|
90 |
);
|
91 |
}
|
92 |
|
93 |
+
protected function preEscapeFilterNode(Twig_Node_Expression_Filter $filter, Twig_Environment $env)
|
94 |
{
|
95 |
$name = $filter->getNode('filter')->getAttribute('value');
|
96 |
|
115 |
|
116 |
if (null === $safe) {
|
117 |
if (null === $this->traverser) {
|
118 |
+
$this->traverser = new Twig_NodeTraverser($env, array($this->safeAnalysis));
|
119 |
}
|
120 |
|
121 |
$this->safeAnalysis->setSafeVars($this->safeVars);
|
124 |
$safe = $this->safeAnalysis->getSafe($expression);
|
125 |
}
|
126 |
|
127 |
+
return in_array($type, $safe) || in_array('all', $safe);
|
128 |
}
|
129 |
|
130 |
+
protected function needEscaping(Twig_Environment $env)
|
131 |
{
|
132 |
+
if (count($this->statusStack)) {
|
133 |
+
return $this->statusStack[count($this->statusStack) - 1];
|
134 |
}
|
135 |
|
136 |
return $this->defaultStrategy ? $this->defaultStrategy : false;
|
139 |
protected function getEscaperFilter($type, Twig_NodeInterface $node)
|
140 |
{
|
141 |
$line = $node->getTemplateLine();
|
142 |
+
$name = new Twig_Node_Expression_Constant('escape', $line);
|
143 |
+
$args = new Twig_Node(array(new Twig_Node_Expression_Constant((string) $type, $line), new Twig_Node_Expression_Constant(null, $line), new Twig_Node_Expression_Constant(true, $line)));
|
144 |
|
145 |
+
return new Twig_Node_Expression_Filter($node, $name, $args, $line);
|
146 |
}
|
147 |
|
148 |
public function getPriority()
|
150 |
return 0;
|
151 |
}
|
152 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/NodeVisitor/Optimizer.php
CHANGED
@@ -9,25 +9,6 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Environment;
|
13 |
-
use Twig\Node\BlockReferenceNode;
|
14 |
-
use Twig\Node\BodyNode;
|
15 |
-
use Twig\Node\Expression\AbstractExpression;
|
16 |
-
use Twig\Node\Expression\BlockReferenceExpression;
|
17 |
-
use Twig\Node\Expression\ConstantExpression;
|
18 |
-
use Twig\Node\Expression\FilterExpression;
|
19 |
-
use Twig\Node\Expression\FunctionExpression;
|
20 |
-
use Twig\Node\Expression\GetAttrExpression;
|
21 |
-
use Twig\Node\Expression\NameExpression;
|
22 |
-
use Twig\Node\Expression\ParentExpression;
|
23 |
-
use Twig\Node\Expression\TempNameExpression;
|
24 |
-
use Twig\Node\ForNode;
|
25 |
-
use Twig\Node\IncludeNode;
|
26 |
-
use Twig\Node\Node;
|
27 |
-
use Twig\Node\PrintNode;
|
28 |
-
use Twig\Node\SetTempNode;
|
29 |
-
use Twig\NodeVisitor\AbstractNodeVisitor;
|
30 |
-
|
31 |
/**
|
32 |
* Twig_NodeVisitor_Optimizer tries to optimizes the AST.
|
33 |
*
|
@@ -40,7 +21,7 @@ use Twig\NodeVisitor\AbstractNodeVisitor;
|
|
40 |
*
|
41 |
* @author Fabien Potencier <fabien@symfony.com>
|
42 |
*/
|
43 |
-
class Twig_NodeVisitor_Optimizer extends
|
44 |
{
|
45 |
const OPTIMIZE_ALL = -1;
|
46 |
const OPTIMIZE_NONE = 0;
|
@@ -48,10 +29,10 @@ class Twig_NodeVisitor_Optimizer extends AbstractNodeVisitor
|
|
48 |
const OPTIMIZE_RAW_FILTER = 4;
|
49 |
const OPTIMIZE_VAR_ACCESS = 8;
|
50 |
|
51 |
-
protected $loops =
|
52 |
-
protected $loopsTargets =
|
53 |
protected $optimizers;
|
54 |
-
protected $prependedNodes =
|
55 |
protected $inABody = false;
|
56 |
|
57 |
/**
|
@@ -59,29 +40,29 @@ class Twig_NodeVisitor_Optimizer extends AbstractNodeVisitor
|
|
59 |
*/
|
60 |
public function __construct($optimizers = -1)
|
61 |
{
|
62 |
-
if (
|
63 |
-
throw new
|
64 |
}
|
65 |
|
66 |
$this->optimizers = $optimizers;
|
67 |
}
|
68 |
|
69 |
-
protected function doEnterNode(
|
70 |
{
|
71 |
if (self::OPTIMIZE_FOR === (self::OPTIMIZE_FOR & $this->optimizers)) {
|
72 |
$this->enterOptimizeFor($node, $env);
|
73 |
}
|
74 |
|
75 |
-
if (PHP_VERSION_ID < 50400 && self::OPTIMIZE_VAR_ACCESS === (self::OPTIMIZE_VAR_ACCESS & $this->optimizers) && !$env->isStrictVariables() && !$env->hasExtension('
|
76 |
if ($this->inABody) {
|
77 |
-
if (!$node instanceof
|
78 |
-
if (
|
79 |
-
array_unshift($this->prependedNodes,
|
80 |
}
|
81 |
} else {
|
82 |
$node = $this->optimizeVariables($node, $env);
|
83 |
}
|
84 |
-
} elseif ($node instanceof
|
85 |
$this->inABody = true;
|
86 |
}
|
87 |
}
|
@@ -89,9 +70,9 @@ class Twig_NodeVisitor_Optimizer extends AbstractNodeVisitor
|
|
89 |
return $node;
|
90 |
}
|
91 |
|
92 |
-
protected function doLeaveNode(
|
93 |
{
|
94 |
-
$expression = $node instanceof
|
95 |
|
96 |
if (self::OPTIMIZE_FOR === (self::OPTIMIZE_FOR & $this->optimizers)) {
|
97 |
$this->leaveOptimizeFor($node, $env);
|
@@ -103,18 +84,18 @@ class Twig_NodeVisitor_Optimizer extends AbstractNodeVisitor
|
|
103 |
|
104 |
$node = $this->optimizePrintNode($node, $env);
|
105 |
|
106 |
-
if (self::OPTIMIZE_VAR_ACCESS === (self::OPTIMIZE_VAR_ACCESS & $this->optimizers) && !$env->isStrictVariables() && !$env->hasExtension('
|
107 |
-
if ($node instanceof
|
108 |
$this->inABody = false;
|
109 |
} elseif ($this->inABody) {
|
110 |
-
if (!$expression &&
|
111 |
-
$nodes =
|
112 |
foreach (array_unique($prependedNodes) as $name) {
|
113 |
-
$nodes[] = new
|
114 |
}
|
115 |
|
116 |
$nodes[] = $node;
|
117 |
-
$node = new
|
118 |
}
|
119 |
}
|
120 |
}
|
@@ -122,12 +103,12 @@ class Twig_NodeVisitor_Optimizer extends AbstractNodeVisitor
|
|
122 |
return $node;
|
123 |
}
|
124 |
|
125 |
-
protected function optimizeVariables(Twig_NodeInterface $node,
|
126 |
{
|
127 |
-
if ('Twig_Node_Expression_Name' ===
|
128 |
$this->prependedNodes[0][] = $node->getAttribute('name');
|
129 |
|
130 |
-
return new
|
131 |
}
|
132 |
|
133 |
return $node;
|
@@ -142,16 +123,16 @@ class Twig_NodeVisitor_Optimizer extends AbstractNodeVisitor
|
|
142 |
*
|
143 |
* @return Twig_NodeInterface
|
144 |
*/
|
145 |
-
protected function optimizePrintNode(Twig_NodeInterface $node,
|
146 |
{
|
147 |
-
if (!$node instanceof
|
148 |
return $node;
|
149 |
}
|
150 |
|
151 |
$exprNode = $node->getNode('expr');
|
152 |
if (
|
153 |
-
$exprNode instanceof
|
154 |
-
$exprNode instanceof
|
155 |
) {
|
156 |
$exprNode->setAttribute('output', true);
|
157 |
|
@@ -166,9 +147,9 @@ class Twig_NodeVisitor_Optimizer extends AbstractNodeVisitor
|
|
166 |
*
|
167 |
* @return Twig_NodeInterface
|
168 |
*/
|
169 |
-
protected function optimizeRawFilter(Twig_NodeInterface $node,
|
170 |
{
|
171 |
-
if ($node instanceof
|
172 |
return $node->getNode('node');
|
173 |
}
|
174 |
|
@@ -178,9 +159,9 @@ class Twig_NodeVisitor_Optimizer extends AbstractNodeVisitor
|
|
178 |
/**
|
179 |
* Optimizes "for" tag by removing the "loop" variable creation whenever possible.
|
180 |
*/
|
181 |
-
protected function enterOptimizeFor(Twig_NodeInterface $node,
|
182 |
{
|
183 |
-
if ($node instanceof
|
184 |
// disable the loop variable by default
|
185 |
$node->setAttribute('with_loop', false);
|
186 |
array_unshift($this->loops, $node);
|
@@ -194,28 +175,28 @@ class Twig_NodeVisitor_Optimizer extends AbstractNodeVisitor
|
|
194 |
// when do we need to add the loop variable back?
|
195 |
|
196 |
// the loop variable is referenced for the current loop
|
197 |
-
elseif ($node instanceof
|
198 |
$node->setAttribute('always_defined', true);
|
199 |
$this->addLoopToCurrent();
|
200 |
}
|
201 |
|
202 |
// optimize access to loop targets
|
203 |
-
elseif ($node instanceof
|
204 |
$node->setAttribute('always_defined', true);
|
205 |
}
|
206 |
|
207 |
// block reference
|
208 |
-
elseif ($node instanceof
|
209 |
$this->addLoopToCurrent();
|
210 |
}
|
211 |
|
212 |
// include without the only attribute
|
213 |
-
elseif ($node instanceof
|
214 |
$this->addLoopToAll();
|
215 |
}
|
216 |
|
217 |
// include function without the with_context=false parameter
|
218 |
-
elseif ($node instanceof
|
219 |
&& 'include' === $node->getAttribute('name')
|
220 |
&& (!$node->getNode('arguments')->hasNode('with_context')
|
221 |
|| false !== $node->getNode('arguments')->getNode('with_context')->getAttribute('value')
|
@@ -225,12 +206,12 @@ class Twig_NodeVisitor_Optimizer extends AbstractNodeVisitor
|
|
225 |
}
|
226 |
|
227 |
// the loop variable is referenced via an attribute
|
228 |
-
elseif ($node instanceof
|
229 |
-
&& (!$node->getNode('attribute') instanceof
|
230 |
|| 'parent' === $node->getNode('attribute')->getAttribute('value')
|
231 |
)
|
232 |
&& (true === $this->loops[0]->getAttribute('with_loop')
|
233 |
-
|| ($node->getNode('node') instanceof
|
234 |
&& 'loop' === $node->getNode('node')->getAttribute('name')
|
235 |
)
|
236 |
)
|
@@ -242,9 +223,9 @@ class Twig_NodeVisitor_Optimizer extends AbstractNodeVisitor
|
|
242 |
/**
|
243 |
* Optimizes "for" tag by removing the "loop" variable creation whenever possible.
|
244 |
*/
|
245 |
-
protected function leaveOptimizeFor(Twig_NodeInterface $node,
|
246 |
{
|
247 |
-
if ($node instanceof
|
248 |
array_shift($this->loops);
|
249 |
array_shift($this->loopsTargets);
|
250 |
array_shift($this->loopsTargets);
|
@@ -268,5 +249,3 @@ class Twig_NodeVisitor_Optimizer extends AbstractNodeVisitor
|
|
268 |
return 255;
|
269 |
}
|
270 |
}
|
271 |
-
|
272 |
-
class_alias('Twig_NodeVisitor_Optimizer', 'Twig\NodeVisitor\OptimizerNodeVisitor', false);
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
/**
|
13 |
* Twig_NodeVisitor_Optimizer tries to optimizes the AST.
|
14 |
*
|
21 |
*
|
22 |
* @author Fabien Potencier <fabien@symfony.com>
|
23 |
*/
|
24 |
+
class Twig_NodeVisitor_Optimizer extends Twig_BaseNodeVisitor
|
25 |
{
|
26 |
const OPTIMIZE_ALL = -1;
|
27 |
const OPTIMIZE_NONE = 0;
|
29 |
const OPTIMIZE_RAW_FILTER = 4;
|
30 |
const OPTIMIZE_VAR_ACCESS = 8;
|
31 |
|
32 |
+
protected $loops = array();
|
33 |
+
protected $loopsTargets = array();
|
34 |
protected $optimizers;
|
35 |
+
protected $prependedNodes = array();
|
36 |
protected $inABody = false;
|
37 |
|
38 |
/**
|
40 |
*/
|
41 |
public function __construct($optimizers = -1)
|
42 |
{
|
43 |
+
if (!is_int($optimizers) || $optimizers > (self::OPTIMIZE_FOR | self::OPTIMIZE_RAW_FILTER | self::OPTIMIZE_VAR_ACCESS)) {
|
44 |
+
throw new InvalidArgumentException(sprintf('Optimizer mode "%s" is not valid.', $optimizers));
|
45 |
}
|
46 |
|
47 |
$this->optimizers = $optimizers;
|
48 |
}
|
49 |
|
50 |
+
protected function doEnterNode(Twig_Node $node, Twig_Environment $env)
|
51 |
{
|
52 |
if (self::OPTIMIZE_FOR === (self::OPTIMIZE_FOR & $this->optimizers)) {
|
53 |
$this->enterOptimizeFor($node, $env);
|
54 |
}
|
55 |
|
56 |
+
if (PHP_VERSION_ID < 50400 && self::OPTIMIZE_VAR_ACCESS === (self::OPTIMIZE_VAR_ACCESS & $this->optimizers) && !$env->isStrictVariables() && !$env->hasExtension('Twig_Extension_Sandbox')) {
|
57 |
if ($this->inABody) {
|
58 |
+
if (!$node instanceof Twig_Node_Expression) {
|
59 |
+
if (get_class($node) !== 'Twig_Node') {
|
60 |
+
array_unshift($this->prependedNodes, array());
|
61 |
}
|
62 |
} else {
|
63 |
$node = $this->optimizeVariables($node, $env);
|
64 |
}
|
65 |
+
} elseif ($node instanceof Twig_Node_Body) {
|
66 |
$this->inABody = true;
|
67 |
}
|
68 |
}
|
70 |
return $node;
|
71 |
}
|
72 |
|
73 |
+
protected function doLeaveNode(Twig_Node $node, Twig_Environment $env)
|
74 |
{
|
75 |
+
$expression = $node instanceof Twig_Node_Expression;
|
76 |
|
77 |
if (self::OPTIMIZE_FOR === (self::OPTIMIZE_FOR & $this->optimizers)) {
|
78 |
$this->leaveOptimizeFor($node, $env);
|
84 |
|
85 |
$node = $this->optimizePrintNode($node, $env);
|
86 |
|
87 |
+
if (self::OPTIMIZE_VAR_ACCESS === (self::OPTIMIZE_VAR_ACCESS & $this->optimizers) && !$env->isStrictVariables() && !$env->hasExtension('Twig_Extension_Sandbox')) {
|
88 |
+
if ($node instanceof Twig_Node_Body) {
|
89 |
$this->inABody = false;
|
90 |
} elseif ($this->inABody) {
|
91 |
+
if (!$expression && get_class($node) !== 'Twig_Node' && $prependedNodes = array_shift($this->prependedNodes)) {
|
92 |
+
$nodes = array();
|
93 |
foreach (array_unique($prependedNodes) as $name) {
|
94 |
+
$nodes[] = new Twig_Node_SetTemp($name, $node->getTemplateLine());
|
95 |
}
|
96 |
|
97 |
$nodes[] = $node;
|
98 |
+
$node = new Twig_Node($nodes);
|
99 |
}
|
100 |
}
|
101 |
}
|
103 |
return $node;
|
104 |
}
|
105 |
|
106 |
+
protected function optimizeVariables(Twig_NodeInterface $node, Twig_Environment $env)
|
107 |
{
|
108 |
+
if ('Twig_Node_Expression_Name' === get_class($node) && $node->isSimple()) {
|
109 |
$this->prependedNodes[0][] = $node->getAttribute('name');
|
110 |
|
111 |
+
return new Twig_Node_Expression_TempName($node->getAttribute('name'), $node->getTemplateLine());
|
112 |
}
|
113 |
|
114 |
return $node;
|
123 |
*
|
124 |
* @return Twig_NodeInterface
|
125 |
*/
|
126 |
+
protected function optimizePrintNode(Twig_NodeInterface $node, Twig_Environment $env)
|
127 |
{
|
128 |
+
if (!$node instanceof Twig_Node_Print) {
|
129 |
return $node;
|
130 |
}
|
131 |
|
132 |
$exprNode = $node->getNode('expr');
|
133 |
if (
|
134 |
+
$exprNode instanceof Twig_Node_Expression_BlockReference ||
|
135 |
+
$exprNode instanceof Twig_Node_Expression_Parent
|
136 |
) {
|
137 |
$exprNode->setAttribute('output', true);
|
138 |
|
147 |
*
|
148 |
* @return Twig_NodeInterface
|
149 |
*/
|
150 |
+
protected function optimizeRawFilter(Twig_NodeInterface $node, Twig_Environment $env)
|
151 |
{
|
152 |
+
if ($node instanceof Twig_Node_Expression_Filter && 'raw' == $node->getNode('filter')->getAttribute('value')) {
|
153 |
return $node->getNode('node');
|
154 |
}
|
155 |
|
159 |
/**
|
160 |
* Optimizes "for" tag by removing the "loop" variable creation whenever possible.
|
161 |
*/
|
162 |
+
protected function enterOptimizeFor(Twig_NodeInterface $node, Twig_Environment $env)
|
163 |
{
|
164 |
+
if ($node instanceof Twig_Node_For) {
|
165 |
// disable the loop variable by default
|
166 |
$node->setAttribute('with_loop', false);
|
167 |
array_unshift($this->loops, $node);
|
175 |
// when do we need to add the loop variable back?
|
176 |
|
177 |
// the loop variable is referenced for the current loop
|
178 |
+
elseif ($node instanceof Twig_Node_Expression_Name && 'loop' === $node->getAttribute('name')) {
|
179 |
$node->setAttribute('always_defined', true);
|
180 |
$this->addLoopToCurrent();
|
181 |
}
|
182 |
|
183 |
// optimize access to loop targets
|
184 |
+
elseif ($node instanceof Twig_Node_Expression_Name && in_array($node->getAttribute('name'), $this->loopsTargets)) {
|
185 |
$node->setAttribute('always_defined', true);
|
186 |
}
|
187 |
|
188 |
// block reference
|
189 |
+
elseif ($node instanceof Twig_Node_BlockReference || $node instanceof Twig_Node_Expression_BlockReference) {
|
190 |
$this->addLoopToCurrent();
|
191 |
}
|
192 |
|
193 |
// include without the only attribute
|
194 |
+
elseif ($node instanceof Twig_Node_Include && !$node->getAttribute('only')) {
|
195 |
$this->addLoopToAll();
|
196 |
}
|
197 |
|
198 |
// include function without the with_context=false parameter
|
199 |
+
elseif ($node instanceof Twig_Node_Expression_Function
|
200 |
&& 'include' === $node->getAttribute('name')
|
201 |
&& (!$node->getNode('arguments')->hasNode('with_context')
|
202 |
|| false !== $node->getNode('arguments')->getNode('with_context')->getAttribute('value')
|
206 |
}
|
207 |
|
208 |
// the loop variable is referenced via an attribute
|
209 |
+
elseif ($node instanceof Twig_Node_Expression_GetAttr
|
210 |
+
&& (!$node->getNode('attribute') instanceof Twig_Node_Expression_Constant
|
211 |
|| 'parent' === $node->getNode('attribute')->getAttribute('value')
|
212 |
)
|
213 |
&& (true === $this->loops[0]->getAttribute('with_loop')
|
214 |
+
|| ($node->getNode('node') instanceof Twig_Node_Expression_Name
|
215 |
&& 'loop' === $node->getNode('node')->getAttribute('name')
|
216 |
)
|
217 |
)
|
223 |
/**
|
224 |
* Optimizes "for" tag by removing the "loop" variable creation whenever possible.
|
225 |
*/
|
226 |
+
protected function leaveOptimizeFor(Twig_NodeInterface $node, Twig_Environment $env)
|
227 |
{
|
228 |
+
if ($node instanceof Twig_Node_For) {
|
229 |
array_shift($this->loops);
|
230 |
array_shift($this->loopsTargets);
|
231 |
array_shift($this->loopsTargets);
|
249 |
return 255;
|
250 |
}
|
251 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/NodeVisitor/SafeAnalysis.php
CHANGED
@@ -9,26 +9,13 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Environment;
|
13 |
-
use Twig\Node\Expression\BlockReferenceExpression;
|
14 |
-
use Twig\Node\Expression\ConditionalExpression;
|
15 |
-
use Twig\Node\Expression\ConstantExpression;
|
16 |
-
use Twig\Node\Expression\FilterExpression;
|
17 |
-
use Twig\Node\Expression\FunctionExpression;
|
18 |
-
use Twig\Node\Expression\GetAttrExpression;
|
19 |
-
use Twig\Node\Expression\MethodCallExpression;
|
20 |
-
use Twig\Node\Expression\NameExpression;
|
21 |
-
use Twig\Node\Expression\ParentExpression;
|
22 |
-
use Twig\Node\Node;
|
23 |
-
use Twig\NodeVisitor\AbstractNodeVisitor;
|
24 |
-
|
25 |
/**
|
26 |
* @final
|
27 |
*/
|
28 |
-
class Twig_NodeVisitor_SafeAnalysis extends
|
29 |
{
|
30 |
-
protected $data =
|
31 |
-
protected $safeVars =
|
32 |
|
33 |
public function setSafeVars($safeVars)
|
34 |
{
|
@@ -47,7 +34,7 @@ class Twig_NodeVisitor_SafeAnalysis extends AbstractNodeVisitor
|
|
47 |
continue;
|
48 |
}
|
49 |
|
50 |
-
if (
|
51 |
$bucket['value'][] = 'html';
|
52 |
}
|
53 |
|
@@ -67,33 +54,33 @@ class Twig_NodeVisitor_SafeAnalysis extends AbstractNodeVisitor
|
|
67 |
}
|
68 |
}
|
69 |
}
|
70 |
-
$this->data[$hash][] =
|
71 |
'key' => $node,
|
72 |
'value' => $safe,
|
73 |
-
|
74 |
}
|
75 |
|
76 |
-
protected function doEnterNode(
|
77 |
{
|
78 |
return $node;
|
79 |
}
|
80 |
|
81 |
-
protected function doLeaveNode(
|
82 |
{
|
83 |
-
if ($node instanceof
|
84 |
// constants are marked safe for all
|
85 |
-
$this->setSafe($node,
|
86 |
-
} elseif ($node instanceof
|
87 |
// blocks are safe by definition
|
88 |
-
$this->setSafe($node,
|
89 |
-
} elseif ($node instanceof
|
90 |
// parent block is safe by definition
|
91 |
-
$this->setSafe($node,
|
92 |
-
} elseif ($node instanceof
|
93 |
// intersect safeness of both operands
|
94 |
$safe = $this->intersectSafe($this->getSafe($node->getNode('expr2')), $this->getSafe($node->getNode('expr3')));
|
95 |
$this->setSafe($node, $safe);
|
96 |
-
} elseif ($node instanceof
|
97 |
// filter expression is safe when the filter is safe
|
98 |
$name = $node->getNode('filter')->getAttribute('value');
|
99 |
$args = $node->getNode('arguments');
|
@@ -104,9 +91,9 @@ class Twig_NodeVisitor_SafeAnalysis extends AbstractNodeVisitor
|
|
104 |
}
|
105 |
$this->setSafe($node, $safe);
|
106 |
} else {
|
107 |
-
$this->setSafe($node,
|
108 |
}
|
109 |
-
} elseif ($node instanceof
|
110 |
// function expression is safe when the function is safe
|
111 |
$name = $node->getAttribute('name');
|
112 |
$args = $node->getNode('arguments');
|
@@ -114,24 +101,24 @@ class Twig_NodeVisitor_SafeAnalysis extends AbstractNodeVisitor
|
|
114 |
if (false !== $function) {
|
115 |
$this->setSafe($node, $function->getSafe($args));
|
116 |
} else {
|
117 |
-
$this->setSafe($node,
|
118 |
}
|
119 |
-
} elseif ($node instanceof
|
120 |
if ($node->getAttribute('safe')) {
|
121 |
-
$this->setSafe($node,
|
122 |
} else {
|
123 |
-
$this->setSafe($node,
|
124 |
}
|
125 |
-
} elseif ($node instanceof
|
126 |
$name = $node->getNode('node')->getAttribute('name');
|
127 |
// attributes on template instances are safe
|
128 |
-
if ('_self' == $name ||
|
129 |
-
$this->setSafe($node,
|
130 |
} else {
|
131 |
-
$this->setSafe($node,
|
132 |
}
|
133 |
} else {
|
134 |
-
$this->setSafe($node,
|
135 |
}
|
136 |
|
137 |
return $node;
|
@@ -140,14 +127,14 @@ class Twig_NodeVisitor_SafeAnalysis extends AbstractNodeVisitor
|
|
140 |
protected function intersectSafe(array $a = null, array $b = null)
|
141 |
{
|
142 |
if (null === $a || null === $b) {
|
143 |
-
return
|
144 |
}
|
145 |
|
146 |
-
if (
|
147 |
return $b;
|
148 |
}
|
149 |
|
150 |
-
if (
|
151 |
return $a;
|
152 |
}
|
153 |
|
@@ -159,5 +146,3 @@ class Twig_NodeVisitor_SafeAnalysis extends AbstractNodeVisitor
|
|
159 |
return 0;
|
160 |
}
|
161 |
}
|
162 |
-
|
163 |
-
class_alias('Twig_NodeVisitor_SafeAnalysis', 'Twig\NodeVisitor\SafeAnalysisNodeVisitor', false);
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
/**
|
13 |
* @final
|
14 |
*/
|
15 |
+
class Twig_NodeVisitor_SafeAnalysis extends Twig_BaseNodeVisitor
|
16 |
{
|
17 |
+
protected $data = array();
|
18 |
+
protected $safeVars = array();
|
19 |
|
20 |
public function setSafeVars($safeVars)
|
21 |
{
|
34 |
continue;
|
35 |
}
|
36 |
|
37 |
+
if (in_array('html_attr', $bucket['value'])) {
|
38 |
$bucket['value'][] = 'html';
|
39 |
}
|
40 |
|
54 |
}
|
55 |
}
|
56 |
}
|
57 |
+
$this->data[$hash][] = array(
|
58 |
'key' => $node,
|
59 |
'value' => $safe,
|
60 |
+
);
|
61 |
}
|
62 |
|
63 |
+
protected function doEnterNode(Twig_Node $node, Twig_Environment $env)
|
64 |
{
|
65 |
return $node;
|
66 |
}
|
67 |
|
68 |
+
protected function doLeaveNode(Twig_Node $node, Twig_Environment $env)
|
69 |
{
|
70 |
+
if ($node instanceof Twig_Node_Expression_Constant) {
|
71 |
// constants are marked safe for all
|
72 |
+
$this->setSafe($node, array('all'));
|
73 |
+
} elseif ($node instanceof Twig_Node_Expression_BlockReference) {
|
74 |
// blocks are safe by definition
|
75 |
+
$this->setSafe($node, array('all'));
|
76 |
+
} elseif ($node instanceof Twig_Node_Expression_Parent) {
|
77 |
// parent block is safe by definition
|
78 |
+
$this->setSafe($node, array('all'));
|
79 |
+
} elseif ($node instanceof Twig_Node_Expression_Conditional) {
|
80 |
// intersect safeness of both operands
|
81 |
$safe = $this->intersectSafe($this->getSafe($node->getNode('expr2')), $this->getSafe($node->getNode('expr3')));
|
82 |
$this->setSafe($node, $safe);
|
83 |
+
} elseif ($node instanceof Twig_Node_Expression_Filter) {
|
84 |
// filter expression is safe when the filter is safe
|
85 |
$name = $node->getNode('filter')->getAttribute('value');
|
86 |
$args = $node->getNode('arguments');
|
91 |
}
|
92 |
$this->setSafe($node, $safe);
|
93 |
} else {
|
94 |
+
$this->setSafe($node, array());
|
95 |
}
|
96 |
+
} elseif ($node instanceof Twig_Node_Expression_Function) {
|
97 |
// function expression is safe when the function is safe
|
98 |
$name = $node->getAttribute('name');
|
99 |
$args = $node->getNode('arguments');
|
101 |
if (false !== $function) {
|
102 |
$this->setSafe($node, $function->getSafe($args));
|
103 |
} else {
|
104 |
+
$this->setSafe($node, array());
|
105 |
}
|
106 |
+
} elseif ($node instanceof Twig_Node_Expression_MethodCall) {
|
107 |
if ($node->getAttribute('safe')) {
|
108 |
+
$this->setSafe($node, array('all'));
|
109 |
} else {
|
110 |
+
$this->setSafe($node, array());
|
111 |
}
|
112 |
+
} elseif ($node instanceof Twig_Node_Expression_GetAttr && $node->getNode('node') instanceof Twig_Node_Expression_Name) {
|
113 |
$name = $node->getNode('node')->getAttribute('name');
|
114 |
// attributes on template instances are safe
|
115 |
+
if ('_self' == $name || in_array($name, $this->safeVars)) {
|
116 |
+
$this->setSafe($node, array('all'));
|
117 |
} else {
|
118 |
+
$this->setSafe($node, array());
|
119 |
}
|
120 |
} else {
|
121 |
+
$this->setSafe($node, array());
|
122 |
}
|
123 |
|
124 |
return $node;
|
127 |
protected function intersectSafe(array $a = null, array $b = null)
|
128 |
{
|
129 |
if (null === $a || null === $b) {
|
130 |
+
return array();
|
131 |
}
|
132 |
|
133 |
+
if (in_array('all', $a)) {
|
134 |
return $b;
|
135 |
}
|
136 |
|
137 |
+
if (in_array('all', $b)) {
|
138 |
return $a;
|
139 |
}
|
140 |
|
146 |
return 0;
|
147 |
}
|
148 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/NodeVisitor/Sandbox.php
CHANGED
@@ -9,17 +9,6 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Environment;
|
13 |
-
use Twig\Node\CheckSecurityNode;
|
14 |
-
use Twig\Node\Expression\Binary\RangeBinary;
|
15 |
-
use Twig\Node\Expression\FilterExpression;
|
16 |
-
use Twig\Node\Expression\FunctionExpression;
|
17 |
-
use Twig\Node\ModuleNode;
|
18 |
-
use Twig\Node\Node;
|
19 |
-
use Twig\Node\PrintNode;
|
20 |
-
use Twig\Node\SandboxedPrintNode;
|
21 |
-
use Twig\NodeVisitor\AbstractNodeVisitor;
|
22 |
-
|
23 |
/**
|
24 |
* Twig_NodeVisitor_Sandbox implements sandboxing.
|
25 |
*
|
@@ -27,20 +16,20 @@ use Twig\NodeVisitor\AbstractNodeVisitor;
|
|
27 |
*
|
28 |
* @author Fabien Potencier <fabien@symfony.com>
|
29 |
*/
|
30 |
-
class Twig_NodeVisitor_Sandbox extends
|
31 |
{
|
32 |
protected $inAModule = false;
|
33 |
protected $tags;
|
34 |
protected $filters;
|
35 |
protected $functions;
|
36 |
|
37 |
-
protected function doEnterNode(
|
38 |
{
|
39 |
-
if ($node instanceof
|
40 |
$this->inAModule = true;
|
41 |
-
$this->tags =
|
42 |
-
$this->filters =
|
43 |
-
$this->functions =
|
44 |
|
45 |
return $node;
|
46 |
} elseif ($this->inAModule) {
|
@@ -50,35 +39,30 @@ class Twig_NodeVisitor_Sandbox extends AbstractNodeVisitor
|
|
50 |
}
|
51 |
|
52 |
// look for filters
|
53 |
-
if ($node instanceof
|
54 |
$this->filters[$node->getNode('filter')->getAttribute('value')] = $node;
|
55 |
}
|
56 |
|
57 |
// look for functions
|
58 |
-
if ($node instanceof
|
59 |
$this->functions[$node->getAttribute('name')] = $node;
|
60 |
}
|
61 |
|
62 |
-
// the .. operator is equivalent to the range() function
|
63 |
-
if ($node instanceof RangeBinary && !isset($this->functions['range'])) {
|
64 |
-
$this->functions['range'] = $node;
|
65 |
-
}
|
66 |
-
|
67 |
// wrap print to check __toString() calls
|
68 |
-
if ($node instanceof
|
69 |
-
return new
|
70 |
}
|
71 |
}
|
72 |
|
73 |
return $node;
|
74 |
}
|
75 |
|
76 |
-
protected function doLeaveNode(
|
77 |
{
|
78 |
-
if ($node instanceof
|
79 |
$this->inAModule = false;
|
80 |
|
81 |
-
$node->setNode('display_start', new
|
82 |
}
|
83 |
|
84 |
return $node;
|
@@ -89,5 +73,3 @@ class Twig_NodeVisitor_Sandbox extends AbstractNodeVisitor
|
|
89 |
return 0;
|
90 |
}
|
91 |
}
|
92 |
-
|
93 |
-
class_alias('Twig_NodeVisitor_Sandbox', 'Twig\NodeVisitor\SandboxNodeVisitor', false);
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
/**
|
13 |
* Twig_NodeVisitor_Sandbox implements sandboxing.
|
14 |
*
|
16 |
*
|
17 |
* @author Fabien Potencier <fabien@symfony.com>
|
18 |
*/
|
19 |
+
class Twig_NodeVisitor_Sandbox extends Twig_BaseNodeVisitor
|
20 |
{
|
21 |
protected $inAModule = false;
|
22 |
protected $tags;
|
23 |
protected $filters;
|
24 |
protected $functions;
|
25 |
|
26 |
+
protected function doEnterNode(Twig_Node $node, Twig_Environment $env)
|
27 |
{
|
28 |
+
if ($node instanceof Twig_Node_Module) {
|
29 |
$this->inAModule = true;
|
30 |
+
$this->tags = array();
|
31 |
+
$this->filters = array();
|
32 |
+
$this->functions = array();
|
33 |
|
34 |
return $node;
|
35 |
} elseif ($this->inAModule) {
|
39 |
}
|
40 |
|
41 |
// look for filters
|
42 |
+
if ($node instanceof Twig_Node_Expression_Filter && !isset($this->filters[$node->getNode('filter')->getAttribute('value')])) {
|
43 |
$this->filters[$node->getNode('filter')->getAttribute('value')] = $node;
|
44 |
}
|
45 |
|
46 |
// look for functions
|
47 |
+
if ($node instanceof Twig_Node_Expression_Function && !isset($this->functions[$node->getAttribute('name')])) {
|
48 |
$this->functions[$node->getAttribute('name')] = $node;
|
49 |
}
|
50 |
|
|
|
|
|
|
|
|
|
|
|
51 |
// wrap print to check __toString() calls
|
52 |
+
if ($node instanceof Twig_Node_Print) {
|
53 |
+
return new Twig_Node_SandboxedPrint($node->getNode('expr'), $node->getTemplateLine(), $node->getNodeTag());
|
54 |
}
|
55 |
}
|
56 |
|
57 |
return $node;
|
58 |
}
|
59 |
|
60 |
+
protected function doLeaveNode(Twig_Node $node, Twig_Environment $env)
|
61 |
{
|
62 |
+
if ($node instanceof Twig_Node_Module) {
|
63 |
$this->inAModule = false;
|
64 |
|
65 |
+
$node->setNode('display_start', new Twig_Node(array(new Twig_Node_CheckSecurity($this->filters, $this->tags, $this->functions), $node->getNode('display_start'))));
|
66 |
}
|
67 |
|
68 |
return $node;
|
73 |
return 0;
|
74 |
}
|
75 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/NodeVisitorInterface.php
CHANGED
@@ -9,8 +9,6 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Environment;
|
13 |
-
|
14 |
/**
|
15 |
* Twig_NodeVisitorInterface is the interface the all node visitor classes must implement.
|
16 |
*
|
@@ -23,14 +21,14 @@ interface Twig_NodeVisitorInterface
|
|
23 |
*
|
24 |
* @return Twig_NodeInterface The modified node
|
25 |
*/
|
26 |
-
public function enterNode(Twig_NodeInterface $node,
|
27 |
|
28 |
/**
|
29 |
* Called after child nodes are visited.
|
30 |
*
|
31 |
* @return Twig_NodeInterface|false The modified node or false if the node must be removed
|
32 |
*/
|
33 |
-
public function leaveNode(Twig_NodeInterface $node,
|
34 |
|
35 |
/**
|
36 |
* Returns the priority for this visitor.
|
@@ -41,7 +39,3 @@ interface Twig_NodeVisitorInterface
|
|
41 |
*/
|
42 |
public function getPriority();
|
43 |
}
|
44 |
-
|
45 |
-
class_alias('Twig_NodeVisitorInterface', 'Twig\NodeVisitor\NodeVisitorInterface', false);
|
46 |
-
class_exists('Twig_Environment');
|
47 |
-
class_exists('Twig_Node');
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
12 |
/**
|
13 |
* Twig_NodeVisitorInterface is the interface the all node visitor classes must implement.
|
14 |
*
|
21 |
*
|
22 |
* @return Twig_NodeInterface The modified node
|
23 |
*/
|
24 |
+
public function enterNode(Twig_NodeInterface $node, Twig_Environment $env);
|
25 |
|
26 |
/**
|
27 |
* Called after child nodes are visited.
|
28 |
*
|
29 |
* @return Twig_NodeInterface|false The modified node or false if the node must be removed
|
30 |
*/
|
31 |
+
public function leaveNode(Twig_NodeInterface $node, Twig_Environment $env);
|
32 |
|
33 |
/**
|
34 |
* Returns the priority for this visitor.
|
39 |
*/
|
40 |
public function getPriority();
|
41 |
}
|
|
|
|
|
|
|
|
vendor/twig/twig/lib/Twig/Parser.php
CHANGED
@@ -10,26 +10,6 @@
|
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
|
13 |
-
use Twig\Environment;
|
14 |
-
use Twig\Error\SyntaxError;
|
15 |
-
use Twig\ExpressionParser;
|
16 |
-
use Twig\Node\BlockNode;
|
17 |
-
use Twig\Node\BlockReferenceNode;
|
18 |
-
use Twig\Node\BodyNode;
|
19 |
-
use Twig\Node\Expression\AbstractExpression;
|
20 |
-
use Twig\Node\MacroNode;
|
21 |
-
use Twig\Node\ModuleNode;
|
22 |
-
use Twig\Node\Node;
|
23 |
-
use Twig\Node\NodeCaptureInterface;
|
24 |
-
use Twig\Node\NodeOutputInterface;
|
25 |
-
use Twig\Node\PrintNode;
|
26 |
-
use Twig\Node\TextNode;
|
27 |
-
use Twig\NodeTraverser;
|
28 |
-
use Twig\NodeVisitor\NodeVisitorInterface;
|
29 |
-
use Twig\Token;
|
30 |
-
use Twig\TokenParser\TokenParserInterface;
|
31 |
-
use Twig\TokenStream;
|
32 |
-
|
33 |
/**
|
34 |
* Default parser implementation.
|
35 |
*
|
@@ -37,7 +17,7 @@ use Twig\TokenStream;
|
|
37 |
*/
|
38 |
class Twig_Parser implements Twig_ParserInterface
|
39 |
{
|
40 |
-
protected $stack =
|
41 |
protected $stream;
|
42 |
protected $parent;
|
43 |
protected $handlers;
|
@@ -50,10 +30,9 @@ class Twig_Parser implements Twig_ParserInterface
|
|
50 |
protected $reservedMacroNames;
|
51 |
protected $importedSymbols;
|
52 |
protected $traits;
|
53 |
-
protected $embeddedTemplates =
|
54 |
-
private $varNameSalt = 0;
|
55 |
|
56 |
-
public function __construct(
|
57 |
{
|
58 |
$this->env = $env;
|
59 |
}
|
@@ -70,7 +49,7 @@ class Twig_Parser implements Twig_ParserInterface
|
|
70 |
|
71 |
public function getVarName()
|
72 |
{
|
73 |
-
return sprintf('__internal_%s', hash('sha256',
|
74 |
}
|
75 |
|
76 |
/**
|
@@ -83,12 +62,12 @@ class Twig_Parser implements Twig_ParserInterface
|
|
83 |
return $this->stream->getSourceContext()->getName();
|
84 |
}
|
85 |
|
86 |
-
public function parse(
|
87 |
{
|
88 |
// push all variables into the stack to keep the current state of the parser
|
89 |
// using get_object_vars() instead of foreach would lead to https://bugs.php.net/71336
|
90 |
// This hack can be removed when min version if PHP 7.0
|
91 |
-
$vars =
|
92 |
foreach ($this as $k => $v) {
|
93 |
$vars[$k] = $v;
|
94 |
}
|
@@ -108,26 +87,25 @@ class Twig_Parser implements Twig_ParserInterface
|
|
108 |
}
|
109 |
|
110 |
if (null === $this->expressionParser) {
|
111 |
-
$this->expressionParser = new
|
112 |
}
|
113 |
|
114 |
$this->stream = $stream;
|
115 |
$this->parent = null;
|
116 |
-
$this->blocks =
|
117 |
-
$this->macros =
|
118 |
-
$this->traits =
|
119 |
-
$this->blockStack =
|
120 |
-
$this->importedSymbols =
|
121 |
-
$this->embeddedTemplates =
|
122 |
-
$this->varNameSalt = 0;
|
123 |
|
124 |
try {
|
125 |
$body = $this->subparse($test, $dropNeedle);
|
126 |
|
127 |
if (null !== $this->parent && null === $body = $this->filterBodyNodes($body)) {
|
128 |
-
$body = new
|
129 |
}
|
130 |
-
} catch (
|
131 |
if (!$e->getSourceContext()) {
|
132 |
$e->setSourceContext($this->stream->getSourceContext());
|
133 |
}
|
@@ -139,9 +117,9 @@ class Twig_Parser implements Twig_ParserInterface
|
|
139 |
throw $e;
|
140 |
}
|
141 |
|
142 |
-
$node = new
|
143 |
|
144 |
-
$traverser = new
|
145 |
|
146 |
$node = $traverser->traverse($node);
|
147 |
|
@@ -156,51 +134,51 @@ class Twig_Parser implements Twig_ParserInterface
|
|
156 |
public function subparse($test, $dropNeedle = false)
|
157 |
{
|
158 |
$lineno = $this->getCurrentToken()->getLine();
|
159 |
-
$rv =
|
160 |
while (!$this->stream->isEOF()) {
|
161 |
switch ($this->getCurrentToken()->getType()) {
|
162 |
-
case
|
163 |
$token = $this->stream->next();
|
164 |
-
$rv[] = new
|
165 |
break;
|
166 |
|
167 |
-
case
|
168 |
$token = $this->stream->next();
|
169 |
$expr = $this->expressionParser->parseExpression();
|
170 |
-
$this->stream->expect(
|
171 |
-
$rv[] = new
|
172 |
break;
|
173 |
|
174 |
-
case
|
175 |
$this->stream->next();
|
176 |
$token = $this->getCurrentToken();
|
177 |
|
178 |
-
if (
|
179 |
-
throw new
|
180 |
}
|
181 |
|
182 |
-
if (null !== $test &&
|
183 |
if ($dropNeedle) {
|
184 |
$this->stream->next();
|
185 |
}
|
186 |
|
187 |
-
if (1 ===
|
188 |
return $rv[0];
|
189 |
}
|
190 |
|
191 |
-
return new
|
192 |
}
|
193 |
|
194 |
$subparser = $this->handlers->getTokenParser($token->getValue());
|
195 |
if (null === $subparser) {
|
196 |
if (null !== $test) {
|
197 |
-
$e = new
|
198 |
|
199 |
-
if (
|
200 |
$e->appendMessage(sprintf(' (expecting closing tag for the "%s" tag defined near line %s).', $test[0]->getTag(), $lineno));
|
201 |
}
|
202 |
} else {
|
203 |
-
$e = new
|
204 |
$e->addSuggestions($token->getValue(), array_keys($this->env->getTags()));
|
205 |
}
|
206 |
|
@@ -216,15 +194,15 @@ class Twig_Parser implements Twig_ParserInterface
|
|
216 |
break;
|
217 |
|
218 |
default:
|
219 |
-
throw new
|
220 |
}
|
221 |
}
|
222 |
|
223 |
-
if (1 ===
|
224 |
return $rv[0];
|
225 |
}
|
226 |
|
227 |
-
return new
|
228 |
}
|
229 |
|
230 |
/**
|
@@ -240,7 +218,7 @@ class Twig_Parser implements Twig_ParserInterface
|
|
240 |
/**
|
241 |
* @deprecated since 1.27 (to be removed in 2.0)
|
242 |
*/
|
243 |
-
public function addNodeVisitor(
|
244 |
{
|
245 |
@trigger_error('The '.__METHOD__.' method is deprecated since version 1.27 and will be removed in 2.0.', E_USER_DEPRECATED);
|
246 |
|
@@ -254,7 +232,7 @@ class Twig_Parser implements Twig_ParserInterface
|
|
254 |
|
255 |
public function peekBlockStack()
|
256 |
{
|
257 |
-
return $this->blockStack[
|
258 |
}
|
259 |
|
260 |
public function popBlockStack()
|
@@ -277,9 +255,9 @@ class Twig_Parser implements Twig_ParserInterface
|
|
277 |
return $this->blocks[$name];
|
278 |
}
|
279 |
|
280 |
-
public function setBlock($name,
|
281 |
{
|
282 |
-
$this->blocks[$name] = new
|
283 |
}
|
284 |
|
285 |
public function hasMacro($name)
|
@@ -287,10 +265,10 @@ class Twig_Parser implements Twig_ParserInterface
|
|
287 |
return isset($this->macros[$name]);
|
288 |
}
|
289 |
|
290 |
-
public function setMacro($name,
|
291 |
{
|
292 |
if ($this->isReservedMacroName($name)) {
|
293 |
-
throw new
|
294 |
}
|
295 |
|
296 |
$this->macros[$name] = $node;
|
@@ -299,8 +277,8 @@ class Twig_Parser implements Twig_ParserInterface
|
|
299 |
public function isReservedMacroName($name)
|
300 |
{
|
301 |
if (null === $this->reservedMacroNames) {
|
302 |
-
$this->reservedMacroNames =
|
303 |
-
$r = new
|
304 |
foreach ($r->getMethods() as $method) {
|
305 |
$methodName = strtolower($method->getName());
|
306 |
|
@@ -310,7 +288,7 @@ class Twig_Parser implements Twig_ParserInterface
|
|
310 |
}
|
311 |
}
|
312 |
|
313 |
-
return
|
314 |
}
|
315 |
|
316 |
public function addTrait($trait)
|
@@ -320,19 +298,19 @@ class Twig_Parser implements Twig_ParserInterface
|
|
320 |
|
321 |
public function hasTraits()
|
322 |
{
|
323 |
-
return
|
324 |
}
|
325 |
|
326 |
-
public function embedTemplate(
|
327 |
{
|
328 |
$template->setIndex(mt_rand());
|
329 |
|
330 |
$this->embeddedTemplates[] = $template;
|
331 |
}
|
332 |
|
333 |
-
public function addImportedSymbol($type, $alias, $name = null,
|
334 |
{
|
335 |
-
$this->importedSymbols[0][$type][$alias] =
|
336 |
}
|
337 |
|
338 |
public function getImportedSymbol($type, $alias)
|
@@ -346,12 +324,12 @@ class Twig_Parser implements Twig_ParserInterface
|
|
346 |
|
347 |
public function isMainScope()
|
348 |
{
|
349 |
-
return 1 ===
|
350 |
}
|
351 |
|
352 |
public function pushLocalScope()
|
353 |
{
|
354 |
-
array_unshift($this->importedSymbols,
|
355 |
}
|
356 |
|
357 |
public function popLocalScope()
|
@@ -360,7 +338,7 @@ class Twig_Parser implements Twig_ParserInterface
|
|
360 |
}
|
361 |
|
362 |
/**
|
363 |
-
* @return
|
364 |
*/
|
365 |
public function getExpressionParser()
|
366 |
{
|
@@ -378,7 +356,7 @@ class Twig_Parser implements Twig_ParserInterface
|
|
378 |
}
|
379 |
|
380 |
/**
|
381 |
-
* @return
|
382 |
*/
|
383 |
public function getStream()
|
384 |
{
|
@@ -386,7 +364,7 @@ class Twig_Parser implements Twig_ParserInterface
|
|
386 |
}
|
387 |
|
388 |
/**
|
389 |
-
* @return
|
390 |
*/
|
391 |
public function getCurrentToken()
|
392 |
{
|
@@ -397,27 +375,23 @@ class Twig_Parser implements Twig_ParserInterface
|
|
397 |
{
|
398 |
// check that the body does not contain non-empty output nodes
|
399 |
if (
|
400 |
-
($node instanceof
|
401 |
||
|
402 |
-
(!$node instanceof
|
403 |
) {
|
404 |
-
if (false !== strpos((string) $node,
|
405 |
-
|
406 |
-
if ('' === $t || ctype_space($t)) {
|
407 |
-
// bypass empty nodes starting with a BOM
|
408 |
-
return;
|
409 |
-
}
|
410 |
}
|
411 |
|
412 |
-
throw new
|
413 |
}
|
414 |
|
415 |
// bypass nodes that will "capture" the output
|
416 |
-
if ($node instanceof
|
417 |
return $node;
|
418 |
}
|
419 |
|
420 |
-
if ($node instanceof
|
421 |
return;
|
422 |
}
|
423 |
|
@@ -430,7 +404,3 @@ class Twig_Parser implements Twig_ParserInterface
|
|
430 |
return $node;
|
431 |
}
|
432 |
}
|
433 |
-
|
434 |
-
class_alias('Twig_Parser', 'Twig\Parser', false);
|
435 |
-
class_exists('Twig_Node');
|
436 |
-
class_exists('Twig_TokenStream');
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
/**
|
14 |
* Default parser implementation.
|
15 |
*
|
17 |
*/
|
18 |
class Twig_Parser implements Twig_ParserInterface
|
19 |
{
|
20 |
+
protected $stack = array();
|
21 |
protected $stream;
|
22 |
protected $parent;
|
23 |
protected $handlers;
|
30 |
protected $reservedMacroNames;
|
31 |
protected $importedSymbols;
|
32 |
protected $traits;
|
33 |
+
protected $embeddedTemplates = array();
|
|
|
34 |
|
35 |
+
public function __construct(Twig_Environment $env)
|
36 |
{
|
37 |
$this->env = $env;
|
38 |
}
|
49 |
|
50 |
public function getVarName()
|
51 |
{
|
52 |
+
return sprintf('__internal_%s', hash('sha256', uniqid(mt_rand(), true), false));
|
53 |
}
|
54 |
|
55 |
/**
|
62 |
return $this->stream->getSourceContext()->getName();
|
63 |
}
|
64 |
|
65 |
+
public function parse(Twig_TokenStream $stream, $test = null, $dropNeedle = false)
|
66 |
{
|
67 |
// push all variables into the stack to keep the current state of the parser
|
68 |
// using get_object_vars() instead of foreach would lead to https://bugs.php.net/71336
|
69 |
// This hack can be removed when min version if PHP 7.0
|
70 |
+
$vars = array();
|
71 |
foreach ($this as $k => $v) {
|
72 |
$vars[$k] = $v;
|
73 |
}
|
87 |
}
|
88 |
|
89 |
if (null === $this->expressionParser) {
|
90 |
+
$this->expressionParser = new Twig_ExpressionParser($this, $this->env);
|
91 |
}
|
92 |
|
93 |
$this->stream = $stream;
|
94 |
$this->parent = null;
|
95 |
+
$this->blocks = array();
|
96 |
+
$this->macros = array();
|
97 |
+
$this->traits = array();
|
98 |
+
$this->blockStack = array();
|
99 |
+
$this->importedSymbols = array(array());
|
100 |
+
$this->embeddedTemplates = array();
|
|
|
101 |
|
102 |
try {
|
103 |
$body = $this->subparse($test, $dropNeedle);
|
104 |
|
105 |
if (null !== $this->parent && null === $body = $this->filterBodyNodes($body)) {
|
106 |
+
$body = new Twig_Node();
|
107 |
}
|
108 |
+
} catch (Twig_Error_Syntax $e) {
|
109 |
if (!$e->getSourceContext()) {
|
110 |
$e->setSourceContext($this->stream->getSourceContext());
|
111 |
}
|
117 |
throw $e;
|
118 |
}
|
119 |
|
120 |
+
$node = new Twig_Node_Module(new Twig_Node_Body(array($body)), $this->parent, new Twig_Node($this->blocks), new Twig_Node($this->macros), new Twig_Node($this->traits), $this->embeddedTemplates, $stream->getSourceContext());
|
121 |
|
122 |
+
$traverser = new Twig_NodeTraverser($this->env, $this->visitors);
|
123 |
|
124 |
$node = $traverser->traverse($node);
|
125 |
|
134 |
public function subparse($test, $dropNeedle = false)
|
135 |
{
|
136 |
$lineno = $this->getCurrentToken()->getLine();
|
137 |
+
$rv = array();
|
138 |
while (!$this->stream->isEOF()) {
|
139 |
switch ($this->getCurrentToken()->getType()) {
|
140 |
+
case Twig_Token::TEXT_TYPE:
|
141 |
$token = $this->stream->next();
|
142 |
+
$rv[] = new Twig_Node_Text($token->getValue(), $token->getLine());
|
143 |
break;
|
144 |
|
145 |
+
case Twig_Token::VAR_START_TYPE:
|
146 |
$token = $this->stream->next();
|
147 |
$expr = $this->expressionParser->parseExpression();
|
148 |
+
$this->stream->expect(Twig_Token::VAR_END_TYPE);
|
149 |
+
$rv[] = new Twig_Node_Print($expr, $token->getLine());
|
150 |
break;
|
151 |
|
152 |
+
case Twig_Token::BLOCK_START_TYPE:
|
153 |
$this->stream->next();
|
154 |
$token = $this->getCurrentToken();
|
155 |
|
156 |
+
if ($token->getType() !== Twig_Token::NAME_TYPE) {
|
157 |
+
throw new Twig_Error_Syntax('A block must start with a tag name.', $token->getLine(), $this->stream->getSourceContext());
|
158 |
}
|
159 |
|
160 |
+
if (null !== $test && call_user_func($test, $token)) {
|
161 |
if ($dropNeedle) {
|
162 |
$this->stream->next();
|
163 |
}
|
164 |
|
165 |
+
if (1 === count($rv)) {
|
166 |
return $rv[0];
|
167 |
}
|
168 |
|
169 |
+
return new Twig_Node($rv, array(), $lineno);
|
170 |
}
|
171 |
|
172 |
$subparser = $this->handlers->getTokenParser($token->getValue());
|
173 |
if (null === $subparser) {
|
174 |
if (null !== $test) {
|
175 |
+
$e = new Twig_Error_Syntax(sprintf('Unexpected "%s" tag', $token->getValue()), $token->getLine(), $this->stream->getSourceContext());
|
176 |
|
177 |
+
if (is_array($test) && isset($test[0]) && $test[0] instanceof Twig_TokenParserInterface) {
|
178 |
$e->appendMessage(sprintf(' (expecting closing tag for the "%s" tag defined near line %s).', $test[0]->getTag(), $lineno));
|
179 |
}
|
180 |
} else {
|
181 |
+
$e = new Twig_Error_Syntax(sprintf('Unknown "%s" tag.', $token->getValue()), $token->getLine(), $this->stream->getSourceContext());
|
182 |
$e->addSuggestions($token->getValue(), array_keys($this->env->getTags()));
|
183 |
}
|
184 |
|
194 |
break;
|
195 |
|
196 |
default:
|
197 |
+
throw new Twig_Error_Syntax('Lexer or parser ended up in unsupported state.', $this->getCurrentToken()->getLine(), $this->stream->getSourceContext());
|
198 |
}
|
199 |
}
|
200 |
|
201 |
+
if (1 === count($rv)) {
|
202 |
return $rv[0];
|
203 |
}
|
204 |
|
205 |
+
return new Twig_Node($rv, array(), $lineno);
|
206 |
}
|
207 |
|
208 |
/**
|
218 |
/**
|
219 |
* @deprecated since 1.27 (to be removed in 2.0)
|
220 |
*/
|
221 |
+
public function addNodeVisitor(Twig_NodeVisitorInterface $visitor)
|
222 |
{
|
223 |
@trigger_error('The '.__METHOD__.' method is deprecated since version 1.27 and will be removed in 2.0.', E_USER_DEPRECATED);
|
224 |
|
232 |
|
233 |
public function peekBlockStack()
|
234 |
{
|
235 |
+
return $this->blockStack[count($this->blockStack) - 1];
|
236 |
}
|
237 |
|
238 |
public function popBlockStack()
|
255 |
return $this->blocks[$name];
|
256 |
}
|
257 |
|
258 |
+
public function setBlock($name, Twig_Node_Block $value)
|
259 |
{
|
260 |
+
$this->blocks[$name] = new Twig_Node_Body(array($value), array(), $value->getTemplateLine());
|
261 |
}
|
262 |
|
263 |
public function hasMacro($name)
|
265 |
return isset($this->macros[$name]);
|
266 |
}
|
267 |
|
268 |
+
public function setMacro($name, Twig_Node_Macro $node)
|
269 |
{
|
270 |
if ($this->isReservedMacroName($name)) {
|
271 |
+
throw new Twig_Error_Syntax(sprintf('"%s" cannot be used as a macro name as it is a reserved keyword.', $name), $node->getTemplateLine(), $this->stream->getSourceContext());
|
272 |
}
|
273 |
|
274 |
$this->macros[$name] = $node;
|
277 |
public function isReservedMacroName($name)
|
278 |
{
|
279 |
if (null === $this->reservedMacroNames) {
|
280 |
+
$this->reservedMacroNames = array();
|
281 |
+
$r = new ReflectionClass($this->env->getBaseTemplateClass());
|
282 |
foreach ($r->getMethods() as $method) {
|
283 |
$methodName = strtolower($method->getName());
|
284 |
|
288 |
}
|
289 |
}
|
290 |
|
291 |
+
return in_array(strtolower($name), $this->reservedMacroNames);
|
292 |
}
|
293 |
|
294 |
public function addTrait($trait)
|
298 |
|
299 |
public function hasTraits()
|
300 |
{
|
301 |
+
return count($this->traits) > 0;
|
302 |
}
|
303 |
|
304 |
+
public function embedTemplate(Twig_Node_Module $template)
|
305 |
{
|
306 |
$template->setIndex(mt_rand());
|
307 |
|
308 |
$this->embeddedTemplates[] = $template;
|
309 |
}
|
310 |
|
311 |
+
public function addImportedSymbol($type, $alias, $name = null, Twig_Node_Expression $node = null)
|
312 |
{
|
313 |
+
$this->importedSymbols[0][$type][$alias] = array('name' => $name, 'node' => $node);
|
314 |
}
|
315 |
|
316 |
public function getImportedSymbol($type, $alias)
|
324 |
|
325 |
public function isMainScope()
|
326 |
{
|
327 |
+
return 1 === count($this->importedSymbols);
|
328 |
}
|
329 |
|
330 |
public function pushLocalScope()
|
331 |
{
|
332 |
+
array_unshift($this->importedSymbols, array());
|
333 |
}
|
334 |
|
335 |
public function popLocalScope()
|
338 |
}
|
339 |
|
340 |
/**
|
341 |
+
* @return Twig_ExpressionParser
|
342 |
*/
|
343 |
public function getExpressionParser()
|
344 |
{
|
356 |
}
|
357 |
|
358 |
/**
|
359 |
+
* @return Twig_TokenStream
|
360 |
*/
|
361 |
public function getStream()
|
362 |
{
|
364 |
}
|
365 |
|
366 |
/**
|
367 |
+
* @return Twig_Token
|
368 |
*/
|
369 |
public function getCurrentToken()
|
370 |
{
|
375 |
{
|
376 |
// check that the body does not contain non-empty output nodes
|
377 |
if (
|
378 |
+
($node instanceof Twig_Node_Text && !ctype_space($node->getAttribute('data')))
|
379 |
||
|
380 |
+
(!$node instanceof Twig_Node_Text && !$node instanceof Twig_Node_BlockReference && $node instanceof Twig_NodeOutputInterface)
|
381 |
) {
|
382 |
+
if (false !== strpos((string) $node, chr(0xEF).chr(0xBB).chr(0xBF))) {
|
383 |
+
throw new Twig_Error_Syntax('A template that extends another one cannot start with a byte order mark (BOM); it must be removed.', $node->getTemplateLine(), $this->stream->getSourceContext());
|
|
|
|
|
|
|
|
|
384 |
}
|
385 |
|
386 |
+
throw new Twig_Error_Syntax('A template that extends another one cannot include contents outside Twig blocks. Did you forget to put the contents inside a {% block %} tag?', $node->getTemplateLine(), $this->stream->getSourceContext());
|
387 |
}
|
388 |
|
389 |
// bypass nodes that will "capture" the output
|
390 |
+
if ($node instanceof Twig_NodeCaptureInterface) {
|
391 |
return $node;
|
392 |
}
|
393 |
|
394 |
+
if ($node instanceof Twig_NodeOutputInterface) {
|
395 |
return;
|
396 |
}
|
397 |
|
404 |
return $node;
|
405 |
}
|
406 |
}
|
|
|
|
|
|
|
|
vendor/twig/twig/lib/Twig/ParserInterface.php
CHANGED
@@ -9,10 +9,6 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Error\SyntaxError;
|
13 |
-
use Twig\Node\ModuleNode;
|
14 |
-
use Twig\TokenStream;
|
15 |
-
|
16 |
/**
|
17 |
* Interface implemented by parser classes.
|
18 |
*
|
@@ -25,9 +21,9 @@ interface Twig_ParserInterface
|
|
25 |
/**
|
26 |
* Converts a token stream to a node tree.
|
27 |
*
|
28 |
-
* @return
|
29 |
*
|
30 |
-
* @throws
|
31 |
*/
|
32 |
-
public function parse(
|
33 |
}
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
|
|
|
|
12 |
/**
|
13 |
* Interface implemented by parser classes.
|
14 |
*
|
21 |
/**
|
22 |
* Converts a token stream to a node tree.
|
23 |
*
|
24 |
+
* @return Twig_Node_Module
|
25 |
*
|
26 |
+
* @throws Twig_Error_Syntax When the token stream is syntactically or semantically wrong
|
27 |
*/
|
28 |
+
public function parse(Twig_TokenStream $stream);
|
29 |
}
|
vendor/twig/twig/lib/Twig/Profiler/Dumper/Base.php
DELETED
@@ -1,64 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of Twig.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
use Twig\Profiler\Profile;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
-
*/
|
17 |
-
abstract class Twig_Profiler_Dumper_Base
|
18 |
-
{
|
19 |
-
private $root;
|
20 |
-
|
21 |
-
public function dump(Profile $profile)
|
22 |
-
{
|
23 |
-
return $this->dumpProfile($profile);
|
24 |
-
}
|
25 |
-
|
26 |
-
abstract protected function formatTemplate(Profile $profile, $prefix);
|
27 |
-
|
28 |
-
abstract protected function formatNonTemplate(Profile $profile, $prefix);
|
29 |
-
|
30 |
-
abstract protected function formatTime(Profile $profile, $percent);
|
31 |
-
|
32 |
-
private function dumpProfile(Profile $profile, $prefix = '', $sibling = false)
|
33 |
-
{
|
34 |
-
if ($profile->isRoot()) {
|
35 |
-
$this->root = $profile->getDuration();
|
36 |
-
$start = $profile->getName();
|
37 |
-
} else {
|
38 |
-
if ($profile->isTemplate()) {
|
39 |
-
$start = $this->formatTemplate($profile, $prefix);
|
40 |
-
} else {
|
41 |
-
$start = $this->formatNonTemplate($profile, $prefix);
|
42 |
-
}
|
43 |
-
$prefix .= $sibling ? '│ ' : ' ';
|
44 |
-
}
|
45 |
-
|
46 |
-
$percent = $this->root ? $profile->getDuration() / $this->root * 100 : 0;
|
47 |
-
|
48 |
-
if ($profile->getDuration() * 1000 < 1) {
|
49 |
-
$str = $start."\n";
|
50 |
-
} else {
|
51 |
-
$str = sprintf("%s %s\n", $start, $this->formatTime($profile, $percent));
|
52 |
-
}
|
53 |
-
|
54 |
-
$nCount = \count($profile->getProfiles());
|
55 |
-
foreach ($profile as $i => $p) {
|
56 |
-
$str .= $this->dumpProfile($p, $prefix, $i + 1 !== $nCount);
|
57 |
-
}
|
58 |
-
|
59 |
-
return $str;
|
60 |
-
}
|
61 |
-
}
|
62 |
-
|
63 |
-
class_alias('Twig_Profiler_Dumper_Base', 'Twig\Profiler\Dumper\BaseDumper', false);
|
64 |
-
class_exists('Twig_Profiler_Profile');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/lib/Twig/Profiler/Dumper/Blackfire.php
CHANGED
@@ -9,8 +9,6 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Profiler\Profile;
|
13 |
-
|
14 |
/**
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*
|
@@ -18,13 +16,13 @@ use Twig\Profiler\Profile;
|
|
18 |
*/
|
19 |
class Twig_Profiler_Dumper_Blackfire
|
20 |
{
|
21 |
-
public function dump(
|
22 |
{
|
23 |
-
$data =
|
24 |
$this->dumpProfile('main()', $profile, $data);
|
25 |
$this->dumpChildren('main()', $profile, $data);
|
26 |
|
27 |
-
$start =
|
28 |
$str = <<<EOF
|
29 |
file-format: BlackfireProbe
|
30 |
cost-dimensions: wt mu pmu
|
@@ -40,7 +38,7 @@ EOF;
|
|
40 |
return $str;
|
41 |
}
|
42 |
|
43 |
-
private function dumpChildren($parent,
|
44 |
{
|
45 |
foreach ($profile as $p) {
|
46 |
if ($p->isTemplate()) {
|
@@ -53,22 +51,20 @@ EOF;
|
|
53 |
}
|
54 |
}
|
55 |
|
56 |
-
private function dumpProfile($edge,
|
57 |
{
|
58 |
if (isset($data[$edge])) {
|
59 |
-
|
60 |
$data[$edge]['wt'] += floor($profile->getDuration() * 1000000);
|
61 |
$data[$edge]['mu'] += $profile->getMemoryUsage();
|
62 |
$data[$edge]['pmu'] += $profile->getPeakMemoryUsage();
|
63 |
} else {
|
64 |
-
$data[$edge] =
|
65 |
'ct' => 1,
|
66 |
'wt' => floor($profile->getDuration() * 1000000),
|
67 |
'mu' => $profile->getMemoryUsage(),
|
68 |
'pmu' => $profile->getPeakMemoryUsage(),
|
69 |
-
|
70 |
}
|
71 |
}
|
72 |
}
|
73 |
-
|
74 |
-
class_alias('Twig_Profiler_Dumper_Blackfire', 'Twig\Profiler\Dumper\BlackfireDumper', false);
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
12 |
/**
|
13 |
* @author Fabien Potencier <fabien@symfony.com>
|
14 |
*
|
16 |
*/
|
17 |
class Twig_Profiler_Dumper_Blackfire
|
18 |
{
|
19 |
+
public function dump(Twig_Profiler_Profile $profile)
|
20 |
{
|
21 |
+
$data = array();
|
22 |
$this->dumpProfile('main()', $profile, $data);
|
23 |
$this->dumpChildren('main()', $profile, $data);
|
24 |
|
25 |
+
$start = microtime(true);
|
26 |
$str = <<<EOF
|
27 |
file-format: BlackfireProbe
|
28 |
cost-dimensions: wt mu pmu
|
38 |
return $str;
|
39 |
}
|
40 |
|
41 |
+
private function dumpChildren($parent, Twig_Profiler_Profile $profile, &$data)
|
42 |
{
|
43 |
foreach ($profile as $p) {
|
44 |
if ($p->isTemplate()) {
|
51 |
}
|
52 |
}
|
53 |
|
54 |
+
private function dumpProfile($edge, Twig_Profiler_Profile $profile, &$data)
|
55 |
{
|
56 |
if (isset($data[$edge])) {
|
57 |
+
$data[$edge]['ct'] += 1;
|
58 |
$data[$edge]['wt'] += floor($profile->getDuration() * 1000000);
|
59 |
$data[$edge]['mu'] += $profile->getMemoryUsage();
|
60 |
$data[$edge]['pmu'] += $profile->getPeakMemoryUsage();
|
61 |
} else {
|
62 |
+
$data[$edge] = array(
|
63 |
'ct' => 1,
|
64 |
'wt' => floor($profile->getDuration() * 1000000),
|
65 |
'mu' => $profile->getMemoryUsage(),
|
66 |
'pmu' => $profile->getPeakMemoryUsage(),
|
67 |
+
);
|
68 |
}
|
69 |
}
|
70 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Profiler/Dumper/Html.php
CHANGED
@@ -9,42 +9,37 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Profiler\Dumper\BaseDumper;
|
13 |
-
use Twig\Profiler\Profile;
|
14 |
-
|
15 |
/**
|
16 |
* @author Fabien Potencier <fabien@symfony.com>
|
17 |
*
|
18 |
* @final
|
19 |
*/
|
20 |
-
class Twig_Profiler_Dumper_Html extends
|
21 |
{
|
22 |
-
private static $colors =
|
23 |
'block' => '#dfd',
|
24 |
'macro' => '#ddf',
|
25 |
'template' => '#ffd',
|
26 |
'big' => '#d44',
|
27 |
-
|
28 |
|
29 |
-
public function dump(
|
30 |
{
|
31 |
return '<pre>'.parent::dump($profile).'</pre>';
|
32 |
}
|
33 |
|
34 |
-
protected function formatTemplate(
|
35 |
{
|
36 |
return sprintf('%s└ <span style="background-color: %s">%s</span>', $prefix, self::$colors['template'], $profile->getTemplate());
|
37 |
}
|
38 |
|
39 |
-
protected function formatNonTemplate(
|
40 |
{
|
41 |
return sprintf('%s└ %s::%s(<span style="background-color: %s">%s</span>)', $prefix, $profile->getTemplate(), $profile->getType(), isset(self::$colors[$profile->getType()]) ? self::$colors[$profile->getType()] : 'auto', $profile->getName());
|
42 |
}
|
43 |
|
44 |
-
protected function formatTime(
|
45 |
{
|
46 |
return sprintf('<span style="color: %s">%.2fms/%.0f%%</span>', $percent > 20 ? self::$colors['big'] : 'auto', $profile->getDuration() * 1000, $percent);
|
47 |
}
|
48 |
}
|
49 |
-
|
50 |
-
class_alias('Twig_Profiler_Dumper_Html', 'Twig\Profiler\Dumper\HtmlDumper', false);
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
|
|
12 |
/**
|
13 |
* @author Fabien Potencier <fabien@symfony.com>
|
14 |
*
|
15 |
* @final
|
16 |
*/
|
17 |
+
class Twig_Profiler_Dumper_Html extends Twig_Profiler_Dumper_Text
|
18 |
{
|
19 |
+
private static $colors = array(
|
20 |
'block' => '#dfd',
|
21 |
'macro' => '#ddf',
|
22 |
'template' => '#ffd',
|
23 |
'big' => '#d44',
|
24 |
+
);
|
25 |
|
26 |
+
public function dump(Twig_Profiler_Profile $profile)
|
27 |
{
|
28 |
return '<pre>'.parent::dump($profile).'</pre>';
|
29 |
}
|
30 |
|
31 |
+
protected function formatTemplate(Twig_Profiler_Profile $profile, $prefix)
|
32 |
{
|
33 |
return sprintf('%s└ <span style="background-color: %s">%s</span>', $prefix, self::$colors['template'], $profile->getTemplate());
|
34 |
}
|
35 |
|
36 |
+
protected function formatNonTemplate(Twig_Profiler_Profile $profile, $prefix)
|
37 |
{
|
38 |
return sprintf('%s└ %s::%s(<span style="background-color: %s">%s</span>)', $prefix, $profile->getTemplate(), $profile->getType(), isset(self::$colors[$profile->getType()]) ? self::$colors[$profile->getType()] : 'auto', $profile->getName());
|
39 |
}
|
40 |
|
41 |
+
protected function formatTime(Twig_Profiler_Profile $profile, $percent)
|
42 |
{
|
43 |
return sprintf('<span style="color: %s">%.2fms/%.0f%%</span>', $percent > 20 ? self::$colors['big'] : 'auto', $profile->getDuration() * 1000, $percent);
|
44 |
}
|
45 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Profiler/Dumper/Text.php
CHANGED
@@ -9,30 +9,62 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Profiler\Dumper\BaseDumper;
|
13 |
-
use Twig\Profiler\Profile;
|
14 |
-
|
15 |
/**
|
16 |
* @author Fabien Potencier <fabien@symfony.com>
|
17 |
*
|
18 |
* @final
|
19 |
*/
|
20 |
-
class Twig_Profiler_Dumper_Text
|
21 |
{
|
22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
{
|
24 |
return sprintf('%s└ %s', $prefix, $profile->getTemplate());
|
25 |
}
|
26 |
|
27 |
-
protected function formatNonTemplate(
|
28 |
{
|
29 |
return sprintf('%s└ %s::%s(%s)', $prefix, $profile->getTemplate(), $profile->getType(), $profile->getName());
|
30 |
}
|
31 |
|
32 |
-
protected function formatTime(
|
33 |
{
|
34 |
return sprintf('%.2fms/%.0f%%', $profile->getDuration() * 1000, $percent);
|
35 |
}
|
36 |
-
}
|
37 |
|
38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
|
|
12 |
/**
|
13 |
* @author Fabien Potencier <fabien@symfony.com>
|
14 |
*
|
15 |
* @final
|
16 |
*/
|
17 |
+
class Twig_Profiler_Dumper_Text
|
18 |
{
|
19 |
+
private $root;
|
20 |
+
|
21 |
+
public function dump(Twig_Profiler_Profile $profile)
|
22 |
+
{
|
23 |
+
return $this->dumpProfile($profile);
|
24 |
+
}
|
25 |
+
|
26 |
+
protected function formatTemplate(Twig_Profiler_Profile $profile, $prefix)
|
27 |
{
|
28 |
return sprintf('%s└ %s', $prefix, $profile->getTemplate());
|
29 |
}
|
30 |
|
31 |
+
protected function formatNonTemplate(Twig_Profiler_Profile $profile, $prefix)
|
32 |
{
|
33 |
return sprintf('%s└ %s::%s(%s)', $prefix, $profile->getTemplate(), $profile->getType(), $profile->getName());
|
34 |
}
|
35 |
|
36 |
+
protected function formatTime(Twig_Profiler_Profile $profile, $percent)
|
37 |
{
|
38 |
return sprintf('%.2fms/%.0f%%', $profile->getDuration() * 1000, $percent);
|
39 |
}
|
|
|
40 |
|
41 |
+
private function dumpProfile(Twig_Profiler_Profile $profile, $prefix = '', $sibling = false)
|
42 |
+
{
|
43 |
+
if ($profile->isRoot()) {
|
44 |
+
$this->root = $profile->getDuration();
|
45 |
+
$start = $profile->getName();
|
46 |
+
} else {
|
47 |
+
if ($profile->isTemplate()) {
|
48 |
+
$start = $this->formatTemplate($profile, $prefix);
|
49 |
+
} else {
|
50 |
+
$start = $this->formatNonTemplate($profile, $prefix);
|
51 |
+
}
|
52 |
+
$prefix .= $sibling ? '│ ' : ' ';
|
53 |
+
}
|
54 |
+
|
55 |
+
$percent = $this->root ? $profile->getDuration() / $this->root * 100 : 0;
|
56 |
+
|
57 |
+
if ($profile->getDuration() * 1000 < 1) {
|
58 |
+
$str = $start."\n";
|
59 |
+
} else {
|
60 |
+
$str = sprintf("%s %s\n", $start, $this->formatTime($profile, $percent));
|
61 |
+
}
|
62 |
+
|
63 |
+
$nCount = count($profile->getProfiles());
|
64 |
+
foreach ($profile as $i => $p) {
|
65 |
+
$str .= $this->dumpProfile($p, $prefix, $i + 1 !== $nCount);
|
66 |
+
}
|
67 |
+
|
68 |
+
return $str;
|
69 |
+
}
|
70 |
+
}
|
vendor/twig/twig/lib/Twig/Profiler/Node/EnterProfile.php
CHANGED
@@ -9,28 +9,25 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Compiler;
|
13 |
-
use Twig\Node\Node;
|
14 |
-
|
15 |
/**
|
16 |
* Represents a profile enter node.
|
17 |
*
|
18 |
* @author Fabien Potencier <fabien@symfony.com>
|
19 |
*/
|
20 |
-
class Twig_Profiler_Node_EnterProfile extends
|
21 |
{
|
22 |
public function __construct($extensionName, $type, $name, $varName)
|
23 |
{
|
24 |
-
parent::__construct(
|
25 |
}
|
26 |
|
27 |
-
public function compile(
|
28 |
{
|
29 |
$compiler
|
30 |
->write(sprintf('$%s = $this->env->getExtension(', $this->getAttribute('var_name')))
|
31 |
->repr($this->getAttribute('extension_name'))
|
32 |
->raw(");\n")
|
33 |
-
->write(sprintf('$%s->enter($%s = new
|
34 |
->repr($this->getAttribute('type'))
|
35 |
->raw(', ')
|
36 |
->repr($this->getAttribute('name'))
|
@@ -38,5 +35,3 @@ class Twig_Profiler_Node_EnterProfile extends Node
|
|
38 |
;
|
39 |
}
|
40 |
}
|
41 |
-
|
42 |
-
class_alias('Twig_Profiler_Node_EnterProfile', 'Twig\Profiler\Node\EnterProfileNode', false);
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
|
|
12 |
/**
|
13 |
* Represents a profile enter node.
|
14 |
*
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
+
class Twig_Profiler_Node_EnterProfile extends Twig_Node
|
18 |
{
|
19 |
public function __construct($extensionName, $type, $name, $varName)
|
20 |
{
|
21 |
+
parent::__construct(array(), array('extension_name' => $extensionName, 'name' => $name, 'type' => $type, 'var_name' => $varName));
|
22 |
}
|
23 |
|
24 |
+
public function compile(Twig_Compiler $compiler)
|
25 |
{
|
26 |
$compiler
|
27 |
->write(sprintf('$%s = $this->env->getExtension(', $this->getAttribute('var_name')))
|
28 |
->repr($this->getAttribute('extension_name'))
|
29 |
->raw(");\n")
|
30 |
+
->write(sprintf('$%s->enter($%s = new Twig_Profiler_Profile($this->getTemplateName(), ', $this->getAttribute('var_name'), $this->getAttribute('var_name').'_prof'))
|
31 |
->repr($this->getAttribute('type'))
|
32 |
->raw(', ')
|
33 |
->repr($this->getAttribute('name'))
|
35 |
;
|
36 |
}
|
37 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Profiler/Node/LeaveProfile.php
CHANGED
@@ -9,22 +9,19 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Compiler;
|
13 |
-
use Twig\Node\Node;
|
14 |
-
|
15 |
/**
|
16 |
* Represents a profile leave node.
|
17 |
*
|
18 |
* @author Fabien Potencier <fabien@symfony.com>
|
19 |
*/
|
20 |
-
class Twig_Profiler_Node_LeaveProfile extends
|
21 |
{
|
22 |
public function __construct($varName)
|
23 |
{
|
24 |
-
parent::__construct(
|
25 |
}
|
26 |
|
27 |
-
public function compile(
|
28 |
{
|
29 |
$compiler
|
30 |
->write("\n")
|
@@ -32,5 +29,3 @@ class Twig_Profiler_Node_LeaveProfile extends Node
|
|
32 |
;
|
33 |
}
|
34 |
}
|
35 |
-
|
36 |
-
class_alias('Twig_Profiler_Node_LeaveProfile', 'Twig\Profiler\Node\LeaveProfileNode', false);
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
|
|
12 |
/**
|
13 |
* Represents a profile leave node.
|
14 |
*
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
+
class Twig_Profiler_Node_LeaveProfile extends Twig_Node
|
18 |
{
|
19 |
public function __construct($varName)
|
20 |
{
|
21 |
+
parent::__construct(array(), array('var_name' => $varName));
|
22 |
}
|
23 |
|
24 |
+
public function compile(Twig_Compiler $compiler)
|
25 |
{
|
26 |
$compiler
|
27 |
->write("\n")
|
29 |
;
|
30 |
}
|
31 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Profiler/NodeVisitor/Profiler.php
CHANGED
@@ -9,23 +9,12 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Environment;
|
13 |
-
use Twig\Node\BlockNode;
|
14 |
-
use Twig\Node\BodyNode;
|
15 |
-
use Twig\Node\MacroNode;
|
16 |
-
use Twig\Node\ModuleNode;
|
17 |
-
use Twig\Node\Node;
|
18 |
-
use Twig\NodeVisitor\AbstractNodeVisitor;
|
19 |
-
use Twig\Profiler\Node\EnterProfileNode;
|
20 |
-
use Twig\Profiler\Node\LeaveProfileNode;
|
21 |
-
use Twig\Profiler\Profile;
|
22 |
-
|
23 |
/**
|
24 |
* @author Fabien Potencier <fabien@symfony.com>
|
25 |
*
|
26 |
* @final
|
27 |
*/
|
28 |
-
class Twig_Profiler_NodeVisitor_Profiler extends
|
29 |
{
|
30 |
private $extensionName;
|
31 |
|
@@ -34,31 +23,31 @@ class Twig_Profiler_NodeVisitor_Profiler extends AbstractNodeVisitor
|
|
34 |
$this->extensionName = $extensionName;
|
35 |
}
|
36 |
|
37 |
-
protected function doEnterNode(
|
38 |
{
|
39 |
return $node;
|
40 |
}
|
41 |
|
42 |
-
protected function doLeaveNode(
|
43 |
{
|
44 |
-
if ($node instanceof
|
45 |
$varName = $this->getVarName();
|
46 |
-
$node->setNode('display_start', new
|
47 |
-
$node->setNode('display_end', new
|
48 |
-
} elseif ($node instanceof
|
49 |
$varName = $this->getVarName();
|
50 |
-
$node->setNode('body', new
|
51 |
-
new
|
52 |
$node->getNode('body'),
|
53 |
-
new
|
54 |
-
|
55 |
-
} elseif ($node instanceof
|
56 |
$varName = $this->getVarName();
|
57 |
-
$node->setNode('body', new
|
58 |
-
new
|
59 |
$node->getNode('body'),
|
60 |
-
new
|
61 |
-
|
62 |
}
|
63 |
|
64 |
return $node;
|
@@ -66,7 +55,7 @@ class Twig_Profiler_NodeVisitor_Profiler extends AbstractNodeVisitor
|
|
66 |
|
67 |
private function getVarName()
|
68 |
{
|
69 |
-
return sprintf('__internal_%s', hash('sha256',
|
70 |
}
|
71 |
|
72 |
public function getPriority()
|
@@ -74,5 +63,3 @@ class Twig_Profiler_NodeVisitor_Profiler extends AbstractNodeVisitor
|
|
74 |
return 0;
|
75 |
}
|
76 |
}
|
77 |
-
|
78 |
-
class_alias('Twig_Profiler_NodeVisitor_Profiler', 'Twig\Profiler\NodeVisitor\ProfilerNodeVisitor', false);
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
/**
|
13 |
* @author Fabien Potencier <fabien@symfony.com>
|
14 |
*
|
15 |
* @final
|
16 |
*/
|
17 |
+
class Twig_Profiler_NodeVisitor_Profiler extends Twig_BaseNodeVisitor
|
18 |
{
|
19 |
private $extensionName;
|
20 |
|
23 |
$this->extensionName = $extensionName;
|
24 |
}
|
25 |
|
26 |
+
protected function doEnterNode(Twig_Node $node, Twig_Environment $env)
|
27 |
{
|
28 |
return $node;
|
29 |
}
|
30 |
|
31 |
+
protected function doLeaveNode(Twig_Node $node, Twig_Environment $env)
|
32 |
{
|
33 |
+
if ($node instanceof Twig_Node_Module) {
|
34 |
$varName = $this->getVarName();
|
35 |
+
$node->setNode('display_start', new Twig_Node(array(new Twig_Profiler_Node_EnterProfile($this->extensionName, Twig_Profiler_Profile::TEMPLATE, $node->getTemplateName(), $varName), $node->getNode('display_start'))));
|
36 |
+
$node->setNode('display_end', new Twig_Node(array(new Twig_Profiler_Node_LeaveProfile($varName), $node->getNode('display_end'))));
|
37 |
+
} elseif ($node instanceof Twig_Node_Block) {
|
38 |
$varName = $this->getVarName();
|
39 |
+
$node->setNode('body', new Twig_Node_Body(array(
|
40 |
+
new Twig_Profiler_Node_EnterProfile($this->extensionName, Twig_Profiler_Profile::BLOCK, $node->getAttribute('name'), $varName),
|
41 |
$node->getNode('body'),
|
42 |
+
new Twig_Profiler_Node_LeaveProfile($varName),
|
43 |
+
)));
|
44 |
+
} elseif ($node instanceof Twig_Node_Macro) {
|
45 |
$varName = $this->getVarName();
|
46 |
+
$node->setNode('body', new Twig_Node_Body(array(
|
47 |
+
new Twig_Profiler_Node_EnterProfile($this->extensionName, Twig_Profiler_Profile::MACRO, $node->getAttribute('name'), $varName),
|
48 |
$node->getNode('body'),
|
49 |
+
new Twig_Profiler_Node_LeaveProfile($varName),
|
50 |
+
)));
|
51 |
}
|
52 |
|
53 |
return $node;
|
55 |
|
56 |
private function getVarName()
|
57 |
{
|
58 |
+
return sprintf('__internal_%s', hash('sha256', uniqid(mt_rand(), true), false));
|
59 |
}
|
60 |
|
61 |
public function getPriority()
|
63 |
return 0;
|
64 |
}
|
65 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Profiler/Profile.php
CHANGED
@@ -14,7 +14,7 @@
|
|
14 |
*
|
15 |
* @final
|
16 |
*/
|
17 |
-
class Twig_Profiler_Profile implements
|
18 |
{
|
19 |
const ROOT = 'ROOT';
|
20 |
const BLOCK = 'block';
|
@@ -24,9 +24,9 @@ class Twig_Profiler_Profile implements \IteratorAggregate, Serializable
|
|
24 |
private $template;
|
25 |
private $name;
|
26 |
private $type;
|
27 |
-
private $starts =
|
28 |
-
private $ends =
|
29 |
-
private $profiles =
|
30 |
|
31 |
public function __construct($template = 'main', $type = self::ROOT, $name = 'main')
|
32 |
{
|
@@ -76,7 +76,7 @@ class Twig_Profiler_Profile implements \IteratorAggregate, Serializable
|
|
76 |
return $this->profiles;
|
77 |
}
|
78 |
|
79 |
-
public function addProfile(
|
80 |
{
|
81 |
$this->profiles[] = $profile;
|
82 |
}
|
@@ -126,11 +126,11 @@ class Twig_Profiler_Profile implements \IteratorAggregate, Serializable
|
|
126 |
*/
|
127 |
public function enter()
|
128 |
{
|
129 |
-
$this->starts =
|
130 |
'wt' => microtime(true),
|
131 |
'mu' => memory_get_usage(),
|
132 |
'pmu' => memory_get_peak_usage(),
|
133 |
-
|
134 |
}
|
135 |
|
136 |
/**
|
@@ -138,27 +138,21 @@ class Twig_Profiler_Profile implements \IteratorAggregate, Serializable
|
|
138 |
*/
|
139 |
public function leave()
|
140 |
{
|
141 |
-
$this->ends =
|
142 |
'wt' => microtime(true),
|
143 |
'mu' => memory_get_usage(),
|
144 |
'pmu' => memory_get_peak_usage(),
|
145 |
-
|
146 |
-
}
|
147 |
-
|
148 |
-
public function reset()
|
149 |
-
{
|
150 |
-
$this->starts = $this->ends = $this->profiles = [];
|
151 |
-
$this->enter();
|
152 |
}
|
153 |
|
154 |
public function getIterator()
|
155 |
{
|
156 |
-
return new
|
157 |
}
|
158 |
|
159 |
public function serialize()
|
160 |
{
|
161 |
-
return serialize(
|
162 |
}
|
163 |
|
164 |
public function unserialize($data)
|
@@ -166,5 +160,3 @@ class Twig_Profiler_Profile implements \IteratorAggregate, Serializable
|
|
166 |
list($this->template, $this->name, $this->type, $this->starts, $this->ends, $this->profiles) = unserialize($data);
|
167 |
}
|
168 |
}
|
169 |
-
|
170 |
-
class_alias('Twig_Profiler_Profile', 'Twig\Profiler\Profile', false);
|
14 |
*
|
15 |
* @final
|
16 |
*/
|
17 |
+
class Twig_Profiler_Profile implements IteratorAggregate, Serializable
|
18 |
{
|
19 |
const ROOT = 'ROOT';
|
20 |
const BLOCK = 'block';
|
24 |
private $template;
|
25 |
private $name;
|
26 |
private $type;
|
27 |
+
private $starts = array();
|
28 |
+
private $ends = array();
|
29 |
+
private $profiles = array();
|
30 |
|
31 |
public function __construct($template = 'main', $type = self::ROOT, $name = 'main')
|
32 |
{
|
76 |
return $this->profiles;
|
77 |
}
|
78 |
|
79 |
+
public function addProfile(Twig_Profiler_Profile $profile)
|
80 |
{
|
81 |
$this->profiles[] = $profile;
|
82 |
}
|
126 |
*/
|
127 |
public function enter()
|
128 |
{
|
129 |
+
$this->starts = array(
|
130 |
'wt' => microtime(true),
|
131 |
'mu' => memory_get_usage(),
|
132 |
'pmu' => memory_get_peak_usage(),
|
133 |
+
);
|
134 |
}
|
135 |
|
136 |
/**
|
138 |
*/
|
139 |
public function leave()
|
140 |
{
|
141 |
+
$this->ends = array(
|
142 |
'wt' => microtime(true),
|
143 |
'mu' => memory_get_usage(),
|
144 |
'pmu' => memory_get_peak_usage(),
|
145 |
+
);
|
|
|
|
|
|
|
|
|
|
|
|
|
146 |
}
|
147 |
|
148 |
public function getIterator()
|
149 |
{
|
150 |
+
return new ArrayIterator($this->profiles);
|
151 |
}
|
152 |
|
153 |
public function serialize()
|
154 |
{
|
155 |
+
return serialize(array($this->template, $this->name, $this->type, $this->starts, $this->ends, $this->profiles));
|
156 |
}
|
157 |
|
158 |
public function unserialize($data)
|
160 |
list($this->template, $this->name, $this->type, $this->starts, $this->ends, $this->profiles) = unserialize($data);
|
161 |
}
|
162 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/RuntimeLoaderInterface.php
CHANGED
@@ -25,5 +25,3 @@ interface Twig_RuntimeLoaderInterface
|
|
25 |
*/
|
26 |
public function load($class);
|
27 |
}
|
28 |
-
|
29 |
-
class_alias('Twig_RuntimeLoaderInterface', 'Twig\RuntimeLoader\RuntimeLoaderInterface', false);
|
25 |
*/
|
26 |
public function load($class);
|
27 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Sandbox/SecurityError.php
CHANGED
@@ -9,15 +9,11 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Error\Error;
|
13 |
-
|
14 |
/**
|
15 |
* Exception thrown when a security error occurs at runtime.
|
16 |
*
|
17 |
* @author Fabien Potencier <fabien@symfony.com>
|
18 |
*/
|
19 |
-
class Twig_Sandbox_SecurityError extends
|
20 |
{
|
21 |
}
|
22 |
-
|
23 |
-
class_alias('Twig_Sandbox_SecurityError', 'Twig\Sandbox\SecurityError', false);
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
12 |
/**
|
13 |
* Exception thrown when a security error occurs at runtime.
|
14 |
*
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
+
class Twig_Sandbox_SecurityError extends Twig_Error
|
18 |
{
|
19 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Sandbox/SecurityNotAllowedFilterError.php
CHANGED
@@ -9,18 +9,16 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Sandbox\SecurityError;
|
13 |
-
|
14 |
/**
|
15 |
* Exception thrown when a not allowed filter is used in a template.
|
16 |
*
|
17 |
* @author Martin Hasoň <martin.hason@gmail.com>
|
18 |
*/
|
19 |
-
class Twig_Sandbox_SecurityNotAllowedFilterError extends
|
20 |
{
|
21 |
private $filterName;
|
22 |
|
23 |
-
public function __construct($message, $functionName, $lineno = -1, $filename = null,
|
24 |
{
|
25 |
parent::__construct($message, $lineno, $filename, $previous);
|
26 |
$this->filterName = $functionName;
|
@@ -31,5 +29,3 @@ class Twig_Sandbox_SecurityNotAllowedFilterError extends SecurityError
|
|
31 |
return $this->filterName;
|
32 |
}
|
33 |
}
|
34 |
-
|
35 |
-
class_alias('Twig_Sandbox_SecurityNotAllowedFilterError', 'Twig\Sandbox\SecurityNotAllowedFilterError', false);
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
12 |
/**
|
13 |
* Exception thrown when a not allowed filter is used in a template.
|
14 |
*
|
15 |
* @author Martin Hasoň <martin.hason@gmail.com>
|
16 |
*/
|
17 |
+
class Twig_Sandbox_SecurityNotAllowedFilterError extends Twig_Sandbox_SecurityError
|
18 |
{
|
19 |
private $filterName;
|
20 |
|
21 |
+
public function __construct($message, $functionName, $lineno = -1, $filename = null, Exception $previous = null)
|
22 |
{
|
23 |
parent::__construct($message, $lineno, $filename, $previous);
|
24 |
$this->filterName = $functionName;
|
29 |
return $this->filterName;
|
30 |
}
|
31 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Sandbox/SecurityNotAllowedFunctionError.php
CHANGED
@@ -9,18 +9,16 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Sandbox\SecurityError;
|
13 |
-
|
14 |
/**
|
15 |
* Exception thrown when a not allowed function is used in a template.
|
16 |
*
|
17 |
* @author Martin Hasoň <martin.hason@gmail.com>
|
18 |
*/
|
19 |
-
class Twig_Sandbox_SecurityNotAllowedFunctionError extends
|
20 |
{
|
21 |
private $functionName;
|
22 |
|
23 |
-
public function __construct($message, $functionName, $lineno = -1, $filename = null,
|
24 |
{
|
25 |
parent::__construct($message, $lineno, $filename, $previous);
|
26 |
$this->functionName = $functionName;
|
@@ -31,5 +29,3 @@ class Twig_Sandbox_SecurityNotAllowedFunctionError extends SecurityError
|
|
31 |
return $this->functionName;
|
32 |
}
|
33 |
}
|
34 |
-
|
35 |
-
class_alias('Twig_Sandbox_SecurityNotAllowedFunctionError', 'Twig\Sandbox\SecurityNotAllowedFunctionError', false);
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
12 |
/**
|
13 |
* Exception thrown when a not allowed function is used in a template.
|
14 |
*
|
15 |
* @author Martin Hasoň <martin.hason@gmail.com>
|
16 |
*/
|
17 |
+
class Twig_Sandbox_SecurityNotAllowedFunctionError extends Twig_Sandbox_SecurityError
|
18 |
{
|
19 |
private $functionName;
|
20 |
|
21 |
+
public function __construct($message, $functionName, $lineno = -1, $filename = null, Exception $previous = null)
|
22 |
{
|
23 |
parent::__construct($message, $lineno, $filename, $previous);
|
24 |
$this->functionName = $functionName;
|
29 |
return $this->functionName;
|
30 |
}
|
31 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Sandbox/SecurityNotAllowedMethodError.php
CHANGED
@@ -9,19 +9,17 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Sandbox\SecurityError;
|
13 |
-
|
14 |
/**
|
15 |
* Exception thrown when a not allowed class method is used in a template.
|
16 |
*
|
17 |
* @author Kit Burton-Senior <mail@kitbs.com>
|
18 |
*/
|
19 |
-
class Twig_Sandbox_SecurityNotAllowedMethodError extends
|
20 |
{
|
21 |
private $className;
|
22 |
private $methodName;
|
23 |
|
24 |
-
public function __construct($message, $className, $methodName, $lineno = -1, $filename = null,
|
25 |
{
|
26 |
parent::__construct($message, $lineno, $filename, $previous);
|
27 |
$this->className = $className;
|
@@ -38,5 +36,3 @@ class Twig_Sandbox_SecurityNotAllowedMethodError extends SecurityError
|
|
38 |
return $this->methodName;
|
39 |
}
|
40 |
}
|
41 |
-
|
42 |
-
class_alias('Twig_Sandbox_SecurityNotAllowedMethodError', 'Twig\Sandbox\SecurityNotAllowedMethodError', false);
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
12 |
/**
|
13 |
* Exception thrown when a not allowed class method is used in a template.
|
14 |
*
|
15 |
* @author Kit Burton-Senior <mail@kitbs.com>
|
16 |
*/
|
17 |
+
class Twig_Sandbox_SecurityNotAllowedMethodError extends Twig_Sandbox_SecurityError
|
18 |
{
|
19 |
private $className;
|
20 |
private $methodName;
|
21 |
|
22 |
+
public function __construct($message, $className, $methodName, $lineno = -1, $filename = null, Exception $previous = null)
|
23 |
{
|
24 |
parent::__construct($message, $lineno, $filename, $previous);
|
25 |
$this->className = $className;
|
36 |
return $this->methodName;
|
37 |
}
|
38 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Sandbox/SecurityNotAllowedPropertyError.php
CHANGED
@@ -9,19 +9,17 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Sandbox\SecurityError;
|
13 |
-
|
14 |
/**
|
15 |
* Exception thrown when a not allowed class property is used in a template.
|
16 |
*
|
17 |
* @author Kit Burton-Senior <mail@kitbs.com>
|
18 |
*/
|
19 |
-
class Twig_Sandbox_SecurityNotAllowedPropertyError extends
|
20 |
{
|
21 |
private $className;
|
22 |
private $propertyName;
|
23 |
|
24 |
-
public function __construct($message, $className, $propertyName, $lineno = -1, $filename = null,
|
25 |
{
|
26 |
parent::__construct($message, $lineno, $filename, $previous);
|
27 |
$this->className = $className;
|
@@ -38,5 +36,3 @@ class Twig_Sandbox_SecurityNotAllowedPropertyError extends SecurityError
|
|
38 |
return $this->propertyName;
|
39 |
}
|
40 |
}
|
41 |
-
|
42 |
-
class_alias('Twig_Sandbox_SecurityNotAllowedPropertyError', 'Twig\Sandbox\SecurityNotAllowedPropertyError', false);
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
12 |
/**
|
13 |
* Exception thrown when a not allowed class property is used in a template.
|
14 |
*
|
15 |
* @author Kit Burton-Senior <mail@kitbs.com>
|
16 |
*/
|
17 |
+
class Twig_Sandbox_SecurityNotAllowedPropertyError extends Twig_Sandbox_SecurityError
|
18 |
{
|
19 |
private $className;
|
20 |
private $propertyName;
|
21 |
|
22 |
+
public function __construct($message, $className, $propertyName, $lineno = -1, $filename = null, Exception $previous = null)
|
23 |
{
|
24 |
parent::__construct($message, $lineno, $filename, $previous);
|
25 |
$this->className = $className;
|
36 |
return $this->propertyName;
|
37 |
}
|
38 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Sandbox/SecurityNotAllowedTagError.php
CHANGED
@@ -9,18 +9,16 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Sandbox\SecurityError;
|
13 |
-
|
14 |
/**
|
15 |
* Exception thrown when a not allowed tag is used in a template.
|
16 |
*
|
17 |
* @author Martin Hasoň <martin.hason@gmail.com>
|
18 |
*/
|
19 |
-
class Twig_Sandbox_SecurityNotAllowedTagError extends
|
20 |
{
|
21 |
private $tagName;
|
22 |
|
23 |
-
public function __construct($message, $tagName, $lineno = -1, $filename = null,
|
24 |
{
|
25 |
parent::__construct($message, $lineno, $filename, $previous);
|
26 |
$this->tagName = $tagName;
|
@@ -31,5 +29,3 @@ class Twig_Sandbox_SecurityNotAllowedTagError extends SecurityError
|
|
31 |
return $this->tagName;
|
32 |
}
|
33 |
}
|
34 |
-
|
35 |
-
class_alias('Twig_Sandbox_SecurityNotAllowedTagError', 'Twig\Sandbox\SecurityNotAllowedTagError', false);
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
12 |
/**
|
13 |
* Exception thrown when a not allowed tag is used in a template.
|
14 |
*
|
15 |
* @author Martin Hasoň <martin.hason@gmail.com>
|
16 |
*/
|
17 |
+
class Twig_Sandbox_SecurityNotAllowedTagError extends Twig_Sandbox_SecurityError
|
18 |
{
|
19 |
private $tagName;
|
20 |
|
21 |
+
public function __construct($message, $tagName, $lineno = -1, $filename = null, Exception $previous = null)
|
22 |
{
|
23 |
parent::__construct($message, $lineno, $filename, $previous);
|
24 |
$this->tagName = $tagName;
|
29 |
return $this->tagName;
|
30 |
}
|
31 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Sandbox/SecurityPolicy.php
CHANGED
@@ -9,14 +9,6 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Markup;
|
13 |
-
use Twig\Sandbox\SecurityNotAllowedFilterError;
|
14 |
-
use Twig\Sandbox\SecurityNotAllowedFunctionError;
|
15 |
-
use Twig\Sandbox\SecurityNotAllowedMethodError;
|
16 |
-
use Twig\Sandbox\SecurityNotAllowedPropertyError;
|
17 |
-
use Twig\Sandbox\SecurityNotAllowedTagError;
|
18 |
-
use Twig\Sandbox\SecurityPolicyInterface;
|
19 |
-
|
20 |
/**
|
21 |
* Represents a security policy which need to be enforced when sandbox mode is enabled.
|
22 |
*
|
@@ -24,7 +16,7 @@ use Twig\Sandbox\SecurityPolicyInterface;
|
|
24 |
*
|
25 |
* @author Fabien Potencier <fabien@symfony.com>
|
26 |
*/
|
27 |
-
class Twig_Sandbox_SecurityPolicy implements
|
28 |
{
|
29 |
protected $allowedTags;
|
30 |
protected $allowedFilters;
|
@@ -32,7 +24,7 @@ class Twig_Sandbox_SecurityPolicy implements SecurityPolicyInterface
|
|
32 |
protected $allowedProperties;
|
33 |
protected $allowedFunctions;
|
34 |
|
35 |
-
public function __construct(array $allowedTags =
|
36 |
{
|
37 |
$this->allowedTags = $allowedTags;
|
38 |
$this->allowedFilters = $allowedFilters;
|
@@ -53,9 +45,9 @@ class Twig_Sandbox_SecurityPolicy implements SecurityPolicyInterface
|
|
53 |
|
54 |
public function setAllowedMethods(array $methods)
|
55 |
{
|
56 |
-
$this->allowedMethods =
|
57 |
foreach ($methods as $class => $m) {
|
58 |
-
$this->allowedMethods[$class] = array_map('strtolower',
|
59 |
}
|
60 |
}
|
61 |
|
@@ -72,27 +64,27 @@ class Twig_Sandbox_SecurityPolicy implements SecurityPolicyInterface
|
|
72 |
public function checkSecurity($tags, $filters, $functions)
|
73 |
{
|
74 |
foreach ($tags as $tag) {
|
75 |
-
if (
|
76 |
-
throw new
|
77 |
}
|
78 |
}
|
79 |
|
80 |
foreach ($filters as $filter) {
|
81 |
-
if (
|
82 |
-
throw new
|
83 |
}
|
84 |
}
|
85 |
|
86 |
foreach ($functions as $function) {
|
87 |
-
if (
|
88 |
-
throw new
|
89 |
}
|
90 |
}
|
91 |
}
|
92 |
|
93 |
public function checkMethodAllowed($obj, $method)
|
94 |
{
|
95 |
-
if ($obj instanceof Twig_TemplateInterface || $obj instanceof
|
96 |
return true;
|
97 |
}
|
98 |
|
@@ -100,15 +92,15 @@ class Twig_Sandbox_SecurityPolicy implements SecurityPolicyInterface
|
|
100 |
$method = strtolower($method);
|
101 |
foreach ($this->allowedMethods as $class => $methods) {
|
102 |
if ($obj instanceof $class) {
|
103 |
-
$allowed =
|
104 |
|
105 |
break;
|
106 |
}
|
107 |
}
|
108 |
|
109 |
if (!$allowed) {
|
110 |
-
$class =
|
111 |
-
throw new
|
112 |
}
|
113 |
}
|
114 |
|
@@ -117,17 +109,15 @@ class Twig_Sandbox_SecurityPolicy implements SecurityPolicyInterface
|
|
117 |
$allowed = false;
|
118 |
foreach ($this->allowedProperties as $class => $properties) {
|
119 |
if ($obj instanceof $class) {
|
120 |
-
$allowed =
|
121 |
|
122 |
break;
|
123 |
}
|
124 |
}
|
125 |
|
126 |
if (!$allowed) {
|
127 |
-
$class =
|
128 |
-
throw new
|
129 |
}
|
130 |
}
|
131 |
}
|
132 |
-
|
133 |
-
class_alias('Twig_Sandbox_SecurityPolicy', 'Twig\Sandbox\SecurityPolicy', false);
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
/**
|
13 |
* Represents a security policy which need to be enforced when sandbox mode is enabled.
|
14 |
*
|
16 |
*
|
17 |
* @author Fabien Potencier <fabien@symfony.com>
|
18 |
*/
|
19 |
+
class Twig_Sandbox_SecurityPolicy implements Twig_Sandbox_SecurityPolicyInterface
|
20 |
{
|
21 |
protected $allowedTags;
|
22 |
protected $allowedFilters;
|
24 |
protected $allowedProperties;
|
25 |
protected $allowedFunctions;
|
26 |
|
27 |
+
public function __construct(array $allowedTags = array(), array $allowedFilters = array(), array $allowedMethods = array(), array $allowedProperties = array(), array $allowedFunctions = array())
|
28 |
{
|
29 |
$this->allowedTags = $allowedTags;
|
30 |
$this->allowedFilters = $allowedFilters;
|
45 |
|
46 |
public function setAllowedMethods(array $methods)
|
47 |
{
|
48 |
+
$this->allowedMethods = array();
|
49 |
foreach ($methods as $class => $m) {
|
50 |
+
$this->allowedMethods[$class] = array_map('strtolower', is_array($m) ? $m : array($m));
|
51 |
}
|
52 |
}
|
53 |
|
64 |
public function checkSecurity($tags, $filters, $functions)
|
65 |
{
|
66 |
foreach ($tags as $tag) {
|
67 |
+
if (!in_array($tag, $this->allowedTags)) {
|
68 |
+
throw new Twig_Sandbox_SecurityNotAllowedTagError(sprintf('Tag "%s" is not allowed.', $tag), $tag);
|
69 |
}
|
70 |
}
|
71 |
|
72 |
foreach ($filters as $filter) {
|
73 |
+
if (!in_array($filter, $this->allowedFilters)) {
|
74 |
+
throw new Twig_Sandbox_SecurityNotAllowedFilterError(sprintf('Filter "%s" is not allowed.', $filter), $filter);
|
75 |
}
|
76 |
}
|
77 |
|
78 |
foreach ($functions as $function) {
|
79 |
+
if (!in_array($function, $this->allowedFunctions)) {
|
80 |
+
throw new Twig_Sandbox_SecurityNotAllowedFunctionError(sprintf('Function "%s" is not allowed.', $function), $function);
|
81 |
}
|
82 |
}
|
83 |
}
|
84 |
|
85 |
public function checkMethodAllowed($obj, $method)
|
86 |
{
|
87 |
+
if ($obj instanceof Twig_TemplateInterface || $obj instanceof Twig_Markup) {
|
88 |
return true;
|
89 |
}
|
90 |
|
92 |
$method = strtolower($method);
|
93 |
foreach ($this->allowedMethods as $class => $methods) {
|
94 |
if ($obj instanceof $class) {
|
95 |
+
$allowed = in_array($method, $methods);
|
96 |
|
97 |
break;
|
98 |
}
|
99 |
}
|
100 |
|
101 |
if (!$allowed) {
|
102 |
+
$class = get_class($obj);
|
103 |
+
throw new Twig_Sandbox_SecurityNotAllowedMethodError(sprintf('Calling "%s" method on a "%s" object is not allowed.', $method, $class), $class, $method);
|
104 |
}
|
105 |
}
|
106 |
|
109 |
$allowed = false;
|
110 |
foreach ($this->allowedProperties as $class => $properties) {
|
111 |
if ($obj instanceof $class) {
|
112 |
+
$allowed = in_array($property, is_array($properties) ? $properties : array($properties));
|
113 |
|
114 |
break;
|
115 |
}
|
116 |
}
|
117 |
|
118 |
if (!$allowed) {
|
119 |
+
$class = get_class($obj);
|
120 |
+
throw new Twig_Sandbox_SecurityNotAllowedPropertyError(sprintf('Calling "%s" property on a "%s" object is not allowed.', $property, $class), $class, $property);
|
121 |
}
|
122 |
}
|
123 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Sandbox/SecurityPolicyInterface.php
CHANGED
@@ -22,5 +22,3 @@ interface Twig_Sandbox_SecurityPolicyInterface
|
|
22 |
|
23 |
public function checkPropertyAllowed($obj, $method);
|
24 |
}
|
25 |
-
|
26 |
-
class_alias('Twig_Sandbox_SecurityPolicyInterface', 'Twig\Sandbox\SecurityPolicyInterface', false);
|
22 |
|
23 |
public function checkPropertyAllowed($obj, $method);
|
24 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/SimpleFilter.php
CHANGED
@@ -9,8 +9,6 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Node\Node;
|
13 |
-
|
14 |
/**
|
15 |
* Represents a template filter.
|
16 |
*
|
@@ -23,13 +21,13 @@ class Twig_SimpleFilter
|
|
23 |
protected $name;
|
24 |
protected $callable;
|
25 |
protected $options;
|
26 |
-
protected $arguments =
|
27 |
|
28 |
-
public function __construct($name, $callable, array $options =
|
29 |
{
|
30 |
$this->name = $name;
|
31 |
$this->callable = $callable;
|
32 |
-
$this->options = array_merge(
|
33 |
'needs_environment' => false,
|
34 |
'needs_context' => false,
|
35 |
'is_variadic' => false,
|
@@ -37,10 +35,10 @@ class Twig_SimpleFilter
|
|
37 |
'is_safe_callback' => null,
|
38 |
'pre_escape' => null,
|
39 |
'preserves_safety' => null,
|
40 |
-
'node_class' => '
|
41 |
'deprecated' => false,
|
42 |
'alternative' => null,
|
43 |
-
|
44 |
}
|
45 |
|
46 |
public function getName()
|
@@ -78,14 +76,14 @@ class Twig_SimpleFilter
|
|
78 |
return $this->options['needs_context'];
|
79 |
}
|
80 |
|
81 |
-
public function getSafe(
|
82 |
{
|
83 |
if (null !== $this->options['is_safe']) {
|
84 |
return $this->options['is_safe'];
|
85 |
}
|
86 |
|
87 |
if (null !== $this->options['is_safe_callback']) {
|
88 |
-
return
|
89 |
}
|
90 |
}
|
91 |
|
@@ -119,5 +117,3 @@ class Twig_SimpleFilter
|
|
119 |
return $this->options['alternative'];
|
120 |
}
|
121 |
}
|
122 |
-
|
123 |
-
class_alias('Twig_SimpleFilter', 'Twig\TwigFilter', false);
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
12 |
/**
|
13 |
* Represents a template filter.
|
14 |
*
|
21 |
protected $name;
|
22 |
protected $callable;
|
23 |
protected $options;
|
24 |
+
protected $arguments = array();
|
25 |
|
26 |
+
public function __construct($name, $callable, array $options = array())
|
27 |
{
|
28 |
$this->name = $name;
|
29 |
$this->callable = $callable;
|
30 |
+
$this->options = array_merge(array(
|
31 |
'needs_environment' => false,
|
32 |
'needs_context' => false,
|
33 |
'is_variadic' => false,
|
35 |
'is_safe_callback' => null,
|
36 |
'pre_escape' => null,
|
37 |
'preserves_safety' => null,
|
38 |
+
'node_class' => 'Twig_Node_Expression_Filter',
|
39 |
'deprecated' => false,
|
40 |
'alternative' => null,
|
41 |
+
), $options);
|
42 |
}
|
43 |
|
44 |
public function getName()
|
76 |
return $this->options['needs_context'];
|
77 |
}
|
78 |
|
79 |
+
public function getSafe(Twig_Node $filterArgs)
|
80 |
{
|
81 |
if (null !== $this->options['is_safe']) {
|
82 |
return $this->options['is_safe'];
|
83 |
}
|
84 |
|
85 |
if (null !== $this->options['is_safe_callback']) {
|
86 |
+
return call_user_func($this->options['is_safe_callback'], $filterArgs);
|
87 |
}
|
88 |
}
|
89 |
|
117 |
return $this->options['alternative'];
|
118 |
}
|
119 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/SimpleFunction.php
CHANGED
@@ -9,8 +9,6 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Node\Node;
|
13 |
-
|
14 |
/**
|
15 |
* Represents a template function.
|
16 |
*
|
@@ -23,22 +21,22 @@ class Twig_SimpleFunction
|
|
23 |
protected $name;
|
24 |
protected $callable;
|
25 |
protected $options;
|
26 |
-
protected $arguments =
|
27 |
|
28 |
-
public function __construct($name, $callable, array $options =
|
29 |
{
|
30 |
$this->name = $name;
|
31 |
$this->callable = $callable;
|
32 |
-
$this->options = array_merge(
|
33 |
'needs_environment' => false,
|
34 |
'needs_context' => false,
|
35 |
'is_variadic' => false,
|
36 |
'is_safe' => null,
|
37 |
'is_safe_callback' => null,
|
38 |
-
'node_class' => '
|
39 |
'deprecated' => false,
|
40 |
'alternative' => null,
|
41 |
-
|
42 |
}
|
43 |
|
44 |
public function getName()
|
@@ -76,17 +74,17 @@ class Twig_SimpleFunction
|
|
76 |
return $this->options['needs_context'];
|
77 |
}
|
78 |
|
79 |
-
public function getSafe(
|
80 |
{
|
81 |
if (null !== $this->options['is_safe']) {
|
82 |
return $this->options['is_safe'];
|
83 |
}
|
84 |
|
85 |
if (null !== $this->options['is_safe_callback']) {
|
86 |
-
return
|
87 |
}
|
88 |
|
89 |
-
return
|
90 |
}
|
91 |
|
92 |
public function isVariadic()
|
@@ -109,5 +107,3 @@ class Twig_SimpleFunction
|
|
109 |
return $this->options['alternative'];
|
110 |
}
|
111 |
}
|
112 |
-
|
113 |
-
class_alias('Twig_SimpleFunction', 'Twig\TwigFunction', false);
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
12 |
/**
|
13 |
* Represents a template function.
|
14 |
*
|
21 |
protected $name;
|
22 |
protected $callable;
|
23 |
protected $options;
|
24 |
+
protected $arguments = array();
|
25 |
|
26 |
+
public function __construct($name, $callable, array $options = array())
|
27 |
{
|
28 |
$this->name = $name;
|
29 |
$this->callable = $callable;
|
30 |
+
$this->options = array_merge(array(
|
31 |
'needs_environment' => false,
|
32 |
'needs_context' => false,
|
33 |
'is_variadic' => false,
|
34 |
'is_safe' => null,
|
35 |
'is_safe_callback' => null,
|
36 |
+
'node_class' => 'Twig_Node_Expression_Function',
|
37 |
'deprecated' => false,
|
38 |
'alternative' => null,
|
39 |
+
), $options);
|
40 |
}
|
41 |
|
42 |
public function getName()
|
74 |
return $this->options['needs_context'];
|
75 |
}
|
76 |
|
77 |
+
public function getSafe(Twig_Node $functionArgs)
|
78 |
{
|
79 |
if (null !== $this->options['is_safe']) {
|
80 |
return $this->options['is_safe'];
|
81 |
}
|
82 |
|
83 |
if (null !== $this->options['is_safe_callback']) {
|
84 |
+
return call_user_func($this->options['is_safe_callback'], $functionArgs);
|
85 |
}
|
86 |
|
87 |
+
return array();
|
88 |
}
|
89 |
|
90 |
public function isVariadic()
|
107 |
return $this->options['alternative'];
|
108 |
}
|
109 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/SimpleTest.php
CHANGED
@@ -22,18 +22,16 @@ class Twig_SimpleTest
|
|
22 |
protected $callable;
|
23 |
protected $options;
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
public function __construct($name, $callable, array $options = [])
|
28 |
{
|
29 |
$this->name = $name;
|
30 |
$this->callable = $callable;
|
31 |
-
$this->options = array_merge(
|
32 |
'is_variadic' => false,
|
33 |
-
'node_class' => '
|
34 |
'deprecated' => false,
|
35 |
'alternative' => null,
|
36 |
-
|
37 |
}
|
38 |
|
39 |
public function getName()
|
@@ -70,16 +68,4 @@ class Twig_SimpleTest
|
|
70 |
{
|
71 |
return $this->options['alternative'];
|
72 |
}
|
73 |
-
|
74 |
-
public function setArguments($arguments)
|
75 |
-
{
|
76 |
-
$this->arguments = $arguments;
|
77 |
-
}
|
78 |
-
|
79 |
-
public function getArguments()
|
80 |
-
{
|
81 |
-
return $this->arguments;
|
82 |
-
}
|
83 |
}
|
84 |
-
|
85 |
-
class_alias('Twig_SimpleTest', 'Twig\TwigTest', false);
|
22 |
protected $callable;
|
23 |
protected $options;
|
24 |
|
25 |
+
public function __construct($name, $callable, array $options = array())
|
|
|
|
|
26 |
{
|
27 |
$this->name = $name;
|
28 |
$this->callable = $callable;
|
29 |
+
$this->options = array_merge(array(
|
30 |
'is_variadic' => false,
|
31 |
+
'node_class' => 'Twig_Node_Expression_Test',
|
32 |
'deprecated' => false,
|
33 |
'alternative' => null,
|
34 |
+
), $options);
|
35 |
}
|
36 |
|
37 |
public function getName()
|
68 |
{
|
69 |
return $this->options['alternative'];
|
70 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Source.php
CHANGED
@@ -49,5 +49,3 @@ class Twig_Source
|
|
49 |
return $this->path;
|
50 |
}
|
51 |
}
|
52 |
-
|
53 |
-
class_alias('Twig_Source', 'Twig\Source', false);
|
49 |
return $this->path;
|
50 |
}
|
51 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/SourceContextLoaderInterface.php
CHANGED
@@ -9,9 +9,6 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Error\LoaderError;
|
13 |
-
use Twig\Source;
|
14 |
-
|
15 |
/**
|
16 |
* Adds a getSourceContext() method for loaders.
|
17 |
*
|
@@ -26,11 +23,9 @@ interface Twig_SourceContextLoaderInterface
|
|
26 |
*
|
27 |
* @param string $name The template logical name
|
28 |
*
|
29 |
-
* @return
|
30 |
*
|
31 |
-
* @throws
|
32 |
*/
|
33 |
public function getSourceContext($name);
|
34 |
}
|
35 |
-
|
36 |
-
class_alias('Twig_SourceContextLoaderInterface', 'Twig\Loader\SourceContextLoaderInterface', false);
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
|
|
12 |
/**
|
13 |
* Adds a getSourceContext() method for loaders.
|
14 |
*
|
23 |
*
|
24 |
* @param string $name The template logical name
|
25 |
*
|
26 |
+
* @return Twig_Source
|
27 |
*
|
28 |
+
* @throws Twig_Error_Loader When $name is not found
|
29 |
*/
|
30 |
public function getSourceContext($name);
|
31 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Template.php
CHANGED
@@ -10,14 +10,6 @@
|
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
|
13 |
-
use Twig\Environment;
|
14 |
-
use Twig\Error\Error;
|
15 |
-
use Twig\Error\LoaderError;
|
16 |
-
use Twig\Error\RuntimeError;
|
17 |
-
use Twig\Markup;
|
18 |
-
use Twig\Source;
|
19 |
-
use Twig\TemplateWrapper;
|
20 |
-
|
21 |
/**
|
22 |
* Default base class for compiled templates.
|
23 |
*
|
@@ -34,15 +26,15 @@ abstract class Twig_Template implements Twig_TemplateInterface
|
|
34 |
/**
|
35 |
* @internal
|
36 |
*/
|
37 |
-
protected static $cache =
|
38 |
|
39 |
protected $parent;
|
40 |
-
protected $parents =
|
41 |
protected $env;
|
42 |
-
protected $blocks =
|
43 |
-
protected $traits =
|
44 |
|
45 |
-
public function __construct(
|
46 |
{
|
47 |
$this->env = $env;
|
48 |
}
|
@@ -71,7 +63,7 @@ abstract class Twig_Template implements Twig_TemplateInterface
|
|
71 |
*/
|
72 |
public function getDebugInfo()
|
73 |
{
|
74 |
-
return
|
75 |
}
|
76 |
|
77 |
/**
|
@@ -91,11 +83,11 @@ abstract class Twig_Template implements Twig_TemplateInterface
|
|
91 |
/**
|
92 |
* Returns information about the original template source code.
|
93 |
*
|
94 |
-
* @return
|
95 |
*/
|
96 |
public function getSourceContext()
|
97 |
{
|
98 |
-
return new
|
99 |
}
|
100 |
|
101 |
/**
|
@@ -116,7 +108,7 @@ abstract class Twig_Template implements Twig_TemplateInterface
|
|
116 |
*
|
117 |
* @param array $context
|
118 |
*
|
119 |
-
* @return Twig_TemplateInterface|
|
120 |
*
|
121 |
* @internal
|
122 |
*/
|
@@ -133,14 +125,14 @@ abstract class Twig_Template implements Twig_TemplateInterface
|
|
133 |
return false;
|
134 |
}
|
135 |
|
136 |
-
if ($parent instanceof self
|
137 |
-
return $this->parents[$parent->
|
138 |
}
|
139 |
|
140 |
if (!isset($this->parents[$parent])) {
|
141 |
$this->parents[$parent] = $this->loadTemplate($parent);
|
142 |
}
|
143 |
-
} catch (
|
144 |
$e->setSourceContext(null);
|
145 |
$e->guess();
|
146 |
|
@@ -172,7 +164,7 @@ abstract class Twig_Template implements Twig_TemplateInterface
|
|
172 |
*
|
173 |
* @internal
|
174 |
*/
|
175 |
-
public function displayParentBlock($name, array $context, array $blocks =
|
176 |
{
|
177 |
$name = (string) $name;
|
178 |
|
@@ -181,7 +173,7 @@ abstract class Twig_Template implements Twig_TemplateInterface
|
|
181 |
} elseif (false !== $parent = $this->getParent($context)) {
|
182 |
$parent->displayBlock($name, $context, $blocks, false);
|
183 |
} else {
|
184 |
-
throw new
|
185 |
}
|
186 |
}
|
187 |
|
@@ -198,7 +190,7 @@ abstract class Twig_Template implements Twig_TemplateInterface
|
|
198 |
*
|
199 |
* @internal
|
200 |
*/
|
201 |
-
public function displayBlock($name, array $context, array $blocks =
|
202 |
{
|
203 |
$name = (string) $name;
|
204 |
|
@@ -215,13 +207,13 @@ abstract class Twig_Template implements Twig_TemplateInterface
|
|
215 |
|
216 |
// avoid RCEs when sandbox is enabled
|
217 |
if (null !== $template && !$template instanceof self) {
|
218 |
-
throw new
|
219 |
}
|
220 |
|
221 |
if (null !== $template) {
|
222 |
try {
|
223 |
$template->$block($context, $blocks);
|
224 |
-
} catch (
|
225 |
if (!$e->getSourceContext()) {
|
226 |
$e->setSourceContext($template->getSourceContext());
|
227 |
}
|
@@ -234,8 +226,8 @@ abstract class Twig_Template implements Twig_TemplateInterface
|
|
234 |
}
|
235 |
|
236 |
throw $e;
|
237 |
-
} catch (
|
238 |
-
throw new
|
239 |
}
|
240 |
} elseif (false !== $parent = $this->getParent($context)) {
|
241 |
$parent->displayBlock($name, $context, array_merge($this->blocks, $blocks), false);
|
@@ -258,7 +250,7 @@ abstract class Twig_Template implements Twig_TemplateInterface
|
|
258 |
*
|
259 |
* @internal
|
260 |
*/
|
261 |
-
public function renderParentBlock($name, array $context, array $blocks =
|
262 |
{
|
263 |
ob_start();
|
264 |
$this->displayParentBlock($name, $context, $blocks);
|
@@ -281,7 +273,7 @@ abstract class Twig_Template implements Twig_TemplateInterface
|
|
281 |
*
|
282 |
* @internal
|
283 |
*/
|
284 |
-
public function renderBlock($name, array $context, array $blocks =
|
285 |
{
|
286 |
ob_start();
|
287 |
$this->displayBlock($name, $context, $blocks, $useBlocks);
|
@@ -303,7 +295,7 @@ abstract class Twig_Template implements Twig_TemplateInterface
|
|
303 |
*
|
304 |
* @internal
|
305 |
*/
|
306 |
-
public function hasBlock($name, array $context = null, array $blocks =
|
307 |
{
|
308 |
if (null === $context) {
|
309 |
@trigger_error('The '.__METHOD__.' method is internal and should never be called; calling it directly is deprecated since version 1.28 and won\'t be possible anymore in 2.0.', E_USER_DEPRECATED);
|
@@ -339,7 +331,7 @@ abstract class Twig_Template implements Twig_TemplateInterface
|
|
339 |
*
|
340 |
* @internal
|
341 |
*/
|
342 |
-
public function getBlockNames(array $context = null, array $blocks =
|
343 |
{
|
344 |
if (null === $context) {
|
345 |
@trigger_error('The '.__METHOD__.' method is internal and should never be called; calling it directly is deprecated since version 1.28 and won\'t be possible anymore in 2.0.', E_USER_DEPRECATED);
|
@@ -359,18 +351,22 @@ abstract class Twig_Template implements Twig_TemplateInterface
|
|
359 |
protected function loadTemplate($template, $templateName = null, $line = null, $index = null)
|
360 |
{
|
361 |
try {
|
362 |
-
if (
|
363 |
return $this->env->resolveTemplate($template);
|
364 |
}
|
365 |
|
366 |
-
if ($template instanceof self
|
|
|
|
|
|
|
|
|
367 |
return $template;
|
368 |
}
|
369 |
|
370 |
return $this->env->loadTemplate($template, $index);
|
371 |
-
} catch (
|
372 |
if (!$e->getSourceContext()) {
|
373 |
-
$e->setSourceContext($templateName ? new
|
374 |
}
|
375 |
|
376 |
if ($e->getTemplateLine()) {
|
@@ -402,7 +398,7 @@ abstract class Twig_Template implements Twig_TemplateInterface
|
|
402 |
return $this->blocks;
|
403 |
}
|
404 |
|
405 |
-
public function display(array $context, array $blocks =
|
406 |
{
|
407 |
$this->displayWithErrorHandling($this->env->mergeGlobals($context), array_merge($this->blocks, $blocks));
|
408 |
}
|
@@ -413,13 +409,13 @@ abstract class Twig_Template implements Twig_TemplateInterface
|
|
413 |
ob_start();
|
414 |
try {
|
415 |
$this->display($context);
|
416 |
-
} catch (
|
417 |
while (ob_get_level() > $level) {
|
418 |
ob_end_clean();
|
419 |
}
|
420 |
|
421 |
throw $e;
|
422 |
-
} catch (
|
423 |
while (ob_get_level() > $level) {
|
424 |
ob_end_clean();
|
425 |
}
|
@@ -430,11 +426,11 @@ abstract class Twig_Template implements Twig_TemplateInterface
|
|
430 |
return ob_get_clean();
|
431 |
}
|
432 |
|
433 |
-
protected function displayWithErrorHandling(array $context, array $blocks =
|
434 |
{
|
435 |
try {
|
436 |
$this->doDisplay($context, $blocks);
|
437 |
-
} catch (
|
438 |
if (!$e->getSourceContext()) {
|
439 |
$e->setSourceContext($this->getSourceContext());
|
440 |
}
|
@@ -447,8 +443,8 @@ abstract class Twig_Template implements Twig_TemplateInterface
|
|
447 |
}
|
448 |
|
449 |
throw $e;
|
450 |
-
} catch (
|
451 |
-
throw new
|
452 |
}
|
453 |
}
|
454 |
|
@@ -458,7 +454,7 @@ abstract class Twig_Template implements Twig_TemplateInterface
|
|
458 |
* @param array $context An array of parameters to pass to the template
|
459 |
* @param array $blocks An array of blocks to pass to the template
|
460 |
*/
|
461 |
-
abstract protected function doDisplay(array $context, array $blocks =
|
462 |
|
463 |
/**
|
464 |
* Returns a variable from the context.
|
@@ -477,18 +473,18 @@ abstract class Twig_Template implements Twig_TemplateInterface
|
|
477 |
*
|
478 |
* @return mixed The content of the context variable
|
479 |
*
|
480 |
-
* @throws
|
481 |
*
|
482 |
* @internal
|
483 |
*/
|
484 |
final protected function getContext($context, $item, $ignoreStrictCheck = false)
|
485 |
{
|
486 |
-
if (
|
487 |
if ($ignoreStrictCheck || !$this->env->isStrictVariables()) {
|
488 |
return;
|
489 |
}
|
490 |
|
491 |
-
throw new
|
492 |
}
|
493 |
|
494 |
return $context[$item];
|
@@ -506,17 +502,17 @@ abstract class Twig_Template implements Twig_TemplateInterface
|
|
506 |
*
|
507 |
* @return mixed The attribute value, or a Boolean when $isDefinedTest is true, or null when the attribute is not set and $ignoreStrictCheck is true
|
508 |
*
|
509 |
-
* @throws
|
510 |
*
|
511 |
* @internal
|
512 |
*/
|
513 |
-
protected function getAttribute($object, $item, array $arguments =
|
514 |
{
|
515 |
// array
|
516 |
if (self::METHOD_CALL !== $type) {
|
517 |
-
$arrayItem =
|
518 |
|
519 |
-
if ((
|
520 |
|| ($object instanceof ArrayAccess && isset($object[$arrayItem]))
|
521 |
) {
|
522 |
if ($isDefinedTest) {
|
@@ -526,7 +522,7 @@ abstract class Twig_Template implements Twig_TemplateInterface
|
|
526 |
return $object[$arrayItem];
|
527 |
}
|
528 |
|
529 |
-
if (self::ARRAY_CALL === $type ||
|
530 |
if ($isDefinedTest) {
|
531 |
return false;
|
532 |
}
|
@@ -536,10 +532,10 @@ abstract class Twig_Template implements Twig_TemplateInterface
|
|
536 |
}
|
537 |
|
538 |
if ($object instanceof ArrayAccess) {
|
539 |
-
$message = sprintf('Key "%s" in object with ArrayAccess of class "%s" does not exist.', $arrayItem,
|
540 |
-
} elseif (
|
541 |
-
$message = sprintf('Impossible to access a key "%s" on an object of class "%s" that does not implement ArrayAccess interface.', $item,
|
542 |
-
} elseif (
|
543 |
if (empty($object)) {
|
544 |
$message = sprintf('Key "%s" does not exist as the array is empty.', $arrayItem);
|
545 |
} else {
|
@@ -549,19 +545,19 @@ abstract class Twig_Template implements Twig_TemplateInterface
|
|
549 |
if (null === $object) {
|
550 |
$message = sprintf('Impossible to access a key ("%s") on a null variable.', $item);
|
551 |
} else {
|
552 |
-
$message = sprintf('Impossible to access a key ("%s") on a %s variable ("%s").', $item,
|
553 |
}
|
554 |
} elseif (null === $object) {
|
555 |
$message = sprintf('Impossible to access an attribute ("%s") on a null variable.', $item);
|
556 |
} else {
|
557 |
-
$message = sprintf('Impossible to access an attribute ("%s") on a %s variable ("%s").', $item,
|
558 |
}
|
559 |
|
560 |
-
throw new
|
561 |
}
|
562 |
}
|
563 |
|
564 |
-
if (
|
565 |
if ($isDefinedTest) {
|
566 |
return false;
|
567 |
}
|
@@ -572,40 +568,38 @@ abstract class Twig_Template implements Twig_TemplateInterface
|
|
572 |
|
573 |
if (null === $object) {
|
574 |
$message = sprintf('Impossible to invoke a method ("%s") on a null variable.', $item);
|
575 |
-
} elseif (\is_array($object)) {
|
576 |
-
$message = sprintf('Impossible to invoke a method ("%s") on an array.', $item);
|
577 |
} else {
|
578 |
-
$message = sprintf('Impossible to invoke a method ("%s") on a %s variable ("%s").', $item,
|
579 |
}
|
580 |
|
581 |
-
throw new
|
582 |
}
|
583 |
|
584 |
// object property
|
585 |
if (self::METHOD_CALL !== $type && !$object instanceof self) { // Twig_Template does not have public properties, and we don't want to allow access to internal ones
|
586 |
-
if (isset($object->$item) ||
|
587 |
if ($isDefinedTest) {
|
588 |
return true;
|
589 |
}
|
590 |
|
591 |
-
if ($this->env->hasExtension('
|
592 |
-
$this->env->getExtension('
|
593 |
}
|
594 |
|
595 |
return $object->$item;
|
596 |
}
|
597 |
}
|
598 |
|
599 |
-
$class =
|
600 |
|
601 |
// object method
|
602 |
if (!isset(self::$cache[$class])) {
|
603 |
// get_class_methods returns all methods accessible in the scope, but we only want public ones to be accessible in templates
|
604 |
if ($object instanceof self) {
|
605 |
-
$ref = new
|
606 |
-
$methods =
|
607 |
|
608 |
-
foreach ($ref->getMethods(
|
609 |
// Accessing the environment from templates is forbidden to prevent untrusted changes to the environment
|
610 |
if ('getenvironment' !== strtolower($refMethod->name)) {
|
611 |
$methods[] = $refMethod->name;
|
@@ -617,7 +611,7 @@ abstract class Twig_Template implements Twig_TemplateInterface
|
|
617 |
// sort values to have consistent behavior, so that "get" methods win precedence over "is" methods
|
618 |
sort($methods);
|
619 |
|
620 |
-
$cache =
|
621 |
|
622 |
foreach ($methods as $method) {
|
623 |
$cache[$method] = $method;
|
@@ -633,14 +627,11 @@ abstract class Twig_Template implements Twig_TemplateInterface
|
|
633 |
continue;
|
634 |
}
|
635 |
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
if (!isset($cache[$lcName])) {
|
642 |
-
$cache[$lcName] = $method;
|
643 |
-
}
|
644 |
}
|
645 |
}
|
646 |
self::$cache[$class] = $cache;
|
@@ -663,15 +654,15 @@ abstract class Twig_Template implements Twig_TemplateInterface
|
|
663 |
return;
|
664 |
}
|
665 |
|
666 |
-
throw new
|
667 |
}
|
668 |
|
669 |
if ($isDefinedTest) {
|
670 |
return true;
|
671 |
}
|
672 |
|
673 |
-
if ($this->env->hasExtension('
|
674 |
-
$this->env->getExtension('
|
675 |
}
|
676 |
|
677 |
// Some objects throw exceptions when they have __call, and the method we try
|
@@ -680,9 +671,9 @@ abstract class Twig_Template implements Twig_TemplateInterface
|
|
680 |
if (!$arguments) {
|
681 |
$ret = $object->$method();
|
682 |
} else {
|
683 |
-
$ret =
|
684 |
}
|
685 |
-
} catch (
|
686 |
if ($call && ($ignoreStrictCheck || !$this->env->isStrictVariables())) {
|
687 |
return;
|
688 |
}
|
@@ -702,11 +693,9 @@ abstract class Twig_Template implements Twig_TemplateInterface
|
|
702 |
}
|
703 |
@trigger_error($message, E_USER_DEPRECATED);
|
704 |
|
705 |
-
return
|
706 |
}
|
707 |
|
708 |
return $ret;
|
709 |
}
|
710 |
}
|
711 |
-
|
712 |
-
class_alias('Twig_Template', 'Twig\Template', false);
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
/**
|
14 |
* Default base class for compiled templates.
|
15 |
*
|
26 |
/**
|
27 |
* @internal
|
28 |
*/
|
29 |
+
protected static $cache = array();
|
30 |
|
31 |
protected $parent;
|
32 |
+
protected $parents = array();
|
33 |
protected $env;
|
34 |
+
protected $blocks = array();
|
35 |
+
protected $traits = array();
|
36 |
|
37 |
+
public function __construct(Twig_Environment $env)
|
38 |
{
|
39 |
$this->env = $env;
|
40 |
}
|
63 |
*/
|
64 |
public function getDebugInfo()
|
65 |
{
|
66 |
+
return array();
|
67 |
}
|
68 |
|
69 |
/**
|
83 |
/**
|
84 |
* Returns information about the original template source code.
|
85 |
*
|
86 |
+
* @return Twig_Source
|
87 |
*/
|
88 |
public function getSourceContext()
|
89 |
{
|
90 |
+
return new Twig_Source('', $this->getTemplateName());
|
91 |
}
|
92 |
|
93 |
/**
|
108 |
*
|
109 |
* @param array $context
|
110 |
*
|
111 |
+
* @return Twig_TemplateInterface|false The parent template or false if there is no parent
|
112 |
*
|
113 |
* @internal
|
114 |
*/
|
125 |
return false;
|
126 |
}
|
127 |
|
128 |
+
if ($parent instanceof self) {
|
129 |
+
return $this->parents[$parent->getTemplateName()] = $parent;
|
130 |
}
|
131 |
|
132 |
if (!isset($this->parents[$parent])) {
|
133 |
$this->parents[$parent] = $this->loadTemplate($parent);
|
134 |
}
|
135 |
+
} catch (Twig_Error_Loader $e) {
|
136 |
$e->setSourceContext(null);
|
137 |
$e->guess();
|
138 |
|
164 |
*
|
165 |
* @internal
|
166 |
*/
|
167 |
+
public function displayParentBlock($name, array $context, array $blocks = array())
|
168 |
{
|
169 |
$name = (string) $name;
|
170 |
|
173 |
} elseif (false !== $parent = $this->getParent($context)) {
|
174 |
$parent->displayBlock($name, $context, $blocks, false);
|
175 |
} else {
|
176 |
+
throw new Twig_Error_Runtime(sprintf('The template has no parent and no traits defining the "%s" block.', $name), -1, $this->getSourceContext());
|
177 |
}
|
178 |
}
|
179 |
|
190 |
*
|
191 |
* @internal
|
192 |
*/
|
193 |
+
public function displayBlock($name, array $context, array $blocks = array(), $useBlocks = true)
|
194 |
{
|
195 |
$name = (string) $name;
|
196 |
|
207 |
|
208 |
// avoid RCEs when sandbox is enabled
|
209 |
if (null !== $template && !$template instanceof self) {
|
210 |
+
throw new LogicException('A block must be a method on a Twig_Template instance.');
|
211 |
}
|
212 |
|
213 |
if (null !== $template) {
|
214 |
try {
|
215 |
$template->$block($context, $blocks);
|
216 |
+
} catch (Twig_Error $e) {
|
217 |
if (!$e->getSourceContext()) {
|
218 |
$e->setSourceContext($template->getSourceContext());
|
219 |
}
|
226 |
}
|
227 |
|
228 |
throw $e;
|
229 |
+
} catch (Exception $e) {
|
230 |
+
throw new Twig_Error_Runtime(sprintf('An exception has been thrown during the rendering of a template ("%s").', $e->getMessage()), -1, $template->getSourceContext(), $e);
|
231 |
}
|
232 |
} elseif (false !== $parent = $this->getParent($context)) {
|
233 |
$parent->displayBlock($name, $context, array_merge($this->blocks, $blocks), false);
|
250 |
*
|
251 |
* @internal
|
252 |
*/
|
253 |
+
public function renderParentBlock($name, array $context, array $blocks = array())
|
254 |
{
|
255 |
ob_start();
|
256 |
$this->displayParentBlock($name, $context, $blocks);
|
273 |
*
|
274 |
* @internal
|
275 |
*/
|
276 |
+
public function renderBlock($name, array $context, array $blocks = array(), $useBlocks = true)
|
277 |
{
|
278 |
ob_start();
|
279 |
$this->displayBlock($name, $context, $blocks, $useBlocks);
|
295 |
*
|
296 |
* @internal
|
297 |
*/
|
298 |
+
public function hasBlock($name, array $context = null, array $blocks = array())
|
299 |
{
|
300 |
if (null === $context) {
|
301 |
@trigger_error('The '.__METHOD__.' method is internal and should never be called; calling it directly is deprecated since version 1.28 and won\'t be possible anymore in 2.0.', E_USER_DEPRECATED);
|
331 |
*
|
332 |
* @internal
|
333 |
*/
|
334 |
+
public function getBlockNames(array $context = null, array $blocks = array())
|
335 |
{
|
336 |
if (null === $context) {
|
337 |
@trigger_error('The '.__METHOD__.' method is internal and should never be called; calling it directly is deprecated since version 1.28 and won\'t be possible anymore in 2.0.', E_USER_DEPRECATED);
|
351 |
protected function loadTemplate($template, $templateName = null, $line = null, $index = null)
|
352 |
{
|
353 |
try {
|
354 |
+
if (is_array($template)) {
|
355 |
return $this->env->resolveTemplate($template);
|
356 |
}
|
357 |
|
358 |
+
if ($template instanceof self) {
|
359 |
+
return $template;
|
360 |
+
}
|
361 |
+
|
362 |
+
if ($template instanceof Twig_TemplateWrapper) {
|
363 |
return $template;
|
364 |
}
|
365 |
|
366 |
return $this->env->loadTemplate($template, $index);
|
367 |
+
} catch (Twig_Error $e) {
|
368 |
if (!$e->getSourceContext()) {
|
369 |
+
$e->setSourceContext($templateName ? new Twig_Source('', $templateName) : $this->getSourceContext());
|
370 |
}
|
371 |
|
372 |
if ($e->getTemplateLine()) {
|
398 |
return $this->blocks;
|
399 |
}
|
400 |
|
401 |
+
public function display(array $context, array $blocks = array())
|
402 |
{
|
403 |
$this->displayWithErrorHandling($this->env->mergeGlobals($context), array_merge($this->blocks, $blocks));
|
404 |
}
|
409 |
ob_start();
|
410 |
try {
|
411 |
$this->display($context);
|
412 |
+
} catch (Exception $e) {
|
413 |
while (ob_get_level() > $level) {
|
414 |
ob_end_clean();
|
415 |
}
|
416 |
|
417 |
throw $e;
|
418 |
+
} catch (Throwable $e) {
|
419 |
while (ob_get_level() > $level) {
|
420 |
ob_end_clean();
|
421 |
}
|
426 |
return ob_get_clean();
|
427 |
}
|
428 |
|
429 |
+
protected function displayWithErrorHandling(array $context, array $blocks = array())
|
430 |
{
|
431 |
try {
|
432 |
$this->doDisplay($context, $blocks);
|
433 |
+
} catch (Twig_Error $e) {
|
434 |
if (!$e->getSourceContext()) {
|
435 |
$e->setSourceContext($this->getSourceContext());
|
436 |
}
|
443 |
}
|
444 |
|
445 |
throw $e;
|
446 |
+
} catch (Exception $e) {
|
447 |
+
throw new Twig_Error_Runtime(sprintf('An exception has been thrown during the rendering of a template ("%s").', $e->getMessage()), -1, $this->getSourceContext(), $e);
|
448 |
}
|
449 |
}
|
450 |
|
454 |
* @param array $context An array of parameters to pass to the template
|
455 |
* @param array $blocks An array of blocks to pass to the template
|
456 |
*/
|
457 |
+
abstract protected function doDisplay(array $context, array $blocks = array());
|
458 |
|
459 |
/**
|
460 |
* Returns a variable from the context.
|
473 |
*
|
474 |
* @return mixed The content of the context variable
|
475 |
*
|
476 |
+
* @throws Twig_Error_Runtime if the variable does not exist and Twig is running in strict mode
|
477 |
*
|
478 |
* @internal
|
479 |
*/
|
480 |
final protected function getContext($context, $item, $ignoreStrictCheck = false)
|
481 |
{
|
482 |
+
if (!array_key_exists($item, $context)) {
|
483 |
if ($ignoreStrictCheck || !$this->env->isStrictVariables()) {
|
484 |
return;
|
485 |
}
|
486 |
|
487 |
+
throw new Twig_Error_Runtime(sprintf('Variable "%s" does not exist.', $item), -1, $this->getSourceContext());
|
488 |
}
|
489 |
|
490 |
return $context[$item];
|
502 |
*
|
503 |
* @return mixed The attribute value, or a Boolean when $isDefinedTest is true, or null when the attribute is not set and $ignoreStrictCheck is true
|
504 |
*
|
505 |
+
* @throws Twig_Error_Runtime if the attribute does not exist and Twig is running in strict mode and $isDefinedTest is false
|
506 |
*
|
507 |
* @internal
|
508 |
*/
|
509 |
+
protected function getAttribute($object, $item, array $arguments = array(), $type = self::ANY_CALL, $isDefinedTest = false, $ignoreStrictCheck = false)
|
510 |
{
|
511 |
// array
|
512 |
if (self::METHOD_CALL !== $type) {
|
513 |
+
$arrayItem = is_bool($item) || is_float($item) ? (int) $item : $item;
|
514 |
|
515 |
+
if ((is_array($object) && (isset($object[$arrayItem]) || array_key_exists($arrayItem, $object)))
|
516 |
|| ($object instanceof ArrayAccess && isset($object[$arrayItem]))
|
517 |
) {
|
518 |
if ($isDefinedTest) {
|
522 |
return $object[$arrayItem];
|
523 |
}
|
524 |
|
525 |
+
if (self::ARRAY_CALL === $type || !is_object($object)) {
|
526 |
if ($isDefinedTest) {
|
527 |
return false;
|
528 |
}
|
532 |
}
|
533 |
|
534 |
if ($object instanceof ArrayAccess) {
|
535 |
+
$message = sprintf('Key "%s" in object with ArrayAccess of class "%s" does not exist.', $arrayItem, get_class($object));
|
536 |
+
} elseif (is_object($object)) {
|
537 |
+
$message = sprintf('Impossible to access a key "%s" on an object of class "%s" that does not implement ArrayAccess interface.', $item, get_class($object));
|
538 |
+
} elseif (is_array($object)) {
|
539 |
if (empty($object)) {
|
540 |
$message = sprintf('Key "%s" does not exist as the array is empty.', $arrayItem);
|
541 |
} else {
|
545 |
if (null === $object) {
|
546 |
$message = sprintf('Impossible to access a key ("%s") on a null variable.', $item);
|
547 |
} else {
|
548 |
+
$message = sprintf('Impossible to access a key ("%s") on a %s variable ("%s").', $item, gettype($object), $object);
|
549 |
}
|
550 |
} elseif (null === $object) {
|
551 |
$message = sprintf('Impossible to access an attribute ("%s") on a null variable.', $item);
|
552 |
} else {
|
553 |
+
$message = sprintf('Impossible to access an attribute ("%s") on a %s variable ("%s").', $item, gettype($object), $object);
|
554 |
}
|
555 |
|
556 |
+
throw new Twig_Error_Runtime($message, -1, $this->getSourceContext());
|
557 |
}
|
558 |
}
|
559 |
|
560 |
+
if (!is_object($object)) {
|
561 |
if ($isDefinedTest) {
|
562 |
return false;
|
563 |
}
|
568 |
|
569 |
if (null === $object) {
|
570 |
$message = sprintf('Impossible to invoke a method ("%s") on a null variable.', $item);
|
|
|
|
|
571 |
} else {
|
572 |
+
$message = sprintf('Impossible to invoke a method ("%s") on a %s variable ("%s").', $item, gettype($object), $object);
|
573 |
}
|
574 |
|
575 |
+
throw new Twig_Error_Runtime($message, -1, $this->getSourceContext());
|
576 |
}
|
577 |
|
578 |
// object property
|
579 |
if (self::METHOD_CALL !== $type && !$object instanceof self) { // Twig_Template does not have public properties, and we don't want to allow access to internal ones
|
580 |
+
if (isset($object->$item) || array_key_exists((string) $item, $object)) {
|
581 |
if ($isDefinedTest) {
|
582 |
return true;
|
583 |
}
|
584 |
|
585 |
+
if ($this->env->hasExtension('Twig_Extension_Sandbox')) {
|
586 |
+
$this->env->getExtension('Twig_Extension_Sandbox')->checkPropertyAllowed($object, $item);
|
587 |
}
|
588 |
|
589 |
return $object->$item;
|
590 |
}
|
591 |
}
|
592 |
|
593 |
+
$class = get_class($object);
|
594 |
|
595 |
// object method
|
596 |
if (!isset(self::$cache[$class])) {
|
597 |
// get_class_methods returns all methods accessible in the scope, but we only want public ones to be accessible in templates
|
598 |
if ($object instanceof self) {
|
599 |
+
$ref = new ReflectionClass($class);
|
600 |
+
$methods = array();
|
601 |
|
602 |
+
foreach ($ref->getMethods(ReflectionMethod::IS_PUBLIC) as $refMethod) {
|
603 |
// Accessing the environment from templates is forbidden to prevent untrusted changes to the environment
|
604 |
if ('getenvironment' !== strtolower($refMethod->name)) {
|
605 |
$methods[] = $refMethod->name;
|
611 |
// sort values to have consistent behavior, so that "get" methods win precedence over "is" methods
|
612 |
sort($methods);
|
613 |
|
614 |
+
$cache = array();
|
615 |
|
616 |
foreach ($methods as $method) {
|
617 |
$cache[$method] = $method;
|
627 |
continue;
|
628 |
}
|
629 |
|
630 |
+
if (!isset($cache[$name])) {
|
631 |
+
$cache[$name] = $method;
|
632 |
+
}
|
633 |
+
if (!isset($cache[$lcName])) {
|
634 |
+
$cache[$lcName] = $method;
|
|
|
|
|
|
|
635 |
}
|
636 |
}
|
637 |
self::$cache[$class] = $cache;
|
654 |
return;
|
655 |
}
|
656 |
|
657 |
+
throw new Twig_Error_Runtime(sprintf('Neither the property "%1$s" nor one of the methods "%1$s()", "get%1$s()"/"is%1$s()" or "__call()" exist and have public access in class "%2$s".', $item, $class), -1, $this->getSourceContext());
|
658 |
}
|
659 |
|
660 |
if ($isDefinedTest) {
|
661 |
return true;
|
662 |
}
|
663 |
|
664 |
+
if ($this->env->hasExtension('Twig_Extension_Sandbox')) {
|
665 |
+
$this->env->getExtension('Twig_Extension_Sandbox')->checkMethodAllowed($object, $method);
|
666 |
}
|
667 |
|
668 |
// Some objects throw exceptions when they have __call, and the method we try
|
671 |
if (!$arguments) {
|
672 |
$ret = $object->$method();
|
673 |
} else {
|
674 |
+
$ret = call_user_func_array(array($object, $method), $arguments);
|
675 |
}
|
676 |
+
} catch (BadMethodCallException $e) {
|
677 |
if ($call && ($ignoreStrictCheck || !$this->env->isStrictVariables())) {
|
678 |
return;
|
679 |
}
|
693 |
}
|
694 |
@trigger_error($message, E_USER_DEPRECATED);
|
695 |
|
696 |
+
return $ret === '' ? '' : new Twig_Markup($ret, $this->env->getCharset());
|
697 |
}
|
698 |
|
699 |
return $ret;
|
700 |
}
|
701 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/TemplateInterface.php
CHANGED
@@ -9,8 +9,6 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Environment;
|
13 |
-
|
14 |
/**
|
15 |
* Interface implemented by all compiled templates.
|
16 |
*
|
@@ -39,12 +37,12 @@ interface Twig_TemplateInterface
|
|
39 |
* @param array $context An array of parameters to pass to the template
|
40 |
* @param array $blocks An array of blocks to pass to the template
|
41 |
*/
|
42 |
-
public function display(array $context, array $blocks =
|
43 |
|
44 |
/**
|
45 |
* Returns the bound environment for this template.
|
46 |
*
|
47 |
-
* @return
|
48 |
*/
|
49 |
public function getEnvironment();
|
50 |
}
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
12 |
/**
|
13 |
* Interface implemented by all compiled templates.
|
14 |
*
|
37 |
* @param array $context An array of parameters to pass to the template
|
38 |
* @param array $blocks An array of blocks to pass to the template
|
39 |
*/
|
40 |
+
public function display(array $context, array $blocks = array());
|
41 |
|
42 |
/**
|
43 |
* Returns the bound environment for this template.
|
44 |
*
|
45 |
+
* @return Twig_Environment
|
46 |
*/
|
47 |
public function getEnvironment();
|
48 |
}
|
vendor/twig/twig/lib/Twig/TemplateWrapper.php
CHANGED
@@ -9,10 +9,6 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Environment;
|
13 |
-
use Twig\Source;
|
14 |
-
use Twig\Template;
|
15 |
-
|
16 |
/**
|
17 |
* Exposes a template to userland.
|
18 |
*
|
@@ -25,11 +21,11 @@ final class Twig_TemplateWrapper
|
|
25 |
|
26 |
/**
|
27 |
* This method is for internal use only and should never be called
|
28 |
-
* directly (use
|
29 |
*
|
30 |
* @internal
|
31 |
*/
|
32 |
-
public function __construct(
|
33 |
{
|
34 |
$this->env = $env;
|
35 |
$this->template = $template;
|
@@ -42,11 +38,9 @@ final class Twig_TemplateWrapper
|
|
42 |
*
|
43 |
* @return string The rendered template
|
44 |
*/
|
45 |
-
public function render($context =
|
46 |
{
|
47 |
-
|
48 |
-
// as it should only be used by internal code
|
49 |
-
return $this->template->render($context, \func_num_args() > 1 ? func_get_arg(1) : []);
|
50 |
}
|
51 |
|
52 |
/**
|
@@ -54,11 +48,9 @@ final class Twig_TemplateWrapper
|
|
54 |
*
|
55 |
* @param array $context An array of parameters to pass to the template
|
56 |
*/
|
57 |
-
public function display($context =
|
58 |
{
|
59 |
-
|
60 |
-
// as it should only be used by internal code
|
61 |
-
$this->template->display($context, \func_num_args() >= 1 ? func_get_arg(1) : []);
|
62 |
}
|
63 |
|
64 |
/**
|
@@ -69,7 +61,7 @@ final class Twig_TemplateWrapper
|
|
69 |
*
|
70 |
* @return bool
|
71 |
*/
|
72 |
-
public function hasBlock($name, $context =
|
73 |
{
|
74 |
return $this->template->hasBlock($name, $context);
|
75 |
}
|
@@ -81,7 +73,7 @@ final class Twig_TemplateWrapper
|
|
81 |
*
|
82 |
* @return string[] An array of defined template block names
|
83 |
*/
|
84 |
-
public function getBlockNames($context =
|
85 |
{
|
86 |
return $this->template->getBlockNames($context);
|
87 |
}
|
@@ -94,20 +86,20 @@ final class Twig_TemplateWrapper
|
|
94 |
*
|
95 |
* @return string The rendered block
|
96 |
*/
|
97 |
-
public function renderBlock($name, $context =
|
98 |
{
|
99 |
$context = $this->env->mergeGlobals($context);
|
100 |
$level = ob_get_level();
|
101 |
ob_start();
|
102 |
try {
|
103 |
$this->template->displayBlock($name, $context);
|
104 |
-
} catch (
|
105 |
while (ob_get_level() > $level) {
|
106 |
ob_end_clean();
|
107 |
}
|
108 |
|
109 |
throw $e;
|
110 |
-
} catch (
|
111 |
while (ob_get_level() > $level) {
|
112 |
ob_end_clean();
|
113 |
}
|
@@ -124,18 +116,16 @@ final class Twig_TemplateWrapper
|
|
124 |
* @param string $name The block name to render
|
125 |
* @param array $context An array of parameters to pass to the template
|
126 |
*/
|
127 |
-
public function displayBlock($name, $context =
|
128 |
{
|
129 |
$this->template->displayBlock($name, $this->env->mergeGlobals($context));
|
130 |
}
|
131 |
|
132 |
/**
|
133 |
-
* @return
|
134 |
*/
|
135 |
public function getSourceContext()
|
136 |
{
|
137 |
return $this->template->getSourceContext();
|
138 |
}
|
139 |
}
|
140 |
-
|
141 |
-
class_alias('Twig_TemplateWrapper', 'Twig\TemplateWrapper', false);
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
|
|
|
|
12 |
/**
|
13 |
* Exposes a template to userland.
|
14 |
*
|
21 |
|
22 |
/**
|
23 |
* This method is for internal use only and should never be called
|
24 |
+
* directly (use Twig_Environment::load() instead).
|
25 |
*
|
26 |
* @internal
|
27 |
*/
|
28 |
+
public function __construct(Twig_Environment $env, Twig_Template $template)
|
29 |
{
|
30 |
$this->env = $env;
|
31 |
$this->template = $template;
|
38 |
*
|
39 |
* @return string The rendered template
|
40 |
*/
|
41 |
+
public function render($context = array())
|
42 |
{
|
43 |
+
return $this->template->render($context);
|
|
|
|
|
44 |
}
|
45 |
|
46 |
/**
|
48 |
*
|
49 |
* @param array $context An array of parameters to pass to the template
|
50 |
*/
|
51 |
+
public function display($context = array())
|
52 |
{
|
53 |
+
$this->template->display($context);
|
|
|
|
|
54 |
}
|
55 |
|
56 |
/**
|
61 |
*
|
62 |
* @return bool
|
63 |
*/
|
64 |
+
public function hasBlock($name, $context = array())
|
65 |
{
|
66 |
return $this->template->hasBlock($name, $context);
|
67 |
}
|
73 |
*
|
74 |
* @return string[] An array of defined template block names
|
75 |
*/
|
76 |
+
public function getBlockNames($context = array())
|
77 |
{
|
78 |
return $this->template->getBlockNames($context);
|
79 |
}
|
86 |
*
|
87 |
* @return string The rendered block
|
88 |
*/
|
89 |
+
public function renderBlock($name, $context = array())
|
90 |
{
|
91 |
$context = $this->env->mergeGlobals($context);
|
92 |
$level = ob_get_level();
|
93 |
ob_start();
|
94 |
try {
|
95 |
$this->template->displayBlock($name, $context);
|
96 |
+
} catch (Exception $e) {
|
97 |
while (ob_get_level() > $level) {
|
98 |
ob_end_clean();
|
99 |
}
|
100 |
|
101 |
throw $e;
|
102 |
+
} catch (Throwable $e) {
|
103 |
while (ob_get_level() > $level) {
|
104 |
ob_end_clean();
|
105 |
}
|
116 |
* @param string $name The block name to render
|
117 |
* @param array $context An array of parameters to pass to the template
|
118 |
*/
|
119 |
+
public function displayBlock($name, $context = array())
|
120 |
{
|
121 |
$this->template->displayBlock($name, $this->env->mergeGlobals($context));
|
122 |
}
|
123 |
|
124 |
/**
|
125 |
+
* @return Twig_Source
|
126 |
*/
|
127 |
public function getSourceContext()
|
128 |
{
|
129 |
return $this->template->getSourceContext();
|
130 |
}
|
131 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Test.php
CHANGED
@@ -21,13 +21,13 @@
|
|
21 |
abstract class Twig_Test implements Twig_TestInterface, Twig_TestCallableInterface
|
22 |
{
|
23 |
protected $options;
|
24 |
-
protected $arguments =
|
25 |
|
26 |
-
public function __construct(array $options =
|
27 |
{
|
28 |
-
$this->options = array_merge(
|
29 |
'callable' => null,
|
30 |
-
|
31 |
}
|
32 |
|
33 |
public function getCallable()
|
21 |
abstract class Twig_Test implements Twig_TestInterface, Twig_TestCallableInterface
|
22 |
{
|
23 |
protected $options;
|
24 |
+
protected $arguments = array();
|
25 |
|
26 |
+
public function __construct(array $options = array())
|
27 |
{
|
28 |
+
$this->options = array_merge(array(
|
29 |
'callable' => null,
|
30 |
+
), $options);
|
31 |
}
|
32 |
|
33 |
public function getCallable()
|
vendor/twig/twig/lib/Twig/Test/Function.php
CHANGED
@@ -22,7 +22,7 @@ class Twig_Test_Function extends Twig_Test
|
|
22 |
{
|
23 |
protected $function;
|
24 |
|
25 |
-
public function __construct($function, array $options =
|
26 |
{
|
27 |
$options['callable'] = $function;
|
28 |
|
22 |
{
|
23 |
protected $function;
|
24 |
|
25 |
+
public function __construct($function, array $options = array())
|
26 |
{
|
27 |
$options['callable'] = $function;
|
28 |
|
vendor/twig/twig/lib/Twig/Test/IntegrationTestCase.php
CHANGED
@@ -9,25 +9,13 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use PHPUnit\Framework\TestCase;
|
13 |
-
use Twig\Environment;
|
14 |
-
use Twig\Error\Error;
|
15 |
-
use Twig\Extension\ExtensionInterface;
|
16 |
-
use Twig\Loader\ArrayLoader;
|
17 |
-
use Twig\Loader\SourceContextLoaderInterface;
|
18 |
-
use Twig\RuntimeLoader\RuntimeLoaderInterface;
|
19 |
-
use Twig\Source;
|
20 |
-
use Twig\TwigFilter;
|
21 |
-
use Twig\TwigFunction;
|
22 |
-
use Twig\TwigTest;
|
23 |
-
|
24 |
/**
|
25 |
* Integration test helper.
|
26 |
*
|
27 |
* @author Fabien Potencier <fabien@symfony.com>
|
28 |
* @author Karma Dordrak <drak@zikula.org>
|
29 |
*/
|
30 |
-
abstract class Twig_Test_IntegrationTestCase extends
|
31 |
{
|
32 |
/**
|
33 |
* @return string
|
@@ -35,43 +23,35 @@ abstract class Twig_Test_IntegrationTestCase extends TestCase
|
|
35 |
abstract protected function getFixturesDir();
|
36 |
|
37 |
/**
|
38 |
-
* @return
|
39 |
-
*/
|
40 |
-
protected function getRuntimeLoaders()
|
41 |
-
{
|
42 |
-
return [];
|
43 |
-
}
|
44 |
-
|
45 |
-
/**
|
46 |
-
* @return ExtensionInterface[]
|
47 |
*/
|
48 |
protected function getExtensions()
|
49 |
{
|
50 |
-
return
|
51 |
}
|
52 |
|
53 |
/**
|
54 |
-
* @return
|
55 |
*/
|
56 |
protected function getTwigFilters()
|
57 |
{
|
58 |
-
return
|
59 |
}
|
60 |
|
61 |
/**
|
62 |
-
* @return
|
63 |
*/
|
64 |
protected function getTwigFunctions()
|
65 |
{
|
66 |
-
return
|
67 |
}
|
68 |
|
69 |
/**
|
70 |
-
* @return
|
71 |
*/
|
72 |
protected function getTwigTests()
|
73 |
{
|
74 |
-
return
|
75 |
}
|
76 |
|
77 |
/**
|
@@ -94,9 +74,9 @@ abstract class Twig_Test_IntegrationTestCase extends TestCase
|
|
94 |
public function getTests($name, $legacyTests = false)
|
95 |
{
|
96 |
$fixturesDir = realpath($this->getFixturesDir());
|
97 |
-
$tests =
|
98 |
|
99 |
-
foreach (new
|
100 |
if (!preg_match('/\.test$/', $file)) {
|
101 |
continue;
|
102 |
}
|
@@ -112,7 +92,7 @@ abstract class Twig_Test_IntegrationTestCase extends TestCase
|
|
112 |
$condition = $match[2];
|
113 |
$templates = self::parseTemplates($match[3]);
|
114 |
$exception = $match[5];
|
115 |
-
$outputs =
|
116 |
} elseif (preg_match('/--TEST--\s*(.*?)\s*(?:--CONDITION--\s*(.*))?\s*((?:--TEMPLATE(?:\(.*?\))?--(?:.*?))+)--DATA--.*?--EXPECT--.*/s', $test, $match)) {
|
117 |
$message = $match[1];
|
118 |
$condition = $match[2];
|
@@ -120,15 +100,15 @@ abstract class Twig_Test_IntegrationTestCase extends TestCase
|
|
120 |
$exception = false;
|
121 |
preg_match_all('/--DATA--(.*?)(?:--CONFIG--(.*?))?--EXPECT--(.*?)(?=\-\-DATA\-\-|$)/s', $test, $outputs, PREG_SET_ORDER);
|
122 |
} else {
|
123 |
-
throw new
|
124 |
}
|
125 |
|
126 |
-
$tests[] =
|
127 |
}
|
128 |
|
129 |
if ($legacyTests && empty($tests)) {
|
130 |
// add a dummy test to avoid a PHPUnit message
|
131 |
-
return
|
132 |
}
|
133 |
|
134 |
return $tests;
|
@@ -142,7 +122,7 @@ abstract class Twig_Test_IntegrationTestCase extends TestCase
|
|
142 |
protected function doIntegrationTest($file, $message, $condition, $templates, $exception, $outputs)
|
143 |
{
|
144 |
if (!$outputs) {
|
145 |
-
$this->markTestSkipped('no tests to run');
|
146 |
}
|
147 |
|
148 |
if ($condition) {
|
@@ -152,19 +132,15 @@ abstract class Twig_Test_IntegrationTestCase extends TestCase
|
|
152 |
}
|
153 |
}
|
154 |
|
155 |
-
$loader = new
|
156 |
|
157 |
foreach ($outputs as $i => $match) {
|
158 |
-
$config = array_merge(
|
159 |
'cache' => false,
|
160 |
'strict_variables' => true,
|
161 |
-
|
162 |
-
$twig = new
|
163 |
$twig->addGlobal('global', 'global');
|
164 |
-
foreach ($this->getRuntimeLoaders() as $runtimeLoader) {
|
165 |
-
$twig->addRuntimeLoader($runtimeLoader);
|
166 |
-
}
|
167 |
-
|
168 |
foreach ($this->getExtensions() as $extension) {
|
169 |
$twig->addExtension($extension);
|
170 |
}
|
@@ -181,43 +157,46 @@ abstract class Twig_Test_IntegrationTestCase extends TestCase
|
|
181 |
$twig->addFunction($function);
|
182 |
}
|
183 |
|
184 |
-
|
185 |
-
|
186 |
-
|
|
|
|
|
|
|
|
|
187 |
|
188 |
try {
|
189 |
$template = $twig->loadTemplate('index.twig');
|
190 |
-
} catch (
|
191 |
if (false !== $exception) {
|
192 |
$message = $e->getMessage();
|
193 |
-
$this->assertSame(trim($exception), trim(sprintf('%s: %s',
|
194 |
-
$last = substr($message,
|
195 |
$this->assertTrue('.' === $last || '?' === $last, $message, 'Exception message must end with a dot or a question mark.');
|
196 |
|
197 |
return;
|
198 |
}
|
199 |
|
200 |
-
throw new
|
201 |
}
|
202 |
|
203 |
try {
|
204 |
$output = trim($template->render(eval($match[1].';')), "\n ");
|
205 |
-
} catch (
|
206 |
if (false !== $exception) {
|
207 |
-
$this->assertSame(trim($exception), trim(sprintf('%s: %s',
|
208 |
|
209 |
return;
|
210 |
}
|
211 |
|
212 |
-
$e = new
|
213 |
|
214 |
-
$output = trim(sprintf('%s: %s',
|
215 |
}
|
216 |
|
217 |
if (false !== $exception) {
|
218 |
list($class) = explode(':', $exception);
|
219 |
-
$
|
220 |
-
$this->assertThat(null, new $constraintClass($class));
|
221 |
}
|
222 |
|
223 |
$expected = trim($match[3], "\n ");
|
@@ -228,8 +207,8 @@ abstract class Twig_Test_IntegrationTestCase extends TestCase
|
|
228 |
foreach (array_keys($templates) as $name) {
|
229 |
echo "Template: $name\n";
|
230 |
$loader = $twig->getLoader();
|
231 |
-
if (!$loader instanceof
|
232 |
-
$source = new
|
233 |
} else {
|
234 |
$source = $loader->getSourceContext($name);
|
235 |
}
|
@@ -242,7 +221,7 @@ abstract class Twig_Test_IntegrationTestCase extends TestCase
|
|
242 |
|
243 |
protected static function parseTemplates($test)
|
244 |
{
|
245 |
-
$templates =
|
246 |
preg_match_all('/--TEMPLATE(?:\((.*?)\))?--(.*?)(?=\-\-TEMPLATE|$)/s', $test, $matches, PREG_SET_ORDER);
|
247 |
foreach ($matches as $match) {
|
248 |
$templates[($match[1] ? $match[1] : 'index.twig')] = $match[2];
|
@@ -251,5 +230,3 @@ abstract class Twig_Test_IntegrationTestCase extends TestCase
|
|
251 |
return $templates;
|
252 |
}
|
253 |
}
|
254 |
-
|
255 |
-
class_alias('Twig_Test_IntegrationTestCase', 'Twig\Test\IntegrationTestCase', false);
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
/**
|
13 |
* Integration test helper.
|
14 |
*
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
* @author Karma Dordrak <drak@zikula.org>
|
17 |
*/
|
18 |
+
abstract class Twig_Test_IntegrationTestCase extends PHPUnit_Framework_TestCase
|
19 |
{
|
20 |
/**
|
21 |
* @return string
|
23 |
abstract protected function getFixturesDir();
|
24 |
|
25 |
/**
|
26 |
+
* @return Twig_ExtensionInterface[]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
*/
|
28 |
protected function getExtensions()
|
29 |
{
|
30 |
+
return array();
|
31 |
}
|
32 |
|
33 |
/**
|
34 |
+
* @return Twig_SimpleFilter[]
|
35 |
*/
|
36 |
protected function getTwigFilters()
|
37 |
{
|
38 |
+
return array();
|
39 |
}
|
40 |
|
41 |
/**
|
42 |
+
* @return Twig_SimpleFunction[]
|
43 |
*/
|
44 |
protected function getTwigFunctions()
|
45 |
{
|
46 |
+
return array();
|
47 |
}
|
48 |
|
49 |
/**
|
50 |
+
* @return Twig_SimpleTest[]
|
51 |
*/
|
52 |
protected function getTwigTests()
|
53 |
{
|
54 |
+
return array();
|
55 |
}
|
56 |
|
57 |
/**
|
74 |
public function getTests($name, $legacyTests = false)
|
75 |
{
|
76 |
$fixturesDir = realpath($this->getFixturesDir());
|
77 |
+
$tests = array();
|
78 |
|
79 |
+
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($fixturesDir), RecursiveIteratorIterator::LEAVES_ONLY) as $file) {
|
80 |
if (!preg_match('/\.test$/', $file)) {
|
81 |
continue;
|
82 |
}
|
92 |
$condition = $match[2];
|
93 |
$templates = self::parseTemplates($match[3]);
|
94 |
$exception = $match[5];
|
95 |
+
$outputs = array(array(null, $match[4], null, ''));
|
96 |
} elseif (preg_match('/--TEST--\s*(.*?)\s*(?:--CONDITION--\s*(.*))?\s*((?:--TEMPLATE(?:\(.*?\))?--(?:.*?))+)--DATA--.*?--EXPECT--.*/s', $test, $match)) {
|
97 |
$message = $match[1];
|
98 |
$condition = $match[2];
|
100 |
$exception = false;
|
101 |
preg_match_all('/--DATA--(.*?)(?:--CONFIG--(.*?))?--EXPECT--(.*?)(?=\-\-DATA\-\-|$)/s', $test, $outputs, PREG_SET_ORDER);
|
102 |
} else {
|
103 |
+
throw new InvalidArgumentException(sprintf('Test "%s" is not valid.', str_replace($fixturesDir.'/', '', $file)));
|
104 |
}
|
105 |
|
106 |
+
$tests[] = array(str_replace($fixturesDir.'/', '', $file), $message, $condition, $templates, $exception, $outputs);
|
107 |
}
|
108 |
|
109 |
if ($legacyTests && empty($tests)) {
|
110 |
// add a dummy test to avoid a PHPUnit message
|
111 |
+
return array(array('not', '-', '', array(), '', array()));
|
112 |
}
|
113 |
|
114 |
return $tests;
|
122 |
protected function doIntegrationTest($file, $message, $condition, $templates, $exception, $outputs)
|
123 |
{
|
124 |
if (!$outputs) {
|
125 |
+
$this->markTestSkipped('no legacy tests to run');
|
126 |
}
|
127 |
|
128 |
if ($condition) {
|
132 |
}
|
133 |
}
|
134 |
|
135 |
+
$loader = new Twig_Loader_Array($templates);
|
136 |
|
137 |
foreach ($outputs as $i => $match) {
|
138 |
+
$config = array_merge(array(
|
139 |
'cache' => false,
|
140 |
'strict_variables' => true,
|
141 |
+
), $match[2] ? eval($match[2].';') : array());
|
142 |
+
$twig = new Twig_Environment($loader, $config);
|
143 |
$twig->addGlobal('global', 'global');
|
|
|
|
|
|
|
|
|
144 |
foreach ($this->getExtensions() as $extension) {
|
145 |
$twig->addExtension($extension);
|
146 |
}
|
157 |
$twig->addFunction($function);
|
158 |
}
|
159 |
|
160 |
+
// avoid using the same PHP class name for different cases
|
161 |
+
// only for PHP 5.2+
|
162 |
+
if (PHP_VERSION_ID >= 50300) {
|
163 |
+
$p = new ReflectionProperty($twig, 'templateClassPrefix');
|
164 |
+
$p->setAccessible(true);
|
165 |
+
$p->setValue($twig, '__TwigTemplate_'.hash('sha256', uniqid(mt_rand(), true), false).'_');
|
166 |
+
}
|
167 |
|
168 |
try {
|
169 |
$template = $twig->loadTemplate('index.twig');
|
170 |
+
} catch (Exception $e) {
|
171 |
if (false !== $exception) {
|
172 |
$message = $e->getMessage();
|
173 |
+
$this->assertSame(trim($exception), trim(sprintf('%s: %s', get_class($e), $message)));
|
174 |
+
$last = substr($message, strlen($message) - 1);
|
175 |
$this->assertTrue('.' === $last || '?' === $last, $message, 'Exception message must end with a dot or a question mark.');
|
176 |
|
177 |
return;
|
178 |
}
|
179 |
|
180 |
+
throw new Twig_Error(sprintf('%s: %s', get_class($e), $e->getMessage()), -1, $file, $e);
|
181 |
}
|
182 |
|
183 |
try {
|
184 |
$output = trim($template->render(eval($match[1].';')), "\n ");
|
185 |
+
} catch (Exception $e) {
|
186 |
if (false !== $exception) {
|
187 |
+
$this->assertSame(trim($exception), trim(sprintf('%s: %s', get_class($e), $e->getMessage())));
|
188 |
|
189 |
return;
|
190 |
}
|
191 |
|
192 |
+
$e = new Twig_Error(sprintf('%s: %s', get_class($e), $e->getMessage()), -1, $file, $e);
|
193 |
|
194 |
+
$output = trim(sprintf('%s: %s', get_class($e), $e->getMessage()));
|
195 |
}
|
196 |
|
197 |
if (false !== $exception) {
|
198 |
list($class) = explode(':', $exception);
|
199 |
+
$this->assertThat(null, new PHPUnit_Framework_Constraint_Exception($class));
|
|
|
200 |
}
|
201 |
|
202 |
$expected = trim($match[3], "\n ");
|
207 |
foreach (array_keys($templates) as $name) {
|
208 |
echo "Template: $name\n";
|
209 |
$loader = $twig->getLoader();
|
210 |
+
if (!$loader instanceof Twig_SourceContextLoaderInterface) {
|
211 |
+
$source = new Twig_Source($loader->getSource($name), $name);
|
212 |
} else {
|
213 |
$source = $loader->getSourceContext($name);
|
214 |
}
|
221 |
|
222 |
protected static function parseTemplates($test)
|
223 |
{
|
224 |
+
$templates = array();
|
225 |
preg_match_all('/--TEMPLATE(?:\((.*?)\))?--(.*?)(?=\-\-TEMPLATE|$)/s', $test, $matches, PREG_SET_ORDER);
|
226 |
foreach ($matches as $match) {
|
227 |
$templates[($match[1] ? $match[1] : 'index.twig')] = $match[2];
|
230 |
return $templates;
|
231 |
}
|
232 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Test/Method.php
CHANGED
@@ -9,8 +9,6 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Extension\ExtensionInterface;
|
13 |
-
|
14 |
@trigger_error('The Twig_Test_Method class is deprecated since version 1.12 and will be removed in 2.0. Use Twig_SimpleTest instead.', E_USER_DEPRECATED);
|
15 |
|
16 |
/**
|
@@ -25,9 +23,9 @@ class Twig_Test_Method extends Twig_Test
|
|
25 |
protected $extension;
|
26 |
protected $method;
|
27 |
|
28 |
-
public function __construct(
|
29 |
{
|
30 |
-
$options['callable'] =
|
31 |
|
32 |
parent::__construct($options);
|
33 |
|
@@ -37,6 +35,6 @@ class Twig_Test_Method extends Twig_Test
|
|
37 |
|
38 |
public function compile()
|
39 |
{
|
40 |
-
return sprintf('$this->env->getExtension(\'%s\')->%s',
|
41 |
}
|
42 |
}
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
12 |
@trigger_error('The Twig_Test_Method class is deprecated since version 1.12 and will be removed in 2.0. Use Twig_SimpleTest instead.', E_USER_DEPRECATED);
|
13 |
|
14 |
/**
|
23 |
protected $extension;
|
24 |
protected $method;
|
25 |
|
26 |
+
public function __construct(Twig_ExtensionInterface $extension, $method, array $options = array())
|
27 |
{
|
28 |
+
$options['callable'] = array($extension, $method);
|
29 |
|
30 |
parent::__construct($options);
|
31 |
|
35 |
|
36 |
public function compile()
|
37 |
{
|
38 |
+
return sprintf('$this->env->getExtension(\'%s\')->%s', get_class($this->extension), $this->method);
|
39 |
}
|
40 |
}
|
vendor/twig/twig/lib/Twig/Test/Node.php
CHANGED
@@ -22,7 +22,7 @@ class Twig_Test_Node extends Twig_Test
|
|
22 |
{
|
23 |
protected $class;
|
24 |
|
25 |
-
public function __construct($class, array $options =
|
26 |
{
|
27 |
parent::__construct($options);
|
28 |
|
22 |
{
|
23 |
protected $class;
|
24 |
|
25 |
+
public function __construct($class, array $options = array())
|
26 |
{
|
27 |
parent::__construct($options);
|
28 |
|
vendor/twig/twig/lib/Twig/Test/NodeTestCase.php
CHANGED
@@ -8,14 +8,7 @@
|
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
-
|
12 |
-
use PHPUnit\Framework\TestCase;
|
13 |
-
use Twig\Compiler;
|
14 |
-
use Twig\Environment;
|
15 |
-
use Twig\Loader\ArrayLoader;
|
16 |
-
use Twig\Node\Node;
|
17 |
-
|
18 |
-
abstract class Twig_Test_NodeTestCase extends TestCase
|
19 |
{
|
20 |
abstract public function getTests();
|
21 |
|
@@ -27,7 +20,7 @@ abstract class Twig_Test_NodeTestCase extends TestCase
|
|
27 |
$this->assertNodeCompilation($source, $node, $environment, $isPattern);
|
28 |
}
|
29 |
|
30 |
-
public function assertNodeCompilation($source,
|
31 |
{
|
32 |
$compiler = $this->getCompiler($environment);
|
33 |
$compiler->compile($node);
|
@@ -39,14 +32,14 @@ abstract class Twig_Test_NodeTestCase extends TestCase
|
|
39 |
}
|
40 |
}
|
41 |
|
42 |
-
protected function getCompiler(
|
43 |
{
|
44 |
-
return new
|
45 |
}
|
46 |
|
47 |
protected function getEnvironment()
|
48 |
{
|
49 |
-
return new
|
50 |
}
|
51 |
|
52 |
protected function getVariableGetter($name, $line = false)
|
@@ -66,14 +59,10 @@ abstract class Twig_Test_NodeTestCase extends TestCase
|
|
66 |
|
67 |
protected function getAttributeGetter()
|
68 |
{
|
69 |
-
if (
|
70 |
return 'twig_template_get_attributes($this, ';
|
71 |
}
|
72 |
|
73 |
return '$this->getAttribute(';
|
74 |
}
|
75 |
}
|
76 |
-
|
77 |
-
class_alias('Twig_Test_NodeTestCase', 'Twig\Test\NodeTestCase', false);
|
78 |
-
class_exists('Twig_Environment');
|
79 |
-
class_exists('Twig_Node');
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
+
abstract class Twig_Test_NodeTestCase extends PHPUnit_Framework_TestCase
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
{
|
13 |
abstract public function getTests();
|
14 |
|
20 |
$this->assertNodeCompilation($source, $node, $environment, $isPattern);
|
21 |
}
|
22 |
|
23 |
+
public function assertNodeCompilation($source, Twig_Node $node, Twig_Environment $environment = null, $isPattern = false)
|
24 |
{
|
25 |
$compiler = $this->getCompiler($environment);
|
26 |
$compiler->compile($node);
|
32 |
}
|
33 |
}
|
34 |
|
35 |
+
protected function getCompiler(Twig_Environment $environment = null)
|
36 |
{
|
37 |
+
return new Twig_Compiler(null === $environment ? $this->getEnvironment() : $environment);
|
38 |
}
|
39 |
|
40 |
protected function getEnvironment()
|
41 |
{
|
42 |
+
return new Twig_Environment(new Twig_Loader_Array(array()));
|
43 |
}
|
44 |
|
45 |
protected function getVariableGetter($name, $line = false)
|
59 |
|
60 |
protected function getAttributeGetter()
|
61 |
{
|
62 |
+
if (function_exists('twig_template_get_attributes')) {
|
63 |
return 'twig_template_get_attributes($this, ';
|
64 |
}
|
65 |
|
66 |
return '$this->getAttribute(';
|
67 |
}
|
68 |
}
|
|
|
|
|
|
|
|
vendor/twig/twig/lib/Twig/Token.php
CHANGED
@@ -62,21 +62,21 @@ class Twig_Token
|
|
62 |
* * type and value (or array of possible values)
|
63 |
* * just value (or array of possible values) (NAME_TYPE is used as type)
|
64 |
*
|
65 |
-
* @param array|
|
66 |
* @param array|string|null $values The token value
|
67 |
*
|
68 |
* @return bool
|
69 |
*/
|
70 |
public function test($type, $values = null)
|
71 |
{
|
72 |
-
if (null === $values &&
|
73 |
$values = $type;
|
74 |
$type = self::NAME_TYPE;
|
75 |
}
|
76 |
|
77 |
return ($this->type === $type) && (
|
78 |
null === $values ||
|
79 |
-
(
|
80 |
$this->value == $values
|
81 |
);
|
82 |
}
|
@@ -156,10 +156,10 @@ class Twig_Token
|
|
156 |
$name = 'INTERPOLATION_END_TYPE';
|
157 |
break;
|
158 |
default:
|
159 |
-
throw new
|
160 |
}
|
161 |
|
162 |
-
return $short ? $name : '
|
163 |
}
|
164 |
|
165 |
/**
|
@@ -199,9 +199,7 @@ class Twig_Token
|
|
199 |
case self::INTERPOLATION_END_TYPE:
|
200 |
return 'end of string interpolation';
|
201 |
default:
|
202 |
-
throw new
|
203 |
}
|
204 |
}
|
205 |
}
|
206 |
-
|
207 |
-
class_alias('Twig_Token', 'Twig\Token', false);
|
62 |
* * type and value (or array of possible values)
|
63 |
* * just value (or array of possible values) (NAME_TYPE is used as type)
|
64 |
*
|
65 |
+
* @param array|int $type The type to test
|
66 |
* @param array|string|null $values The token value
|
67 |
*
|
68 |
* @return bool
|
69 |
*/
|
70 |
public function test($type, $values = null)
|
71 |
{
|
72 |
+
if (null === $values && !is_int($type)) {
|
73 |
$values = $type;
|
74 |
$type = self::NAME_TYPE;
|
75 |
}
|
76 |
|
77 |
return ($this->type === $type) && (
|
78 |
null === $values ||
|
79 |
+
(is_array($values) && in_array($this->value, $values)) ||
|
80 |
$this->value == $values
|
81 |
);
|
82 |
}
|
156 |
$name = 'INTERPOLATION_END_TYPE';
|
157 |
break;
|
158 |
default:
|
159 |
+
throw new LogicException(sprintf('Token of type "%s" does not exist.', $type));
|
160 |
}
|
161 |
|
162 |
+
return $short ? $name : 'Twig_Token::'.$name;
|
163 |
}
|
164 |
|
165 |
/**
|
199 |
case self::INTERPOLATION_END_TYPE:
|
200 |
return 'end of string interpolation';
|
201 |
default:
|
202 |
+
throw new LogicException(sprintf('Token of type "%s" does not exist.', $type));
|
203 |
}
|
204 |
}
|
205 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/TokenParser.php
CHANGED
@@ -9,15 +9,12 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Parser;
|
13 |
-
use Twig\TokenParser\TokenParserInterface;
|
14 |
-
|
15 |
/**
|
16 |
* Base class for all token parsers.
|
17 |
*
|
18 |
* @author Fabien Potencier <fabien@symfony.com>
|
19 |
*/
|
20 |
-
abstract class Twig_TokenParser implements
|
21 |
{
|
22 |
/**
|
23 |
* @var Twig_Parser
|
@@ -27,10 +24,8 @@ abstract class Twig_TokenParser implements TokenParserInterface
|
|
27 |
/**
|
28 |
* Sets the parser associated with this token parser.
|
29 |
*/
|
30 |
-
public function setParser(
|
31 |
{
|
32 |
$this->parser = $parser;
|
33 |
}
|
34 |
}
|
35 |
-
|
36 |
-
class_alias('Twig_TokenParser', 'Twig\TokenParser\AbstractTokenParser', false);
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
|
|
12 |
/**
|
13 |
* Base class for all token parsers.
|
14 |
*
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
+
abstract class Twig_TokenParser implements Twig_TokenParserInterface
|
18 |
{
|
19 |
/**
|
20 |
* @var Twig_Parser
|
24 |
/**
|
25 |
* Sets the parser associated with this token parser.
|
26 |
*/
|
27 |
+
public function setParser(Twig_Parser $parser)
|
28 |
{
|
29 |
$this->parser = $parser;
|
30 |
}
|
31 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/TokenParser/AutoEscape.php
CHANGED
@@ -9,43 +9,39 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Error\SyntaxError;
|
13 |
-
use Twig\Node\AutoEscapeNode;
|
14 |
-
use Twig\Node\Expression\ConstantExpression;
|
15 |
-
use Twig\Token;
|
16 |
-
use Twig\TokenParser\AbstractTokenParser;
|
17 |
-
|
18 |
/**
|
19 |
* Marks a section of a template to be escaped or not.
|
20 |
*
|
21 |
-
*
|
22 |
-
*
|
23 |
-
*
|
|
|
24 |
*
|
25 |
-
*
|
26 |
-
*
|
27 |
-
*
|
28 |
*
|
29 |
-
*
|
30 |
-
*
|
31 |
-
*
|
32 |
-
*
|
|
|
33 |
*
|
34 |
* @final
|
35 |
*/
|
36 |
-
class Twig_TokenParser_AutoEscape extends
|
37 |
{
|
38 |
-
public function parse(
|
39 |
{
|
40 |
$lineno = $token->getLine();
|
41 |
$stream = $this->parser->getStream();
|
42 |
|
43 |
-
if ($stream->test(
|
44 |
$value = 'html';
|
45 |
} else {
|
46 |
$expr = $this->parser->getExpressionParser()->parseExpression();
|
47 |
-
if (!$expr instanceof
|
48 |
-
throw new
|
49 |
}
|
50 |
$value = $expr->getAttribute('value');
|
51 |
|
@@ -55,25 +51,25 @@ class Twig_TokenParser_AutoEscape extends AbstractTokenParser
|
|
55 |
$value = 'html';
|
56 |
}
|
57 |
|
58 |
-
if ($compat && $stream->test(
|
59 |
@trigger_error('Using the autoescape tag with "true" or "false" before the strategy name is deprecated since version 1.21.', E_USER_DEPRECATED);
|
60 |
|
61 |
if (false === $value) {
|
62 |
-
throw new
|
63 |
}
|
64 |
|
65 |
$value = $stream->next()->getValue();
|
66 |
}
|
67 |
}
|
68 |
|
69 |
-
$stream->expect(
|
70 |
-
$body = $this->parser->subparse(
|
71 |
-
$stream->expect(
|
72 |
|
73 |
-
return new
|
74 |
}
|
75 |
|
76 |
-
public function decideBlockEnd(
|
77 |
{
|
78 |
return $token->test('endautoescape');
|
79 |
}
|
@@ -83,5 +79,3 @@ class Twig_TokenParser_AutoEscape extends AbstractTokenParser
|
|
83 |
return 'autoescape';
|
84 |
}
|
85 |
}
|
86 |
-
|
87 |
-
class_alias('Twig_TokenParser_AutoEscape', 'Twig\TokenParser\AutoEscapeTokenParser', false);
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
/**
|
13 |
* Marks a section of a template to be escaped or not.
|
14 |
*
|
15 |
+
* <pre>
|
16 |
+
* {% autoescape true %}
|
17 |
+
* Everything will be automatically escaped in this block
|
18 |
+
* {% endautoescape %}
|
19 |
*
|
20 |
+
* {% autoescape false %}
|
21 |
+
* Everything will be outputed as is in this block
|
22 |
+
* {% endautoescape %}
|
23 |
*
|
24 |
+
* {% autoescape true js %}
|
25 |
+
* Everything will be automatically escaped in this block
|
26 |
+
* using the js escaping strategy
|
27 |
+
* {% endautoescape %}
|
28 |
+
* </pre>
|
29 |
*
|
30 |
* @final
|
31 |
*/
|
32 |
+
class Twig_TokenParser_AutoEscape extends Twig_TokenParser
|
33 |
{
|
34 |
+
public function parse(Twig_Token $token)
|
35 |
{
|
36 |
$lineno = $token->getLine();
|
37 |
$stream = $this->parser->getStream();
|
38 |
|
39 |
+
if ($stream->test(Twig_Token::BLOCK_END_TYPE)) {
|
40 |
$value = 'html';
|
41 |
} else {
|
42 |
$expr = $this->parser->getExpressionParser()->parseExpression();
|
43 |
+
if (!$expr instanceof Twig_Node_Expression_Constant) {
|
44 |
+
throw new Twig_Error_Syntax('An escaping strategy must be a string or a bool.', $stream->getCurrent()->getLine(), $stream->getSourceContext());
|
45 |
}
|
46 |
$value = $expr->getAttribute('value');
|
47 |
|
51 |
$value = 'html';
|
52 |
}
|
53 |
|
54 |
+
if ($compat && $stream->test(Twig_Token::NAME_TYPE)) {
|
55 |
@trigger_error('Using the autoescape tag with "true" or "false" before the strategy name is deprecated since version 1.21.', E_USER_DEPRECATED);
|
56 |
|
57 |
if (false === $value) {
|
58 |
+
throw new Twig_Error_Syntax('Unexpected escaping strategy as you set autoescaping to false.', $stream->getCurrent()->getLine(), $stream->getSourceContext());
|
59 |
}
|
60 |
|
61 |
$value = $stream->next()->getValue();
|
62 |
}
|
63 |
}
|
64 |
|
65 |
+
$stream->expect(Twig_Token::BLOCK_END_TYPE);
|
66 |
+
$body = $this->parser->subparse(array($this, 'decideBlockEnd'), true);
|
67 |
+
$stream->expect(Twig_Token::BLOCK_END_TYPE);
|
68 |
|
69 |
+
return new Twig_Node_AutoEscape($value, $body, $lineno, $this->getTag());
|
70 |
}
|
71 |
|
72 |
+
public function decideBlockEnd(Twig_Token $token)
|
73 |
{
|
74 |
return $token->test('endautoescape');
|
75 |
}
|
79 |
return 'autoescape';
|
80 |
}
|
81 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/TokenParser/Block.php
CHANGED
@@ -10,62 +10,56 @@
|
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
|
13 |
-
use Twig\Error\SyntaxError;
|
14 |
-
use Twig\Node\BlockNode;
|
15 |
-
use Twig\Node\BlockReferenceNode;
|
16 |
-
use Twig\Node\Node;
|
17 |
-
use Twig\Node\PrintNode;
|
18 |
-
use Twig\Token;
|
19 |
-
use Twig\TokenParser\AbstractTokenParser;
|
20 |
-
|
21 |
/**
|
22 |
* Marks a section of a template as being reusable.
|
23 |
*
|
|
|
24 |
* {% block head %}
|
25 |
* <link rel="stylesheet" href="style.css" />
|
26 |
* <title>{% block title %}{% endblock %} - My Webpage</title>
|
27 |
* {% endblock %}
|
|
|
28 |
*
|
29 |
* @final
|
30 |
*/
|
31 |
-
class Twig_TokenParser_Block extends
|
32 |
{
|
33 |
-
public function parse(
|
34 |
{
|
35 |
$lineno = $token->getLine();
|
36 |
$stream = $this->parser->getStream();
|
37 |
-
$name = $stream->expect(
|
38 |
if ($this->parser->hasBlock($name)) {
|
39 |
-
throw new
|
40 |
}
|
41 |
-
$this->parser->setBlock($name, $block = new
|
42 |
$this->parser->pushLocalScope();
|
43 |
$this->parser->pushBlockStack($name);
|
44 |
|
45 |
-
if ($stream->nextIf(
|
46 |
-
$body = $this->parser->subparse(
|
47 |
-
if ($token = $stream->nextIf(
|
48 |
$value = $token->getValue();
|
49 |
|
50 |
if ($value != $name) {
|
51 |
-
throw new
|
52 |
}
|
53 |
}
|
54 |
} else {
|
55 |
-
$body = new
|
56 |
-
new
|
57 |
-
|
58 |
}
|
59 |
-
$stream->expect(
|
60 |
|
61 |
$block->setNode('body', $body);
|
62 |
$this->parser->popBlockStack();
|
63 |
$this->parser->popLocalScope();
|
64 |
|
65 |
-
return new
|
66 |
}
|
67 |
|
68 |
-
public function decideBlockEnd(
|
69 |
{
|
70 |
return $token->test('endblock');
|
71 |
}
|
@@ -75,5 +69,3 @@ class Twig_TokenParser_Block extends AbstractTokenParser
|
|
75 |
return 'block';
|
76 |
}
|
77 |
}
|
78 |
-
|
79 |
-
class_alias('Twig_TokenParser_Block', 'Twig\TokenParser\BlockTokenParser', false);
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
/**
|
14 |
* Marks a section of a template as being reusable.
|
15 |
*
|
16 |
+
* <pre>
|
17 |
* {% block head %}
|
18 |
* <link rel="stylesheet" href="style.css" />
|
19 |
* <title>{% block title %}{% endblock %} - My Webpage</title>
|
20 |
* {% endblock %}
|
21 |
+
* </pre>
|
22 |
*
|
23 |
* @final
|
24 |
*/
|
25 |
+
class Twig_TokenParser_Block extends Twig_TokenParser
|
26 |
{
|
27 |
+
public function parse(Twig_Token $token)
|
28 |
{
|
29 |
$lineno = $token->getLine();
|
30 |
$stream = $this->parser->getStream();
|
31 |
+
$name = $stream->expect(Twig_Token::NAME_TYPE)->getValue();
|
32 |
if ($this->parser->hasBlock($name)) {
|
33 |
+
throw new Twig_Error_Syntax(sprintf("The block '%s' has already been defined line %d.", $name, $this->parser->getBlock($name)->getTemplateLine()), $stream->getCurrent()->getLine(), $stream->getSourceContext());
|
34 |
}
|
35 |
+
$this->parser->setBlock($name, $block = new Twig_Node_Block($name, new Twig_Node(array()), $lineno));
|
36 |
$this->parser->pushLocalScope();
|
37 |
$this->parser->pushBlockStack($name);
|
38 |
|
39 |
+
if ($stream->nextIf(Twig_Token::BLOCK_END_TYPE)) {
|
40 |
+
$body = $this->parser->subparse(array($this, 'decideBlockEnd'), true);
|
41 |
+
if ($token = $stream->nextIf(Twig_Token::NAME_TYPE)) {
|
42 |
$value = $token->getValue();
|
43 |
|
44 |
if ($value != $name) {
|
45 |
+
throw new Twig_Error_Syntax(sprintf('Expected endblock for block "%s" (but "%s" given).', $name, $value), $stream->getCurrent()->getLine(), $stream->getSourceContext());
|
46 |
}
|
47 |
}
|
48 |
} else {
|
49 |
+
$body = new Twig_Node(array(
|
50 |
+
new Twig_Node_Print($this->parser->getExpressionParser()->parseExpression(), $lineno),
|
51 |
+
));
|
52 |
}
|
53 |
+
$stream->expect(Twig_Token::BLOCK_END_TYPE);
|
54 |
|
55 |
$block->setNode('body', $body);
|
56 |
$this->parser->popBlockStack();
|
57 |
$this->parser->popLocalScope();
|
58 |
|
59 |
+
return new Twig_Node_BlockReference($name, $lineno, $this->getTag());
|
60 |
}
|
61 |
|
62 |
+
public function decideBlockEnd(Twig_Token $token)
|
63 |
{
|
64 |
return $token->test('endblock');
|
65 |
}
|
69 |
return 'block';
|
70 |
}
|
71 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/TokenParser/Deprecated.php
DELETED
@@ -1,43 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of Twig.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
use Twig\Node\DeprecatedNode;
|
13 |
-
use Twig\Token;
|
14 |
-
use Twig\TokenParser\AbstractTokenParser;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Deprecates a section of a template.
|
18 |
-
*
|
19 |
-
* {% deprecated 'The "base.twig" template is deprecated, use "layout.twig" instead.' %}
|
20 |
-
* {% extends 'layout.html.twig' %}
|
21 |
-
*
|
22 |
-
* @author Yonel Ceruto <yonelceruto@gmail.com>
|
23 |
-
*
|
24 |
-
* @final
|
25 |
-
*/
|
26 |
-
class Twig_TokenParser_Deprecated extends AbstractTokenParser
|
27 |
-
{
|
28 |
-
public function parse(Token $token)
|
29 |
-
{
|
30 |
-
$expr = $this->parser->getExpressionParser()->parseExpression();
|
31 |
-
|
32 |
-
$this->parser->getStream()->expect(Token::BLOCK_END_TYPE);
|
33 |
-
|
34 |
-
return new DeprecatedNode($expr, $token->getLine(), $this->getTag());
|
35 |
-
}
|
36 |
-
|
37 |
-
public function getTag()
|
38 |
-
{
|
39 |
-
return 'deprecated';
|
40 |
-
}
|
41 |
-
}
|
42 |
-
|
43 |
-
class_alias('Twig_TokenParser_Deprecated', 'Twig\TokenParser\DeprecatedTokenParser', false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/lib/Twig/TokenParser/Do.php
CHANGED
@@ -9,24 +9,20 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Node\DoNode;
|
13 |
-
use Twig\Token;
|
14 |
-
use Twig\TokenParser\AbstractTokenParser;
|
15 |
-
|
16 |
/**
|
17 |
* Evaluates an expression, discarding the returned value.
|
18 |
*
|
19 |
* @final
|
20 |
*/
|
21 |
-
class Twig_TokenParser_Do extends
|
22 |
{
|
23 |
-
public function parse(
|
24 |
{
|
25 |
$expr = $this->parser->getExpressionParser()->parseExpression();
|
26 |
|
27 |
-
$this->parser->getStream()->expect(
|
28 |
|
29 |
-
return new
|
30 |
}
|
31 |
|
32 |
public function getTag()
|
@@ -34,5 +30,3 @@ class Twig_TokenParser_Do extends AbstractTokenParser
|
|
34 |
return 'do';
|
35 |
}
|
36 |
}
|
37 |
-
|
38 |
-
class_alias('Twig_TokenParser_Do', 'Twig\TokenParser\DoTokenParser', false);
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
|
|
|
|
12 |
/**
|
13 |
* Evaluates an expression, discarding the returned value.
|
14 |
*
|
15 |
* @final
|
16 |
*/
|
17 |
+
class Twig_TokenParser_Do extends Twig_TokenParser
|
18 |
{
|
19 |
+
public function parse(Twig_Token $token)
|
20 |
{
|
21 |
$expr = $this->parser->getExpressionParser()->parseExpression();
|
22 |
|
23 |
+
$this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
|
24 |
|
25 |
+
return new Twig_Node_Do($expr, $token->getLine(), $this->getTag());
|
26 |
}
|
27 |
|
28 |
public function getTag()
|
30 |
return 'do';
|
31 |
}
|
32 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/TokenParser/Embed.php
CHANGED
@@ -9,20 +9,14 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Node\EmbedNode;
|
13 |
-
use Twig\Node\Expression\ConstantExpression;
|
14 |
-
use Twig\Node\Expression\NameExpression;
|
15 |
-
use Twig\Token;
|
16 |
-
use Twig\TokenParser\IncludeTokenParser;
|
17 |
-
|
18 |
/**
|
19 |
* Embeds a template.
|
20 |
*
|
21 |
* @final
|
22 |
*/
|
23 |
-
class Twig_TokenParser_Embed extends
|
24 |
{
|
25 |
-
public function parse(
|
26 |
{
|
27 |
$stream = $this->parser->getStream();
|
28 |
|
@@ -30,22 +24,22 @@ class Twig_TokenParser_Embed extends IncludeTokenParser
|
|
30 |
|
31 |
list($variables, $only, $ignoreMissing) = $this->parseArguments();
|
32 |
|
33 |
-
$parentToken = $fakeParentToken = new
|
34 |
-
if ($parent instanceof
|
35 |
-
$parentToken = new
|
36 |
-
} elseif ($parent instanceof
|
37 |
-
$parentToken = new
|
38 |
}
|
39 |
|
40 |
// inject a fake parent to make the parent() function work
|
41 |
-
$stream->injectTokens(
|
42 |
-
new
|
43 |
-
new
|
44 |
$parentToken,
|
45 |
-
new
|
46 |
-
|
47 |
|
48 |
-
$module = $this->parser->parse($stream,
|
49 |
|
50 |
// override the parent with the correct one
|
51 |
if ($fakeParentToken === $parentToken) {
|
@@ -54,12 +48,12 @@ class Twig_TokenParser_Embed extends IncludeTokenParser
|
|
54 |
|
55 |
$this->parser->embedTemplate($module);
|
56 |
|
57 |
-
$stream->expect(
|
58 |
|
59 |
-
return new
|
60 |
}
|
61 |
|
62 |
-
public function decideBlockEnd(
|
63 |
{
|
64 |
return $token->test('endembed');
|
65 |
}
|
@@ -69,5 +63,3 @@ class Twig_TokenParser_Embed extends IncludeTokenParser
|
|
69 |
return 'embed';
|
70 |
}
|
71 |
}
|
72 |
-
|
73 |
-
class_alias('Twig_TokenParser_Embed', 'Twig\TokenParser\EmbedTokenParser', false);
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
/**
|
13 |
* Embeds a template.
|
14 |
*
|
15 |
* @final
|
16 |
*/
|
17 |
+
class Twig_TokenParser_Embed extends Twig_TokenParser_Include
|
18 |
{
|
19 |
+
public function parse(Twig_Token $token)
|
20 |
{
|
21 |
$stream = $this->parser->getStream();
|
22 |
|
24 |
|
25 |
list($variables, $only, $ignoreMissing) = $this->parseArguments();
|
26 |
|
27 |
+
$parentToken = $fakeParentToken = new Twig_Token(Twig_Token::STRING_TYPE, '__parent__', $token->getLine());
|
28 |
+
if ($parent instanceof Twig_Node_Expression_Constant) {
|
29 |
+
$parentToken = new Twig_Token(Twig_Token::STRING_TYPE, $parent->getAttribute('value'), $token->getLine());
|
30 |
+
} elseif ($parent instanceof Twig_Node_Expression_Name) {
|
31 |
+
$parentToken = new Twig_Token(Twig_Token::NAME_TYPE, $parent->getAttribute('name'), $token->getLine());
|
32 |
}
|
33 |
|
34 |
// inject a fake parent to make the parent() function work
|
35 |
+
$stream->injectTokens(array(
|
36 |
+
new Twig_Token(Twig_Token::BLOCK_START_TYPE, '', $token->getLine()),
|
37 |
+
new Twig_Token(Twig_Token::NAME_TYPE, 'extends', $token->getLine()),
|
38 |
$parentToken,
|
39 |
+
new Twig_Token(Twig_Token::BLOCK_END_TYPE, '', $token->getLine()),
|
40 |
+
));
|
41 |
|
42 |
+
$module = $this->parser->parse($stream, array($this, 'decideBlockEnd'), true);
|
43 |
|
44 |
// override the parent with the correct one
|
45 |
if ($fakeParentToken === $parentToken) {
|
48 |
|
49 |
$this->parser->embedTemplate($module);
|
50 |
|
51 |
+
$stream->expect(Twig_Token::BLOCK_END_TYPE);
|
52 |
|
53 |
+
return new Twig_Node_Embed($module->getTemplateName(), $module->getAttribute('index'), $variables, $only, $ignoreMissing, $token->getLine(), $this->getTag());
|
54 |
}
|
55 |
|
56 |
+
public function decideBlockEnd(Twig_Token $token)
|
57 |
{
|
58 |
return $token->test('endembed');
|
59 |
}
|
63 |
return 'embed';
|
64 |
}
|
65 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/TokenParser/Extends.php
CHANGED
@@ -10,33 +10,31 @@
|
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
|
13 |
-
use Twig\Error\SyntaxError;
|
14 |
-
use Twig\Token;
|
15 |
-
use Twig\TokenParser\AbstractTokenParser;
|
16 |
-
|
17 |
/**
|
18 |
* Extends a template by another one.
|
19 |
*
|
|
|
20 |
* {% extends "base.html" %}
|
|
|
21 |
*
|
22 |
* @final
|
23 |
*/
|
24 |
-
class Twig_TokenParser_Extends extends
|
25 |
{
|
26 |
-
public function parse(
|
27 |
{
|
28 |
$stream = $this->parser->getStream();
|
29 |
|
30 |
if (!$this->parser->isMainScope()) {
|
31 |
-
throw new
|
32 |
}
|
33 |
|
34 |
if (null !== $this->parser->getParent()) {
|
35 |
-
throw new
|
36 |
}
|
37 |
$this->parser->setParent($this->parser->getExpressionParser()->parseExpression());
|
38 |
|
39 |
-
$stream->expect(
|
40 |
}
|
41 |
|
42 |
public function getTag()
|
@@ -44,5 +42,3 @@ class Twig_TokenParser_Extends extends AbstractTokenParser
|
|
44 |
return 'extends';
|
45 |
}
|
46 |
}
|
47 |
-
|
48 |
-
class_alias('Twig_TokenParser_Extends', 'Twig\TokenParser\ExtendsTokenParser', false);
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
|
|
|
|
|
|
|
|
|
13 |
/**
|
14 |
* Extends a template by another one.
|
15 |
*
|
16 |
+
* <pre>
|
17 |
* {% extends "base.html" %}
|
18 |
+
* </pre>
|
19 |
*
|
20 |
* @final
|
21 |
*/
|
22 |
+
class Twig_TokenParser_Extends extends Twig_TokenParser
|
23 |
{
|
24 |
+
public function parse(Twig_Token $token)
|
25 |
{
|
26 |
$stream = $this->parser->getStream();
|
27 |
|
28 |
if (!$this->parser->isMainScope()) {
|
29 |
+
throw new Twig_Error_Syntax('Cannot extend from a block.', $token->getLine(), $stream->getSourceContext());
|
30 |
}
|
31 |
|
32 |
if (null !== $this->parser->getParent()) {
|
33 |
+
throw new Twig_Error_Syntax('Multiple extends tags are forbidden.', $token->getLine(), $stream->getSourceContext());
|
34 |
}
|
35 |
$this->parser->setParent($this->parser->getExpressionParser()->parseExpression());
|
36 |
|
37 |
+
$stream->expect(Twig_Token::BLOCK_END_TYPE);
|
38 |
}
|
39 |
|
40 |
public function getTag()
|
42 |
return 'extends';
|
43 |
}
|
44 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/TokenParser/Filter.php
CHANGED
@@ -9,42 +9,37 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Node\BlockNode;
|
13 |
-
use Twig\Node\Expression\BlockReferenceExpression;
|
14 |
-
use Twig\Node\Expression\ConstantExpression;
|
15 |
-
use Twig\Node\PrintNode;
|
16 |
-
use Twig\Token;
|
17 |
-
use Twig\TokenParser\AbstractTokenParser;
|
18 |
-
|
19 |
/**
|
20 |
* Filters a section of a template by applying filters.
|
21 |
*
|
22 |
-
*
|
23 |
-
*
|
24 |
-
*
|
|
|
|
|
25 |
*
|
26 |
* @final
|
27 |
*/
|
28 |
-
class Twig_TokenParser_Filter extends
|
29 |
{
|
30 |
-
public function parse(
|
31 |
{
|
32 |
$name = $this->parser->getVarName();
|
33 |
-
$ref = new
|
34 |
|
35 |
$filter = $this->parser->getExpressionParser()->parseFilterExpressionRaw($ref, $this->getTag());
|
36 |
-
$this->parser->getStream()->expect(
|
37 |
|
38 |
-
$body = $this->parser->subparse(
|
39 |
-
$this->parser->getStream()->expect(
|
40 |
|
41 |
-
$block = new
|
42 |
$this->parser->setBlock($name, $block);
|
43 |
|
44 |
-
return new
|
45 |
}
|
46 |
|
47 |
-
public function decideBlockEnd(
|
48 |
{
|
49 |
return $token->test('endfilter');
|
50 |
}
|
@@ -54,5 +49,3 @@ class Twig_TokenParser_Filter extends AbstractTokenParser
|
|
54 |
return 'filter';
|
55 |
}
|
56 |
}
|
57 |
-
|
58 |
-
class_alias('Twig_TokenParser_Filter', 'Twig\TokenParser\FilterTokenParser', false);
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
/**
|
13 |
* Filters a section of a template by applying filters.
|
14 |
*
|
15 |
+
* <pre>
|
16 |
+
* {% filter upper %}
|
17 |
+
* This text becomes uppercase
|
18 |
+
* {% endfilter %}
|
19 |
+
* </pre>
|
20 |
*
|
21 |
* @final
|
22 |
*/
|
23 |
+
class Twig_TokenParser_Filter extends Twig_TokenParser
|
24 |
{
|
25 |
+
public function parse(Twig_Token $token)
|
26 |
{
|
27 |
$name = $this->parser->getVarName();
|
28 |
+
$ref = new Twig_Node_Expression_BlockReference(new Twig_Node_Expression_Constant($name, $token->getLine()), null, $token->getLine(), $this->getTag());
|
29 |
|
30 |
$filter = $this->parser->getExpressionParser()->parseFilterExpressionRaw($ref, $this->getTag());
|
31 |
+
$this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
|
32 |
|
33 |
+
$body = $this->parser->subparse(array($this, 'decideBlockEnd'), true);
|
34 |
+
$this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
|
35 |
|
36 |
+
$block = new Twig_Node_Block($name, $body, $token->getLine());
|
37 |
$this->parser->setBlock($name, $block);
|
38 |
|
39 |
+
return new Twig_Node_Print($filter, $token->getLine(), $this->getTag());
|
40 |
}
|
41 |
|
42 |
+
public function decideBlockEnd(Twig_Token $token)
|
43 |
{
|
44 |
return $token->test('endfilter');
|
45 |
}
|
49 |
return 'filter';
|
50 |
}
|
51 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/TokenParser/Flush.php
CHANGED
@@ -9,10 +9,6 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Node\FlushNode;
|
13 |
-
use Twig\Token;
|
14 |
-
use Twig\TokenParser\AbstractTokenParser;
|
15 |
-
|
16 |
/**
|
17 |
* Flushes the output to the client.
|
18 |
*
|
@@ -20,13 +16,13 @@ use Twig\TokenParser\AbstractTokenParser;
|
|
20 |
*
|
21 |
* @final
|
22 |
*/
|
23 |
-
class Twig_TokenParser_Flush extends
|
24 |
{
|
25 |
-
public function parse(
|
26 |
{
|
27 |
-
$this->parser->getStream()->expect(
|
28 |
|
29 |
-
return new
|
30 |
}
|
31 |
|
32 |
public function getTag()
|
@@ -34,5 +30,3 @@ class Twig_TokenParser_Flush extends AbstractTokenParser
|
|
34 |
return 'flush';
|
35 |
}
|
36 |
}
|
37 |
-
|
38 |
-
class_alias('Twig_TokenParser_Flush', 'Twig\TokenParser\FlushTokenParser', false);
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
|
|
|
|
12 |
/**
|
13 |
* Flushes the output to the client.
|
14 |
*
|
16 |
*
|
17 |
* @final
|
18 |
*/
|
19 |
+
class Twig_TokenParser_Flush extends Twig_TokenParser
|
20 |
{
|
21 |
+
public function parse(Twig_Token $token)
|
22 |
{
|
23 |
+
$this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
|
24 |
|
25 |
+
return new Twig_Node_Flush($token->getLine(), $this->getTag());
|
26 |
}
|
27 |
|
28 |
public function getTag()
|
30 |
return 'flush';
|
31 |
}
|
32 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/TokenParser/For.php
CHANGED
@@ -10,61 +10,53 @@
|
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
|
13 |
-
use Twig\Error\SyntaxError;
|
14 |
-
use Twig\Node\Expression\AssignNameExpression;
|
15 |
-
use Twig\Node\Expression\ConstantExpression;
|
16 |
-
use Twig\Node\Expression\GetAttrExpression;
|
17 |
-
use Twig\Node\Expression\NameExpression;
|
18 |
-
use Twig\Node\ForNode;
|
19 |
-
use Twig\Token;
|
20 |
-
use Twig\TokenParser\AbstractTokenParser;
|
21 |
-
use Twig\TokenStream;
|
22 |
-
|
23 |
/**
|
24 |
* Loops over each item of a sequence.
|
25 |
*
|
26 |
-
*
|
27 |
-
*
|
28 |
-
*
|
29 |
-
* {
|
30 |
-
*
|
|
|
|
|
31 |
*
|
32 |
* @final
|
33 |
*/
|
34 |
-
class Twig_TokenParser_For extends
|
35 |
{
|
36 |
-
public function parse(
|
37 |
{
|
38 |
$lineno = $token->getLine();
|
39 |
$stream = $this->parser->getStream();
|
40 |
$targets = $this->parser->getExpressionParser()->parseAssignmentExpression();
|
41 |
-
$stream->expect(
|
42 |
$seq = $this->parser->getExpressionParser()->parseExpression();
|
43 |
|
44 |
$ifexpr = null;
|
45 |
-
if ($stream->nextIf(
|
46 |
$ifexpr = $this->parser->getExpressionParser()->parseExpression();
|
47 |
}
|
48 |
|
49 |
-
$stream->expect(
|
50 |
-
$body = $this->parser->subparse(
|
51 |
-
if (
|
52 |
-
$stream->expect(
|
53 |
-
$else = $this->parser->subparse(
|
54 |
} else {
|
55 |
$else = null;
|
56 |
}
|
57 |
-
$stream->expect(
|
58 |
|
59 |
-
if (
|
60 |
$keyTarget = $targets->getNode(0);
|
61 |
-
$keyTarget = new
|
62 |
$valueTarget = $targets->getNode(1);
|
63 |
-
$valueTarget = new
|
64 |
} else {
|
65 |
-
$keyTarget = new
|
66 |
$valueTarget = $targets->getNode(0);
|
67 |
-
$valueTarget = new
|
68 |
}
|
69 |
|
70 |
if ($ifexpr) {
|
@@ -72,24 +64,24 @@ class Twig_TokenParser_For extends AbstractTokenParser
|
|
72 |
$this->checkLoopUsageBody($stream, $body);
|
73 |
}
|
74 |
|
75 |
-
return new
|
76 |
}
|
77 |
|
78 |
-
public function decideForFork(
|
79 |
{
|
80 |
-
return $token->test(
|
81 |
}
|
82 |
|
83 |
-
public function decideForEnd(
|
84 |
{
|
85 |
return $token->test('endfor');
|
86 |
}
|
87 |
|
88 |
// the loop variable cannot be used in the condition
|
89 |
-
protected function checkLoopUsageCondition(
|
90 |
{
|
91 |
-
if ($node instanceof
|
92 |
-
throw new
|
93 |
}
|
94 |
|
95 |
foreach ($node as $n) {
|
@@ -103,17 +95,17 @@ class Twig_TokenParser_For extends AbstractTokenParser
|
|
103 |
|
104 |
// check usage of non-defined loop-items
|
105 |
// it does not catch all problems (for instance when a for is included into another or when the variable is used in an include)
|
106 |
-
protected function checkLoopUsageBody(
|
107 |
{
|
108 |
-
if ($node instanceof
|
109 |
$attribute = $node->getNode('attribute');
|
110 |
-
if ($attribute instanceof
|
111 |
-
throw new
|
112 |
}
|
113 |
}
|
114 |
|
115 |
// should check for parent.loop.XXX usage
|
116 |
-
if ($node instanceof
|
117 |
return;
|
118 |
}
|
119 |
|
@@ -131,5 +123,3 @@ class Twig_TokenParser_For extends AbstractTokenParser
|
|
131 |
return 'for';
|
132 |
}
|
133 |
}
|
134 |
-
|
135 |
-
class_alias('Twig_TokenParser_For', 'Twig\TokenParser\ForTokenParser', false);
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
/**
|
14 |
* Loops over each item of a sequence.
|
15 |
*
|
16 |
+
* <pre>
|
17 |
+
* <ul>
|
18 |
+
* {% for user in users %}
|
19 |
+
* <li>{{ user.username|e }}</li>
|
20 |
+
* {% endfor %}
|
21 |
+
* </ul>
|
22 |
+
* </pre>
|
23 |
*
|
24 |
* @final
|
25 |
*/
|
26 |
+
class Twig_TokenParser_For extends Twig_TokenParser
|
27 |
{
|
28 |
+
public function parse(Twig_Token $token)
|
29 |
{
|
30 |
$lineno = $token->getLine();
|
31 |
$stream = $this->parser->getStream();
|
32 |
$targets = $this->parser->getExpressionParser()->parseAssignmentExpression();
|
33 |
+
$stream->expect(Twig_Token::OPERATOR_TYPE, 'in');
|
34 |
$seq = $this->parser->getExpressionParser()->parseExpression();
|
35 |
|
36 |
$ifexpr = null;
|
37 |
+
if ($stream->nextIf(Twig_Token::NAME_TYPE, 'if')) {
|
38 |
$ifexpr = $this->parser->getExpressionParser()->parseExpression();
|
39 |
}
|
40 |
|
41 |
+
$stream->expect(Twig_Token::BLOCK_END_TYPE);
|
42 |
+
$body = $this->parser->subparse(array($this, 'decideForFork'));
|
43 |
+
if ($stream->next()->getValue() == 'else') {
|
44 |
+
$stream->expect(Twig_Token::BLOCK_END_TYPE);
|
45 |
+
$else = $this->parser->subparse(array($this, 'decideForEnd'), true);
|
46 |
} else {
|
47 |
$else = null;
|
48 |
}
|
49 |
+
$stream->expect(Twig_Token::BLOCK_END_TYPE);
|
50 |
|
51 |
+
if (count($targets) > 1) {
|
52 |
$keyTarget = $targets->getNode(0);
|
53 |
+
$keyTarget = new Twig_Node_Expression_AssignName($keyTarget->getAttribute('name'), $keyTarget->getTemplateLine());
|
54 |
$valueTarget = $targets->getNode(1);
|
55 |
+
$valueTarget = new Twig_Node_Expression_AssignName($valueTarget->getAttribute('name'), $valueTarget->getTemplateLine());
|
56 |
} else {
|
57 |
+
$keyTarget = new Twig_Node_Expression_AssignName('_key', $lineno);
|
58 |
$valueTarget = $targets->getNode(0);
|
59 |
+
$valueTarget = new Twig_Node_Expression_AssignName($valueTarget->getAttribute('name'), $valueTarget->getTemplateLine());
|
60 |
}
|
61 |
|
62 |
if ($ifexpr) {
|
64 |
$this->checkLoopUsageBody($stream, $body);
|
65 |
}
|
66 |
|
67 |
+
return new Twig_Node_For($keyTarget, $valueTarget, $seq, $ifexpr, $body, $else, $lineno, $this->getTag());
|
68 |
}
|
69 |
|
70 |
+
public function decideForFork(Twig_Token $token)
|
71 |
{
|
72 |
+
return $token->test(array('else', 'endfor'));
|
73 |
}
|
74 |
|
75 |
+
public function decideForEnd(Twig_Token $token)
|
76 |
{
|
77 |
return $token->test('endfor');
|
78 |
}
|
79 |
|
80 |
// the loop variable cannot be used in the condition
|
81 |
+
protected function checkLoopUsageCondition(Twig_TokenStream $stream, Twig_NodeInterface $node)
|
82 |
{
|
83 |
+
if ($node instanceof Twig_Node_Expression_GetAttr && $node->getNode('node') instanceof Twig_Node_Expression_Name && 'loop' == $node->getNode('node')->getAttribute('name')) {
|
84 |
+
throw new Twig_Error_Syntax('The "loop" variable cannot be used in a looping condition.', $node->getTemplateLine(), $stream->getSourceContext());
|
85 |
}
|
86 |
|
87 |
foreach ($node as $n) {
|
95 |
|
96 |
// check usage of non-defined loop-items
|
97 |
// it does not catch all problems (for instance when a for is included into another or when the variable is used in an include)
|
98 |
+
protected function checkLoopUsageBody(Twig_TokenStream $stream, Twig_NodeInterface $node)
|
99 |
{
|
100 |
+
if ($node instanceof Twig_Node_Expression_GetAttr && $node->getNode('node') instanceof Twig_Node_Expression_Name && 'loop' == $node->getNode('node')->getAttribute('name')) {
|
101 |
$attribute = $node->getNode('attribute');
|
102 |
+
if ($attribute instanceof Twig_Node_Expression_Constant && in_array($attribute->getAttribute('value'), array('length', 'revindex0', 'revindex', 'last'))) {
|
103 |
+
throw new Twig_Error_Syntax(sprintf('The "loop.%s" variable is not defined when looping with a condition.', $attribute->getAttribute('value')), $node->getTemplateLine(), $stream->getSourceContext());
|
104 |
}
|
105 |
}
|
106 |
|
107 |
// should check for parent.loop.XXX usage
|
108 |
+
if ($node instanceof Twig_Node_For) {
|
109 |
return;
|
110 |
}
|
111 |
|
123 |
return 'for';
|
124 |
}
|
125 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/TokenParser/From.php
CHANGED
@@ -9,50 +9,46 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Error\SyntaxError;
|
13 |
-
use Twig\Node\Expression\AssignNameExpression;
|
14 |
-
use Twig\Node\ImportNode;
|
15 |
-
use Twig\Token;
|
16 |
-
use Twig\TokenParser\AbstractTokenParser;
|
17 |
-
|
18 |
/**
|
19 |
* Imports macros.
|
20 |
*
|
|
|
21 |
* {% from 'forms.html' import forms %}
|
|
|
22 |
*
|
23 |
* @final
|
24 |
*/
|
25 |
-
class Twig_TokenParser_From extends
|
26 |
{
|
27 |
-
public function parse(
|
28 |
{
|
29 |
$macro = $this->parser->getExpressionParser()->parseExpression();
|
30 |
$stream = $this->parser->getStream();
|
31 |
$stream->expect('import');
|
32 |
|
33 |
-
$targets =
|
34 |
do {
|
35 |
-
$name = $stream->expect(
|
36 |
|
37 |
$alias = $name;
|
38 |
if ($stream->nextIf('as')) {
|
39 |
-
$alias = $stream->expect(
|
40 |
}
|
41 |
|
42 |
$targets[$name] = $alias;
|
43 |
|
44 |
-
if (!$stream->nextIf(
|
45 |
break;
|
46 |
}
|
47 |
} while (true);
|
48 |
|
49 |
-
$stream->expect(
|
50 |
|
51 |
-
$node = new
|
52 |
|
53 |
foreach ($targets as $name => $alias) {
|
54 |
if ($this->parser->isReservedMacroName($name)) {
|
55 |
-
throw new
|
56 |
}
|
57 |
|
58 |
$this->parser->addImportedSymbol('function', $alias, 'get'.$name, $node->getNode('var'));
|
@@ -66,5 +62,3 @@ class Twig_TokenParser_From extends AbstractTokenParser
|
|
66 |
return 'from';
|
67 |
}
|
68 |
}
|
69 |
-
|
70 |
-
class_alias('Twig_TokenParser_From', 'Twig\TokenParser\FromTokenParser', false);
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
/**
|
13 |
* Imports macros.
|
14 |
*
|
15 |
+
* <pre>
|
16 |
* {% from 'forms.html' import forms %}
|
17 |
+
* </pre>
|
18 |
*
|
19 |
* @final
|
20 |
*/
|
21 |
+
class Twig_TokenParser_From extends Twig_TokenParser
|
22 |
{
|
23 |
+
public function parse(Twig_Token $token)
|
24 |
{
|
25 |
$macro = $this->parser->getExpressionParser()->parseExpression();
|
26 |
$stream = $this->parser->getStream();
|
27 |
$stream->expect('import');
|
28 |
|
29 |
+
$targets = array();
|
30 |
do {
|
31 |
+
$name = $stream->expect(Twig_Token::NAME_TYPE)->getValue();
|
32 |
|
33 |
$alias = $name;
|
34 |
if ($stream->nextIf('as')) {
|
35 |
+
$alias = $stream->expect(Twig_Token::NAME_TYPE)->getValue();
|
36 |
}
|
37 |
|
38 |
$targets[$name] = $alias;
|
39 |
|
40 |
+
if (!$stream->nextIf(Twig_Token::PUNCTUATION_TYPE, ',')) {
|
41 |
break;
|
42 |
}
|
43 |
} while (true);
|
44 |
|
45 |
+
$stream->expect(Twig_Token::BLOCK_END_TYPE);
|
46 |
|
47 |
+
$node = new Twig_Node_Import($macro, new Twig_Node_Expression_AssignName($this->parser->getVarName(), $token->getLine()), $token->getLine(), $this->getTag());
|
48 |
|
49 |
foreach ($targets as $name => $alias) {
|
50 |
if ($this->parser->isReservedMacroName($name)) {
|
51 |
+
throw new Twig_Error_Syntax(sprintf('"%s" cannot be an imported macro as it is a reserved keyword.', $name), $token->getLine(), $stream->getSourceContext());
|
52 |
}
|
53 |
|
54 |
$this->parser->addImportedSymbol('function', $alias, 'get'.$name, $node->getNode('var'));
|
62 |
return 'from';
|
63 |
}
|
64 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/TokenParser/If.php
CHANGED
@@ -10,49 +10,45 @@
|
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
|
13 |
-
use Twig\Error\SyntaxError;
|
14 |
-
use Twig\Node\IfNode;
|
15 |
-
use Twig\Node\Node;
|
16 |
-
use Twig\Token;
|
17 |
-
use Twig\TokenParser\AbstractTokenParser;
|
18 |
-
|
19 |
/**
|
20 |
* Tests a condition.
|
21 |
*
|
22 |
-
*
|
23 |
-
*
|
24 |
-
*
|
25 |
-
*
|
26 |
-
* {
|
27 |
-
*
|
28 |
-
*
|
|
|
|
|
29 |
*
|
30 |
* @final
|
31 |
*/
|
32 |
-
class Twig_TokenParser_If extends
|
33 |
{
|
34 |
-
public function parse(
|
35 |
{
|
36 |
$lineno = $token->getLine();
|
37 |
$expr = $this->parser->getExpressionParser()->parseExpression();
|
38 |
$stream = $this->parser->getStream();
|
39 |
-
$stream->expect(
|
40 |
-
$body = $this->parser->subparse(
|
41 |
-
$tests =
|
42 |
$else = null;
|
43 |
|
44 |
$end = false;
|
45 |
while (!$end) {
|
46 |
switch ($stream->next()->getValue()) {
|
47 |
case 'else':
|
48 |
-
$stream->expect(
|
49 |
-
$else = $this->parser->subparse(
|
50 |
break;
|
51 |
|
52 |
case 'elseif':
|
53 |
$expr = $this->parser->getExpressionParser()->parseExpression();
|
54 |
-
$stream->expect(
|
55 |
-
$body = $this->parser->subparse(
|
56 |
$tests[] = $expr;
|
57 |
$tests[] = $body;
|
58 |
break;
|
@@ -62,23 +58,23 @@ class Twig_TokenParser_If extends AbstractTokenParser
|
|
62 |
break;
|
63 |
|
64 |
default:
|
65 |
-
throw new
|
66 |
}
|
67 |
}
|
68 |
|
69 |
-
$stream->expect(
|
70 |
|
71 |
-
return new
|
72 |
}
|
73 |
|
74 |
-
public function decideIfFork(
|
75 |
{
|
76 |
-
return $token->test(
|
77 |
}
|
78 |
|
79 |
-
public function decideIfEnd(
|
80 |
{
|
81 |
-
return $token->test(
|
82 |
}
|
83 |
|
84 |
public function getTag()
|
@@ -86,5 +82,3 @@ class Twig_TokenParser_If extends AbstractTokenParser
|
|
86 |
return 'if';
|
87 |
}
|
88 |
}
|
89 |
-
|
90 |
-
class_alias('Twig_TokenParser_If', 'Twig\TokenParser\IfTokenParser', false);
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
/**
|
14 |
* Tests a condition.
|
15 |
*
|
16 |
+
* <pre>
|
17 |
+
* {% if users %}
|
18 |
+
* <ul>
|
19 |
+
* {% for user in users %}
|
20 |
+
* <li>{{ user.username|e }}</li>
|
21 |
+
* {% endfor %}
|
22 |
+
* </ul>
|
23 |
+
* {% endif %}
|
24 |
+
* </pre>
|
25 |
*
|
26 |
* @final
|
27 |
*/
|
28 |
+
class Twig_TokenParser_If extends Twig_TokenParser
|
29 |
{
|
30 |
+
public function parse(Twig_Token $token)
|
31 |
{
|
32 |
$lineno = $token->getLine();
|
33 |
$expr = $this->parser->getExpressionParser()->parseExpression();
|
34 |
$stream = $this->parser->getStream();
|
35 |
+
$stream->expect(Twig_Token::BLOCK_END_TYPE);
|
36 |
+
$body = $this->parser->subparse(array($this, 'decideIfFork'));
|
37 |
+
$tests = array($expr, $body);
|
38 |
$else = null;
|
39 |
|
40 |
$end = false;
|
41 |
while (!$end) {
|
42 |
switch ($stream->next()->getValue()) {
|
43 |
case 'else':
|
44 |
+
$stream->expect(Twig_Token::BLOCK_END_TYPE);
|
45 |
+
$else = $this->parser->subparse(array($this, 'decideIfEnd'));
|
46 |
break;
|
47 |
|
48 |
case 'elseif':
|
49 |
$expr = $this->parser->getExpressionParser()->parseExpression();
|
50 |
+
$stream->expect(Twig_Token::BLOCK_END_TYPE);
|
51 |
+
$body = $this->parser->subparse(array($this, 'decideIfFork'));
|
52 |
$tests[] = $expr;
|
53 |
$tests[] = $body;
|
54 |
break;
|
58 |
break;
|
59 |
|
60 |
default:
|
61 |
+
throw new Twig_Error_Syntax(sprintf('Unexpected end of template. Twig was looking for the following tags "else", "elseif", or "endif" to close the "if" block started at line %d).', $lineno), $stream->getCurrent()->getLine(), $stream->getSourceContext());
|
62 |
}
|
63 |
}
|
64 |
|
65 |
+
$stream->expect(Twig_Token::BLOCK_END_TYPE);
|
66 |
|
67 |
+
return new Twig_Node_If(new Twig_Node($tests), $else, $lineno, $this->getTag());
|
68 |
}
|
69 |
|
70 |
+
public function decideIfFork(Twig_Token $token)
|
71 |
{
|
72 |
+
return $token->test(array('elseif', 'else', 'endif'));
|
73 |
}
|
74 |
|
75 |
+
public function decideIfEnd(Twig_Token $token)
|
76 |
{
|
77 |
+
return $token->test(array('endif'));
|
78 |
}
|
79 |
|
80 |
public function getTag()
|
82 |
return 'if';
|
83 |
}
|
84 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/TokenParser/Import.php
CHANGED
@@ -9,30 +9,27 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Node\Expression\AssignNameExpression;
|
13 |
-
use Twig\Node\ImportNode;
|
14 |
-
use Twig\Token;
|
15 |
-
use Twig\TokenParser\AbstractTokenParser;
|
16 |
-
|
17 |
/**
|
18 |
* Imports macros.
|
19 |
*
|
|
|
20 |
* {% import 'forms.html' as forms %}
|
|
|
21 |
*
|
22 |
* @final
|
23 |
*/
|
24 |
-
class Twig_TokenParser_Import extends
|
25 |
{
|
26 |
-
public function parse(
|
27 |
{
|
28 |
$macro = $this->parser->getExpressionParser()->parseExpression();
|
29 |
$this->parser->getStream()->expect('as');
|
30 |
-
$var = new
|
31 |
-
$this->parser->getStream()->expect(
|
32 |
|
33 |
$this->parser->addImportedSymbol('template', $var->getAttribute('name'));
|
34 |
|
35 |
-
return new
|
36 |
}
|
37 |
|
38 |
public function getTag()
|
@@ -40,5 +37,3 @@ class Twig_TokenParser_Import extends AbstractTokenParser
|
|
40 |
return 'import';
|
41 |
}
|
42 |
}
|
43 |
-
|
44 |
-
class_alias('Twig_TokenParser_Import', 'Twig\TokenParser\ImportTokenParser', false);
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
|
|
|
|
|
|
12 |
/**
|
13 |
* Imports macros.
|
14 |
*
|
15 |
+
* <pre>
|
16 |
* {% import 'forms.html' as forms %}
|
17 |
+
* </pre>
|
18 |
*
|
19 |
* @final
|
20 |
*/
|
21 |
+
class Twig_TokenParser_Import extends Twig_TokenParser
|
22 |
{
|
23 |
+
public function parse(Twig_Token $token)
|
24 |
{
|
25 |
$macro = $this->parser->getExpressionParser()->parseExpression();
|
26 |
$this->parser->getStream()->expect('as');
|
27 |
+
$var = new Twig_Node_Expression_AssignName($this->parser->getStream()->expect(Twig_Token::NAME_TYPE)->getValue(), $token->getLine());
|
28 |
+
$this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
|
29 |
|
30 |
$this->parser->addImportedSymbol('template', $var->getAttribute('name'));
|
31 |
|
32 |
+
return new Twig_Node_Import($macro, $var, $token->getLine(), $this->getTag());
|
33 |
}
|
34 |
|
35 |
public function getTag()
|
37 |
return 'import';
|
38 |
}
|
39 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/TokenParser/Include.php
CHANGED
@@ -10,26 +10,26 @@
|
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
|
13 |
-
use Twig\Node\IncludeNode;
|
14 |
-
use Twig\Token;
|
15 |
-
use Twig\TokenParser\AbstractTokenParser;
|
16 |
-
|
17 |
/**
|
18 |
* Includes a template.
|
19 |
*
|
|
|
20 |
* {% include 'header.html' %}
|
21 |
* Body
|
22 |
* {% include 'footer.html' %}
|
|
|
|
|
|
|
23 |
*/
|
24 |
-
class Twig_TokenParser_Include extends
|
25 |
{
|
26 |
-
public function parse(
|
27 |
{
|
28 |
$expr = $this->parser->getExpressionParser()->parseExpression();
|
29 |
|
30 |
list($variables, $only, $ignoreMissing) = $this->parseArguments();
|
31 |
|
32 |
-
return new
|
33 |
}
|
34 |
|
35 |
protected function parseArguments()
|
@@ -37,25 +37,25 @@ class Twig_TokenParser_Include extends AbstractTokenParser
|
|
37 |
$stream = $this->parser->getStream();
|
38 |
|
39 |
$ignoreMissing = false;
|
40 |
-
if ($stream->nextIf(
|
41 |
-
$stream->expect(
|
42 |
|
43 |
$ignoreMissing = true;
|
44 |
}
|
45 |
|
46 |
$variables = null;
|
47 |
-
if ($stream->nextIf(
|
48 |
$variables = $this->parser->getExpressionParser()->parseExpression();
|
49 |
}
|
50 |
|
51 |
$only = false;
|
52 |
-
if ($stream->nextIf(
|
53 |
$only = true;
|
54 |
}
|
55 |
|
56 |
-
$stream->expect(
|
57 |
|
58 |
-
return
|
59 |
}
|
60 |
|
61 |
public function getTag()
|
@@ -63,5 +63,3 @@ class Twig_TokenParser_Include extends AbstractTokenParser
|
|
63 |
return 'include';
|
64 |
}
|
65 |
}
|
66 |
-
|
67 |
-
class_alias('Twig_TokenParser_Include', 'Twig\TokenParser\IncludeTokenParser', false);
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
|
|
|
|
|
|
|
|
|
13 |
/**
|
14 |
* Includes a template.
|
15 |
*
|
16 |
+
* <pre>
|
17 |
* {% include 'header.html' %}
|
18 |
* Body
|
19 |
* {% include 'footer.html' %}
|
20 |
+
* </pre>
|
21 |
+
*
|
22 |
+
* @final
|
23 |
*/
|
24 |
+
class Twig_TokenParser_Include extends Twig_TokenParser
|
25 |
{
|
26 |
+
public function parse(Twig_Token $token)
|
27 |
{
|
28 |
$expr = $this->parser->getExpressionParser()->parseExpression();
|
29 |
|
30 |
list($variables, $only, $ignoreMissing) = $this->parseArguments();
|
31 |
|
32 |
+
return new Twig_Node_Include($expr, $variables, $only, $ignoreMissing, $token->getLine(), $this->getTag());
|
33 |
}
|
34 |
|
35 |
protected function parseArguments()
|
37 |
$stream = $this->parser->getStream();
|
38 |
|
39 |
$ignoreMissing = false;
|
40 |
+
if ($stream->nextIf(Twig_Token::NAME_TYPE, 'ignore')) {
|
41 |
+
$stream->expect(Twig_Token::NAME_TYPE, 'missing');
|
42 |
|
43 |
$ignoreMissing = true;
|
44 |
}
|
45 |
|
46 |
$variables = null;
|
47 |
+
if ($stream->nextIf(Twig_Token::NAME_TYPE, 'with')) {
|
48 |
$variables = $this->parser->getExpressionParser()->parseExpression();
|
49 |
}
|
50 |
|
51 |
$only = false;
|
52 |
+
if ($stream->nextIf(Twig_Token::NAME_TYPE, 'only')) {
|
53 |
$only = true;
|
54 |
}
|
55 |
|
56 |
+
$stream->expect(Twig_Token::BLOCK_END_TYPE);
|
57 |
|
58 |
+
return array($variables, $only, $ignoreMissing);
|
59 |
}
|
60 |
|
61 |
public function getTag()
|
63 |
return 'include';
|
64 |
}
|
65 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/TokenParser/Macro.php
CHANGED
@@ -9,48 +9,44 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Error\SyntaxError;
|
13 |
-
use Twig\Node\BodyNode;
|
14 |
-
use Twig\Node\MacroNode;
|
15 |
-
use Twig\Token;
|
16 |
-
use Twig\TokenParser\AbstractTokenParser;
|
17 |
-
|
18 |
/**
|
19 |
* Defines a macro.
|
20 |
*
|
21 |
-
*
|
22 |
-
*
|
23 |
-
*
|
|
|
|
|
24 |
*
|
25 |
* @final
|
26 |
*/
|
27 |
-
class Twig_TokenParser_Macro extends
|
28 |
{
|
29 |
-
public function parse(
|
30 |
{
|
31 |
$lineno = $token->getLine();
|
32 |
$stream = $this->parser->getStream();
|
33 |
-
$name = $stream->expect(
|
34 |
|
35 |
$arguments = $this->parser->getExpressionParser()->parseArguments(true, true);
|
36 |
|
37 |
-
$stream->expect(
|
38 |
$this->parser->pushLocalScope();
|
39 |
-
$body = $this->parser->subparse(
|
40 |
-
if ($token = $stream->nextIf(
|
41 |
$value = $token->getValue();
|
42 |
|
43 |
if ($value != $name) {
|
44 |
-
throw new
|
45 |
}
|
46 |
}
|
47 |
$this->parser->popLocalScope();
|
48 |
-
$stream->expect(
|
49 |
|
50 |
-
$this->parser->setMacro($name, new
|
51 |
}
|
52 |
|
53 |
-
public function decideBlockEnd(
|
54 |
{
|
55 |
return $token->test('endmacro');
|
56 |
}
|
@@ -60,5 +56,3 @@ class Twig_TokenParser_Macro extends AbstractTokenParser
|
|
60 |
return 'macro';
|
61 |
}
|
62 |
}
|
63 |
-
|
64 |
-
class_alias('Twig_TokenParser_Macro', 'Twig\TokenParser\MacroTokenParser', false);
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
/**
|
13 |
* Defines a macro.
|
14 |
*
|
15 |
+
* <pre>
|
16 |
+
* {% macro input(name, value, type, size) %}
|
17 |
+
* <input type="{{ type|default('text') }}" name="{{ name }}" value="{{ value|e }}" size="{{ size|default(20) }}" />
|
18 |
+
* {% endmacro %}
|
19 |
+
* </pre>
|
20 |
*
|
21 |
* @final
|
22 |
*/
|
23 |
+
class Twig_TokenParser_Macro extends Twig_TokenParser
|
24 |
{
|
25 |
+
public function parse(Twig_Token $token)
|
26 |
{
|
27 |
$lineno = $token->getLine();
|
28 |
$stream = $this->parser->getStream();
|
29 |
+
$name = $stream->expect(Twig_Token::NAME_TYPE)->getValue();
|
30 |
|
31 |
$arguments = $this->parser->getExpressionParser()->parseArguments(true, true);
|
32 |
|
33 |
+
$stream->expect(Twig_Token::BLOCK_END_TYPE);
|
34 |
$this->parser->pushLocalScope();
|
35 |
+
$body = $this->parser->subparse(array($this, 'decideBlockEnd'), true);
|
36 |
+
if ($token = $stream->nextIf(Twig_Token::NAME_TYPE)) {
|
37 |
$value = $token->getValue();
|
38 |
|
39 |
if ($value != $name) {
|
40 |
+
throw new Twig_Error_Syntax(sprintf('Expected endmacro for macro "%s" (but "%s" given).', $name, $value), $stream->getCurrent()->getLine(), $stream->getSourceContext());
|
41 |
}
|
42 |
}
|
43 |
$this->parser->popLocalScope();
|
44 |
+
$stream->expect(Twig_Token::BLOCK_END_TYPE);
|
45 |
|
46 |
+
$this->parser->setMacro($name, new Twig_Node_Macro($name, new Twig_Node_Body(array($body)), $arguments, $lineno, $this->getTag()));
|
47 |
}
|
48 |
|
49 |
+
public function decideBlockEnd(Twig_Token $token)
|
50 |
{
|
51 |
return $token->test('endmacro');
|
52 |
}
|
56 |
return 'macro';
|
57 |
}
|
58 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/TokenParser/Sandbox.php
CHANGED
@@ -9,50 +9,45 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Error\SyntaxError;
|
13 |
-
use Twig\Node\IncludeNode;
|
14 |
-
use Twig\Node\SandboxNode;
|
15 |
-
use Twig\Node\TextNode;
|
16 |
-
use Twig\Token;
|
17 |
-
use Twig\TokenParser\AbstractTokenParser;
|
18 |
-
|
19 |
/**
|
20 |
* Marks a section of a template as untrusted code that must be evaluated in the sandbox mode.
|
21 |
*
|
22 |
-
*
|
23 |
-
*
|
24 |
-
*
|
|
|
|
|
25 |
*
|
26 |
-
* @see
|
27 |
*
|
28 |
* @final
|
29 |
*/
|
30 |
-
class Twig_TokenParser_Sandbox extends
|
31 |
{
|
32 |
-
public function parse(
|
33 |
{
|
34 |
$stream = $this->parser->getStream();
|
35 |
-
$stream->expect(
|
36 |
-
$body = $this->parser->subparse(
|
37 |
-
$stream->expect(
|
38 |
|
39 |
// in a sandbox tag, only include tags are allowed
|
40 |
-
if (!$body instanceof
|
41 |
foreach ($body as $node) {
|
42 |
-
if ($node instanceof
|
43 |
continue;
|
44 |
}
|
45 |
|
46 |
-
if (!$node instanceof
|
47 |
-
throw new
|
48 |
}
|
49 |
}
|
50 |
}
|
51 |
|
52 |
-
return new
|
53 |
}
|
54 |
|
55 |
-
public function decideBlockEnd(
|
56 |
{
|
57 |
return $token->test('endsandbox');
|
58 |
}
|
@@ -62,5 +57,3 @@ class Twig_TokenParser_Sandbox extends AbstractTokenParser
|
|
62 |
return 'sandbox';
|
63 |
}
|
64 |
}
|
65 |
-
|
66 |
-
class_alias('Twig_TokenParser_Sandbox', 'Twig\TokenParser\SandboxTokenParser', false);
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
/**
|
13 |
* Marks a section of a template as untrusted code that must be evaluated in the sandbox mode.
|
14 |
*
|
15 |
+
* <pre>
|
16 |
+
* {% sandbox %}
|
17 |
+
* {% include 'user.html' %}
|
18 |
+
* {% endsandbox %}
|
19 |
+
* </pre>
|
20 |
*
|
21 |
+
* @see http://www.twig-project.org/doc/api.html#sandbox-extension for details
|
22 |
*
|
23 |
* @final
|
24 |
*/
|
25 |
+
class Twig_TokenParser_Sandbox extends Twig_TokenParser
|
26 |
{
|
27 |
+
public function parse(Twig_Token $token)
|
28 |
{
|
29 |
$stream = $this->parser->getStream();
|
30 |
+
$stream->expect(Twig_Token::BLOCK_END_TYPE);
|
31 |
+
$body = $this->parser->subparse(array($this, 'decideBlockEnd'), true);
|
32 |
+
$stream->expect(Twig_Token::BLOCK_END_TYPE);
|
33 |
|
34 |
// in a sandbox tag, only include tags are allowed
|
35 |
+
if (!$body instanceof Twig_Node_Include) {
|
36 |
foreach ($body as $node) {
|
37 |
+
if ($node instanceof Twig_Node_Text && ctype_space($node->getAttribute('data'))) {
|
38 |
continue;
|
39 |
}
|
40 |
|
41 |
+
if (!$node instanceof Twig_Node_Include) {
|
42 |
+
throw new Twig_Error_Syntax('Only "include" tags are allowed within a "sandbox" section.', $node->getTemplateLine(), $stream->getSourceContext());
|
43 |
}
|
44 |
}
|
45 |
}
|
46 |
|
47 |
+
return new Twig_Node_Sandbox($body, $token->getLine(), $this->getTag());
|
48 |
}
|
49 |
|
50 |
+
public function decideBlockEnd(Twig_Token $token)
|
51 |
{
|
52 |
return $token->test('endsandbox');
|
53 |
}
|
57 |
return 'sandbox';
|
58 |
}
|
59 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/TokenParser/Set.php
CHANGED
@@ -9,57 +9,59 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Error\SyntaxError;
|
13 |
-
use Twig\Node\SetNode;
|
14 |
-
use Twig\Token;
|
15 |
-
use Twig\TokenParser\AbstractTokenParser;
|
16 |
-
|
17 |
/**
|
18 |
* Defines a variable.
|
19 |
*
|
|
|
20 |
* {% set foo = 'foo' %}
|
|
|
21 |
* {% set foo = [1, 2] %}
|
|
|
22 |
* {% set foo = {'foo': 'bar'} %}
|
|
|
23 |
* {% set foo = 'foo' ~ 'bar' %}
|
|
|
24 |
* {% set foo, bar = 'foo', 'bar' %}
|
|
|
25 |
* {% set foo %}Some content{% endset %}
|
|
|
26 |
*
|
27 |
* @final
|
28 |
*/
|
29 |
-
class Twig_TokenParser_Set extends
|
30 |
{
|
31 |
-
public function parse(
|
32 |
{
|
33 |
$lineno = $token->getLine();
|
34 |
$stream = $this->parser->getStream();
|
35 |
$names = $this->parser->getExpressionParser()->parseAssignmentExpression();
|
36 |
|
37 |
$capture = false;
|
38 |
-
if ($stream->nextIf(
|
39 |
$values = $this->parser->getExpressionParser()->parseMultitargetExpression();
|
40 |
|
41 |
-
$stream->expect(
|
42 |
|
43 |
-
if (
|
44 |
-
throw new
|
45 |
}
|
46 |
} else {
|
47 |
$capture = true;
|
48 |
|
49 |
-
if (
|
50 |
-
throw new
|
51 |
}
|
52 |
|
53 |
-
$stream->expect(
|
54 |
|
55 |
-
$values = $this->parser->subparse(
|
56 |
-
$stream->expect(
|
57 |
}
|
58 |
|
59 |
-
return new
|
60 |
}
|
61 |
|
62 |
-
public function decideBlockEnd(
|
63 |
{
|
64 |
return $token->test('endset');
|
65 |
}
|
@@ -69,5 +71,3 @@ class Twig_TokenParser_Set extends AbstractTokenParser
|
|
69 |
return 'set';
|
70 |
}
|
71 |
}
|
72 |
-
|
73 |
-
class_alias('Twig_TokenParser_Set', 'Twig\TokenParser\SetTokenParser', false);
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
|
|
|
|
|
|
12 |
/**
|
13 |
* Defines a variable.
|
14 |
*
|
15 |
+
* <pre>
|
16 |
* {% set foo = 'foo' %}
|
17 |
+
*
|
18 |
* {% set foo = [1, 2] %}
|
19 |
+
*
|
20 |
* {% set foo = {'foo': 'bar'} %}
|
21 |
+
*
|
22 |
* {% set foo = 'foo' ~ 'bar' %}
|
23 |
+
*
|
24 |
* {% set foo, bar = 'foo', 'bar' %}
|
25 |
+
*
|
26 |
* {% set foo %}Some content{% endset %}
|
27 |
+
* </pre>
|
28 |
*
|
29 |
* @final
|
30 |
*/
|
31 |
+
class Twig_TokenParser_Set extends Twig_TokenParser
|
32 |
{
|
33 |
+
public function parse(Twig_Token $token)
|
34 |
{
|
35 |
$lineno = $token->getLine();
|
36 |
$stream = $this->parser->getStream();
|
37 |
$names = $this->parser->getExpressionParser()->parseAssignmentExpression();
|
38 |
|
39 |
$capture = false;
|
40 |
+
if ($stream->nextIf(Twig_Token::OPERATOR_TYPE, '=')) {
|
41 |
$values = $this->parser->getExpressionParser()->parseMultitargetExpression();
|
42 |
|
43 |
+
$stream->expect(Twig_Token::BLOCK_END_TYPE);
|
44 |
|
45 |
+
if (count($names) !== count($values)) {
|
46 |
+
throw new Twig_Error_Syntax('When using set, you must have the same number of variables and assignments.', $stream->getCurrent()->getLine(), $stream->getSourceContext());
|
47 |
}
|
48 |
} else {
|
49 |
$capture = true;
|
50 |
|
51 |
+
if (count($names) > 1) {
|
52 |
+
throw new Twig_Error_Syntax('When using set with a block, you cannot have a multi-target.', $stream->getCurrent()->getLine(), $stream->getSourceContext());
|
53 |
}
|
54 |
|
55 |
+
$stream->expect(Twig_Token::BLOCK_END_TYPE);
|
56 |
|
57 |
+
$values = $this->parser->subparse(array($this, 'decideBlockEnd'), true);
|
58 |
+
$stream->expect(Twig_Token::BLOCK_END_TYPE);
|
59 |
}
|
60 |
|
61 |
+
return new Twig_Node_Set($capture, $names, $values, $lineno, $this->getTag());
|
62 |
}
|
63 |
|
64 |
+
public function decideBlockEnd(Twig_Token $token)
|
65 |
{
|
66 |
return $token->test('endset');
|
67 |
}
|
71 |
return 'set';
|
72 |
}
|
73 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/TokenParser/Spaceless.php
CHANGED
@@ -9,36 +9,35 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Node\SpacelessNode;
|
13 |
-
use Twig\Token;
|
14 |
-
use Twig\TokenParser\AbstractTokenParser;
|
15 |
-
|
16 |
/**
|
17 |
* Remove whitespaces between HTML tags.
|
18 |
*
|
19 |
-
*
|
|
|
20 |
* <div>
|
21 |
* <strong>foo</strong>
|
22 |
* </div>
|
23 |
-
*
|
24 |
-
*
|
|
|
|
|
25 |
*
|
26 |
* @final
|
27 |
*/
|
28 |
-
class Twig_TokenParser_Spaceless extends
|
29 |
{
|
30 |
-
public function parse(
|
31 |
{
|
32 |
$lineno = $token->getLine();
|
33 |
|
34 |
-
$this->parser->getStream()->expect(
|
35 |
-
$body = $this->parser->subparse(
|
36 |
-
$this->parser->getStream()->expect(
|
37 |
|
38 |
-
return new
|
39 |
}
|
40 |
|
41 |
-
public function decideSpacelessEnd(
|
42 |
{
|
43 |
return $token->test('endspaceless');
|
44 |
}
|
@@ -48,5 +47,3 @@ class Twig_TokenParser_Spaceless extends AbstractTokenParser
|
|
48 |
return 'spaceless';
|
49 |
}
|
50 |
}
|
51 |
-
|
52 |
-
class_alias('Twig_TokenParser_Spaceless', 'Twig\TokenParser\SpacelessTokenParser', false);
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
|
|
|
|
12 |
/**
|
13 |
* Remove whitespaces between HTML tags.
|
14 |
*
|
15 |
+
* <pre>
|
16 |
+
* {% spaceless %}
|
17 |
* <div>
|
18 |
* <strong>foo</strong>
|
19 |
* </div>
|
20 |
+
* {% endspaceless %}
|
21 |
+
*
|
22 |
+
* {# output will be <div><strong>foo</strong></div> #}
|
23 |
+
* </pre>
|
24 |
*
|
25 |
* @final
|
26 |
*/
|
27 |
+
class Twig_TokenParser_Spaceless extends Twig_TokenParser
|
28 |
{
|
29 |
+
public function parse(Twig_Token $token)
|
30 |
{
|
31 |
$lineno = $token->getLine();
|
32 |
|
33 |
+
$this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
|
34 |
+
$body = $this->parser->subparse(array($this, 'decideSpacelessEnd'), true);
|
35 |
+
$this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
|
36 |
|
37 |
+
return new Twig_Node_Spaceless($body, $lineno, $this->getTag());
|
38 |
}
|
39 |
|
40 |
+
public function decideSpacelessEnd(Twig_Token $token)
|
41 |
{
|
42 |
return $token->test('endspaceless');
|
43 |
}
|
47 |
return 'spaceless';
|
48 |
}
|
49 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/TokenParser/Use.php
CHANGED
@@ -9,60 +9,54 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Error\SyntaxError;
|
13 |
-
use Twig\Node\Expression\ConstantExpression;
|
14 |
-
use Twig\Node\Node;
|
15 |
-
use Twig\Token;
|
16 |
-
use Twig\TokenParser\AbstractTokenParser;
|
17 |
-
|
18 |
/**
|
19 |
* Imports blocks defined in another template into the current template.
|
20 |
*
|
21 |
-
*
|
|
|
22 |
*
|
23 |
-
*
|
24 |
*
|
25 |
-
*
|
26 |
-
*
|
|
|
27 |
*
|
28 |
-
* @see
|
29 |
*
|
30 |
* @final
|
31 |
*/
|
32 |
-
class Twig_TokenParser_Use extends
|
33 |
{
|
34 |
-
public function parse(
|
35 |
{
|
36 |
$template = $this->parser->getExpressionParser()->parseExpression();
|
37 |
$stream = $this->parser->getStream();
|
38 |
|
39 |
-
if (!$template instanceof
|
40 |
-
throw new
|
41 |
}
|
42 |
|
43 |
-
$targets =
|
44 |
if ($stream->nextIf('with')) {
|
45 |
do {
|
46 |
-
$name = $stream->expect(
|
47 |
|
48 |
$alias = $name;
|
49 |
if ($stream->nextIf('as')) {
|
50 |
-
$alias = $stream->expect(
|
51 |
}
|
52 |
|
53 |
-
$targets[$name] = new
|
54 |
|
55 |
-
if (!$stream->nextIf(
|
56 |
break;
|
57 |
}
|
58 |
} while (true);
|
59 |
}
|
60 |
|
61 |
-
$stream->expect(
|
62 |
-
|
63 |
-
$this->parser->addTrait(new Node(['template' => $template, 'targets' => new Node($targets)]));
|
64 |
|
65 |
-
|
66 |
}
|
67 |
|
68 |
public function getTag()
|
@@ -70,5 +64,3 @@ class Twig_TokenParser_Use extends AbstractTokenParser
|
|
70 |
return 'use';
|
71 |
}
|
72 |
}
|
73 |
-
|
74 |
-
class_alias('Twig_TokenParser_Use', 'Twig\TokenParser\UseTokenParser', false);
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
/**
|
13 |
* Imports blocks defined in another template into the current template.
|
14 |
*
|
15 |
+
* <pre>
|
16 |
+
* {% extends "base.html" %}
|
17 |
*
|
18 |
+
* {% use "blocks.html" %}
|
19 |
*
|
20 |
+
* {% block title %}{% endblock %}
|
21 |
+
* {% block content %}{% endblock %}
|
22 |
+
* </pre>
|
23 |
*
|
24 |
+
* @see http://www.twig-project.org/doc/templates.html#horizontal-reuse for details.
|
25 |
*
|
26 |
* @final
|
27 |
*/
|
28 |
+
class Twig_TokenParser_Use extends Twig_TokenParser
|
29 |
{
|
30 |
+
public function parse(Twig_Token $token)
|
31 |
{
|
32 |
$template = $this->parser->getExpressionParser()->parseExpression();
|
33 |
$stream = $this->parser->getStream();
|
34 |
|
35 |
+
if (!$template instanceof Twig_Node_Expression_Constant) {
|
36 |
+
throw new Twig_Error_Syntax('The template references in a "use" statement must be a string.', $stream->getCurrent()->getLine(), $stream->getSourceContext());
|
37 |
}
|
38 |
|
39 |
+
$targets = array();
|
40 |
if ($stream->nextIf('with')) {
|
41 |
do {
|
42 |
+
$name = $stream->expect(Twig_Token::NAME_TYPE)->getValue();
|
43 |
|
44 |
$alias = $name;
|
45 |
if ($stream->nextIf('as')) {
|
46 |
+
$alias = $stream->expect(Twig_Token::NAME_TYPE)->getValue();
|
47 |
}
|
48 |
|
49 |
+
$targets[$name] = new Twig_Node_Expression_Constant($alias, -1);
|
50 |
|
51 |
+
if (!$stream->nextIf(Twig_Token::PUNCTUATION_TYPE, ',')) {
|
52 |
break;
|
53 |
}
|
54 |
} while (true);
|
55 |
}
|
56 |
|
57 |
+
$stream->expect(Twig_Token::BLOCK_END_TYPE);
|
|
|
|
|
58 |
|
59 |
+
$this->parser->addTrait(new Twig_Node(array('template' => $template, 'targets' => new Twig_Node($targets))));
|
60 |
}
|
61 |
|
62 |
public function getTag()
|
64 |
return 'use';
|
65 |
}
|
66 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/TokenParser/With.php
CHANGED
@@ -9,10 +9,6 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Node\WithNode;
|
13 |
-
use Twig\Token;
|
14 |
-
use Twig\TokenParser\AbstractTokenParser;
|
15 |
-
|
16 |
/**
|
17 |
* Creates a nested scope.
|
18 |
*
|
@@ -20,29 +16,29 @@ use Twig\TokenParser\AbstractTokenParser;
|
|
20 |
*
|
21 |
* @final
|
22 |
*/
|
23 |
-
class Twig_TokenParser_With extends
|
24 |
{
|
25 |
-
public function parse(
|
26 |
{
|
27 |
$stream = $this->parser->getStream();
|
28 |
|
29 |
$variables = null;
|
30 |
$only = false;
|
31 |
-
if (!$stream->test(
|
32 |
$variables = $this->parser->getExpressionParser()->parseExpression();
|
33 |
-
$only = $stream->nextIf(
|
34 |
}
|
35 |
|
36 |
-
$stream->expect(
|
37 |
|
38 |
-
$body = $this->parser->subparse(
|
39 |
|
40 |
-
$stream->expect(
|
41 |
|
42 |
-
return new
|
43 |
}
|
44 |
|
45 |
-
public function decideWithEnd(
|
46 |
{
|
47 |
return $token->test('endwith');
|
48 |
}
|
@@ -52,5 +48,3 @@ class Twig_TokenParser_With extends AbstractTokenParser
|
|
52 |
return 'with';
|
53 |
}
|
54 |
}
|
55 |
-
|
56 |
-
class_alias('Twig_TokenParser_With', 'Twig\TokenParser\WithTokenParser', false);
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
|
|
|
|
12 |
/**
|
13 |
* Creates a nested scope.
|
14 |
*
|
16 |
*
|
17 |
* @final
|
18 |
*/
|
19 |
+
class Twig_TokenParser_With extends Twig_TokenParser
|
20 |
{
|
21 |
+
public function parse(Twig_Token $token)
|
22 |
{
|
23 |
$stream = $this->parser->getStream();
|
24 |
|
25 |
$variables = null;
|
26 |
$only = false;
|
27 |
+
if (!$stream->test(Twig_Token::BLOCK_END_TYPE)) {
|
28 |
$variables = $this->parser->getExpressionParser()->parseExpression();
|
29 |
+
$only = $stream->nextIf(Twig_Token::NAME_TYPE, 'only');
|
30 |
}
|
31 |
|
32 |
+
$stream->expect(Twig_Token::BLOCK_END_TYPE);
|
33 |
|
34 |
+
$body = $this->parser->subparse(array($this, 'decideWithEnd'), true);
|
35 |
|
36 |
+
$stream->expect(Twig_Token::BLOCK_END_TYPE);
|
37 |
|
38 |
+
return new Twig_Node_With($body, $variables, $only, $token->getLine(), $this->getTag());
|
39 |
}
|
40 |
|
41 |
+
public function decideWithEnd(Twig_Token $token)
|
42 |
{
|
43 |
return $token->test('endwith');
|
44 |
}
|
48 |
return 'with';
|
49 |
}
|
50 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/TokenParserBroker.php
CHANGED
@@ -10,8 +10,6 @@
|
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
|
13 |
-
use Twig\TokenParser\TokenParserInterface;
|
14 |
-
|
15 |
/**
|
16 |
* Default implementation of a token parser broker.
|
17 |
*
|
@@ -22,40 +20,40 @@ use Twig\TokenParser\TokenParserInterface;
|
|
22 |
class Twig_TokenParserBroker implements Twig_TokenParserBrokerInterface
|
23 |
{
|
24 |
protected $parser;
|
25 |
-
protected $parsers =
|
26 |
-
protected $brokers =
|
27 |
|
28 |
/**
|
29 |
-
* @param array
|
30 |
-
* @param array
|
31 |
-
* @param bool
|
32 |
*/
|
33 |
-
public function __construct($parsers =
|
34 |
{
|
35 |
if ($triggerDeprecationError) {
|
36 |
@trigger_error('The '.__CLASS__.' class is deprecated since version 1.12 and will be removed in 2.0.', E_USER_DEPRECATED);
|
37 |
}
|
38 |
|
39 |
foreach ($parsers as $parser) {
|
40 |
-
if (!$parser instanceof
|
41 |
-
throw new
|
42 |
}
|
43 |
$this->parsers[$parser->getTag()] = $parser;
|
44 |
}
|
45 |
foreach ($brokers as $broker) {
|
46 |
if (!$broker instanceof Twig_TokenParserBrokerInterface) {
|
47 |
-
throw new
|
48 |
}
|
49 |
$this->brokers[] = $broker;
|
50 |
}
|
51 |
}
|
52 |
|
53 |
-
public function addTokenParser(
|
54 |
{
|
55 |
$this->parsers[$parser->getTag()] = $parser;
|
56 |
}
|
57 |
|
58 |
-
public function removeTokenParser(
|
59 |
{
|
60 |
$name = $parser->getTag();
|
61 |
if (isset($this->parsers[$name]) && $parser === $this->parsers[$name]) {
|
@@ -63,12 +61,12 @@ class Twig_TokenParserBroker implements Twig_TokenParserBrokerInterface
|
|
63 |
}
|
64 |
}
|
65 |
|
66 |
-
public function addTokenParserBroker(
|
67 |
{
|
68 |
$this->brokers[] = $broker;
|
69 |
}
|
70 |
|
71 |
-
public function removeTokenParserBroker(
|
72 |
{
|
73 |
if (false !== $pos = array_search($broker, $this->brokers)) {
|
74 |
unset($this->brokers[$pos]);
|
@@ -82,7 +80,7 @@ class Twig_TokenParserBroker implements Twig_TokenParserBrokerInterface
|
|
82 |
*
|
83 |
* @param string $tag A tag name
|
84 |
*
|
85 |
-
* @return
|
86 |
*/
|
87 |
public function getTokenParser($tag)
|
88 |
{
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
|
|
|
|
|
13 |
/**
|
14 |
* Default implementation of a token parser broker.
|
15 |
*
|
20 |
class Twig_TokenParserBroker implements Twig_TokenParserBrokerInterface
|
21 |
{
|
22 |
protected $parser;
|
23 |
+
protected $parsers = array();
|
24 |
+
protected $brokers = array();
|
25 |
|
26 |
/**
|
27 |
+
* @param array|Traversable $parsers A Traversable of Twig_TokenParserInterface instances
|
28 |
+
* @param array|Traversable $brokers A Traversable of Twig_TokenParserBrokerInterface instances
|
29 |
+
* @param bool $triggerDeprecationError
|
30 |
*/
|
31 |
+
public function __construct($parsers = array(), $brokers = array(), $triggerDeprecationError = true)
|
32 |
{
|
33 |
if ($triggerDeprecationError) {
|
34 |
@trigger_error('The '.__CLASS__.' class is deprecated since version 1.12 and will be removed in 2.0.', E_USER_DEPRECATED);
|
35 |
}
|
36 |
|
37 |
foreach ($parsers as $parser) {
|
38 |
+
if (!$parser instanceof Twig_TokenParserInterface) {
|
39 |
+
throw new LogicException('$parsers must a an array of Twig_TokenParserInterface.');
|
40 |
}
|
41 |
$this->parsers[$parser->getTag()] = $parser;
|
42 |
}
|
43 |
foreach ($brokers as $broker) {
|
44 |
if (!$broker instanceof Twig_TokenParserBrokerInterface) {
|
45 |
+
throw new LogicException('$brokers must a an array of Twig_TokenParserBrokerInterface.');
|
46 |
}
|
47 |
$this->brokers[] = $broker;
|
48 |
}
|
49 |
}
|
50 |
|
51 |
+
public function addTokenParser(Twig_TokenParserInterface $parser)
|
52 |
{
|
53 |
$this->parsers[$parser->getTag()] = $parser;
|
54 |
}
|
55 |
|
56 |
+
public function removeTokenParser(Twig_TokenParserInterface $parser)
|
57 |
{
|
58 |
$name = $parser->getTag();
|
59 |
if (isset($this->parsers[$name]) && $parser === $this->parsers[$name]) {
|
61 |
}
|
62 |
}
|
63 |
|
64 |
+
public function addTokenParserBroker(Twig_TokenParserBroker $broker)
|
65 |
{
|
66 |
$this->brokers[] = $broker;
|
67 |
}
|
68 |
|
69 |
+
public function removeTokenParserBroker(Twig_TokenParserBroker $broker)
|
70 |
{
|
71 |
if (false !== $pos = array_search($broker, $this->brokers)) {
|
72 |
unset($this->brokers[$pos]);
|
80 |
*
|
81 |
* @param string $tag A tag name
|
82 |
*
|
83 |
+
* @return null|Twig_TokenParserInterface A Twig_TokenParserInterface or null if no suitable TokenParser was found
|
84 |
*/
|
85 |
public function getTokenParser($tag)
|
86 |
{
|
vendor/twig/twig/lib/Twig/TokenParserBrokerInterface.php
CHANGED
@@ -10,8 +10,6 @@
|
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
|
13 |
-
use Twig\TokenParser\TokenParserInterface;
|
14 |
-
|
15 |
/**
|
16 |
* Interface implemented by token parser brokers.
|
17 |
*
|
@@ -28,19 +26,19 @@ interface Twig_TokenParserBrokerInterface
|
|
28 |
*
|
29 |
* @param string $tag A tag name
|
30 |
*
|
31 |
-
* @return
|
32 |
*/
|
33 |
public function getTokenParser($tag);
|
34 |
|
35 |
/**
|
36 |
-
* Calls
|
37 |
*/
|
38 |
public function setParser(Twig_ParserInterface $parser);
|
39 |
|
40 |
/**
|
41 |
* Gets the Twig_ParserInterface.
|
42 |
*
|
43 |
-
* @return Twig_ParserInterface
|
44 |
*/
|
45 |
public function getParser();
|
46 |
}
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
|
|
|
|
|
13 |
/**
|
14 |
* Interface implemented by token parser brokers.
|
15 |
*
|
26 |
*
|
27 |
* @param string $tag A tag name
|
28 |
*
|
29 |
+
* @return Twig_TokenParserInterface|null A Twig_TokenParserInterface or null if no suitable TokenParser was found
|
30 |
*/
|
31 |
public function getTokenParser($tag);
|
32 |
|
33 |
/**
|
34 |
+
* Calls Twig_TokenParserInterface::setParser on all parsers the implementation knows of.
|
35 |
*/
|
36 |
public function setParser(Twig_ParserInterface $parser);
|
37 |
|
38 |
/**
|
39 |
* Gets the Twig_ParserInterface.
|
40 |
*
|
41 |
+
* @return null|Twig_ParserInterface A Twig_ParserInterface instance or null
|
42 |
*/
|
43 |
public function getParser();
|
44 |
}
|
vendor/twig/twig/lib/Twig/TokenParserInterface.php
CHANGED
@@ -9,10 +9,6 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Error\SyntaxError;
|
13 |
-
use Twig\Parser;
|
14 |
-
use Twig\Token;
|
15 |
-
|
16 |
/**
|
17 |
* Interface implemented by token parsers.
|
18 |
*
|
@@ -23,16 +19,16 @@ interface Twig_TokenParserInterface
|
|
23 |
/**
|
24 |
* Sets the parser associated with this token parser.
|
25 |
*/
|
26 |
-
public function setParser(
|
27 |
|
28 |
/**
|
29 |
* Parses a token and returns a node.
|
30 |
*
|
31 |
* @return Twig_NodeInterface
|
32 |
*
|
33 |
-
* @throws
|
34 |
*/
|
35 |
-
public function parse(
|
36 |
|
37 |
/**
|
38 |
* Gets the tag name associated with this token parser.
|
@@ -41,7 +37,3 @@ interface Twig_TokenParserInterface
|
|
41 |
*/
|
42 |
public function getTag();
|
43 |
}
|
44 |
-
|
45 |
-
class_alias('Twig_TokenParserInterface', 'Twig\TokenParser\TokenParserInterface', false);
|
46 |
-
class_exists('Twig_Parser');
|
47 |
-
class_exists('Twig_Token');
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
|
|
|
|
12 |
/**
|
13 |
* Interface implemented by token parsers.
|
14 |
*
|
19 |
/**
|
20 |
* Sets the parser associated with this token parser.
|
21 |
*/
|
22 |
+
public function setParser(Twig_Parser $parser);
|
23 |
|
24 |
/**
|
25 |
* Parses a token and returns a node.
|
26 |
*
|
27 |
* @return Twig_NodeInterface
|
28 |
*
|
29 |
+
* @throws Twig_Error_Syntax
|
30 |
*/
|
31 |
+
public function parse(Twig_Token $token);
|
32 |
|
33 |
/**
|
34 |
* Gets the tag name associated with this token parser.
|
37 |
*/
|
38 |
public function getTag();
|
39 |
}
|
|
|
|
|
|
|
|
vendor/twig/twig/lib/Twig/TokenStream.php
CHANGED
@@ -10,10 +10,6 @@
|
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
|
13 |
-
use Twig\Error\SyntaxError;
|
14 |
-
use Twig\Source;
|
15 |
-
use Twig\Token;
|
16 |
-
|
17 |
/**
|
18 |
* Represents a token stream.
|
19 |
*
|
@@ -36,11 +32,11 @@ class Twig_TokenStream
|
|
36 |
*/
|
37 |
public function __construct(array $tokens, $name = null, $source = null)
|
38 |
{
|
39 |
-
if (!$name instanceof
|
40 |
if (null !== $name || null !== $source) {
|
41 |
@trigger_error(sprintf('Passing a string as the $name argument of %s() is deprecated since version 1.27. Pass a Twig_Source instance instead.', __METHOD__), E_USER_DEPRECATED);
|
42 |
}
|
43 |
-
$this->source = new
|
44 |
} else {
|
45 |
$this->source = $name;
|
46 |
}
|
@@ -58,18 +54,18 @@ class Twig_TokenStream
|
|
58 |
|
59 |
public function injectTokens(array $tokens)
|
60 |
{
|
61 |
-
$this->tokens = array_merge(
|
62 |
}
|
63 |
|
64 |
/**
|
65 |
* Sets the pointer to the next token and returns the old one.
|
66 |
*
|
67 |
-
* @return
|
68 |
*/
|
69 |
public function next()
|
70 |
{
|
71 |
if (!isset($this->tokens[++$this->current])) {
|
72 |
-
throw new
|
73 |
}
|
74 |
|
75 |
return $this->tokens[$this->current - 1];
|
@@ -78,7 +74,7 @@ class Twig_TokenStream
|
|
78 |
/**
|
79 |
* Tests a token, sets the pointer to the next one and returns it or throws a syntax error.
|
80 |
*
|
81 |
-
* @return
|
82 |
*/
|
83 |
public function nextIf($primary, $secondary = null)
|
84 |
{
|
@@ -90,17 +86,17 @@ class Twig_TokenStream
|
|
90 |
/**
|
91 |
* Tests a token and returns it or throws a syntax error.
|
92 |
*
|
93 |
-
* @return
|
94 |
*/
|
95 |
public function expect($type, $value = null, $message = null)
|
96 |
{
|
97 |
$token = $this->tokens[$this->current];
|
98 |
if (!$token->test($type, $value)) {
|
99 |
$line = $token->getLine();
|
100 |
-
throw new
|
101 |
$message ? $message.'. ' : '',
|
102 |
-
|
103 |
-
|
104 |
$line,
|
105 |
$this->source
|
106 |
);
|
@@ -115,12 +111,12 @@ class Twig_TokenStream
|
|
115 |
*
|
116 |
* @param int $number
|
117 |
*
|
118 |
-
* @return
|
119 |
*/
|
120 |
public function look($number = 1)
|
121 |
{
|
122 |
if (!isset($this->tokens[$this->current + $number])) {
|
123 |
-
throw new
|
124 |
}
|
125 |
|
126 |
return $this->tokens[$this->current + $number];
|
@@ -143,11 +139,11 @@ class Twig_TokenStream
|
|
143 |
*/
|
144 |
public function isEOF()
|
145 |
{
|
146 |
-
return
|
147 |
}
|
148 |
|
149 |
/**
|
150 |
-
* @return
|
151 |
*/
|
152 |
public function getCurrent()
|
153 |
{
|
@@ -187,7 +183,7 @@ class Twig_TokenStream
|
|
187 |
/**
|
188 |
* Gets the source associated with this stream.
|
189 |
*
|
190 |
-
* @return
|
191 |
*
|
192 |
* @internal
|
193 |
*/
|
@@ -196,5 +192,3 @@ class Twig_TokenStream
|
|
196 |
return $this->source;
|
197 |
}
|
198 |
}
|
199 |
-
|
200 |
-
class_alias('Twig_TokenStream', 'Twig\TokenStream', false);
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
|
|
|
|
|
|
|
|
|
13 |
/**
|
14 |
* Represents a token stream.
|
15 |
*
|
32 |
*/
|
33 |
public function __construct(array $tokens, $name = null, $source = null)
|
34 |
{
|
35 |
+
if (!$name instanceof Twig_Source) {
|
36 |
if (null !== $name || null !== $source) {
|
37 |
@trigger_error(sprintf('Passing a string as the $name argument of %s() is deprecated since version 1.27. Pass a Twig_Source instance instead.', __METHOD__), E_USER_DEPRECATED);
|
38 |
}
|
39 |
+
$this->source = new Twig_Source($source, $name);
|
40 |
} else {
|
41 |
$this->source = $name;
|
42 |
}
|
54 |
|
55 |
public function injectTokens(array $tokens)
|
56 |
{
|
57 |
+
$this->tokens = array_merge(array_slice($this->tokens, 0, $this->current), $tokens, array_slice($this->tokens, $this->current));
|
58 |
}
|
59 |
|
60 |
/**
|
61 |
* Sets the pointer to the next token and returns the old one.
|
62 |
*
|
63 |
+
* @return Twig_Token
|
64 |
*/
|
65 |
public function next()
|
66 |
{
|
67 |
if (!isset($this->tokens[++$this->current])) {
|
68 |
+
throw new Twig_Error_Syntax('Unexpected end of template.', $this->tokens[$this->current - 1]->getLine(), $this->source);
|
69 |
}
|
70 |
|
71 |
return $this->tokens[$this->current - 1];
|
74 |
/**
|
75 |
* Tests a token, sets the pointer to the next one and returns it or throws a syntax error.
|
76 |
*
|
77 |
+
* @return Twig_Token|null The next token if the condition is true, null otherwise
|
78 |
*/
|
79 |
public function nextIf($primary, $secondary = null)
|
80 |
{
|
86 |
/**
|
87 |
* Tests a token and returns it or throws a syntax error.
|
88 |
*
|
89 |
+
* @return Twig_Token
|
90 |
*/
|
91 |
public function expect($type, $value = null, $message = null)
|
92 |
{
|
93 |
$token = $this->tokens[$this->current];
|
94 |
if (!$token->test($type, $value)) {
|
95 |
$line = $token->getLine();
|
96 |
+
throw new Twig_Error_Syntax(sprintf('%sUnexpected token "%s" of value "%s" ("%s" expected%s).',
|
97 |
$message ? $message.'. ' : '',
|
98 |
+
Twig_Token::typeToEnglish($token->getType()), $token->getValue(),
|
99 |
+
Twig_Token::typeToEnglish($type), $value ? sprintf(' with value "%s"', $value) : ''),
|
100 |
$line,
|
101 |
$this->source
|
102 |
);
|
111 |
*
|
112 |
* @param int $number
|
113 |
*
|
114 |
+
* @return Twig_Token
|
115 |
*/
|
116 |
public function look($number = 1)
|
117 |
{
|
118 |
if (!isset($this->tokens[$this->current + $number])) {
|
119 |
+
throw new Twig_Error_Syntax('Unexpected end of template.', $this->tokens[$this->current + $number - 1]->getLine(), $this->source);
|
120 |
}
|
121 |
|
122 |
return $this->tokens[$this->current + $number];
|
139 |
*/
|
140 |
public function isEOF()
|
141 |
{
|
142 |
+
return $this->tokens[$this->current]->getType() === Twig_Token::EOF_TYPE;
|
143 |
}
|
144 |
|
145 |
/**
|
146 |
+
* @return Twig_Token
|
147 |
*/
|
148 |
public function getCurrent()
|
149 |
{
|
183 |
/**
|
184 |
* Gets the source associated with this stream.
|
185 |
*
|
186 |
+
* @return Twig_Source
|
187 |
*
|
188 |
* @internal
|
189 |
*/
|
192 |
return $this->source;
|
193 |
}
|
194 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Util/DeprecationCollector.php
CHANGED
@@ -9,11 +9,6 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
use Twig\Environment;
|
13 |
-
use Twig\Error\SyntaxError;
|
14 |
-
use Twig\Source;
|
15 |
-
use Twig\Util\TemplateDirIterator;
|
16 |
-
|
17 |
/**
|
18 |
* @author Fabien Potencier <fabien@symfony.com>
|
19 |
*
|
@@ -24,7 +19,7 @@ class Twig_Util_DeprecationCollector
|
|
24 |
private $twig;
|
25 |
private $deprecations;
|
26 |
|
27 |
-
public function __construct(
|
28 |
{
|
29 |
$this->twig = $twig;
|
30 |
}
|
@@ -39,32 +34,32 @@ class Twig_Util_DeprecationCollector
|
|
39 |
*/
|
40 |
public function collectDir($dir, $ext = '.twig')
|
41 |
{
|
42 |
-
$iterator = new
|
43 |
-
new
|
44 |
-
new
|
45 |
), '{'.preg_quote($ext).'$}'
|
46 |
);
|
47 |
|
48 |
-
return $this->collect(new
|
49 |
}
|
50 |
|
51 |
/**
|
52 |
* Returns deprecations for passed templates.
|
53 |
*
|
54 |
-
* @param
|
55 |
*
|
56 |
* @return array An array of deprecations
|
57 |
*/
|
58 |
-
public function collect(
|
59 |
{
|
60 |
-
$this->deprecations =
|
61 |
|
62 |
-
set_error_handler(
|
63 |
|
64 |
foreach ($iterator as $name => $contents) {
|
65 |
try {
|
66 |
-
$this->twig->parse($this->twig->tokenize(new
|
67 |
-
} catch (
|
68 |
// ignore templates containing syntax errors
|
69 |
}
|
70 |
}
|
@@ -72,7 +67,7 @@ class Twig_Util_DeprecationCollector
|
|
72 |
restore_error_handler();
|
73 |
|
74 |
$deprecations = $this->deprecations;
|
75 |
-
$this->deprecations =
|
76 |
|
77 |
return $deprecations;
|
78 |
}
|
@@ -87,5 +82,3 @@ class Twig_Util_DeprecationCollector
|
|
87 |
}
|
88 |
}
|
89 |
}
|
90 |
-
|
91 |
-
class_alias('Twig_Util_DeprecationCollector', 'Twig\Util\DeprecationCollector', false);
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
|
|
|
|
|
|
12 |
/**
|
13 |
* @author Fabien Potencier <fabien@symfony.com>
|
14 |
*
|
19 |
private $twig;
|
20 |
private $deprecations;
|
21 |
|
22 |
+
public function __construct(Twig_Environment $twig)
|
23 |
{
|
24 |
$this->twig = $twig;
|
25 |
}
|
34 |
*/
|
35 |
public function collectDir($dir, $ext = '.twig')
|
36 |
{
|
37 |
+
$iterator = new RegexIterator(
|
38 |
+
new RecursiveIteratorIterator(
|
39 |
+
new RecursiveDirectoryIterator($dir), RecursiveIteratorIterator::LEAVES_ONLY
|
40 |
), '{'.preg_quote($ext).'$}'
|
41 |
);
|
42 |
|
43 |
+
return $this->collect(new Twig_Util_TemplateDirIterator($iterator));
|
44 |
}
|
45 |
|
46 |
/**
|
47 |
* Returns deprecations for passed templates.
|
48 |
*
|
49 |
+
* @param Traversable $iterator An iterator of templates (where keys are template names and values the contents of the template)
|
50 |
*
|
51 |
* @return array An array of deprecations
|
52 |
*/
|
53 |
+
public function collect(Traversable $iterator)
|
54 |
{
|
55 |
+
$this->deprecations = array();
|
56 |
|
57 |
+
set_error_handler(array($this, 'errorHandler'));
|
58 |
|
59 |
foreach ($iterator as $name => $contents) {
|
60 |
try {
|
61 |
+
$this->twig->parse($this->twig->tokenize(new Twig_Source($contents, $name)));
|
62 |
+
} catch (Twig_Error_Syntax $e) {
|
63 |
// ignore templates containing syntax errors
|
64 |
}
|
65 |
}
|
67 |
restore_error_handler();
|
68 |
|
69 |
$deprecations = $this->deprecations;
|
70 |
+
$this->deprecations = array();
|
71 |
|
72 |
return $deprecations;
|
73 |
}
|
82 |
}
|
83 |
}
|
84 |
}
|
|
|
|
vendor/twig/twig/lib/Twig/Util/TemplateDirIterator.php
CHANGED
@@ -24,5 +24,3 @@ class Twig_Util_TemplateDirIterator extends IteratorIterator
|
|
24 |
return (string) parent::key();
|
25 |
}
|
26 |
}
|
27 |
-
|
28 |
-
class_alias('Twig_Util_TemplateDirIterator', 'Twig\Util\TemplateDirIterator', false);
|
24 |
return (string) parent::key();
|
25 |
}
|
26 |
}
|
|
|
|
vendor/twig/twig/phpunit.xml.dist
CHANGED
@@ -9,7 +9,7 @@
|
|
9 |
processIsolation="false"
|
10 |
stopOnFailure="false"
|
11 |
syntaxCheck="false"
|
12 |
-
bootstrap="
|
13 |
>
|
14 |
<testsuites>
|
15 |
<testsuite name="Twig Test Suite">
|
9 |
processIsolation="false"
|
10 |
stopOnFailure="false"
|
11 |
syntaxCheck="false"
|
12 |
+
bootstrap="test/bootstrap.php"
|
13 |
>
|
14 |
<testsuites>
|
15 |
<testsuite name="Twig Test Suite">
|
vendor/twig/twig/src/Cache/CacheInterface.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Cache;
|
4 |
-
|
5 |
-
class_exists('Twig_CacheInterface');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
interface CacheInterface extends \Twig_CacheInterface
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Cache/FilesystemCache.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Cache;
|
4 |
-
|
5 |
-
class_exists('Twig_Cache_Filesystem');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class FilesystemCache extends \Twig_Cache_Filesystem
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Cache/NullCache.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Cache;
|
4 |
-
|
5 |
-
class_exists('Twig_Cache_Null');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class NullCache extends \Twig_Cache_Null
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Compiler.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig;
|
4 |
-
|
5 |
-
class_exists('Twig_Compiler');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class Compiler extends \Twig_Compiler
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Environment.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig;
|
4 |
-
|
5 |
-
class_exists('Twig_Environment');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class Environment extends \Twig_Environment
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Error/Error.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Error;
|
4 |
-
|
5 |
-
class_exists('Twig_Error');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class Error extends \Twig_Error
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Error/LoaderError.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Error;
|
4 |
-
|
5 |
-
class_exists('Twig_Error_Loader');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class LoaderError extends \Twig_Error_Loader
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Error/RuntimeError.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Error;
|
4 |
-
|
5 |
-
class_exists('Twig_Error_Runtime');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class RuntimeError extends \Twig_Error_Runtime
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Error/SyntaxError.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Error;
|
4 |
-
|
5 |
-
class_exists('Twig_Error_Syntax');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class SyntaxError extends \Twig_Error_Syntax
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/ExpressionParser.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig;
|
4 |
-
|
5 |
-
class_exists('Twig_ExpressionParser');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class ExpressionParser extends \Twig_ExpressionParser
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Extension/AbstractExtension.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Extension;
|
4 |
-
|
5 |
-
class_exists('Twig_Extension');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class AbstractExtension extends \Twig_Extension
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Extension/CoreExtension.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Extension;
|
4 |
-
|
5 |
-
class_exists('Twig_Extension_Core');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class CoreExtension extends \Twig_Extension_Core
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Extension/DebugExtension.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Extension;
|
4 |
-
|
5 |
-
class_exists('Twig_Extension_Debug');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class DebugExtension extends \Twig_Extension_Debug
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Extension/EscaperExtension.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Extension;
|
4 |
-
|
5 |
-
class_exists('Twig_Extension_Escaper');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class EscaperExtension extends \Twig_Extension_Escaper
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Extension/ExtensionInterface.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Extension;
|
4 |
-
|
5 |
-
class_exists('Twig_ExtensionInterface');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
interface ExtensionInterface extends \Twig_ExtensionInterface
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Extension/GlobalsInterface.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Extension;
|
4 |
-
|
5 |
-
class_exists('Twig_Extension_GlobalsInterface');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
interface GlobalsInterface extends \Twig_Extension_GlobalsInterface
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Extension/InitRuntimeInterface.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Extension;
|
4 |
-
|
5 |
-
class_exists('Twig_Extension_InitRuntimeInterface');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
interface InitRuntimeInterface extends \Twig_Extension_InitRuntimeInterface
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Extension/OptimizerExtension.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Extension;
|
4 |
-
|
5 |
-
class_exists('Twig_Extension_Optimizer');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class OptimizerExtension extends \Twig_Extension_Optimizer
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Extension/ProfilerExtension.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Extension;
|
4 |
-
|
5 |
-
class_exists('Twig_Extension_Profiler');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class ProfilerExtension extends \Twig_Extension_Profiler
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Extension/RuntimeExtensionInterface.php
DELETED
@@ -1,19 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* This file is part of Twig.
|
5 |
-
*
|
6 |
-
* (c) Fabien Potencier
|
7 |
-
*
|
8 |
-
* For the full copyright and license information, please view the LICENSE
|
9 |
-
* file that was distributed with this source code.
|
10 |
-
*/
|
11 |
-
|
12 |
-
namespace Twig\Extension;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* @author Grégoire Pineau <lyrixx@lyrixx.info>
|
16 |
-
*/
|
17 |
-
interface RuntimeExtensionInterface
|
18 |
-
{
|
19 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Extension/SandboxExtension.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Extension;
|
4 |
-
|
5 |
-
class_exists('Twig_Extension_Sandbox');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class SandboxExtension extends \Twig_Extension_Sandbox
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Extension/StagingExtension.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Extension;
|
4 |
-
|
5 |
-
class_exists('Twig_Extension_Staging');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class StagingExtension extends \Twig_Extension_Staging
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Extension/StringLoaderExtension.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Extension;
|
4 |
-
|
5 |
-
class_exists('Twig_Extension_StringLoader');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class StringLoaderExtension extends \Twig_Extension_StringLoader
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/FileExtensionEscapingStrategy.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig;
|
4 |
-
|
5 |
-
class_exists('Twig_FileExtensionEscapingStrategy');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class FileExtensionEscapingStrategy extends \Twig_FileExtensionEscapingStrategy
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Lexer.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig;
|
4 |
-
|
5 |
-
class_exists('Twig_Lexer');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class Lexer extends \Twig_Lexer
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Loader/ArrayLoader.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Loader;
|
4 |
-
|
5 |
-
class_exists('Twig_Loader_Array');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class ArrayLoader extends \Twig_Loader_Array
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Loader/ChainLoader.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Loader;
|
4 |
-
|
5 |
-
class_exists('Twig_Loader_Chain');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class ChainLoader extends \Twig_Loader_Chain
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Loader/ExistsLoaderInterface.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Loader;
|
4 |
-
|
5 |
-
class_exists('Twig_ExistsLoaderInterface');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
interface ExistsLoaderInterface extends \Twig_ExistsLoaderInterface
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Loader/FilesystemLoader.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Loader;
|
4 |
-
|
5 |
-
class_exists('Twig_Loader_Filesystem');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class FilesystemLoader extends \Twig_Loader_Filesystem
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Loader/LoaderInterface.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Loader;
|
4 |
-
|
5 |
-
class_exists('Twig_LoaderInterface');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
interface LoaderInterface extends \Twig_LoaderInterface
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Loader/SourceContextLoaderInterface.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Loader;
|
4 |
-
|
5 |
-
class_exists('Twig_SourceContextLoaderInterface');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
interface SourceContextLoaderInterface extends \Twig_SourceContextLoaderInterface
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Markup.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig;
|
4 |
-
|
5 |
-
class_exists('Twig_Markup');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class Markup extends \Twig_Markup
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Node/AutoEscapeNode.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Node;
|
4 |
-
|
5 |
-
class_exists('Twig_Node_AutoEscape');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class AutoEscapeNode extends \Twig_Node_AutoEscape
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Node/BlockNode.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Node;
|
4 |
-
|
5 |
-
class_exists('Twig_Node_Block');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class BlockNode extends \Twig_Node_Block
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Node/BlockReferenceNode.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Node;
|
4 |
-
|
5 |
-
class_exists('Twig_Node_BlockReference');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class BlockReferenceNode extends \Twig_Node_BlockReference
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Node/BodyNode.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Node;
|
4 |
-
|
5 |
-
class_exists('Twig_Node_Body');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class BodyNode extends \Twig_Node_Body
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Node/CheckSecurityNode.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Node;
|
4 |
-
|
5 |
-
class_exists('Twig_Node_CheckSecurity');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class CheckSecurityNode extends \Twig_Node_CheckSecurity
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Node/DeprecatedNode.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Node;
|
4 |
-
|
5 |
-
class_exists('Twig_Node_Deprecated');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class DeprecatedNode extends \Twig_Node_Deprecated
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Node/DoNode.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Node;
|
4 |
-
|
5 |
-
class_exists('Twig_Node_Do');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class DoNode extends \Twig_Node_Do
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Node/EmbedNode.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Node;
|
4 |
-
|
5 |
-
class_exists('Twig_Node_Embed');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class EmbedNode extends \Twig_Node_Embed
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Node/Expression/AbstractExpression.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Node\Expression;
|
4 |
-
|
5 |
-
class_exists('Twig_Node_Expression');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class AbstractExpression extends \Twig_Node_Expression
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Node/Expression/ArrayExpression.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Node\Expression;
|
4 |
-
|
5 |
-
class_exists('Twig_Node_Expression_Array');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class ArrayExpression extends \Twig_Node_Expression_Array
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Node/Expression/AssignNameExpression.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Node\Expression;
|
4 |
-
|
5 |
-
class_exists('Twig_Node_Expression_AssignName');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class AssignNameExpression extends \Twig_Node_Expression_AssignName
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Node/Expression/Binary/AbstractBinary.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Node\Expression\Binary;
|
4 |
-
|
5 |
-
class_exists('Twig_Node_Expression_Binary');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class AbstractBinary extends \Twig_Node_Expression_Binary
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Node/Expression/Binary/AddBinary.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Node\Expression\Binary;
|
4 |
-
|
5 |
-
class_exists('Twig_Node_Expression_Binary_Add');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class AddBinary extends \Twig_Node_Expression_Binary_Add
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Node/Expression/Binary/AndBinary.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Node\Expression\Binary;
|
4 |
-
|
5 |
-
class_exists('Twig_Node_Expression_Binary_And');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class AndBinary extends \Twig_Node_Expression_Binary_And
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Node/Expression/Binary/BitwiseAndBinary.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Node\Expression\Binary;
|
4 |
-
|
5 |
-
class_exists('Twig_Node_Expression_Binary_BitwiseAnd');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class BitwiseAndBinary extends \Twig_Node_Expression_Binary_BitwiseAnd
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Node/Expression/Binary/BitwiseOrBinary.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Node\Expression\Binary;
|
4 |
-
|
5 |
-
class_exists('Twig_Node_Expression_Binary_BitwiseOr');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class BitwiseOrBinary extends \Twig_Node_Expression_Binary_BitwiseOr
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Node/Expression/Binary/BitwiseXorBinary.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Node\Expression\Binary;
|
4 |
-
|
5 |
-
class_exists('Twig_Node_Expression_Binary_BitwiseXor');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class BitwiseXorBinary extends \Twig_Node_Expression_Binary_BitwiseXor
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Node/Expression/Binary/ConcatBinary.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Node\Expression\Binary;
|
4 |
-
|
5 |
-
class_exists('Twig_Node_Expression_Binary_Concat');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class ConcatBinary extends \Twig_Node_Expression_Binary_Concat
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Node/Expression/Binary/DivBinary.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Node\Expression\Binary;
|
4 |
-
|
5 |
-
class_exists('Twig_Node_Expression_Binary_Div');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class DivBinary extends \Twig_Node_Expression_Binary_Div
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Node/Expression/Binary/EndsWithBinary.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Node\Expression\Binary;
|
4 |
-
|
5 |
-
class_exists('Twig_Node_Expression_Binary_EndsWith');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class EndsWithBinary extends \Twig_Node_Expression_Binary_EndsWith
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Node/Expression/Binary/EqualBinary.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Node\Expression\Binary;
|
4 |
-
|
5 |
-
class_exists('Twig_Node_Expression_Binary_Equal');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class EqualBinary extends \Twig_Node_Expression_Binary_Equal
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Node/Expression/Binary/FloorDivBinary.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Node\Expression\Binary;
|
4 |
-
|
5 |
-
class_exists('Twig_Node_Expression_Binary_FloorDiv');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class FloorDivBinary extends \Twig_Node_Expression_Binary_FloorDiv
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Node/Expression/Binary/GreaterBinary.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Node\Expression\Binary;
|
4 |
-
|
5 |
-
class_exists('Twig_Node_Expression_Binary_Greater');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class GreaterBinary extends \Twig_Node_Expression_Binary_Greater
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Node/Expression/Binary/GreaterEqualBinary.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Node\Expression\Binary;
|
4 |
-
|
5 |
-
class_exists('Twig_Node_Expression_Binary_GreaterEqual');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class GreaterEqualBinary extends \Twig_Node_Expression_Binary_GreaterEqual
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Node/Expression/Binary/InBinary.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Node\Expression\Binary;
|
4 |
-
|
5 |
-
class_exists('Twig_Node_Expression_Binary_In');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class InBinary extends \Twig_Node_Expression_Binary_In
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Node/Expression/Binary/LessBinary.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Node\Expression\Binary;
|
4 |
-
|
5 |
-
class_exists('Twig_Node_Expression_Binary_Less');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class LessBinary extends \Twig_Node_Expression_Binary_Less
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Node/Expression/Binary/LessEqualBinary.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Node\Expression\Binary;
|
4 |
-
|
5 |
-
class_exists('Twig_Node_Expression_Binary_LessEqual');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class LessEqualBinary extends \Twig_Node_Expression_Binary_LessEqual
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Node/Expression/Binary/MatchesBinary.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Node\Expression\Binary;
|
4 |
-
|
5 |
-
class_exists('Twig_Node_Expression_Binary_Matches');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class MatchesBinary extends \Twig_Node_Expression_Binary_Matches
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Node/Expression/Binary/ModBinary.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Node\Expression\Binary;
|
4 |
-
|
5 |
-
class_exists('Twig_Node_Expression_Binary_Mod');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class ModBinary extends \Twig_Node_Expression_Binary_Mod
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Node/Expression/Binary/MulBinary.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Node\Expression\Binary;
|
4 |
-
|
5 |
-
class_exists('Twig_Node_Expression_Binary_Mul');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class MulBinary extends \Twig_Node_Expression_Binary_Mul
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Node/Expression/Binary/NotEqualBinary.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Node\Expression\Binary;
|
4 |
-
|
5 |
-
class_exists('Twig_Node_Expression_Binary_NotEqual');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class NotEqualBinary extends \Twig_Node_Expression_Binary_NotEqual
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Node/Expression/Binary/NotInBinary.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Node\Expression\Binary;
|
4 |
-
|
5 |
-
class_exists('Twig_Node_Expression_Binary_NotIn');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class NotInBinary extends \Twig_Node_Expression_Binary_NotIn
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Node/Expression/Binary/OrBinary.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Node\Expression\Binary;
|
4 |
-
|
5 |
-
class_exists('Twig_Node_Expression_Binary_Or');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class OrBinary extends \Twig_Node_Expression_Binary_Or
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Node/Expression/Binary/PowerBinary.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Node\Expression\Binary;
|
4 |
-
|
5 |
-
class_exists('Twig_Node_Expression_Binary_Power');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class PowerBinary extends \Twig_Node_Expression_Binary_Power
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Node/Expression/Binary/RangeBinary.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Node\Expression\Binary;
|
4 |
-
|
5 |
-
class_exists('Twig_Node_Expression_Binary_Range');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class RangeBinary extends \Twig_Node_Expression_Binary_Range
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Node/Expression/Binary/StartsWithBinary.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Node\Expression\Binary;
|
4 |
-
|
5 |
-
class_exists('Twig_Node_Expression_Binary_StartsWith');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class StartsWithBinary extends \Twig_Node_Expression_Binary_StartsWith
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Node/Expression/Binary/SubBinary.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Node\Expression\Binary;
|
4 |
-
|
5 |
-
class_exists('Twig_Node_Expression_Binary_Sub');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class SubBinary extends \Twig_Node_Expression_Binary_Sub
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Node/Expression/BlockReferenceExpression.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Node\Expression;
|
4 |
-
|
5 |
-
class_exists('Twig_Node_Expression_BlockReference');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class BlockReferenceExpression extends \Twig_Node_Expression_BlockReference
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Node/Expression/CallExpression.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Node\Expression;
|
4 |
-
|
5 |
-
class_exists('Twig_Node_Expression_Call');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class CallExpression extends \Twig_Node_Expression_Call
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Node/Expression/ConditionalExpression.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Node\Expression;
|
4 |
-
|
5 |
-
class_exists('Twig_Node_Expression_Conditional');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class ConditionalExpression extends \Twig_Node_Expression_Conditional
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Node/Expression/ConstantExpression.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Node\Expression;
|
4 |
-
|
5 |
-
class_exists('Twig_Node_Expression_Constant');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class ConstantExpression extends \Twig_Node_Expression_Constant
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Node/Expression/Filter/DefaultFilter.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Node\Expression\Filter;
|
4 |
-
|
5 |
-
class_exists('Twig_Node_Expression_Filter_Default');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class DefaultFilter extends \Twig_Node_Expression_Filter_Default
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Node/Expression/FilterExpression.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Node\Expression;
|
4 |
-
|
5 |
-
class_exists('Twig_Node_Expression_Filter');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class FilterExpression extends \Twig_Node_Expression_Filter
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Node/Expression/FunctionExpression.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Node\Expression;
|
4 |
-
|
5 |
-
class_exists('Twig_Node_Expression_Function');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class FunctionExpression extends \Twig_Node_Expression_Function
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Node/Expression/GetAttrExpression.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Node\Expression;
|
4 |
-
|
5 |
-
class_exists('Twig_Node_Expression_GetAttr');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class GetAttrExpression extends \Twig_Node_Expression_GetAttr
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Node/Expression/MethodCallExpression.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Node\Expression;
|
4 |
-
|
5 |
-
class_exists('Twig_Node_Expression_MethodCall');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class MethodCallExpression extends \Twig_Node_Expression_MethodCall
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Node/Expression/NameExpression.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Node\Expression;
|
4 |
-
|
5 |
-
class_exists('Twig_Node_Expression_Name');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class NameExpression extends \Twig_Node_Expression_Name
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Node/Expression/NullCoalesceExpression.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Node\Expression;
|
4 |
-
|
5 |
-
class_exists('Twig_Node_Expression_NullCoalesce');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class NullCoalesceExpression extends \Twig_Node_Expression_NullCoalesce
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Node/Expression/ParentExpression.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Node\Expression;
|
4 |
-
|
5 |
-
class_exists('Twig_Node_Expression_Parent');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class ParentExpression extends \Twig_Node_Expression_Parent
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Node/Expression/TempNameExpression.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Node\Expression;
|
4 |
-
|
5 |
-
class_exists('Twig_Node_Expression_TempName');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class TempNameExpression extends \Twig_Node_Expression_TempName
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Node/Expression/Test/ConstantTest.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Node\Expression\Test;
|
4 |
-
|
5 |
-
class_exists('Twig_Node_Expression_Test_Constant');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class ConstantTest extends \Twig_Node_Expression_Test_Constant
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Node/Expression/Test/DefinedTest.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Node\Expression\Test;
|
4 |
-
|
5 |
-
class_exists('Twig_Node_Expression_Test_Defined');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class DefinedTest extends \Twig_Node_Expression_Test_Defined
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Node/Expression/Test/DivisiblebyTest.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Node\Expression\Test;
|
4 |
-
|
5 |
-
class_exists('Twig_Node_Expression_Test_Divisibleby');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class DivisiblebyTest extends \Twig_Node_Expression_Test_Divisibleby
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Node/Expression/Test/EvenTest.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Node\Expression\Test;
|
4 |
-
|
5 |
-
class_exists('Twig_Node_Expression_Test_Even');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class EvenTest extends \Twig_Node_Expression_Test_Even
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Node/Expression/Test/NullTest.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Node\Expression\Test;
|
4 |
-
|
5 |
-
class_exists('Twig_Node_Expression_Test_Null');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class NullTest extends \Twig_Node_Expression_Test_Null
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Node/Expression/Test/OddTest.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Node\Expression\Test;
|
4 |
-
|
5 |
-
class_exists('Twig_Node_Expression_Test_Odd');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class OddTest extends \Twig_Node_Expression_Test_Odd
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Node/Expression/Test/SameasTest.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Node\Expression\Test;
|
4 |
-
|
5 |
-
class_exists('Twig_Node_Expression_Test_Sameas');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class SameasTest extends \Twig_Node_Expression_Test_Sameas
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Node/Expression/TestExpression.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Node\Expression;
|
4 |
-
|
5 |
-
class_exists('Twig_Node_Expression_Test');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class TestExpression extends \Twig_Node_Expression_Test
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Node/Expression/Unary/AbstractUnary.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Node\Expression\Unary;
|
4 |
-
|
5 |
-
class_exists('Twig_Node_Expression_Unary');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class AbstractUnary extends \Twig_Node_Expression_Unary
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Node/Expression/Unary/NegUnary.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Node\Expression\Unary;
|
4 |
-
|
5 |
-
class_exists('Twig_Node_Expression_Unary_Neg');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class NegUnary extends \Twig_Node_Expression_Unary_Neg
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Node/Expression/Unary/NotUnary.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Node\Expression\Unary;
|
4 |
-
|
5 |
-
class_exists('Twig_Node_Expression_Unary_Not');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class NotUnary extends \Twig_Node_Expression_Unary_Not
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Node/Expression/Unary/PosUnary.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Node\Expression\Unary;
|
4 |
-
|
5 |
-
class_exists('Twig_Node_Expression_Unary_Pos');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class PosUnary extends \Twig_Node_Expression_Unary_Pos
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Node/FlushNode.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Node;
|
4 |
-
|
5 |
-
class_exists('Twig_Node_Flush');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class FlushNode extends \Twig_Node_Flush
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Node/ForLoopNode.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Node;
|
4 |
-
|
5 |
-
class_exists('Twig_Node_ForLoop');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class ForLoopNode extends \Twig_Node_ForLoop
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Node/ForNode.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Node;
|
4 |
-
|
5 |
-
class_exists('Twig_Node_For');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class ForNode extends \Twig_Node_For
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Node/IfNode.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Node;
|
4 |
-
|
5 |
-
class_exists('Twig_Node_If');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class IfNode extends \Twig_Node_If
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Node/ImportNode.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Node;
|
4 |
-
|
5 |
-
class_exists('Twig_Node_Import');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class ImportNode extends \Twig_Node_Import
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Node/IncludeNode.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Node;
|
4 |
-
|
5 |
-
class_exists('Twig_Node_Include');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class IncludeNode extends \Twig_Node_Include
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Node/MacroNode.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Node;
|
4 |
-
|
5 |
-
class_exists('Twig_Node_Macro');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class MacroNode extends \Twig_Node_Macro
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Node/ModuleNode.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Node;
|
4 |
-
|
5 |
-
class_exists('Twig_Node_Module');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class ModuleNode extends \Twig_Node_Module
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Node/Node.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Node;
|
4 |
-
|
5 |
-
class_exists('Twig_Node');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class Node extends \Twig_Node
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Node/NodeCaptureInterface.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Node;
|
4 |
-
|
5 |
-
class_exists('Twig_NodeCaptureInterface');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
interface NodeCaptureInterface extends \Twig_NodeCaptureInterface
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Node/NodeOutputInterface.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Node;
|
4 |
-
|
5 |
-
class_exists('Twig_NodeOutputInterface');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
interface NodeOutputInterface extends \Twig_NodeOutputInterface
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Node/PrintNode.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Node;
|
4 |
-
|
5 |
-
class_exists('Twig_Node_Print');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class PrintNode extends \Twig_Node_Print
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Node/SandboxNode.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Node;
|
4 |
-
|
5 |
-
class_exists('Twig_Node_Sandbox');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class SandboxNode extends \Twig_Node_Sandbox
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Node/SandboxedPrintNode.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Node;
|
4 |
-
|
5 |
-
class_exists('Twig_Node_SandboxedPrint');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class SandboxedPrintNode extends \Twig_Node_SandboxedPrint
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Node/SetNode.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Node;
|
4 |
-
|
5 |
-
class_exists('Twig_Node_Set');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class SetNode extends \Twig_Node_Set
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Node/SetTempNode.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Node;
|
4 |
-
|
5 |
-
class_exists('Twig_Node_SetTemp');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class SetTempNode extends \Twig_Node_SetTemp
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Node/SpacelessNode.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Node;
|
4 |
-
|
5 |
-
class_exists('Twig_Node_Spaceless');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class SpacelessNode extends \Twig_Node_Spaceless
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Node/TextNode.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Node;
|
4 |
-
|
5 |
-
class_exists('Twig_Node_Text');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class TextNode extends \Twig_Node_Text
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Node/WithNode.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Node;
|
4 |
-
|
5 |
-
class_exists('Twig_Node_With');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class WithNode extends \Twig_Node_With
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/NodeTraverser.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig;
|
4 |
-
|
5 |
-
class_exists('Twig_NodeTraverser');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class NodeTraverser extends \Twig_NodeTraverser
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/NodeVisitor/AbstractNodeVisitor.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\NodeVisitor;
|
4 |
-
|
5 |
-
class_exists('Twig_BaseNodeVisitor');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class AbstractNodeVisitor extends \Twig_BaseNodeVisitor
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/NodeVisitor/EscaperNodeVisitor.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\NodeVisitor;
|
4 |
-
|
5 |
-
class_exists('Twig_NodeVisitor_Escaper');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class EscaperNodeVisitor extends \Twig_NodeVisitor_Escaper
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/NodeVisitor/NodeVisitorInterface.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\NodeVisitor;
|
4 |
-
|
5 |
-
class_exists('Twig_NodeVisitorInterface');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
interface NodeVisitorInterface extends \Twig_NodeVisitorInterface
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/NodeVisitor/OptimizerNodeVisitor.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\NodeVisitor;
|
4 |
-
|
5 |
-
class_exists('Twig_NodeVisitor_Optimizer');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class OptimizerNodeVisitor extends \Twig_NodeVisitor_Optimizer
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/NodeVisitor/SafeAnalysisNodeVisitor.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\NodeVisitor;
|
4 |
-
|
5 |
-
class_exists('Twig_NodeVisitor_SafeAnalysis');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class SafeAnalysisNodeVisitor extends \Twig_NodeVisitor_SafeAnalysis
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/NodeVisitor/SandboxNodeVisitor.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\NodeVisitor;
|
4 |
-
|
5 |
-
class_exists('Twig_NodeVisitor_Sandbox');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class SandboxNodeVisitor extends \Twig_NodeVisitor_Sandbox
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Parser.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig;
|
4 |
-
|
5 |
-
class_exists('Twig_Parser');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class Parser extends \Twig_Parser
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Profiler/Dumper/BaseDumper.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Profiler\Dumper;
|
4 |
-
|
5 |
-
class_exists('Twig_Profiler_Dumper_Base');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class BaseDumper extends \Twig_Profiler_Dumper_Base
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Profiler/Dumper/BlackfireDumper.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Profiler\Dumper;
|
4 |
-
|
5 |
-
class_exists('Twig_Profiler_Dumper_Blackfire');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class BlackfireDumper extends \Twig_Profiler_Dumper_Blackfire
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Profiler/Dumper/HtmlDumper.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Profiler\Dumper;
|
4 |
-
|
5 |
-
class_exists('Twig_Profiler_Dumper_Html');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class HtmlDumper extends \Twig_Profiler_Dumper_Html
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Profiler/Dumper/TextDumper.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Profiler\Dumper;
|
4 |
-
|
5 |
-
class_exists('Twig_Profiler_Dumper_Text');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class TextDumper extends \Twig_Profiler_Dumper_Text
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Profiler/Node/EnterProfileNode.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Profiler\Node;
|
4 |
-
|
5 |
-
class_exists('Twig_Profiler_Node_EnterProfile');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class EnterProfileNode extends \Twig_Profiler_Node_EnterProfile
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Profiler/Node/LeaveProfileNode.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Profiler\Node;
|
4 |
-
|
5 |
-
class_exists('Twig_Profiler_Node_LeaveProfile');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class LeaveProfileNode extends \Twig_Profiler_Node_LeaveProfile
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Profiler/NodeVisitor/ProfilerNodeVisitor.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Profiler\NodeVisitor;
|
4 |
-
|
5 |
-
class_exists('Twig_Profiler_NodeVisitor_Profiler');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class ProfilerNodeVisitor extends \Twig_Profiler_NodeVisitor_Profiler
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Profiler/Profile.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Profiler;
|
4 |
-
|
5 |
-
class_exists('Twig_Profiler_Profile');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class Profile extends \Twig_Profiler_Profile
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/RuntimeLoader/ContainerRuntimeLoader.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\RuntimeLoader;
|
4 |
-
|
5 |
-
class_exists('Twig_ContainerRuntimeLoader');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class ContainerRuntimeLoader extends \Twig_ContainerRuntimeLoader
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/RuntimeLoader/FactoryRuntimeLoader.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\RuntimeLoader;
|
4 |
-
|
5 |
-
class_exists('Twig_FactoryRuntimeLoader');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class FactoryRuntimeLoader extends \Twig_FactoryRuntimeLoader
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/RuntimeLoader/RuntimeLoaderInterface.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\RuntimeLoader;
|
4 |
-
|
5 |
-
class_exists('Twig_RuntimeLoaderInterface');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
interface RuntimeLoaderInterface extends \Twig_RuntimeLoaderInterface
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Sandbox/SecurityError.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Sandbox;
|
4 |
-
|
5 |
-
class_exists('Twig_Sandbox_SecurityError');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class SecurityError extends \Twig_Sandbox_SecurityError
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Sandbox/SecurityNotAllowedFilterError.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Sandbox;
|
4 |
-
|
5 |
-
class_exists('Twig_Sandbox_SecurityNotAllowedFilterError');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class SecurityNotAllowedFilterError extends \Twig_Sandbox_SecurityNotAllowedFilterError
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Sandbox/SecurityNotAllowedFunctionError.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Sandbox;
|
4 |
-
|
5 |
-
class_exists('Twig_Sandbox_SecurityNotAllowedFunctionError');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class SecurityNotAllowedFunctionError extends \Twig_Sandbox_SecurityNotAllowedFunctionError
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Sandbox/SecurityNotAllowedMethodError.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Sandbox;
|
4 |
-
|
5 |
-
class_exists('Twig_Sandbox_SecurityNotAllowedMethodError');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class SecurityNotAllowedMethodError extends \Twig_Sandbox_SecurityNotAllowedMethodError
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Sandbox/SecurityNotAllowedPropertyError.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Sandbox;
|
4 |
-
|
5 |
-
class_exists('Twig_Sandbox_SecurityNotAllowedPropertyError');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class SecurityNotAllowedPropertyError extends \Twig_Sandbox_SecurityNotAllowedPropertyError
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Sandbox/SecurityNotAllowedTagError.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Sandbox;
|
4 |
-
|
5 |
-
class_exists('Twig_Sandbox_SecurityNotAllowedTagError');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class SecurityNotAllowedTagError extends \Twig_Sandbox_SecurityNotAllowedTagError
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Sandbox/SecurityPolicy.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Sandbox;
|
4 |
-
|
5 |
-
class_exists('Twig_Sandbox_SecurityPolicy');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class SecurityPolicy extends \Twig_Sandbox_SecurityPolicy
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Sandbox/SecurityPolicyInterface.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Sandbox;
|
4 |
-
|
5 |
-
class_exists('Twig_Sandbox_SecurityPolicyInterface');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
interface SecurityPolicyInterface extends \Twig_Sandbox_SecurityPolicyInterface
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Source.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig;
|
4 |
-
|
5 |
-
class_exists('Twig_Source');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class Source extends \Twig_Source
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Template.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig;
|
4 |
-
|
5 |
-
class_exists('Twig_Template');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class Template extends \Twig_Template
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/TemplateWrapper.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig;
|
4 |
-
|
5 |
-
class_exists('Twig_TemplateWrapper');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class TemplateWrapper extends \Twig_TemplateWrapper
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Test/IntegrationTestCase.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Test;
|
4 |
-
|
5 |
-
class_exists('Twig_Test_IntegrationTestCase');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class IntegrationTestCase extends \Twig_Test_IntegrationTestCase
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Test/NodeTestCase.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Test;
|
4 |
-
|
5 |
-
class_exists('Twig_Test_NodeTestCase');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class NodeTestCase extends \Twig_Test_NodeTestCase
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Token.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig;
|
4 |
-
|
5 |
-
class_exists('Twig_Token');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class Token extends \Twig_Token
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/TokenParser/AbstractTokenParser.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\TokenParser;
|
4 |
-
|
5 |
-
class_exists('Twig_TokenParser');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class AbstractTokenParser extends \Twig_TokenParser
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/TokenParser/AutoEscapeTokenParser.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\TokenParser;
|
4 |
-
|
5 |
-
class_exists('Twig_TokenParser_AutoEscape');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class AutoEscapeTokenParser extends \Twig_TokenParser_AutoEscape
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/TokenParser/BlockTokenParser.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\TokenParser;
|
4 |
-
|
5 |
-
class_exists('Twig_TokenParser_Block');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class BlockTokenParser extends \Twig_TokenParser_Block
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/TokenParser/DeprecatedTokenParser.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\TokenParser;
|
4 |
-
|
5 |
-
class_exists('Twig_TokenParser_Deprecated');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class DeprecatedTokenParser extends \Twig_TokenParser_Deprecated
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/TokenParser/DoTokenParser.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\TokenParser;
|
4 |
-
|
5 |
-
class_exists('Twig_TokenParser_Do');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class DoTokenParser extends \Twig_TokenParser_Do
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/TokenParser/EmbedTokenParser.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\TokenParser;
|
4 |
-
|
5 |
-
class_exists('Twig_TokenParser_Embed');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class EmbedTokenParser extends \Twig_TokenParser_Embed
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/TokenParser/ExtendsTokenParser.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\TokenParser;
|
4 |
-
|
5 |
-
class_exists('Twig_TokenParser_Extends');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class ExtendsTokenParser extends \Twig_TokenParser_Extends
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/TokenParser/FilterTokenParser.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\TokenParser;
|
4 |
-
|
5 |
-
class_exists('Twig_TokenParser_Filter');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class FilterTokenParser extends \Twig_TokenParser_Filter
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/TokenParser/FlushTokenParser.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\TokenParser;
|
4 |
-
|
5 |
-
class_exists('Twig_TokenParser_Flush');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class FlushTokenParser extends \Twig_TokenParser_Flush
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/TokenParser/ForTokenParser.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\TokenParser;
|
4 |
-
|
5 |
-
class_exists('Twig_TokenParser_For');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class ForTokenParser extends \Twig_TokenParser_For
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/TokenParser/FromTokenParser.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\TokenParser;
|
4 |
-
|
5 |
-
class_exists('Twig_TokenParser_From');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class FromTokenParser extends \Twig_TokenParser_From
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/TokenParser/IfTokenParser.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\TokenParser;
|
4 |
-
|
5 |
-
class_exists('Twig_TokenParser_If');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class IfTokenParser extends \Twig_TokenParser_If
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/TokenParser/ImportTokenParser.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\TokenParser;
|
4 |
-
|
5 |
-
class_exists('Twig_TokenParser_Import');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class ImportTokenParser extends \Twig_TokenParser_Import
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/TokenParser/IncludeTokenParser.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\TokenParser;
|
4 |
-
|
5 |
-
class_exists('Twig_TokenParser_Include');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class IncludeTokenParser extends \Twig_TokenParser_Include
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/TokenParser/MacroTokenParser.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\TokenParser;
|
4 |
-
|
5 |
-
class_exists('Twig_TokenParser_Macro');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class MacroTokenParser extends \Twig_TokenParser_Macro
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/TokenParser/SandboxTokenParser.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\TokenParser;
|
4 |
-
|
5 |
-
class_exists('Twig_TokenParser_Sandbox');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class SandboxTokenParser extends \Twig_TokenParser_Sandbox
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/TokenParser/SetTokenParser.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\TokenParser;
|
4 |
-
|
5 |
-
class_exists('Twig_TokenParser_Set');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class SetTokenParser extends \Twig_TokenParser_Set
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/TokenParser/SpacelessTokenParser.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\TokenParser;
|
4 |
-
|
5 |
-
class_exists('Twig_TokenParser_Spaceless');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class SpacelessTokenParser extends \Twig_TokenParser_Spaceless
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/TokenParser/TokenParserInterface.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\TokenParser;
|
4 |
-
|
5 |
-
class_exists('Twig_TokenParserInterface');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
interface TokenParserInterface extends \Twig_TokenParserInterface
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/TokenParser/UseTokenParser.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\TokenParser;
|
4 |
-
|
5 |
-
class_exists('Twig_TokenParser_Use');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class UseTokenParser extends \Twig_TokenParser_Use
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/TokenParser/WithTokenParser.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\TokenParser;
|
4 |
-
|
5 |
-
class_exists('Twig_TokenParser_With');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class WithTokenParser extends \Twig_TokenParser_With
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/TokenStream.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig;
|
4 |
-
|
5 |
-
class_exists('Twig_TokenStream');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class TokenStream extends \Twig_TokenStream
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/TwigFilter.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig;
|
4 |
-
|
5 |
-
class_exists('Twig_SimpleFilter');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class TwigFilter extends \Twig_SimpleFilter
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/TwigFunction.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig;
|
4 |
-
|
5 |
-
class_exists('Twig_SimpleFunction');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class TwigFunction extends \Twig_SimpleFunction
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/TwigTest.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig;
|
4 |
-
|
5 |
-
class_exists('Twig_SimpleTest');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class TwigTest extends \Twig_SimpleTest
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Util/DeprecationCollector.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Util;
|
4 |
-
|
5 |
-
class_exists('Twig_Util_DeprecationCollector');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class DeprecationCollector extends \Twig_Util_DeprecationCollector
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Util/TemplateDirIterator.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Util;
|
4 |
-
|
5 |
-
class_exists('Twig_Util_TemplateDirIterator');
|
6 |
-
|
7 |
-
if (\false) {
|
8 |
-
class TemplateDirIterator extends \Twig_Util_TemplateDirIterator
|
9 |
-
{
|
10 |
-
}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|