Version Description
- A bunch of fixes to how images in themes are handled #1317 #1293 (@jarednova)
- Fixed filter for avatar images in comments #1310 (@xavivars)
- Upgrades to PHPUnit and testing suite (@jarednova)
Download this release
Release Info
Developer | jarednova |
Plugin | Timber |
Version | 1.2.2 |
Comparing to | |
See all releases |
Code changes from version 1.2.1 to 1.2.2
- lib/Admin.php +1 -1
- lib/Comment.php +7 -1
- lib/ImageHelper.php +40 -15
- lib/Timber.php +2 -2
- lib/URLHelper.php +10 -0
- readme.txt +12 -1
- timber-starter-theme/templates/comment-form.twig +36 -0
- timber-starter-theme/templates/comment.twig +15 -0
- timber-starter-theme/templates/single.twig +21 -14
- timber.php +1 -1
- vendor/asm89/twig-cache-extension/.travis.yml +19 -1
- vendor/asm89/twig-cache-extension/README.md +1 -1
- vendor/asm89/twig-cache-extension/composer.json +2 -2
- vendor/asm89/twig-cache-extension/lib/Asm89/Twig/CacheExtension/Extension.php +3 -0
- vendor/asm89/twig-cache-extension/lib/Asm89/Twig/CacheExtension/Node/CacheNode.php +7 -1
- vendor/asm89/twig-cache-extension/test/Asm89/Twig/CacheExtension/Tests/FunctionalExtensionTest.php +1 -1
- vendor/autoload.php +1 -1
- vendor/composer/autoload_real.php +3 -3
- vendor/composer/installed.json +16 -16
- vendor/twig/twig/.php_cs.dist +15 -0
- vendor/twig/twig/CHANGELOG +23 -0
- vendor/twig/twig/LICENSE +1 -1
- vendor/twig/twig/composer.json +2 -2
- vendor/twig/twig/doc/advanced.rst +1 -1
- vendor/twig/twig/doc/advanced_legacy.rst +1 -1
- vendor/twig/twig/doc/deprecated.rst +12 -1
- vendor/twig/twig/doc/filters/replace.rst +1 -1
- vendor/twig/twig/doc/functions/range.rst +15 -2
- vendor/twig/twig/doc/tags/extends.rst +1 -1
- vendor/twig/twig/ext/twig/php_twig.h +1 -1
- vendor/twig/twig/ext/twig/twig.c +106 -18
- vendor/twig/twig/lib/Twig/Autoloader.php +3 -3
- vendor/twig/twig/lib/Twig/BaseNodeVisitor.php +0 -6
- vendor/twig/twig/lib/Twig/Cache/Filesystem.php +1 -13
- vendor/twig/twig/lib/Twig/Cache/Null.php +3 -13
- vendor/twig/twig/lib/Twig/CacheInterface.php +1 -1
- vendor/twig/twig/lib/Twig/Compiler.php +4 -2
- vendor/twig/twig/lib/Twig/CompilerInterface.php +1 -1
- vendor/twig/twig/lib/Twig/Environment.php +28 -15
- vendor/twig/twig/lib/Twig/Error.php +73 -11
- vendor/twig/twig/lib/Twig/Error/Loader.php +10 -3
- vendor/twig/twig/lib/Twig/Error/Runtime.php +2 -2
- vendor/twig/twig/lib/Twig/Error/Syntax.php +2 -2
- vendor/twig/twig/lib/Twig/ExistsLoaderInterface.php +1 -1
- vendor/twig/twig/lib/Twig/ExpressionParser.php +25 -22
- vendor/twig/twig/lib/Twig/Extension.php +1 -25
- vendor/twig/twig/lib/Twig/Extension/Core.php +63 -13
- vendor/twig/twig/lib/Twig/Extension/Debug.php +5 -1
- vendor/twig/twig/lib/Twig/Extension/Escaper.php +5 -1
- vendor/twig/twig/lib/Twig/Extension/Optimizer.php +5 -1
- vendor/twig/twig/lib/Twig/Extension/Profiler.php +1 -1
- vendor/twig/twig/lib/Twig/Extension/Sandbox.php +5 -1
- vendor/twig/twig/lib/Twig/Extension/Staging.php +18 -2
- vendor/twig/twig/lib/Twig/Extension/StringLoader.php +5 -1
- vendor/twig/twig/lib/Twig/ExtensionInterface.php +2 -2
- vendor/twig/twig/lib/Twig/FactoryRuntimeLoader.php +37 -0
- vendor/twig/twig/lib/Twig/FileExtensionEscapingStrategy.php +1 -1
- vendor/twig/twig/lib/Twig/Filter.php +1 -1
- vendor/twig/twig/lib/Twig/Filter/Function.php +1 -1
- vendor/twig/twig/lib/Twig/Filter/Method.php +1 -1
- vendor/twig/twig/lib/Twig/Filter/Node.php +1 -1
- vendor/twig/twig/lib/Twig/FilterCallableInterface.php +1 -1
- vendor/twig/twig/lib/Twig/FilterInterface.php +1 -1
- vendor/twig/twig/lib/Twig/Function.php +1 -1
- vendor/twig/twig/lib/Twig/Function/Function.php +2 -2
- vendor/twig/twig/lib/Twig/Function/Method.php +2 -2
- vendor/twig/twig/lib/Twig/Function/Node.php +1 -1
- vendor/twig/twig/lib/Twig/FunctionCallableInterface.php +1 -1
- vendor/twig/twig/lib/Twig/FunctionInterface.php +2 -2
- vendor/twig/twig/lib/Twig/Lexer.php +21 -18
- vendor/twig/twig/lib/Twig/LexerInterface.php +1 -1
- vendor/twig/twig/lib/Twig/Loader/Array.php +3 -16
- vendor/twig/twig/lib/Twig/Loader/Chain.php +3 -16
- vendor/twig/twig/lib/Twig/Loader/Filesystem.php +1 -16
- vendor/twig/twig/lib/Twig/Loader/String.php +1 -16
- vendor/twig/twig/lib/Twig/LoaderInterface.php +1 -1
- vendor/twig/twig/lib/Twig/Markup.php +1 -1
- vendor/twig/twig/lib/Twig/Node.php +2 -2
- vendor/twig/twig/lib/Twig/Node/AutoEscape.php +1 -1
- vendor/twig/twig/lib/Twig/Node/Block.php +2 -2
- vendor/twig/twig/lib/Twig/Node/BlockReference.php +2 -2
- vendor/twig/twig/lib/Twig/Node/Body.php +1 -1
- vendor/twig/twig/lib/Twig/Node/CheckSecurity.php +2 -2
- vendor/twig/twig/lib/Twig/Node/Do.php +1 -1
- vendor/twig/twig/lib/Twig/Node/Embed.php +1 -1
- vendor/twig/twig/lib/Twig/Node/Expression.php +2 -2
- vendor/twig/twig/lib/Twig/Node/Expression/Array.php +1 -1
- vendor/twig/twig/lib/Twig/Node/Expression/AssignName.php +2 -2
- vendor/twig/twig/lib/Twig/Node/Expression/Binary.php +2 -2
- vendor/twig/twig/lib/Twig/Node/Expression/Binary/Add.php +2 -2
- vendor/twig/twig/lib/Twig/Node/Expression/Binary/And.php +2 -2
- vendor/twig/twig/lib/Twig/Node/Expression/Binary/BitwiseAnd.php +2 -2
- vendor/twig/twig/lib/Twig/Node/Expression/Binary/BitwiseOr.php +2 -2
- vendor/twig/twig/lib/Twig/Node/Expression/Binary/BitwiseXor.php +2 -2
- vendor/twig/twig/lib/Twig/Node/Expression/Binary/Concat.php +2 -2
- vendor/twig/twig/lib/Twig/Node/Expression/Binary/Div.php +2 -2
- vendor/twig/twig/lib/Twig/Node/Expression/Binary/EndsWith.php +1 -1
- vendor/twig/twig/lib/Twig/Node/Expression/Binary/Equal.php +1 -1
- vendor/twig/twig/lib/Twig/Node/Expression/Binary/FloorDiv.php +1 -1
- vendor/twig/twig/lib/Twig/Node/Expression/Binary/Greater.php +1 -1
- vendor/twig/twig/lib/Twig/Node/Expression/Binary/GreaterEqual.php +1 -1
- vendor/twig/twig/lib/Twig/Node/Expression/Binary/In.php +1 -1
- vendor/twig/twig/lib/Twig/Node/Expression/Binary/Less.php +1 -1
- vendor/twig/twig/lib/Twig/Node/Expression/Binary/LessEqual.php +1 -1
- vendor/twig/twig/lib/Twig/Node/Expression/Binary/Matches.php +1 -1
- vendor/twig/twig/lib/Twig/Node/Expression/Binary/Mod.php +2 -2
- vendor/twig/twig/lib/Twig/Node/Expression/Binary/Mul.php +2 -2
- vendor/twig/twig/lib/Twig/Node/Expression/Binary/NotEqual.php +1 -1
- vendor/twig/twig/lib/Twig/Node/Expression/Binary/NotIn.php +1 -1
- vendor/twig/twig/lib/Twig/Node/Expression/Binary/Or.php +2 -2
- vendor/twig/twig/lib/Twig/Node/Expression/Binary/Power.php +1 -1
- vendor/twig/twig/lib/Twig/Node/Expression/Binary/Range.php +1 -1
- vendor/twig/twig/lib/Twig/Node/Expression/Binary/StartsWith.php +1 -1
- vendor/twig/twig/lib/Twig/Node/Expression/Binary/Sub.php +2 -2
- vendor/twig/twig/lib/Twig/Node/Expression/BlockReference.php +2 -2
- vendor/twig/twig/lib/Twig/Node/Expression/Call.php +1 -1
- vendor/twig/twig/lib/Twig/Node/Expression/Conditional.php +2 -2
- vendor/twig/twig/lib/Twig/Node/Expression/Constant.php +2 -2
- vendor/twig/twig/lib/Twig/Node/Expression/ExtensionReference.php +1 -1
- vendor/twig/twig/lib/Twig/Node/Expression/Filter.php +2 -2
- vendor/twig/twig/lib/Twig/Node/Expression/Filter/Default.php +1 -1
- vendor/twig/twig/lib/Twig/Node/Expression/Function.php +1 -1
- vendor/twig/twig/lib/Twig/Node/Expression/GetAttr.php +6 -2
- vendor/twig/twig/lib/Twig/Node/Expression/MethodCall.php +1 -1
- vendor/twig/twig/lib/Twig/Node/Expression/Name.php +2 -2
- vendor/twig/twig/lib/Twig/Node/Expression/Parent.php +2 -2
- vendor/twig/twig/lib/Twig/Node/Expression/TempName.php +1 -1
- vendor/twig/twig/lib/Twig/Node/Expression/Test.php +1 -1
- vendor/twig/twig/lib/Twig/Node/Expression/Test/Constant.php +1 -1
- vendor/twig/twig/lib/Twig/Node/Expression/Test/Defined.php +1 -1
- vendor/twig/twig/lib/Twig/Node/Expression/Test/Divisibleby.php +1 -1
- vendor/twig/twig/lib/Twig/Node/Expression/Test/Even.php +1 -1
- vendor/twig/twig/lib/Twig/Node/Expression/Test/Null.php +1 -1
- vendor/twig/twig/lib/Twig/Node/Expression/Test/Odd.php +1 -1
- vendor/twig/twig/lib/Twig/Node/Expression/Test/Sameas.php +1 -1
- vendor/twig/twig/lib/Twig/Node/Expression/Unary.php +2 -2
- vendor/twig/twig/lib/Twig/Node/Expression/Unary/Neg.php +2 -2
- vendor/twig/twig/lib/Twig/Node/Expression/Unary/Not.php +2 -2
- vendor/twig/twig/lib/Twig/Node/Expression/Unary/Pos.php +2 -2
- vendor/twig/twig/lib/Twig/Node/Flush.php +1 -1
- vendor/twig/twig/lib/Twig/Node/For.php +2 -2
- vendor/twig/twig/lib/Twig/Node/ForLoop.php +1 -1
- vendor/twig/twig/lib/Twig/Node/If.php +2 -2
- vendor/twig/twig/lib/Twig/Node/Import.php +1 -1
- vendor/twig/twig/lib/Twig/Node/Include.php +2 -2
- vendor/twig/twig/lib/Twig/Node/Macro.php +1 -1
- vendor/twig/twig/lib/Twig/Node/Module.php +2 -2
- vendor/twig/twig/lib/Twig/Node/Print.php +2 -2
- vendor/twig/twig/lib/Twig/Node/Sandbox.php +1 -1
- vendor/twig/twig/lib/Twig/Node/SandboxedPrint.php +1 -1
- vendor/twig/twig/lib/Twig/Node/Set.php +2 -2
- vendor/twig/twig/lib/Twig/Node/SetTemp.php +1 -1
- vendor/twig/twig/lib/Twig/Node/Spaceless.php +1 -1
- vendor/twig/twig/lib/Twig/Node/Text.php +2 -2
- vendor/twig/twig/lib/Twig/Node/With.php +1 -1
- vendor/twig/twig/lib/Twig/NodeCaptureInterface.php +19 -0
- vendor/twig/twig/lib/Twig/NodeInterface.php +1 -1
- vendor/twig/twig/lib/Twig/NodeOutputInterface.php +1 -1
- vendor/twig/twig/lib/Twig/NodeTraverser.php +3 -1
- vendor/twig/twig/lib/Twig/NodeVisitor/Escaper.php +3 -10
- vendor/twig/twig/lib/Twig/NodeVisitor/Optimizer.php +3 -10
- vendor/twig/twig/lib/Twig/NodeVisitor/SafeAnalysis.php +3 -9
- vendor/twig/twig/lib/Twig/NodeVisitor/Sandbox.php +3 -10
- vendor/twig/twig/lib/Twig/NodeVisitorInterface.php +1 -1
- vendor/twig/twig/lib/Twig/Parser.php +13 -16
- vendor/twig/twig/lib/Twig/ParserInterface.php +1 -1
- vendor/twig/twig/lib/Twig/Profiler/Dumper/Blackfire.php +3 -1
- vendor/twig/twig/lib/Twig/Profiler/Dumper/Html.php +3 -1
- vendor/twig/twig/lib/Twig/Profiler/Dumper/Text.php +3 -1
- vendor/twig/twig/lib/Twig/Profiler/Node/EnterProfile.php +1 -4
- vendor/twig/twig/lib/Twig/Profiler/Node/LeaveProfile.php +1 -4
- vendor/twig/twig/lib/Twig/Profiler/NodeVisitor/Profiler.php +3 -10
- vendor/twig/twig/lib/Twig/Profiler/Profile.php +3 -1
- vendor/twig/twig/lib/Twig/Sandbox/SecurityError.php +1 -1
- vendor/twig/twig/lib/Twig/Sandbox/SecurityNotAllowedFilterError.php +1 -1
- vendor/twig/twig/lib/Twig/Sandbox/SecurityNotAllowedFunctionError.php +1 -1
- vendor/twig/twig/lib/Twig/Sandbox/SecurityNotAllowedMethodError.php +1 -1
- vendor/twig/twig/lib/Twig/Sandbox/SecurityNotAllowedPropertyError.php +1 -1
- vendor/twig/twig/lib/Twig/Sandbox/SecurityNotAllowedTagError.php +1 -1
- vendor/twig/twig/lib/Twig/Sandbox/SecurityPolicy.php +3 -1
- vendor/twig/twig/lib/Twig/Sandbox/SecurityPolicyInterface.php +1 -1
- vendor/twig/twig/lib/Twig/SimpleFilter.php +3 -1
- vendor/twig/twig/lib/Twig/SimpleFunction.php +3 -1
- vendor/twig/twig/lib/Twig/SimpleTest.php +3 -1
- vendor/twig/twig/lib/Twig/Source.php +3 -1
- vendor/twig/twig/lib/Twig/SourceContextLoaderInterface.php +1 -1
- vendor/twig/twig/lib/Twig/Template.php +32 -28
- vendor/twig/twig/lib/Twig/TemplateInterface.php +1 -1
- vendor/twig/twig/lib/Twig/TemplateWrapper.php +1 -1
- vendor/twig/twig/lib/Twig/Test.php +1 -1
- vendor/twig/twig/lib/Twig/Test/Function.php +1 -1
- vendor/twig/twig/lib/Twig/Test/IntegrationTestCase.php +2 -12
- vendor/twig/twig/lib/Twig/Test/Method.php +1 -1
- vendor/twig/twig/lib/Twig/Test/Node.php +1 -1
- vendor/twig/twig/lib/Twig/TestCallableInterface.php +1 -1
- vendor/twig/twig/lib/Twig/TestInterface.php +1 -1
- vendor/twig/twig/lib/Twig/Token.php +4 -2
- vendor/twig/twig/lib/Twig/TokenParser.php +1 -1
- vendor/twig/twig/lib/Twig/TokenParser/AutoEscape.php +5 -3
- vendor/twig/twig/lib/Twig/TokenParser/Block.php +6 -4
- vendor/twig/twig/lib/Twig/TokenParser/Do.php +3 -1
- vendor/twig/twig/lib/Twig/TokenParser/Embed.php +3 -1
- vendor/twig/twig/lib/Twig/TokenParser/Extends.php +6 -4
- vendor/twig/twig/lib/Twig/TokenParser/Filter.php +3 -1
- vendor/twig/twig/lib/Twig/TokenParser/Flush.php +3 -1
- vendor/twig/twig/lib/Twig/TokenParser/For.php +6 -4
- vendor/twig/twig/lib/Twig/TokenParser/From.php +4 -2
- vendor/twig/twig/lib/Twig/TokenParser/If.php +5 -3
- vendor/twig/twig/lib/Twig/TokenParser/Import.php +3 -1
- vendor/twig/twig/lib/Twig/TokenParser/Include.php +4 -2
- vendor/twig/twig/lib/Twig/TokenParser/Macro.php +4 -2
- vendor/twig/twig/lib/Twig/TokenParser/Sandbox.php +4 -2
- vendor/twig/twig/lib/Twig/TokenParser/Set.php +5 -3
- vendor/twig/twig/lib/Twig/TokenParser/Spaceless.php +3 -1
- vendor/twig/twig/lib/Twig/TokenParser/Use.php +4 -2
- vendor/twig/twig/lib/Twig/TokenParser/With.php +3 -1
- vendor/twig/twig/lib/Twig/TokenParserBroker.php +2 -2
- vendor/twig/twig/lib/Twig/TokenParserBrokerInterface.php +2 -2
- vendor/twig/twig/lib/Twig/TokenParserInterface.php +1 -1
- vendor/twig/twig/lib/Twig/TokenStream.php +7 -5
- vendor/twig/twig/lib/Twig/Util/DeprecationCollector.php +2 -0
- vendor/twig/twig/test/Twig/Tests/Cache/FilesystemTest.php +7 -7
- vendor/twig/twig/test/Twig/Tests/CustomExtensionTest.php +88 -0
- vendor/twig/twig/test/Twig/Tests/EnvironmentTest.php +7 -7
- vendor/twig/twig/test/Twig/Tests/ErrorTest.php +75 -8
- vendor/twig/twig/test/Twig/Tests/Extension/CoreTest.php +211 -14
- vendor/twig/twig/test/Twig/Tests/Extension/SandboxTest.php +20 -1
- vendor/twig/twig/test/Twig/Tests/FileCachingTest.php +3 -3
- vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/_self.test +8 -0
- vendor/twig/twig/test/Twig/Tests/Fixtures/functions/recursive_block_with_inheritance.test +1 -1
- vendor/twig/twig/test/Twig/Tests/LegacyFixtures/functions/undefined_block.legacy.test +12 -0
- vendor/twig/twig/test/Twig/Tests/Loader/ChainTest.php +5 -1
- vendor/twig/twig/test/Twig/Tests/ParserTest.php +1 -2
- vendor/twig/twig/test/Twig/Tests/RuntimeFactoryLoaderTest.php +32 -0
- vendor/twig/twig/test/Twig/Tests/TemplateTest.php +83 -130
lib/Admin.php
CHANGED
@@ -71,7 +71,7 @@ class Admin {
|
|
71 |
* @codeCoverageIgnore
|
72 |
*/
|
73 |
protected static function update_message_minor() {
|
74 |
-
$m = "<br><b>Warning:</b> This new version of Timber introduces some new features which might have unknown effects on your site. We have automated tests to help us catch potential issues, but nothing is 100%. You're
|
75 |
return $m;
|
76 |
}
|
77 |
|
71 |
* @codeCoverageIgnore
|
72 |
*/
|
73 |
protected static function update_message_minor() {
|
74 |
+
$m = "<br><b>Warning:</b> This new version of Timber introduces some new features which might have unknown effects on your site. We have automated tests to help us catch potential issues, but nothing is 100%. You're likely safe to upgrade, but do so very carefully and only if you have an experienced WordPress developer available to help you debug potential issues.";
|
75 |
return $m;
|
76 |
}
|
77 |
|
lib/Comment.php
CHANGED
@@ -130,6 +130,12 @@ class Comment extends Core implements CoreInterface {
|
|
130 |
}
|
131 |
|
132 |
$email = $this->avatar_email();
|
|
|
|
|
|
|
|
|
|
|
|
|
133 |
$email_hash = '';
|
134 |
if ( !empty($email) ) {
|
135 |
$email_hash = md5(strtolower(trim($email)));
|
@@ -420,4 +426,4 @@ class Comment extends Core implements CoreInterface {
|
|
420 |
return str_replace('&', '&', esc_url($out));
|
421 |
}
|
422 |
|
423 |
-
}
|
130 |
}
|
131 |
|
132 |
$email = $this->avatar_email();
|
133 |
+
|
134 |
+
$args = apply_filters('pre_get_avatar_data', array(), $email);
|
135 |
+
if ( isset($args['url']) ) {
|
136 |
+
return $args['url'];
|
137 |
+
}
|
138 |
+
|
139 |
$email_hash = '';
|
140 |
if ( !empty($email) ) {
|
141 |
$email_hash = md5(strtolower(trim($email)));
|
426 |
return str_replace('&', '&', esc_url($out));
|
427 |
}
|
428 |
|
429 |
+
}
|
lib/ImageHelper.php
CHANGED
@@ -342,7 +342,7 @@ class ImageHelper {
|
|
342 |
* @param string $url an URL (absolute or relative) pointing to an image
|
343 |
* @return array an array (see keys in code below)
|
344 |
*/
|
345 |
-
|
346 |
$result = array(
|
347 |
'url' => $url, // the initial url
|
348 |
'absolute' => URLHelper::is_absolute($url), // is the url absolute or relative (to home_url)
|
@@ -372,14 +372,13 @@ class ImageHelper {
|
|
372 |
if ( 0 === strpos($tmp, $upload_dir['baseurl']) ) {
|
373 |
$result['base'] = self::BASE_UPLOADS; // upload based
|
374 |
$tmp = str_replace($upload_dir['baseurl'], '', $tmp);
|
375 |
-
}
|
376 |
-
if ( 0 === strpos($tmp, content_url()) ) {
|
377 |
$result['base'] = self::BASE_CONTENT; // content-based
|
378 |
$tmp = self::theme_url_to_dir($tmp);
|
|
|
379 |
}
|
380 |
}
|
381 |
$parts = pathinfo($tmp);
|
382 |
-
|
383 |
$result['subdir'] = ($parts['dirname'] === '/') ? '' : $parts['dirname'];
|
384 |
$result['filename'] = $parts['filename'];
|
385 |
$result['extension'] = strtolower($parts['extension']);
|
@@ -388,14 +387,18 @@ class ImageHelper {
|
|
388 |
}
|
389 |
|
390 |
/**
|
391 |
-
* Converts a URL located in a theme directory into the raw path
|
392 |
* @param string $src a URL (http://example.org/wp-content/themes/twentysixteen/images/home.jpg)
|
393 |
* @return string full path to the file in question
|
394 |
*/
|
395 |
-
|
396 |
-
$
|
397 |
-
$tmp = str_replace($
|
398 |
-
|
|
|
|
|
|
|
|
|
399 |
return $tmp;
|
400 |
}
|
401 |
|
@@ -435,6 +438,19 @@ class ImageHelper {
|
|
435 |
return $url;
|
436 |
}
|
437 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
438 |
/**
|
439 |
* Builds the absolute file system location of a file based on its different components
|
440 |
*
|
@@ -444,24 +460,30 @@ class ImageHelper {
|
|
444 |
* @return string the file location
|
445 |
*/
|
446 |
private static function _get_file_path( $base, $subdir, $filename ) {
|
|
|
|
|
|
|
|
|
|
|
447 |
$path = '';
|
448 |
if ( self::BASE_UPLOADS == $base ) {
|
|
|
449 |
$upload_dir = wp_upload_dir();
|
450 |
$path = $upload_dir['basedir'];
|
451 |
-
}
|
452 |
-
|
453 |
$path = WP_CONTENT_DIR;
|
454 |
}
|
455 |
if ( self::is_in_theme_dir(trailingslashit($subdir).$filename) ) {
|
|
|
456 |
return trailingslashit($subdir).$filename;
|
457 |
-
$path = $subdir;
|
458 |
}
|
459 |
if ( !empty($subdir) ) {
|
460 |
-
$path
|
461 |
}
|
462 |
-
$path
|
463 |
|
464 |
-
return $path;
|
465 |
}
|
466 |
|
467 |
|
@@ -488,8 +510,10 @@ class ImageHelper {
|
|
488 |
$src = self::sideload_image($src);
|
489 |
$external = true;
|
490 |
}
|
|
|
491 |
// break down URL into components
|
492 |
$au = self::analyze_url($src);
|
|
|
493 |
// build URL and filenames
|
494 |
$new_url = self::_get_file_url(
|
495 |
$au['base'],
|
@@ -507,6 +531,7 @@ class ImageHelper {
|
|
507 |
$au['subdir'],
|
508 |
$au['basename']
|
509 |
);
|
|
|
510 |
$new_url = apply_filters('timber/image/new_url', $new_url);
|
511 |
$destination_path = apply_filters('timber/image/new_path', $destination_path);
|
512 |
// if already exists...
|
342 |
* @param string $url an URL (absolute or relative) pointing to an image
|
343 |
* @return array an array (see keys in code below)
|
344 |
*/
|
345 |
+
public static function analyze_url( $url ) {
|
346 |
$result = array(
|
347 |
'url' => $url, // the initial url
|
348 |
'absolute' => URLHelper::is_absolute($url), // is the url absolute or relative (to home_url)
|
372 |
if ( 0 === strpos($tmp, $upload_dir['baseurl']) ) {
|
373 |
$result['base'] = self::BASE_UPLOADS; // upload based
|
374 |
$tmp = str_replace($upload_dir['baseurl'], '', $tmp);
|
375 |
+
} else if ( 0 === strpos($tmp, content_url()) ) {
|
|
|
376 |
$result['base'] = self::BASE_CONTENT; // content-based
|
377 |
$tmp = self::theme_url_to_dir($tmp);
|
378 |
+
$tmp = str_replace(WP_CONTENT_DIR, '', $tmp);
|
379 |
}
|
380 |
}
|
381 |
$parts = pathinfo($tmp);
|
|
|
382 |
$result['subdir'] = ($parts['dirname'] === '/') ? '' : $parts['dirname'];
|
383 |
$result['filename'] = $parts['filename'];
|
384 |
$result['extension'] = strtolower($parts['extension']);
|
387 |
}
|
388 |
|
389 |
/**
|
390 |
+
* Converts a URL located in a theme directory into the raw file path
|
391 |
* @param string $src a URL (http://example.org/wp-content/themes/twentysixteen/images/home.jpg)
|
392 |
* @return string full path to the file in question
|
393 |
*/
|
394 |
+
static function theme_url_to_dir( $src ) {
|
395 |
+
$site_root = trailingslashit(get_theme_root_uri()).get_stylesheet();
|
396 |
+
$tmp = str_replace($site_root, '', $src);
|
397 |
+
//$tmp = trailingslashit(get_theme_root()).get_stylesheet().$tmp;
|
398 |
+
$tmp = get_stylesheet_directory().$tmp;
|
399 |
+
if ( realpath($tmp) ) {
|
400 |
+
return realpath($tmp);
|
401 |
+
}
|
402 |
return $tmp;
|
403 |
}
|
404 |
|
438 |
return $url;
|
439 |
}
|
440 |
|
441 |
+
/**
|
442 |
+
* Runs realpath to resolve symbolic links (../, etc). But only if it's a path and not a URL
|
443 |
+
* @param string $path
|
444 |
+
* @return string the resolved path
|
445 |
+
*/
|
446 |
+
protected static function maybe_realpath( $path ) {
|
447 |
+
if ( strstr($path, '../') !== false ) {
|
448 |
+
return realpath($path);
|
449 |
+
}
|
450 |
+
return $path;
|
451 |
+
}
|
452 |
+
|
453 |
+
|
454 |
/**
|
455 |
* Builds the absolute file system location of a file based on its different components
|
456 |
*
|
460 |
* @return string the file location
|
461 |
*/
|
462 |
private static function _get_file_path( $base, $subdir, $filename ) {
|
463 |
+
if ( URLHelper::is_url($subdir) ) {
|
464 |
+
$subdir = URLHelper::url_to_file_system($subdir);
|
465 |
+
}
|
466 |
+
$subdir = self::maybe_realpath($subdir);
|
467 |
+
|
468 |
$path = '';
|
469 |
if ( self::BASE_UPLOADS == $base ) {
|
470 |
+
//it is in the Uploads directory
|
471 |
$upload_dir = wp_upload_dir();
|
472 |
$path = $upload_dir['basedir'];
|
473 |
+
} else if ( self::BASE_CONTENT == $base ) {
|
474 |
+
//it is in the content directory, somewhere else ...
|
475 |
$path = WP_CONTENT_DIR;
|
476 |
}
|
477 |
if ( self::is_in_theme_dir(trailingslashit($subdir).$filename) ) {
|
478 |
+
//this is for weird installs when the theme folder is outside of /wp-content
|
479 |
return trailingslashit($subdir).$filename;
|
|
|
480 |
}
|
481 |
if ( !empty($subdir) ) {
|
482 |
+
$path = trailingslashit($path).$subdir;
|
483 |
}
|
484 |
+
$path = trailingslashit($path).$filename;
|
485 |
|
486 |
+
return URLHelper::remove_double_slashes($path);
|
487 |
}
|
488 |
|
489 |
|
510 |
$src = self::sideload_image($src);
|
511 |
$external = true;
|
512 |
}
|
513 |
+
|
514 |
// break down URL into components
|
515 |
$au = self::analyze_url($src);
|
516 |
+
|
517 |
// build URL and filenames
|
518 |
$new_url = self::_get_file_url(
|
519 |
$au['base'],
|
531 |
$au['subdir'],
|
532 |
$au['basename']
|
533 |
);
|
534 |
+
|
535 |
$new_url = apply_filters('timber/image/new_url', $new_url);
|
536 |
$destination_path = apply_filters('timber/image/new_path', $destination_path);
|
537 |
// if already exists...
|
lib/Timber.php
CHANGED
@@ -35,7 +35,7 @@ use Timber\Loader;
|
|
35 |
*/
|
36 |
class Timber {
|
37 |
|
38 |
-
public static $version = '1.2.
|
39 |
public static $locations;
|
40 |
public static $dirname = 'views';
|
41 |
public static $twig_cache = false;
|
@@ -240,7 +240,7 @@ class Timber {
|
|
240 |
self::$context_cache['user'] = ($user->ID) ? $user : false;
|
241 |
self::$context_cache['theme'] = self::$context_cache['site']->theme;
|
242 |
|
243 |
-
|
244 |
//self::$context_cache['posts'] = new PostQuery();
|
245 |
self::$context_cache['posts'] = Timber::query_posts();
|
246 |
|
35 |
*/
|
36 |
class Timber {
|
37 |
|
38 |
+
public static $version = '1.2.2';
|
39 |
public static $locations;
|
40 |
public static $dirname = 'views';
|
41 |
public static $twig_cache = false;
|
240 |
self::$context_cache['user'] = ($user->ID) ? $user : false;
|
241 |
self::$context_cache['theme'] = self::$context_cache['site']->theme;
|
242 |
|
243 |
+
/* @todo enable PostQuery in 1.3 */
|
244 |
//self::$context_cache['posts'] = new PostQuery();
|
245 |
self::$context_cache['posts'] = Timber::query_posts();
|
246 |
|
lib/URLHelper.php
CHANGED
@@ -219,6 +219,16 @@ class URLHelper {
|
|
219 |
return $path;
|
220 |
}
|
221 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
222 |
/**
|
223 |
* This will evaluate wheter a URL is at an aboslute location (like http://example.org/whatever)
|
224 |
*
|
219 |
return $path;
|
220 |
}
|
221 |
|
222 |
+
/**
|
223 |
+
*
|
224 |
+
*
|
225 |
+
* @param string $path
|
226 |
+
* @return string
|
227 |
+
*/
|
228 |
+
public static function unpreslashit( $path ) {
|
229 |
+
return ltrim($path, '/');
|
230 |
+
}
|
231 |
+
|
232 |
/**
|
233 |
* This will evaluate wheter a URL is at an aboslute location (like http://example.org/whatever)
|
234 |
*
|
readme.txt
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
Contributors: jarednova, connorjburton, lggorman
|
3 |
Tags: template engine, templates, twig
|
4 |
Requires at least: 3.7
|
5 |
-
Stable tag: 1.2.
|
6 |
Tested up to: 4.7.1
|
7 |
PHP version: 5.3.0 or greater
|
8 |
License: GPLv2 or later
|
@@ -41,6 +41,17 @@ Timber is great for any WordPress developer who cares about writing good, mainta
|
|
41 |
|
42 |
== Changelog ==
|
43 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
= 1.2.0 =
|
45 |
* Fixed issues with WordPress 4.7
|
46 |
* Introduced Timber\CommentThread object
|
2 |
Contributors: jarednova, connorjburton, lggorman
|
3 |
Tags: template engine, templates, twig
|
4 |
Requires at least: 3.7
|
5 |
+
Stable tag: 1.2.2
|
6 |
Tested up to: 4.7.1
|
7 |
PHP version: 5.3.0 or greater
|
8 |
License: GPLv2 or later
|
41 |
|
42 |
== Changelog ==
|
43 |
|
44 |
+
= 1.2.2 =
|
45 |
+
* A bunch of fixes to how images in themes are handled #1317 #1293 (@jarednova)
|
46 |
+
* Fixed filter for avatar images in comments #1310 (@xavivars)
|
47 |
+
* Upgrades to PHPUnit and testing suite (@jarednova)
|
48 |
+
|
49 |
+
= 1.2.1 =
|
50 |
+
* Cleaned-up theme handling #1281 (thanks @xavivars)
|
51 |
+
* Refactor of Pagination #1284 (thanks again @xavivars)
|
52 |
+
* Fixed an error in Admin #1285 (thanks @alexanderanberg)
|
53 |
+
* Fixed an issue with User->id #1283 (thanks @drumba)
|
54 |
+
|
55 |
= 1.2.0 =
|
56 |
* Fixed issues with WordPress 4.7
|
57 |
* Introduced Timber\CommentThread object
|
timber-starter-theme/templates/comment-form.twig
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div class="comment-form">
|
2 |
+
<h3> add comment </h3>
|
3 |
+
|
4 |
+
<form id="form" class="comment-form" method="post" action="{{ site.url~'/wp-comments-post.php' }}">
|
5 |
+
{% if user %}
|
6 |
+
<input type="hidden" name="email" value="{{ user.email }}">
|
7 |
+
<input type="hidden" name="author" value="{{ user.name }}">
|
8 |
+
<input type="hidden" name="url" value="{{ user.link }}">
|
9 |
+
{% else %}
|
10 |
+
<div>
|
11 |
+
<label for="email"> email </label>
|
12 |
+
<input required name="email" type="text" id="email"/>
|
13 |
+
|
14 |
+
<label for="author"> username </label>
|
15 |
+
<input required name="author" type="text" id="author"/>
|
16 |
+
|
17 |
+
<label for="url"> url </label>
|
18 |
+
<input name="url" id="url" type="text"/>
|
19 |
+
</div>
|
20 |
+
{% endif %}
|
21 |
+
|
22 |
+
<div>
|
23 |
+
<label for="comment"> comment </label>
|
24 |
+
<textarea placeholder="comment text" name="comment" cols="60" rows="3" id="comment"></textarea>
|
25 |
+
</div>
|
26 |
+
|
27 |
+
<input name="comment_post_ID" value="{{ post.id }}" id="comment_post_ID" type="hidden">
|
28 |
+
<input name="comment_parent" id="comment_parent" value="{{ comment.ID|default('0') }}" type="hidden">
|
29 |
+
|
30 |
+
<div>
|
31 |
+
<button type="submit" name="Submit" class="btn"> send </button>
|
32 |
+
<button type="reset"> cancel </button>
|
33 |
+
<p> Your comment will be revised by the site if needed. </p>
|
34 |
+
</div>
|
35 |
+
</form>
|
36 |
+
</div>
|
timber-starter-theme/templates/comment.twig
CHANGED
@@ -1,4 +1,19 @@
|
|
1 |
<div class="blog-comment {{comment.comment_type}}" id="blog-comment-{{comment.ID}}">
|
2 |
<h5 class="comment-author">{{comment.author.name}} says</h5>
|
3 |
<div class="comment-content">{{comment.comment_content|wpautop}}</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
</div>
|
1 |
<div class="blog-comment {{comment.comment_type}}" id="blog-comment-{{comment.ID}}">
|
2 |
<h5 class="comment-author">{{comment.author.name}} says</h5>
|
3 |
<div class="comment-content">{{comment.comment_content|wpautop}}</div>
|
4 |
+
|
5 |
+
<section class="comment-box">
|
6 |
+
<!-- child comments -->
|
7 |
+
{% if post.comments %}
|
8 |
+
<h4> replies </h4>
|
9 |
+
<div class="comments">
|
10 |
+
{% for cmt in comment.children %}
|
11 |
+
{% include "comment.twig" with {comment:cmt} %}
|
12 |
+
{% endfor %}
|
13 |
+
</div>
|
14 |
+
{% endif %}
|
15 |
+
|
16 |
+
<!-- comment form -->
|
17 |
+
{% include "comment-form.twig" %}
|
18 |
+
</section>
|
19 |
</div>
|
timber-starter-theme/templates/single.twig
CHANGED
@@ -12,19 +12,26 @@
|
|
12 |
{{post.content}}
|
13 |
</div>
|
14 |
</section>
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
</article>
|
29 |
</div><!-- /content-wrapper -->
|
30 |
-
{% endblock %}
|
12 |
{{post.content}}
|
13 |
</div>
|
14 |
</section>
|
15 |
+
|
16 |
+
<!-- comment box -->
|
17 |
+
<section class="comment-box">
|
18 |
+
<!-- comments -->
|
19 |
+
<div class="comments">
|
20 |
+
{% if post.comments %}
|
21 |
+
<h3> comments </h3>
|
22 |
+
{% for cmt in post.comments %}
|
23 |
+
{% include "comment.twig" with {comment:cmt} %}
|
24 |
+
{% endfor %}
|
25 |
+
{% endif %}
|
26 |
+
</div>
|
27 |
+
|
28 |
+
{% if post.comment_status == "closed" %}
|
29 |
+
<p> comments for this post are closed </p>
|
30 |
+
{% else %}
|
31 |
+
<!-- comment form -->
|
32 |
+
{% include "comment-form.twig" %}
|
33 |
+
{% endif %}
|
34 |
+
</section>
|
35 |
</article>
|
36 |
</div><!-- /content-wrapper -->
|
37 |
+
{% endblock %}
|
timber.php
CHANGED
@@ -4,7 +4,7 @@ Plugin Name: Timber
|
|
4 |
Description: The WordPress Timber Library allows you to write themes using the power Twig templates.
|
5 |
Plugin URI: http://timber.upstatement.com
|
6 |
Author: Jared Novack + Upstatement
|
7 |
-
Version: 1.2.
|
8 |
Author URI: http://upstatement.com/
|
9 |
*/
|
10 |
// we look for Composer files first in the plugins dir.
|
4 |
Description: The WordPress Timber Library allows you to write themes using the power Twig templates.
|
5 |
Plugin URI: http://timber.upstatement.com
|
6 |
Author: Jared Novack + Upstatement
|
7 |
+
Version: 1.2.2
|
8 |
Author URI: http://upstatement.com/
|
9 |
*/
|
10 |
// we look for Composer files first in the plugins dir.
|
vendor/asm89/twig-cache-extension/.travis.yml
CHANGED
@@ -5,14 +5,32 @@ cache:
|
|
5 |
- vendor
|
6 |
- $HOME/.composer/cache
|
7 |
|
|
|
|
|
|
|
|
|
8 |
php:
|
9 |
- 5.3
|
10 |
- 5.4
|
11 |
- 5.5
|
12 |
- 5.6
|
13 |
- 7.0
|
|
|
14 |
- hhvm
|
15 |
|
16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
script: phpunit
|
5 |
- vendor
|
6 |
- $HOME/.composer/cache
|
7 |
|
8 |
+
env:
|
9 |
+
- TWIG_VERSION="^1.0"
|
10 |
+
- TWIG_VERSION="^2.0"
|
11 |
+
|
12 |
php:
|
13 |
- 5.3
|
14 |
- 5.4
|
15 |
- 5.5
|
16 |
- 5.6
|
17 |
- 7.0
|
18 |
+
- 7.1
|
19 |
- hhvm
|
20 |
|
21 |
+
matrix:
|
22 |
+
exclude:
|
23 |
+
- php: 5.3
|
24 |
+
env: TWIG_VERSION="^2.0"
|
25 |
+
- php: 5.4
|
26 |
+
env: TWIG_VERSION="^2.0"
|
27 |
+
- php: 5.5
|
28 |
+
env: TWIG_VERSION="^2.0"
|
29 |
+
- php: 5.6
|
30 |
+
env: TWIG_VERSION="^2.0"
|
31 |
+
- php: hhvm
|
32 |
+
env: TWIG_VERSION="^2.0"
|
33 |
+
|
34 |
+
install: composer require twig/twig:${TWIG_VERSION}
|
35 |
|
36 |
script: phpunit
|
vendor/asm89/twig-cache-extension/README.md
CHANGED
@@ -58,7 +58,7 @@ composer require cache/apcu-adapter
|
|
58 |
use Asm89\Twig\CacheExtension\CacheProvider\PsrCacheAdapter;
|
59 |
use Asm89\Twig\CacheExtension\CacheStrategy\LifetimeCacheStrategy;
|
60 |
use Asm89\Twig\CacheExtension\Extension as CacheExtension;
|
61 |
-
use Cache\Adapter\Apcu\ApcuCachePool
|
62 |
|
63 |
$cacheProvider = new PsrCacheAdapter(new ApcuCachePool());
|
64 |
$cacheStrategy = new LifetimeCacheStrategy($cacheProvider);
|
58 |
use Asm89\Twig\CacheExtension\CacheProvider\PsrCacheAdapter;
|
59 |
use Asm89\Twig\CacheExtension\CacheStrategy\LifetimeCacheStrategy;
|
60 |
use Asm89\Twig\CacheExtension\Extension as CacheExtension;
|
61 |
+
use Cache\Adapter\Apcu\ApcuCachePool;
|
62 |
|
63 |
$cacheProvider = new PsrCacheAdapter(new ApcuCachePool());
|
64 |
$cacheStrategy = new LifetimeCacheStrategy($cacheProvider);
|
vendor/asm89/twig-cache-extension/composer.json
CHANGED
@@ -13,7 +13,7 @@
|
|
13 |
],
|
14 |
"require": {
|
15 |
"php": ">=5.3.2",
|
16 |
-
"twig/twig": "
|
17 |
},
|
18 |
"require-dev": {
|
19 |
"doctrine/cache": "~1.0"
|
@@ -33,7 +33,7 @@
|
|
33 |
},
|
34 |
"extra": {
|
35 |
"branch-alias": {
|
36 |
-
"dev-master": "1.
|
37 |
}
|
38 |
}
|
39 |
}
|
13 |
],
|
14 |
"require": {
|
15 |
"php": ">=5.3.2",
|
16 |
+
"twig/twig": "^1.0|^2.0"
|
17 |
},
|
18 |
"require-dev": {
|
19 |
"doctrine/cache": "~1.0"
|
33 |
},
|
34 |
"extra": {
|
35 |
"branch-alias": {
|
36 |
+
"dev-master": "1.3-dev"
|
37 |
}
|
38 |
}
|
39 |
}
|
vendor/asm89/twig-cache-extension/lib/Asm89/Twig/CacheExtension/Extension.php
CHANGED
@@ -41,6 +41,9 @@ class Extension extends \Twig_Extension
|
|
41 |
*/
|
42 |
public function getName()
|
43 |
{
|
|
|
|
|
|
|
44 |
return 'asm89_cache';
|
45 |
}
|
46 |
|
41 |
*/
|
42 |
public function getName()
|
43 |
{
|
44 |
+
if (version_compare(\Twig_Environment::VERSION, '1.26.0', '>=')) {
|
45 |
+
return get_class($this);
|
46 |
+
}
|
47 |
return 'asm89_cache';
|
48 |
}
|
49 |
|
vendor/asm89/twig-cache-extension/lib/Asm89/Twig/CacheExtension/Node/CacheNode.php
CHANGED
@@ -39,9 +39,15 @@ class CacheNode extends \Twig_Node
|
|
39 |
{
|
40 |
$i = self::$cacheCount++;
|
41 |
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
$compiler
|
43 |
->addDebugInfo($this)
|
44 |
-
->write("\$asm89CacheStrategy".$i." = \$this->env->getExtension('
|
45 |
->write("\$asm89Key".$i." = \$asm89CacheStrategy".$i."->generateKey(")
|
46 |
->subcompile($this->getNode('annotation'))
|
47 |
->raw(", ")
|
39 |
{
|
40 |
$i = self::$cacheCount++;
|
41 |
|
42 |
+
if (version_compare(\Twig_Environment::VERSION, '1.26.0', '>=')) {
|
43 |
+
$extension = 'Asm89\Twig\CacheExtension\Extension';
|
44 |
+
} else {
|
45 |
+
$extension = 'asm89_cache';
|
46 |
+
}
|
47 |
+
|
48 |
$compiler
|
49 |
->addDebugInfo($this)
|
50 |
+
->write("\$asm89CacheStrategy".$i." = \$this->env->getExtension('{$extension}')->getCacheStrategy();\n")
|
51 |
->write("\$asm89Key".$i." = \$asm89CacheStrategy".$i."->generateKey(")
|
52 |
->subcompile($this->getNode('annotation'))
|
53 |
->raw(", ")
|
vendor/asm89/twig-cache-extension/test/Asm89/Twig/CacheExtension/Tests/FunctionalExtensionTest.php
CHANGED
@@ -132,7 +132,7 @@ class FunctionalExtensionTest extends \PHPUnit_Framework_TestCase
|
|
132 |
|
133 |
/**
|
134 |
* @expectedException Twig_Error_Runtime
|
135 |
-
* @expectedExceptionMessage An exception has been thrown during the rendering of a template ("No strategy key found in value.")
|
136 |
*/
|
137 |
public function testIndexedChainingStrategyNeedsKey()
|
138 |
{
|
132 |
|
133 |
/**
|
134 |
* @expectedException Twig_Error_Runtime
|
135 |
+
* @expectedExceptionMessage An exception has been thrown during the rendering of a template ("No strategy key found in value.")
|
136 |
*/
|
137 |
public function testIndexedChainingStrategyNeedsKey()
|
138 |
{
|
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 ComposerAutoloaderInit224e0edbae26e0da9078296bff38b54c::getLoader();
|
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,9 +19,9 @@ class ComposerAutoloaderInitbae1da8343e649dd75a784392ec6d01a
|
|
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 |
$map = require __DIR__ . '/autoload_namespaces.php';
|
27 |
foreach ($map as $namespace => $path) {
|
2 |
|
3 |
// autoload_real.php @generated by Composer
|
4 |
|
5 |
+
class ComposerAutoloaderInit224e0edbae26e0da9078296bff38b54c
|
6 |
{
|
7 |
private static $loader;
|
8 |
|
19 |
return self::$loader;
|
20 |
}
|
21 |
|
22 |
+
spl_autoload_register(array('ComposerAutoloaderInit224e0edbae26e0da9078296bff38b54c', 'loadClassLoader'), true, true);
|
23 |
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
24 |
+
spl_autoload_unregister(array('ComposerAutoloaderInit224e0edbae26e0da9078296bff38b54c', 'loadClassLoader'));
|
25 |
|
26 |
$map = require __DIR__ . '/autoload_namespaces.php';
|
27 |
foreach ($map as $namespace => $path) {
|
vendor/composer/installed.json
CHANGED
@@ -110,17 +110,17 @@
|
|
110 |
},
|
111 |
{
|
112 |
"name": "twig/twig",
|
113 |
-
"version": "v1.
|
114 |
-
"version_normalized": "1.
|
115 |
"source": {
|
116 |
"type": "git",
|
117 |
"url": "https://github.com/twigphp/Twig.git",
|
118 |
-
"reference": "
|
119 |
},
|
120 |
"dist": {
|
121 |
"type": "zip",
|
122 |
-
"url": "https://api.github.com/repos/twigphp/Twig/zipball/
|
123 |
-
"reference": "
|
124 |
"shasum": ""
|
125 |
},
|
126 |
"require": {
|
@@ -128,13 +128,13 @@
|
|
128 |
},
|
129 |
"require-dev": {
|
130 |
"symfony/debug": "~2.7",
|
131 |
-
"symfony/phpunit-bridge": "~3.2
|
132 |
},
|
133 |
-
"time": "
|
134 |
"type": "library",
|
135 |
"extra": {
|
136 |
"branch-alias": {
|
137 |
-
"dev-master": "1.
|
138 |
}
|
139 |
},
|
140 |
"installation-source": "dist",
|
@@ -173,22 +173,22 @@
|
|
173 |
},
|
174 |
{
|
175 |
"name": "asm89/twig-cache-extension",
|
176 |
-
"version": "1.3.
|
177 |
-
"version_normalized": "1.3.
|
178 |
"source": {
|
179 |
"type": "git",
|
180 |
"url": "https://github.com/asm89/twig-cache-extension.git",
|
181 |
-
"reference": "
|
182 |
},
|
183 |
"dist": {
|
184 |
"type": "zip",
|
185 |
-
"url": "https://api.github.com/repos/asm89/twig-cache-extension/zipball/
|
186 |
-
"reference": "
|
187 |
"shasum": ""
|
188 |
},
|
189 |
"require": {
|
190 |
"php": ">=5.3.2",
|
191 |
-
"twig/twig": "
|
192 |
},
|
193 |
"require-dev": {
|
194 |
"doctrine/cache": "~1.0"
|
@@ -196,11 +196,11 @@
|
|
196 |
"suggest": {
|
197 |
"psr/cache-implementation": "To make use of PSR-6 cache implementation via PsrCacheAdapter."
|
198 |
},
|
199 |
-
"time": "
|
200 |
"type": "library",
|
201 |
"extra": {
|
202 |
"branch-alias": {
|
203 |
-
"dev-master": "1.
|
204 |
}
|
205 |
},
|
206 |
"installation-source": "dist",
|
110 |
},
|
111 |
{
|
112 |
"name": "twig/twig",
|
113 |
+
"version": "v1.31.0",
|
114 |
+
"version_normalized": "1.31.0.0",
|
115 |
"source": {
|
116 |
"type": "git",
|
117 |
"url": "https://github.com/twigphp/Twig.git",
|
118 |
+
"reference": "ddc9e3e20ee9c0b6908f401ac8353635b750eca7"
|
119 |
},
|
120 |
"dist": {
|
121 |
"type": "zip",
|
122 |
+
"url": "https://api.github.com/repos/twigphp/Twig/zipball/ddc9e3e20ee9c0b6908f401ac8353635b750eca7",
|
123 |
+
"reference": "ddc9e3e20ee9c0b6908f401ac8353635b750eca7",
|
124 |
"shasum": ""
|
125 |
},
|
126 |
"require": {
|
128 |
},
|
129 |
"require-dev": {
|
130 |
"symfony/debug": "~2.7",
|
131 |
+
"symfony/phpunit-bridge": "~3.2"
|
132 |
},
|
133 |
+
"time": "2017-01-11 19:36:15",
|
134 |
"type": "library",
|
135 |
"extra": {
|
136 |
"branch-alias": {
|
137 |
+
"dev-master": "1.31-dev"
|
138 |
}
|
139 |
},
|
140 |
"installation-source": "dist",
|
173 |
},
|
174 |
{
|
175 |
"name": "asm89/twig-cache-extension",
|
176 |
+
"version": "1.3.2",
|
177 |
+
"version_normalized": "1.3.2.0",
|
178 |
"source": {
|
179 |
"type": "git",
|
180 |
"url": "https://github.com/asm89/twig-cache-extension.git",
|
181 |
+
"reference": "630ea7abdc3fc62ba6786c02590a1560e449cf55"
|
182 |
},
|
183 |
"dist": {
|
184 |
"type": "zip",
|
185 |
+
"url": "https://api.github.com/repos/asm89/twig-cache-extension/zipball/630ea7abdc3fc62ba6786c02590a1560e449cf55",
|
186 |
+
"reference": "630ea7abdc3fc62ba6786c02590a1560e449cf55",
|
187 |
"shasum": ""
|
188 |
},
|
189 |
"require": {
|
190 |
"php": ">=5.3.2",
|
191 |
+
"twig/twig": "^1.0|^2.0"
|
192 |
},
|
193 |
"require-dev": {
|
194 |
"doctrine/cache": "~1.0"
|
196 |
"suggest": {
|
197 |
"psr/cache-implementation": "To make use of PSR-6 cache implementation via PsrCacheAdapter."
|
198 |
},
|
199 |
+
"time": "2017-01-10 22:04:15",
|
200 |
"type": "library",
|
201 |
"extra": {
|
202 |
"branch-alias": {
|
203 |
+
"dev-master": "1.3-dev"
|
204 |
}
|
205 |
},
|
206 |
"installation-source": "dist",
|
vendor/twig/twig/.php_cs.dist
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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/CHANGELOG
CHANGED
@@ -1,3 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
* 1.28.2 (2016-11-23)
|
2 |
|
3 |
* fixed precedence between getFoo() and isFoo() in Twig_Template::getAttribute()
|
1 |
+
* 1.31.0 (2017-01-11)
|
2 |
+
|
3 |
+
* added Twig_NodeCaptureInterface for nodes that capture all output
|
4 |
+
* fixed marking the environment as initialized too early
|
5 |
+
* fixed C89 compat for the C extension
|
6 |
+
* turned fatal error into exception when a previously generated cache is corrupted
|
7 |
+
* fixed offline cache warm-ups for embedded templates
|
8 |
+
|
9 |
+
* 1.30.0 (2016-12-23)
|
10 |
+
|
11 |
+
* added Twig_FactoryRuntimeLoader
|
12 |
+
* deprecated function/test/filter/tag overriding
|
13 |
+
* deprecated the "disable_c_ext" attribute on Twig_Node_Expression_GetAttr
|
14 |
+
|
15 |
+
* 1.29.0 (2016-12-13)
|
16 |
+
|
17 |
+
* fixed sandbox being left enabled if an exception is thrown while rendering
|
18 |
+
* marked some classes as being final (via @final)
|
19 |
+
* made Twig_Error report real source path when possible
|
20 |
+
* added support for {{ _self }} to provide an upgrade path from 1.x to 2.0 (replaces {{ _self.templateName }})
|
21 |
+
* deprecated silent display of undefined blocks
|
22 |
+
* deprecated support for mbstring.func_overload != 0
|
23 |
+
|
24 |
* 1.28.2 (2016-11-23)
|
25 |
|
26 |
* fixed precedence between getFoo() and isFoo() in Twig_Template::getAttribute()
|
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/composer.json
CHANGED
@@ -30,7 +30,7 @@
|
|
30 |
"php": ">=5.2.7"
|
31 |
},
|
32 |
"require-dev": {
|
33 |
-
"symfony/phpunit-bridge": "~3.2
|
34 |
"symfony/debug": "~2.7"
|
35 |
},
|
36 |
"autoload": {
|
@@ -40,7 +40,7 @@
|
|
40 |
},
|
41 |
"extra": {
|
42 |
"branch-alias": {
|
43 |
-
"dev-master": "1.
|
44 |
}
|
45 |
}
|
46 |
}
|
30 |
"php": ">=5.2.7"
|
31 |
},
|
32 |
"require-dev": {
|
33 |
+
"symfony/phpunit-bridge": "~3.2",
|
34 |
"symfony/debug": "~2.7"
|
35 |
},
|
36 |
"autoload": {
|
40 |
},
|
41 |
"extra": {
|
42 |
"branch-alias": {
|
43 |
+
"dev-master": "1.31-dev"
|
44 |
}
|
45 |
}
|
46 |
}
|
vendor/twig/twig/doc/advanced.rst
CHANGED
@@ -596,7 +596,7 @@ An extension is a class that implements the following interface::
|
|
596 |
/**
|
597 |
* Returns a list of operators to add to the existing list.
|
598 |
*
|
599 |
-
* @return array
|
600 |
*/
|
601 |
function getOperators();
|
602 |
|
596 |
/**
|
597 |
* Returns a list of operators to add to the existing list.
|
598 |
*
|
599 |
+
* @return array<array> First array of unary operators, second array of binary operators
|
600 |
*/
|
601 |
function getOperators();
|
602 |
|
vendor/twig/twig/doc/advanced_legacy.rst
CHANGED
@@ -580,7 +580,7 @@ An extension is a class that implements the following interface::
|
|
580 |
/**
|
581 |
* Returns a list of operators to add to the existing list.
|
582 |
*
|
583 |
-
* @return array
|
584 |
*/
|
585 |
function getOperators();
|
586 |
|
580 |
/**
|
581 |
* Returns a list of operators to add to the existing list.
|
582 |
*
|
583 |
+
* @return array<array> First array of unary operators, second array of binary operators
|
584 |
*/
|
585 |
function getOperators();
|
586 |
|
vendor/twig/twig/doc/deprecated.rst
CHANGED
@@ -11,6 +11,13 @@ Deprecation Notices
|
|
11 |
As of Twig 1.21, Twig generates deprecation notices when a template uses
|
12 |
deprecated features. See :ref:`deprecation-notices` for more information.
|
13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
Token Parsers
|
15 |
-------------
|
16 |
|
@@ -181,7 +188,8 @@ Globals
|
|
181 |
current ``Twig_Template`` instance is deprecated; most usages only need the
|
182 |
current template name, which will continue to work in Twig 2.0. In Twig 2.0,
|
183 |
``_self`` returns the current template name instead of the current
|
184 |
-
``Twig_Template`` instance.
|
|
|
185 |
|
186 |
Miscellaneous
|
187 |
-------------
|
@@ -208,3 +216,6 @@ Miscellaneous
|
|
208 |
|
209 |
* As of Twig 1.27, ``Twig_Parser::addHandler()`` and
|
210 |
``Twig_Parser::addNodeVisitor()`` are deprecated and will be removed in 2.0.
|
|
|
|
|
|
11 |
As of Twig 1.21, Twig generates deprecation notices when a template uses
|
12 |
deprecated features. See :ref:`deprecation-notices` for more information.
|
13 |
|
14 |
+
Macros
|
15 |
+
------
|
16 |
+
|
17 |
+
As of Twig 2.0, macros imported in a file are not available in child templates
|
18 |
+
anymore (via an ``include`` call for instance). You need to import macros
|
19 |
+
explicitly in each file where you are using them.
|
20 |
+
|
21 |
Token Parsers
|
22 |
-------------
|
23 |
|
188 |
current ``Twig_Template`` instance is deprecated; most usages only need the
|
189 |
current template name, which will continue to work in Twig 2.0. In Twig 2.0,
|
190 |
``_self`` returns the current template name instead of the current
|
191 |
+
``Twig_Template`` instance. If you are using ``{{ _self.templateName }}``,
|
192 |
+
just replace it with ``{{ _self }}``.
|
193 |
|
194 |
Miscellaneous
|
195 |
-------------
|
216 |
|
217 |
* As of Twig 1.27, ``Twig_Parser::addHandler()`` and
|
218 |
``Twig_Parser::addNodeVisitor()`` are deprecated and will be removed in 2.0.
|
219 |
+
|
220 |
+
* As of Twig 1.29, some classes are marked as being final via the `@final`
|
221 |
+
annotation. Those classes will be marked as final in 2.0.
|
vendor/twig/twig/doc/filters/replace.rst
CHANGED
@@ -14,6 +14,6 @@ The ``replace`` filter formats a given string by replacing the placeholders
|
|
14 |
Arguments
|
15 |
---------
|
16 |
|
17 |
-
* ``
|
18 |
|
19 |
.. seealso:: :doc:`format<format>`
|
14 |
Arguments
|
15 |
---------
|
16 |
|
17 |
+
* ``from``: The placeholder values
|
18 |
|
19 |
.. seealso:: :doc:`format<format>`
|
vendor/twig/twig/doc/functions/range.rst
CHANGED
@@ -12,7 +12,7 @@ Returns a list containing an arithmetic progression of integers:
|
|
12 |
{# outputs 0, 1, 2, 3, #}
|
13 |
|
14 |
When step is given (as the third parameter), it specifies the increment (or
|
15 |
-
decrement):
|
16 |
|
17 |
.. code-block:: jinja
|
18 |
|
@@ -22,8 +22,21 @@ decrement):
|
|
22 |
|
23 |
{# outputs 0, 2, 4, 6, #}
|
24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
The Twig built-in ``..`` operator is just syntactic sugar for the ``range``
|
26 |
-
function (with a step of 1):
|
27 |
|
28 |
.. code-block:: jinja
|
29 |
|
12 |
{# outputs 0, 1, 2, 3, #}
|
13 |
|
14 |
When step is given (as the third parameter), it specifies the increment (or
|
15 |
+
decrement for negative values):
|
16 |
|
17 |
.. code-block:: jinja
|
18 |
|
22 |
|
23 |
{# outputs 0, 2, 4, 6, #}
|
24 |
|
25 |
+
.. note::
|
26 |
+
|
27 |
+
Note that if the start is greater than the end, ``range`` assumes a step of
|
28 |
+
``-1``:
|
29 |
+
|
30 |
+
.. code-block:: jinja
|
31 |
+
|
32 |
+
{% for i in range(3, 0) %}
|
33 |
+
{{ i }},
|
34 |
+
{% endfor %}
|
35 |
+
|
36 |
+
{# outputs 3, 2, 1, 0, #}
|
37 |
+
|
38 |
The Twig built-in ``..`` operator is just syntactic sugar for the ``range``
|
39 |
+
function (with a step of ``1``, or ``-1`` if the start is greater than the end):
|
40 |
|
41 |
.. code-block:: jinja
|
42 |
|
vendor/twig/twig/doc/tags/extends.rst
CHANGED
@@ -153,7 +153,7 @@ Twig supports dynamic inheritance by using a variable as the base template:
|
|
153 |
|
154 |
{% extends some_var %}
|
155 |
|
156 |
-
If the variable evaluates to a ``Twig_Template`` or a ``
|
157 |
instance, Twig will use it as the parent template::
|
158 |
|
159 |
// {% extends layout %}
|
153 |
|
154 |
{% extends some_var %}
|
155 |
|
156 |
+
If the variable evaluates to a ``Twig_Template`` or a ``Twig_TemplateWrapper``
|
157 |
instance, Twig will use it as the parent template::
|
158 |
|
159 |
// {% extends layout %}
|
vendor/twig/twig/ext/twig/php_twig.h
CHANGED
@@ -15,7 +15,7 @@
|
|
15 |
#ifndef PHP_TWIG_H
|
16 |
#define PHP_TWIG_H
|
17 |
|
18 |
-
#define PHP_TWIG_VERSION "1.
|
19 |
|
20 |
#include "php.h"
|
21 |
|
15 |
#ifndef PHP_TWIG_H
|
16 |
#define PHP_TWIG_H
|
17 |
|
18 |
+
#define PHP_TWIG_VERSION "1.31.0"
|
19 |
|
20 |
#include "php.h"
|
21 |
|
vendor/twig/twig/ext/twig/twig.c
CHANGED
@@ -31,6 +31,10 @@
|
|
31 |
#define Z_ADDREF_P(pz) (pz)->refcount++
|
32 |
#endif
|
33 |
|
|
|
|
|
|
|
|
|
34 |
#define FREE_DTOR(z) \
|
35 |
zval_dtor(z); \
|
36 |
efree(z);
|
@@ -987,6 +991,7 @@ PHP_FUNCTION(twig_template_get_attributes)
|
|
987 |
char *lcItem = TWIG_STRTOLOWER(item, item_len);
|
988 |
int lcItem_length;
|
989 |
char *method = NULL;
|
|
|
990 |
char *tmp_method_name_get;
|
991 |
char *tmp_method_name_is;
|
992 |
zval *zmethod;
|
@@ -1000,6 +1005,8 @@ PHP_FUNCTION(twig_template_get_attributes)
|
|
1000 |
sprintf(tmp_method_name_is, "is%s", lcItem);
|
1001 |
|
1002 |
tmp_methods = TWIG_GET_ARRAY_ELEMENT(tmp_class, "methods", strlen("methods") TSRMLS_CC);
|
|
|
|
|
1003 |
|
1004 |
if (TWIG_GET_ARRAY_ELEMENT(tmp_methods, lcItem, lcItem_length TSRMLS_CC)) {
|
1005 |
method = item;
|
@@ -1094,34 +1101,115 @@ PHP_FUNCTION(twig_template_get_attributes)
|
|
1094 |
efree(tmp_method_name_get);
|
1095 |
efree(tmp_method_name_is);
|
1096 |
efree(lcItem);
|
1097 |
-
}
|
1098 |
/*
|
1099 |
-
//
|
1100 |
-
// this is not supported but unfortunately heavily used in the Symfony profiler
|
1101 |
if ($object instanceof Twig_TemplateInterface) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1102 |
return $ret === '' ? '' : new Twig_Markup($ret, $this->env->getCharset());
|
1103 |
}
|
1104 |
|
1105 |
return $ret;
|
1106 |
*/
|
1107 |
-
|
1108 |
-
|
1109 |
-
|
1110 |
-
|
1111 |
-
|
1112 |
-
|
1113 |
-
|
1114 |
-
|
1115 |
-
|
1116 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1117 |
}
|
1118 |
-
return;
|
1119 |
}
|
1120 |
-
}
|
1121 |
|
1122 |
-
|
1123 |
-
|
1124 |
-
|
|
|
1125 |
}
|
|
|
|
|
1126 |
}
|
1127 |
}
|
31 |
#define Z_ADDREF_P(pz) (pz)->refcount++
|
32 |
#endif
|
33 |
|
34 |
+
#ifndef E_USER_DEPRECATED
|
35 |
+
#define E_USER_DEPRECATED (1<<14L)
|
36 |
+
#endif
|
37 |
+
|
38 |
#define FREE_DTOR(z) \
|
39 |
zval_dtor(z); \
|
40 |
efree(z);
|
991 |
char *lcItem = TWIG_STRTOLOWER(item, item_len);
|
992 |
int lcItem_length;
|
993 |
char *method = NULL;
|
994 |
+
char *methodForDeprecation = NULL;
|
995 |
char *tmp_method_name_get;
|
996 |
char *tmp_method_name_is;
|
997 |
zval *zmethod;
|
1005 |
sprintf(tmp_method_name_is, "is%s", lcItem);
|
1006 |
|
1007 |
tmp_methods = TWIG_GET_ARRAY_ELEMENT(tmp_class, "methods", strlen("methods") TSRMLS_CC);
|
1008 |
+
methodForDeprecation = emalloc(item_len + 1);
|
1009 |
+
sprintf(methodForDeprecation, "%s", item);
|
1010 |
|
1011 |
if (TWIG_GET_ARRAY_ELEMENT(tmp_methods, lcItem, lcItem_length TSRMLS_CC)) {
|
1012 |
method = item;
|
1101 |
efree(tmp_method_name_get);
|
1102 |
efree(tmp_method_name_is);
|
1103 |
efree(lcItem);
|
|
|
1104 |
/*
|
1105 |
+
// @deprecated in 1.28
|
|
|
1106 |
if ($object instanceof Twig_TemplateInterface) {
|
1107 |
+
$self = $object->getTemplateName() === $this->getTemplateName();
|
1108 |
+
$message = sprintf('Calling "%s" on template "%s" from template "%s" is deprecated since version 1.28 and won\'t be supported anymore in 2.0.', $item, $object->getTemplateName(), $this->getTemplateName());
|
1109 |
+
if ('renderBlock' === $method || 'displayBlock' === $method) {
|
1110 |
+
$message .= sprintf(' Use block("%s"%s) instead).', $arguments[0], $self ? '' : ', template');
|
1111 |
+
} elseif ('hasBlock' === $method) {
|
1112 |
+
$message .= sprintf(' Use "block("%s"%s) is defined" instead).', $arguments[0], $self ? '' : ', template');
|
1113 |
+
} elseif ('render' === $method || 'display' === $method) {
|
1114 |
+
$message .= sprintf(' Use include("%s") instead).', $object->getTemplateName());
|
1115 |
+
}
|
1116 |
+
@trigger_error($message, E_USER_DEPRECATED);
|
1117 |
+
|
1118 |
return $ret === '' ? '' : new Twig_Markup($ret, $this->env->getCharset());
|
1119 |
}
|
1120 |
|
1121 |
return $ret;
|
1122 |
*/
|
1123 |
+
efree(item);
|
1124 |
+
// ret can be null, if e.g. the called method throws an exception
|
1125 |
+
if (ret) {
|
1126 |
+
if (TWIG_INSTANCE_OF_USERLAND(object, "Twig_TemplateInterface" TSRMLS_CC)) {
|
1127 |
+
int self;
|
1128 |
+
int old_error_reporting;
|
1129 |
+
zval *object_filename;
|
1130 |
+
zval *this_filename;
|
1131 |
+
zval *filename_func;
|
1132 |
+
char *deprecation_message_complement = NULL;
|
1133 |
+
char *deprecation_message = NULL;
|
1134 |
+
|
1135 |
+
MAKE_STD_ZVAL(object_filename);
|
1136 |
+
MAKE_STD_ZVAL(this_filename);
|
1137 |
+
MAKE_STD_ZVAL(filename_func);
|
1138 |
+
|
1139 |
+
// Get templates names
|
1140 |
+
ZVAL_STRINGL(filename_func, "getTemplateName", sizeof("getTemplateName")-1, 1);
|
1141 |
+
call_user_function(EG(function_table), &object, filename_func, object_filename, 0, 0 TSRMLS_CC);
|
1142 |
+
ZVAL_STRINGL(filename_func, "getTemplateName", sizeof("getTemplateName")-1, 1);
|
1143 |
+
call_user_function(EG(function_table), &template, filename_func, this_filename, 0, 0 TSRMLS_CC);
|
1144 |
+
|
1145 |
+
self = (strcmp(Z_STRVAL_P(object_filename), Z_STRVAL_P(this_filename)) == 0);
|
1146 |
+
|
1147 |
+
if (strcmp(methodForDeprecation, "renderBlock") == 0 || strcmp(methodForDeprecation, "displayBlock") == 0) {
|
1148 |
+
zval **arg0;
|
1149 |
+
zend_hash_index_find(HASH_OF(arguments), 0, (void **) &arg0);
|
1150 |
+
asprintf(
|
1151 |
+
&deprecation_message_complement,
|
1152 |
+
" Use block(\"%s\"%s) instead).",
|
1153 |
+
Z_STRVAL_PP(arg0),
|
1154 |
+
self ? "" : ", template"
|
1155 |
+
);
|
1156 |
+
} else if (strcmp(methodForDeprecation, "hasBlock") == 0) {
|
1157 |
+
zval **arg0;
|
1158 |
+
zend_hash_index_find(HASH_OF(arguments), 0, (void **) &arg0);
|
1159 |
+
asprintf(
|
1160 |
+
&deprecation_message_complement,
|
1161 |
+
" Use \"block(\"%s\"%s) is defined\" instead).",
|
1162 |
+
Z_STRVAL_PP(arg0),
|
1163 |
+
self ? "" : ", template"
|
1164 |
+
);
|
1165 |
+
} else if (strcmp(methodForDeprecation, "render") == 0 || strcmp(methodForDeprecation, "display") == 0) {
|
1166 |
+
asprintf(
|
1167 |
+
&deprecation_message_complement,
|
1168 |
+
" Use include(\"%s\") instead).",
|
1169 |
+
Z_STRVAL_P(object_filename)
|
1170 |
+
);
|
1171 |
+
} else {
|
1172 |
+
deprecation_message_complement = (char*)calloc(0, sizeof(char));
|
1173 |
+
}
|
1174 |
+
|
1175 |
+
asprintf(
|
1176 |
+
&deprecation_message,
|
1177 |
+
"Calling \"%s\" on template \"%s\" from template \"%s\" is deprecated since version 1.28 and won't be supported anymore in 2.0.%s",
|
1178 |
+
methodForDeprecation,
|
1179 |
+
Z_STRVAL_P(object_filename),
|
1180 |
+
Z_STRVAL_P(this_filename),
|
1181 |
+
deprecation_message_complement
|
1182 |
+
);
|
1183 |
+
|
1184 |
+
old_error_reporting = EG(error_reporting);
|
1185 |
+
EG(error_reporting) = 0;
|
1186 |
+
zend_error(E_USER_DEPRECATED, "%s", deprecation_message);
|
1187 |
+
EG(error_reporting) = old_error_reporting;
|
1188 |
+
|
1189 |
+
FREE_DTOR(filename_func)
|
1190 |
+
FREE_DTOR(object_filename)
|
1191 |
+
FREE_DTOR(this_filename)
|
1192 |
+
free(deprecation_message);
|
1193 |
+
free(deprecation_message_complement);
|
1194 |
+
|
1195 |
+
if (Z_STRLEN_P(ret) != 0) {
|
1196 |
+
zval *charset = TWIG_CALL_USER_FUNC_ARRAY(TWIG_PROPERTY_CHAR(template, "env" TSRMLS_CC), "getCharset", NULL TSRMLS_CC);
|
1197 |
+
TWIG_NEW(return_value, "Twig_Markup", ret, charset TSRMLS_CC);
|
1198 |
+
zval_ptr_dtor(&charset);
|
1199 |
+
if (ret) {
|
1200 |
+
zval_ptr_dtor(&ret);
|
1201 |
+
}
|
1202 |
+
efree(methodForDeprecation);
|
1203 |
+
return;
|
1204 |
}
|
|
|
1205 |
}
|
|
|
1206 |
|
1207 |
+
RETVAL_ZVAL(ret, 1, 0);
|
1208 |
+
if (free_ret) {
|
1209 |
+
zval_ptr_dtor(&ret);
|
1210 |
+
}
|
1211 |
}
|
1212 |
+
|
1213 |
+
efree(methodForDeprecation);
|
1214 |
}
|
1215 |
}
|
vendor/twig/twig/lib/Twig/Autoloader.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
@@ -23,7 +23,7 @@ class Twig_Autoloader
|
|
23 |
/**
|
24 |
* Registers Twig_Autoloader as an SPL autoloader.
|
25 |
*
|
26 |
-
* @param bool $prepend
|
27 |
*/
|
28 |
public static function register($prepend = false)
|
29 |
{
|
@@ -39,7 +39,7 @@ class Twig_Autoloader
|
|
39 |
/**
|
40 |
* Handles autoloading of classes.
|
41 |
*
|
42 |
-
* @param string $class
|
43 |
*/
|
44 |
public static function autoload($class)
|
45 |
{
|
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.
|
23 |
/**
|
24 |
* Registers Twig_Autoloader as an SPL autoloader.
|
25 |
*
|
26 |
+
* @param bool $prepend whether to prepend the autoloader or not
|
27 |
*/
|
28 |
public static function register($prepend = false)
|
29 |
{
|
39 |
/**
|
40 |
* Handles autoloading of classes.
|
41 |
*
|
42 |
+
* @param string $class a class name
|
43 |
*/
|
44 |
public static function autoload($class)
|
45 |
{
|
vendor/twig/twig/lib/Twig/BaseNodeVisitor.php
CHANGED
@@ -16,9 +16,6 @@
|
|
16 |
*/
|
17 |
abstract class Twig_BaseNodeVisitor implements Twig_NodeVisitorInterface
|
18 |
{
|
19 |
-
/**
|
20 |
-
* {@inheritdoc}
|
21 |
-
*/
|
22 |
final public function enterNode(Twig_NodeInterface $node, Twig_Environment $env)
|
23 |
{
|
24 |
if (!$node instanceof Twig_Node) {
|
@@ -28,9 +25,6 @@ abstract class Twig_BaseNodeVisitor implements Twig_NodeVisitorInterface
|
|
28 |
return $this->doEnterNode($node, $env);
|
29 |
}
|
30 |
|
31 |
-
/**
|
32 |
-
* {@inheritdoc}
|
33 |
-
*/
|
34 |
final public function leaveNode(Twig_NodeInterface $node, Twig_Environment $env)
|
35 |
{
|
36 |
if (!$node instanceof Twig_Node) {
|
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) {
|
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) {
|
vendor/twig/twig/lib/Twig/Cache/Filesystem.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
@@ -31,9 +31,6 @@ class Twig_Cache_Filesystem implements Twig_CacheInterface
|
|
31 |
$this->options = $options;
|
32 |
}
|
33 |
|
34 |
-
/**
|
35 |
-
* {@inheritdoc}
|
36 |
-
*/
|
37 |
public function generateKey($name, $className)
|
38 |
{
|
39 |
$hash = hash('sha256', $className);
|
@@ -41,9 +38,6 @@ class Twig_Cache_Filesystem implements Twig_CacheInterface
|
|
41 |
return $this->directory.$hash[0].$hash[1].'/'.$hash.'.php';
|
42 |
}
|
43 |
|
44 |
-
/**
|
45 |
-
* {@inheritdoc}
|
46 |
-
*/
|
47 |
public function load($key)
|
48 |
{
|
49 |
if (file_exists($key)) {
|
@@ -51,9 +45,6 @@ class Twig_Cache_Filesystem implements Twig_CacheInterface
|
|
51 |
}
|
52 |
}
|
53 |
|
54 |
-
/**
|
55 |
-
* {@inheritdoc}
|
56 |
-
*/
|
57 |
public function write($key, $content)
|
58 |
{
|
59 |
$dir = dirname($key);
|
@@ -84,9 +75,6 @@ class Twig_Cache_Filesystem implements Twig_CacheInterface
|
|
84 |
throw new RuntimeException(sprintf('Failed to write cache file "%s".', $key));
|
85 |
}
|
86 |
|
87 |
-
/**
|
88 |
-
* {@inheritdoc}
|
89 |
-
*/
|
90 |
public function getTimestamp($key)
|
91 |
{
|
92 |
if (!file_exists($key)) {
|
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.
|
31 |
$this->options = $options;
|
32 |
}
|
33 |
|
|
|
|
|
|
|
34 |
public function generateKey($name, $className)
|
35 |
{
|
36 |
$hash = hash('sha256', $className);
|
38 |
return $this->directory.$hash[0].$hash[1].'/'.$hash.'.php';
|
39 |
}
|
40 |
|
|
|
|
|
|
|
41 |
public function load($key)
|
42 |
{
|
43 |
if (file_exists($key)) {
|
45 |
}
|
46 |
}
|
47 |
|
|
|
|
|
|
|
48 |
public function write($key, $content)
|
49 |
{
|
50 |
$dir = dirname($key);
|
75 |
throw new RuntimeException(sprintf('Failed to write cache file "%s".', $key));
|
76 |
}
|
77 |
|
|
|
|
|
|
|
78 |
public function getTimestamp($key)
|
79 |
{
|
80 |
if (!file_exists($key)) {
|
vendor/twig/twig/lib/Twig/Cache/Null.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
@@ -12,35 +12,25 @@
|
|
12 |
/**
|
13 |
* Implements a no-cache strategy.
|
14 |
*
|
|
|
|
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
class Twig_Cache_Null implements Twig_CacheInterface
|
18 |
{
|
19 |
-
/**
|
20 |
-
* {@inheritdoc}
|
21 |
-
*/
|
22 |
public function generateKey($name, $className)
|
23 |
{
|
24 |
return '';
|
25 |
}
|
26 |
|
27 |
-
/**
|
28 |
-
* {@inheritdoc}
|
29 |
-
*/
|
30 |
public function write($key, $content)
|
31 |
{
|
32 |
}
|
33 |
|
34 |
-
/**
|
35 |
-
* {@inheritdoc}
|
36 |
-
*/
|
37 |
public function load($key)
|
38 |
{
|
39 |
}
|
40 |
|
41 |
-
/**
|
42 |
-
* {@inheritdoc}
|
43 |
-
*/
|
44 |
public function getTimestamp($key)
|
45 |
{
|
46 |
return 0;
|
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.
|
12 |
/**
|
13 |
* Implements a no-cache strategy.
|
14 |
*
|
15 |
+
* @final
|
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 |
{
|
23 |
return '';
|
24 |
}
|
25 |
|
|
|
|
|
|
|
26 |
public function write($key, $content)
|
27 |
{
|
28 |
}
|
29 |
|
|
|
|
|
|
|
30 |
public function load($key)
|
31 |
{
|
32 |
}
|
33 |
|
|
|
|
|
|
|
34 |
public function getTimestamp($key)
|
35 |
{
|
36 |
return 0;
|
vendor/twig/twig/lib/Twig/CacheInterface.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
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.
|
vendor/twig/twig/lib/Twig/Compiler.php
CHANGED
@@ -3,8 +3,8 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
-
* (c)
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
@@ -216,6 +216,8 @@ class Twig_Compiler implements Twig_CompilerInterface
|
|
216 |
// mb_substr_count() replaces substr_count()
|
217 |
// but they have different signatures!
|
218 |
if (((int) ini_get('mbstring.func_overload')) & 2) {
|
|
|
|
|
219 |
// this is much slower than the "right" version
|
220 |
$this->sourceLine += mb_substr_count(mb_substr($this->source, $this->sourceOffset), "\n");
|
221 |
} else {
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
+
* (c) Fabien Potencier
|
7 |
+
* (c) Armin Ronacher
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
216 |
// mb_substr_count() replaces substr_count()
|
217 |
// but they have different signatures!
|
218 |
if (((int) ini_get('mbstring.func_overload')) & 2) {
|
219 |
+
@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);
|
220 |
+
|
221 |
// this is much slower than the "right" version
|
222 |
$this->sourceLine += mb_substr_count(mb_substr($this->source, $this->sourceOffset), "\n");
|
223 |
} else {
|
vendor/twig/twig/lib/Twig/CompilerInterface.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
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.
|
vendor/twig/twig/lib/Twig/Environment.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
@@ -16,11 +16,11 @@
|
|
16 |
*/
|
17 |
class Twig_Environment
|
18 |
{
|
19 |
-
const VERSION = '1.
|
20 |
-
const VERSION_ID =
|
21 |
const MAJOR_VERSION = 1;
|
22 |
-
const MINOR_VERSION =
|
23 |
-
const RELEASE_VERSION =
|
24 |
const EXTRA_VERSION = '';
|
25 |
|
26 |
protected $charset;
|
@@ -408,14 +408,18 @@ class Twig_Environment
|
|
408 |
*
|
409 |
* @return Twig_TemplateInterface A template instance representing the given template name
|
410 |
*
|
411 |
-
* @throws Twig_Error_Loader
|
412 |
-
* @throws
|
|
|
413 |
*
|
414 |
* @internal
|
415 |
*/
|
416 |
public function loadTemplate($name, $index = null)
|
417 |
{
|
418 |
-
$cls = $this->getTemplateClass($name
|
|
|
|
|
|
|
419 |
|
420 |
if (isset($this->loadedTemplates[$cls])) {
|
421 |
return $this->loadedTemplates[$cls];
|
@@ -425,7 +429,7 @@ class Twig_Environment
|
|
425 |
if ($this->bcGetCacheFilename) {
|
426 |
$key = $this->getCacheFilename($name);
|
427 |
} else {
|
428 |
-
$key = $this->cache->generateKey($name, $
|
429 |
}
|
430 |
|
431 |
if (!$this->isAutoReload() || $this->isTemplateFresh($name, $this->cache->getTimestamp($key))) {
|
@@ -449,7 +453,7 @@ class Twig_Environment
|
|
449 |
$this->cache->load($key);
|
450 |
}
|
451 |
|
452 |
-
if (!class_exists($
|
453 |
/* Last line of defense if either $this->bcWriteCacheFile was used,
|
454 |
* $this->cache is implemented as a no-op or we have a race condition
|
455 |
* where the cache was cleared between the above calls to write to and load from
|
@@ -458,6 +462,10 @@ class Twig_Environment
|
|
458 |
eval('?>'.$content);
|
459 |
}
|
460 |
}
|
|
|
|
|
|
|
|
|
461 |
}
|
462 |
|
463 |
if (!$this->runtimeInitialized) {
|
@@ -741,10 +749,10 @@ class Twig_Environment
|
|
741 |
try {
|
742 |
return $this->compile($this->parse($this->tokenize($source)));
|
743 |
} catch (Twig_Error $e) {
|
744 |
-
$e->
|
745 |
throw $e;
|
746 |
} catch (Exception $e) {
|
747 |
-
throw new Twig_Error_Syntax(sprintf('An exception has been thrown during the compilation of a template ("%s").', $e->getMessage()), -1, $source
|
748 |
}
|
749 |
}
|
750 |
|
@@ -831,7 +839,7 @@ class Twig_Environment
|
|
831 |
return true;
|
832 |
}
|
833 |
|
834 |
-
return isset($this->extensionsByClass[
|
835 |
}
|
836 |
|
837 |
/**
|
@@ -1439,7 +1447,6 @@ class Twig_Environment
|
|
1439 |
return;
|
1440 |
}
|
1441 |
|
1442 |
-
$this->extensionInitialized = true;
|
1443 |
$this->parsers = new Twig_TokenParserBroker(array(), array(), false);
|
1444 |
$this->filters = array();
|
1445 |
$this->functions = array();
|
@@ -1452,6 +1459,8 @@ class Twig_Environment
|
|
1452 |
$this->initExtension($extension);
|
1453 |
}
|
1454 |
$this->initExtension($this->staging);
|
|
|
|
|
1455 |
}
|
1456 |
|
1457 |
/**
|
@@ -1512,8 +1521,12 @@ class Twig_Environment
|
|
1512 |
|
1513 |
// operators
|
1514 |
if ($operators = $extension->getOperators()) {
|
|
|
|
|
|
|
|
|
1515 |
if (2 !== count($operators)) {
|
1516 |
-
throw new InvalidArgumentException(sprintf('"%s::getOperators()"
|
1517 |
}
|
1518 |
|
1519 |
$this->unaryOperators = array_merge($this->unaryOperators, $operators[0]);
|
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.
|
16 |
*/
|
17 |
class Twig_Environment
|
18 |
{
|
19 |
+
const VERSION = '1.31.0';
|
20 |
+
const VERSION_ID = 13100;
|
21 |
const MAJOR_VERSION = 1;
|
22 |
+
const MINOR_VERSION = 31;
|
23 |
+
const RELEASE_VERSION = 0;
|
24 |
const EXTRA_VERSION = '';
|
25 |
|
26 |
protected $charset;
|
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 |
*/
|
417 |
public function loadTemplate($name, $index = null)
|
418 |
{
|
419 |
+
$cls = $mainCls = $this->getTemplateClass($name);
|
420 |
+
if (null !== $index) {
|
421 |
+
$cls .= '_'.$index;
|
422 |
+
}
|
423 |
|
424 |
if (isset($this->loadedTemplates[$cls])) {
|
425 |
return $this->loadedTemplates[$cls];
|
429 |
if ($this->bcGetCacheFilename) {
|
430 |
$key = $this->getCacheFilename($name);
|
431 |
} else {
|
432 |
+
$key = $this->cache->generateKey($name, $mainCls);
|
433 |
}
|
434 |
|
435 |
if (!$this->isAutoReload() || $this->isTemplateFresh($name, $this->cache->getTimestamp($key))) {
|
453 |
$this->cache->load($key);
|
454 |
}
|
455 |
|
456 |
+
if (!class_exists($mainCls, false)) {
|
457 |
/* Last line of defense if either $this->bcWriteCacheFile was used,
|
458 |
* $this->cache is implemented as a no-op or we have a race condition
|
459 |
* where the cache was cleared between the above calls to write to and load from
|
462 |
eval('?>'.$content);
|
463 |
}
|
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 |
|
471 |
if (!$this->runtimeInitialized) {
|
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 |
|
839 |
return true;
|
840 |
}
|
841 |
|
842 |
+
return isset($this->extensionsByClass[$class]);
|
843 |
}
|
844 |
|
845 |
/**
|
1447 |
return;
|
1448 |
}
|
1449 |
|
|
|
1450 |
$this->parsers = new Twig_TokenParserBroker(array(), array(), false);
|
1451 |
$this->filters = array();
|
1452 |
$this->functions = array();
|
1459 |
$this->initExtension($extension);
|
1460 |
}
|
1461 |
$this->initExtension($this->staging);
|
1462 |
+
// Done at the end only, so that an exception during initialization does not mark the environment as initialized when catching the exception
|
1463 |
+
$this->extensionInitialized = true;
|
1464 |
}
|
1465 |
|
1466 |
/**
|
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]);
|
vendor/twig/twig/lib/Twig/Error.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
@@ -39,6 +39,9 @@ class Twig_Error extends Exception
|
|
39 |
protected $rawMessage;
|
40 |
protected $previous;
|
41 |
|
|
|
|
|
|
|
42 |
/**
|
43 |
* Constructor.
|
44 |
*
|
@@ -51,13 +54,23 @@ class Twig_Error extends Exception
|
|
51 |
*
|
52 |
* By default, automatic guessing is enabled.
|
53 |
*
|
54 |
-
* @param string
|
55 |
-
* @param int
|
56 |
-
* @param string
|
57 |
-
* @param Exception
|
58 |
*/
|
59 |
-
public function __construct($message, $lineno = -1, $
|
60 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
if (PHP_VERSION_ID < 50300) {
|
62 |
$this->previous = $previous;
|
63 |
parent::__construct('');
|
@@ -68,7 +81,7 @@ class Twig_Error extends Exception
|
|
68 |
$this->lineno = $lineno;
|
69 |
$this->filename = $name;
|
70 |
|
71 |
-
if (-1 === $lineno || null === $name) {
|
72 |
$this->guessTemplateInfo();
|
73 |
}
|
74 |
|
@@ -92,11 +105,11 @@ class Twig_Error extends Exception
|
|
92 |
*
|
93 |
* @return string The name
|
94 |
*
|
95 |
-
* @deprecated since 1.27 (to be removed in 2.0). Use
|
96 |
*/
|
97 |
public function getTemplateFile()
|
98 |
{
|
99 |
-
@trigger_error(sprintf('The "%s" method is deprecated since version 1.27 and will be removed in 2.0. Use
|
100 |
|
101 |
return $this->filename;
|
102 |
}
|
@@ -106,11 +119,11 @@ class Twig_Error extends Exception
|
|
106 |
*
|
107 |
* @param string $name The name
|
108 |
*
|
109 |
-
* @deprecated since 1.27 (to be removed in 2.0). Use
|
110 |
*/
|
111 |
public function setTemplateFile($name)
|
112 |
{
|
113 |
-
@trigger_error(sprintf('The "%s" method is deprecated since version 1.27 and will be removed in 2.0. Use
|
114 |
|
115 |
$this->filename = $name;
|
116 |
|
@@ -121,9 +134,13 @@ class Twig_Error extends Exception
|
|
121 |
* Gets the logical name where the error occurred.
|
122 |
*
|
123 |
* @return string The name
|
|
|
|
|
124 |
*/
|
125 |
public function getTemplateName()
|
126 |
{
|
|
|
|
|
127 |
return $this->filename;
|
128 |
}
|
129 |
|
@@ -131,10 +148,15 @@ class Twig_Error extends Exception
|
|
131 |
* Sets the logical name where the error occurred.
|
132 |
*
|
133 |
* @param string $name The name
|
|
|
|
|
134 |
*/
|
135 |
public function setTemplateName($name)
|
136 |
{
|
|
|
|
|
137 |
$this->filename = $name;
|
|
|
138 |
|
139 |
$this->updateRepr();
|
140 |
}
|
@@ -161,6 +183,32 @@ class Twig_Error extends Exception
|
|
161 |
$this->updateRepr();
|
162 |
}
|
163 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
164 |
public function guess()
|
165 |
{
|
166 |
$this->guessTemplateInfo();
|
@@ -199,6 +247,13 @@ class Twig_Error extends Exception
|
|
199 |
{
|
200 |
$this->message = $this->rawMessage;
|
201 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
202 |
$dot = false;
|
203 |
if ('.' === substr($this->message, -1)) {
|
204 |
$this->message = substr($this->message, 0, -1);
|
@@ -263,6 +318,13 @@ class Twig_Error extends Exception
|
|
263 |
$this->filename = $template->getTemplateName();
|
264 |
}
|
265 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
266 |
if (null === $template || $this->lineno > -1) {
|
267 |
return;
|
268 |
}
|
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.
|
39 |
protected $rawMessage;
|
40 |
protected $previous;
|
41 |
|
42 |
+
private $sourcePath;
|
43 |
+
private $sourceCode;
|
44 |
+
|
45 |
/**
|
46 |
* Constructor.
|
47 |
*
|
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 {
|
70 |
+
$name = $source->getName();
|
71 |
+
$this->sourceCode = $source->getCode();
|
72 |
+
$this->sourcePath = $source->getPath();
|
73 |
+
}
|
74 |
if (PHP_VERSION_ID < 50300) {
|
75 |
$this->previous = $previous;
|
76 |
parent::__construct('');
|
81 |
$this->lineno = $lineno;
|
82 |
$this->filename = $name;
|
83 |
|
84 |
+
if (-1 === $lineno || null === $name || null === $this->sourcePath) {
|
85 |
$this->guessTemplateInfo();
|
86 |
}
|
87 |
|
105 |
*
|
106 |
* @return string The name
|
107 |
*
|
108 |
+
* @deprecated since 1.27 (to be removed in 2.0). Use getSourceContext() instead.
|
109 |
*/
|
110 |
public function getTemplateFile()
|
111 |
{
|
112 |
+
@trigger_error(sprintf('The "%s" method is deprecated since version 1.27 and will be removed in 2.0. Use getSourceContext() instead.', __METHOD__), E_USER_DEPRECATED);
|
113 |
|
114 |
return $this->filename;
|
115 |
}
|
119 |
*
|
120 |
* @param string $name The name
|
121 |
*
|
122 |
+
* @deprecated since 1.27 (to be removed in 2.0). Use setSourceContext() instead.
|
123 |
*/
|
124 |
public function setTemplateFile($name)
|
125 |
{
|
126 |
+
@trigger_error(sprintf('The "%s" method is deprecated since version 1.27 and will be removed in 2.0. Use setSourceContext() instead.', __METHOD__), E_USER_DEPRECATED);
|
127 |
|
128 |
$this->filename = $name;
|
129 |
|
134 |
* Gets the logical name where the error occurred.
|
135 |
*
|
136 |
* @return string The name
|
137 |
+
*
|
138 |
+
* @deprecated since 1.29 (to be removed in 2.0). Use getSourceContext() instead.
|
139 |
*/
|
140 |
public function getTemplateName()
|
141 |
{
|
142 |
+
@trigger_error(sprintf('The "%s" method is deprecated since version 1.29 and will be removed in 2.0. Use getSourceContext() instead.', __METHOD__), E_USER_DEPRECATED);
|
143 |
+
|
144 |
return $this->filename;
|
145 |
}
|
146 |
|
148 |
* Sets the logical name where the error occurred.
|
149 |
*
|
150 |
* @param string $name The name
|
151 |
+
*
|
152 |
+
* @deprecated since 1.29 (to be removed in 2.0). Use setSourceContext() instead.
|
153 |
*/
|
154 |
public function setTemplateName($name)
|
155 |
{
|
156 |
+
@trigger_error(sprintf('The "%s" method is deprecated since version 1.29 and will be removed in 2.0. Use setSourceContext() instead.', __METHOD__), E_USER_DEPRECATED);
|
157 |
+
|
158 |
$this->filename = $name;
|
159 |
+
$this->sourceCode = $this->sourcePath = null;
|
160 |
|
161 |
$this->updateRepr();
|
162 |
}
|
183 |
$this->updateRepr();
|
184 |
}
|
185 |
|
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;
|
203 |
+
} else {
|
204 |
+
$this->sourceCode = $source->getCode();
|
205 |
+
$this->filename = $source->getName();
|
206 |
+
$this->sourcePath = $source->getPath();
|
207 |
+
}
|
208 |
+
|
209 |
+
$this->updateRepr();
|
210 |
+
}
|
211 |
+
|
212 |
public function guess()
|
213 |
{
|
214 |
$this->guessTemplateInfo();
|
247 |
{
|
248 |
$this->message = $this->rawMessage;
|
249 |
|
250 |
+
if ($this->sourcePath && $this->lineno > 0) {
|
251 |
+
$this->file = $this->sourcePath;
|
252 |
+
$this->line = $this->lineno;
|
253 |
+
|
254 |
+
return;
|
255 |
+
}
|
256 |
+
|
257 |
$dot = false;
|
258 |
if ('.' === substr($this->message, -1)) {
|
259 |
$this->message = substr($this->message, 0, -1);
|
318 |
$this->filename = $template->getTemplateName();
|
319 |
}
|
320 |
|
321 |
+
// update template path if any
|
322 |
+
if (null !== $template && null === $this->sourcePath) {
|
323 |
+
$src = $template->getSourceContext();
|
324 |
+
$this->sourceCode = $src->getCode();
|
325 |
+
$this->sourcePath = $src->getPath();
|
326 |
+
}
|
327 |
+
|
328 |
if (null === $template || $this->lineno > -1) {
|
329 |
return;
|
330 |
}
|
vendor/twig/twig/lib/Twig/Error/Loader.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
@@ -24,8 +24,15 @@
|
|
24 |
*/
|
25 |
class Twig_Error_Loader extends Twig_Error
|
26 |
{
|
27 |
-
public function __construct($message, $lineno = -1, $
|
28 |
{
|
29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
}
|
31 |
}
|
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.
|
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
@@ -3,8 +3,8 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
-
* (c)
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
+
* (c) Fabien Potencier
|
7 |
+
* (c) Armin Ronacher
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
vendor/twig/twig/lib/Twig/Error/Syntax.php
CHANGED
@@ -3,8 +3,8 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
-
* (c)
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
+
* (c) Fabien Potencier
|
7 |
+
* (c) Armin Ronacher
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
vendor/twig/twig/lib/Twig/ExistsLoaderInterface.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
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.
|
vendor/twig/twig/lib/Twig/ExpressionParser.php
CHANGED
@@ -3,8 +3,8 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
-
* (c)
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
@@ -33,7 +33,7 @@ class Twig_ExpressionParser
|
|
33 |
|
34 |
private $env;
|
35 |
|
36 |
-
public function __construct(Twig_Parser $parser,
|
37 |
{
|
38 |
$this->parser = $parser;
|
39 |
|
@@ -189,7 +189,7 @@ class Twig_ExpressionParser
|
|
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();
|
@@ -205,7 +205,7 @@ class Twig_ExpressionParser
|
|
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 |
|
@@ -296,7 +296,7 @@ class Twig_ExpressionParser
|
|
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 (:)');
|
@@ -335,25 +335,25 @@ class Twig_ExpressionParser
|
|
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);
|
@@ -402,18 +402,18 @@ class Twig_ExpressionParser
|
|
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);
|
@@ -523,7 +523,7 @@ class Twig_ExpressionParser
|
|
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,7 +531,7 @@ class Twig_ExpressionParser
|
|
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();
|
@@ -565,7 +565,7 @@ class Twig_ExpressionParser
|
|
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 |
|
@@ -629,7 +629,7 @@ class Twig_ExpressionParser
|
|
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;
|
@@ -646,7 +646,8 @@ class Twig_ExpressionParser
|
|
646 |
if ($test->getAlternative()) {
|
647 |
$message .= sprintf('. Use "%s" instead', $test->getAlternative());
|
648 |
}
|
649 |
-
$
|
|
|
650 |
|
651 |
@trigger_error($message, E_USER_DEPRECATED);
|
652 |
}
|
@@ -661,7 +662,7 @@ class Twig_ExpressionParser
|
|
661 |
protected function getFunctionNodeClass($name, $line)
|
662 |
{
|
663 |
if (false === $function = $this->env->getFunction($name)) {
|
664 |
-
$e = new Twig_Error_Syntax(sprintf('Unknown "%s" function.', $name), $line, $this->parser->getStream()->getSourceContext()
|
665 |
$e->addSuggestions($name, array_keys($this->env->getFunctions()));
|
666 |
|
667 |
throw $e;
|
@@ -675,7 +676,8 @@ class Twig_ExpressionParser
|
|
675 |
if ($function->getAlternative()) {
|
676 |
$message .= sprintf('. Use "%s" instead', $function->getAlternative());
|
677 |
}
|
678 |
-
$
|
|
|
679 |
|
680 |
@trigger_error($message, E_USER_DEPRECATED);
|
681 |
}
|
@@ -690,7 +692,7 @@ class Twig_ExpressionParser
|
|
690 |
protected function getFilterNodeClass($name, $line)
|
691 |
{
|
692 |
if (false === $filter = $this->env->getFilter($name)) {
|
693 |
-
$e = new Twig_Error_Syntax(sprintf('Unknown "%s" filter.', $name), $line, $this->parser->getStream()->getSourceContext()
|
694 |
$e->addSuggestions($name, array_keys($this->env->getFilters()));
|
695 |
|
696 |
throw $e;
|
@@ -704,7 +706,8 @@ class Twig_ExpressionParser
|
|
704 |
if ($filter->getAlternative()) {
|
705 |
$message .= sprintf('. Use "%s" instead', $filter->getAlternative());
|
706 |
}
|
707 |
-
$
|
|
|
708 |
|
709 |
@trigger_error($message, E_USER_DEPRECATED);
|
710 |
}
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
+
* (c) Fabien Potencier
|
7 |
+
* (c) Armin Ronacher
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
33 |
|
34 |
private $env;
|
35 |
|
36 |
+
public function __construct(Twig_Parser $parser, $env = null)
|
37 |
{
|
38 |
$this->parser = $parser;
|
39 |
|
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();
|
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 |
|
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 (:)');
|
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);
|
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);
|
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();
|
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 |
|
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;
|
646 |
if ($test->getAlternative()) {
|
647 |
$message .= sprintf('. Use "%s" instead', $test->getAlternative());
|
648 |
}
|
649 |
+
$src = $stream->getSourceContext();
|
650 |
+
$message .= sprintf(' in %s at line %d.', $src->getPath() ? $src->getPath() : $src->getName(), $stream->getCurrent()->getLine());
|
651 |
|
652 |
@trigger_error($message, E_USER_DEPRECATED);
|
653 |
}
|
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;
|
676 |
if ($function->getAlternative()) {
|
677 |
$message .= sprintf('. Use "%s" instead', $function->getAlternative());
|
678 |
}
|
679 |
+
$src = $this->parser->getStream()->getSourceContext();
|
680 |
+
$message .= sprintf(' in %s at line %d.', $src->getPath() ? $src->getPath() : $src->getName(), $line);
|
681 |
|
682 |
@trigger_error($message, E_USER_DEPRECATED);
|
683 |
}
|
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;
|
706 |
if ($filter->getAlternative()) {
|
707 |
$message .= sprintf('. Use "%s" instead', $filter->getAlternative());
|
708 |
}
|
709 |
+
$src = $this->parser->getStream()->getSourceContext();
|
710 |
+
$message .= sprintf(' in %s at line %d.', $src->getPath() ? $src->getPath() : $src->getName(), $line);
|
711 |
|
712 |
@trigger_error($message, E_USER_DEPRECATED);
|
713 |
}
|
vendor/twig/twig/lib/Twig/Extension.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
@@ -11,65 +11,43 @@
|
|
11 |
abstract class Twig_Extension implements Twig_ExtensionInterface
|
12 |
{
|
13 |
/**
|
14 |
-
* {@inheritdoc}
|
15 |
-
*
|
16 |
* @deprecated since 1.23 (to be removed in 2.0), implement Twig_Extension_InitRuntimeInterface instead
|
17 |
*/
|
18 |
public function initRuntime(Twig_Environment $environment)
|
19 |
{
|
20 |
}
|
21 |
|
22 |
-
/**
|
23 |
-
* {@inheritdoc}
|
24 |
-
*/
|
25 |
public function getTokenParsers()
|
26 |
{
|
27 |
return array();
|
28 |
}
|
29 |
|
30 |
-
/**
|
31 |
-
* {@inheritdoc}
|
32 |
-
*/
|
33 |
public function getNodeVisitors()
|
34 |
{
|
35 |
return array();
|
36 |
}
|
37 |
|
38 |
-
/**
|
39 |
-
* {@inheritdoc}
|
40 |
-
*/
|
41 |
public function getFilters()
|
42 |
{
|
43 |
return array();
|
44 |
}
|
45 |
|
46 |
-
/**
|
47 |
-
* {@inheritdoc}
|
48 |
-
*/
|
49 |
public function getTests()
|
50 |
{
|
51 |
return array();
|
52 |
}
|
53 |
|
54 |
-
/**
|
55 |
-
* {@inheritdoc}
|
56 |
-
*/
|
57 |
public function getFunctions()
|
58 |
{
|
59 |
return array();
|
60 |
}
|
61 |
|
62 |
-
/**
|
63 |
-
* {@inheritdoc}
|
64 |
-
*/
|
65 |
public function getOperators()
|
66 |
{
|
67 |
return array();
|
68 |
}
|
69 |
|
70 |
/**
|
71 |
-
* {@inheritdoc}
|
72 |
-
*
|
73 |
* @deprecated since 1.23 (to be removed in 2.0), implement Twig_Extension_GlobalsInterface instead
|
74 |
*/
|
75 |
public function getGlobals()
|
@@ -78,8 +56,6 @@ abstract class Twig_Extension implements Twig_ExtensionInterface
|
|
78 |
}
|
79 |
|
80 |
/**
|
81 |
-
* {@inheritdoc}
|
82 |
-
*
|
83 |
* @deprecated since 1.26 (to be removed in 2.0), not used anymore internally
|
84 |
*/
|
85 |
public function getName()
|
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.
|
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 |
/**
|
|
|
|
|
51 |
* @deprecated since 1.23 (to be removed in 2.0), implement Twig_Extension_GlobalsInterface instead
|
52 |
*/
|
53 |
public function getGlobals()
|
56 |
}
|
57 |
|
58 |
/**
|
|
|
|
|
59 |
* @deprecated since 1.26 (to be removed in 2.0), not used anymore internally
|
60 |
*/
|
61 |
public function getName()
|
vendor/twig/twig/lib/Twig/Extension/Core.php
CHANGED
@@ -8,11 +8,15 @@ if (!defined('ENT_SUBSTITUTE')) {
|
|
8 |
/*
|
9 |
* This file is part of Twig.
|
10 |
*
|
11 |
-
* (c)
|
12 |
*
|
13 |
* For the full copyright and license information, please view the LICENSE
|
14 |
* file that was distributed with this source code.
|
15 |
*/
|
|
|
|
|
|
|
|
|
16 |
class Twig_Extension_Core extends Twig_Extension
|
17 |
{
|
18 |
protected $dateFormats = array('F j, Y H:i', '%d days');
|
@@ -95,9 +99,9 @@ class Twig_Extension_Core extends Twig_Extension
|
|
95 |
/**
|
96 |
* Sets the default format to be used by the number_format filter.
|
97 |
*
|
98 |
-
* @param int $decimal
|
99 |
-
* @param string $decimalPoint
|
100 |
-
* @param string $thousandSep
|
101 |
*/
|
102 |
public function setNumberFormat($decimal, $decimalPoint, $thousandSep)
|
103 |
{
|
@@ -299,7 +303,7 @@ function twig_cycle($values, $position)
|
|
299 |
* @param Twig_Environment $env
|
300 |
* @param Traversable|array|int|float|string $values The values to pick a random item from
|
301 |
*
|
302 |
-
* @throws Twig_Error_Runtime
|
303 |
*
|
304 |
* @return mixed A random value from the given sequence
|
305 |
*/
|
@@ -514,9 +518,9 @@ function twig_round($value, $precision = 0, $method = 'common')
|
|
514 |
*
|
515 |
* @param Twig_Environment $env
|
516 |
* @param mixed $number A float/int/string of the number to format
|
517 |
-
* @param int $decimal
|
518 |
-
* @param string $decimalPoint
|
519 |
-
* @param string $thousandSep
|
520 |
*
|
521 |
* @return string The formatted number
|
522 |
*/
|
@@ -562,7 +566,7 @@ if (PHP_VERSION_ID < 50300) {
|
|
562 |
/**
|
563 |
* JSON encodes a variable.
|
564 |
*
|
565 |
-
* @param mixed $value
|
566 |
* @param int $options Not used on PHP 5.2.x
|
567 |
*
|
568 |
* @return mixed The JSON encoded value
|
@@ -581,7 +585,7 @@ if (PHP_VERSION_ID < 50300) {
|
|
581 |
/**
|
582 |
* JSON encodes a variable.
|
583 |
*
|
584 |
-
* @param mixed $value
|
585 |
* @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
|
586 |
*
|
587 |
* @return mixed The JSON encoded value
|
@@ -652,7 +656,7 @@ function twig_array_merge($arr1, $arr2)
|
|
652 |
function twig_slice(Twig_Environment $env, $item, $start, $length = null, $preserveKeys = false)
|
653 |
{
|
654 |
if ($item instanceof Traversable) {
|
655 |
-
|
656 |
$item = $item->getIterator();
|
657 |
}
|
658 |
|
@@ -821,7 +825,27 @@ function _twig_default_filter($value, $default = '')
|
|
821 |
function twig_get_array_keys_filter($array)
|
822 |
{
|
823 |
if ($array instanceof Traversable) {
|
824 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
825 |
}
|
826 |
|
827 |
if (!is_array($array)) {
|
@@ -901,7 +925,21 @@ function twig_in_filter($value, $compare)
|
|
901 |
} elseif (is_string($compare) && (is_string($value) || is_int($value) || is_float($value))) {
|
902 |
return '' === $value || false !== strpos($compare, (string) $value);
|
903 |
} elseif ($compare instanceof Traversable) {
|
904 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
905 |
}
|
906 |
|
907 |
return false;
|
@@ -1402,6 +1440,18 @@ function twig_include(Twig_Environment $env, $context, $template, $variables = a
|
|
1402 |
|
1403 |
throw $e;
|
1404 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1405 |
}
|
1406 |
|
1407 |
if ($isSandboxed && !$alreadySandboxed) {
|
8 |
/*
|
9 |
* This file is part of Twig.
|
10 |
*
|
11 |
+
* (c) Fabien Potencier
|
12 |
*
|
13 |
* For the full copyright and license information, please view the LICENSE
|
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');
|
99 |
/**
|
100 |
* Sets the default format to be used by the number_format filter.
|
101 |
*
|
102 |
+
* @param int $decimal the number of decimal places to use
|
103 |
+
* @param string $decimalPoint the character(s) to use for the decimal point
|
104 |
+
* @param string $thousandSep the character(s) to use for the thousands separator
|
105 |
*/
|
106 |
public function setNumberFormat($decimal, $decimalPoint, $thousandSep)
|
107 |
{
|
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 |
*/
|
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 |
*/
|
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
|
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
|
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 |
|
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();
|
837 |
+
$array->next();
|
838 |
+
}
|
839 |
+
|
840 |
+
return $keys;
|
841 |
+
}
|
842 |
+
|
843 |
+
$keys = array();
|
844 |
+
foreach ($array as $key => $item) {
|
845 |
+
$keys[] = $key;
|
846 |
+
}
|
847 |
+
|
848 |
+
return $keys;
|
849 |
}
|
850 |
|
851 |
if (!is_array($array)) {
|
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;
|
932 |
+
}
|
933 |
+
}
|
934 |
+
} else {
|
935 |
+
foreach ($compare as $item) {
|
936 |
+
if ($item == $value) {
|
937 |
+
return true;
|
938 |
+
}
|
939 |
+
}
|
940 |
+
}
|
941 |
+
|
942 |
+
return false;
|
943 |
}
|
944 |
|
945 |
return false;
|
1440 |
|
1441 |
throw $e;
|
1442 |
}
|
1443 |
+
} catch (Throwable $e) {
|
1444 |
+
if ($isSandboxed && !$alreadySandboxed) {
|
1445 |
+
$sandbox->disableSandbox();
|
1446 |
+
}
|
1447 |
+
|
1448 |
+
throw $e;
|
1449 |
+
} catch (Exception $e) {
|
1450 |
+
if ($isSandboxed && !$alreadySandboxed) {
|
1451 |
+
$sandbox->disableSandbox();
|
1452 |
+
}
|
1453 |
+
|
1454 |
+
throw $e;
|
1455 |
}
|
1456 |
|
1457 |
if ($isSandboxed && !$alreadySandboxed) {
|
vendor/twig/twig/lib/Twig/Extension/Debug.php
CHANGED
@@ -3,11 +3,15 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
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_Extension_Debug extends Twig_Extension
|
12 |
{
|
13 |
public function getFunctions()
|
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 |
+
/**
|
13 |
+
* @final
|
14 |
+
*/
|
15 |
class Twig_Extension_Debug extends Twig_Extension
|
16 |
{
|
17 |
public function getFunctions()
|
vendor/twig/twig/lib/Twig/Extension/Escaper.php
CHANGED
@@ -3,11 +3,15 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
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_Extension_Escaper extends Twig_Extension
|
12 |
{
|
13 |
protected $defaultStrategy;
|
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 |
+
/**
|
13 |
+
* @final
|
14 |
+
*/
|
15 |
class Twig_Extension_Escaper extends Twig_Extension
|
16 |
{
|
17 |
protected $defaultStrategy;
|
vendor/twig/twig/lib/Twig/Extension/Optimizer.php
CHANGED
@@ -3,11 +3,15 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
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_Extension_Optimizer extends Twig_Extension
|
12 |
{
|
13 |
protected $optimizers;
|
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 |
+
/**
|
13 |
+
* @final
|
14 |
+
*/
|
15 |
class Twig_Extension_Optimizer extends Twig_Extension
|
16 |
{
|
17 |
protected $optimizers;
|
vendor/twig/twig/lib/Twig/Extension/Profiler.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
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.
|
vendor/twig/twig/lib/Twig/Extension/Sandbox.php
CHANGED
@@ -3,11 +3,15 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
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_Extension_Sandbox extends Twig_Extension
|
12 |
{
|
13 |
protected $sandboxedGlobally;
|
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 |
+
/**
|
13 |
+
* @final
|
14 |
+
*/
|
15 |
class Twig_Extension_Sandbox extends Twig_Extension
|
16 |
{
|
17 |
protected $sandboxedGlobally;
|
vendor/twig/twig/lib/Twig/Extension/Staging.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
@@ -29,6 +29,10 @@ class Twig_Extension_Staging extends Twig_Extension
|
|
29 |
|
30 |
public function addFunction($name, $function)
|
31 |
{
|
|
|
|
|
|
|
|
|
32 |
$this->functions[$name] = $function;
|
33 |
}
|
34 |
|
@@ -39,6 +43,10 @@ class Twig_Extension_Staging extends Twig_Extension
|
|
39 |
|
40 |
public function addFilter($name, $filter)
|
41 |
{
|
|
|
|
|
|
|
|
|
42 |
$this->filters[$name] = $filter;
|
43 |
}
|
44 |
|
@@ -59,7 +67,11 @@ class Twig_Extension_Staging extends Twig_Extension
|
|
59 |
|
60 |
public function addTokenParser(Twig_TokenParserInterface $parser)
|
61 |
{
|
62 |
-
$this->tokenParsers[]
|
|
|
|
|
|
|
|
|
63 |
}
|
64 |
|
65 |
public function getTokenParsers()
|
@@ -79,6 +91,10 @@ class Twig_Extension_Staging extends Twig_Extension
|
|
79 |
|
80 |
public function addTest($name, $test)
|
81 |
{
|
|
|
|
|
|
|
|
|
82 |
$this->tests[$name] = $test;
|
83 |
}
|
84 |
|
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.
|
29 |
|
30 |
public function addFunction($name, $function)
|
31 |
{
|
32 |
+
if (isset($this->functions[$name])) {
|
33 |
+
@trigger_error(sprintf('Overriding function "%s" that is already registered is deprecated since version 1.30 and won\'t be possible anymore in 2.0.', $name), E_USER_DEPRECATED);
|
34 |
+
}
|
35 |
+
|
36 |
$this->functions[$name] = $function;
|
37 |
}
|
38 |
|
43 |
|
44 |
public function addFilter($name, $filter)
|
45 |
{
|
46 |
+
if (isset($this->filters[$name])) {
|
47 |
+
@trigger_error(sprintf('Overriding filter "%s" that is already registered is deprecated since version 1.30 and won\'t be possible anymore in 2.0.', $name), E_USER_DEPRECATED);
|
48 |
+
}
|
49 |
+
|
50 |
$this->filters[$name] = $filter;
|
51 |
}
|
52 |
|
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);
|
72 |
+
}
|
73 |
+
|
74 |
+
$this->tokenParsers[$parser->getTag()] = $parser;
|
75 |
}
|
76 |
|
77 |
public function getTokenParsers()
|
91 |
|
92 |
public function addTest($name, $test)
|
93 |
{
|
94 |
+
if (isset($this->tests[$name])) {
|
95 |
+
@trigger_error(sprintf('Overriding test "%s" that is already registered is deprecated since version 1.30 and won\'t be possible anymore in 2.0.', $name), E_USER_DEPRECATED);
|
96 |
+
}
|
97 |
+
|
98 |
$this->tests[$name] = $test;
|
99 |
}
|
100 |
|
vendor/twig/twig/lib/Twig/Extension/StringLoader.php
CHANGED
@@ -3,11 +3,15 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
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_Extension_StringLoader extends Twig_Extension
|
12 |
{
|
13 |
public function getFunctions()
|
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 |
+
/**
|
13 |
+
* @final
|
14 |
+
*/
|
15 |
class Twig_Extension_StringLoader extends Twig_Extension
|
16 |
{
|
17 |
public function getFunctions()
|
vendor/twig/twig/lib/Twig/ExtensionInterface.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
@@ -63,7 +63,7 @@ interface Twig_ExtensionInterface
|
|
63 |
/**
|
64 |
* Returns a list of operators to add to the existing list.
|
65 |
*
|
66 |
-
* @return array
|
67 |
*/
|
68 |
public function getOperators();
|
69 |
|
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.
|
63 |
/**
|
64 |
* Returns a list of operators to add to the existing list.
|
65 |
*
|
66 |
+
* @return array<array> First array of unary operators, second array of binary operators
|
67 |
*/
|
68 |
public function getOperators();
|
69 |
|
vendor/twig/twig/lib/Twig/FactoryRuntimeLoader.php
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
/**
|
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 |
+
}
|
28 |
+
|
29 |
+
public function load($class)
|
30 |
+
{
|
31 |
+
if (isset($this->map[$class])) {
|
32 |
+
$runtimeFactory = $this->map[$class];
|
33 |
+
|
34 |
+
return $runtimeFactory();
|
35 |
+
}
|
36 |
+
}
|
37 |
+
}
|
vendor/twig/twig/lib/Twig/FileExtensionEscapingStrategy.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
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.
|
vendor/twig/twig/lib/Twig/Filter.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
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.
|
vendor/twig/twig/lib/Twig/Filter/Function.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
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.
|
vendor/twig/twig/lib/Twig/Filter/Method.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
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.
|
vendor/twig/twig/lib/Twig/Filter/Node.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
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.
|
vendor/twig/twig/lib/Twig/FilterCallableInterface.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
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.
|
vendor/twig/twig/lib/Twig/FilterInterface.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
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.
|
vendor/twig/twig/lib/Twig/Function.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
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.
|
vendor/twig/twig/lib/Twig/Function/Function.php
CHANGED
@@ -3,8 +3,8 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
-
* (c)
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
+
* (c) Fabien Potencier
|
7 |
+
* (c) Arnaud Le Blanc
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
vendor/twig/twig/lib/Twig/Function/Method.php
CHANGED
@@ -3,8 +3,8 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
-
* (c)
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
+
* (c) Fabien Potencier
|
7 |
+
* (c) Arnaud Le Blanc
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
vendor/twig/twig/lib/Twig/Function/Node.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
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.
|
vendor/twig/twig/lib/Twig/FunctionCallableInterface.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
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.
|
vendor/twig/twig/lib/Twig/FunctionInterface.php
CHANGED
@@ -3,8 +3,8 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
-
* (c)
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
+
* (c) Fabien Potencier
|
7 |
+
* (c) Arnaud Le Blanc
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
vendor/twig/twig/lib/Twig/Lexer.php
CHANGED
@@ -3,8 +3,8 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
-
* (c)
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
@@ -34,6 +34,8 @@ class Twig_Lexer implements Twig_LexerInterface
|
|
34 |
protected $positions;
|
35 |
protected $currentVarBlockLine;
|
36 |
|
|
|
|
|
37 |
const STATE_DATA = 0;
|
38 |
const STATE_BLOCK = 1;
|
39 |
const STATE_VAR = 2;
|
@@ -73,16 +75,17 @@ class Twig_Lexer implements Twig_LexerInterface
|
|
73 |
);
|
74 |
}
|
75 |
|
76 |
-
/**
|
77 |
-
* {@inheritdoc}
|
78 |
-
*/
|
79 |
public function tokenize($code, $name = null)
|
80 |
{
|
81 |
if (!$code instanceof Twig_Source) {
|
82 |
@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);
|
83 |
-
$source = new Twig_Source($code, $name);
|
84 |
} else {
|
85 |
-
$source = $code;
|
|
|
|
|
|
|
|
|
86 |
}
|
87 |
|
88 |
if (function_exists('mb_internal_encoding') && ((int) ini_get('mbstring.func_overload')) & 2) {
|
@@ -92,8 +95,8 @@ class Twig_Lexer implements Twig_LexerInterface
|
|
92 |
$mbEncoding = null;
|
93 |
}
|
94 |
|
95 |
-
$this->code = str_replace(array("\r\n", "\r"), "\n", $source->getCode());
|
96 |
-
$this->filename = $source->getName();
|
97 |
$this->cursor = 0;
|
98 |
$this->lineno = 1;
|
99 |
$this->end = strlen($this->code);
|
@@ -137,14 +140,14 @@ class Twig_Lexer implements Twig_LexerInterface
|
|
137 |
|
138 |
if (!empty($this->brackets)) {
|
139 |
list($expect, $lineno) = array_pop($this->brackets);
|
140 |
-
throw new Twig_Error_Syntax(sprintf('Unclosed "%s".', $expect), $lineno, $this->
|
141 |
}
|
142 |
|
143 |
if ($mbEncoding) {
|
144 |
mb_internal_encoding($mbEncoding);
|
145 |
}
|
146 |
|
147 |
-
return new Twig_TokenStream($this->tokens, $source);
|
148 |
}
|
149 |
|
150 |
protected function lexData()
|
@@ -232,7 +235,7 @@ class Twig_Lexer implements Twig_LexerInterface
|
|
232 |
$this->moveCursor($match[0]);
|
233 |
|
234 |
if ($this->cursor >= $this->end) {
|
235 |
-
throw new Twig_Error_Syntax(sprintf('Unclosed "%s".', $this->state === self::STATE_BLOCK ? 'block' : 'variable'), $this->currentVarBlockLine, $this->
|
236 |
}
|
237 |
}
|
238 |
|
@@ -264,12 +267,12 @@ class Twig_Lexer implements Twig_LexerInterface
|
|
264 |
// closing bracket
|
265 |
elseif (false !== strpos(')]}', $this->code[$this->cursor])) {
|
266 |
if (empty($this->brackets)) {
|
267 |
-
throw new Twig_Error_Syntax(sprintf('Unexpected "%s".', $this->code[$this->cursor]), $this->lineno, $this->
|
268 |
}
|
269 |
|
270 |
list($expect, $lineno) = array_pop($this->brackets);
|
271 |
if ($this->code[$this->cursor] != strtr($expect, '([{', ')]}')) {
|
272 |
-
throw new Twig_Error_Syntax(sprintf('Unclosed "%s".', $expect), $lineno, $this->
|
273 |
}
|
274 |
}
|
275 |
|
@@ -289,7 +292,7 @@ class Twig_Lexer implements Twig_LexerInterface
|
|
289 |
}
|
290 |
// unlexable
|
291 |
else {
|
292 |
-
throw new Twig_Error_Syntax(sprintf('Unexpected character "%s".', $this->code[$this->cursor]), $this->lineno, $this->
|
293 |
}
|
294 |
}
|
295 |
|
@@ -300,7 +303,7 @@ class Twig_Lexer implements Twig_LexerInterface
|
|
300 |
}
|
301 |
|
302 |
if (!preg_match(str_replace('%s', $tag, $this->regexes['lex_raw_data']), $this->code, $match, PREG_OFFSET_CAPTURE, $this->cursor)) {
|
303 |
-
throw new Twig_Error_Syntax(sprintf('Unexpected end of file: Unclosed "%s" block.', $tag), $this->lineno, $this->
|
304 |
}
|
305 |
|
306 |
$text = substr($this->code, $this->cursor, $match[0][1] - $this->cursor);
|
@@ -316,7 +319,7 @@ class Twig_Lexer implements Twig_LexerInterface
|
|
316 |
protected function lexComment()
|
317 |
{
|
318 |
if (!preg_match($this->regexes['lex_comment'], $this->code, $match, PREG_OFFSET_CAPTURE, $this->cursor)) {
|
319 |
-
throw new Twig_Error_Syntax('Unclosed comment.', $this->lineno, $this->
|
320 |
}
|
321 |
|
322 |
$this->moveCursor(substr($this->code, $this->cursor, $match[0][1] - $this->cursor).$match[0][0]);
|
@@ -335,7 +338,7 @@ class Twig_Lexer implements Twig_LexerInterface
|
|
335 |
} elseif (preg_match(self::REGEX_DQ_STRING_DELIM, $this->code, $match, null, $this->cursor)) {
|
336 |
list($expect, $lineno) = array_pop($this->brackets);
|
337 |
if ($this->code[$this->cursor] != '"') {
|
338 |
-
throw new Twig_Error_Syntax(sprintf('Unclosed "%s".', $expect), $lineno, $this->
|
339 |
}
|
340 |
|
341 |
$this->popState();
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
+
* (c) Fabien Potencier
|
7 |
+
* (c) Armin Ronacher
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
34 |
protected $positions;
|
35 |
protected $currentVarBlockLine;
|
36 |
|
37 |
+
private $source;
|
38 |
+
|
39 |
const STATE_DATA = 0;
|
40 |
const STATE_BLOCK = 1;
|
41 |
const STATE_VAR = 2;
|
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 |
+
}
|
86 |
+
|
87 |
+
if (((int) ini_get('mbstring.func_overload')) & 2) {
|
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) {
|
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);
|
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()
|
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 |
|
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 |
|
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);
|
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]);
|
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();
|
vendor/twig/twig/lib/Twig/LexerInterface.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
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.
|
vendor/twig/twig/lib/Twig/Loader/Array.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
@@ -19,6 +19,8 @@
|
|
19 |
*
|
20 |
* This loader should only be used for unit testing.
|
21 |
*
|
|
|
|
|
22 |
* @author Fabien Potencier <fabien@symfony.com>
|
23 |
*/
|
24 |
class Twig_Loader_Array implements Twig_LoaderInterface, Twig_ExistsLoaderInterface, Twig_SourceContextLoaderInterface
|
@@ -44,9 +46,6 @@ class Twig_Loader_Array implements Twig_LoaderInterface, Twig_ExistsLoaderInterf
|
|
44 |
$this->templates[(string) $name] = $template;
|
45 |
}
|
46 |
|
47 |
-
/**
|
48 |
-
* {@inheritdoc}
|
49 |
-
*/
|
50 |
public function getSource($name)
|
51 |
{
|
52 |
@trigger_error(sprintf('Calling "getSource" on "%s" is deprecated since 1.27. Use getSourceContext() instead.', get_class($this)), E_USER_DEPRECATED);
|
@@ -59,9 +58,6 @@ class Twig_Loader_Array implements Twig_LoaderInterface, Twig_ExistsLoaderInterf
|
|
59 |
return $this->templates[$name];
|
60 |
}
|
61 |
|
62 |
-
/**
|
63 |
-
* {@inheritdoc}
|
64 |
-
*/
|
65 |
public function getSourceContext($name)
|
66 |
{
|
67 |
$name = (string) $name;
|
@@ -72,17 +68,11 @@ class Twig_Loader_Array implements Twig_LoaderInterface, Twig_ExistsLoaderInterf
|
|
72 |
return new Twig_Source($this->templates[$name], $name);
|
73 |
}
|
74 |
|
75 |
-
/**
|
76 |
-
* {@inheritdoc}
|
77 |
-
*/
|
78 |
public function exists($name)
|
79 |
{
|
80 |
return isset($this->templates[(string) $name]);
|
81 |
}
|
82 |
|
83 |
-
/**
|
84 |
-
* {@inheritdoc}
|
85 |
-
*/
|
86 |
public function getCacheKey($name)
|
87 |
{
|
88 |
$name = (string) $name;
|
@@ -93,9 +83,6 @@ class Twig_Loader_Array implements Twig_LoaderInterface, Twig_ExistsLoaderInterf
|
|
93 |
return $this->templates[$name];
|
94 |
}
|
95 |
|
96 |
-
/**
|
97 |
-
* {@inheritdoc}
|
98 |
-
*/
|
99 |
public function isFresh($name, $time)
|
100 |
{
|
101 |
$name = (string) $name;
|
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.
|
19 |
*
|
20 |
* This loader should only be used for unit testing.
|
21 |
*
|
22 |
+
* @final
|
23 |
+
*
|
24 |
* @author Fabien Potencier <fabien@symfony.com>
|
25 |
*/
|
26 |
class Twig_Loader_Array implements Twig_LoaderInterface, Twig_ExistsLoaderInterface, Twig_SourceContextLoaderInterface
|
46 |
$this->templates[(string) $name] = $template;
|
47 |
}
|
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);
|
58 |
return $this->templates[$name];
|
59 |
}
|
60 |
|
|
|
|
|
|
|
61 |
public function getSourceContext($name)
|
62 |
{
|
63 |
$name = (string) $name;
|
68 |
return new Twig_Source($this->templates[$name], $name);
|
69 |
}
|
70 |
|
|
|
|
|
|
|
71 |
public function exists($name)
|
72 |
{
|
73 |
return isset($this->templates[(string) $name]);
|
74 |
}
|
75 |
|
|
|
|
|
|
|
76 |
public function getCacheKey($name)
|
77 |
{
|
78 |
$name = (string) $name;
|
83 |
return $this->templates[$name];
|
84 |
}
|
85 |
|
|
|
|
|
|
|
86 |
public function isFresh($name, $time)
|
87 |
{
|
88 |
$name = (string) $name;
|
vendor/twig/twig/lib/Twig/Loader/Chain.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
@@ -12,6 +12,8 @@
|
|
12 |
/**
|
13 |
* Loads templates from other loaders.
|
14 |
*
|
|
|
|
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
class Twig_Loader_Chain implements Twig_LoaderInterface, Twig_ExistsLoaderInterface, Twig_SourceContextLoaderInterface
|
@@ -35,9 +37,6 @@ class Twig_Loader_Chain implements Twig_LoaderInterface, Twig_ExistsLoaderInterf
|
|
35 |
$this->hasSourceCache = array();
|
36 |
}
|
37 |
|
38 |
-
/**
|
39 |
-
* {@inheritdoc}
|
40 |
-
*/
|
41 |
public function getSource($name)
|
42 |
{
|
43 |
@trigger_error(sprintf('Calling "getSource" on "%s" is deprecated since 1.27. Use getSourceContext() instead.', get_class($this)), E_USER_DEPRECATED);
|
@@ -58,9 +57,6 @@ class Twig_Loader_Chain implements Twig_LoaderInterface, Twig_ExistsLoaderInterf
|
|
58 |
throw new Twig_Error_Loader(sprintf('Template "%s" is not defined%s.', $name, $exceptions ? ' ('.implode(', ', $exceptions).')' : ''));
|
59 |
}
|
60 |
|
61 |
-
/**
|
62 |
-
* {@inheritdoc}
|
63 |
-
*/
|
64 |
public function getSourceContext($name)
|
65 |
{
|
66 |
$exceptions = array();
|
@@ -83,9 +79,6 @@ class Twig_Loader_Chain implements Twig_LoaderInterface, Twig_ExistsLoaderInterf
|
|
83 |
throw new Twig_Error_Loader(sprintf('Template "%s" is not defined%s.', $name, $exceptions ? ' ('.implode(', ', $exceptions).')' : ''));
|
84 |
}
|
85 |
|
86 |
-
/**
|
87 |
-
* {@inheritdoc}
|
88 |
-
*/
|
89 |
public function exists($name)
|
90 |
{
|
91 |
$name = (string) $name;
|
@@ -118,9 +111,6 @@ class Twig_Loader_Chain implements Twig_LoaderInterface, Twig_ExistsLoaderInterf
|
|
118 |
return $this->hasSourceCache[$name] = false;
|
119 |
}
|
120 |
|
121 |
-
/**
|
122 |
-
* {@inheritdoc}
|
123 |
-
*/
|
124 |
public function getCacheKey($name)
|
125 |
{
|
126 |
$exceptions = array();
|
@@ -139,9 +129,6 @@ class Twig_Loader_Chain implements Twig_LoaderInterface, Twig_ExistsLoaderInterf
|
|
139 |
throw new Twig_Error_Loader(sprintf('Template "%s" is not defined%s.', $name, $exceptions ? ' ('.implode(', ', $exceptions).')' : ''));
|
140 |
}
|
141 |
|
142 |
-
/**
|
143 |
-
* {@inheritdoc}
|
144 |
-
*/
|
145 |
public function isFresh($name, $time)
|
146 |
{
|
147 |
$exceptions = array();
|
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.
|
12 |
/**
|
13 |
* Loads templates from other loaders.
|
14 |
*
|
15 |
+
* @final
|
16 |
+
*
|
17 |
* @author Fabien Potencier <fabien@symfony.com>
|
18 |
*/
|
19 |
class Twig_Loader_Chain implements Twig_LoaderInterface, Twig_ExistsLoaderInterface, Twig_SourceContextLoaderInterface
|
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);
|
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();
|
79 |
throw new Twig_Error_Loader(sprintf('Template "%s" is not defined%s.', $name, $exceptions ? ' ('.implode(', ', $exceptions).')' : ''));
|
80 |
}
|
81 |
|
|
|
|
|
|
|
82 |
public function exists($name)
|
83 |
{
|
84 |
$name = (string) $name;
|
111 |
return $this->hasSourceCache[$name] = false;
|
112 |
}
|
113 |
|
|
|
|
|
|
|
114 |
public function getCacheKey($name)
|
115 |
{
|
116 |
$exceptions = array();
|
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();
|
vendor/twig/twig/lib/Twig/Loader/Filesystem.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
@@ -131,9 +131,6 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface, Twig_ExistsLoaderI
|
|
131 |
}
|
132 |
}
|
133 |
|
134 |
-
/**
|
135 |
-
* {@inheritdoc}
|
136 |
-
*/
|
137 |
public function getSource($name)
|
138 |
{
|
139 |
@trigger_error(sprintf('Calling "getSource" on "%s" is deprecated since 1.27. Use getSourceContext() instead.', get_class($this)), E_USER_DEPRECATED);
|
@@ -141,9 +138,6 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface, Twig_ExistsLoaderI
|
|
141 |
return file_get_contents($this->findTemplate($name));
|
142 |
}
|
143 |
|
144 |
-
/**
|
145 |
-
* {@inheritdoc}
|
146 |
-
*/
|
147 |
public function getSourceContext($name)
|
148 |
{
|
149 |
$path = $this->findTemplate($name);
|
@@ -151,9 +145,6 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface, Twig_ExistsLoaderI
|
|
151 |
return new Twig_Source(file_get_contents($path), $name, $path);
|
152 |
}
|
153 |
|
154 |
-
/**
|
155 |
-
* {@inheritdoc}
|
156 |
-
*/
|
157 |
public function getCacheKey($name)
|
158 |
{
|
159 |
$path = $this->findTemplate($name);
|
@@ -165,9 +156,6 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface, Twig_ExistsLoaderI
|
|
165 |
return $path;
|
166 |
}
|
167 |
|
168 |
-
/**
|
169 |
-
* {@inheritdoc}
|
170 |
-
*/
|
171 |
public function exists($name)
|
172 |
{
|
173 |
$name = $this->normalizeName($name);
|
@@ -185,9 +173,6 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface, Twig_ExistsLoaderI
|
|
185 |
}
|
186 |
}
|
187 |
|
188 |
-
/**
|
189 |
-
* {@inheritdoc}
|
190 |
-
*/
|
191 |
public function isFresh($name, $time)
|
192 |
{
|
193 |
return filemtime($this->findTemplate($name)) <= $time;
|
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.
|
131 |
}
|
132 |
}
|
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);
|
138 |
return file_get_contents($this->findTemplate($name));
|
139 |
}
|
140 |
|
|
|
|
|
|
|
141 |
public function getSourceContext($name)
|
142 |
{
|
143 |
$path = $this->findTemplate($name);
|
145 |
return new Twig_Source(file_get_contents($path), $name, $path);
|
146 |
}
|
147 |
|
|
|
|
|
|
|
148 |
public function getCacheKey($name)
|
149 |
{
|
150 |
$path = $this->findTemplate($name);
|
156 |
return $path;
|
157 |
}
|
158 |
|
|
|
|
|
|
|
159 |
public function exists($name)
|
160 |
{
|
161 |
$name = $this->normalizeName($name);
|
173 |
}
|
174 |
}
|
175 |
|
|
|
|
|
|
|
176 |
public function isFresh($name, $time)
|
177 |
{
|
178 |
return filemtime($this->findTemplate($name)) <= $time;
|
vendor/twig/twig/lib/Twig/Loader/String.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
@@ -29,9 +29,6 @@
|
|
29 |
*/
|
30 |
class Twig_Loader_String implements Twig_LoaderInterface, Twig_ExistsLoaderInterface, Twig_SourceContextLoaderInterface
|
31 |
{
|
32 |
-
/**
|
33 |
-
* {@inheritdoc}
|
34 |
-
*/
|
35 |
public function getSource($name)
|
36 |
{
|
37 |
@trigger_error(sprintf('Calling "getSource" on "%s" is deprecated since 1.27. Use getSourceContext() instead.', get_class($this)), E_USER_DEPRECATED);
|
@@ -39,33 +36,21 @@ class Twig_Loader_String implements Twig_LoaderInterface, Twig_ExistsLoaderInter
|
|
39 |
return $name;
|
40 |
}
|
41 |
|
42 |
-
/**
|
43 |
-
* {@inheritdoc}
|
44 |
-
*/
|
45 |
public function getSourceContext($name)
|
46 |
{
|
47 |
return new Twig_Source($name, $name);
|
48 |
}
|
49 |
|
50 |
-
/**
|
51 |
-
* {@inheritdoc}
|
52 |
-
*/
|
53 |
public function exists($name)
|
54 |
{
|
55 |
return true;
|
56 |
}
|
57 |
|
58 |
-
/**
|
59 |
-
* {@inheritdoc}
|
60 |
-
*/
|
61 |
public function getCacheKey($name)
|
62 |
{
|
63 |
return $name;
|
64 |
}
|
65 |
|
66 |
-
/**
|
67 |
-
* {@inheritdoc}
|
68 |
-
*/
|
69 |
public function isFresh($name, $time)
|
70 |
{
|
71 |
return true;
|
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.
|
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);
|
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)
|
45 |
{
|
46 |
return true;
|
47 |
}
|
48 |
|
|
|
|
|
|
|
49 |
public function getCacheKey($name)
|
50 |
{
|
51 |
return $name;
|
52 |
}
|
53 |
|
|
|
|
|
|
|
54 |
public function isFresh($name, $time)
|
55 |
{
|
56 |
return true;
|
vendor/twig/twig/lib/Twig/LoaderInterface.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
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.
|
vendor/twig/twig/lib/Twig/Markup.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
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.
|
vendor/twig/twig/lib/Twig/Node.php
CHANGED
@@ -3,8 +3,8 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
-
* (c)
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
+
* (c) Fabien Potencier
|
7 |
+
* (c) Armin Ronacher
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
vendor/twig/twig/lib/Twig/Node/AutoEscape.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
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.
|
vendor/twig/twig/lib/Twig/Node/Block.php
CHANGED
@@ -3,8 +3,8 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
-
* (c)
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
+
* (c) Fabien Potencier
|
7 |
+
* (c) Armin Ronacher
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
vendor/twig/twig/lib/Twig/Node/BlockReference.php
CHANGED
@@ -3,8 +3,8 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
-
* (c)
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
+
* (c) Fabien Potencier
|
7 |
+
* (c) Armin Ronacher
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
vendor/twig/twig/lib/Twig/Node/Body.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
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.
|
vendor/twig/twig/lib/Twig/Node/CheckSecurity.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
@@ -56,7 +56,7 @@ class Twig_Node_CheckSecurity extends Twig_Node
|
|
56 |
->outdent()
|
57 |
->write("} catch (Twig_Sandbox_SecurityError \$e) {\n")
|
58 |
->indent()
|
59 |
-
->write("\$e->
|
60 |
->write("if (\$e instanceof Twig_Sandbox_SecurityNotAllowedTagError && isset(\$tags[\$e->getTagName()])) {\n")
|
61 |
->indent()
|
62 |
->write("\$e->setTemplateLine(\$tags[\$e->getTagName()]);\n")
|
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.
|
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")
|
vendor/twig/twig/lib/Twig/Node/Do.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
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.
|
vendor/twig/twig/lib/Twig/Node/Embed.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
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.
|
vendor/twig/twig/lib/Twig/Node/Expression.php
CHANGED
@@ -3,8 +3,8 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
-
* (c)
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
+
* (c) Fabien Potencier
|
7 |
+
* (c) Armin Ronacher
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
vendor/twig/twig/lib/Twig/Node/Expression/Array.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
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.
|
vendor/twig/twig/lib/Twig/Node/Expression/AssignName.php
CHANGED
@@ -3,8 +3,8 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
-
* (c)
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
+
* (c) Fabien Potencier
|
7 |
+
* (c) Armin Ronacher
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
vendor/twig/twig/lib/Twig/Node/Expression/Binary.php
CHANGED
@@ -3,8 +3,8 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
-
* (c)
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
+
* (c) Fabien Potencier
|
7 |
+
* (c) Armin Ronacher
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
vendor/twig/twig/lib/Twig/Node/Expression/Binary/Add.php
CHANGED
@@ -3,8 +3,8 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
-
* (c)
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
+
* (c) Fabien Potencier
|
7 |
+
* (c) Armin Ronacher
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
vendor/twig/twig/lib/Twig/Node/Expression/Binary/And.php
CHANGED
@@ -3,8 +3,8 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
-
* (c)
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
+
* (c) Fabien Potencier
|
7 |
+
* (c) Armin Ronacher
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
vendor/twig/twig/lib/Twig/Node/Expression/Binary/BitwiseAnd.php
CHANGED
@@ -3,8 +3,8 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
-
* (c)
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
+
* (c) Fabien Potencier
|
7 |
+
* (c) Armin Ronacher
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
vendor/twig/twig/lib/Twig/Node/Expression/Binary/BitwiseOr.php
CHANGED
@@ -3,8 +3,8 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
-
* (c)
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
+
* (c) Fabien Potencier
|
7 |
+
* (c) Armin Ronacher
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
vendor/twig/twig/lib/Twig/Node/Expression/Binary/BitwiseXor.php
CHANGED
@@ -3,8 +3,8 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
-
* (c)
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
+
* (c) Fabien Potencier
|
7 |
+
* (c) Armin Ronacher
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
vendor/twig/twig/lib/Twig/Node/Expression/Binary/Concat.php
CHANGED
@@ -3,8 +3,8 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
-
* (c)
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
+
* (c) Fabien Potencier
|
7 |
+
* (c) Armin Ronacher
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
vendor/twig/twig/lib/Twig/Node/Expression/Binary/Div.php
CHANGED
@@ -3,8 +3,8 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
-
* (c)
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
+
* (c) Fabien Potencier
|
7 |
+
* (c) Armin Ronacher
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
vendor/twig/twig/lib/Twig/Node/Expression/Binary/EndsWith.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
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.
|
vendor/twig/twig/lib/Twig/Node/Expression/Binary/Equal.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
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.
|
vendor/twig/twig/lib/Twig/Node/Expression/Binary/FloorDiv.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
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.
|
vendor/twig/twig/lib/Twig/Node/Expression/Binary/Greater.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
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.
|
vendor/twig/twig/lib/Twig/Node/Expression/Binary/GreaterEqual.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
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.
|
vendor/twig/twig/lib/Twig/Node/Expression/Binary/In.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
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.
|
vendor/twig/twig/lib/Twig/Node/Expression/Binary/Less.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
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.
|
vendor/twig/twig/lib/Twig/Node/Expression/Binary/LessEqual.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
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.
|
vendor/twig/twig/lib/Twig/Node/Expression/Binary/Matches.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
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.
|
vendor/twig/twig/lib/Twig/Node/Expression/Binary/Mod.php
CHANGED
@@ -3,8 +3,8 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
-
* (c)
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
+
* (c) Fabien Potencier
|
7 |
+
* (c) Armin Ronacher
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
vendor/twig/twig/lib/Twig/Node/Expression/Binary/Mul.php
CHANGED
@@ -3,8 +3,8 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
-
* (c)
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
+
* (c) Fabien Potencier
|
7 |
+
* (c) Armin Ronacher
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
vendor/twig/twig/lib/Twig/Node/Expression/Binary/NotEqual.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
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.
|
vendor/twig/twig/lib/Twig/Node/Expression/Binary/NotIn.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
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.
|
vendor/twig/twig/lib/Twig/Node/Expression/Binary/Or.php
CHANGED
@@ -3,8 +3,8 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
-
* (c)
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
+
* (c) Fabien Potencier
|
7 |
+
* (c) Armin Ronacher
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
vendor/twig/twig/lib/Twig/Node/Expression/Binary/Power.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
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.
|
vendor/twig/twig/lib/Twig/Node/Expression/Binary/Range.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
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.
|
vendor/twig/twig/lib/Twig/Node/Expression/Binary/StartsWith.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
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.
|
vendor/twig/twig/lib/Twig/Node/Expression/Binary/Sub.php
CHANGED
@@ -3,8 +3,8 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
-
* (c)
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
+
* (c) Fabien Potencier
|
7 |
+
* (c) Armin Ronacher
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
vendor/twig/twig/lib/Twig/Node/Expression/BlockReference.php
CHANGED
@@ -3,8 +3,8 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
-
* (c)
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
+
* (c) Fabien Potencier
|
7 |
+
* (c) Armin Ronacher
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
vendor/twig/twig/lib/Twig/Node/Expression/Call.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
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.
|
vendor/twig/twig/lib/Twig/Node/Expression/Conditional.php
CHANGED
@@ -3,8 +3,8 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
-
* (c)
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
+
* (c) Fabien Potencier
|
7 |
+
* (c) Armin Ronacher
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
vendor/twig/twig/lib/Twig/Node/Expression/Constant.php
CHANGED
@@ -3,8 +3,8 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
-
* (c)
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
+
* (c) Fabien Potencier
|
7 |
+
* (c) Armin Ronacher
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
vendor/twig/twig/lib/Twig/Node/Expression/ExtensionReference.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
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.
|
vendor/twig/twig/lib/Twig/Node/Expression/Filter.php
CHANGED
@@ -3,8 +3,8 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
-
* (c)
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
+
* (c) Fabien Potencier
|
7 |
+
* (c) Armin Ronacher
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
vendor/twig/twig/lib/Twig/Node/Expression/Filter/Default.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
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.
|
vendor/twig/twig/lib/Twig/Node/Expression/Function.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
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.
|
vendor/twig/twig/lib/Twig/Node/Expression/GetAttr.php
CHANGED
@@ -3,8 +3,8 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
-
* (c)
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
@@ -23,6 +23,10 @@ class Twig_Node_Expression_GetAttr extends Twig_Node_Expression
|
|
23 |
|
24 |
public function compile(Twig_Compiler $compiler)
|
25 |
{
|
|
|
|
|
|
|
|
|
26 |
if (function_exists('twig_template_get_attributes') && !$this->getAttribute('disable_c_ext')) {
|
27 |
$compiler->raw('twig_template_get_attributes($this, ');
|
28 |
} else {
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
+
* (c) Fabien Potencier
|
7 |
+
* (c) Armin Ronacher
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
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 {
|
vendor/twig/twig/lib/Twig/Node/Expression/MethodCall.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
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.
|
vendor/twig/twig/lib/Twig/Node/Expression/Name.php
CHANGED
@@ -3,8 +3,8 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
-
* (c)
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
+
* (c) Fabien Potencier
|
7 |
+
* (c) Armin Ronacher
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
vendor/twig/twig/lib/Twig/Node/Expression/Parent.php
CHANGED
@@ -3,8 +3,8 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
-
* (c)
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
+
* (c) Fabien Potencier
|
7 |
+
* (c) Armin Ronacher
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
vendor/twig/twig/lib/Twig/Node/Expression/TempName.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
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.
|
vendor/twig/twig/lib/Twig/Node/Expression/Test.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
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.
|
vendor/twig/twig/lib/Twig/Node/Expression/Test/Constant.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
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.
|
vendor/twig/twig/lib/Twig/Node/Expression/Test/Defined.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
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.
|
vendor/twig/twig/lib/Twig/Node/Expression/Test/Divisibleby.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
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.
|
vendor/twig/twig/lib/Twig/Node/Expression/Test/Even.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
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.
|
vendor/twig/twig/lib/Twig/Node/Expression/Test/Null.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
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.
|
vendor/twig/twig/lib/Twig/Node/Expression/Test/Odd.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
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.
|
vendor/twig/twig/lib/Twig/Node/Expression/Test/Sameas.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
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.
|
vendor/twig/twig/lib/Twig/Node/Expression/Unary.php
CHANGED
@@ -3,8 +3,8 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
-
* (c)
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
+
* (c) Fabien Potencier
|
7 |
+
* (c) Armin Ronacher
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
vendor/twig/twig/lib/Twig/Node/Expression/Unary/Neg.php
CHANGED
@@ -3,8 +3,8 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
-
* (c)
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
+
* (c) Fabien Potencier
|
7 |
+
* (c) Armin Ronacher
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
vendor/twig/twig/lib/Twig/Node/Expression/Unary/Not.php
CHANGED
@@ -3,8 +3,8 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
-
* (c)
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
+
* (c) Fabien Potencier
|
7 |
+
* (c) Armin Ronacher
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
vendor/twig/twig/lib/Twig/Node/Expression/Unary/Pos.php
CHANGED
@@ -3,8 +3,8 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
-
* (c)
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
+
* (c) Fabien Potencier
|
7 |
+
* (c) Armin Ronacher
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
vendor/twig/twig/lib/Twig/Node/Flush.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
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.
|
vendor/twig/twig/lib/Twig/Node/For.php
CHANGED
@@ -3,8 +3,8 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
-
* (c)
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
+
* (c) Fabien Potencier
|
7 |
+
* (c) Armin Ronacher
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
vendor/twig/twig/lib/Twig/Node/ForLoop.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
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.
|
vendor/twig/twig/lib/Twig/Node/If.php
CHANGED
@@ -3,8 +3,8 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
-
* (c)
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
+
* (c) Fabien Potencier
|
7 |
+
* (c) Armin Ronacher
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
vendor/twig/twig/lib/Twig/Node/Import.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
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.
|
vendor/twig/twig/lib/Twig/Node/Include.php
CHANGED
@@ -3,8 +3,8 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
-
* (c)
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
+
* (c) Fabien Potencier
|
7 |
+
* (c) Armin Ronacher
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
vendor/twig/twig/lib/Twig/Node/Macro.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
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.
|
vendor/twig/twig/lib/Twig/Node/Module.php
CHANGED
@@ -3,8 +3,8 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
-
* (c)
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
+
* (c) Fabien Potencier
|
7 |
+
* (c) Armin Ronacher
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
vendor/twig/twig/lib/Twig/Node/Print.php
CHANGED
@@ -3,8 +3,8 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
-
* (c)
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
+
* (c) Fabien Potencier
|
7 |
+
* (c) Armin Ronacher
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
vendor/twig/twig/lib/Twig/Node/Sandbox.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
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.
|
vendor/twig/twig/lib/Twig/Node/SandboxedPrint.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
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.
|
vendor/twig/twig/lib/Twig/Node/Set.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
@@ -14,7 +14,7 @@
|
|
14 |
*
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
-
class Twig_Node_Set extends Twig_Node
|
18 |
{
|
19 |
public function __construct($capture, Twig_NodeInterface $names, Twig_NodeInterface $values, $lineno, $tag = null)
|
20 |
{
|
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.
|
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 |
{
|
vendor/twig/twig/lib/Twig/Node/SetTemp.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
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.
|
vendor/twig/twig/lib/Twig/Node/Spaceless.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
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.
|
vendor/twig/twig/lib/Twig/Node/Text.php
CHANGED
@@ -3,8 +3,8 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
-
* (c)
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
+
* (c) Fabien Potencier
|
7 |
+
* (c) Armin Ronacher
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
vendor/twig/twig/lib/Twig/Node/With.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
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.
|
vendor/twig/twig/lib/Twig/NodeCaptureInterface.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
/**
|
13 |
+
* Represents a node that captures any nested displayable nodes.
|
14 |
+
*
|
15 |
+
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
+
*/
|
17 |
+
interface Twig_NodeCaptureInterface
|
18 |
+
{
|
19 |
+
}
|
vendor/twig/twig/lib/Twig/NodeInterface.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
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.
|
vendor/twig/twig/lib/Twig/NodeOutputInterface.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
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.
|
vendor/twig/twig/lib/Twig/NodeTraverser.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
@@ -14,6 +14,8 @@
|
|
14 |
*
|
15 |
* It visits all nodes and their children and calls the given visitor for each.
|
16 |
*
|
|
|
|
|
17 |
* @author Fabien Potencier <fabien@symfony.com>
|
18 |
*/
|
19 |
class Twig_NodeTraverser
|
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.
|
14 |
*
|
15 |
* It visits all nodes and their children and calls the given visitor for each.
|
16 |
*
|
17 |
+
* @final
|
18 |
+
*
|
19 |
* @author Fabien Potencier <fabien@symfony.com>
|
20 |
*/
|
21 |
class Twig_NodeTraverser
|
vendor/twig/twig/lib/Twig/NodeVisitor/Escaper.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
@@ -12,6 +12,8 @@
|
|
12 |
/**
|
13 |
* Twig_NodeVisitor_Escaper implements output escaping.
|
14 |
*
|
|
|
|
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
class Twig_NodeVisitor_Escaper extends Twig_BaseNodeVisitor
|
@@ -28,9 +30,6 @@ class Twig_NodeVisitor_Escaper extends Twig_BaseNodeVisitor
|
|
28 |
$this->safeAnalysis = new Twig_NodeVisitor_SafeAnalysis();
|
29 |
}
|
30 |
|
31 |
-
/**
|
32 |
-
* {@inheritdoc}
|
33 |
-
*/
|
34 |
protected function doEnterNode(Twig_Node $node, Twig_Environment $env)
|
35 |
{
|
36 |
if ($node instanceof Twig_Node_Module) {
|
@@ -50,9 +49,6 @@ class Twig_NodeVisitor_Escaper extends Twig_BaseNodeVisitor
|
|
50 |
return $node;
|
51 |
}
|
52 |
|
53 |
-
/**
|
54 |
-
* {@inheritdoc}
|
55 |
-
*/
|
56 |
protected function doLeaveNode(Twig_Node $node, Twig_Environment $env)
|
57 |
{
|
58 |
if ($node instanceof Twig_Node_Module) {
|
@@ -149,9 +145,6 @@ class Twig_NodeVisitor_Escaper extends Twig_BaseNodeVisitor
|
|
149 |
return new Twig_Node_Expression_Filter($node, $name, $args, $line);
|
150 |
}
|
151 |
|
152 |
-
/**
|
153 |
-
* {@inheritdoc}
|
154 |
-
*/
|
155 |
public function getPriority()
|
156 |
{
|
157 |
return 0;
|
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.
|
12 |
/**
|
13 |
* Twig_NodeVisitor_Escaper implements output escaping.
|
14 |
*
|
15 |
+
* @final
|
16 |
+
*
|
17 |
* @author Fabien Potencier <fabien@symfony.com>
|
18 |
*/
|
19 |
class Twig_NodeVisitor_Escaper extends Twig_BaseNodeVisitor
|
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) {
|
49 |
return $node;
|
50 |
}
|
51 |
|
|
|
|
|
|
|
52 |
protected function doLeaveNode(Twig_Node $node, Twig_Environment $env)
|
53 |
{
|
54 |
if ($node instanceof Twig_Node_Module) {
|
145 |
return new Twig_Node_Expression_Filter($node, $name, $args, $line);
|
146 |
}
|
147 |
|
|
|
|
|
|
|
148 |
public function getPriority()
|
149 |
{
|
150 |
return 0;
|
vendor/twig/twig/lib/Twig/NodeVisitor/Optimizer.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
@@ -17,6 +17,8 @@
|
|
17 |
* You can configure which optimizations you want to activate via the
|
18 |
* optimizer mode.
|
19 |
*
|
|
|
|
|
20 |
* @author Fabien Potencier <fabien@symfony.com>
|
21 |
*/
|
22 |
class Twig_NodeVisitor_Optimizer extends Twig_BaseNodeVisitor
|
@@ -45,9 +47,6 @@ class Twig_NodeVisitor_Optimizer extends Twig_BaseNodeVisitor
|
|
45 |
$this->optimizers = $optimizers;
|
46 |
}
|
47 |
|
48 |
-
/**
|
49 |
-
* {@inheritdoc}
|
50 |
-
*/
|
51 |
protected function doEnterNode(Twig_Node $node, Twig_Environment $env)
|
52 |
{
|
53 |
if (self::OPTIMIZE_FOR === (self::OPTIMIZE_FOR & $this->optimizers)) {
|
@@ -71,9 +70,6 @@ class Twig_NodeVisitor_Optimizer extends Twig_BaseNodeVisitor
|
|
71 |
return $node;
|
72 |
}
|
73 |
|
74 |
-
/**
|
75 |
-
* {@inheritdoc}
|
76 |
-
*/
|
77 |
protected function doLeaveNode(Twig_Node $node, Twig_Environment $env)
|
78 |
{
|
79 |
$expression = $node instanceof Twig_Node_Expression;
|
@@ -248,9 +244,6 @@ class Twig_NodeVisitor_Optimizer extends Twig_BaseNodeVisitor
|
|
248 |
}
|
249 |
}
|
250 |
|
251 |
-
/**
|
252 |
-
* {@inheritdoc}
|
253 |
-
*/
|
254 |
public function getPriority()
|
255 |
{
|
256 |
return 255;
|
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.
|
17 |
* You can configure which optimizations you want to activate via the
|
18 |
* optimizer mode.
|
19 |
*
|
20 |
+
* @final
|
21 |
+
*
|
22 |
* @author Fabien Potencier <fabien@symfony.com>
|
23 |
*/
|
24 |
class Twig_NodeVisitor_Optimizer extends Twig_BaseNodeVisitor
|
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)) {
|
70 |
return $node;
|
71 |
}
|
72 |
|
|
|
|
|
|
|
73 |
protected function doLeaveNode(Twig_Node $node, Twig_Environment $env)
|
74 |
{
|
75 |
$expression = $node instanceof Twig_Node_Expression;
|
244 |
}
|
245 |
}
|
246 |
|
|
|
|
|
|
|
247 |
public function getPriority()
|
248 |
{
|
249 |
return 255;
|
vendor/twig/twig/lib/Twig/NodeVisitor/SafeAnalysis.php
CHANGED
@@ -9,6 +9,9 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
|
|
|
|
|
|
12 |
class Twig_NodeVisitor_SafeAnalysis extends Twig_BaseNodeVisitor
|
13 |
{
|
14 |
protected $data = array();
|
@@ -57,17 +60,11 @@ class Twig_NodeVisitor_SafeAnalysis extends Twig_BaseNodeVisitor
|
|
57 |
);
|
58 |
}
|
59 |
|
60 |
-
/**
|
61 |
-
* {@inheritdoc}
|
62 |
-
*/
|
63 |
protected function doEnterNode(Twig_Node $node, Twig_Environment $env)
|
64 |
{
|
65 |
return $node;
|
66 |
}
|
67 |
|
68 |
-
/**
|
69 |
-
* {@inheritdoc}
|
70 |
-
*/
|
71 |
protected function doLeaveNode(Twig_Node $node, Twig_Environment $env)
|
72 |
{
|
73 |
if ($node instanceof Twig_Node_Expression_Constant) {
|
@@ -144,9 +141,6 @@ class Twig_NodeVisitor_SafeAnalysis extends Twig_BaseNodeVisitor
|
|
144 |
return array_intersect($a, $b);
|
145 |
}
|
146 |
|
147 |
-
/**
|
148 |
-
* {@inheritdoc}
|
149 |
-
*/
|
150 |
public function getPriority()
|
151 |
{
|
152 |
return 0;
|
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();
|
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) {
|
141 |
return array_intersect($a, $b);
|
142 |
}
|
143 |
|
|
|
|
|
|
|
144 |
public function getPriority()
|
145 |
{
|
146 |
return 0;
|
vendor/twig/twig/lib/Twig/NodeVisitor/Sandbox.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
@@ -12,6 +12,8 @@
|
|
12 |
/**
|
13 |
* Twig_NodeVisitor_Sandbox implements sandboxing.
|
14 |
*
|
|
|
|
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
class Twig_NodeVisitor_Sandbox extends Twig_BaseNodeVisitor
|
@@ -21,9 +23,6 @@ class Twig_NodeVisitor_Sandbox extends Twig_BaseNodeVisitor
|
|
21 |
protected $filters;
|
22 |
protected $functions;
|
23 |
|
24 |
-
/**
|
25 |
-
* {@inheritdoc}
|
26 |
-
*/
|
27 |
protected function doEnterNode(Twig_Node $node, Twig_Environment $env)
|
28 |
{
|
29 |
if ($node instanceof Twig_Node_Module) {
|
@@ -58,9 +57,6 @@ class Twig_NodeVisitor_Sandbox extends Twig_BaseNodeVisitor
|
|
58 |
return $node;
|
59 |
}
|
60 |
|
61 |
-
/**
|
62 |
-
* {@inheritdoc}
|
63 |
-
*/
|
64 |
protected function doLeaveNode(Twig_Node $node, Twig_Environment $env)
|
65 |
{
|
66 |
if ($node instanceof Twig_Node_Module) {
|
@@ -72,9 +68,6 @@ class Twig_NodeVisitor_Sandbox extends Twig_BaseNodeVisitor
|
|
72 |
return $node;
|
73 |
}
|
74 |
|
75 |
-
/**
|
76 |
-
* {@inheritdoc}
|
77 |
-
*/
|
78 |
public function getPriority()
|
79 |
{
|
80 |
return 0;
|
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.
|
12 |
/**
|
13 |
* Twig_NodeVisitor_Sandbox implements sandboxing.
|
14 |
*
|
15 |
+
* @final
|
16 |
+
*
|
17 |
* @author Fabien Potencier <fabien@symfony.com>
|
18 |
*/
|
19 |
class Twig_NodeVisitor_Sandbox extends Twig_BaseNodeVisitor
|
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) {
|
57 |
return $node;
|
58 |
}
|
59 |
|
|
|
|
|
|
|
60 |
protected function doLeaveNode(Twig_Node $node, Twig_Environment $env)
|
61 |
{
|
62 |
if ($node instanceof Twig_Node_Module) {
|
68 |
return $node;
|
69 |
}
|
70 |
|
|
|
|
|
|
|
71 |
public function getPriority()
|
72 |
{
|
73 |
return 0;
|
vendor/twig/twig/lib/Twig/NodeVisitorInterface.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
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.
|
vendor/twig/twig/lib/Twig/Parser.php
CHANGED
@@ -3,8 +3,8 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
-
* (c)
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
@@ -62,9 +62,6 @@ class Twig_Parser implements Twig_ParserInterface
|
|
62 |
return $this->stream->getSourceContext()->getName();
|
63 |
}
|
64 |
|
65 |
-
/**
|
66 |
-
* {@inheritdoc}
|
67 |
-
*/
|
68 |
public function parse(Twig_TokenStream $stream, $test = null, $dropNeedle = false)
|
69 |
{
|
70 |
// push all variables into the stack to keep the current state of the parser
|
@@ -109,8 +106,8 @@ class Twig_Parser implements Twig_ParserInterface
|
|
109 |
$body = new Twig_Node();
|
110 |
}
|
111 |
} catch (Twig_Error_Syntax $e) {
|
112 |
-
if (!$e->
|
113 |
-
$e->
|
114 |
}
|
115 |
|
116 |
if (!$e->getTemplateLine()) {
|
@@ -157,7 +154,7 @@ class Twig_Parser implements Twig_ParserInterface
|
|
157 |
$token = $this->getCurrentToken();
|
158 |
|
159 |
if ($token->getType() !== Twig_Token::NAME_TYPE) {
|
160 |
-
throw new Twig_Error_Syntax('A block must start with a tag name.', $token->getLine(), $this->stream->getSourceContext()
|
161 |
}
|
162 |
|
163 |
if (null !== $test && call_user_func($test, $token)) {
|
@@ -175,13 +172,13 @@ class Twig_Parser implements Twig_ParserInterface
|
|
175 |
$subparser = $this->handlers->getTokenParser($token->getValue());
|
176 |
if (null === $subparser) {
|
177 |
if (null !== $test) {
|
178 |
-
$e = new Twig_Error_Syntax(sprintf('Unexpected "%s" tag', $token->getValue()), $token->getLine(), $this->stream->getSourceContext()
|
179 |
|
180 |
if (is_array($test) && isset($test[0]) && $test[0] instanceof Twig_TokenParserInterface) {
|
181 |
$e->appendMessage(sprintf(' (expecting closing tag for the "%s" tag defined near line %s).', $test[0]->getTag(), $lineno));
|
182 |
}
|
183 |
} else {
|
184 |
-
$e = new Twig_Error_Syntax(sprintf('Unknown "%s" tag.', $token->getValue()), $token->getLine(), $this->stream->getSourceContext()
|
185 |
$e->addSuggestions($token->getValue(), array_keys($this->env->getTags()));
|
186 |
}
|
187 |
|
@@ -197,7 +194,7 @@ class Twig_Parser implements Twig_ParserInterface
|
|
197 |
break;
|
198 |
|
199 |
default:
|
200 |
-
throw new Twig_Error_Syntax('Lexer or parser ended up in unsupported state.',
|
201 |
}
|
202 |
}
|
203 |
|
@@ -271,7 +268,7 @@ class Twig_Parser implements Twig_ParserInterface
|
|
271 |
public function setMacro($name, Twig_Node_Macro $node)
|
272 |
{
|
273 |
if ($this->isReservedMacroName($name)) {
|
274 |
-
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()
|
275 |
}
|
276 |
|
277 |
$this->macros[$name] = $node;
|
@@ -383,14 +380,14 @@ class Twig_Parser implements Twig_ParserInterface
|
|
383 |
(!$node instanceof Twig_Node_Text && !$node instanceof Twig_Node_BlockReference && $node instanceof Twig_NodeOutputInterface)
|
384 |
) {
|
385 |
if (false !== strpos((string) $node, chr(0xEF).chr(0xBB).chr(0xBF))) {
|
386 |
-
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()
|
387 |
}
|
388 |
|
389 |
-
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()
|
390 |
}
|
391 |
|
392 |
-
// bypass
|
393 |
-
if ($node instanceof
|
394 |
return $node;
|
395 |
}
|
396 |
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
+
* (c) Fabien Potencier
|
7 |
+
* (c) Armin Ronacher
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
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
|
106 |
$body = new Twig_Node();
|
107 |
}
|
108 |
} catch (Twig_Error_Syntax $e) {
|
109 |
+
if (!$e->getSourceContext()) {
|
110 |
+
$e->setSourceContext($this->stream->getSourceContext());
|
111 |
}
|
112 |
|
113 |
if (!$e->getTemplateLine()) {
|
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)) {
|
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 |
|
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;
|
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 |
|
vendor/twig/twig/lib/Twig/ParserInterface.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
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.
|
vendor/twig/twig/lib/Twig/Profiler/Dumper/Blackfire.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
@@ -11,6 +11,8 @@
|
|
11 |
|
12 |
/**
|
13 |
* @author Fabien Potencier <fabien@symfony.com>
|
|
|
|
|
14 |
*/
|
15 |
class Twig_Profiler_Dumper_Blackfire
|
16 |
{
|
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.
|
11 |
|
12 |
/**
|
13 |
* @author Fabien Potencier <fabien@symfony.com>
|
14 |
+
*
|
15 |
+
* @final
|
16 |
*/
|
17 |
class Twig_Profiler_Dumper_Blackfire
|
18 |
{
|
vendor/twig/twig/lib/Twig/Profiler/Dumper/Html.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
@@ -11,6 +11,8 @@
|
|
11 |
|
12 |
/**
|
13 |
* @author Fabien Potencier <fabien@symfony.com>
|
|
|
|
|
14 |
*/
|
15 |
class Twig_Profiler_Dumper_Html extends Twig_Profiler_Dumper_Text
|
16 |
{
|
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.
|
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 |
{
|
vendor/twig/twig/lib/Twig/Profiler/Dumper/Text.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
@@ -11,6 +11,8 @@
|
|
11 |
|
12 |
/**
|
13 |
* @author Fabien Potencier <fabien@symfony.com>
|
|
|
|
|
14 |
*/
|
15 |
class Twig_Profiler_Dumper_Text
|
16 |
{
|
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.
|
11 |
|
12 |
/**
|
13 |
* @author Fabien Potencier <fabien@symfony.com>
|
14 |
+
*
|
15 |
+
* @final
|
16 |
*/
|
17 |
class Twig_Profiler_Dumper_Text
|
18 |
{
|
vendor/twig/twig/lib/Twig/Profiler/Node/EnterProfile.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
@@ -21,9 +21,6 @@ class Twig_Profiler_Node_EnterProfile extends Twig_Node
|
|
21 |
parent::__construct(array(), array('extension_name' => $extensionName, 'name' => $name, 'type' => $type, 'var_name' => $varName));
|
22 |
}
|
23 |
|
24 |
-
/**
|
25 |
-
* {@inheritdoc}
|
26 |
-
*/
|
27 |
public function compile(Twig_Compiler $compiler)
|
28 |
{
|
29 |
$compiler
|
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.
|
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
|
vendor/twig/twig/lib/Twig/Profiler/Node/LeaveProfile.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
@@ -21,9 +21,6 @@ class Twig_Profiler_Node_LeaveProfile extends Twig_Node
|
|
21 |
parent::__construct(array(), array('var_name' => $varName));
|
22 |
}
|
23 |
|
24 |
-
/**
|
25 |
-
* {@inheritdoc}
|
26 |
-
*/
|
27 |
public function compile(Twig_Compiler $compiler)
|
28 |
{
|
29 |
$compiler
|
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.
|
21 |
parent::__construct(array(), array('var_name' => $varName));
|
22 |
}
|
23 |
|
|
|
|
|
|
|
24 |
public function compile(Twig_Compiler $compiler)
|
25 |
{
|
26 |
$compiler
|
vendor/twig/twig/lib/Twig/Profiler/NodeVisitor/Profiler.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
@@ -11,6 +11,8 @@
|
|
11 |
|
12 |
/**
|
13 |
* @author Fabien Potencier <fabien@symfony.com>
|
|
|
|
|
14 |
*/
|
15 |
class Twig_Profiler_NodeVisitor_Profiler extends Twig_BaseNodeVisitor
|
16 |
{
|
@@ -21,17 +23,11 @@ class Twig_Profiler_NodeVisitor_Profiler extends Twig_BaseNodeVisitor
|
|
21 |
$this->extensionName = $extensionName;
|
22 |
}
|
23 |
|
24 |
-
/**
|
25 |
-
* {@inheritdoc}
|
26 |
-
*/
|
27 |
protected function doEnterNode(Twig_Node $node, Twig_Environment $env)
|
28 |
{
|
29 |
return $node;
|
30 |
}
|
31 |
|
32 |
-
/**
|
33 |
-
* {@inheritdoc}
|
34 |
-
*/
|
35 |
protected function doLeaveNode(Twig_Node $node, Twig_Environment $env)
|
36 |
{
|
37 |
if ($node instanceof Twig_Node_Module) {
|
@@ -62,9 +58,6 @@ class Twig_Profiler_NodeVisitor_Profiler extends Twig_BaseNodeVisitor
|
|
62 |
return sprintf('__internal_%s', hash('sha256', uniqid(mt_rand(), true), false));
|
63 |
}
|
64 |
|
65 |
-
/**
|
66 |
-
* {@inheritdoc}
|
67 |
-
*/
|
68 |
public function getPriority()
|
69 |
{
|
70 |
return 0;
|
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.
|
11 |
|
12 |
/**
|
13 |
* @author Fabien Potencier <fabien@symfony.com>
|
14 |
+
*
|
15 |
+
* @final
|
16 |
*/
|
17 |
class Twig_Profiler_NodeVisitor_Profiler extends Twig_BaseNodeVisitor
|
18 |
{
|
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) {
|
58 |
return sprintf('__internal_%s', hash('sha256', uniqid(mt_rand(), true), false));
|
59 |
}
|
60 |
|
|
|
|
|
|
|
61 |
public function getPriority()
|
62 |
{
|
63 |
return 0;
|
vendor/twig/twig/lib/Twig/Profiler/Profile.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
@@ -11,6 +11,8 @@
|
|
11 |
|
12 |
/**
|
13 |
* @author Fabien Potencier <fabien@symfony.com>
|
|
|
|
|
14 |
*/
|
15 |
class Twig_Profiler_Profile implements IteratorAggregate, Serializable
|
16 |
{
|
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.
|
11 |
|
12 |
/**
|
13 |
* @author Fabien Potencier <fabien@symfony.com>
|
14 |
+
*
|
15 |
+
* @final
|
16 |
*/
|
17 |
class Twig_Profiler_Profile implements IteratorAggregate, Serializable
|
18 |
{
|
vendor/twig/twig/lib/Twig/Sandbox/SecurityError.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
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.
|
vendor/twig/twig/lib/Twig/Sandbox/SecurityNotAllowedFilterError.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
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.
|
vendor/twig/twig/lib/Twig/Sandbox/SecurityNotAllowedFunctionError.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
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.
|
vendor/twig/twig/lib/Twig/Sandbox/SecurityNotAllowedMethodError.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
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.
|
vendor/twig/twig/lib/Twig/Sandbox/SecurityNotAllowedPropertyError.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
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.
|
vendor/twig/twig/lib/Twig/Sandbox/SecurityNotAllowedTagError.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
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.
|
vendor/twig/twig/lib/Twig/Sandbox/SecurityPolicy.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
@@ -12,6 +12,8 @@
|
|
12 |
/**
|
13 |
* Represents a security policy which need to be enforced when sandbox mode is enabled.
|
14 |
*
|
|
|
|
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
class Twig_Sandbox_SecurityPolicy implements Twig_Sandbox_SecurityPolicyInterface
|
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.
|
12 |
/**
|
13 |
* Represents a security policy which need to be enforced when sandbox mode is enabled.
|
14 |
*
|
15 |
+
* @final
|
16 |
+
*
|
17 |
* @author Fabien Potencier <fabien@symfony.com>
|
18 |
*/
|
19 |
class Twig_Sandbox_SecurityPolicy implements Twig_Sandbox_SecurityPolicyInterface
|
vendor/twig/twig/lib/Twig/Sandbox/SecurityPolicyInterface.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
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.
|
vendor/twig/twig/lib/Twig/SimpleFilter.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
@@ -12,6 +12,8 @@
|
|
12 |
/**
|
13 |
* Represents a template filter.
|
14 |
*
|
|
|
|
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
class Twig_SimpleFilter
|
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.
|
12 |
/**
|
13 |
* Represents a template filter.
|
14 |
*
|
15 |
+
* @final
|
16 |
+
*
|
17 |
* @author Fabien Potencier <fabien@symfony.com>
|
18 |
*/
|
19 |
class Twig_SimpleFilter
|
vendor/twig/twig/lib/Twig/SimpleFunction.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
@@ -12,6 +12,8 @@
|
|
12 |
/**
|
13 |
* Represents a template function.
|
14 |
*
|
|
|
|
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
class Twig_SimpleFunction
|
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.
|
12 |
/**
|
13 |
* Represents a template function.
|
14 |
*
|
15 |
+
* @final
|
16 |
+
*
|
17 |
* @author Fabien Potencier <fabien@symfony.com>
|
18 |
*/
|
19 |
class Twig_SimpleFunction
|
vendor/twig/twig/lib/Twig/SimpleTest.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
@@ -12,6 +12,8 @@
|
|
12 |
/**
|
13 |
* Represents a template test.
|
14 |
*
|
|
|
|
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
class Twig_SimpleTest
|
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.
|
12 |
/**
|
13 |
* Represents a template test.
|
14 |
*
|
15 |
+
* @final
|
16 |
+
*
|
17 |
* @author Fabien Potencier <fabien@symfony.com>
|
18 |
*/
|
19 |
class Twig_SimpleTest
|
vendor/twig/twig/lib/Twig/Source.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
@@ -12,6 +12,8 @@
|
|
12 |
/**
|
13 |
* Holds information about a non-compiled Twig template.
|
14 |
*
|
|
|
|
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
class Twig_Source
|
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.
|
12 |
/**
|
13 |
* Holds information about a non-compiled Twig template.
|
14 |
*
|
15 |
+
* @final
|
16 |
+
*
|
17 |
* @author Fabien Potencier <fabien@symfony.com>
|
18 |
*/
|
19 |
class Twig_Source
|
vendor/twig/twig/lib/Twig/SourceContextLoaderInterface.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
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.
|
vendor/twig/twig/lib/Twig/Template.php
CHANGED
@@ -3,8 +3,8 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
-
* (c)
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
@@ -39,6 +39,14 @@ abstract class Twig_Template implements Twig_TemplateInterface
|
|
39 |
$this->env = $env;
|
40 |
}
|
41 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
/**
|
43 |
* Returns the template name.
|
44 |
*
|
@@ -125,7 +133,7 @@ abstract class Twig_Template implements Twig_TemplateInterface
|
|
125 |
$this->parents[$parent] = $this->loadTemplate($parent);
|
126 |
}
|
127 |
} catch (Twig_Error_Loader $e) {
|
128 |
-
$e->
|
129 |
$e->guess();
|
130 |
|
131 |
throw $e;
|
@@ -165,7 +173,7 @@ abstract class Twig_Template implements Twig_TemplateInterface
|
|
165 |
} elseif (false !== $parent = $this->getParent($context)) {
|
166 |
$parent->displayBlock($name, $context, $blocks, false);
|
167 |
} else {
|
168 |
-
throw new Twig_Error_Runtime(sprintf('The template has no parent and no traits defining the "%s" block.', $name), -1, $this->
|
169 |
}
|
170 |
}
|
171 |
|
@@ -197,17 +205,17 @@ abstract class Twig_Template implements Twig_TemplateInterface
|
|
197 |
$block = null;
|
198 |
}
|
199 |
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
}
|
205 |
|
|
|
206 |
try {
|
207 |
$template->$block($context, $blocks);
|
208 |
} catch (Twig_Error $e) {
|
209 |
-
if (!$e->
|
210 |
-
$e->
|
211 |
}
|
212 |
|
213 |
// this is mostly useful for Twig_Error_Loader exceptions
|
@@ -219,10 +227,12 @@ abstract class Twig_Template implements Twig_TemplateInterface
|
|
219 |
|
220 |
throw $e;
|
221 |
} catch (Exception $e) {
|
222 |
-
throw new Twig_Error_Runtime(sprintf('An exception has been thrown during the rendering of a template ("%s").', $e->getMessage()), -1, $template->
|
223 |
}
|
224 |
} elseif (false !== $parent = $this->getParent($context)) {
|
225 |
$parent->displayBlock($name, $context, array_merge($this->blocks, $blocks), false);
|
|
|
|
|
226 |
}
|
227 |
}
|
228 |
|
@@ -355,8 +365,8 @@ abstract class Twig_Template implements Twig_TemplateInterface
|
|
355 |
|
356 |
return $this->env->loadTemplate($template, $index);
|
357 |
} catch (Twig_Error $e) {
|
358 |
-
if (!$e->
|
359 |
-
$e->
|
360 |
}
|
361 |
|
362 |
if ($e->getTemplateLine()) {
|
@@ -388,17 +398,11 @@ abstract class Twig_Template implements Twig_TemplateInterface
|
|
388 |
return $this->blocks;
|
389 |
}
|
390 |
|
391 |
-
/**
|
392 |
-
* {@inheritdoc}
|
393 |
-
*/
|
394 |
public function display(array $context, array $blocks = array())
|
395 |
{
|
396 |
$this->displayWithErrorHandling($this->env->mergeGlobals($context), array_merge($this->blocks, $blocks));
|
397 |
}
|
398 |
|
399 |
-
/**
|
400 |
-
* {@inheritdoc}
|
401 |
-
*/
|
402 |
public function render(array $context)
|
403 |
{
|
404 |
$level = ob_get_level();
|
@@ -427,8 +431,8 @@ abstract class Twig_Template implements Twig_TemplateInterface
|
|
427 |
try {
|
428 |
$this->doDisplay($context, $blocks);
|
429 |
} catch (Twig_Error $e) {
|
430 |
-
if (!$e->
|
431 |
-
$e->
|
432 |
}
|
433 |
|
434 |
// this is mostly useful for Twig_Error_Loader exceptions
|
@@ -440,7 +444,7 @@ abstract class Twig_Template implements Twig_TemplateInterface
|
|
440 |
|
441 |
throw $e;
|
442 |
} catch (Exception $e) {
|
443 |
-
throw new Twig_Error_Runtime(sprintf('An exception has been thrown during the rendering of a template ("%s").', $e->getMessage()), -1, $this->
|
444 |
}
|
445 |
}
|
446 |
|
@@ -480,7 +484,7 @@ abstract class Twig_Template implements Twig_TemplateInterface
|
|
480 |
return;
|
481 |
}
|
482 |
|
483 |
-
throw new Twig_Error_Runtime(sprintf('Variable "%s" does not exist.', $item), -1, $this->
|
484 |
}
|
485 |
|
486 |
return $context[$item];
|
@@ -549,7 +553,7 @@ abstract class Twig_Template implements Twig_TemplateInterface
|
|
549 |
$message = sprintf('Impossible to access an attribute ("%s") on a %s variable ("%s").', $item, gettype($object), $object);
|
550 |
}
|
551 |
|
552 |
-
throw new Twig_Error_Runtime($message, -1, $this->
|
553 |
}
|
554 |
}
|
555 |
|
@@ -568,7 +572,7 @@ abstract class Twig_Template implements Twig_TemplateInterface
|
|
568 |
$message = sprintf('Impossible to invoke a method ("%s") on a %s variable ("%s").', $item, gettype($object), $object);
|
569 |
}
|
570 |
|
571 |
-
throw new Twig_Error_Runtime($message, -1, $this->
|
572 |
}
|
573 |
|
574 |
// object property
|
@@ -650,7 +654,7 @@ abstract class Twig_Template implements Twig_TemplateInterface
|
|
650 |
return;
|
651 |
}
|
652 |
|
653 |
-
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->
|
654 |
}
|
655 |
|
656 |
if ($isDefinedTest) {
|
@@ -679,7 +683,7 @@ abstract class Twig_Template implements Twig_TemplateInterface
|
|
679 |
// @deprecated in 1.28
|
680 |
if ($object instanceof Twig_TemplateInterface) {
|
681 |
$self = $object->getTemplateName() === $this->getTemplateName();
|
682 |
-
$message = sprintf('Calling "%s" on template "%s" from template "%s" is deprecated since version 1.28 and won\'t be supported anymore in 2.0.', $
|
683 |
if ('renderBlock' === $method || 'displayBlock' === $method) {
|
684 |
$message .= sprintf(' Use block("%s"%s) instead).', $arguments[0], $self ? '' : ', template');
|
685 |
} elseif ('hasBlock' === $method) {
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
+
* (c) Fabien Potencier
|
7 |
+
* (c) Armin Ronacher
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
39 |
$this->env = $env;
|
40 |
}
|
41 |
|
42 |
+
/**
|
43 |
+
* @internal this method will be removed in 2.0 and is only used internally to provide an upgrade path from 1.x to 2.0
|
44 |
+
*/
|
45 |
+
public function __toString()
|
46 |
+
{
|
47 |
+
return $this->getTemplateName();
|
48 |
+
}
|
49 |
+
|
50 |
/**
|
51 |
* Returns the template name.
|
52 |
*
|
133 |
$this->parents[$parent] = $this->loadTemplate($parent);
|
134 |
}
|
135 |
} catch (Twig_Error_Loader $e) {
|
136 |
+
$e->setSourceContext(null);
|
137 |
$e->guess();
|
138 |
|
139 |
throw $e;
|
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 |
|
205 |
$block = null;
|
206 |
}
|
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 |
}
|
220 |
|
221 |
// this is mostly useful for Twig_Error_Loader exceptions
|
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);
|
234 |
+
} else {
|
235 |
+
@trigger_error(sprintf('Silent display of undefined block "%s" in template "%s" is deprecated since version 1.29 and will throw an exception in 2.0. Use the "block(\'%s\') is defined" expression to test for block existence.', $name, $this->getTemplateName(), $name), E_USER_DEPRECATED);
|
236 |
}
|
237 |
}
|
238 |
|
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 |
}
|
405 |
|
|
|
|
|
|
|
406 |
public function render(array $context)
|
407 |
{
|
408 |
$level = ob_get_level();
|
431 |
try {
|
432 |
$this->doDisplay($context, $blocks);
|
433 |
} catch (Twig_Error $e) {
|
434 |
+
if (!$e->getSourceContext()) {
|
435 |
+
$e->setSourceContext($this->getSourceContext());
|
436 |
}
|
437 |
|
438 |
// this is mostly useful for Twig_Error_Loader exceptions
|
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 |
|
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];
|
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 |
|
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
|
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) {
|
683 |
// @deprecated in 1.28
|
684 |
if ($object instanceof Twig_TemplateInterface) {
|
685 |
$self = $object->getTemplateName() === $this->getTemplateName();
|
686 |
+
$message = sprintf('Calling "%s" on template "%s" from template "%s" is deprecated since version 1.28 and won\'t be supported anymore in 2.0.', $item, $object->getTemplateName(), $this->getTemplateName());
|
687 |
if ('renderBlock' === $method || 'displayBlock' === $method) {
|
688 |
$message .= sprintf(' Use block("%s"%s) instead).', $arguments[0], $self ? '' : ', template');
|
689 |
} elseif ('hasBlock' === $method) {
|
vendor/twig/twig/lib/Twig/TemplateInterface.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
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.
|
vendor/twig/twig/lib/Twig/TemplateWrapper.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
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.
|
vendor/twig/twig/lib/Twig/Test.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
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.
|
vendor/twig/twig/lib/Twig/Test/Function.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
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.
|
vendor/twig/twig/lib/Twig/Test/IntegrationTestCase.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
@@ -173,12 +173,6 @@ abstract class Twig_Test_IntegrationTestCase extends PHPUnit_Framework_TestCase
|
|
173 |
return;
|
174 |
}
|
175 |
|
176 |
-
if ($e instanceof Twig_Error_Syntax) {
|
177 |
-
$e->setTemplateName($file);
|
178 |
-
|
179 |
-
throw $e;
|
180 |
-
}
|
181 |
-
|
182 |
throw new Twig_Error(sprintf('%s: %s', get_class($e), $e->getMessage()), -1, $file, $e);
|
183 |
}
|
184 |
|
@@ -191,11 +185,7 @@ abstract class Twig_Test_IntegrationTestCase extends PHPUnit_Framework_TestCase
|
|
191 |
return;
|
192 |
}
|
193 |
|
194 |
-
|
195 |
-
$e->setTemplateName($file);
|
196 |
-
} else {
|
197 |
-
$e = new Twig_Error(sprintf('%s: %s', get_class($e), $e->getMessage()), -1, $file, $e);
|
198 |
-
}
|
199 |
|
200 |
$output = trim(sprintf('%s: %s', get_class($e), $e->getMessage()));
|
201 |
}
|
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.
|
173 |
return;
|
174 |
}
|
175 |
|
|
|
|
|
|
|
|
|
|
|
|
|
176 |
throw new Twig_Error(sprintf('%s: %s', get_class($e), $e->getMessage()), -1, $file, $e);
|
177 |
}
|
178 |
|
185 |
return;
|
186 |
}
|
187 |
|
188 |
+
$e = new Twig_Error(sprintf('%s: %s', get_class($e), $e->getMessage()), -1, $file, $e);
|
|
|
|
|
|
|
|
|
189 |
|
190 |
$output = trim(sprintf('%s: %s', get_class($e), $e->getMessage()));
|
191 |
}
|
vendor/twig/twig/lib/Twig/Test/Method.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
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.
|
vendor/twig/twig/lib/Twig/Test/Node.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
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.
|
vendor/twig/twig/lib/Twig/TestCallableInterface.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
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.
|
vendor/twig/twig/lib/Twig/TestInterface.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
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.
|
vendor/twig/twig/lib/Twig/Token.php
CHANGED
@@ -3,8 +3,8 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
-
* (c)
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
@@ -14,6 +14,8 @@
|
|
14 |
* Represents a Token.
|
15 |
*
|
16 |
* @author Fabien Potencier <fabien@symfony.com>
|
|
|
|
|
17 |
*/
|
18 |
class Twig_Token
|
19 |
{
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
+
* (c) Fabien Potencier
|
7 |
+
* (c) Armin Ronacher
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
14 |
* Represents a Token.
|
15 |
*
|
16 |
* @author Fabien Potencier <fabien@symfony.com>
|
17 |
+
*
|
18 |
+
* @final
|
19 |
*/
|
20 |
class Twig_Token
|
21 |
{
|
vendor/twig/twig/lib/Twig/TokenParser.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
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.
|
vendor/twig/twig/lib/Twig/TokenParser/AutoEscape.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
@@ -26,6 +26,8 @@
|
|
26 |
* using the js escaping strategy
|
27 |
* {% endautoescape %}
|
28 |
* </pre>
|
|
|
|
|
29 |
*/
|
30 |
class Twig_TokenParser_AutoEscape extends Twig_TokenParser
|
31 |
{
|
@@ -39,7 +41,7 @@ class Twig_TokenParser_AutoEscape extends Twig_TokenParser
|
|
39 |
} else {
|
40 |
$expr = $this->parser->getExpressionParser()->parseExpression();
|
41 |
if (!$expr instanceof Twig_Node_Expression_Constant) {
|
42 |
-
throw new Twig_Error_Syntax('An escaping strategy must be a string or a bool.', $stream->getCurrent()->getLine(), $stream->getSourceContext()
|
43 |
}
|
44 |
$value = $expr->getAttribute('value');
|
45 |
|
@@ -53,7 +55,7 @@ class Twig_TokenParser_AutoEscape extends Twig_TokenParser
|
|
53 |
@trigger_error('Using the autoescape tag with "true" or "false" before the strategy name is deprecated since version 1.21.', E_USER_DEPRECATED);
|
54 |
|
55 |
if (false === $value) {
|
56 |
-
throw new Twig_Error_Syntax('Unexpected escaping strategy as you set autoescaping to false.', $stream->getCurrent()->getLine(), $stream->getSourceContext()
|
57 |
}
|
58 |
|
59 |
$value = $stream->next()->getValue();
|
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.
|
26 |
* using the js escaping strategy
|
27 |
* {% endautoescape %}
|
28 |
* </pre>
|
29 |
+
*
|
30 |
+
* @final
|
31 |
*/
|
32 |
class Twig_TokenParser_AutoEscape extends Twig_TokenParser
|
33 |
{
|
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 |
|
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();
|
vendor/twig/twig/lib/Twig/TokenParser/Block.php
CHANGED
@@ -3,8 +3,8 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
-
* (c)
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
@@ -19,6 +19,8 @@
|
|
19 |
* <title>{% block title %}{% endblock %} - My Webpage</title>
|
20 |
* {% endblock %}
|
21 |
* </pre>
|
|
|
|
|
22 |
*/
|
23 |
class Twig_TokenParser_Block extends Twig_TokenParser
|
24 |
{
|
@@ -28,7 +30,7 @@ class Twig_TokenParser_Block extends Twig_TokenParser
|
|
28 |
$stream = $this->parser->getStream();
|
29 |
$name = $stream->expect(Twig_Token::NAME_TYPE)->getValue();
|
30 |
if ($this->parser->hasBlock($name)) {
|
31 |
-
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()
|
32 |
}
|
33 |
$this->parser->setBlock($name, $block = new Twig_Node_Block($name, new Twig_Node(array()), $lineno));
|
34 |
$this->parser->pushLocalScope();
|
@@ -40,7 +42,7 @@ class Twig_TokenParser_Block extends Twig_TokenParser
|
|
40 |
$value = $token->getValue();
|
41 |
|
42 |
if ($value != $name) {
|
43 |
-
throw new Twig_Error_Syntax(sprintf('Expected endblock for block "%s" (but "%s" given).', $name, $value), $stream->getCurrent()->getLine(), $stream->getSourceContext()
|
44 |
}
|
45 |
}
|
46 |
} else {
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
+
* (c) Fabien Potencier
|
7 |
+
* (c) Armin Ronacher
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
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 |
{
|
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();
|
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 {
|
vendor/twig/twig/lib/Twig/TokenParser/Do.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
@@ -11,6 +11,8 @@
|
|
11 |
|
12 |
/**
|
13 |
* Evaluates an expression, discarding the returned value.
|
|
|
|
|
14 |
*/
|
15 |
class Twig_TokenParser_Do extends Twig_TokenParser
|
16 |
{
|
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.
|
11 |
|
12 |
/**
|
13 |
* Evaluates an expression, discarding the returned value.
|
14 |
+
*
|
15 |
+
* @final
|
16 |
*/
|
17 |
class Twig_TokenParser_Do extends Twig_TokenParser
|
18 |
{
|
vendor/twig/twig/lib/Twig/TokenParser/Embed.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
@@ -11,6 +11,8 @@
|
|
11 |
|
12 |
/**
|
13 |
* Embeds a template.
|
|
|
|
|
14 |
*/
|
15 |
class Twig_TokenParser_Embed extends Twig_TokenParser_Include
|
16 |
{
|
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.
|
11 |
|
12 |
/**
|
13 |
* Embeds a template.
|
14 |
+
*
|
15 |
+
* @final
|
16 |
*/
|
17 |
class Twig_TokenParser_Embed extends Twig_TokenParser_Include
|
18 |
{
|
vendor/twig/twig/lib/Twig/TokenParser/Extends.php
CHANGED
@@ -3,8 +3,8 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
-
* (c)
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
@@ -16,6 +16,8 @@
|
|
16 |
* <pre>
|
17 |
* {% extends "base.html" %}
|
18 |
* </pre>
|
|
|
|
|
19 |
*/
|
20 |
class Twig_TokenParser_Extends extends Twig_TokenParser
|
21 |
{
|
@@ -24,11 +26,11 @@ class Twig_TokenParser_Extends extends Twig_TokenParser
|
|
24 |
$stream = $this->parser->getStream();
|
25 |
|
26 |
if (!$this->parser->isMainScope()) {
|
27 |
-
throw new Twig_Error_Syntax('Cannot extend from a block.', $token->getLine(), $stream->getSourceContext()
|
28 |
}
|
29 |
|
30 |
if (null !== $this->parser->getParent()) {
|
31 |
-
throw new Twig_Error_Syntax('Multiple extends tags are forbidden.', $token->getLine(), $stream->getSourceContext()
|
32 |
}
|
33 |
$this->parser->setParent($this->parser->getExpressionParser()->parseExpression());
|
34 |
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
+
* (c) Fabien Potencier
|
7 |
+
* (c) Armin Ronacher
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
16 |
* <pre>
|
17 |
* {% extends "base.html" %}
|
18 |
* </pre>
|
19 |
+
*
|
20 |
+
* @final
|
21 |
*/
|
22 |
class Twig_TokenParser_Extends extends Twig_TokenParser
|
23 |
{
|
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 |
|
vendor/twig/twig/lib/Twig/TokenParser/Filter.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
@@ -17,6 +17,8 @@
|
|
17 |
* This text becomes uppercase
|
18 |
* {% endfilter %}
|
19 |
* </pre>
|
|
|
|
|
20 |
*/
|
21 |
class Twig_TokenParser_Filter extends Twig_TokenParser
|
22 |
{
|
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.
|
17 |
* This text becomes uppercase
|
18 |
* {% endfilter %}
|
19 |
* </pre>
|
20 |
+
*
|
21 |
+
* @final
|
22 |
*/
|
23 |
class Twig_TokenParser_Filter extends Twig_TokenParser
|
24 |
{
|
vendor/twig/twig/lib/Twig/TokenParser/Flush.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
@@ -13,6 +13,8 @@
|
|
13 |
* Flushes the output to the client.
|
14 |
*
|
15 |
* @see flush()
|
|
|
|
|
16 |
*/
|
17 |
class Twig_TokenParser_Flush extends Twig_TokenParser
|
18 |
{
|
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.
|
13 |
* Flushes the output to the client.
|
14 |
*
|
15 |
* @see flush()
|
16 |
+
*
|
17 |
+
* @final
|
18 |
*/
|
19 |
class Twig_TokenParser_Flush extends Twig_TokenParser
|
20 |
{
|
vendor/twig/twig/lib/Twig/TokenParser/For.php
CHANGED
@@ -3,8 +3,8 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
-
* (c)
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
@@ -20,6 +20,8 @@
|
|
20 |
* {% endfor %}
|
21 |
* </ul>
|
22 |
* </pre>
|
|
|
|
|
23 |
*/
|
24 |
class Twig_TokenParser_For extends Twig_TokenParser
|
25 |
{
|
@@ -79,7 +81,7 @@ class Twig_TokenParser_For extends Twig_TokenParser
|
|
79 |
protected function checkLoopUsageCondition(Twig_TokenStream $stream, Twig_NodeInterface $node)
|
80 |
{
|
81 |
if ($node instanceof Twig_Node_Expression_GetAttr && $node->getNode('node') instanceof Twig_Node_Expression_Name && 'loop' == $node->getNode('node')->getAttribute('name')) {
|
82 |
-
throw new Twig_Error_Syntax('The "loop" variable cannot be used in a looping condition.', $node->getTemplateLine(), $stream->getSourceContext()
|
83 |
}
|
84 |
|
85 |
foreach ($node as $n) {
|
@@ -98,7 +100,7 @@ class Twig_TokenParser_For extends Twig_TokenParser
|
|
98 |
if ($node instanceof Twig_Node_Expression_GetAttr && $node->getNode('node') instanceof Twig_Node_Expression_Name && 'loop' == $node->getNode('node')->getAttribute('name')) {
|
99 |
$attribute = $node->getNode('attribute');
|
100 |
if ($attribute instanceof Twig_Node_Expression_Constant && in_array($attribute->getAttribute('value'), array('length', 'revindex0', 'revindex', 'last'))) {
|
101 |
-
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()
|
102 |
}
|
103 |
}
|
104 |
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
+
* (c) Fabien Potencier
|
7 |
+
* (c) Armin Ronacher
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
20 |
* {% endfor %}
|
21 |
* </ul>
|
22 |
* </pre>
|
23 |
+
*
|
24 |
+
* @final
|
25 |
*/
|
26 |
class Twig_TokenParser_For extends Twig_TokenParser
|
27 |
{
|
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) {
|
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 |
|
vendor/twig/twig/lib/Twig/TokenParser/From.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
@@ -15,6 +15,8 @@
|
|
15 |
* <pre>
|
16 |
* {% from 'forms.html' import forms %}
|
17 |
* </pre>
|
|
|
|
|
18 |
*/
|
19 |
class Twig_TokenParser_From extends Twig_TokenParser
|
20 |
{
|
@@ -46,7 +48,7 @@ class Twig_TokenParser_From extends Twig_TokenParser
|
|
46 |
|
47 |
foreach ($targets as $name => $alias) {
|
48 |
if ($this->parser->isReservedMacroName($name)) {
|
49 |
-
throw new Twig_Error_Syntax(sprintf('"%s" cannot be an imported macro as it is a reserved keyword.', $name), $token->getLine(), $stream->getSourceContext()
|
50 |
}
|
51 |
|
52 |
$this->parser->addImportedSymbol('function', $alias, 'get'.$name, $node->getNode('var'));
|
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.
|
15 |
* <pre>
|
16 |
* {% from 'forms.html' import forms %}
|
17 |
* </pre>
|
18 |
+
*
|
19 |
+
* @final
|
20 |
*/
|
21 |
class Twig_TokenParser_From extends Twig_TokenParser
|
22 |
{
|
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'));
|
vendor/twig/twig/lib/Twig/TokenParser/If.php
CHANGED
@@ -3,8 +3,8 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
-
* (c)
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
@@ -22,6 +22,8 @@
|
|
22 |
* </ul>
|
23 |
* {% endif %}
|
24 |
* </pre>
|
|
|
|
|
25 |
*/
|
26 |
class Twig_TokenParser_If extends Twig_TokenParser
|
27 |
{
|
@@ -56,7 +58,7 @@ class Twig_TokenParser_If extends Twig_TokenParser
|
|
56 |
break;
|
57 |
|
58 |
default:
|
59 |
-
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()
|
60 |
}
|
61 |
}
|
62 |
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
+
* (c) Fabien Potencier
|
7 |
+
* (c) Armin Ronacher
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
22 |
* </ul>
|
23 |
* {% endif %}
|
24 |
* </pre>
|
25 |
+
*
|
26 |
+
* @final
|
27 |
*/
|
28 |
class Twig_TokenParser_If extends Twig_TokenParser
|
29 |
{
|
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 |
|
vendor/twig/twig/lib/Twig/TokenParser/Import.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
@@ -15,6 +15,8 @@
|
|
15 |
* <pre>
|
16 |
* {% import 'forms.html' as forms %}
|
17 |
* </pre>
|
|
|
|
|
18 |
*/
|
19 |
class Twig_TokenParser_Import extends Twig_TokenParser
|
20 |
{
|
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.
|
15 |
* <pre>
|
16 |
* {% import 'forms.html' as forms %}
|
17 |
* </pre>
|
18 |
+
*
|
19 |
+
* @final
|
20 |
*/
|
21 |
class Twig_TokenParser_Import extends Twig_TokenParser
|
22 |
{
|
vendor/twig/twig/lib/Twig/TokenParser/Include.php
CHANGED
@@ -3,8 +3,8 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
-
* (c)
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
@@ -18,6 +18,8 @@
|
|
18 |
* Body
|
19 |
* {% include 'footer.html' %}
|
20 |
* </pre>
|
|
|
|
|
21 |
*/
|
22 |
class Twig_TokenParser_Include extends Twig_TokenParser
|
23 |
{
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
+
* (c) Fabien Potencier
|
7 |
+
* (c) Armin Ronacher
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
18 |
* Body
|
19 |
* {% include 'footer.html' %}
|
20 |
* </pre>
|
21 |
+
*
|
22 |
+
* @final
|
23 |
*/
|
24 |
class Twig_TokenParser_Include extends Twig_TokenParser
|
25 |
{
|
vendor/twig/twig/lib/Twig/TokenParser/Macro.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
@@ -17,6 +17,8 @@
|
|
17 |
* <input type="{{ type|default('text') }}" name="{{ name }}" value="{{ value|e }}" size="{{ size|default(20) }}" />
|
18 |
* {% endmacro %}
|
19 |
* </pre>
|
|
|
|
|
20 |
*/
|
21 |
class Twig_TokenParser_Macro extends Twig_TokenParser
|
22 |
{
|
@@ -35,7 +37,7 @@ class Twig_TokenParser_Macro extends Twig_TokenParser
|
|
35 |
$value = $token->getValue();
|
36 |
|
37 |
if ($value != $name) {
|
38 |
-
throw new Twig_Error_Syntax(sprintf('Expected endmacro for macro "%s" (but "%s" given).', $name, $value), $stream->getCurrent()->getLine(), $stream->getSourceContext()
|
39 |
}
|
40 |
}
|
41 |
$this->parser->popLocalScope();
|
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.
|
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 |
{
|
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();
|
vendor/twig/twig/lib/Twig/TokenParser/Sandbox.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
@@ -19,6 +19,8 @@
|
|
19 |
* </pre>
|
20 |
*
|
21 |
* @see http://www.twig-project.org/doc/api.html#sandbox-extension for details
|
|
|
|
|
22 |
*/
|
23 |
class Twig_TokenParser_Sandbox extends Twig_TokenParser
|
24 |
{
|
@@ -37,7 +39,7 @@ class Twig_TokenParser_Sandbox extends Twig_TokenParser
|
|
37 |
}
|
38 |
|
39 |
if (!$node instanceof Twig_Node_Include) {
|
40 |
-
throw new Twig_Error_Syntax('Only "include" tags are allowed within a "sandbox" section.', $node->getTemplateLine(), $stream->getSourceContext()
|
41 |
}
|
42 |
}
|
43 |
}
|
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.
|
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 |
{
|
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 |
}
|
vendor/twig/twig/lib/Twig/TokenParser/Set.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
@@ -25,6 +25,8 @@
|
|
25 |
*
|
26 |
* {% set foo %}Some content{% endset %}
|
27 |
* </pre>
|
|
|
|
|
28 |
*/
|
29 |
class Twig_TokenParser_Set extends Twig_TokenParser
|
30 |
{
|
@@ -41,13 +43,13 @@ class Twig_TokenParser_Set extends Twig_TokenParser
|
|
41 |
$stream->expect(Twig_Token::BLOCK_END_TYPE);
|
42 |
|
43 |
if (count($names) !== count($values)) {
|
44 |
-
throw new Twig_Error_Syntax('When using set, you must have the same number of variables and assignments.', $stream->getCurrent()->getLine(), $stream->getSourceContext()
|
45 |
}
|
46 |
} else {
|
47 |
$capture = true;
|
48 |
|
49 |
if (count($names) > 1) {
|
50 |
-
throw new Twig_Error_Syntax('When using set with a block, you cannot have a multi-target.', $stream->getCurrent()->getLine(), $stream->getSourceContext()
|
51 |
}
|
52 |
|
53 |
$stream->expect(Twig_Token::BLOCK_END_TYPE);
|
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.
|
25 |
*
|
26 |
* {% set foo %}Some content{% endset %}
|
27 |
* </pre>
|
28 |
+
*
|
29 |
+
* @final
|
30 |
*/
|
31 |
class Twig_TokenParser_Set extends Twig_TokenParser
|
32 |
{
|
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);
|
vendor/twig/twig/lib/Twig/TokenParser/Spaceless.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
@@ -21,6 +21,8 @@
|
|
21 |
*
|
22 |
* {# output will be <div><strong>foo</strong></div> #}
|
23 |
* </pre>
|
|
|
|
|
24 |
*/
|
25 |
class Twig_TokenParser_Spaceless extends Twig_TokenParser
|
26 |
{
|
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.
|
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 |
{
|
vendor/twig/twig/lib/Twig/TokenParser/Use.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
@@ -22,6 +22,8 @@
|
|
22 |
* </pre>
|
23 |
*
|
24 |
* @see http://www.twig-project.org/doc/templates.html#horizontal-reuse for details.
|
|
|
|
|
25 |
*/
|
26 |
class Twig_TokenParser_Use extends Twig_TokenParser
|
27 |
{
|
@@ -31,7 +33,7 @@ class Twig_TokenParser_Use extends Twig_TokenParser
|
|
31 |
$stream = $this->parser->getStream();
|
32 |
|
33 |
if (!$template instanceof Twig_Node_Expression_Constant) {
|
34 |
-
throw new Twig_Error_Syntax('The template references in a "use" statement must be a string.', $stream->getCurrent()->getLine(), $stream->getSourceContext()
|
35 |
}
|
36 |
|
37 |
$targets = array();
|
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.
|
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 |
{
|
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();
|
vendor/twig/twig/lib/Twig/TokenParser/With.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
@@ -13,6 +13,8 @@
|
|
13 |
* Creates a nested scope.
|
14 |
*
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
|
|
|
|
16 |
*/
|
17 |
class Twig_TokenParser_With extends Twig_TokenParser
|
18 |
{
|
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.
|
13 |
* Creates a nested scope.
|
14 |
*
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
+
*
|
17 |
+
* @final
|
18 |
*/
|
19 |
class Twig_TokenParser_With extends Twig_TokenParser
|
20 |
{
|
vendor/twig/twig/lib/Twig/TokenParserBroker.php
CHANGED
@@ -3,8 +3,8 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
-
* (c)
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
+
* (c) Fabien Potencier
|
7 |
+
* (c) Arnaud Le Blanc
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
vendor/twig/twig/lib/Twig/TokenParserBrokerInterface.php
CHANGED
@@ -3,8 +3,8 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
-
* (c)
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
+
* (c) Fabien Potencier
|
7 |
+
* (c) Arnaud Le Blanc
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
vendor/twig/twig/lib/Twig/TokenParserInterface.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
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.
|
vendor/twig/twig/lib/Twig/TokenStream.php
CHANGED
@@ -3,8 +3,8 @@
|
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
-
* (c)
|
7 |
-
* (c)
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
@@ -13,6 +13,8 @@
|
|
13 |
/**
|
14 |
* Represents a token stream.
|
15 |
*
|
|
|
|
|
16 |
* @author Fabien Potencier <fabien@symfony.com>
|
17 |
*/
|
18 |
class Twig_TokenStream
|
@@ -63,7 +65,7 @@ class Twig_TokenStream
|
|
63 |
public function next()
|
64 |
{
|
65 |
if (!isset($this->tokens[++$this->current])) {
|
66 |
-
throw new Twig_Error_Syntax('Unexpected end of template.', $this->tokens[$this->current - 1]->getLine(), $this->source
|
67 |
}
|
68 |
|
69 |
return $this->tokens[$this->current - 1];
|
@@ -96,7 +98,7 @@ class Twig_TokenStream
|
|
96 |
Twig_Token::typeToEnglish($token->getType()), $token->getValue(),
|
97 |
Twig_Token::typeToEnglish($type), $value ? sprintf(' with value "%s"', $value) : ''),
|
98 |
$line,
|
99 |
-
$this->source
|
100 |
);
|
101 |
}
|
102 |
$this->next();
|
@@ -114,7 +116,7 @@ class Twig_TokenStream
|
|
114 |
public function look($number = 1)
|
115 |
{
|
116 |
if (!isset($this->tokens[$this->current + $number])) {
|
117 |
-
throw new Twig_Error_Syntax('Unexpected end of template.', $this->tokens[$this->current + $number - 1]->getLine(), $this->source
|
118 |
}
|
119 |
|
120 |
return $this->tokens[$this->current + $number];
|
3 |
/*
|
4 |
* This file is part of Twig.
|
5 |
*
|
6 |
+
* (c) Fabien Potencier
|
7 |
+
* (c) Armin Ronacher
|
8 |
*
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
13 |
/**
|
14 |
* Represents a token stream.
|
15 |
*
|
16 |
+
* @final
|
17 |
+
*
|
18 |
* @author Fabien Potencier <fabien@symfony.com>
|
19 |
*/
|
20 |
class Twig_TokenStream
|
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];
|
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 |
);
|
103 |
}
|
104 |
$this->next();
|
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];
|
vendor/twig/twig/lib/Twig/Util/DeprecationCollector.php
CHANGED
@@ -11,6 +11,8 @@
|
|
11 |
|
12 |
/**
|
13 |
* @author Fabien Potencier <fabien@symfony.com>
|
|
|
|
|
14 |
*/
|
15 |
class Twig_Util_DeprecationCollector
|
16 |
{
|
11 |
|
12 |
/**
|
13 |
* @author Fabien Potencier <fabien@symfony.com>
|
14 |
+
*
|
15 |
+
* @final
|
16 |
*/
|
17 |
class Twig_Util_DeprecationCollector
|
18 |
{
|
vendor/twig/twig/test/Twig/Tests/Cache/FilesystemTest.php
CHANGED
@@ -65,13 +65,13 @@ class Twig_Tests_Cache_FilesystemTest extends PHPUnit_Framework_TestCase
|
|
65 |
$key = $this->directory.'/cache/cachefile.php';
|
66 |
$content = $this->generateSource();
|
67 |
|
68 |
-
$this->
|
69 |
-
$this->
|
70 |
|
71 |
$this->cache->write($key, $content);
|
72 |
|
73 |
-
$this->
|
74 |
-
$this->
|
75 |
$this->assertSame(file_get_contents($key), $content);
|
76 |
}
|
77 |
|
@@ -88,7 +88,7 @@ class Twig_Tests_Cache_FilesystemTest extends PHPUnit_Framework_TestCase
|
|
88 |
$key = $this->directory.'/cache/cachefile.php';
|
89 |
$content = $this->generateSource();
|
90 |
|
91 |
-
$this->
|
92 |
|
93 |
// Create read-only root directory.
|
94 |
@mkdir($this->directory, 0555, true);
|
@@ -110,7 +110,7 @@ class Twig_Tests_Cache_FilesystemTest extends PHPUnit_Framework_TestCase
|
|
110 |
$key = $this->directory.'/cache/cachefile.php';
|
111 |
$content = $this->generateSource();
|
112 |
|
113 |
-
$this->
|
114 |
|
115 |
// Create root directory.
|
116 |
@mkdir($this->directory, 0777, true);
|
@@ -130,7 +130,7 @@ class Twig_Tests_Cache_FilesystemTest extends PHPUnit_Framework_TestCase
|
|
130 |
$key = $this->directory.'/cache/cachefile.php';
|
131 |
$content = $this->generateSource();
|
132 |
|
133 |
-
$this->
|
134 |
|
135 |
// Create a directory in the place of the cache file.
|
136 |
@mkdir($key, 0777, true);
|
65 |
$key = $this->directory.'/cache/cachefile.php';
|
66 |
$content = $this->generateSource();
|
67 |
|
68 |
+
$this->assertFileNotExists($key);
|
69 |
+
$this->assertFileNotExists($this->directory);
|
70 |
|
71 |
$this->cache->write($key, $content);
|
72 |
|
73 |
+
$this->assertFileExists($this->directory);
|
74 |
+
$this->assertFileExists($key);
|
75 |
$this->assertSame(file_get_contents($key), $content);
|
76 |
}
|
77 |
|
88 |
$key = $this->directory.'/cache/cachefile.php';
|
89 |
$content = $this->generateSource();
|
90 |
|
91 |
+
$this->assertFileNotExists($key);
|
92 |
|
93 |
// Create read-only root directory.
|
94 |
@mkdir($this->directory, 0555, true);
|
110 |
$key = $this->directory.'/cache/cachefile.php';
|
111 |
$content = $this->generateSource();
|
112 |
|
113 |
+
$this->assertFileNotExists($key);
|
114 |
|
115 |
// Create root directory.
|
116 |
@mkdir($this->directory, 0777, true);
|
130 |
$key = $this->directory.'/cache/cachefile.php';
|
131 |
$content = $this->generateSource();
|
132 |
|
133 |
+
$this->assertFileNotExists($key);
|
134 |
|
135 |
// Create a directory in the place of the cache file.
|
136 |
@mkdir($key, 0777, true);
|
vendor/twig/twig/test/Twig/Tests/CustomExtensionTest.php
ADDED
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
class CustomExtensionTest extends PHPUnit_Framework_TestCase
|
13 |
+
{
|
14 |
+
/**
|
15 |
+
* @requires PHP 5.3
|
16 |
+
* @dataProvider provideInvalidExtensions
|
17 |
+
*/
|
18 |
+
public function testGetInvalidOperators(Twig_ExtensionInterface $extension, $expectedExceptionMessage)
|
19 |
+
{
|
20 |
+
$this->setExpectedException('InvalidArgumentException', $expectedExceptionMessage);
|
21 |
+
|
22 |
+
$env = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock());
|
23 |
+
$env->addExtension($extension);
|
24 |
+
$env->getUnaryOperators();
|
25 |
+
}
|
26 |
+
|
27 |
+
public function provideInvalidExtensions()
|
28 |
+
{
|
29 |
+
return array(
|
30 |
+
array(new InvalidOperatorExtension(new stdClass()), '"InvalidOperatorExtension::getOperators()" must return an array with operators, got "stdClass".'),
|
31 |
+
array(new InvalidOperatorExtension(array(1, 2, 3)), '"InvalidOperatorExtension::getOperators()" must return an array of 2 elements, got 3.'),
|
32 |
+
);
|
33 |
+
}
|
34 |
+
}
|
35 |
+
|
36 |
+
class InvalidOperatorExtension implements Twig_ExtensionInterface
|
37 |
+
{
|
38 |
+
private $operators;
|
39 |
+
|
40 |
+
public function __construct($operators)
|
41 |
+
{
|
42 |
+
$this->operators = $operators;
|
43 |
+
}
|
44 |
+
|
45 |
+
public function initRuntime(Twig_Environment $environment)
|
46 |
+
{
|
47 |
+
}
|
48 |
+
|
49 |
+
public function getTokenParsers()
|
50 |
+
{
|
51 |
+
return array();
|
52 |
+
}
|
53 |
+
|
54 |
+
public function getNodeVisitors()
|
55 |
+
{
|
56 |
+
return array();
|
57 |
+
}
|
58 |
+
|
59 |
+
public function getFilters()
|
60 |
+
{
|
61 |
+
return array();
|
62 |
+
}
|
63 |
+
|
64 |
+
public function getTests()
|
65 |
+
{
|
66 |
+
return array();
|
67 |
+
}
|
68 |
+
|
69 |
+
public function getFunctions()
|
70 |
+
{
|
71 |
+
return array();
|
72 |
+
}
|
73 |
+
|
74 |
+
public function getGlobals()
|
75 |
+
{
|
76 |
+
return array();
|
77 |
+
}
|
78 |
+
|
79 |
+
public function getOperators()
|
80 |
+
{
|
81 |
+
return $this->operators;
|
82 |
+
}
|
83 |
+
|
84 |
+
public function getName()
|
85 |
+
{
|
86 |
+
return __CLASS__;
|
87 |
+
}
|
88 |
+
}
|
vendor/twig/twig/test/Twig/Tests/EnvironmentTest.php
CHANGED
@@ -363,13 +363,13 @@ class Twig_Tests_EnvironmentTest extends PHPUnit_Framework_TestCase
|
|
363 |
$twig->addExtension(new Twig_Tests_EnvironmentTest_Extension_WithDeprecatedName());
|
364 |
$twig->removeExtension('environment_test');
|
365 |
|
366 |
-
$this->
|
367 |
-
$this->
|
368 |
-
$this->
|
369 |
-
$this->
|
370 |
-
$this->
|
371 |
-
$this->
|
372 |
-
$this->
|
373 |
$this->assertCount(2, $twig->getNodeVisitors());
|
374 |
}
|
375 |
|
363 |
$twig->addExtension(new Twig_Tests_EnvironmentTest_Extension_WithDeprecatedName());
|
364 |
$twig->removeExtension('environment_test');
|
365 |
|
366 |
+
$this->assertArrayNotHasKey('test', $twig->getTags());
|
367 |
+
$this->assertArrayNotHasKey('foo_filter', $twig->getFilters());
|
368 |
+
$this->assertArrayNotHasKey('foo_function', $twig->getFunctions());
|
369 |
+
$this->assertArrayNotHasKey('foo_test', $twig->getTests());
|
370 |
+
$this->assertArrayNotHasKey('foo_unary', $twig->getUnaryOperators());
|
371 |
+
$this->assertArrayNotHasKey('foo_binary', $twig->getBinaryOperators());
|
372 |
+
$this->assertArrayNotHasKey('foo_global', $twig->getGlobals());
|
373 |
$this->assertCount(2, $twig->getNodeVisitors());
|
374 |
}
|
375 |
|
vendor/twig/twig/test/Twig/Tests/ErrorTest.php
CHANGED
@@ -14,7 +14,7 @@ class Twig_Tests_ErrorTest extends PHPUnit_Framework_TestCase
|
|
14 |
public function testErrorWithObjectFilename()
|
15 |
{
|
16 |
$error = new Twig_Error('foo');
|
17 |
-
$error->
|
18 |
|
19 |
$this->assertContains('test'.DIRECTORY_SEPARATOR.'Twig'.DIRECTORY_SEPARATOR.'Tests'.DIRECTORY_SEPARATOR.'ErrorTest.php', $error->getMessage());
|
20 |
}
|
@@ -22,14 +22,25 @@ class Twig_Tests_ErrorTest extends PHPUnit_Framework_TestCase
|
|
22 |
public function testErrorWithArrayFilename()
|
23 |
{
|
24 |
$error = new Twig_Error('foo');
|
25 |
-
$error->
|
26 |
|
27 |
$this->assertEquals('foo in {"foo":"bar"}', $error->getMessage());
|
28 |
}
|
29 |
|
30 |
-
public function
|
31 |
{
|
32 |
-
$loader = new
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
$twig = new Twig_Environment($loader, array('strict_variables' => true, 'debug' => true, 'cache' => false));
|
34 |
|
35 |
$template = $twig->loadTemplate('index.html');
|
@@ -40,9 +51,27 @@ class Twig_Tests_ErrorTest extends PHPUnit_Framework_TestCase
|
|
40 |
} catch (Twig_Error_Runtime $e) {
|
41 |
$this->assertEquals('Variable "foo" does not exist in "index.html" at line 3.', $e->getMessage());
|
42 |
$this->assertEquals(3, $e->getTemplateLine());
|
43 |
-
$this->assertEquals('index.html', $e->
|
44 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
|
|
|
46 |
try {
|
47 |
$template->render(array('foo' => new Twig_Tests_ErrorTest_Foo()));
|
48 |
|
@@ -50,7 +79,45 @@ class Twig_Tests_ErrorTest extends PHPUnit_Framework_TestCase
|
|
50 |
} catch (Twig_Error_Runtime $e) {
|
51 |
$this->assertEquals('An exception has been thrown during the rendering of a template ("Runtime error...") in "index.html" at line 3.', $e->getMessage());
|
52 |
$this->assertEquals(3, $e->getTemplateLine());
|
53 |
-
$this->assertEquals('index.html', $e->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
}
|
55 |
}
|
56 |
|
@@ -71,7 +138,7 @@ class Twig_Tests_ErrorTest extends PHPUnit_Framework_TestCase
|
|
71 |
} catch (Twig_Error_Runtime $e) {
|
72 |
$this->assertEquals(sprintf('Variable "foo" does not exist in "%s" at line %d.', $name, $line), $e->getMessage());
|
73 |
$this->assertEquals($line, $e->getTemplateLine());
|
74 |
-
$this->assertEquals($name, $e->
|
75 |
}
|
76 |
|
77 |
try {
|
@@ -81,7 +148,7 @@ class Twig_Tests_ErrorTest extends PHPUnit_Framework_TestCase
|
|
81 |
} catch (Twig_Error_Runtime $e) {
|
82 |
$this->assertEquals(sprintf('An exception has been thrown during the rendering of a template ("Runtime error...") in "%s" at line %d.', $name, $line), $e->getMessage());
|
83 |
$this->assertEquals($line, $e->getTemplateLine());
|
84 |
-
$this->assertEquals($name, $e->
|
85 |
}
|
86 |
}
|
87 |
|
14 |
public function testErrorWithObjectFilename()
|
15 |
{
|
16 |
$error = new Twig_Error('foo');
|
17 |
+
$error->setSourceContext(new Twig_Source('', new SplFileInfo(__FILE__)));
|
18 |
|
19 |
$this->assertContains('test'.DIRECTORY_SEPARATOR.'Twig'.DIRECTORY_SEPARATOR.'Tests'.DIRECTORY_SEPARATOR.'ErrorTest.php', $error->getMessage());
|
20 |
}
|
22 |
public function testErrorWithArrayFilename()
|
23 |
{
|
24 |
$error = new Twig_Error('foo');
|
25 |
+
$error->setSourceContext(new Twig_Source('', array('foo' => 'bar')));
|
26 |
|
27 |
$this->assertEquals('foo in {"foo":"bar"}', $error->getMessage());
|
28 |
}
|
29 |
|
30 |
+
public function testTwigExceptionGuessWithMissingVarAndArrayLoader()
|
31 |
{
|
32 |
+
$loader = new Twig_Loader_Array(array(
|
33 |
+
'base.html' => '{% block content %}{% endblock %}',
|
34 |
+
'index.html' => <<<EOHTML
|
35 |
+
{% extends 'base.html' %}
|
36 |
+
{% block content %}
|
37 |
+
{{ foo.bar }}
|
38 |
+
{% endblock %}
|
39 |
+
{% block foo %}
|
40 |
+
{{ foo.bar }}
|
41 |
+
{% endblock %}
|
42 |
+
EOHTML
|
43 |
+
));
|
44 |
$twig = new Twig_Environment($loader, array('strict_variables' => true, 'debug' => true, 'cache' => false));
|
45 |
|
46 |
$template = $twig->loadTemplate('index.html');
|
51 |
} catch (Twig_Error_Runtime $e) {
|
52 |
$this->assertEquals('Variable "foo" does not exist in "index.html" at line 3.', $e->getMessage());
|
53 |
$this->assertEquals(3, $e->getTemplateLine());
|
54 |
+
$this->assertEquals('index.html', $e->getSourceContext()->getName());
|
55 |
}
|
56 |
+
}
|
57 |
+
|
58 |
+
public function testTwigExceptionGuessWithExceptionAndArrayLoader()
|
59 |
+
{
|
60 |
+
$loader = new Twig_Loader_Array(array(
|
61 |
+
'base.html' => '{% block content %}{% endblock %}',
|
62 |
+
'index.html' => <<<EOHTML
|
63 |
+
{% extends 'base.html' %}
|
64 |
+
{% block content %}
|
65 |
+
{{ foo.bar }}
|
66 |
+
{% endblock %}
|
67 |
+
{% block foo %}
|
68 |
+
{{ foo.bar }}
|
69 |
+
{% endblock %}
|
70 |
+
EOHTML
|
71 |
+
));
|
72 |
+
$twig = new Twig_Environment($loader, array('strict_variables' => true, 'debug' => true, 'cache' => false));
|
73 |
|
74 |
+
$template = $twig->loadTemplate('index.html');
|
75 |
try {
|
76 |
$template->render(array('foo' => new Twig_Tests_ErrorTest_Foo()));
|
77 |
|
79 |
} catch (Twig_Error_Runtime $e) {
|
80 |
$this->assertEquals('An exception has been thrown during the rendering of a template ("Runtime error...") in "index.html" at line 3.', $e->getMessage());
|
81 |
$this->assertEquals(3, $e->getTemplateLine());
|
82 |
+
$this->assertEquals('index.html', $e->getSourceContext()->getName());
|
83 |
+
}
|
84 |
+
}
|
85 |
+
|
86 |
+
public function testTwigExceptionGuessWithMissingVarAndFilesystemLoader()
|
87 |
+
{
|
88 |
+
$loader = new Twig_Loader_Filesystem(dirname(__FILE__).'/Fixtures/errors');
|
89 |
+
$twig = new Twig_Environment($loader, array('strict_variables' => true, 'debug' => true, 'cache' => false));
|
90 |
+
|
91 |
+
$template = $twig->loadTemplate('index.html');
|
92 |
+
try {
|
93 |
+
$template->render(array());
|
94 |
+
|
95 |
+
$this->fail();
|
96 |
+
} catch (Twig_Error_Runtime $e) {
|
97 |
+
$this->assertEquals('Variable "foo" does not exist.', $e->getMessage());
|
98 |
+
$this->assertEquals(3, $e->getTemplateLine());
|
99 |
+
$this->assertEquals('index.html', $e->getSourceContext()->getName());
|
100 |
+
$this->assertEquals(3, $e->getLine());
|
101 |
+
$this->assertEquals(strtr(dirname(__FILE__).'/Fixtures/errors/index.html', '/', DIRECTORY_SEPARATOR), $e->getFile());
|
102 |
+
}
|
103 |
+
}
|
104 |
+
|
105 |
+
public function testTwigExceptionGuessWithExceptionAndFilesystemLoader()
|
106 |
+
{
|
107 |
+
$loader = new Twig_Loader_Filesystem(dirname(__FILE__).'/Fixtures/errors');
|
108 |
+
$twig = new Twig_Environment($loader, array('strict_variables' => true, 'debug' => true, 'cache' => false));
|
109 |
+
|
110 |
+
$template = $twig->loadTemplate('index.html');
|
111 |
+
try {
|
112 |
+
$template->render(array('foo' => new Twig_Tests_ErrorTest_Foo()));
|
113 |
+
|
114 |
+
$this->fail();
|
115 |
+
} catch (Twig_Error_Runtime $e) {
|
116 |
+
$this->assertEquals('An exception has been thrown during the rendering of a template ("Runtime error...").', $e->getMessage());
|
117 |
+
$this->assertEquals(3, $e->getTemplateLine());
|
118 |
+
$this->assertEquals('index.html', $e->getSourceContext()->getName());
|
119 |
+
$this->assertEquals(3, $e->getLine());
|
120 |
+
$this->assertEquals(strtr(dirname(__FILE__).'/Fixtures/errors/index.html', '/', DIRECTORY_SEPARATOR), $e->getFile());
|
121 |
}
|
122 |
}
|
123 |
|
138 |
} catch (Twig_Error_Runtime $e) {
|
139 |
$this->assertEquals(sprintf('Variable "foo" does not exist in "%s" at line %d.', $name, $line), $e->getMessage());
|
140 |
$this->assertEquals($line, $e->getTemplateLine());
|
141 |
+
$this->assertEquals($name, $e->getSourceContext()->getName());
|
142 |
}
|
143 |
|
144 |
try {
|
148 |
} catch (Twig_Error_Runtime $e) {
|
149 |
$this->assertEquals(sprintf('An exception has been thrown during the rendering of a template ("Runtime error...") in "%s" at line %d.', $name, $line), $e->getMessage());
|
150 |
$this->assertEquals($line, $e->getTemplateLine());
|
151 |
+
$this->assertEquals($name, $e->getSourceContext()->getName());
|
152 |
}
|
153 |
}
|
154 |
|
vendor/twig/twig/test/Twig/Tests/Extension/CoreTest.php
CHANGED
@@ -115,14 +115,24 @@ class Twig_Tests_Extension_CoreTest extends PHPUnit_Framework_TestCase
|
|
115 |
$this->assertEquals($output, 'éÄ');
|
116 |
}
|
117 |
|
118 |
-
|
|
|
|
|
|
|
119 |
{
|
120 |
$twig = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock());
|
121 |
$twig->getExtension('Twig_Extension_Core')->setEscaper('foo', 'foo_escaper_for_test');
|
122 |
|
123 |
-
$this->
|
124 |
-
|
125 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
126 |
}
|
127 |
|
128 |
/**
|
@@ -133,22 +143,129 @@ class Twig_Tests_Extension_CoreTest extends PHPUnit_Framework_TestCase
|
|
133 |
twig_escape_filter(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()), 'foo', 'bar');
|
134 |
}
|
135 |
|
136 |
-
|
|
|
|
|
|
|
137 |
{
|
138 |
$twig = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock());
|
139 |
-
$this->
|
140 |
-
$this->assertEquals(1, twig_first($twig, array(1, 2, 3)));
|
141 |
-
$this->assertSame('', twig_first($twig, null));
|
142 |
-
$this->assertSame('', twig_first($twig, ''));
|
143 |
}
|
144 |
|
145 |
-
public function
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
146 |
{
|
147 |
$twig = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock());
|
148 |
-
$this->
|
149 |
-
|
150 |
-
|
151 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
152 |
}
|
153 |
}
|
154 |
|
@@ -156,3 +273,83 @@ function foo_escaper_for_test(Twig_Environment $env, $string, $charset)
|
|
156 |
{
|
157 |
return $string.$charset;
|
158 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
115 |
$this->assertEquals($output, 'éÄ');
|
116 |
}
|
117 |
|
118 |
+
/**
|
119 |
+
* @dataProvider provideCustomEscaperCases
|
120 |
+
*/
|
121 |
+
public function testCustomEscaper($expected, $string, $strategy)
|
122 |
{
|
123 |
$twig = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock());
|
124 |
$twig->getExtension('Twig_Extension_Core')->setEscaper('foo', 'foo_escaper_for_test');
|
125 |
|
126 |
+
$this->assertSame($expected, twig_escape_filter($twig, $string, $strategy));
|
127 |
+
}
|
128 |
+
|
129 |
+
public function provideCustomEscaperCases()
|
130 |
+
{
|
131 |
+
return array(
|
132 |
+
array('fooUTF-8', 'foo', 'foo'),
|
133 |
+
array('UTF-8', null, 'foo'),
|
134 |
+
array('42UTF-8', 42, 'foo'),
|
135 |
+
);
|
136 |
}
|
137 |
|
138 |
/**
|
143 |
twig_escape_filter(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()), 'foo', 'bar');
|
144 |
}
|
145 |
|
146 |
+
/**
|
147 |
+
* @dataProvider provideTwigFirstCases
|
148 |
+
*/
|
149 |
+
public function testTwigFirst($expected, $input)
|
150 |
{
|
151 |
$twig = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock());
|
152 |
+
$this->assertSame($expected, twig_first($twig, $input));
|
|
|
|
|
|
|
153 |
}
|
154 |
|
155 |
+
public function provideTwigFirstCases()
|
156 |
+
{
|
157 |
+
$i = array(1 => 'a', 2 => 'b', 3 => 'c');
|
158 |
+
|
159 |
+
return array(
|
160 |
+
array('a', 'abc'),
|
161 |
+
array(1, array(1, 2, 3)),
|
162 |
+
array('', null),
|
163 |
+
array('', ''),
|
164 |
+
array('a', new CoreTestIterator($i, array_keys($i), true, 3)),
|
165 |
+
);
|
166 |
+
}
|
167 |
+
|
168 |
+
/**
|
169 |
+
* @dataProvider provideTwigLastCases
|
170 |
+
*/
|
171 |
+
public function testTwigLast($expected, $input)
|
172 |
{
|
173 |
$twig = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock());
|
174 |
+
$this->assertSame($expected, twig_last($twig, $input));
|
175 |
+
}
|
176 |
+
|
177 |
+
public function provideTwigLastCases()
|
178 |
+
{
|
179 |
+
$i = array(1 => 'a', 2 => 'b', 3 => 'c');
|
180 |
+
|
181 |
+
return array(
|
182 |
+
array('c', 'abc'),
|
183 |
+
array(3, array(1, 2, 3)),
|
184 |
+
array('', null),
|
185 |
+
array('', ''),
|
186 |
+
array('c', new CoreTestIterator($i, array_keys($i), true)),
|
187 |
+
);
|
188 |
+
}
|
189 |
+
|
190 |
+
/**
|
191 |
+
* @dataProvider provideArrayKeyCases
|
192 |
+
*/
|
193 |
+
public function testArrayKeysFilter(array $expected, $input)
|
194 |
+
{
|
195 |
+
$this->assertSame($expected, twig_get_array_keys_filter($input));
|
196 |
+
}
|
197 |
+
|
198 |
+
public function provideArrayKeyCases()
|
199 |
+
{
|
200 |
+
$array = array('a' => 'a1', 'b' => 'b1', 'c' => 'c1');
|
201 |
+
$keys = array_keys($array);
|
202 |
+
|
203 |
+
return array(
|
204 |
+
array($keys, $array),
|
205 |
+
array($keys, new CoreTestIterator($array, $keys)),
|
206 |
+
array($keys, new CoreTestIteratorAggregate($array, $keys)),
|
207 |
+
array($keys, new CoreTestIteratorAggregateAggregate($array, $keys)),
|
208 |
+
array(array(), null),
|
209 |
+
array(array('a'), new SimpleXMLElement('<xml><a></a></xml>')),
|
210 |
+
);
|
211 |
+
}
|
212 |
+
|
213 |
+
/**
|
214 |
+
* @dataProvider provideInFilterCases
|
215 |
+
*/
|
216 |
+
public function testInFilter($expected, $value, $compare)
|
217 |
+
{
|
218 |
+
$this->assertSame($expected, twig_in_filter($value, $compare));
|
219 |
+
}
|
220 |
+
|
221 |
+
public function provideInFilterCases()
|
222 |
+
{
|
223 |
+
$array = array(1, 2, 'a' => 3, 5, 6, 7);
|
224 |
+
$keys = array_keys($array);
|
225 |
+
|
226 |
+
return array(
|
227 |
+
array(true, 1, $array),
|
228 |
+
array(true, '3', $array),
|
229 |
+
array(true, '3', 'abc3def'),
|
230 |
+
array(true, 1, new CoreTestIterator($array, $keys, true, 1)),
|
231 |
+
array(true, '3', new CoreTestIterator($array, $keys, true, 3)),
|
232 |
+
array(true, '3', new CoreTestIteratorAggregateAggregate($array, $keys, true, 3)),
|
233 |
+
array(false, 4, $array),
|
234 |
+
array(false, 4, new CoreTestIterator($array, $keys, true)),
|
235 |
+
array(false, 4, new CoreTestIteratorAggregateAggregate($array, $keys, true)),
|
236 |
+
array(false, 1, 1),
|
237 |
+
array(true, 'b', new SimpleXMLElement('<xml><a>b</a></xml>')),
|
238 |
+
);
|
239 |
+
}
|
240 |
+
|
241 |
+
/**
|
242 |
+
* @dataProvider provideSliceFilterCases
|
243 |
+
*/
|
244 |
+
public function testSliceFilter($expected, $input, $start, $length = null, $preserveKeys = false)
|
245 |
+
{
|
246 |
+
$twig = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock());
|
247 |
+
$this->assertSame($expected, twig_slice($twig, $input, $start, $length, $preserveKeys));
|
248 |
+
}
|
249 |
+
|
250 |
+
public function provideSliceFilterCases()
|
251 |
+
{
|
252 |
+
$i = array('a' => 1, 'b' => 2, 'c' => 3, 'd' => 4);
|
253 |
+
$keys = array_keys($i);
|
254 |
+
|
255 |
+
return array(
|
256 |
+
array(array('a' => 1), $i, 0, 1, true),
|
257 |
+
array(array('a' => 1), $i, 0, 1, false),
|
258 |
+
array(array('b' => 2, 'c' => 3), $i, 1, 2),
|
259 |
+
array(array(1), array(1, 2, 3, 4), 0, 1),
|
260 |
+
array(array(2, 3), array(1, 2, 3, 4), 1, 2),
|
261 |
+
array(array(2, 3), new CoreTestIterator($i, $keys, true), 1, 2),
|
262 |
+
array(array('c' => 3, 'd' => 4), new CoreTestIteratorAggregate($i, $keys, true), 2, null, true),
|
263 |
+
array($i, new CoreTestIterator($i, $keys, true), 0, count($keys) + 10, true),
|
264 |
+
array(array(), new CoreTestIterator($i, $keys, true), count($keys) + 10),
|
265 |
+
array('de', 'abcdef', 3, 2),
|
266 |
+
array(array(), new SimpleXMLElement('<items><item>1</item><item>2</item></items>'), 3),
|
267 |
+
array(array(), new ArrayIterator(array(1, 2)), 3)
|
268 |
+
);
|
269 |
}
|
270 |
}
|
271 |
|
273 |
{
|
274 |
return $string.$charset;
|
275 |
}
|
276 |
+
|
277 |
+
final class CoreTestIteratorAggregate implements IteratorAggregate
|
278 |
+
{
|
279 |
+
private $iterator;
|
280 |
+
|
281 |
+
public function __construct(array $array, array $keys, $allowAccess = false, $maxPosition = false)
|
282 |
+
{
|
283 |
+
$this->iterator = new CoreTestIterator($array, $keys, $allowAccess, $maxPosition);
|
284 |
+
}
|
285 |
+
|
286 |
+
public function getIterator()
|
287 |
+
{
|
288 |
+
return $this->iterator;
|
289 |
+
}
|
290 |
+
}
|
291 |
+
|
292 |
+
final class CoreTestIteratorAggregateAggregate implements IteratorAggregate
|
293 |
+
{
|
294 |
+
private $iterator;
|
295 |
+
|
296 |
+
public function __construct(array $array, array $keys, $allowValueAccess = false, $maxPosition = false)
|
297 |
+
{
|
298 |
+
$this->iterator = new CoreTestIteratorAggregate($array, $keys, $allowValueAccess, $maxPosition);
|
299 |
+
}
|
300 |
+
|
301 |
+
public function getIterator()
|
302 |
+
{
|
303 |
+
return $this->iterator;
|
304 |
+
}
|
305 |
+
}
|
306 |
+
|
307 |
+
final class CoreTestIterator implements Iterator
|
308 |
+
{
|
309 |
+
private $position;
|
310 |
+
private $array;
|
311 |
+
private $arrayKeys;
|
312 |
+
private $allowValueAccess;
|
313 |
+
private $maxPosition;
|
314 |
+
|
315 |
+
public function __construct(array $values, array $keys, $allowValueAccess = false, $maxPosition = false)
|
316 |
+
{
|
317 |
+
$this->array = $values;
|
318 |
+
$this->arrayKeys = $keys;
|
319 |
+
$this->position = 0;
|
320 |
+
$this->allowValueAccess = $allowValueAccess;
|
321 |
+
$this->maxPosition = false === $maxPosition ? count($values) + 1 : $maxPosition;
|
322 |
+
}
|
323 |
+
|
324 |
+
public function rewind()
|
325 |
+
{
|
326 |
+
$this->position = 0;
|
327 |
+
}
|
328 |
+
|
329 |
+
public function current()
|
330 |
+
{
|
331 |
+
if ($this->allowValueAccess) {
|
332 |
+
return $this->array[$this->key()];
|
333 |
+
}
|
334 |
+
|
335 |
+
throw new LogicException('Code should only use the keys, not the values provided by iterator.');
|
336 |
+
}
|
337 |
+
|
338 |
+
public function key()
|
339 |
+
{
|
340 |
+
return $this->arrayKeys[$this->position];
|
341 |
+
}
|
342 |
+
|
343 |
+
public function next()
|
344 |
+
{
|
345 |
+
++$this->position;
|
346 |
+
if ($this->position === $this->maxPosition) {
|
347 |
+
throw new LogicException(sprintf('Code should not iterate beyond %d.', $this->maxPosition));
|
348 |
+
}
|
349 |
+
}
|
350 |
+
|
351 |
+
public function valid()
|
352 |
+
{
|
353 |
+
return isset($this->arrayKeys[$this->position]);
|
354 |
+
}
|
355 |
+
}
|
vendor/twig/twig/test/Twig/Tests/Extension/SandboxTest.php
CHANGED
@@ -11,7 +11,8 @@
|
|
11 |
|
12 |
class Twig_Tests_Extension_SandboxTest extends PHPUnit_Framework_TestCase
|
13 |
{
|
14 |
-
protected static $params
|
|
|
15 |
|
16 |
protected function setUp()
|
17 |
{
|
@@ -34,6 +35,7 @@ class Twig_Tests_Extension_SandboxTest extends PHPUnit_Framework_TestCase
|
|
34 |
'1_basic' => '{% if obj.foo %}{{ obj.foo|upper }}{% endif %}',
|
35 |
'1_layout' => '{% block content %}{% endblock %}',
|
36 |
'1_child' => "{% extends \"1_layout\" %}\n{% block content %}\n{{ \"a\"|json_encode }}\n{% endblock %}",
|
|
|
37 |
);
|
38 |
}
|
39 |
|
@@ -240,6 +242,23 @@ EOF
|
|
240 |
$this->assertEquals('<p>username</p>', $twig->loadTemplate('index')->render(array()));
|
241 |
}
|
242 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
243 |
protected function getEnvironment($sandboxed, $options, $templates, $tags = array(), $filters = array(), $methods = array(), $properties = array(), $functions = array())
|
244 |
{
|
245 |
$loader = new Twig_Loader_Array($templates);
|
11 |
|
12 |
class Twig_Tests_Extension_SandboxTest extends PHPUnit_Framework_TestCase
|
13 |
{
|
14 |
+
protected static $params;
|
15 |
+
protected static $templates;
|
16 |
|
17 |
protected function setUp()
|
18 |
{
|
35 |
'1_basic' => '{% if obj.foo %}{{ obj.foo|upper }}{% endif %}',
|
36 |
'1_layout' => '{% block content %}{% endblock %}',
|
37 |
'1_child' => "{% extends \"1_layout\" %}\n{% block content %}\n{{ \"a\"|json_encode }}\n{% endblock %}",
|
38 |
+
'1_include' => '{{ include("1_basic1", sandboxed=true) }}',
|
39 |
);
|
40 |
}
|
41 |
|
242 |
$this->assertEquals('<p>username</p>', $twig->loadTemplate('index')->render(array()));
|
243 |
}
|
244 |
|
245 |
+
public function testSandboxDisabledAfterIncludeFunctionError()
|
246 |
+
{
|
247 |
+
$twig = $this->getEnvironment(false, array(), self::$templates);
|
248 |
+
|
249 |
+
$e = null;
|
250 |
+
try {
|
251 |
+
$twig->loadTemplate('1_include')->render(self::$params);
|
252 |
+
} catch (Throwable $e) {
|
253 |
+
} catch (Exception $e) {
|
254 |
+
}
|
255 |
+
if ($e === null) {
|
256 |
+
$this->fail('An exception should be thrown for this test to be valid.');
|
257 |
+
}
|
258 |
+
|
259 |
+
$this->assertFalse($twig->getExtension('Twig_Extension_Sandbox')->isSandboxed(), 'Sandboxed include() function call should not leave Sandbox enabled when an error occurs.');
|
260 |
+
}
|
261 |
+
|
262 |
protected function getEnvironment($sandboxed, $options, $templates, $tags = array(), $filters = array(), $methods = array(), $properties = array(), $functions = array())
|
263 |
{
|
264 |
$loader = new Twig_Loader_Array($templates);
|
vendor/twig/twig/test/Twig/Tests/FileCachingTest.php
CHANGED
@@ -44,7 +44,7 @@ class Twig_Tests_FileCachingTest extends PHPUnit_Framework_TestCase
|
|
44 |
$this->env->loadTemplate($name);
|
45 |
$cacheFileName = $this->env->getCacheFilename($name);
|
46 |
|
47 |
-
$this->
|
48 |
}
|
49 |
|
50 |
/**
|
@@ -56,8 +56,8 @@ class Twig_Tests_FileCachingTest extends PHPUnit_Framework_TestCase
|
|
56 |
$this->env->loadTemplate($name);
|
57 |
$cacheFileName = $this->env->getCacheFilename($name);
|
58 |
|
59 |
-
$this->
|
60 |
$this->env->clearCacheFiles();
|
61 |
-
$this->
|
62 |
}
|
63 |
}
|
44 |
$this->env->loadTemplate($name);
|
45 |
$cacheFileName = $this->env->getCacheFilename($name);
|
46 |
|
47 |
+
$this->assertFileExists($cacheFileName, 'Cache file does not exist.');
|
48 |
}
|
49 |
|
50 |
/**
|
56 |
$this->env->loadTemplate($name);
|
57 |
$cacheFileName = $this->env->getCacheFilename($name);
|
58 |
|
59 |
+
$this->assertFileExists($cacheFileName, 'Cache file does not exist.');
|
60 |
$this->env->clearCacheFiles();
|
61 |
+
$this->assertFileNotExists($cacheFileName, 'Cache file was not cleared.');
|
62 |
}
|
63 |
}
|
vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/_self.test
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
--TEST--
|
2 |
+
_self returns the template name
|
3 |
+
--TEMPLATE--
|
4 |
+
{{ _self }}
|
5 |
+
--DATA--
|
6 |
+
return array()
|
7 |
+
--EXPECT--
|
8 |
+
index.twig
|
vendor/twig/twig/test/Twig/Tests/Fixtures/functions/recursive_block_with_inheritance.test
CHANGED
@@ -12,7 +12,7 @@
|
|
12 |
{% block list %}<ul>{{ block('children') }}</ul>{% endblock %}
|
13 |
{% block children %}{% set currentItem = item %}{% for item in currentItem %}{{ block('item') }}{% endfor %}{% set item = currentItem %}{% endblock %}
|
14 |
{% block item %}<li>{% if item is not iterable %}{{ block('label') }}{% else %}{{ block('list') }}{% endif %}</li>{% endblock %}
|
15 |
-
{% block label %}{{ item }}{
|
16 |
--TEMPLATE(base.twig)--
|
17 |
{{ block('list') }}
|
18 |
--DATA--
|
12 |
{% block list %}<ul>{{ block('children') }}</ul>{% endblock %}
|
13 |
{% block children %}{% set currentItem = item %}{% for item in currentItem %}{{ block('item') }}{% endfor %}{% set item = currentItem %}{% endblock %}
|
14 |
{% block item %}<li>{% if item is not iterable %}{{ block('label') }}{% else %}{{ block('list') }}{% endif %}</li>{% endblock %}
|
15 |
+
{% block label %}{{ item }}{% endblock %}
|
16 |
--TEMPLATE(base.twig)--
|
17 |
{{ block('list') }}
|
18 |
--DATA--
|
vendor/twig/twig/test/Twig/Tests/LegacyFixtures/functions/undefined_block.legacy.test
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
--TEST--
|
2 |
+
"block" function with undefined block
|
3 |
+
--TEMPLATE--
|
4 |
+
{% extends "base.twig" %}
|
5 |
+
{% block foo %}{{ parent() }}{{ block('unknown') }}{{ block('bar') }}{% endblock %}
|
6 |
+
--TEMPLATE(base.twig)--
|
7 |
+
{% block foo %}Foo{% endblock %}
|
8 |
+
{% block bar %}Bar{% endblock %}
|
9 |
+
--DATA--
|
10 |
+
return array()
|
11 |
+
--EXPECT--
|
12 |
+
FooBarBar
|
vendor/twig/twig/test/Twig/Tests/Loader/ChainTest.php
CHANGED
@@ -98,7 +98,7 @@ class Twig_Tests_Loader_ChainTest extends PHPUnit_Framework_TestCase
|
|
98 |
|
99 |
public function testExists()
|
100 |
{
|
101 |
-
$loader1 = $this->getMockBuilder('
|
102 |
$loader1->expects($this->once())->method('exists')->will($this->returnValue(false));
|
103 |
$loader1->expects($this->never())->method('getSourceContext');
|
104 |
|
@@ -118,3 +118,7 @@ class Twig_Tests_Loader_ChainTest extends PHPUnit_Framework_TestCase
|
|
118 |
interface Twig_ChainTestLoaderInterface extends Twig_LoaderInterface, Twig_SourceContextLoaderInterface
|
119 |
{
|
120 |
}
|
|
|
|
|
|
|
|
98 |
|
99 |
public function testExists()
|
100 |
{
|
101 |
+
$loader1 = $this->getMockBuilder('Twig_ChainTestLoaderWithExistsInterface')->getMock();
|
102 |
$loader1->expects($this->once())->method('exists')->will($this->returnValue(false));
|
103 |
$loader1->expects($this->never())->method('getSourceContext');
|
104 |
|
118 |
interface Twig_ChainTestLoaderInterface extends Twig_LoaderInterface, Twig_SourceContextLoaderInterface
|
119 |
{
|
120 |
}
|
121 |
+
|
122 |
+
interface Twig_ChainTestLoaderWithExistsInterface extends Twig_LoaderInterface, Twig_ExistsLoaderInterface, Twig_SourceContextLoaderInterface
|
123 |
+
{
|
124 |
+
}
|
vendor/twig/twig/test/Twig/Tests/ParserTest.php
CHANGED
@@ -155,8 +155,7 @@ EOF
|
|
155 |
{
|
156 |
$parser = new TestParser(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()));
|
157 |
$parser->setParent(new Twig_Node());
|
158 |
-
$parser->stream =
|
159 |
-
$parser->stream->expects($this->any())->method('getSourceContext')->will($this->returnValue(new Twig_Source('', '')));
|
160 |
|
161 |
return $parser;
|
162 |
}
|
155 |
{
|
156 |
$parser = new TestParser(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()));
|
157 |
$parser->setParent(new Twig_Node());
|
158 |
+
$parser->stream = new Twig_TokenStream(array());
|
|
|
159 |
|
160 |
return $parser;
|
161 |
}
|
vendor/twig/twig/test/Twig/Tests/RuntimeFactoryLoaderTest.php
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
class Twig_Tests_FactoryRuntimeLoaderTest extends PHPUnit_Framework_TestCase
|
13 |
+
{
|
14 |
+
public function testLoad()
|
15 |
+
{
|
16 |
+
$loader = new Twig_FactoryRuntimeLoader(array('stdClass' => 'getRuntime'));
|
17 |
+
|
18 |
+
$this->assertInstanceOf('stdClass', $loader->load('stdClass'));
|
19 |
+
}
|
20 |
+
|
21 |
+
public function testLoadReturnsNullForUnmappedRuntime()
|
22 |
+
{
|
23 |
+
$loader = new Twig_FactoryRuntimeLoader();
|
24 |
+
|
25 |
+
$this->assertNull($loader->load('stdClass'));
|
26 |
+
}
|
27 |
+
}
|
28 |
+
|
29 |
+
function getRuntime()
|
30 |
+
{
|
31 |
+
return new stdClass();
|
32 |
+
}
|
vendor/twig/twig/test/Twig/Tests/TemplateTest.php
CHANGED
@@ -22,18 +22,11 @@ class Twig_Tests_TemplateTest extends PHPUnit_Framework_TestCase
|
|
22 |
/**
|
23 |
* @dataProvider getAttributeExceptions
|
24 |
*/
|
25 |
-
public function testGetAttributeExceptions($template, $message
|
26 |
{
|
27 |
-
$
|
28 |
-
$templates = array(
|
29 |
-
$name => $template.$useExt, // appending $useExt makes the template content unique
|
30 |
-
);
|
31 |
-
|
32 |
$env = new Twig_Environment(new Twig_Loader_Array($templates), array('strict_variables' => true));
|
33 |
-
|
34 |
-
$env->addNodeVisitor(new CExtDisablingNodeVisitor());
|
35 |
-
}
|
36 |
-
$template = $env->loadTemplate($name);
|
37 |
|
38 |
$context = array(
|
39 |
'string' => 'foo',
|
@@ -49,50 +42,41 @@ class Twig_Tests_TemplateTest extends PHPUnit_Framework_TestCase
|
|
49 |
$template->render($context);
|
50 |
$this->fail('Accessing an invalid attribute should throw an exception.');
|
51 |
} catch (Twig_Error_Runtime $e) {
|
52 |
-
$this->assertSame(sprintf($message,
|
53 |
}
|
54 |
}
|
55 |
|
56 |
public function getAttributeExceptions()
|
57 |
{
|
58 |
-
|
59 |
-
array('{{ string["a"] }}', 'Impossible to access a key ("a") on a string variable ("foo") in "%s" at line 1.'
|
60 |
-
array('{{ null["a"] }}', 'Impossible to access a key ("a") on a null variable in "%s" at line 1.'
|
61 |
-
array('{{ empty_array["a"] }}', 'Key "a" does not exist as the array is empty in "%s" at line 1.'
|
62 |
-
array('{{ array["a"] }}', 'Key "a" for array with keys "foo" does not exist in "%s" at line 1.'
|
63 |
-
array('{{ array_access["a"] }}', 'Key "a" in object with ArrayAccess of class "Twig_TemplateArrayAccessObject" does not exist in "%s" at line 1.'
|
64 |
-
array('{{ string.a }}', 'Impossible to access an attribute ("a") on a string variable ("foo") in "%s" at line 1.'
|
65 |
-
array('{{ string.a() }}', 'Impossible to invoke a method ("a") on a string variable ("foo") in "%s" at line 1.'
|
66 |
-
array('{{ null.a }}', 'Impossible to access an attribute ("a") on a null variable in "%s" at line 1.'
|
67 |
-
array('{{ null.a() }}', 'Impossible to invoke a method ("a") on a null variable in "%s" at line 1.'
|
68 |
-
array('{{ empty_array.a }}', 'Key "a" does not exist as the array is empty in "%s" at line 1.'
|
69 |
-
array('{{ array.a }}', 'Key "a" for array with keys "foo" does not exist in "%s" at line 1.'
|
70 |
-
array('{{ attribute(array, -10) }}', 'Key "-10" for array with keys "foo" does not exist in "%s" at line 1.'
|
71 |
-
array('{{ array_access.a }}', 'Neither the property "a" nor one of the methods "a()", "geta()"/"isa()" or "__call()" exist and have public access in class "Twig_TemplateArrayAccessObject" in "%s" at line 1.'
|
72 |
-
array('{% from _self import foo %}{% macro foo(obj) %}{{ obj.missing_method() }}{% endmacro %}{{ foo(array_access) }}', 'Neither the property "missing_method" nor one of the methods "missing_method()", "getmissing_method()"/"ismissing_method()" or "__call()" exist and have public access in class "Twig_TemplateArrayAccessObject" in "%s" at line 1.'
|
73 |
-
array('{{ magic_exception.test }}', 'An exception has been thrown during the rendering of a template ("Hey! Don\'t try to isset me!") in "%s" at line 1.'
|
74 |
-
array('{{ object["a"] }}', 'Impossible to access a key "a" on an object of class "stdClass" that does not implement ArrayAccess interface in "%s" at line 1.'
|
75 |
);
|
76 |
-
|
77 |
-
if (function_exists('twig_template_get_attributes')) {
|
78 |
-
foreach (array_slice($tests, 0) as $test) {
|
79 |
-
$test[2] = true;
|
80 |
-
$tests[] = $test;
|
81 |
-
}
|
82 |
-
}
|
83 |
-
|
84 |
-
return $tests;
|
85 |
}
|
86 |
|
87 |
/**
|
88 |
* @dataProvider getGetAttributeWithSandbox
|
89 |
*/
|
90 |
-
public function testGetAttributeWithSandbox($object, $item, $allowed
|
91 |
{
|
92 |
$twig = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock());
|
93 |
$policy = new Twig_Sandbox_SecurityPolicy(array(), array(), array(/*method*/), array(/*prop*/), array());
|
94 |
$twig->addExtension(new Twig_Extension_Sandbox($policy, !$allowed));
|
95 |
-
$template = new Twig_TemplateTest($twig
|
96 |
|
97 |
try {
|
98 |
$template->getAttribute($object, $item, array(), 'any');
|
@@ -111,35 +95,25 @@ class Twig_Tests_TemplateTest extends PHPUnit_Framework_TestCase
|
|
111 |
|
112 |
public function getGetAttributeWithSandbox()
|
113 |
{
|
114 |
-
|
115 |
-
array(new Twig_TemplatePropertyObject(), 'defined', false
|
116 |
-
array(new Twig_TemplatePropertyObject(), 'defined', true
|
117 |
-
array(new Twig_TemplateMethodObject(), 'defined', false
|
118 |
-
array(new Twig_TemplateMethodObject(), 'defined', true
|
119 |
);
|
120 |
-
|
121 |
-
if (function_exists('twig_template_get_attributes')) {
|
122 |
-
foreach (array_slice($tests, 0) as $test) {
|
123 |
-
$test[3] = true;
|
124 |
-
$tests[] = $test;
|
125 |
-
}
|
126 |
-
}
|
127 |
-
|
128 |
-
return $tests;
|
129 |
}
|
130 |
|
131 |
/**
|
132 |
-
* @dataProvider getGetAttributeWithTemplateAsObject
|
133 |
* @group legacy
|
134 |
*/
|
135 |
-
public function testGetAttributeWithTemplateAsObject(
|
136 |
{
|
137 |
// to be removed in 2.0
|
138 |
$twig = new Twig_Environment($this->getMockBuilder('Twig_TemplateTestLoaderInterface')->getMock());
|
139 |
//$twig = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface', 'Twig_SourceContextLoaderInterface')->getMock());
|
140 |
|
141 |
-
$template = new Twig_TemplateTest($twig,
|
142 |
-
$template1 = new Twig_TemplateTest($twig,
|
143 |
|
144 |
$this->assertInstanceof('Twig_Markup', $template->getAttribute($template1, 'string'));
|
145 |
$this->assertEquals('some_string', $template->getAttribute($template1, 'string'));
|
@@ -159,29 +133,16 @@ class Twig_Tests_TemplateTest extends PHPUnit_Framework_TestCase
|
|
159 |
$this->assertFalse($template->getAttribute($template1, 'displayWithErrorHandling', array(), Twig_Template::METHOD_CALL, true));
|
160 |
}
|
161 |
|
162 |
-
public function getGetAttributeWithTemplateAsObject()
|
163 |
-
{
|
164 |
-
$bools = array(
|
165 |
-
array(false),
|
166 |
-
);
|
167 |
-
|
168 |
-
if (function_exists('twig_template_get_attributes')) {
|
169 |
-
$bools[] = array(true);
|
170 |
-
}
|
171 |
-
|
172 |
-
return $bools;
|
173 |
-
}
|
174 |
-
|
175 |
/**
|
176 |
* @group legacy
|
177 |
-
* @expectedDeprecation Calling "
|
178 |
-
* @expectedDeprecation Calling "
|
179 |
-
* @expectedDeprecation Calling "
|
180 |
-
* @expectedDeprecation Calling "
|
181 |
-
* @expectedDeprecation Calling "
|
182 |
-
* @expectedDeprecation Calling "
|
183 |
-
* @expectedDeprecation Calling "
|
184 |
-
* @expectedDeprecation Calling "
|
185 |
* @expectedDeprecation Calling "renderBlock" on template "index.twig" from template "index.twig" is deprecated since version 1.28 and won't be supported anymore in 2.0. Use block("name") instead).
|
186 |
* @expectedDeprecation Calling "displayBlock" on template "index.twig" from template "index.twig" is deprecated since version 1.28 and won't be supported anymore in 2.0. Use block("name") instead).
|
187 |
* @expectedDeprecation Calling "hasBlock" on template "index.twig" from template "index.twig" is deprecated since version 1.28 and won't be supported anymore in 2.0. Use "block("name") is defined" instead).
|
@@ -199,8 +160,8 @@ class Twig_Tests_TemplateTest extends PHPUnit_Framework_TestCase
|
|
199 |
$twig = new Twig_Environment($this->getMockBuilder('Twig_TemplateTestLoaderInterface')->getMock());
|
200 |
//$twig = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface', 'Twig_SourceContextLoaderInterface')->getMock());
|
201 |
|
202 |
-
$template = new Twig_TemplateTest($twig,
|
203 |
-
$template1 = new Twig_TemplateTest($twig,
|
204 |
|
205 |
$this->assertInstanceof('Twig_Markup', $template->getAttribute($template1, 'string'));
|
206 |
$this->assertEquals('some_string', $template->getAttribute($template1, 'string'));
|
@@ -214,15 +175,17 @@ class Twig_Tests_TemplateTest extends PHPUnit_Framework_TestCase
|
|
214 |
$this->assertNotInstanceof('Twig_Markup', $template->getAttribute($template1, 'empty'));
|
215 |
$this->assertSame('', $template->getAttribute($template1, 'empty'));
|
216 |
|
|
|
|
|
217 |
// trigger some deprecation notice messages to check them with @expectedDeprecation
|
218 |
-
$template->getAttribute($template, 'renderBlock', array('name', array()));
|
219 |
-
$template->getAttribute($template, 'displayBlock', array('name', array()));
|
220 |
$template->getAttribute($template, 'hasBlock', array('name', array()));
|
221 |
$template->getAttribute($template, 'render', array(array()));
|
222 |
$template->getAttribute($template, 'display', array(array()));
|
223 |
|
224 |
-
$template->getAttribute($template1, 'renderBlock', array('name', array()));
|
225 |
-
$template->getAttribute($template1, 'displayBlock', array('name', array()));
|
226 |
$template->getAttribute($template1, 'hasBlock', array('name', array()));
|
227 |
$template->getAttribute($template1, 'render', array(array()));
|
228 |
$template->getAttribute($template1, 'display', array(array()));
|
@@ -234,14 +197,22 @@ class Twig_Tests_TemplateTest extends PHPUnit_Framework_TestCase
|
|
234 |
}
|
235 |
|
236 |
/**
|
237 |
-
* @
|
|
|
|
|
238 |
*/
|
239 |
-
public function
|
240 |
{
|
241 |
-
$
|
242 |
-
|
243 |
-
|
244 |
-
);
|
|
|
|
|
|
|
|
|
|
|
|
|
245 |
|
246 |
$array = array('Zero', 'One', -1 => 'MinusOne', '' => 'EmptyString', '1.5' => 'FloatButString', '01' => 'IntegerButStringWithLeadingZeros');
|
247 |
|
@@ -264,21 +235,12 @@ class Twig_Tests_TemplateTest extends PHPUnit_Framework_TestCase
|
|
264 |
$this->assertSame('EmptyString', $template->getAttribute($array, null), 'null is treated as "" when accessing an array (equals PHP behavior)');
|
265 |
}
|
266 |
|
267 |
-
public function getTestsDependingOnExtensionAvailability()
|
268 |
-
{
|
269 |
-
if (function_exists('twig_template_get_attributes')) {
|
270 |
-
return array(array(false), array(true));
|
271 |
-
}
|
272 |
-
|
273 |
-
return array(array(false));
|
274 |
-
}
|
275 |
-
|
276 |
/**
|
277 |
* @dataProvider getGetAttributeTests
|
278 |
*/
|
279 |
-
public function testGetAttribute($defined, $value, $object, $item, $arguments, $type
|
280 |
{
|
281 |
-
$template = new Twig_TemplateTest(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock())
|
282 |
|
283 |
$this->assertEquals($value, $template->getAttribute($object, $item, $arguments, $type));
|
284 |
}
|
@@ -286,9 +248,9 @@ class Twig_Tests_TemplateTest extends PHPUnit_Framework_TestCase
|
|
286 |
/**
|
287 |
* @dataProvider getGetAttributeTests
|
288 |
*/
|
289 |
-
public function testGetAttributeStrict($defined, $value, $object, $item, $arguments, $type, $
|
290 |
{
|
291 |
-
$template = new Twig_TemplateTest(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('strict_variables' => true))
|
292 |
|
293 |
if ($defined) {
|
294 |
$this->assertEquals($value, $template->getAttribute($object, $item, $arguments, $type));
|
@@ -308,9 +270,9 @@ class Twig_Tests_TemplateTest extends PHPUnit_Framework_TestCase
|
|
308 |
/**
|
309 |
* @dataProvider getGetAttributeTests
|
310 |
*/
|
311 |
-
public function testGetAttributeDefined($defined, $value, $object, $item, $arguments, $type
|
312 |
{
|
313 |
-
$template = new Twig_TemplateTest(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock())
|
314 |
|
315 |
$this->assertEquals($defined, $template->getAttribute($object, $item, $arguments, $type, true));
|
316 |
}
|
@@ -318,19 +280,16 @@ class Twig_Tests_TemplateTest extends PHPUnit_Framework_TestCase
|
|
318 |
/**
|
319 |
* @dataProvider getGetAttributeTests
|
320 |
*/
|
321 |
-
public function testGetAttributeDefinedStrict($defined, $value, $object, $item, $arguments, $type
|
322 |
{
|
323 |
-
$template = new Twig_TemplateTest(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('strict_variables' => true))
|
324 |
|
325 |
$this->assertEquals($defined, $template->getAttribute($object, $item, $arguments, $type, true));
|
326 |
}
|
327 |
|
328 |
-
|
329 |
-
* @dataProvider getTestsDependingOnExtensionAvailability
|
330 |
-
*/
|
331 |
-
public function testGetAttributeCallExceptions($useExt = false)
|
332 |
{
|
333 |
-
$template = new Twig_TemplateTest(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock())
|
334 |
|
335 |
$object = new Twig_TemplateMagicMethodExceptionObject();
|
336 |
|
@@ -450,39 +409,26 @@ class Twig_Tests_TemplateTest extends PHPUnit_Framework_TestCase
|
|
450 |
array(false, null, $methodAndPropObject, 'c', array(), $anyType),
|
451 |
array(false, null, $methodAndPropObject, 'c', array(), $methodType),
|
452 |
array(false, null, $methodAndPropObject, 'c', array(), $arrayType),
|
453 |
-
|
454 |
));
|
455 |
|
456 |
// tests when input is not an array or object
|
457 |
$tests = array_merge($tests, array(
|
458 |
-
array(false, null, 42, 'a', array(), $anyType,
|
459 |
-
array(false, null, 'string', 'a', array(), $anyType,
|
460 |
-
array(false, null, array(), 'a', array(), $anyType,
|
461 |
));
|
462 |
|
463 |
-
// add twig_template_get_attributes tests
|
464 |
-
|
465 |
-
if (function_exists('twig_template_get_attributes')) {
|
466 |
-
foreach (array_slice($tests, 0) as $test) {
|
467 |
-
$test = array_pad($test, 7, null);
|
468 |
-
$test[6] = true;
|
469 |
-
$tests[] = $test;
|
470 |
-
}
|
471 |
-
}
|
472 |
-
|
473 |
return $tests;
|
474 |
}
|
475 |
}
|
476 |
|
477 |
class Twig_TemplateTest extends Twig_Template
|
478 |
{
|
479 |
-
protected $useExtGetAttribute = false;
|
480 |
private $name;
|
481 |
|
482 |
-
public function __construct(Twig_Environment $env, $
|
483 |
{
|
484 |
parent::__construct($env);
|
485 |
-
$this->useExtGetAttribute = $useExtGetAttribute;
|
486 |
self::$cache = array();
|
487 |
$this->name = $name;
|
488 |
}
|
@@ -528,12 +474,16 @@ class Twig_TemplateTest extends Twig_Template
|
|
528 |
|
529 |
public function getAttribute($object, $item, array $arguments = array(), $type = Twig_Template::ANY_CALL, $isDefinedTest = false, $ignoreStrictCheck = false)
|
530 |
{
|
531 |
-
if (
|
532 |
return twig_template_get_attributes($this, $object, $item, $arguments, $type, $isDefinedTest, $ignoreStrictCheck);
|
533 |
} else {
|
534 |
return parent::getAttribute($object, $item, $arguments, $type, $isDefinedTest, $ignoreStrictCheck);
|
535 |
}
|
536 |
}
|
|
|
|
|
|
|
|
|
537 |
}
|
538 |
|
539 |
class Twig_TemplateArrayAccessObject implements ArrayAccess
|
@@ -712,18 +662,21 @@ class Twig_TemplateMethodObject
|
|
712 |
class Twig_TemplateMethodAndPropObject
|
713 |
{
|
714 |
private $a = 'a_prop';
|
|
|
715 |
public function getA()
|
716 |
{
|
717 |
return 'a';
|
718 |
}
|
719 |
|
720 |
public $b = 'b_prop';
|
|
|
721 |
public function getB()
|
722 |
{
|
723 |
return 'b';
|
724 |
}
|
725 |
|
726 |
private $c = 'c_prop';
|
|
|
727 |
private function getC()
|
728 |
{
|
729 |
return 'c';
|
22 |
/**
|
23 |
* @dataProvider getAttributeExceptions
|
24 |
*/
|
25 |
+
public function testGetAttributeExceptions($template, $message)
|
26 |
{
|
27 |
+
$templates = array('index' => $template);
|
|
|
|
|
|
|
|
|
28 |
$env = new Twig_Environment(new Twig_Loader_Array($templates), array('strict_variables' => true));
|
29 |
+
$template = $env->loadTemplate('index');
|
|
|
|
|
|
|
30 |
|
31 |
$context = array(
|
32 |
'string' => 'foo',
|
42 |
$template->render($context);
|
43 |
$this->fail('Accessing an invalid attribute should throw an exception.');
|
44 |
} catch (Twig_Error_Runtime $e) {
|
45 |
+
$this->assertSame(sprintf($message, 'index'), $e->getMessage());
|
46 |
}
|
47 |
}
|
48 |
|
49 |
public function getAttributeExceptions()
|
50 |
{
|
51 |
+
return array(
|
52 |
+
array('{{ string["a"] }}', 'Impossible to access a key ("a") on a string variable ("foo") in "%s" at line 1.'),
|
53 |
+
array('{{ null["a"] }}', 'Impossible to access a key ("a") on a null variable in "%s" at line 1.'),
|
54 |
+
array('{{ empty_array["a"] }}', 'Key "a" does not exist as the array is empty in "%s" at line 1.'),
|
55 |
+
array('{{ array["a"] }}', 'Key "a" for array with keys "foo" does not exist in "%s" at line 1.'),
|
56 |
+
array('{{ array_access["a"] }}', 'Key "a" in object with ArrayAccess of class "Twig_TemplateArrayAccessObject" does not exist in "%s" at line 1.'),
|
57 |
+
array('{{ string.a }}', 'Impossible to access an attribute ("a") on a string variable ("foo") in "%s" at line 1.'),
|
58 |
+
array('{{ string.a() }}', 'Impossible to invoke a method ("a") on a string variable ("foo") in "%s" at line 1.'),
|
59 |
+
array('{{ null.a }}', 'Impossible to access an attribute ("a") on a null variable in "%s" at line 1.'),
|
60 |
+
array('{{ null.a() }}', 'Impossible to invoke a method ("a") on a null variable in "%s" at line 1.'),
|
61 |
+
array('{{ empty_array.a }}', 'Key "a" does not exist as the array is empty in "%s" at line 1.'),
|
62 |
+
array('{{ array.a }}', 'Key "a" for array with keys "foo" does not exist in "%s" at line 1.'),
|
63 |
+
array('{{ attribute(array, -10) }}', 'Key "-10" for array with keys "foo" does not exist in "%s" at line 1.'),
|
64 |
+
array('{{ array_access.a }}', 'Neither the property "a" nor one of the methods "a()", "geta()"/"isa()" or "__call()" exist and have public access in class "Twig_TemplateArrayAccessObject" in "%s" at line 1.'),
|
65 |
+
array('{% from _self import foo %}{% macro foo(obj) %}{{ obj.missing_method() }}{% endmacro %}{{ foo(array_access) }}', 'Neither the property "missing_method" nor one of the methods "missing_method()", "getmissing_method()"/"ismissing_method()" or "__call()" exist and have public access in class "Twig_TemplateArrayAccessObject" in "%s" at line 1.'),
|
66 |
+
array('{{ magic_exception.test }}', 'An exception has been thrown during the rendering of a template ("Hey! Don\'t try to isset me!") in "%s" at line 1.'),
|
67 |
+
array('{{ object["a"] }}', 'Impossible to access a key "a" on an object of class "stdClass" that does not implement ArrayAccess interface in "%s" at line 1.'),
|
68 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
}
|
70 |
|
71 |
/**
|
72 |
* @dataProvider getGetAttributeWithSandbox
|
73 |
*/
|
74 |
+
public function testGetAttributeWithSandbox($object, $item, $allowed)
|
75 |
{
|
76 |
$twig = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock());
|
77 |
$policy = new Twig_Sandbox_SecurityPolicy(array(), array(), array(/*method*/), array(/*prop*/), array());
|
78 |
$twig->addExtension(new Twig_Extension_Sandbox($policy, !$allowed));
|
79 |
+
$template = new Twig_TemplateTest($twig);
|
80 |
|
81 |
try {
|
82 |
$template->getAttribute($object, $item, array(), 'any');
|
95 |
|
96 |
public function getGetAttributeWithSandbox()
|
97 |
{
|
98 |
+
return array(
|
99 |
+
array(new Twig_TemplatePropertyObject(), 'defined', false),
|
100 |
+
array(new Twig_TemplatePropertyObject(), 'defined', true),
|
101 |
+
array(new Twig_TemplateMethodObject(), 'defined', false),
|
102 |
+
array(new Twig_TemplateMethodObject(), 'defined', true),
|
103 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
104 |
}
|
105 |
|
106 |
/**
|
|
|
107 |
* @group legacy
|
108 |
*/
|
109 |
+
public function testGetAttributeWithTemplateAsObject()
|
110 |
{
|
111 |
// to be removed in 2.0
|
112 |
$twig = new Twig_Environment($this->getMockBuilder('Twig_TemplateTestLoaderInterface')->getMock());
|
113 |
//$twig = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface', 'Twig_SourceContextLoaderInterface')->getMock());
|
114 |
|
115 |
+
$template = new Twig_TemplateTest($twig, 'index.twig');
|
116 |
+
$template1 = new Twig_TemplateTest($twig, 'index1.twig');
|
117 |
|
118 |
$this->assertInstanceof('Twig_Markup', $template->getAttribute($template1, 'string'));
|
119 |
$this->assertEquals('some_string', $template->getAttribute($template1, 'string'));
|
133 |
$this->assertFalse($template->getAttribute($template1, 'displayWithErrorHandling', array(), Twig_Template::METHOD_CALL, true));
|
134 |
}
|
135 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
136 |
/**
|
137 |
* @group legacy
|
138 |
+
* @expectedDeprecation Calling "string" on template "index1.twig" from template "index.twig" is deprecated since version 1.28 and won't be supported anymore in 2.0.
|
139 |
+
* @expectedDeprecation Calling "string" on template "index1.twig" from template "index.twig" is deprecated since version 1.28 and won't be supported anymore in 2.0.
|
140 |
+
* @expectedDeprecation Calling "true" on template "index1.twig" from template "index.twig" is deprecated since version 1.28 and won't be supported anymore in 2.0.
|
141 |
+
* @expectedDeprecation Calling "true" on template "index1.twig" from template "index.twig" is deprecated since version 1.28 and won't be supported anymore in 2.0.
|
142 |
+
* @expectedDeprecation Calling "zero" on template "index1.twig" from template "index.twig" is deprecated since version 1.28 and won't be supported anymore in 2.0.
|
143 |
+
* @expectedDeprecation Calling "zero" on template "index1.twig" from template "index.twig" is deprecated since version 1.28 and won't be supported anymore in 2.0.
|
144 |
+
* @expectedDeprecation Calling "empty" on template "index1.twig" from template "index.twig" is deprecated since version 1.28 and won't be supported anymore in 2.0.
|
145 |
+
* @expectedDeprecation Calling "empty" on template "index1.twig" from template "index.twig" is deprecated since version 1.28 and won't be supported anymore in 2.0.
|
146 |
* @expectedDeprecation Calling "renderBlock" on template "index.twig" from template "index.twig" is deprecated since version 1.28 and won't be supported anymore in 2.0. Use block("name") instead).
|
147 |
* @expectedDeprecation Calling "displayBlock" on template "index.twig" from template "index.twig" is deprecated since version 1.28 and won't be supported anymore in 2.0. Use block("name") instead).
|
148 |
* @expectedDeprecation Calling "hasBlock" on template "index.twig" from template "index.twig" is deprecated since version 1.28 and won't be supported anymore in 2.0. Use "block("name") is defined" instead).
|
160 |
$twig = new Twig_Environment($this->getMockBuilder('Twig_TemplateTestLoaderInterface')->getMock());
|
161 |
//$twig = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface', 'Twig_SourceContextLoaderInterface')->getMock());
|
162 |
|
163 |
+
$template = new Twig_TemplateTest($twig, 'index.twig');
|
164 |
+
$template1 = new Twig_TemplateTest($twig, 'index1.twig');
|
165 |
|
166 |
$this->assertInstanceof('Twig_Markup', $template->getAttribute($template1, 'string'));
|
167 |
$this->assertEquals('some_string', $template->getAttribute($template1, 'string'));
|
175 |
$this->assertNotInstanceof('Twig_Markup', $template->getAttribute($template1, 'empty'));
|
176 |
$this->assertSame('', $template->getAttribute($template1, 'empty'));
|
177 |
|
178 |
+
$blocks = array('name' => array($template1, 'block_name'));
|
179 |
+
|
180 |
// trigger some deprecation notice messages to check them with @expectedDeprecation
|
181 |
+
$template->getAttribute($template, 'renderBlock', array('name', array(), $blocks));
|
182 |
+
$template->getAttribute($template, 'displayBlock', array('name', array(), $blocks));
|
183 |
$template->getAttribute($template, 'hasBlock', array('name', array()));
|
184 |
$template->getAttribute($template, 'render', array(array()));
|
185 |
$template->getAttribute($template, 'display', array(array()));
|
186 |
|
187 |
+
$template->getAttribute($template1, 'renderBlock', array('name', array(), $blocks));
|
188 |
+
$template->getAttribute($template1, 'displayBlock', array('name', array(), $blocks));
|
189 |
$template->getAttribute($template1, 'hasBlock', array('name', array()));
|
190 |
$template->getAttribute($template1, 'render', array(array()));
|
191 |
$template->getAttribute($template1, 'display', array(array()));
|
197 |
}
|
198 |
|
199 |
/**
|
200 |
+
* @group legacy
|
201 |
+
* @expectedDeprecation Silent display of undefined block "unknown" in template "index.twig" is deprecated since version 1.29 and will throw an exception in 2.0. Use the "block('unknown') is defined" expression to test for block existence.
|
202 |
+
* @expectedDeprecation Silent display of undefined block "unknown" in template "index.twig" is deprecated since version 1.29 and will throw an exception in 2.0. Use the "block('unknown') is defined" expression to test for block existence.
|
203 |
*/
|
204 |
+
public function testRenderBlockWithUndefinedBlock()
|
205 |
{
|
206 |
+
$twig = new Twig_Environment($this->getMockBuilder('Twig_TemplateTestLoaderInterface')->getMock());
|
207 |
+
|
208 |
+
$template = new Twig_TemplateTest($twig, 'index.twig');
|
209 |
+
$template->renderBlock('unknown', array());
|
210 |
+
$template->displayBlock('unknown', array());
|
211 |
+
}
|
212 |
+
|
213 |
+
public function testGetAttributeOnArrayWithConfusableKey()
|
214 |
+
{
|
215 |
+
$template = new Twig_TemplateTest(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()));
|
216 |
|
217 |
$array = array('Zero', 'One', -1 => 'MinusOne', '' => 'EmptyString', '1.5' => 'FloatButString', '01' => 'IntegerButStringWithLeadingZeros');
|
218 |
|
235 |
$this->assertSame('EmptyString', $template->getAttribute($array, null), 'null is treated as "" when accessing an array (equals PHP behavior)');
|
236 |
}
|
237 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
238 |
/**
|
239 |
* @dataProvider getGetAttributeTests
|
240 |
*/
|
241 |
+
public function testGetAttribute($defined, $value, $object, $item, $arguments, $type)
|
242 |
{
|
243 |
+
$template = new Twig_TemplateTest(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()));
|
244 |
|
245 |
$this->assertEquals($value, $template->getAttribute($object, $item, $arguments, $type));
|
246 |
}
|
248 |
/**
|
249 |
* @dataProvider getGetAttributeTests
|
250 |
*/
|
251 |
+
public function testGetAttributeStrict($defined, $value, $object, $item, $arguments, $type, $exceptionMessage = null)
|
252 |
{
|
253 |
+
$template = new Twig_TemplateTest(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('strict_variables' => true)));
|
254 |
|
255 |
if ($defined) {
|
256 |
$this->assertEquals($value, $template->getAttribute($object, $item, $arguments, $type));
|
270 |
/**
|
271 |
* @dataProvider getGetAttributeTests
|
272 |
*/
|
273 |
+
public function testGetAttributeDefined($defined, $value, $object, $item, $arguments, $type)
|
274 |
{
|
275 |
+
$template = new Twig_TemplateTest(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()));
|
276 |
|
277 |
$this->assertEquals($defined, $template->getAttribute($object, $item, $arguments, $type, true));
|
278 |
}
|
280 |
/**
|
281 |
* @dataProvider getGetAttributeTests
|
282 |
*/
|
283 |
+
public function testGetAttributeDefinedStrict($defined, $value, $object, $item, $arguments, $type)
|
284 |
{
|
285 |
+
$template = new Twig_TemplateTest(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('strict_variables' => true)));
|
286 |
|
287 |
$this->assertEquals($defined, $template->getAttribute($object, $item, $arguments, $type, true));
|
288 |
}
|
289 |
|
290 |
+
public function testGetAttributeCallExceptions()
|
|
|
|
|
|
|
291 |
{
|
292 |
+
$template = new Twig_TemplateTest(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()));
|
293 |
|
294 |
$object = new Twig_TemplateMagicMethodExceptionObject();
|
295 |
|
409 |
array(false, null, $methodAndPropObject, 'c', array(), $anyType),
|
410 |
array(false, null, $methodAndPropObject, 'c', array(), $methodType),
|
411 |
array(false, null, $methodAndPropObject, 'c', array(), $arrayType),
|
|
|
412 |
));
|
413 |
|
414 |
// tests when input is not an array or object
|
415 |
$tests = array_merge($tests, array(
|
416 |
+
array(false, null, 42, 'a', array(), $anyType, 'Impossible to access an attribute ("a") on a integer variable ("42") in "index.twig".'),
|
417 |
+
array(false, null, 'string', 'a', array(), $anyType, 'Impossible to access an attribute ("a") on a string variable ("string") in "index.twig".'),
|
418 |
+
array(false, null, array(), 'a', array(), $anyType, 'Key "a" does not exist as the array is empty in "index.twig".'),
|
419 |
));
|
420 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
421 |
return $tests;
|
422 |
}
|
423 |
}
|
424 |
|
425 |
class Twig_TemplateTest extends Twig_Template
|
426 |
{
|
|
|
427 |
private $name;
|
428 |
|
429 |
+
public function __construct(Twig_Environment $env, $name = 'index.twig')
|
430 |
{
|
431 |
parent::__construct($env);
|
|
|
432 |
self::$cache = array();
|
433 |
$this->name = $name;
|
434 |
}
|
474 |
|
475 |
public function getAttribute($object, $item, array $arguments = array(), $type = Twig_Template::ANY_CALL, $isDefinedTest = false, $ignoreStrictCheck = false)
|
476 |
{
|
477 |
+
if (function_exists('twig_template_get_attributes')) {
|
478 |
return twig_template_get_attributes($this, $object, $item, $arguments, $type, $isDefinedTest, $ignoreStrictCheck);
|
479 |
} else {
|
480 |
return parent::getAttribute($object, $item, $arguments, $type, $isDefinedTest, $ignoreStrictCheck);
|
481 |
}
|
482 |
}
|
483 |
+
|
484 |
+
public function block_name($context, array $blocks = array())
|
485 |
+
{
|
486 |
+
}
|
487 |
}
|
488 |
|
489 |
class Twig_TemplateArrayAccessObject implements ArrayAccess
|
662 |
class Twig_TemplateMethodAndPropObject
|
663 |
{
|
664 |
private $a = 'a_prop';
|
665 |
+
|
666 |
public function getA()
|
667 |
{
|
668 |
return 'a';
|
669 |
}
|
670 |
|
671 |
public $b = 'b_prop';
|
672 |
+
|
673 |
public function getB()
|
674 |
{
|
675 |
return 'b';
|
676 |
}
|
677 |
|
678 |
private $c = 'c_prop';
|
679 |
+
|
680 |
private function getC()
|
681 |
{
|
682 |
return 'c';
|