Timber - Version 0.22.4

Version Description

  • Fixed bug in get_calling_script file (thanks @gwagroves)
  • Added tons of new tests and docs (thanks @lggorman and @jarednova)
Download this release

Release Info

Developer jarednova
Plugin Icon 128x128 Timber
Version 0.22.4
Comparing to
See all releases

Code changes from version 0.22.3 to 0.22.4

Files changed (172) hide show
  1. README.md +1 -1
  2. lib/image/timber-image-operation-resize.php +15 -3
  3. lib/image/timber-image-operation-retina.php +5 -3
  4. lib/timber-helper.php +3 -29
  5. lib/timber-image-helper.php +1 -1
  6. lib/timber-loader.php +4 -4
  7. lib/timber-menu.php +2 -1
  8. lib/timber-post.php +25 -17
  9. lib/timber-twig.php +5 -1
  10. readme.txt +7 -2
  11. timber.php +2 -3
  12. vendor/asm89/twig-cache-extension/.travis.yml +11 -7
  13. vendor/asm89/twig-cache-extension/README.md +9 -1
  14. vendor/asm89/twig-cache-extension/composer.json +12 -5
  15. vendor/asm89/twig-cache-extension/lib/Asm89/Twig/CacheExtension/CacheProviderInterface.php +2 -0
  16. vendor/asm89/twig-cache-extension/lib/Asm89/Twig/CacheExtension/CacheStrategy/BlackholeCacheStrategy.php +53 -0
  17. vendor/asm89/twig-cache-extension/lib/Asm89/Twig/CacheExtension/CacheStrategy/GenerationalCacheStrategy.php +2 -2
  18. vendor/asm89/twig-cache-extension/lib/Asm89/Twig/CacheExtension/CacheStrategy/IndexedChainingCacheStrategy.php +10 -9
  19. vendor/asm89/twig-cache-extension/lib/Asm89/Twig/CacheExtension/CacheStrategy/LifetimeCacheStrategy.php +4 -4
  20. vendor/asm89/twig-cache-extension/lib/Asm89/Twig/CacheExtension/CacheStrategyInterface.php +3 -1
  21. vendor/asm89/twig-cache-extension/lib/Asm89/Twig/CacheExtension/Exception/BaseException.php +20 -0
  22. vendor/asm89/twig-cache-extension/lib/Asm89/Twig/CacheExtension/Exception/InvalidCacheKeyException.php +23 -0
  23. vendor/asm89/twig-cache-extension/lib/Asm89/Twig/CacheExtension/Exception/InvalidCacheLifetimeException.php +23 -0
  24. vendor/asm89/twig-cache-extension/lib/Asm89/Twig/CacheExtension/Exception/NonExistingStrategyException.php +23 -0
  25. vendor/asm89/twig-cache-extension/lib/Asm89/Twig/CacheExtension/Exception/NonExistingStrategyKeyException.php +23 -0
  26. vendor/asm89/twig-cache-extension/lib/Asm89/Twig/CacheExtension/Node/CacheNode.php +1 -1
  27. vendor/asm89/twig-cache-extension/lib/Asm89/Twig/CacheExtension/TokenParser/Cache.php +8 -6
  28. vendor/asm89/twig-cache-extension/test/Asm89/Twig/CacheExtension/Tests/CacheStrategy/GenerationCacheStrategyTest.php +1 -1
  29. vendor/asm89/twig-cache-extension/test/Asm89/Twig/CacheExtension/Tests/CacheStrategy/IndexedChainingCacheStrategyTest.php +10 -2
  30. vendor/asm89/twig-cache-extension/test/Asm89/Twig/CacheExtension/Tests/CacheStrategy/LifetimeCacheStrategyTest.php +1 -1
  31. vendor/asm89/twig-cache-extension/test/Asm89/Twig/CacheExtension/Tests/FunctionalExtensionTest.php +2 -2
  32. vendor/autoload.php +1 -1
  33. vendor/composer/autoload_namespaces.php +0 -1
  34. vendor/composer/autoload_psr4.php +1 -0
  35. vendor/composer/autoload_real.php +4 -4
  36. vendor/composer/installed.json +30 -28
  37. vendor/composer/installers/.travis.yml +11 -4
  38. vendor/composer/installers/README.md +4 -2
  39. vendor/composer/installers/composer.json +5 -2
  40. vendor/composer/installers/src/Composer/Installers/BaseInstaller.php +5 -1
  41. vendor/composer/installers/src/Composer/Installers/BitrixInstaller.php +81 -3
  42. vendor/composer/installers/src/Composer/Installers/BonefishInstaller.php +9 -0
  43. vendor/composer/installers/src/Composer/Installers/CakePHPInstaller.php +12 -6
  44. vendor/composer/installers/src/Composer/Installers/CraftInstaller.php +26 -0
  45. vendor/composer/installers/src/Composer/Installers/Installer.php +16 -3
  46. vendor/composer/installers/src/Composer/Installers/KodiCMSInstaller.php +10 -0
  47. vendor/composer/installers/src/Composer/Installers/MoodleInstaller.php +9 -0
  48. vendor/composer/installers/src/Composer/Installers/Plugin.php +17 -0
  49. vendor/composer/installers/tests/Composer/Installers/Test/CakePHPInstallerTest.php +1 -1
  50. vendor/composer/installers/tests/Composer/Installers/Test/CraftInstallerTest.php +83 -0
  51. vendor/composer/installers/tests/Composer/Installers/Test/InstallerTest.php +9 -3
  52. vendor/twig/twig/CHANGELOG +47 -0
  53. vendor/twig/twig/composer.json +1 -1
  54. vendor/twig/twig/doc/advanced.rst +4 -4
  55. vendor/twig/twig/doc/deprecated.rst +16 -4
  56. vendor/twig/twig/doc/filters/merge.rst +2 -1
  57. vendor/twig/twig/doc/filters/sort.rst +2 -1
  58. vendor/twig/twig/doc/recipes.rst +44 -14
  59. vendor/twig/twig/doc/templates.rst +18 -6
  60. vendor/twig/twig/ext/twig/php_twig.h +1 -1
  61. vendor/twig/twig/lib/Twig/Cache/Filesystem.php +96 -0
  62. vendor/twig/twig/lib/Twig/Cache/Null.php +48 -0
  63. vendor/twig/twig/lib/Twig/CacheInterface.php +56 -0
  64. vendor/twig/twig/lib/Twig/Environment.php +152 -72
  65. vendor/twig/twig/lib/Twig/Error.php +22 -0
  66. vendor/twig/twig/lib/Twig/Error/Syntax.php +33 -0
  67. vendor/twig/twig/lib/Twig/ExpressionParser.php +18 -22
  68. vendor/twig/twig/lib/Twig/Extension.php +10 -24
  69. vendor/twig/twig/lib/Twig/Extension/Core.php +78 -57
  70. vendor/twig/twig/lib/Twig/Extension/Debug.php +0 -10
  71. vendor/twig/twig/lib/Twig/Extension/Escaper.php +0 -20
  72. vendor/twig/twig/lib/Twig/Extension/GlobalsInterface.php +22 -0
  73. vendor/twig/twig/lib/Twig/Extension/InitRuntimeInterface.php +22 -0
  74. vendor/twig/twig/lib/Twig/Extension/Optimizer.php +0 -6
  75. vendor/twig/twig/lib/Twig/Extension/Profiler.php +0 -6
  76. vendor/twig/twig/lib/Twig/Extension/Sandbox.php +0 -15
  77. vendor/twig/twig/lib/Twig/Extension/Staging.php +2 -21
  78. vendor/twig/twig/lib/Twig/Extension/StringLoader.php +2 -8
  79. vendor/twig/twig/lib/Twig/ExtensionInterface.php +8 -4
  80. vendor/twig/twig/lib/Twig/FileExtensionEscapingStrategy.php +13 -4
  81. vendor/twig/twig/lib/Twig/Lexer.php +8 -8
  82. vendor/twig/twig/lib/Twig/Loader/Chain.php +3 -3
  83. vendor/twig/twig/lib/Twig/Loader/Filesystem.php +1 -1
  84. vendor/twig/twig/lib/Twig/Loader/String.php +3 -1
  85. vendor/twig/twig/lib/Twig/Node.php +1 -1
  86. vendor/twig/twig/lib/Twig/Node/AutoEscape.php +0 -5
  87. vendor/twig/twig/lib/Twig/Node/Block.php +0 -5
  88. vendor/twig/twig/lib/Twig/Node/BlockReference.php +0 -5
  89. vendor/twig/twig/lib/Twig/Node/Do.php +0 -5
  90. vendor/twig/twig/lib/Twig/Node/Expression/Array.php +0 -5
  91. vendor/twig/twig/lib/Twig/Node/Expression/AssignName.php +0 -5
  92. vendor/twig/twig/lib/Twig/Node/Expression/Binary.php +0 -5
  93. vendor/twig/twig/lib/Twig/Node/Expression/Binary/FloorDiv.php +0 -5
  94. vendor/twig/twig/lib/Twig/Node/Expression/Binary/In.php +0 -5
  95. vendor/twig/twig/lib/Twig/Node/Expression/Binary/NotIn.php +0 -5
  96. vendor/twig/twig/lib/Twig/Node/Expression/Binary/Power.php +0 -5
  97. vendor/twig/twig/lib/Twig/Node/Expression/Binary/Range.php +0 -5
  98. vendor/twig/twig/lib/Twig/Node/Expression/BlockReference.php +0 -5
  99. vendor/twig/twig/lib/Twig/Node/Expression/ExtensionReference.php +0 -5
  100. vendor/twig/twig/lib/Twig/Node/Expression/Parent.php +0 -5
  101. vendor/twig/twig/lib/Twig/Node/Expression/Test/Defined.php +1 -1
  102. vendor/twig/twig/lib/Twig/Node/Flush.php +0 -5
  103. vendor/twig/twig/lib/Twig/Node/For.php +1 -7
  104. vendor/twig/twig/lib/Twig/Node/ForLoop.php +0 -5
  105. vendor/twig/twig/lib/Twig/Node/If.php +0 -5
  106. vendor/twig/twig/lib/Twig/Node/Import.php +0 -5
  107. vendor/twig/twig/lib/Twig/Node/Include.php +0 -5
  108. vendor/twig/twig/lib/Twig/Node/Macro.php +1 -6
  109. vendor/twig/twig/lib/Twig/Node/Module.php +0 -5
  110. vendor/twig/twig/lib/Twig/Node/Print.php +0 -5
  111. vendor/twig/twig/lib/Twig/Node/Sandbox.php +0 -5
  112. vendor/twig/twig/lib/Twig/Node/SandboxedPrint.php +0 -10
  113. vendor/twig/twig/lib/Twig/Node/Set.php +0 -5
  114. vendor/twig/twig/lib/Twig/Node/Spaceless.php +0 -5
  115. vendor/twig/twig/lib/Twig/Node/Text.php +0 -5
  116. vendor/twig/twig/lib/Twig/Parser.php +11 -16
  117. vendor/twig/twig/lib/Twig/Profiler/Profile.php +10 -0
  118. vendor/twig/twig/lib/Twig/Template.php +45 -0
  119. vendor/twig/twig/lib/Twig/Test/IntegrationTestCase.php +56 -8
  120. vendor/twig/twig/lib/Twig/Test/NodeTestCase.php +8 -4
  121. vendor/twig/twig/lib/Twig/TokenParser/AutoEscape.php +1 -13
  122. vendor/twig/twig/lib/Twig/TokenParser/Block.php +2 -14
  123. vendor/twig/twig/lib/Twig/TokenParser/Do.php +0 -12
  124. vendor/twig/twig/lib/Twig/TokenParser/Embed.php +0 -12
  125. vendor/twig/twig/lib/Twig/TokenParser/Extends.php +2 -14
  126. vendor/twig/twig/lib/Twig/TokenParser/Filter.php +0 -12
  127. vendor/twig/twig/lib/Twig/TokenParser/Flush.php +0 -12
  128. vendor/twig/twig/lib/Twig/TokenParser/For.php +2 -14
  129. vendor/twig/twig/lib/Twig/TokenParser/From.php +1 -13
  130. vendor/twig/twig/lib/Twig/TokenParser/If.php +1 -13
  131. vendor/twig/twig/lib/Twig/TokenParser/Import.php +0 -12
  132. vendor/twig/twig/lib/Twig/TokenParser/Include.php +0 -12
  133. vendor/twig/twig/lib/Twig/TokenParser/Macro.php +1 -13
  134. vendor/twig/twig/lib/Twig/TokenParser/Sandbox.php +1 -13
  135. vendor/twig/twig/lib/Twig/TokenParser/Set.php +0 -12
  136. vendor/twig/twig/lib/Twig/TokenParser/Spaceless.php +0 -12
  137. vendor/twig/twig/lib/Twig/TokenParser/Use.php +0 -12
  138. vendor/twig/twig/lib/Twig/TokenParserBroker.php +5 -4
  139. vendor/twig/twig/lib/Twig/TokenStream.php +3 -3
  140. vendor/twig/twig/test/Twig/Tests/Cache/FilesystemTest.php +169 -0
  141. vendor/twig/twig/test/Twig/Tests/EnvironmentTest.php +254 -18
  142. vendor/twig/twig/test/Twig/Tests/ExpressionParserTest.php +40 -4
  143. vendor/twig/twig/test/Twig/Tests/Extension/CoreTest.php +2 -0
  144. vendor/twig/twig/test/Twig/Tests/FileCachingTest.php +6 -0
  145. vendor/twig/twig/test/Twig/Tests/FileExtensionEscapingStrategyTest.php +3 -1
  146. vendor/twig/twig/test/Twig/Tests/Fixtures/exceptions/syntax_error_in_reused_template.test +1 -1
  147. vendor/twig/twig/test/Twig/Tests/Fixtures/exceptions/unclosed_tag.test +1 -1
  148. vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/two_word_operators_as_variables.test +1 -1
  149. vendor/twig/twig/test/Twig/Tests/Fixtures/filters/merge.test +3 -1
  150. vendor/twig/twig/test/Twig/Tests/Fixtures/filters/replace.test +6 -2
  151. vendor/twig/twig/test/Twig/Tests/Fixtures/filters/replace_invalid_arg.test +8 -0
  152. vendor/twig/twig/test/Twig/Tests/Fixtures/filters/sort.test +3 -1
  153. vendor/twig/twig/test/Twig/Tests/Fixtures/macros/varargs_argument.test +1 -1
  154. vendor/twig/twig/test/Twig/Tests/Fixtures/tags/block/block_unique_name.test +1 -1
  155. vendor/twig/twig/test/Twig/Tests/Fixtures/tags/for/loop_not_defined.test +1 -1
  156. vendor/twig/twig/test/Twig/Tests/Fixtures/tags/for/loop_not_defined_cond.test +1 -1
  157. vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/parent_in_a_block.test +1 -1
  158. vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/parent_without_extends.test +1 -1
  159. vendor/twig/twig/test/Twig/Tests/Fixtures/tags/macro/from_with_reserved_name.test +1 -1
  160. vendor/twig/twig/test/Twig/Tests/Fixtures/tags/macro/import_with_reserved_nam.test +1 -1
  161. vendor/twig/twig/test/Twig/Tests/Fixtures/tags/macro/reserved_name.test +1 -1
  162. vendor/twig/twig/test/Twig/Tests/Fixtures/tags/raw/mixed_usage_with_raw.legacy.test +1 -1
  163. vendor/twig/twig/test/Twig/Tests/Fixtures/tags/sandbox/not_valid1.test +1 -1
  164. vendor/twig/twig/test/Twig/Tests/Fixtures/tags/sandbox/not_valid2.test +1 -1
  165. vendor/twig/twig/test/Twig/Tests/Fixtures/tags/use/inheritance.test +2 -2
  166. vendor/twig/twig/test/Twig/Tests/Fixtures/tags/use/inheritance2.test +2 -2
  167. vendor/twig/twig/test/Twig/Tests/Fixtures/tags/verbatim/mixed_usage_with_raw.test +1 -1
  168. vendor/twig/twig/test/Twig/Tests/LegacyIntegrationTest.php +9 -0
  169. vendor/twig/twig/test/Twig/Tests/Node/ForTest.php +4 -4
  170. vendor/twig/twig/test/Twig/Tests/Node/ModuleTest.php +6 -6
  171. vendor/twig/twig/test/Twig/Tests/ParserTest.php +17 -1
  172. vendor/twig/twig/test/Twig/Tests/TemplateTest.php +10 -1
README.md CHANGED
@@ -4,7 +4,7 @@
4
  By Jared Novack (<a href="http://twitter.com/jarednova">@JaredNova</a>) and <a href="http://upstatement.com">Upstatement</a> (<a href="http://twitter.com/upstatement">@Upstatement</a>)</div>
5
  </div>
6
 
7
- [![Build Status](https://img.shields.io/travis/jarednova/timber.svg?style=flat-square)](https://travis-ci.org/jarednova/timber)
8
  [![Coverage Status](https://img.shields.io/coveralls/jarednova/timber.svg?style=flat-square)](https://coveralls.io/r/jarednova/timber?branch=master)
9
  [![Dependency Status](https://img.shields.io/versioneye/d/ruby/rails.svg?style=flat-square)](https://www.versioneye.com/user/projects/54e3c717d1ec5734f4000099)
10
  [![Scrutinizer Code Quality](https://img.shields.io/scrutinizer/g/jarednova/timber.svg?style=flat-square)](https://scrutinizer-ci.com/g/jarednova/timber/?branch=master)
4
  By Jared Novack (<a href="http://twitter.com/jarednova">@JaredNova</a>) and <a href="http://upstatement.com">Upstatement</a> (<a href="http://twitter.com/upstatement">@Upstatement</a>)</div>
5
  </div>
6
 
7
+ [![Build Status](https://img.shields.io/travis/jarednova/timber/master.svg?style=flat-square)](https://travis-ci.org/jarednova/timber)
8
  [![Coverage Status](https://img.shields.io/coveralls/jarednova/timber.svg?style=flat-square)](https://coveralls.io/r/jarednova/timber?branch=master)
9
  [![Dependency Status](https://img.shields.io/versioneye/d/ruby/rails.svg?style=flat-square)](https://www.versioneye.com/user/projects/54e3c717d1ec5734f4000099)
10
  [![Scrutinizer Code Quality](https://img.shields.io/scrutinizer/g/jarednova/timber.svg?style=flat-square)](https://scrutinizer-ci.com/g/jarednova/timber/?branch=master)
lib/image/timber-image-operation-resize.php CHANGED
@@ -34,7 +34,15 @@ class TimberImageOperationResize extends TimberImageOperation {
34
  * @return string the final filename to be used (ex: my-awesome-pic-300x200-c-default.jpg)
35
  */
36
  public function filename($src_filename, $src_extension) {
37
- $result = $src_filename . '-' . $this->w . 'x' . $this->h . '-c-' . ( $this->crop ? $this->crop : 'f' ); // Crop will be either user named or f (false)
 
 
 
 
 
 
 
 
38
  if($src_extension) {
39
  $result .= '.'.$src_extension;
40
  }
@@ -155,16 +163,20 @@ class TimberImageOperationResize extends TimberImageOperation {
155
  );
156
  $result = $image->save( $save_filename );
157
  if ( is_wp_error( $result ) ) {
158
- error_log( 'Error resizing image' );
159
- error_log( print_r( $result, true ) );
 
160
  return false;
 
161
  } else {
162
  return true;
163
  }
164
  } else if ( isset( $image->error_data['error_loading_image'] ) ) {
 
165
  TimberHelper::error_log( 'Error loading ' . $image->error_data['error_loading_image'] );
166
  } else {
167
  TimberHelper::error_log( $image );
 
168
  }
169
  }
170
  }
34
  * @return string the final filename to be used (ex: my-awesome-pic-300x200-c-default.jpg)
35
  */
36
  public function filename($src_filename, $src_extension) {
37
+ $w = 0;
38
+ $h = 0;
39
+ if ( $this->w ) {
40
+ $w = $this->w;
41
+ }
42
+ if ( $this->h ) {
43
+ $h = $this->h;
44
+ }
45
+ $result = $src_filename . '-' . $w . 'x' . $h . '-c-' . ( $this->crop ? $this->crop : 'f' ); // Crop will be either user named or f (false)
46
  if($src_extension) {
47
  $result .= '.'.$src_extension;
48
  }
163
  );
164
  $result = $image->save( $save_filename );
165
  if ( is_wp_error( $result ) ) {
166
+ // @codeCoverageIgnoreStart
167
+ TimberHelper::error_log( 'Error resizing image' );
168
+ TimberHelper::error_log( $result );
169
  return false;
170
+ // @codeCoverageIgnoreEnd
171
  } else {
172
  return true;
173
  }
174
  } else if ( isset( $image->error_data['error_loading_image'] ) ) {
175
+ // @codeCoverageIgnoreStart
176
  TimberHelper::error_log( 'Error loading ' . $image->error_data['error_loading_image'] );
177
  } else {
178
  TimberHelper::error_log( $image );
179
+ // @codeCoverageIgnoreEnd
180
  }
181
  }
182
  }
lib/image/timber-image-operation-retina.php CHANGED
@@ -56,9 +56,11 @@ class TimberImageOperationRetina extends TimberImageOperation {
56
  $image->crop( 0, 0, $src_w, $src_h, $w, $h );
57
  $result = $image->save( $save_filename );
58
  if ( is_wp_error( $result ) ) {
59
- error_log( 'Error resizing image' );
60
- error_log( print_r( $result, true ) );
61
- return false;
 
 
62
  } else {
63
  return true;
64
  }
56
  $image->crop( 0, 0, $src_w, $src_h, $w, $h );
57
  $result = $image->save( $save_filename );
58
  if ( is_wp_error( $result ) ) {
59
+ // @codeCoverageIgnoreStart
60
+ TimberHelper::error_log( 'Error resizing image' );
61
+ TimberHelper::error_log( $result );
62
+ return false;
63
+ // @codeCoverageIgnoreEnd
64
  } else {
65
  return true;
66
  }
lib/timber-helper.php CHANGED
@@ -423,7 +423,8 @@ class TimberHelper {
423
  }
424
  }
425
  } else {
426
- throw new Exception( '$array is not an array, given value: ' . $array );
 
427
  }
428
  }
429
 
@@ -510,7 +511,7 @@ class TimberHelper {
510
  'total' => 1,
511
  'current' => 0,
512
  'show_all' => false,
513
- 'prev_next' => true,
514
  'prev_text' => __( '&laquo; Previous' ),
515
  'next_text' => __( 'Next &raquo;' ),
516
  'end_size' => 1,
@@ -531,20 +532,6 @@ class TimberHelper {
531
  $args['add_args'] = is_array( $args['add_args'] ) ? $args['add_args'] : false;
532
  $page_links = array();
533
  $dots = false;
534
- if ( $args['prev_next'] && $args['current'] && 1 < $args['current'] ) {
535
- $link = str_replace( '%_%', 2 == $args['current'] ? '' : $args['format'], $args['base'] );
536
- $link = str_replace( '%#%', $args['current'] - 1, $link );
537
- if ( $args['add_args'] ) {
538
- $link = add_query_arg( $args['add_args'], $link );
539
- }
540
- $link .= $args['add_fragment'];
541
- $link = untrailingslashit( $link );
542
- $page_links[] = array(
543
- 'class' => 'prev page-numbers',
544
- 'link' => esc_url( apply_filters( 'paginate_links', $link ) ),
545
- 'title' => $args['prev_text']
546
- );
547
- }
548
  for ( $n = 1; $n <= $args['total']; $n++ ) {
549
  $n_display = number_format_i18n( $n );
550
  if ( $n == $args['current'] ) {
@@ -583,19 +570,6 @@ class TimberHelper {
583
  }
584
  }
585
  }
586
- if ( $args['prev_next'] && $args['current'] && ( $args['current'] < $args['total'] || -1 == $args['total'] ) ) {
587
- $link = str_replace( '%_%', $args['format'], $args['base'] );
588
- $link = str_replace( '%#%', $args['current'] + 1, $link );
589
- if ( $args['add_args'] ) {
590
- $link = add_query_arg( $args['add_args'], $link );
591
- }
592
- $link = untrailingslashit( trailingslashit( $link ) . $args['add_fragment'] );
593
- $page_links[] = array(
594
- 'class' => 'next page-numbers',
595
- 'link' => esc_url( apply_filters( 'paginate_links', $link ) ),
596
- 'title' => $args['next_text']
597
- );
598
- }
599
  return $page_links;
600
  }
601
 
423
  }
424
  }
425
  } else {
426
+ throw new InvalidArgumentException( '$array is not an array, got:' );
427
+ TimberHelper::error_log( $array );
428
  }
429
  }
430
 
511
  'total' => 1,
512
  'current' => 0,
513
  'show_all' => false,
514
+ 'prev_next' => false,
515
  'prev_text' => __( '&laquo; Previous' ),
516
  'next_text' => __( 'Next &raquo;' ),
517
  'end_size' => 1,
532
  $args['add_args'] = is_array( $args['add_args'] ) ? $args['add_args'] : false;
533
  $page_links = array();
534
  $dots = false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
535
  for ( $n = 1; $n <= $args['total']; $n++ ) {
536
  $n_display = number_format_i18n( $n );
537
  if ( $n == $args['current'] ) {
570
  }
571
  }
572
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
573
  return $page_links;
574
  }
575
 
lib/timber-image-helper.php CHANGED
@@ -106,7 +106,7 @@ class TimberImageHelper {
106
  return false;
107
  }
108
  //its a gif so test
109
- if(!($fh = @fopen($file, 'rb'))) {
110
  return false;
111
  }
112
  $count = 0;
106
  return false;
107
  }
108
  //its a gif so test
109
+ if( !($fh = @fopen($file, 'rb')) ) {
110
  return false;
111
  }
112
  $count = 0;
lib/timber-loader.php CHANGED
@@ -80,15 +80,15 @@ class TimberLoader {
80
  * @param array $filenames
81
  * @return bool
82
  */
83
- function choose_template($filenames) {
84
  if (is_array($filenames)) {
85
  /* its an array so we have to figure out which one the dev wants */
86
  foreach ($filenames as $filename) {
87
- if ($this->template_exists($filename)) {
88
  return $filename;
89
  }
90
  }
91
- return false;
92
  }
93
  return $filenames;
94
  }
@@ -97,7 +97,7 @@ class TimberLoader {
97
  * @param string $file
98
  * @return bool
99
  */
100
- function template_exists($file) {
101
  foreach ($this->locations as $dir) {
102
  $look_for = trailingslashit($dir) . $file;
103
  if (file_exists($look_for)) {
80
  * @param array $filenames
81
  * @return bool
82
  */
83
+ public function choose_template($filenames) {
84
  if (is_array($filenames)) {
85
  /* its an array so we have to figure out which one the dev wants */
86
  foreach ($filenames as $filename) {
87
+ if (self::template_exists($filename)) {
88
  return $filename;
89
  }
90
  }
91
+ return $filenames[0];
92
  }
93
  return $filenames;
94
  }
97
  * @param string $file
98
  * @return bool
99
  */
100
+ protected function template_exists($file) {
101
  foreach ($this->locations as $dir) {
102
  $look_for = trailingslashit($dir) . $file;
103
  if (file_exists($look_for)) {
lib/timber-menu.php CHANGED
@@ -144,7 +144,8 @@ class TimberMenu extends TimberCore {
144
  $slug = array_search($slug, $locations);
145
  }
146
  if (isset($locations[$slug])) {
147
- return $locations[$slug];
 
148
  }
149
  }
150
 
144
  $slug = array_search($slug, $locations);
145
  }
146
  if (isset($locations[$slug])) {
147
+ $menu_id = $locations[$slug];
148
+ return $menu_id;
149
  }
150
  }
151
 
lib/timber-post.php CHANGED
@@ -281,9 +281,6 @@ class TimberPost extends TimberCore implements TimberCoreInterface {
281
  $post = get_post($pid);
282
  if ( $post ) {
283
  return $post;
284
- } else {
285
- $post = get_page($pid);
286
- return $post;
287
  }
288
  }
289
  //we can skip if already is WP_Post
@@ -378,7 +375,7 @@ class TimberPost extends TimberCore implements TimberCoreInterface {
378
  $text = trim($text);
379
  $last = $text[strlen($text) - 1];
380
  if ( $last != '.' && $trimmed ) {
381
- $text .= ' &hellip; ';
382
  }
383
  if ( !$strip ) {
384
  $last_p_tag = strrpos($text, '</p>');
@@ -745,18 +742,32 @@ class TimberPost extends TimberCore implements TimberCoreInterface {
745
  $overridden_cpage = true;
746
  }
747
 
748
- foreach( $comments as $key => &$comment ) {
749
- $timber_comment = new $CommentClass($comment);
750
- $timber_comments[$timber_comment->id] = $timber_comment;
751
- }
 
752
 
 
 
753
  foreach( $timber_comments as $key => $comment ) {
754
- if ( $comment->is_child() ) {
755
- unset($timber_comments[$comment->id]);
 
756
 
757
- if ( isset($timber_comments[$comment->comment_parent]) ) {
758
- $timber_comments[$comment->comment_parent]->children[] = $comment;
759
- }
 
 
 
 
 
 
 
 
 
 
760
  }
761
  }
762
 
@@ -971,10 +982,7 @@ class TimberPost extends TimberCore implements TimberCoreInterface {
971
  * @return int the number of comments on a post
972
  */
973
  public function get_comment_count() {
974
- if ( isset($this->ID) ) {
975
- return get_comments_number($this->ID);
976
- }
977
- return 0;
978
  }
979
 
980
  /**
281
  $post = get_post($pid);
282
  if ( $post ) {
283
  return $post;
 
 
 
284
  }
285
  }
286
  //we can skip if already is WP_Post
375
  $text = trim($text);
376
  $last = $text[strlen($text) - 1];
377
  if ( $last != '.' && $trimmed ) {
378
+ $text .= ' &hellip;';
379
  }
380
  if ( !$strip ) {
381
  $last_p_tag = strrpos($text, '</p>');
742
  $overridden_cpage = true;
743
  }
744
 
745
+ foreach($comments as $key => &$comment) {
746
+ $timber_comment = new $CommentClass($comment);
747
+ $timber_comment->reply_link = $this->TimberComment_reply_link($comment->comment_ID, $this->ID);
748
+ $timber_comments[$timber_comment->id] = $timber_comment;
749
+ }
750
 
751
+ // Build a flattened (depth=1) comment tree
752
+ $comments_tree = array();
753
  foreach( $timber_comments as $key => $comment ) {
754
+ if ( ! $comment->is_child() ) {
755
+ continue;
756
+ }
757
 
758
+ $tree_element = $comment;
759
+ do {
760
+ $tree_element = $timber_comments[$tree_element->comment_parent];
761
+ } while( $tree_element->is_child() );
762
+
763
+ $comments_tree[$tree_element->id][] = $comment->id;
764
+ }
765
+
766
+ // Add child comments to the relative "super parents"
767
+ foreach($comments_tree as $comment_parent => $comment_children) {
768
+ foreach($comment_children as $comment_child) {
769
+ $timber_comments[$comment_parent]->children[] = $timber_comments[$comment_child];
770
+ unset($timber_comments[$comment_child]);
771
  }
772
  }
773
 
982
  * @return int the number of comments on a post
983
  */
984
  public function get_comment_count() {
985
+ return get_comments_number($this->ID);
 
 
 
986
  }
987
 
988
  /**
lib/timber-twig.php CHANGED
@@ -5,12 +5,15 @@ class TimberTwig {
5
  public static $dir_name;
6
 
7
  /**
8
- * Initialization
9
  */
10
  public static function init() {
11
  new TimberTwig();
12
  }
13
 
 
 
 
14
  function __construct() {
15
  add_action( 'timber/twig/filters', array( $this, 'add_timber_filters_deprecated' ) );
16
  add_action( 'timber/twig/filters', array( $this, 'add_timber_filters' ) );
@@ -283,6 +286,7 @@ class TimberTwig {
283
  *
284
  * @param mixed $obj
285
  * @param bool $methods
 
286
  * @return string
287
  */
288
  function object_docs( $obj, $methods = true ) {
5
  public static $dir_name;
6
 
7
  /**
8
+ * @codeCoverageIgnore
9
  */
10
  public static function init() {
11
  new TimberTwig();
12
  }
13
 
14
+ /**
15
+ * @codeCoverageIgnore
16
+ */
17
  function __construct() {
18
  add_action( 'timber/twig/filters', array( $this, 'add_timber_filters_deprecated' ) );
19
  add_action( 'timber/twig/filters', array( $this, 'add_timber_filters' ) );
286
  *
287
  * @param mixed $obj
288
  * @param bool $methods
289
+ * @deprecated since 0.20.7
290
  * @return string
291
  */
292
  function object_docs( $obj, $methods = true ) {
readme.txt CHANGED
@@ -2,7 +2,7 @@
2
  Contributors: jarednova, lggorman
3
  Tags: template engine, templates, twig
4
  Requires at least: 3.7
5
- Stable tag: 0.22.3
6
  Tested up to: 4.3.1
7
  PHP version: 5.3.0 or greater
8
  License: GPLv2 or later
@@ -17,7 +17,7 @@ Once Timber is installed and activated in your plugin directory, it gives any Wo
17
 
18
  ### Looking for docs?
19
  * **[Project Page](http://upstatement.com/timber)**
20
- * [Timber Documentation](https://jarednova.github.io/timber/)
21
  * [Twig Reference (from SensioLabs)](http://twig.sensiolabs.org/doc/templates.html)
22
  _Twig is the template language powering Timber; if you need a little background on what a template language is, [Twig's homepage has an overview](http://twig.sensiolabs.org/)_
23
  * **[Video Tutorials](https://github.com/jarednova/timber/wiki/Video-Tutorials)**
@@ -41,7 +41,12 @@ Timber is great for any WordPress developer who cares about writing good, mainta
41
 
42
  == Changelog ==
43
 
 
 
 
 
44
  = 0.22.3 =
 
45
  * Fixed-up conditional for when comments are being moderated (thanks @lggorman)
46
  * Fixed hooks for when attachments are deleted (thanks @lgaechter)
47
  * Added a new filter for `list` (thanks @lggorman)
2
  Contributors: jarednova, lggorman
3
  Tags: template engine, templates, twig
4
  Requires at least: 3.7
5
+ Stable tag: 0.22.4
6
  Tested up to: 4.3.1
7
  PHP version: 5.3.0 or greater
8
  License: GPLv2 or later
17
 
18
  ### Looking for docs?
19
  * **[Project Page](http://upstatement.com/timber)**
20
+ * [Timber Documentation](https://github.com/jarednova/timber/wiki/)
21
  * [Twig Reference (from SensioLabs)](http://twig.sensiolabs.org/doc/templates.html)
22
  _Twig is the template language powering Timber; if you need a little background on what a template language is, [Twig's homepage has an overview](http://twig.sensiolabs.org/)_
23
  * **[Video Tutorials](https://github.com/jarednova/timber/wiki/Video-Tutorials)**
41
 
42
  == Changelog ==
43
 
44
+ = 0.22.4 =
45
+ * Fixed [bug](https://github.com/jarednova/timber/issues/785) in get_calling_script file (thanks @gwagroves)
46
+ * Added tons of new tests and docs (thanks @lggorman and @jarednova)
47
+
48
  = 0.22.3 =
49
+ * Fix to comment threadding (thanks @josephbergdoll)
50
  * Fixed-up conditional for when comments are being moderated (thanks @lggorman)
51
  * Fixed hooks for when attachments are deleted (thanks @lgaechter)
52
  * Added a new filter for `list` (thanks @lggorman)
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: 0.22.3
8
  Author URI: http://upstatement.com/
9
  */
10
 
@@ -541,7 +541,6 @@ class Timber {
541
  $args['type'] = 'array';
542
  $args['current'] = max( 1, get_query_var( 'paged' ) );
543
  $args['mid_size'] = max( 9 - $args['current'], 3 );
544
- $args['prev_next'] = false;
545
  if ( is_int( $prefs ) ) {
546
  $args['mid_size'] = $prefs - 2;
547
  } else {
@@ -606,7 +605,7 @@ class Timber {
606
  $backtrace = debug_backtrace();
607
  $i = 0;
608
  foreach ( $backtrace as $trace ) {
609
- if ( $trace['file'] != __FILE__ ) {
610
  $caller = $trace['file'];
611
  break;
612
  }
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: 0.22.4
8
  Author URI: http://upstatement.com/
9
  */
10
 
541
  $args['type'] = 'array';
542
  $args['current'] = max( 1, get_query_var( 'paged' ) );
543
  $args['mid_size'] = max( 9 - $args['current'], 3 );
 
544
  if ( is_int( $prefs ) ) {
545
  $args['mid_size'] = $prefs - 2;
546
  } else {
605
  $backtrace = debug_backtrace();
606
  $i = 0;
607
  foreach ( $backtrace as $trace ) {
608
+ if ( array_key_exists('file', $trace) && $trace['file'] != __FILE__ ) {
609
  $caller = $trace['file'];
610
  break;
611
  }
vendor/asm89/twig-cache-extension/.travis.yml CHANGED
@@ -1,13 +1,17 @@
1
  language: php
2
 
3
- php:
4
- - 5.3
5
- - 5.4
6
- - 5.5
7
 
8
- matrix:
9
- allow_failures:
10
- - php: 5.5
 
 
 
 
11
 
12
  before_script: composer install --dev
13
 
1
  language: php
2
 
3
+ cache:
4
+ directories:
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
  before_script: composer install --dev
17
 
vendor/asm89/twig-cache-extension/README.md CHANGED
@@ -13,7 +13,7 @@ The extension is installable via composer:
13
  ```json
14
  {
15
  "require": {
16
- "asm89/twig-cache-extension": "~0.1"
17
  }
18
  }
19
  ```
@@ -94,6 +94,14 @@ For example: entities containing a last update time, would include a timestamp
94
  in the key. For an interesting blog post about this type of caching see:
95
  http://37signals.com/svn/posts/3113-how-key-based-cache-expiration-works
96
 
 
 
 
 
 
 
 
 
97
  #### Setup
98
 
99
  In order to use the strategy you need to setup a `KeyGenerator` class that is
13
  ```json
14
  {
15
  "require": {
16
+ "asm89/twig-cache-extension": "~1.0"
17
  }
18
  }
19
  ```
94
  in the key. For an interesting blog post about this type of caching see:
95
  http://37signals.com/svn/posts/3113-how-key-based-cache-expiration-works
96
 
97
+ ### Blackhole
98
+
99
+ Strategy for development mode.
100
+
101
+ In development mode it often not very useful to cache fragments. The blackhole
102
+ strategy provides an easy way to not cache anything it all. It always generates
103
+ a new key and does not fetch or save any fragments.
104
+
105
  #### Setup
106
 
107
  In order to use the strategy you need to setup a `KeyGenerator` class that is
vendor/asm89/twig-cache-extension/composer.json CHANGED
@@ -1,6 +1,6 @@
1
  {
2
  "name": "asm89/twig-cache-extension",
3
- "description": "Caching template fragments with Twig.",
4
  "keywords": ["twig", "cache", "extension"],
5
  "homepage": "https://github.com/asm89/twig-cache-extension",
6
  "type": "library",
@@ -12,14 +12,21 @@
12
  }
13
  ],
14
  "require": {
15
- "php": ">=5.3.2",
16
- "twig/twig": "1.*"
17
  },
18
  "require-dev": {
19
- "doctrine/cache": "1.*"
20
  },
21
  "autoload": {
22
- "psr-0": { "Asm89\\Twig\\CacheExtension\\": "lib/" }
 
 
 
 
 
 
 
23
  },
24
  "extra": {
25
  "branch-alias": {
1
  {
2
  "name": "asm89/twig-cache-extension",
3
+ "description": "Cache fragments of templates directly within Twig.",
4
  "keywords": ["twig", "cache", "extension"],
5
  "homepage": "https://github.com/asm89/twig-cache-extension",
6
  "type": "library",
12
  }
13
  ],
14
  "require": {
15
+ "php": ">=5.3.2",
16
+ "twig/twig": "~1.0"
17
  },
18
  "require-dev": {
19
+ "doctrine/cache": "~1.0"
20
  },
21
  "autoload": {
22
+ "psr-4": {
23
+ "": "lib/"
24
+ }
25
+ },
26
+ "autoload-dev": {
27
+ "psr-4": {
28
+ "": "test/"
29
+ }
30
  },
31
  "extra": {
32
  "branch-alias": {
vendor/asm89/twig-cache-extension/lib/Asm89/Twig/CacheExtension/CacheProviderInterface.php CHANGED
@@ -29,6 +29,8 @@ interface CacheProviderInterface
29
  * @param string $key
30
  * @param string $value
31
  * @param integer $lifetime
 
 
32
  */
33
  public function save($key, $value, $lifetime = 0);
34
  }
29
  * @param string $key
30
  * @param string $value
31
  * @param integer $lifetime
32
+ *
33
+ * @return boolean
34
  */
35
  public function save($key, $value, $lifetime = 0);
36
  }
vendor/asm89/twig-cache-extension/lib/Asm89/Twig/CacheExtension/CacheStrategy/BlackholeCacheStrategy.php ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of twig-cache-extension.
5
+ *
6
+ * (c) Alexander <iam.asm89@gmail.com>
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ namespace Asm89\Twig\CacheExtension\CacheStrategy;
13
+
14
+ use Asm89\Twig\CacheExtension\CacheStrategyInterface;
15
+
16
+ /**
17
+ * CacheStrategy which doesn't cache at all
18
+ *
19
+ * This strategy can be used in development mode, e.g. editing twig templates,
20
+ * to prevent previously cached versions from being rendered.
21
+ *
22
+ * @see https://github.com/asm89/twig-cache-extension/pull/29
23
+ *
24
+ * @author Hagen Hübel <hhuebel@itinance.com>
25
+ *
26
+ * @package Asm89\Twig\CacheExtension\CacheStrategy
27
+ */
28
+ class BlackholeCacheStrategy implements CacheStrategyInterface
29
+ {
30
+ /**
31
+ * {@inheritDoc}
32
+ */
33
+ public function fetchBlock($key)
34
+ {
35
+ return false;
36
+ }
37
+
38
+ /**
39
+ * {@inheritDoc}
40
+ */
41
+ public function generateKey($annotation, $value)
42
+ {
43
+ return microtime(true) . mt_rand();
44
+ }
45
+
46
+ /**
47
+ * {@inheritDoc}
48
+ */
49
+ public function saveBlock($key, $block)
50
+ {
51
+ // fire and forget
52
+ }
53
+ }
vendor/asm89/twig-cache-extension/lib/Asm89/Twig/CacheExtension/CacheStrategy/GenerationalCacheStrategy.php CHANGED
@@ -13,6 +13,7 @@ namespace Asm89\Twig\CacheExtension\CacheStrategy;
13
 
14
  use Asm89\Twig\CacheExtension\CacheProviderInterface;
15
  use Asm89\Twig\CacheExtension\CacheStrategyInterface;
 
16
 
17
  /**
18
  * Strategy for generational caching.
@@ -62,8 +63,7 @@ class GenerationalCacheStrategy implements CacheStrategyInterface
62
  $key = $this->keyGenerator->generateKey($value);
63
 
64
  if (null === $key) {
65
- // todo: more specific exception
66
- throw new \RuntimeException('Key generator did not return a key.');
67
  }
68
 
69
  return $annotation . '__GCS__' . $key;
13
 
14
  use Asm89\Twig\CacheExtension\CacheProviderInterface;
15
  use Asm89\Twig\CacheExtension\CacheStrategyInterface;
16
+ use Asm89\Twig\CacheExtension\Exception\InvalidCacheKeyException;
17
 
18
  /**
19
  * Strategy for generational caching.
63
  $key = $this->keyGenerator->generateKey($value);
64
 
65
  if (null === $key) {
66
+ throw new InvalidCacheKeyException();
 
67
  }
68
 
69
  return $annotation . '__GCS__' . $key;
vendor/asm89/twig-cache-extension/lib/Asm89/Twig/CacheExtension/CacheStrategy/IndexedChainingCacheStrategy.php CHANGED
@@ -12,6 +12,8 @@
12
  namespace Asm89\Twig\CacheExtension\CacheStrategy;
13
 
14
  use Asm89\Twig\CacheExtension\CacheStrategyInterface;
 
 
15
 
16
  /**
17
  * Combines several configured cache strategies.
@@ -24,6 +26,9 @@ use Asm89\Twig\CacheExtension\CacheStrategyInterface;
24
  */
25
  class IndexedChainingCacheStrategy implements CacheStrategyInterface
26
  {
 
 
 
27
  private $strategies;
28
 
29
  /**
@@ -47,21 +52,17 @@ class IndexedChainingCacheStrategy implements CacheStrategyInterface
47
  */
48
  public function generateKey($annotation, $value)
49
  {
50
- if (! is_array($value) || null === $strategyKey = key($value)) {
51
- //todo: specialized exception
52
- throw new \RuntimeException('No strategy key found in value.');
53
  }
54
 
55
- if (! isset($this->strategies[$strategyKey])) {
56
- //todo: specialized exception
57
- throw new \RuntimeException(sprintf('No strategy configured with key "%s".', $strategyKey));
58
  }
59
 
60
- $key = $this->strategies[$strategyKey]->generateKey($annotation, current($value));
61
-
62
  return array(
63
  'strategyKey' => $strategyKey,
64
- 'key' => $key,
65
  );
66
  }
67
 
12
  namespace Asm89\Twig\CacheExtension\CacheStrategy;
13
 
14
  use Asm89\Twig\CacheExtension\CacheStrategyInterface;
15
+ use Asm89\Twig\CacheExtension\Exception\NonExistingStrategyException;
16
+ use Asm89\Twig\CacheExtension\Exception\NonExistingStrategyKeyException;
17
 
18
  /**
19
  * Combines several configured cache strategies.
26
  */
27
  class IndexedChainingCacheStrategy implements CacheStrategyInterface
28
  {
29
+ /**
30
+ * @var CacheStrategyInterface[]
31
+ */
32
  private $strategies;
33
 
34
  /**
52
  */
53
  public function generateKey($annotation, $value)
54
  {
55
+ if (!is_array($value) || null === $strategyKey = key($value)) {
56
+ throw new NonExistingStrategyKeyException();
 
57
  }
58
 
59
+ if (!isset($this->strategies[$strategyKey])) {
60
+ throw new NonExistingStrategyException($strategyKey);
 
61
  }
62
 
 
 
63
  return array(
64
  'strategyKey' => $strategyKey,
65
+ 'key' => $this->strategies[$strategyKey]->generateKey($annotation, current($value)),
66
  );
67
  }
68
 
vendor/asm89/twig-cache-extension/lib/Asm89/Twig/CacheExtension/CacheStrategy/LifetimeCacheStrategy.php CHANGED
@@ -13,6 +13,7 @@ namespace Asm89\Twig\CacheExtension\CacheStrategy;
13
 
14
  use Asm89\Twig\CacheExtension\CacheProviderInterface;
15
  use Asm89\Twig\CacheExtension\CacheStrategyInterface;
 
16
 
17
  /**
18
  * Strategy for caching with a pre-defined lifetime.
@@ -47,14 +48,13 @@ class LifetimeCacheStrategy implements CacheStrategyInterface
47
  */
48
  public function generateKey($annotation, $value)
49
  {
50
- if (! is_numeric($value)) {
51
- //todo: specialized exception
52
- throw new \RuntimeException('Value is not a valid lifetime.');
53
  }
54
 
55
  return array(
56
  'lifetime' => $value,
57
- 'key' => '__LCS__' . $annotation,
58
  );
59
  }
60
 
13
 
14
  use Asm89\Twig\CacheExtension\CacheProviderInterface;
15
  use Asm89\Twig\CacheExtension\CacheStrategyInterface;
16
+ use Asm89\Twig\CacheExtension\Exception\InvalidCacheLifetimeException;
17
 
18
  /**
19
  * Strategy for caching with a pre-defined lifetime.
48
  */
49
  public function generateKey($annotation, $value)
50
  {
51
+ if (!is_numeric($value)) {
52
+ throw new InvalidCacheLifetimeException($value);
 
53
  }
54
 
55
  return array(
56
  'lifetime' => $value,
57
+ 'key' => '__LCS__' . $annotation,
58
  );
59
  }
60
 
vendor/asm89/twig-cache-extension/lib/Asm89/Twig/CacheExtension/CacheStrategyInterface.php CHANGED
@@ -23,7 +23,7 @@ interface CacheStrategyInterface
23
  *
24
  * @param mixed $key
25
  *
26
- * @return string
27
  */
28
  public function fetchBlock($key);
29
 
@@ -42,6 +42,8 @@ interface CacheStrategyInterface
42
  *
43
  * @param mixed $key
44
  * @param string $block
 
 
45
  */
46
  public function saveBlock($key, $block);
47
  }
23
  *
24
  * @param mixed $key
25
  *
26
+ * @return mixed
27
  */
28
  public function fetchBlock($key);
29
 
42
  *
43
  * @param mixed $key
44
  * @param string $block
45
+ *
46
+ * @return mixed
47
  */
48
  public function saveBlock($key, $block);
49
  }
vendor/asm89/twig-cache-extension/lib/Asm89/Twig/CacheExtension/Exception/BaseException.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of twig-cache-extension.
5
+ *
6
+ * (c) Alexander <iam.asm89@gmail.com>
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ namespace Asm89\Twig\CacheExtension\Exception;
13
+
14
+ /**
15
+ * @todo Replace \RuntimeException with \InvalidArgumentException at version 2.0
16
+ */
17
+ class BaseException extends \RuntimeException
18
+ {
19
+
20
+ }
vendor/asm89/twig-cache-extension/lib/Asm89/Twig/CacheExtension/Exception/InvalidCacheKeyException.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of twig-cache-extension.
5
+ *
6
+ * (c) Alexander <iam.asm89@gmail.com>
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ namespace Asm89\Twig\CacheExtension\Exception;
13
+
14
+ class InvalidCacheKeyException extends BaseException
15
+ {
16
+ /**
17
+ * {@inheritdoc}
18
+ */
19
+ public function __construct($message = 'Key generator did not return a key.', $code = 0, \Exception $previous = null)
20
+ {
21
+ parent::__construct($message, $code, $previous);
22
+ }
23
+ }
vendor/asm89/twig-cache-extension/lib/Asm89/Twig/CacheExtension/Exception/InvalidCacheLifetimeException.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of twig-cache-extension.
5
+ *
6
+ * (c) Alexander <iam.asm89@gmail.com>
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ namespace Asm89\Twig\CacheExtension\Exception;
13
+
14
+ class InvalidCacheLifetimeException extends BaseException
15
+ {
16
+ /**
17
+ * {@inheritdoc}
18
+ */
19
+ public function __construct($lifetime, $code = 0, \Exception $previous = null)
20
+ {
21
+ parent::__construct(sprintf('Value "%s" is not a valid lifetime.', gettype($lifetime)), $code, $previous);
22
+ }
23
+ }
vendor/asm89/twig-cache-extension/lib/Asm89/Twig/CacheExtension/Exception/NonExistingStrategyException.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of twig-cache-extension.
5
+ *
6
+ * (c) Alexander <iam.asm89@gmail.com>
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ namespace Asm89\Twig\CacheExtension\Exception;
13
+
14
+ class NonExistingStrategyException extends BaseException
15
+ {
16
+ /**
17
+ * {@inheritdoc}
18
+ */
19
+ public function __construct($strategyKey, $code = 0, \Exception $previous = null)
20
+ {
21
+ parent::__construct(sprintf('No strategy configured with key "%s".', $strategyKey), $code, $previous);
22
+ }
23
+ }
vendor/asm89/twig-cache-extension/lib/Asm89/Twig/CacheExtension/Exception/NonExistingStrategyKeyException.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of twig-cache-extension.
5
+ *
6
+ * (c) Alexander <iam.asm89@gmail.com>
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ namespace Asm89\Twig\CacheExtension\Exception;
13
+
14
+ class NonExistingStrategyKeyException extends BaseException
15
+ {
16
+ /**
17
+ * {@inheritdoc}
18
+ */
19
+ public function __construct($message = 'No strategy key found in value.', $code = 0, \Exception $previous = null)
20
+ {
21
+ parent::__construct($message, $code, $previous);
22
+ }
23
+ }
vendor/asm89/twig-cache-extension/lib/Asm89/Twig/CacheExtension/Node/CacheNode.php CHANGED
@@ -41,7 +41,7 @@ class CacheNode extends \Twig_Node
41
 
42
  $compiler
43
  ->addDebugInfo($this)
44
- ->write("\$asm89CacheStrategy".$i." = \$this->getEnvironment()->getExtension('asm89_cache')->getCacheStrategy();\n")
45
  ->write("\$asm89Key".$i." = \$asm89CacheStrategy".$i."->generateKey(")
46
  ->subcompile($this->getNode('annotation'))
47
  ->raw(", ")
41
 
42
  $compiler
43
  ->addDebugInfo($this)
44
+ ->write("\$asm89CacheStrategy".$i." = \$this->env->getExtension('asm89_cache')->getCacheStrategy();\n")
45
  ->write("\$asm89Key".$i." = \$asm89CacheStrategy".$i."->generateKey(")
46
  ->subcompile($this->getNode('annotation'))
47
  ->raw(", ")
vendor/asm89/twig-cache-extension/lib/Asm89/Twig/CacheExtension/TokenParser/Cache.php CHANGED
@@ -11,7 +11,7 @@
11
 
12
  namespace Asm89\Twig\CacheExtension\TokenParser;
13
 
14
- use \Twig_Token;
15
 
16
  /**
17
  * Parser for cache/endcache blocks.
@@ -21,9 +21,11 @@ use \Twig_Token;
21
  class Cache extends \Twig_TokenParser
22
  {
23
  /**
 
 
24
  * @return boolean
25
  */
26
- public function decideCacheEnd(Twig_Token $token)
27
  {
28
  return $token->test('endcache');
29
  }
@@ -39,7 +41,7 @@ class Cache extends \Twig_TokenParser
39
  /**
40
  * {@inheritDoc}
41
  */
42
- public function parse(Twig_Token $token)
43
  {
44
  $lineno = $token->getLine();
45
  $stream = $this->parser->getStream();
@@ -48,10 +50,10 @@ class Cache extends \Twig_TokenParser
48
 
49
  $key = $this->parser->getExpressionParser()->parseExpression();
50
 
51
- $stream->expect(Twig_Token::BLOCK_END_TYPE);
52
  $body = $this->parser->subparse(array($this, 'decideCacheEnd'), true);
53
- $stream->expect(Twig_Token::BLOCK_END_TYPE);
54
 
55
- return new \Asm89\Twig\CacheExtension\Node\CacheNode($annotation, $key, $body, $lineno, $this->getTag());
56
  }
57
  }
11
 
12
  namespace Asm89\Twig\CacheExtension\TokenParser;
13
 
14
+ use Asm89\Twig\CacheExtension\Node\CacheNode;
15
 
16
  /**
17
  * Parser for cache/endcache blocks.
21
  class Cache extends \Twig_TokenParser
22
  {
23
  /**
24
+ * @param \Twig_Token $token
25
+ *
26
  * @return boolean
27
  */
28
+ public function decideCacheEnd(\Twig_Token $token)
29
  {
30
  return $token->test('endcache');
31
  }
41
  /**
42
  * {@inheritDoc}
43
  */
44
+ public function parse(\Twig_Token $token)
45
  {
46
  $lineno = $token->getLine();
47
  $stream = $this->parser->getStream();
50
 
51
  $key = $this->parser->getExpressionParser()->parseExpression();
52
 
53
+ $stream->expect(\Twig_Token::BLOCK_END_TYPE);
54
  $body = $this->parser->subparse(array($this, 'decideCacheEnd'), true);
55
+ $stream->expect(\Twig_Token::BLOCK_END_TYPE);
56
 
57
+ return new CacheNode($annotation, $key, $body, $lineno, $this->getTag());
58
  }
59
  }
vendor/asm89/twig-cache-extension/test/Asm89/Twig/CacheExtension/Tests/CacheStrategy/GenerationCacheStrategyTest.php CHANGED
@@ -37,7 +37,7 @@ class GenerationalCacheStrategyTest extends \PHPUnit_Framework_TestCase
37
  }
38
 
39
  /**
40
- * @expectedException RuntimeException
41
  */
42
  public function testGenerationKeyThrowsExceptionWhenKeyGeneratorReturnsNull()
43
  {
37
  }
38
 
39
  /**
40
+ * @expectedException \Asm89\Twig\CacheExtension\Exception\InvalidCacheKeyException
41
  */
42
  public function testGenerationKeyThrowsExceptionWhenKeyGeneratorReturnsNull()
43
  {
vendor/asm89/twig-cache-extension/test/Asm89/Twig/CacheExtension/Tests/CacheStrategy/IndexedChainingCacheStrategyTest.php CHANGED
@@ -47,13 +47,21 @@ class IndexedChainingCacheStrategyTest extends \PHPUnit_Framework_TestCase
47
  }
48
 
49
  /**
50
- * @expectedException RuntimeException
 
 
 
 
 
 
 
 
 
51
  * @expectedExceptionMessage No strategy configured with key "unknown"
52
  */
53
  public function testGenerateKeyThrowsExceptionOnUnknownKey()
54
  {
55
  $strategy = $this->createCacheStrategy();
56
-
57
  $strategy->generateKey('v42', array('unknown' => 'proxied_value'));
58
  }
59
 
47
  }
48
 
49
  /**
50
+ * @expectedException \Asm89\Twig\CacheExtension\Exception\NonExistingStrategyKeyException
51
+ */
52
+ public function testGenerateKeyThrowsExceptionOnMissingKey()
53
+ {
54
+ $strategy = $this->createCacheStrategy();
55
+ $strategy->generateKey('v42', 'proxied_value');
56
+ }
57
+
58
+ /**
59
+ * @expectedException \Asm89\Twig\CacheExtension\Exception\NonExistingStrategyException
60
  * @expectedExceptionMessage No strategy configured with key "unknown"
61
  */
62
  public function testGenerateKeyThrowsExceptionOnUnknownKey()
63
  {
64
  $strategy = $this->createCacheStrategy();
 
65
  $strategy->generateKey('v42', array('unknown' => 'proxied_value'));
66
  }
67
 
vendor/asm89/twig-cache-extension/test/Asm89/Twig/CacheExtension/Tests/CacheStrategy/LifetimeCacheStrategyTest.php CHANGED
@@ -44,7 +44,7 @@ class LifetimeCacheStrategyTest extends \PHPUnit_Framework_TestCase
44
 
45
  /**
46
  * @dataProvider getInvalidLifetimeValues
47
- * @expectedException RuntimeException
48
  */
49
  public function testGenerateKeyThrowsExceptionWhenNoLifetimeProvided($value)
50
  {
44
 
45
  /**
46
  * @dataProvider getInvalidLifetimeValues
47
+ * @expectedException \Asm89\Twig\CacheExtension\Exception\InvalidCacheLifetimeException
48
  */
49
  public function testGenerateKeyThrowsExceptionWhenNoLifetimeProvided($value)
50
  {
vendor/asm89/twig-cache-extension/test/Asm89/Twig/CacheExtension/Tests/FunctionalExtensionTest.php CHANGED
@@ -61,7 +61,6 @@ class FunctionalExtensionTest extends \PHPUnit_Framework_TestCase
61
  $loader = new Twig_Loader_Filesystem(__DIR__ . '/fixtures/');
62
  $twig = new Twig_Environment($loader);
63
 
64
- $cache = $this->createCacheProvider();
65
  $cacheExtension = new Extension($this->createCacheStrategy($cacheStrategyName));
66
 
67
  $twig->addExtension($cacheExtension);
@@ -139,7 +138,7 @@ class FunctionalExtensionTest extends \PHPUnit_Framework_TestCase
139
  {
140
  $twig = $this->createTwig('indexed');
141
 
142
- $rendered = $twig->render('ics_no_key.twig', array('value' => $this->getValue('asm89', 1)));
143
  }
144
 
145
  public function testAnnotationExpression()
@@ -162,6 +161,7 @@ class KeyGenerator implements KeyGeneratorInterface
162
 
163
  class Value
164
  {
 
165
  private $updatedAt;
166
 
167
  public function __construct($value, $updatedAt)
61
  $loader = new Twig_Loader_Filesystem(__DIR__ . '/fixtures/');
62
  $twig = new Twig_Environment($loader);
63
 
 
64
  $cacheExtension = new Extension($this->createCacheStrategy($cacheStrategyName));
65
 
66
  $twig->addExtension($cacheExtension);
138
  {
139
  $twig = $this->createTwig('indexed');
140
 
141
+ $twig->render('ics_no_key.twig', array('value' => $this->getValue('asm89', 1)));
142
  }
143
 
144
  public function testAnnotationExpression()
161
 
162
  class Value
163
  {
164
+ private $value;
165
  private $updatedAt;
166
 
167
  public function __construct($value, $updatedAt)
vendor/autoload.php CHANGED
@@ -4,4 +4,4 @@
4
 
5
  require_once __DIR__ . '/composer' . '/autoload_real.php';
6
 
7
- return ComposerAutoloaderInit2d2b9fafc2334be2a58d651726da1d81::getLoader();
4
 
5
  require_once __DIR__ . '/composer' . '/autoload_real.php';
6
 
7
+ return ComposerAutoloaderInitda6ae1fb7a0f5ad33c0ddd4db606e55b::getLoader();
vendor/composer/autoload_namespaces.php CHANGED
@@ -9,5 +9,4 @@ return array(
9
  'Twig_' => array($vendorDir . '/twig/twig/lib'),
10
  'Routes' => array($vendorDir . '/upstatement/routes'),
11
  'Composer\\Installers\\' => array($vendorDir . '/composer/installers/src'),
12
- 'Asm89\\Twig\\CacheExtension\\' => array($vendorDir . '/asm89/twig-cache-extension/lib'),
13
  );
9
  'Twig_' => array($vendorDir . '/twig/twig/lib'),
10
  'Routes' => array($vendorDir . '/upstatement/routes'),
11
  'Composer\\Installers\\' => array($vendorDir . '/composer/installers/src'),
 
12
  );
vendor/composer/autoload_psr4.php CHANGED
@@ -6,4 +6,5 @@ $vendorDir = dirname(dirname(__FILE__));
6
  $baseDir = dirname($vendorDir);
7
 
8
  return array(
 
9
  );
6
  $baseDir = dirname($vendorDir);
7
 
8
  return array(
9
+ '' => array($vendorDir . '/asm89/twig-cache-extension/lib'),
10
  );
vendor/composer/autoload_real.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
- class ComposerAutoloaderInit2d2b9fafc2334be2a58d651726da1d81
6
  {
7
  private static $loader;
8
 
@@ -19,9 +19,9 @@ class ComposerAutoloaderInit2d2b9fafc2334be2a58d651726da1d81
19
  return self::$loader;
20
  }
21
 
22
- spl_autoload_register(array('ComposerAutoloaderInit2d2b9fafc2334be2a58d651726da1d81', 'loadClassLoader'), true, true);
23
  self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
- spl_autoload_unregister(array('ComposerAutoloaderInit2d2b9fafc2334be2a58d651726da1d81', 'loadClassLoader'));
25
 
26
  $map = require __DIR__ . '/autoload_namespaces.php';
27
  foreach ($map as $namespace => $path) {
@@ -44,7 +44,7 @@ class ComposerAutoloaderInit2d2b9fafc2334be2a58d651726da1d81
44
  }
45
  }
46
 
47
- function composerRequire2d2b9fafc2334be2a58d651726da1d81($file)
48
  {
49
  require $file;
50
  }
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
+ class ComposerAutoloaderInitda6ae1fb7a0f5ad33c0ddd4db606e55b
6
  {
7
  private static $loader;
8
 
19
  return self::$loader;
20
  }
21
 
22
+ spl_autoload_register(array('ComposerAutoloaderInitda6ae1fb7a0f5ad33c0ddd4db606e55b', 'loadClassLoader'), true, true);
23
  self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
+ spl_autoload_unregister(array('ComposerAutoloaderInitda6ae1fb7a0f5ad33c0ddd4db606e55b', 'loadClassLoader'));
25
 
26
  $map = require __DIR__ . '/autoload_namespaces.php';
27
  foreach ($map as $namespace => $path) {
44
  }
45
  }
46
 
47
+ function composerRequireda6ae1fb7a0f5ad33c0ddd4db606e55b($file)
48
  {
49
  require $file;
50
  }
vendor/composer/installed.json CHANGED
@@ -1,19 +1,22 @@
1
  [
2
  {
3
  "name": "composer/installers",
4
- "version": "v1.0.21",
5
- "version_normalized": "1.0.21.0",
6
  "source": {
7
  "type": "git",
8
  "url": "https://github.com/composer/installers.git",
9
- "reference": "d64e23fce42a4063d63262b19b8e7c0f3b5e4c45"
10
  },
11
  "dist": {
12
  "type": "zip",
13
- "url": "https://api.github.com/repos/composer/installers/zipball/d64e23fce42a4063d63262b19b8e7c0f3b5e4c45",
14
- "reference": "d64e23fce42a4063d63262b19b8e7c0f3b5e4c45",
15
  "shasum": ""
16
  },
 
 
 
17
  "replace": {
18
  "roundcube/plugin-installer": "*",
19
  "shama/baton": "*"
@@ -22,10 +25,10 @@
22
  "composer/composer": "1.0.*@dev",
23
  "phpunit/phpunit": "4.1.*"
24
  },
25
- "time": "2015-02-18 17:17:01",
26
- "type": "composer-installer",
27
  "extra": {
28
- "class": "Composer\\Installers\\Installer",
29
  "branch-alias": {
30
  "dev-master": "1.0-dev"
31
  }
@@ -98,17 +101,17 @@
98
  },
99
  {
100
  "name": "twig/twig",
101
- "version": "v1.21.1",
102
- "version_normalized": "1.21.1.0",
103
  "source": {
104
  "type": "git",
105
  "url": "https://github.com/twigphp/Twig.git",
106
- "reference": "ca8d3aa90b6a01c82e07909fe815d6b443e75a23"
107
  },
108
  "dist": {
109
  "type": "zip",
110
- "url": "https://api.github.com/repos/twigphp/Twig/zipball/ca8d3aa90b6a01c82e07909fe815d6b443e75a23",
111
- "reference": "ca8d3aa90b6a01c82e07909fe815d6b443e75a23",
112
  "shasum": ""
113
  },
114
  "require": {
@@ -118,11 +121,11 @@
118
  "symfony/debug": "~2.7",
119
  "symfony/phpunit-bridge": "~2.7"
120
  },
121
- "time": "2015-08-26 08:58:31",
122
  "type": "library",
123
  "extra": {
124
  "branch-alias": {
125
- "dev-master": "1.21-dev"
126
  }
127
  },
128
  "installation-source": "dist",
@@ -161,27 +164,27 @@
161
  },
162
  {
163
  "name": "asm89/twig-cache-extension",
164
- "version": "1.0.0",
165
- "version_normalized": "1.0.0.0",
166
  "source": {
167
  "type": "git",
168
  "url": "https://github.com/asm89/twig-cache-extension.git",
169
- "reference": "92edc2ab522997fd0a2a02b6b9e89b3e08ac5c60"
170
  },
171
  "dist": {
172
  "type": "zip",
173
- "url": "https://api.github.com/repos/asm89/twig-cache-extension/zipball/92edc2ab522997fd0a2a02b6b9e89b3e08ac5c60",
174
- "reference": "92edc2ab522997fd0a2a02b6b9e89b3e08ac5c60",
175
  "shasum": ""
176
  },
177
  "require": {
178
  "php": ">=5.3.2",
179
- "twig/twig": "1.*"
180
  },
181
  "require-dev": {
182
- "doctrine/cache": "1.*"
183
  },
184
- "time": "2014-05-31 13:57:16",
185
  "type": "library",
186
  "extra": {
187
  "branch-alias": {
@@ -190,8 +193,8 @@
190
  },
191
  "installation-source": "dist",
192
  "autoload": {
193
- "psr-0": {
194
- "Asm89\\Twig\\CacheExtension\\": "lib/"
195
  }
196
  },
197
  "notification-url": "https://packagist.org/downloads/",
@@ -201,11 +204,10 @@
201
  "authors": [
202
  {
203
  "name": "Alexander",
204
- "email": "iam.asm89@gmail.com",
205
- "homepage": "http://asm89.github.io/"
206
  }
207
  ],
208
- "description": "Caching template fragments with Twig.",
209
  "homepage": "https://github.com/asm89/twig-cache-extension",
210
  "keywords": [
211
  "cache",
1
  [
2
  {
3
  "name": "composer/installers",
4
+ "version": "v1.0.22",
5
+ "version_normalized": "1.0.22.0",
6
  "source": {
7
  "type": "git",
8
  "url": "https://github.com/composer/installers.git",
9
+ "reference": "bd9b14f094c89c8b5804a4e41edeb7853bb85046"
10
  },
11
  "dist": {
12
  "type": "zip",
13
+ "url": "https://api.github.com/repos/composer/installers/zipball/bd9b14f094c89c8b5804a4e41edeb7853bb85046",
14
+ "reference": "bd9b14f094c89c8b5804a4e41edeb7853bb85046",
15
  "shasum": ""
16
  },
17
+ "require": {
18
+ "composer-plugin-api": "1.0.0"
19
+ },
20
  "replace": {
21
  "roundcube/plugin-installer": "*",
22
  "shama/baton": "*"
25
  "composer/composer": "1.0.*@dev",
26
  "phpunit/phpunit": "4.1.*"
27
  },
28
+ "time": "2015-10-29 23:28:48",
29
+ "type": "composer-plugin",
30
  "extra": {
31
+ "class": "Composer\\Installers\\Plugin",
32
  "branch-alias": {
33
  "dev-master": "1.0-dev"
34
  }
101
  },
102
  {
103
  "name": "twig/twig",
104
+ "version": "v1.23.1",
105
+ "version_normalized": "1.23.1.0",
106
  "source": {
107
  "type": "git",
108
  "url": "https://github.com/twigphp/Twig.git",
109
+ "reference": "d9b6333ae8dd2c8e3fd256e127548def0bc614c6"
110
  },
111
  "dist": {
112
  "type": "zip",
113
+ "url": "https://api.github.com/repos/twigphp/Twig/zipball/d9b6333ae8dd2c8e3fd256e127548def0bc614c6",
114
+ "reference": "d9b6333ae8dd2c8e3fd256e127548def0bc614c6",
115
  "shasum": ""
116
  },
117
  "require": {
121
  "symfony/debug": "~2.7",
122
  "symfony/phpunit-bridge": "~2.7"
123
  },
124
+ "time": "2015-11-05 12:49:06",
125
  "type": "library",
126
  "extra": {
127
  "branch-alias": {
128
+ "dev-master": "1.23-dev"
129
  }
130
  },
131
  "installation-source": "dist",
164
  },
165
  {
166
  "name": "asm89/twig-cache-extension",
167
+ "version": "1.1.0",
168
+ "version_normalized": "1.1.0.0",
169
  "source": {
170
  "type": "git",
171
  "url": "https://github.com/asm89/twig-cache-extension.git",
172
+ "reference": "127410728db193a88254c399e3455274fc05fa5d"
173
  },
174
  "dist": {
175
  "type": "zip",
176
+ "url": "https://api.github.com/repos/asm89/twig-cache-extension/zipball/127410728db193a88254c399e3455274fc05fa5d",
177
+ "reference": "127410728db193a88254c399e3455274fc05fa5d",
178
  "shasum": ""
179
  },
180
  "require": {
181
  "php": ">=5.3.2",
182
+ "twig/twig": "~1.0"
183
  },
184
  "require-dev": {
185
+ "doctrine/cache": "~1.0"
186
  },
187
+ "time": "2015-10-17 11:55:02",
188
  "type": "library",
189
  "extra": {
190
  "branch-alias": {
193
  },
194
  "installation-source": "dist",
195
  "autoload": {
196
+ "psr-4": {
197
+ "": "lib/"
198
  }
199
  },
200
  "notification-url": "https://packagist.org/downloads/",
204
  "authors": [
205
  {
206
  "name": "Alexander",
207
+ "email": "iam.asm89@gmail.com"
 
208
  }
209
  ],
210
+ "description": "Cache fragments of templates directly within Twig.",
211
  "homepage": "https://github.com/asm89/twig-cache-extension",
212
  "keywords": [
213
  "cache",
vendor/composer/installers/.travis.yml CHANGED
@@ -5,10 +5,17 @@ php:
5
  - 5.4
6
  - 5.5
7
  - 5.6
 
8
  - hhvm
9
 
10
- before_script:
11
- - curl -s http://getcomposer.org/installer | php -- --quiet
12
- - php composer.phar install --dev
 
13
 
14
- script: phpunit
 
 
 
 
 
5
  - 5.4
6
  - 5.5
7
  - 5.6
8
+ - 7.0
9
  - hhvm
10
 
11
+ matrix:
12
+ fast_finish: true
13
+ allow_failures:
14
+ - php: 7.0
15
 
16
+ before_script:
17
+ - composer self-update
18
+ - composer install
19
+
20
+ script:
21
+ - phpunit
vendor/composer/installers/README.md CHANGED
@@ -36,6 +36,7 @@ is not needed to install packages with these frameworks:
36
  | Aimeos | `aimeos-extension`
37
  | Asgard | `asgard-module`<br>`asgard-theme`
38
  | AGL | `agl-module`
 
39
  | AnnotateCms | `annotatecms-module`<br>`annotatecms-component`<br>`annotatecms-service`
40
  | Bitrix | `bitrix-module`<br>`bitrix-component`<br>`bitrix-theme`
41
  | CakePHP 2+ | **`cakephp-plugin`**
@@ -55,6 +56,7 @@ is not needed to install packages with these frameworks:
55
  | Hurad | `hurad-plugin`<br>`hurad-theme`
56
  | Joomla | `joomla-component`<br>`joomla-module`<br>`joomla-template`<br>`joomla-plugin`<br>`joomla-library`
57
  | Kirby | **`kirby-plugin`**
 
58
  | Kohana | **`kohana-module`**
59
  | Laravel | `laravel-library`
60
  | Lithium | **`lithium-library`<br>`lithium-source`**
@@ -166,8 +168,8 @@ not be inflected.
166
  ## Contribute!
167
 
168
  * [Fork and clone](https://help.github.com/articles/fork-a-repo).
169
- * Run the command `php composer.phar install --dev` to install the dev
170
- dependencies. See [Composer](https://github.com/composer/composer#installation--usage).
171
  * Use the command `phpunit` to run the tests. See [PHPUnit](http://phpunit.de).
172
  * Create a branch, commit, push and send us a
173
  [pull request](https://help.github.com/articles/using-pull-requests).
36
  | Aimeos | `aimeos-extension`
37
  | Asgard | `asgard-module`<br>`asgard-theme`
38
  | AGL | `agl-module`
39
+ | Bonefish | `bonefish-package`
40
  | AnnotateCms | `annotatecms-module`<br>`annotatecms-component`<br>`annotatecms-service`
41
  | Bitrix | `bitrix-module`<br>`bitrix-component`<br>`bitrix-theme`
42
  | CakePHP 2+ | **`cakephp-plugin`**
56
  | Hurad | `hurad-plugin`<br>`hurad-theme`
57
  | Joomla | `joomla-component`<br>`joomla-module`<br>`joomla-template`<br>`joomla-plugin`<br>`joomla-library`
58
  | Kirby | **`kirby-plugin`**
59
+ | KodiCMS | `kodicms-plugin`<br>`kodicms-media`
60
  | Kohana | **`kohana-module`**
61
  | Laravel | `laravel-library`
62
  | Lithium | **`lithium-library`<br>`lithium-source`**
168
  ## Contribute!
169
 
170
  * [Fork and clone](https://help.github.com/articles/fork-a-repo).
171
+ * Run the command `php composer.phar install` to install the dependencies.
172
+ This will also install the dev dependencies. See [Composer](https://getcomposer.org/doc/03-cli.md#install).
173
  * Use the command `phpunit` to run the tests. See [PHPUnit](http://phpunit.de).
174
  * Create a branch, commit, push and send us a
175
  [pull request](https://help.github.com/articles/using-pull-requests).
vendor/composer/installers/composer.json CHANGED
@@ -1,6 +1,6 @@
1
  {
2
  "name": "composer/installers",
3
- "type": "composer-installer",
4
  "license": "MIT",
5
  "description": "A multi-framework Composer library installer",
6
  "keywords": [
@@ -61,7 +61,7 @@
61
  "psr-0": { "Composer\\Installers\\": "src/" }
62
  },
63
  "extra": {
64
- "class": "Composer\\Installers\\Installer",
65
  "branch-alias": {
66
  "dev-master": "1.0-dev"
67
  }
@@ -70,6 +70,9 @@
70
  "shama/baton": "*",
71
  "roundcube/plugin-installer": "*"
72
  },
 
 
 
73
  "require-dev": {
74
  "composer/composer": "1.0.*@dev",
75
  "phpunit/phpunit": "4.1.*"
1
  {
2
  "name": "composer/installers",
3
+ "type": "composer-plugin",
4
  "license": "MIT",
5
  "description": "A multi-framework Composer library installer",
6
  "keywords": [
61
  "psr-0": { "Composer\\Installers\\": "src/" }
62
  },
63
  "extra": {
64
+ "class": "Composer\\Installers\\Plugin",
65
  "branch-alias": {
66
  "dev-master": "1.0-dev"
67
  }
70
  "shama/baton": "*",
71
  "roundcube/plugin-installer": "*"
72
  },
73
+ "require": {
74
+ "composer-plugin-api": "1.0.0"
75
+ },
76
  "require-dev": {
77
  "composer/composer": "1.0.*@dev",
78
  "phpunit/phpunit": "4.1.*"
vendor/composer/installers/src/Composer/Installers/BaseInstaller.php CHANGED
@@ -1,6 +1,7 @@
1
  <?php
2
  namespace Composer\Installers;
3
 
 
4
  use Composer\Composer;
5
  use Composer\Package\PackageInterface;
6
 
@@ -9,17 +10,20 @@ abstract class BaseInstaller
9
  protected $locations = array();
10
  protected $composer;
11
  protected $package;
 
12
 
13
  /**
14
  * Initializes base installer.
15
  *
16
  * @param PackageInterface $package
17
  * @param Composer $composer
 
18
  */
19
- public function __construct(PackageInterface $package = null, Composer $composer = null)
20
  {
21
  $this->composer = $composer;
22
  $this->package = $package;
 
23
  }
24
 
25
  /**
1
  <?php
2
  namespace Composer\Installers;
3
 
4
+ use Composer\IO\IOInterface;
5
  use Composer\Composer;
6
  use Composer\Package\PackageInterface;
7
 
10
  protected $locations = array();
11
  protected $composer;
12
  protected $package;
13
+ protected $io;
14
 
15
  /**
16
  * Initializes base installer.
17
  *
18
  * @param PackageInterface $package
19
  * @param Composer $composer
20
+ * @param IOInterface $io
21
  */
22
+ public function __construct(PackageInterface $package = null, Composer $composer = null, IOInterface $io = null)
23
  {
24
  $this->composer = $composer;
25
  $this->package = $package;
26
+ $this->io = $io;
27
  }
28
 
29
  /**
vendor/composer/installers/src/Composer/Installers/BitrixInstaller.php CHANGED
@@ -1,11 +1,89 @@
1
  <?php
2
  namespace Composer\Installers;
3
 
 
 
 
 
 
 
 
 
4
  class BitrixInstaller extends BaseInstaller
5
  {
6
  protected $locations = array(
7
- 'module' => 'local/modules/{$name}/',
8
- 'component' => 'local/components/{$name}/',
9
- 'theme' => 'local/templates/{$name}/'
10
  );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  }
1
  <?php
2
  namespace Composer\Installers;
3
 
4
+ use Composer\Util\Filesystem;
5
+
6
+ /**
7
+ * Installer for Bitrix Framework
8
+ *
9
+ * @author Nik Samokhvalov <nik@samokhvalov.info>
10
+ * @author Denis Kulichkin <onexhovia@gmail.com>
11
+ */
12
  class BitrixInstaller extends BaseInstaller
13
  {
14
  protected $locations = array(
15
+ 'module' => 'bitrix/modules/{$name}/',
16
+ 'component' => 'bitrix/components/{$name}/',
17
+ 'theme' => 'bitrix/templates/{$name}/',
18
  );
19
+
20
+ /**
21
+ * @var array Storage for informations about duplicates at all the time of installation packages
22
+ */
23
+ private static $checkedDuplicates = array();
24
+
25
+ /**
26
+ * {@inheritdoc}
27
+ */
28
+ protected function templatePath($path, array $vars = array())
29
+ {
30
+ $templatePath = parent::templatePath($path, $vars);
31
+ $this->checkDuplicates($templatePath, $vars);
32
+
33
+ return $templatePath;
34
+ }
35
+
36
+ /**
37
+ * Duplicates search packages
38
+ *
39
+ * @param string $templatePath
40
+ * @param array $vars
41
+ */
42
+ protected function checkDuplicates($templatePath, array $vars = array())
43
+ {
44
+ /**
45
+ * Incorrect paths for backward compatibility
46
+ */
47
+ $oldLocations = array(
48
+ 'module' => 'local/modules/{$name}/',
49
+ 'component' => 'local/components/{$name}/',
50
+ 'theme' => 'local/templates/{$name}/'
51
+ );
52
+
53
+ $packageType = substr($vars['type'], strlen('bitrix') + 1);
54
+ $oldLocation = str_replace('{$name}', $vars['name'], $oldLocations[$packageType]);
55
+
56
+ if (in_array($oldLocation, static::$checkedDuplicates)) {
57
+ return;
58
+ }
59
+
60
+ if ($oldLocation !== $templatePath && file_exists($oldLocation) && $this->io && $this->io->isInteractive()) {
61
+
62
+ $this->io->writeError(' <error>Duplication of packages:</error>');
63
+ $this->io->writeError(' <info>Package ' . $oldLocation . ' will be called instead package ' . $templatePath . '</info>');
64
+
65
+ while (true) {
66
+ switch ($this->io->ask(' <info>Delete ' . $oldLocation . ' [y,n,?]?</info> ', '?')) {
67
+ case 'y':
68
+ $fs = new Filesystem();
69
+ $fs->removeDirectory($oldLocation);
70
+ break 2;
71
+
72
+ case 'n':
73
+ break 2;
74
+
75
+ case '?':
76
+ default:
77
+ $this->io->writeError(array(
78
+ ' y - delete package ' . $oldLocation . ' and to continue with the installation',
79
+ ' n - don\'t delete and to continue with the installation',
80
+ ));
81
+ $this->io->writeError(' ? - print help');
82
+ break;
83
+ }
84
+ }
85
+ }
86
+
87
+ static::$checkedDuplicates[] = $oldLocation;
88
+ }
89
  }
vendor/composer/installers/src/Composer/Installers/BonefishInstaller.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Composer\Installers;
3
+
4
+ class BonefishInstaller extends BaseInstaller
5
+ {
6
+ protected $locations = array(
7
+ 'package' => 'Packages/{$vendor}/{$name}/'
8
+ );
9
+ }
vendor/composer/installers/src/Composer/Installers/CakePHPInstaller.php CHANGED
@@ -3,8 +3,6 @@ namespace Composer\Installers;
3
 
4
  use Composer\DependencyResolver\Pool;
5
  use Composer\Package\PackageInterface;
6
- use Composer\Package\LinkConstraint\MultiConstraint;
7
- use Composer\Package\LinkConstraint\VersionConstraint;
8
 
9
  class CakePHPInstaller extends BaseInstaller
10
  {
@@ -52,21 +50,29 @@ class CakePHPInstaller extends BaseInstaller
52
  */
53
  protected function matchesCakeVersion($matcher, $version)
54
  {
 
 
 
 
 
 
 
 
55
  $repositoryManager = $this->composer->getRepositoryManager();
56
  if ($repositoryManager) {
57
  $repos = $repositoryManager->getLocalRepository();
58
  if (!$repos) {
59
  return false;
60
  }
61
- $cake3 = new MultiConstraint(array(
62
- new VersionConstraint($matcher, $version),
63
- new VersionConstraint('!=', '9999999-dev'),
64
  ));
65
  $pool = new Pool('dev');
66
  $pool->addRepository($repos);
67
  $packages = $pool->whatProvides('cakephp/cakephp');
68
  foreach ($packages as $package) {
69
- $installed = new VersionConstraint('=', $package->getVersion());
70
  if ($cake3->matches($installed)) {
71
  return true;
72
  break;
3
 
4
  use Composer\DependencyResolver\Pool;
5
  use Composer\Package\PackageInterface;
 
 
6
 
7
  class CakePHPInstaller extends BaseInstaller
8
  {
50
  */
51
  protected function matchesCakeVersion($matcher, $version)
52
  {
53
+ if (class_exists('Composer\Semver\Constraint\MultiConstraint')) {
54
+ $multiClass = 'Composer\Semver\Constraint\MultiConstraint';
55
+ $constraintClass = 'Composer\Semver\Constraint\Constraint';
56
+ } else {
57
+ $multiClass = 'Composer\Package\LinkConstraint\MultiConstraint';
58
+ $constraintClass = 'Composer\Package\LinkConstraint\VersionConstraint';
59
+ }
60
+
61
  $repositoryManager = $this->composer->getRepositoryManager();
62
  if ($repositoryManager) {
63
  $repos = $repositoryManager->getLocalRepository();
64
  if (!$repos) {
65
  return false;
66
  }
67
+ $cake3 = new $multiClass(array(
68
+ new $constraintClass($matcher, $version),
69
+ new $constraintClass('!=', '9999999-dev'),
70
  ));
71
  $pool = new Pool('dev');
72
  $pool->addRepository($repos);
73
  $packages = $pool->whatProvides('cakephp/cakephp');
74
  foreach ($packages as $package) {
75
+ $installed = new $constraintClass('=', $package->getVersion());
76
  if ($cake3->matches($installed)) {
77
  return true;
78
  break;
vendor/composer/installers/src/Composer/Installers/CraftInstaller.php CHANGED
@@ -1,9 +1,35 @@
1
  <?php
2
  namespace Composer\Installers;
3
 
 
 
 
4
  class CraftInstaller extends BaseInstaller
5
  {
 
 
 
6
  protected $locations = array(
7
  'plugin' => 'craft/plugins/{$name}/',
8
  );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  }
1
  <?php
2
  namespace Composer\Installers;
3
 
4
+ /**
5
+ * Installer for Craft Plugins
6
+ */
7
  class CraftInstaller extends BaseInstaller
8
  {
9
+ const NAME_PREFIX = 'craft';
10
+ const NAME_SUFFIX = 'plugin';
11
+
12
  protected $locations = array(
13
  'plugin' => 'craft/plugins/{$name}/',
14
  );
15
+
16
+ /**
17
+ * Strip `craft-` prefix and/or `-plugin` suffix from package names
18
+ *
19
+ * @param array $vars
20
+ *
21
+ * @return array
22
+ */
23
+ final public function inflectPackageVars($vars)
24
+ {
25
+ return $this->inflectPluginVars($vars);
26
+ }
27
+
28
+ private function inflectPluginVars($vars)
29
+ {
30
+ $vars['name'] = preg_replace('/-' . self::NAME_SUFFIX . '$/i', '', $vars['name']);
31
+ $vars['name'] = preg_replace('/^' . self::NAME_PREFIX . '-/i', '', $vars['name']);
32
+
33
+ return $vars;
34
+ }
35
  }
vendor/composer/installers/src/Composer/Installers/Installer.php CHANGED
@@ -1,6 +1,7 @@
1
  <?php
2
  namespace Composer\Installers;
3
 
 
4
  use Composer\Installer\LibraryInstaller;
5
  use Composer\Package\PackageInterface;
6
  use Composer\Repository\InstalledRepositoryInterface;
@@ -18,6 +19,7 @@ class Installer extends LibraryInstaller
18
  'agl' => 'AglInstaller',
19
  'annotatecms' => 'AnnotateCmsInstaller',
20
  'bitrix' => 'BitrixInstaller',
 
21
  'cakephp' => 'CakePHPInstaller',
22
  'chef' => 'ChefInstaller',
23
  'ccframework' => 'ClanCatsFrameworkInstaller',
@@ -35,6 +37,7 @@ class Installer extends LibraryInstaller
35
  'hurad' => 'HuradInstaller',
36
  'joomla' => 'JoomlaInstaller',
37
  'kirby' => 'KirbyInstaller',
 
38
  'kohana' => 'KohanaInstaller',
39
  'laravel' => 'LaravelInstaller',
40
  'lithium' => 'LithiumInstaller',
@@ -67,7 +70,7 @@ class Installer extends LibraryInstaller
67
  'wordpress' => 'WordPressInstaller',
68
  'zend' => 'ZendInstaller',
69
  'zikula' => 'ZikulaInstaller',
70
- 'prestashop' => 'PrestashopInstaller',
71
  );
72
 
73
  /**
@@ -85,7 +88,7 @@ class Installer extends LibraryInstaller
85
  }
86
 
87
  $class = 'Composer\\Installers\\' . $this->supportedTypes[$frameworkType];
88
- $installer = new $class($package, $this->composer);
89
 
90
  return $installer->getInstallPath($package, $frameworkType);
91
  }
@@ -153,11 +156,21 @@ class Installer extends LibraryInstaller
153
  if (!empty($this->supportedTypes[$frameworkType])) {
154
  $frameworkClass = 'Composer\\Installers\\' . $this->supportedTypes[$frameworkType];
155
  /** @var BaseInstaller $framework */
156
- $framework = new $frameworkClass(null, $this->composer);
157
  $locations = array_keys($framework->getLocations());
158
  $pattern = $locations ? '(' . implode('|', $locations) . ')' : false;
159
  }
160
 
161
  return $pattern ? : '(\w+)';
162
  }
 
 
 
 
 
 
 
 
 
 
163
  }
1
  <?php
2
  namespace Composer\Installers;
3
 
4
+ use Composer\IO\IOInterface;
5
  use Composer\Installer\LibraryInstaller;
6
  use Composer\Package\PackageInterface;
7
  use Composer\Repository\InstalledRepositoryInterface;
19
  'agl' => 'AglInstaller',
20
  'annotatecms' => 'AnnotateCmsInstaller',
21
  'bitrix' => 'BitrixInstaller',
22
+ 'bonefish' => 'BonefishInstaller',
23
  'cakephp' => 'CakePHPInstaller',
24
  'chef' => 'ChefInstaller',
25
  'ccframework' => 'ClanCatsFrameworkInstaller',
37
  'hurad' => 'HuradInstaller',
38
  'joomla' => 'JoomlaInstaller',
39
  'kirby' => 'KirbyInstaller',
40
+ 'kodicms' => 'KodiCMSInstaller',
41
  'kohana' => 'KohanaInstaller',
42
  'laravel' => 'LaravelInstaller',
43
  'lithium' => 'LithiumInstaller',
70
  'wordpress' => 'WordPressInstaller',
71
  'zend' => 'ZendInstaller',
72
  'zikula' => 'ZikulaInstaller',
73
+ 'prestashop' => 'PrestashopInstaller'
74
  );
75
 
76
  /**
88
  }
89
 
90
  $class = 'Composer\\Installers\\' . $this->supportedTypes[$frameworkType];
91
+ $installer = new $class($package, $this->composer, $this->getIO());
92
 
93
  return $installer->getInstallPath($package, $frameworkType);
94
  }
156
  if (!empty($this->supportedTypes[$frameworkType])) {
157
  $frameworkClass = 'Composer\\Installers\\' . $this->supportedTypes[$frameworkType];
158
  /** @var BaseInstaller $framework */
159
+ $framework = new $frameworkClass(null, $this->composer, $this->getIO());
160
  $locations = array_keys($framework->getLocations());
161
  $pattern = $locations ? '(' . implode('|', $locations) . ')' : false;
162
  }
163
 
164
  return $pattern ? : '(\w+)';
165
  }
166
+
167
+ /**
168
+ * Get I/O object
169
+ *
170
+ * @return IOInterface
171
+ */
172
+ private function getIO()
173
+ {
174
+ return $this->io;
175
+ }
176
  }
vendor/composer/installers/src/Composer/Installers/KodiCMSInstaller.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Composer\Installers;
3
+
4
+ class KodiCMSInstaller extends BaseInstaller
5
+ {
6
+ protected $locations = array(
7
+ 'plugin' => 'cms/plugins/{$name}/',
8
+ 'media' => 'cms/media/vendor/{$name}/'
9
+ );
10
+ }
vendor/composer/installers/src/Composer/Installers/MoodleInstaller.php CHANGED
@@ -6,6 +6,7 @@ class MoodleInstaller extends BaseInstaller
6
  protected $locations = array(
7
  'mod' => 'mod/{$name}/',
8
  'admin_report' => 'admin/report/{$name}/',
 
9
  'tool' => 'admin/tool/{$name}/',
10
  'assignment' => 'mod/assignment/type/{$name}/',
11
  'assignsubmission' => 'mod/assign/submission/{$name}/',
@@ -13,6 +14,9 @@ class MoodleInstaller extends BaseInstaller
13
  'auth' => 'auth/{$name}/',
14
  'availability' => 'availability/condition/{$name}/',
15
  'block' => 'blocks/{$name}/',
 
 
 
16
  'calendartype' => 'calendar/type/{$name}/',
17
  'format' => 'course/format/{$name}/',
18
  'coursereport' => 'course/report/{$name}/',
@@ -26,7 +30,11 @@ class MoodleInstaller extends BaseInstaller
26
  'gradereport' => 'grade/report/{$name}/',
27
  'gradingform' => 'grade/grading/form/{$name}/',
28
  'local' => 'local/{$name}/',
 
 
 
29
  'message' => 'message/output/{$name}/',
 
30
  'plagiarism' => 'plagiarism/{$name}/',
31
  'portfolio' => 'portfolio/{$name}/',
32
  'qbehaviour' => 'question/behaviour/{$name}/',
@@ -38,6 +46,7 @@ class MoodleInstaller extends BaseInstaller
38
  'repository' => 'repository/{$name}/',
39
  'scormreport' => 'mod/scorm/report/{$name}/',
40
  'theme' => 'theme/{$name}/',
 
41
  'profilefield' => 'user/profile/field/{$name}/',
42
  'webservice' => 'webservice/{$name}/',
43
  'workshopallocation' => 'mod/workshop/allocation/{$name}/',
6
  protected $locations = array(
7
  'mod' => 'mod/{$name}/',
8
  'admin_report' => 'admin/report/{$name}/',
9
+ 'atto' => 'lib/editor/atto/plugins/{$name}/',
10
  'tool' => 'admin/tool/{$name}/',
11
  'assignment' => 'mod/assignment/type/{$name}/',
12
  'assignsubmission' => 'mod/assign/submission/{$name}/',
14
  'auth' => 'auth/{$name}/',
15
  'availability' => 'availability/condition/{$name}/',
16
  'block' => 'blocks/{$name}/',
17
+ 'booktool' => 'mod/book/tool/{$name}/',
18
+ 'cachestore' => 'cache/stores/{$name}/',
19
+ 'cachelock' => 'cache/locks/{$name}/',
20
  'calendartype' => 'calendar/type/{$name}/',
21
  'format' => 'course/format/{$name}/',
22
  'coursereport' => 'course/report/{$name}/',
30
  'gradereport' => 'grade/report/{$name}/',
31
  'gradingform' => 'grade/grading/form/{$name}/',
32
  'local' => 'local/{$name}/',
33
+ 'logstore' => 'admin/tool/log/store/{$name}/',
34
+ 'ltisource' => 'mod/lti/source/{$name}/',
35
+ 'ltiservice' => 'mod/lti/service/{$name}/',
36
  'message' => 'message/output/{$name}/',
37
+ 'mnetservice' => 'mnet/service/{$name}/',
38
  'plagiarism' => 'plagiarism/{$name}/',
39
  'portfolio' => 'portfolio/{$name}/',
40
  'qbehaviour' => 'question/behaviour/{$name}/',
46
  'repository' => 'repository/{$name}/',
47
  'scormreport' => 'mod/scorm/report/{$name}/',
48
  'theme' => 'theme/{$name}/',
49
+ 'tinymce' => 'lib/editor/tinymce/plugins/{$name}/',
50
  'profilefield' => 'user/profile/field/{$name}/',
51
  'webservice' => 'webservice/{$name}/',
52
  'workshopallocation' => 'mod/workshop/allocation/{$name}/',
vendor/composer/installers/src/Composer/Installers/Plugin.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Composer\Installers;
4
+
5
+ use Composer\Composer;
6
+ use Composer\IO\IOInterface;
7
+ use Composer\Plugin\PluginInterface;
8
+
9
+ class Plugin implements PluginInterface
10
+ {
11
+
12
+ public function activate(Composer $composer, IOInterface $io)
13
+ {
14
+ $installer = new Installer($io, $composer);
15
+ $composer->getInstallationManager()->addInstaller($installer);
16
+ }
17
+ }
vendor/composer/installers/tests/Composer/Installers/Test/CakePHPInstallerTest.php CHANGED
@@ -100,7 +100,7 @@ class CakePHPInstallerTest extends TestCase
100
 
101
  $this->setCakephpVersion($rm, '~8.8');
102
  $result = $installer->getLocations();
103
- $this->assertEquals('vendor/{$vendor}/{$name}/', $result['plugin']);
104
  }
105
 
106
  protected function setCakephpVersion($rm, $version) {
100
 
101
  $this->setCakephpVersion($rm, '~8.8');
102
  $result = $installer->getLocations();
103
+ $this->assertContains('vendor/{$vendor}/{$name}/', $result['plugin']);
104
  }
105
 
106
  protected function setCakephpVersion($rm, $version) {
vendor/composer/installers/tests/Composer/Installers/Test/CraftInstallerTest.php ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Composer\Installers\Test;
4
+
5
+ use Composer\Installers\CraftInstaller;
6
+
7
+ /**
8
+ * Tests for the CraftInstaller Class
9
+ *
10
+ * @coversDefaultClass Composer\Installers\CraftInstaller
11
+ */
12
+ class CraftInstallerTest extends TestCase
13
+ {
14
+ /** @var CraftInstaller */
15
+ private $installer;
16
+
17
+ /**
18
+ * Sets up the fixture, for example, instantiate the class-under-test.
19
+ *
20
+ * This method is called before a test is executed.
21
+ */
22
+ final public function setup()
23
+ {
24
+ $this->installer = new CraftInstaller();
25
+ }
26
+
27
+ /**
28
+ * @param string $packageName
29
+ * @param string $expectedName
30
+ *
31
+ * @covers ::inflectPackageVars
32
+ *
33
+ * @dataProvider provideExpectedInflectionResults
34
+ */
35
+ final public function testInflectPackageVars($packageName, $expectedName)
36
+ {
37
+ $installer = $this->installer;
38
+
39
+ $vars = array('name' => $packageName);
40
+ $expected = array('name' => $expectedName);
41
+
42
+ $actual = $installer->inflectPackageVars($vars);
43
+
44
+ $this->assertEquals($actual, $expected);
45
+ }
46
+
47
+ /**
48
+ * Provides various names for packages and the expected result after inflection
49
+ *
50
+ * @return array
51
+ */
52
+ final public function provideExpectedInflectionResults()
53
+ {
54
+ return array(
55
+ // lowercase
56
+ array('foo', 'foo'),
57
+ array('craftfoo', 'craftfoo'),
58
+ array('fooplugin', 'fooplugin'),
59
+ array('craftfooplugin', 'craftfooplugin'),
60
+ // lowercase - dash
61
+ array('craft-foo', 'foo'),
62
+ array('foo-plugin', 'foo'),
63
+ array('craft-foo-plugin', 'foo'),
64
+ // lowercase - underscore
65
+ array('craft_foo', 'craft_foo'),
66
+ array('foo_plugin', 'foo_plugin'),
67
+ array('craft_foo_plugin', 'craft_foo_plugin'),
68
+ // CamelCase
69
+ array('Foo', 'Foo'),
70
+ array('CraftFoo', 'CraftFoo'),
71
+ array('FooPlugin', 'FooPlugin'),
72
+ array('CraftFooPlugin', 'CraftFooPlugin'),
73
+ // CamelCase - Dash
74
+ array('Craft-Foo', 'Foo'),
75
+ array('Foo-Plugin', 'Foo'),
76
+ array('Craft-Foo-Plugin', 'Foo'),
77
+ // CamelCase - underscore
78
+ array('Craft_Foo', 'Craft_Foo'),
79
+ array('Foo_Plugin', 'Foo_Plugin'),
80
+ array('Craft_Foo_Plugin', 'Craft_Foo_Plugin'),
81
+ );
82
+ }
83
+ }
vendor/composer/installers/tests/Composer/Installers/Test/InstallerTest.php CHANGED
@@ -92,6 +92,7 @@ class InstallerTest extends TestCase
92
  array('bitrix-module', true),
93
  array('bitrix-component', true),
94
  array('bitrix-theme', true),
 
95
  array('cakephp', false),
96
  array('cakephp-', false),
97
  array('cakephp-app', false),
@@ -173,6 +174,8 @@ class InstallerTest extends TestCase
173
  array('zend-library', true),
174
  array('zikula-module', true),
175
  array('zikula-theme', true),
 
 
176
  );
177
  }
178
 
@@ -202,9 +205,10 @@ class InstallerTest extends TestCase
202
  array('annotatecms-module', 'addons/modules/my_module/', 'vysinsky/my_module'),
203
  array('annotatecms-component', 'addons/components/my_component/', 'vysinsky/my_component'),
204
  array('annotatecms-service', 'addons/services/my_service/', 'vysinsky/my_service'),
205
- array('bitrix-module', 'local/modules/my_module/', 'author/my_module'),
206
- array('bitrix-component', 'local/components/my_component/', 'author/my_component'),
207
- array('bitrix-theme', 'local/templates/my_theme/', 'author/my_theme'),
 
208
  array('cakephp-plugin', 'Plugin/Ftp/', 'shama/ftp'),
209
  array('chef-cookbook', 'Chef/mre/my_cookbook/', 'mre/my_cookbook'),
210
  array('chef-role', 'Chef/roles/my_role/', 'mre/my_role'),
@@ -297,6 +301,8 @@ class InstallerTest extends TestCase
297
  array('zend-extra', 'extras/library/zend_test/', 'shama/zend_test'),
298
  array('zikula-module', 'modules/my-test_module/', 'my/test_module'),
299
  array('zikula-theme', 'themes/my-test_theme/', 'my/test_theme'),
 
 
300
  );
301
  }
302
 
92
  array('bitrix-module', true),
93
  array('bitrix-component', true),
94
  array('bitrix-theme', true),
95
+ array('bonefish-package', true),
96
  array('cakephp', false),
97
  array('cakephp-', false),
98
  array('cakephp-app', false),
174
  array('zend-library', true),
175
  array('zikula-module', true),
176
  array('zikula-theme', true),
177
+ array('kodicms-plugin', true),
178
+ array('kodicms-media', true),
179
  );
180
  }
181
 
205
  array('annotatecms-module', 'addons/modules/my_module/', 'vysinsky/my_module'),
206
  array('annotatecms-component', 'addons/components/my_component/', 'vysinsky/my_component'),
207
  array('annotatecms-service', 'addons/services/my_service/', 'vysinsky/my_service'),
208
+ array('bitrix-module', 'bitrix/modules/my_module/', 'author/my_module'),
209
+ array('bitrix-component', 'bitrix/components/my_component/', 'author/my_component'),
210
+ array('bitrix-theme', 'bitrix/templates/my_theme/', 'author/my_theme'),
211
+ array('bonefish-package', 'Packages/bonefish/package/', 'bonefish/package'),
212
  array('cakephp-plugin', 'Plugin/Ftp/', 'shama/ftp'),
213
  array('chef-cookbook', 'Chef/mre/my_cookbook/', 'mre/my_cookbook'),
214
  array('chef-role', 'Chef/roles/my_role/', 'mre/my_role'),
301
  array('zend-extra', 'extras/library/zend_test/', 'shama/zend_test'),
302
  array('zikula-module', 'modules/my-test_module/', 'my/test_module'),
303
  array('zikula-theme', 'themes/my-test_theme/', 'my/test_theme'),
304
+ array('kodicms-media', 'cms/media/vendor/my_media/', 'shama/my_media'),
305
+ array('kodicms-plugin', 'cms/plugins/my_plugin/', 'shama/my_plugin'),
306
  );
307
  }
308
 
vendor/twig/twig/CHANGELOG CHANGED
@@ -1,3 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  * 1.21.1 (2015-08-26)
2
 
3
  * fixed regression when using the deprecated Twig_Test_* classes
1
+ * 1.23.1 (2015-XX-XX)
2
+
3
+ * fixed some exception messages which triggered PHP warnings
4
+ * fixed BC on Twig_Test_NodeTestCase
5
+
6
+ * 1.23.0 (2015-10-29)
7
+
8
+ * deprecated the possibility to override an extension by registering another one with the same name
9
+ * deprecated Twig_ExtensionInterface::getGlobals() (added Twig_Extension_GlobalsInterface for BC)
10
+ * deprecated Twig_ExtensionInterface::initRuntime() (added Twig_Extension_InitRuntimeInterface for BC)
11
+ * deprecated Twig_Environment::computeAlternatives()
12
+
13
+ * 1.22.3 (2015-10-13)
14
+
15
+ * fixed regression when using null as a cache strategy
16
+ * improved performance when checking template freshness
17
+ * fixed warnings when loaded templates do not exist
18
+ * fixed template class name generation to prevent possible collisions
19
+ * fixed logic for custom escapers to call them even on integers and null values
20
+ * changed template cache names to take into account the Twig C extension
21
+
22
+ * 1.22.2 (2015-09-22)
23
+
24
+ * fixed a race condition in template loading
25
+
26
+ * 1.22.1 (2015-09-15)
27
+
28
+ * fixed regression in template_from_string
29
+
30
+ * 1.22.0 (2015-09-13)
31
+
32
+ * made Twig_Test_IntegrationTestCase more flexible
33
+ * added an option to force PHP bytecode invalidation when writing a compiled template into the cache
34
+ * fixed the profiler duration for the root node
35
+ * changed template cache names to take into account enabled extensions
36
+ * deprecated Twig_Environment::clearCacheFiles(), Twig_Environment::getCacheFilename(),
37
+ Twig_Environment::writeCacheFile(), and Twig_Environment::getTemplateClassPrefix()
38
+ * added a way to override the filesystem template cache system
39
+ * added a way to get the original template source from Twig_Template
40
+
41
+ * 1.21.2 (2015-09-09)
42
+
43
+ * fixed variable names for the deprecation triggering code
44
+ * fixed escaping strategy detection based on filename
45
+ * added Traversable support for replace, merge, and sort
46
+ * deprecated support for character by character replacement for the "replace" filter
47
+
48
  * 1.21.1 (2015-08-26)
49
 
50
  * fixed regression when using the deprecated Twig_Test_* classes
vendor/twig/twig/composer.json CHANGED
@@ -40,7 +40,7 @@
40
  },
41
  "extra": {
42
  "branch-alias": {
43
- "dev-master": "1.21-dev"
44
  }
45
  }
46
  }
40
  },
41
  "extra": {
42
  "branch-alias": {
43
+ "dev-master": "1.23-dev"
44
  }
45
  }
46
  }
vendor/twig/twig/doc/advanced.rst CHANGED
@@ -553,6 +553,8 @@ An extension is a class that implements the following interface::
553
  * This is where you can load some file that contains filter functions for instance.
554
  *
555
  * @param Twig_Environment $environment The current Twig_Environment instance
 
 
556
  */
557
  function initRuntime(Twig_Environment $environment);
558
 
@@ -602,6 +604,8 @@ An extension is a class that implements the following interface::
602
  * Returns a list of global variables to add to the existing list.
603
  *
604
  * @return array An array of global variables
 
 
605
  */
606
  function getGlobals();
607
 
@@ -645,9 +649,6 @@ main ``Environment`` object::
645
  $twig = new Twig_Environment($loader);
646
  $twig->addExtension(new Project_Twig_Extension());
647
 
648
- Of course, you need to first load the extension file by either using
649
- ``require_once()`` or by using an autoloader (see `spl_autoload_register()`_).
650
-
651
  .. tip::
652
 
653
  The bundled extensions are great examples of how extensions work.
@@ -866,7 +867,6 @@ Testing the node visitors can be complex, so extend your test cases from
866
  ``Twig_Test_NodeTestCase``. Examples can be found in the Twig repository
867
  `tests/Twig/Node`_ directory.
868
 
869
- .. _`spl_autoload_register()`: http://www.php.net/spl_autoload_register
870
  .. _`rot13`: http://www.php.net/manual/en/function.str-rot13.php
871
  .. _`tests/Twig/Fixtures`: https://github.com/twigphp/Twig/tree/master/test/Twig/Tests/Fixtures
872
  .. _`tests/Twig/Node`: https://github.com/twigphp/Twig/tree/master/test/Twig/Tests/Node
553
  * This is where you can load some file that contains filter functions for instance.
554
  *
555
  * @param Twig_Environment $environment The current Twig_Environment instance
556
+ *
557
+ * @deprecated since 1.23 (to be removed in 2.0), implement Twig_Extension_InitRuntimeInterace instead
558
  */
559
  function initRuntime(Twig_Environment $environment);
560
 
604
  * Returns a list of global variables to add to the existing list.
605
  *
606
  * @return array An array of global variables
607
+ *
608
+ * @deprecated since 1.23 (to be removed in 2.0), implement Twig_Extension_GlobalsInterface instead
609
  */
610
  function getGlobals();
611
 
649
  $twig = new Twig_Environment($loader);
650
  $twig->addExtension(new Project_Twig_Extension());
651
 
 
 
 
652
  .. tip::
653
 
654
  The bundled extensions are great examples of how extensions work.
867
  ``Twig_Test_NodeTestCase``. Examples can be found in the Twig repository
868
  `tests/Twig/Node`_ directory.
869
 
 
870
  .. _`rot13`: http://www.php.net/manual/en/function.str-rot13.php
871
  .. _`tests/Twig/Fixtures`: https://github.com/twigphp/Twig/tree/master/test/Twig/Tests/Fixtures
872
  .. _`tests/Twig/Node`: https://github.com/twigphp/Twig/tree/master/test/Twig/Tests/Node
vendor/twig/twig/doc/deprecated.rst CHANGED
@@ -26,6 +26,17 @@ Extensions
26
  * As of Twig 1.x, the ability to remove an extension is deprecated and the
27
  ``Twig_Environment::removeExtension()`` method will be removed in 2.0.
28
 
 
 
 
 
 
 
 
 
 
 
 
29
  PEAR
30
  ----
31
 
@@ -117,13 +128,13 @@ Loaders
117
  -------
118
 
119
  * As of Twig 1.x, ``Twig_Loader_String`` is deprecated and will be removed in
120
- 2.0.
121
 
122
  Node Visitors
123
  -------------
124
 
125
  * Because of the removal of ``Twig_NodeInterface`` in 2.0, you need to extend
126
- ``Twig_BaseNodeVistor`` instead of implementing ``Twig_NodeVisitorInterface``
127
  directly to make your node visitors compatible with both Twig 1.x and 2.x.
128
 
129
  Globals
@@ -140,8 +151,9 @@ Globals
140
  Miscellaneous
141
  -------------
142
 
143
- * As of Twig 1.x, ``Twig_Environment::clearTemplateCache()`` is deprecated and
144
- will be removed in 2.0.
 
145
 
146
  * As of Twig 1.x, ``Twig_Template::getEnvironment()`` and
147
  ``Twig_TemplateInterface::getEnvironment()`` are deprecated and will be
26
  * As of Twig 1.x, the ability to remove an extension is deprecated and the
27
  ``Twig_Environment::removeExtension()`` method will be removed in 2.0.
28
 
29
+ * As of Twig 1.23, the ``Twig_ExtensionInterface::initRuntime()`` method is
30
+ deprecated. You have two options to avoid the deprecation notice: if you
31
+ implement this method to store the environment for your custom filters,
32
+ functions, or tests, use the ``needs_environment`` option instead; if you
33
+ have more complex needs, explicitly implement
34
+ ``Twig_Extension_InitRuntimeInterface`` (not recommended).
35
+
36
+ * As of Twig 1.23, the ``Twig_ExtensionInterface::getGlobals()`` method is
37
+ deprecated. Implement ``Twig_Extension_GlobalsInterface`` to avoid
38
+ deprecation notices.
39
+
40
  PEAR
41
  ----
42
 
128
  -------
129
 
130
  * As of Twig 1.x, ``Twig_Loader_String`` is deprecated and will be removed in
131
+ 2.0. You can render a string via ``Twig_Environment::createTemplate()``.
132
 
133
  Node Visitors
134
  -------------
135
 
136
  * Because of the removal of ``Twig_NodeInterface`` in 2.0, you need to extend
137
+ ``Twig_BaseNodeVisitor`` instead of implementing ``Twig_NodeVisitorInterface``
138
  directly to make your node visitors compatible with both Twig 1.x and 2.x.
139
 
140
  Globals
151
  Miscellaneous
152
  -------------
153
 
154
+ * As of Twig 1.x, ``Twig_Environment::clearTemplateCache()``, ``Twig_Environment::writeCacheFile()``,
155
+ ``Twig_Environment::clearCacheFiles()``, ``Twig_Environment::getCacheFilename()``, and
156
+ ``Twig_Environment::getTemplateClassPrefix()`` are deprecated and will be removed in 2.0.
157
 
158
  * As of Twig 1.x, ``Twig_Template::getEnvironment()`` and
159
  ``Twig_TemplateInterface::getEnvironment()`` are deprecated and will be
vendor/twig/twig/doc/filters/merge.rst CHANGED
@@ -42,6 +42,7 @@ overridden.
42
 
43
  .. note::
44
 
45
- Internally, Twig uses the PHP `array_merge`_ function.
 
46
 
47
  .. _`array_merge`: http://php.net/array_merge
42
 
43
  .. note::
44
 
45
+ Internally, Twig uses the PHP `array_merge`_ function. It supports
46
+ Traversable objects by transforming those to arrays.
47
 
48
  .. _`array_merge`: http://php.net/array_merge
vendor/twig/twig/doc/filters/sort.rst CHANGED
@@ -12,6 +12,7 @@ The ``sort`` filter sorts an array:
12
  .. note::
13
 
14
  Internally, Twig uses the PHP `asort`_ function to maintain index
15
- association.
 
16
 
17
  .. _`asort`: http://php.net/asort
12
  .. note::
13
 
14
  Internally, Twig uses the PHP `asort`_ function to maintain index
15
+ association. It supports Traversable objects by transforming
16
+ those to arrays.
17
 
18
  .. _`asort`: http://php.net/asort
vendor/twig/twig/doc/recipes.rst CHANGED
@@ -337,24 +337,33 @@ Refreshing modified Templates when OPcache or APC is enabled
337
 
338
  When using OPcache with ``opcache.validate_timestamps`` set to ``0`` or APC
339
  with ``apc.stat`` set to ``0`` and Twig cache enabled, clearing the template
340
- cache won't update the cache. To get around this, one can extend
341
- ``Twig_Environment`` and force the update of the cache when Twig rewrites the
342
- cache::
343
 
344
- class Twig_Environment_APC extends Twig_Environment
345
- {
346
- protected function writeCacheFile($file, $content)
347
- {
348
- parent::writeCacheFile($file, $content);
 
349
 
350
- // Compile cached file into bytecode cache
351
- if (extension_loaded('Zend OPcache') && ini_get('opcache.enable')) {
352
- opcache_compile_file($file);
353
- } elseif (extension_loaded('apc') && ini_get('apc.enabled')) {
354
- apc_compile_file($file);
 
 
 
 
 
 
 
 
 
 
 
355
  }
356
  }
357
- }
358
 
359
  Reusing a stateful Node Visitor
360
  -------------------------------
@@ -485,4 +494,25 @@ logical name, and not the path from the filesystem::
485
  Now that the ``base.twig`` templates is defined in an array loader, you can
486
  remove it from the database, and everything else will still work as before.
487
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
488
  .. _callback: http://www.php.net/manual/en/function.is-callable.php
337
 
338
  When using OPcache with ``opcache.validate_timestamps`` set to ``0`` or APC
339
  with ``apc.stat`` set to ``0`` and Twig cache enabled, clearing the template
340
+ cache won't update the cache.
 
 
341
 
342
+ To get around this, force Twig to invalidate the bytecode cache::
343
+
344
+ $twig = new Twig_Environment($loader, array(
345
+ 'cache' => new Twig_Cache_Filesystem('/some/cache/path', Twig_Cache_Filesystem::FORCE_BYTECODE_INVALIDATION),
346
+ // ...
347
+ ));
348
 
349
+ .. note::
350
+
351
+ Before Twig 1.22, you should extend ``Twig_Environment`` instead::
352
+
353
+ class OpCacheAwareTwigEnvironment extends Twig_Environment
354
+ {
355
+ protected function writeCacheFile($file, $content)
356
+ {
357
+ parent::writeCacheFile($file, $content);
358
+
359
+ // Compile cached file into bytecode cache
360
+ if (function_exists('opcache_invalidate')) {
361
+ opcache_invalidate($file, true);
362
+ } elseif (function_exists('apc_compile_file')) {
363
+ apc_compile_file($file);
364
+ }
365
  }
366
  }
 
367
 
368
  Reusing a stateful Node Visitor
369
  -------------------------------
494
  Now that the ``base.twig`` templates is defined in an array loader, you can
495
  remove it from the database, and everything else will still work as before.
496
 
497
+ Loading a Template from a String
498
+ --------------------------------
499
+
500
+ From a template, you can easily load a template stored in a string via the
501
+ ``template_from_string`` function (available as of Twig 1.11 via the
502
+ ``Twig_Extension_StringLoader`` extension)::
503
+
504
+ .. code-block:: jinja
505
+
506
+ {{ include(template_from_string("Hello {{ name }}")) }}
507
+
508
+ From PHP, it's also possible to load a template stored in a string via
509
+ ``Twig_Environment::createTemplate()`` (available as of Twig 1.18)::
510
+
511
+ $template = $twig->createTemplate('hello {{ name }}');
512
+ echo $template->render(array('name' => 'Fabien'));
513
+
514
+ .. note::
515
+
516
+ Never use the ``Twig_Loader_String`` loader, which has severe limitations.
517
+
518
  .. _callback: http://www.php.net/manual/en/function.is-callable.php
vendor/twig/twig/doc/templates.rst CHANGED
@@ -771,15 +771,27 @@ Other Operators
771
  .. versionadded:: 1.12.0
772
  Support for the extended ternary operator was added in Twig 1.12.0.
773
 
774
- The following operators are very useful but don't fit into any of the other
775
- categories:
776
-
777
- * ``..``: Creates a sequence based on the operand before and after the
778
- operator (this is just syntactic sugar for the :doc:`range<functions/range>`
779
- function).
780
 
781
  * ``|``: Applies a filter.
782
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
783
  * ``~``: Converts all operands into strings and concatenates them. ``{{ "Hello
784
  " ~ name ~ "!" }}`` would return (assuming ``name`` is ``'John'``) ``Hello
785
  John!``.
771
  .. versionadded:: 1.12.0
772
  Support for the extended ternary operator was added in Twig 1.12.0.
773
 
774
+ The following operators don't fit into any of the other categories:
 
 
 
 
 
775
 
776
  * ``|``: Applies a filter.
777
 
778
+ * ``..``: Creates a sequence based on the operand before and after the operator
779
+ (this is just syntactic sugar for the :doc:`range<functions/range>` function):
780
+
781
+ .. code-block:: jinja
782
+
783
+ {{ 1..5 }}
784
+
785
+ {# equivalent to #}
786
+ {{ range(1, 5) }}
787
+
788
+ Note that you must use parentheses when combining it with the filter operator
789
+ due to the :ref:`operator precedence rules <twig-expressions>`:
790
+
791
+ .. code-block:: jinja
792
+
793
+ (1..5)|join(', ')
794
+
795
  * ``~``: Converts all operands into strings and concatenates them. ``{{ "Hello
796
  " ~ name ~ "!" }}`` would return (assuming ``name`` is ``'John'``) ``Hello
797
  John!``.
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.21.1"
19
 
20
  #include "php.h"
21
 
15
  #ifndef PHP_TWIG_H
16
  #define PHP_TWIG_H
17
 
18
+ #define PHP_TWIG_VERSION "1.23.1"
19
 
20
  #include "php.h"
21
 
vendor/twig/twig/lib/Twig/Cache/Filesystem.php ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of Twig.
5
+ *
6
+ * (c) 2015 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
+ * Implements a cache on the filesystem.
14
+ *
15
+ * @author Andrew Tch <andrew@noop.lv>
16
+ */
17
+ class Twig_Cache_Filesystem implements Twig_CacheInterface
18
+ {
19
+ const FORCE_BYTECODE_INVALIDATION = 1;
20
+
21
+ private $directory;
22
+ private $options;
23
+
24
+ /**
25
+ * @param $directory string The root cache directory
26
+ * @param $options int A set of options
27
+ */
28
+ public function __construct($directory, $options = 0)
29
+ {
30
+ $this->directory = $directory;
31
+ $this->options = $options;
32
+ }
33
+
34
+ /**
35
+ * {@inheritdoc}
36
+ */
37
+ public function generateKey($name, $className)
38
+ {
39
+ $hash = hash('sha256', $className);
40
+
41
+ return $this->directory.'/'.$hash[0].$hash[1].'/'.$hash.'.php';
42
+ }
43
+
44
+ /**
45
+ * {@inheritdoc}
46
+ */
47
+ public function load($key)
48
+ {
49
+ @include_once $key;
50
+ }
51
+
52
+ /**
53
+ * {@inheritdoc}
54
+ */
55
+ public function write($key, $content)
56
+ {
57
+ $dir = dirname($key);
58
+ if (!is_dir($dir)) {
59
+ if (false === @mkdir($dir, 0777, true) && !is_dir($dir)) {
60
+ throw new RuntimeException(sprintf('Unable to create the cache directory (%s).', $dir));
61
+ }
62
+ } elseif (!is_writable($dir)) {
63
+ throw new RuntimeException(sprintf('Unable to write in the cache directory (%s).', $dir));
64
+ }
65
+
66
+ $tmpFile = tempnam($dir, basename($key));
67
+ if (false !== @file_put_contents($tmpFile, $content) && @rename($tmpFile, $key)) {
68
+ @chmod($key, 0666 & ~umask());
69
+
70
+ if (self::FORCE_BYTECODE_INVALIDATION == ($this->options & self::FORCE_BYTECODE_INVALIDATION)) {
71
+ // Compile cached file into bytecode cache
72
+ if (function_exists('opcache_invalidate')) {
73
+ opcache_invalidate($key, true);
74
+ } elseif (function_exists('apc_compile_file')) {
75
+ apc_compile_file($key);
76
+ }
77
+ }
78
+
79
+ return;
80
+ }
81
+
82
+ throw new RuntimeException(sprintf('Failed to write cache file "%s".', $key));
83
+ }
84
+
85
+ /**
86
+ * {@inheritdoc}
87
+ */
88
+ public function getTimestamp($key)
89
+ {
90
+ if (!file_exists($key)) {
91
+ return 0;
92
+ }
93
+
94
+ return (int) @filemtime($key);
95
+ }
96
+ }
vendor/twig/twig/lib/Twig/Cache/Null.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of Twig.
5
+ *
6
+ * (c) 2015 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
+ * 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;
47
+ }
48
+ }
vendor/twig/twig/lib/Twig/CacheInterface.php ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of Twig.
5
+ *
6
+ * (c) 2015 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
+ * Interface implemented by cache classes.
14
+ *
15
+ * It is highly recommended to always store templates on the filesystem to
16
+ * benefit from the PHP opcode cache. This interface is mostly useful if you
17
+ * need to implement a custom strategy for storing templates on the filesystem.
18
+ *
19
+ * @author Andrew Tch <andrew@noop.lv>
20
+ */
21
+ interface Twig_CacheInterface
22
+ {
23
+ /**
24
+ * Generates a cache key for the given template class name.
25
+ *
26
+ * @param string $name The template name
27
+ * @param string $className The template class name
28
+ *
29
+ * @return string
30
+ */
31
+ public function generateKey($name, $className);
32
+
33
+ /**
34
+ * Writes the compiled template to cache.
35
+ *
36
+ * @param string $key The cache key
37
+ * @param string $content The template representation as a PHP class
38
+ */
39
+ public function write($key, $content);
40
+
41
+ /**
42
+ * Loads a template from the cache.
43
+ *
44
+ * @param string $key The cache key
45
+ */
46
+ public function load($key);
47
+
48
+ /**
49
+ * Returns the modification timestamp of a key.
50
+ *
51
+ * @param string $key The cache key
52
+ *
53
+ * @return int
54
+ */
55
+ public function getTimestamp($key);
56
+ }
vendor/twig/twig/lib/Twig/Environment.php CHANGED
@@ -16,7 +16,7 @@
16
  */
17
  class Twig_Environment
18
  {
19
- const VERSION = '1.21.1';
20
 
21
  protected $charset;
22
  protected $loader;
@@ -45,6 +45,11 @@ class Twig_Environment
45
  protected $filterCallbacks = array();
46
  protected $staging;
47
 
 
 
 
 
 
48
  /**
49
  * Constructor.
50
  *
@@ -58,8 +63,9 @@ class Twig_Environment
58
  * * base_template_class: The base template class to use for generated
59
  * templates (default to Twig_Template).
60
  *
61
- * * cache: An absolute path where to store the compiled templates, or
62
- * false to disable compilation cache (default).
 
63
  *
64
  * * auto_reload: Whether to reload the template if the original source changed.
65
  * If you don't provide the auto_reload option, it will be
@@ -112,6 +118,23 @@ class Twig_Environment
112
  $this->addExtension(new Twig_Extension_Escaper($options['autoescape']));
113
  $this->addExtension(new Twig_Extension_Optimizer($options['optimizations']));
114
  $this->staging = new Twig_Extension_Staging();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
115
  }
116
 
117
  /**
@@ -213,24 +236,43 @@ class Twig_Environment
213
  }
214
 
215
  /**
216
- * Gets the cache directory or false if cache is disabled.
217
  *
218
- * @return string|false
 
 
 
 
219
  */
220
- public function getCache()
221
  {
222
- return $this->cache;
223
  }
224
 
225
  /**
226
- * Sets the cache directory or false if cache is disabled.
227
  *
228
- * @param string|false $cache The absolute path to the compiled templates,
229
- * or false to disable cache
 
230
  */
231
  public function setCache($cache)
232
  {
233
- $this->cache = $cache ? $cache : false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
234
  }
235
 
236
  /**
@@ -239,38 +281,52 @@ class Twig_Environment
239
  * @param string $name The template name
240
  *
241
  * @return string|false The cache file name or false when caching is disabled
 
 
242
  */
243
  public function getCacheFilename($name)
244
  {
245
- if (false === $this->cache) {
246
- return false;
247
- }
248
 
249
- $class = substr($this->getTemplateClass($name), strlen($this->templateClassPrefix));
250
 
251
- return $this->getCache().'/'.$class[0].'/'.$class[1].'/'.$class.'.php';
252
  }
253
 
254
  /**
255
  * Gets the template class associated with the given string.
256
  *
257
- * @param string $name The name for which to calculate the template class name
258
- * @param int $index The index if it is an embedded template
 
 
 
 
 
 
259
  *
260
  * @return string The template class name
261
  */
262
  public function getTemplateClass($name, $index = null)
263
  {
264
- return $this->templateClassPrefix.hash('sha256', $this->getLoader()->getCacheKey($name)).(null === $index ? '' : '_'.$index);
 
 
 
 
265
  }
266
 
267
  /**
268
  * Gets the template class prefix.
269
  *
270
  * @return string The template class prefix
 
 
271
  */
272
  public function getTemplateClassPrefix()
273
  {
 
 
274
  return $this->templateClassPrefix;
275
  }
276
 
@@ -326,14 +382,25 @@ class Twig_Environment
326
  }
327
 
328
  if (!class_exists($cls, false)) {
329
- if (false === $cache = $this->getCacheFilename($name)) {
330
- eval('?>'.$this->compileSource($this->getLoader()->getSource($name), $name));
331
  } else {
332
- if (!is_file($cache) || ($this->isAutoReload() && !$this->isTemplateFresh($name, filemtime($cache)))) {
333
- $this->writeCacheFile($cache, $this->compileSource($this->getLoader()->getSource($name), $name));
 
 
 
 
 
 
 
 
 
 
 
334
  }
335
 
336
- require_once $cache;
337
  }
338
  }
339
 
@@ -392,14 +459,16 @@ class Twig_Environment
392
  */
393
  public function isTemplateFresh($name, $time)
394
  {
395
- foreach ($this->extensions as $extension) {
396
- $r = new ReflectionObject($extension);
397
- if (filemtime($r->getFileName()) > $time) {
398
- return false;
 
 
399
  }
400
  }
401
 
402
- return $this->getLoader()->isFresh($name, $time);
403
  }
404
 
405
  /**
@@ -453,16 +522,18 @@ class Twig_Environment
453
 
454
  /**
455
  * Clears the template cache files on the filesystem.
 
 
456
  */
457
  public function clearCacheFiles()
458
  {
459
- if (false === $this->cache) {
460
- return;
461
- }
462
 
463
- foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($this->cache), RecursiveIteratorIterator::LEAVES_ONLY) as $file) {
464
- if ($file->isFile()) {
465
- @unlink($file->getPathname());
 
 
466
  }
467
  }
468
  }
@@ -593,7 +664,13 @@ class Twig_Environment
593
  public function compileSource($source, $name = null)
594
  {
595
  try {
596
- return $this->compile($this->parse($this->tokenize($source, $name)));
 
 
 
 
 
 
597
  } catch (Twig_Error $e) {
598
  $e->setTemplateFile($name);
599
  throw $e;
@@ -648,12 +725,22 @@ class Twig_Environment
648
 
649
  /**
650
  * Initializes the runtime environment.
 
 
651
  */
652
  public function initRuntime()
653
  {
654
  $this->runtimeInitialized = true;
655
 
656
- foreach ($this->getExtensions() as $extension) {
 
 
 
 
 
 
 
 
657
  $extension->initRuntime($this);
658
  }
659
  }
@@ -693,11 +780,19 @@ class Twig_Environment
693
  */
694
  public function addExtension(Twig_ExtensionInterface $extension)
695
  {
 
 
696
  if ($this->extensionInitialized) {
697
- throw new LogicException(sprintf('Unable to register extension "%s" as extensions have already been initialized.', $extension->getName()));
 
 
 
 
698
  }
699
 
700
- $this->extensions[$extension->getName()] = $extension;
 
 
701
  }
702
 
703
  /**
@@ -1156,24 +1251,28 @@ class Twig_Environment
1156
  return $this->binaryOperators;
1157
  }
1158
 
 
 
 
1159
  public function computeAlternatives($name, $items)
1160
  {
1161
- $alternatives = array();
1162
- foreach ($items as $item) {
1163
- $lev = levenshtein($name, $item);
1164
- if ($lev <= strlen($name) / 3 || false !== strpos($item, $name)) {
1165
- $alternatives[$item] = $lev;
1166
- }
1167
- }
1168
- asort($alternatives);
1169
 
1170
- return array_keys($alternatives);
1171
  }
1172
 
1173
  protected function initGlobals()
1174
  {
1175
  $globals = array();
1176
- foreach ($this->extensions as $extension) {
 
 
 
 
 
 
 
 
1177
  $extGlob = $extension->getGlobals();
1178
  if (!is_array($extGlob)) {
1179
  throw new UnexpectedValueException(sprintf('"%s::getGlobals()" must return an array of globals.', get_class($extension)));
@@ -1272,30 +1371,11 @@ class Twig_Environment
1272
  }
1273
  }
1274
 
 
 
 
1275
  protected function writeCacheFile($file, $content)
1276
  {
1277
- $dir = dirname($file);
1278
- if (!is_dir($dir)) {
1279
- if (false === @mkdir($dir, 0777, true)) {
1280
- clearstatcache(false, $dir);
1281
- if (!is_dir($dir)) {
1282
- throw new RuntimeException(sprintf('Unable to create the cache directory (%s).', $dir));
1283
- }
1284
- }
1285
- } elseif (!is_writable($dir)) {
1286
- throw new RuntimeException(sprintf('Unable to write in the cache directory (%s).', $dir));
1287
- }
1288
-
1289
- $tmpFile = tempnam($dir, basename($file));
1290
- if (false !== @file_put_contents($tmpFile, $content)) {
1291
- // rename does not work on Win32 before 5.2.6
1292
- if (@rename($tmpFile, $file) || (@copy($tmpFile, $file) && unlink($tmpFile))) {
1293
- @chmod($file, 0666 & ~umask());
1294
-
1295
- return;
1296
- }
1297
- }
1298
-
1299
- throw new RuntimeException(sprintf('Failed to write cache file "%s".', $file));
1300
  }
1301
  }
16
  */
17
  class Twig_Environment
18
  {
19
+ const VERSION = '1.23.1';
20
 
21
  protected $charset;
22
  protected $loader;
45
  protected $filterCallbacks = array();
46
  protected $staging;
47
 
48
+ private $originalCache;
49
+ private $bcWriteCacheFile = false;
50
+ private $bcGetCacheFilename = false;
51
+ private $lastModifiedExtension = 0;
52
+
53
  /**
54
  * Constructor.
55
  *
63
  * * base_template_class: The base template class to use for generated
64
  * templates (default to Twig_Template).
65
  *
66
+ * * cache: An absolute path where to store the compiled templates,
67
+ * a Twig_Cache_Interface implementation,
68
+ * or false to disable compilation cache (default).
69
  *
70
  * * auto_reload: Whether to reload the template if the original source changed.
71
  * If you don't provide the auto_reload option, it will be
118
  $this->addExtension(new Twig_Extension_Escaper($options['autoescape']));
119
  $this->addExtension(new Twig_Extension_Optimizer($options['optimizations']));
120
  $this->staging = new Twig_Extension_Staging();
121
+
122
+ // For BC
123
+ if (is_string($this->originalCache)) {
124
+ $r = new ReflectionMethod($this, 'writeCacheFile');
125
+ if ($r->getDeclaringClass()->getName() !== __CLASS__) {
126
+ @trigger_error('The Twig_Environment::writeCacheFile method is deprecated and will be removed in Twig 2.0.', E_USER_DEPRECATED);
127
+
128
+ $this->bcWriteCacheFile = true;
129
+ }
130
+
131
+ $r = new ReflectionMethod($this, 'getCacheFilename');
132
+ if ($r->getDeclaringClass()->getName() !== __CLASS__) {
133
+ @trigger_error('The Twig_Environment::getCacheFilename method is deprecated and will be removed in Twig 2.0.', E_USER_DEPRECATED);
134
+
135
+ $this->bcGetCacheFilename = true;
136
+ }
137
+ }
138
  }
139
 
140
  /**
236
  }
237
 
238
  /**
239
+ * Gets the current cache implementation.
240
  *
241
+ * @param bool $original Whether to return the original cache option or the real cache instance
242
+ *
243
+ * @return Twig_CacheInterface|string|false A Twig_CacheInterface implementation,
244
+ * an absolute path to the compiled templates,
245
+ * or false to disable cache
246
  */
247
+ public function getCache($original = true)
248
  {
249
+ return $original ? $this->originalCache : $this->cache;
250
  }
251
 
252
  /**
253
+ * Sets the current cache implementation.
254
  *
255
+ * @param Twig_CacheInterface|string|false $cache A Twig_CacheInterface implementation,
256
+ * an absolute path to the compiled templates,
257
+ * or false to disable cache
258
  */
259
  public function setCache($cache)
260
  {
261
+ if (is_string($cache)) {
262
+ $this->originalCache = $cache;
263
+ $this->cache = new Twig_Cache_Filesystem($cache);
264
+ } elseif (false === $cache) {
265
+ $this->originalCache = $cache;
266
+ $this->cache = new Twig_Cache_Null();
267
+ } elseif (null === $cache) {
268
+ @trigger_error('Using "null" as the cache strategy is deprecated and will be removed in Twig 2.0.', E_USER_DEPRECATED);
269
+ $this->originalCache = false;
270
+ $this->cache = new Twig_Cache_Null();
271
+ } elseif ($cache instanceof Twig_CacheInterface) {
272
+ $this->originalCache = $this->cache = $cache;
273
+ } else {
274
+ throw new LogicException(sprintf('Cache can only be a string, false, or a Twig_CacheInterface implementation.'));
275
+ }
276
  }
277
 
278
  /**
281
  * @param string $name The template name
282
  *
283
  * @return string|false The cache file name or false when caching is disabled
284
+ *
285
+ * @deprecated since 1.22 (to be removed in 2.0)
286
  */
287
  public function getCacheFilename($name)
288
  {
289
+ @trigger_error(sprintf('The %s method is deprecated and will be removed in Twig 2.0.', __METHOD__), E_USER_DEPRECATED);
 
 
290
 
291
+ $key = $this->cache->generateKey($name, $this->getTemplateClass($name));
292
 
293
+ return !$key ? false : $key;
294
  }
295
 
296
  /**
297
  * Gets the template class associated with the given string.
298
  *
299
+ * The generated template class is based on the following parameters:
300
+ *
301
+ * * The cache key for the given template;
302
+ * * The currently enabled extensions;
303
+ * * Whether the Twig C extension is available or not.
304
+ *
305
+ * @param string $name The name for which to calculate the template class name
306
+ * @param int|null $index The index if it is an embedded template
307
  *
308
  * @return string The template class name
309
  */
310
  public function getTemplateClass($name, $index = null)
311
  {
312
+ $key = $this->getLoader()->getCacheKey($name);
313
+ $key .= json_encode(array_keys($this->extensions));
314
+ $key .= function_exists('twig_template_get_attributes');
315
+
316
+ return $this->templateClassPrefix.hash('sha256', $key).(null === $index ? '' : '_'.$index);
317
  }
318
 
319
  /**
320
  * Gets the template class prefix.
321
  *
322
  * @return string The template class prefix
323
+ *
324
+ * @deprecated since 1.22 (to be removed in 2.0)
325
  */
326
  public function getTemplateClassPrefix()
327
  {
328
+ @trigger_error(sprintf('The %s method is deprecated and will be removed in Twig 2.0.', __METHOD__), E_USER_DEPRECATED);
329
+
330
  return $this->templateClassPrefix;
331
  }
332
 
382
  }
383
 
384
  if (!class_exists($cls, false)) {
385
+ if ($this->bcGetCacheFilename) {
386
+ $key = $this->getCacheFilename($name);
387
  } else {
388
+ $key = $this->cache->generateKey($name, $cls);
389
+ }
390
+
391
+ if (!$this->isAutoReload() || $this->isTemplateFresh($name, $this->cache->getTimestamp($key))) {
392
+ $this->cache->load($key);
393
+ }
394
+
395
+ if (!class_exists($cls, false)) {
396
+ $content = $this->compileSource($this->getLoader()->getSource($name), $name);
397
+ if ($this->bcWriteCacheFile) {
398
+ $this->writeCacheFile($key, $content);
399
+ } else {
400
+ $this->cache->write($key, $content);
401
  }
402
 
403
+ eval('?>'.$content);
404
  }
405
  }
406
 
459
  */
460
  public function isTemplateFresh($name, $time)
461
  {
462
+ if (0 === $this->lastModifiedExtension) {
463
+ foreach ($this->extensions as $extension) {
464
+ $r = new ReflectionObject($extension);
465
+ if (file_exists($r->getFileName()) && ($extensionTime = filemtime($r->getFileName())) > $this->lastModifiedExtension) {
466
+ $this->lastModifiedExtension = $extensionTime;
467
+ }
468
  }
469
  }
470
 
471
+ return $this->lastModifiedExtension <= $time && $this->getLoader()->isFresh($name, $time);
472
  }
473
 
474
  /**
522
 
523
  /**
524
  * Clears the template cache files on the filesystem.
525
+ *
526
+ * @deprecated since 1.22 (to be removed in 2.0)
527
  */
528
  public function clearCacheFiles()
529
  {
530
+ @trigger_error(sprintf('The %s method is deprecated and will be removed in Twig 2.0.', __METHOD__), E_USER_DEPRECATED);
 
 
531
 
532
+ if (is_string($this->originalCache)) {
533
+ foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($this->originalCache), RecursiveIteratorIterator::LEAVES_ONLY) as $file) {
534
+ if ($file->isFile()) {
535
+ @unlink($file->getPathname());
536
+ }
537
  }
538
  }
539
  }
664
  public function compileSource($source, $name = null)
665
  {
666
  try {
667
+ $compiled = $this->compile($this->parse($this->tokenize($source, $name)), $source);
668
+
669
+ if (isset($source[0])) {
670
+ $compiled .= '/* '.str_replace(array('*/', "\r\n", "\r", "\n"), array('*//* ', "\n", "\n", "*/\n/* "), $source)."*/\n";
671
+ }
672
+
673
+ return $compiled;
674
  } catch (Twig_Error $e) {
675
  $e->setTemplateFile($name);
676
  throw $e;
725
 
726
  /**
727
  * Initializes the runtime environment.
728
+ *
729
+ * @deprecated since 1.23 (to be removed in 2.0)
730
  */
731
  public function initRuntime()
732
  {
733
  $this->runtimeInitialized = true;
734
 
735
+ foreach ($this->getExtensions() as $name => $extension) {
736
+ if (!$extension instanceof Twig_Extension_InitRuntimeInterface) {
737
+ $m = new ReflectionMethod($extension, 'initRuntime');
738
+
739
+ if ('Twig_Extension' !== $m->getDeclaringClass()->getName()) {
740
+ @trigger_error(sprintf('Defining the initRuntime() method in the "%s" extension is deprecated. Use the `needs_environment` option to get the Twig_Environment instance in filters, functions, or tests; or explicitly implement Twig_Extension_InitRuntimeInterface if needed (not recommended).', $name), E_USER_DEPRECATED);
741
+ }
742
+ }
743
+
744
  $extension->initRuntime($this);
745
  }
746
  }
780
  */
781
  public function addExtension(Twig_ExtensionInterface $extension)
782
  {
783
+ $name = $extension->getName();
784
+
785
  if ($this->extensionInitialized) {
786
+ throw new LogicException(sprintf('Unable to register extension "%s" as extensions have already been initialized.', $name));
787
+ }
788
+
789
+ if (isset($this->extensions[$name])) {
790
+ @trigger_error(sprintf('The possibility to register the same extension twice ("%s") is deprecated and will be removed in Twig 2.0. Use proper PHP inheritance instead.', $name), E_USER_DEPRECATED);
791
  }
792
 
793
+ $this->lastModifiedExtension = 0;
794
+
795
+ $this->extensions[$name] = $extension;
796
  }
797
 
798
  /**
1251
  return $this->binaryOperators;
1252
  }
1253
 
1254
+ /**
1255
+ * @deprecated since 1.23 (to be removed in 2.0)
1256
+ */
1257
  public function computeAlternatives($name, $items)
1258
  {
1259
+ @trigger_error(sprintf('The %s method is deprecated and will be removed in Twig 2.0.', __METHOD__), E_USER_DEPRECATED);
 
 
 
 
 
 
 
1260
 
1261
+ return Twig_Error_Syntax::computeAlternatives($name, $items);
1262
  }
1263
 
1264
  protected function initGlobals()
1265
  {
1266
  $globals = array();
1267
+ foreach ($this->extensions as $name => $extension) {
1268
+ if (!$extension instanceof Twig_Extension_GlobalsInterface) {
1269
+ $m = new ReflectionMethod($extension, 'getGlobals');
1270
+
1271
+ if ('Twig_Extension' !== $m->getDeclaringClass()->getName()) {
1272
+ @trigger_error(sprintf('Defining the getGlobals() method in the "%s" extension is deprecated without explicitly implementing Twig_Extension_GlobalsInterface.', $name), E_USER_DEPRECATED);
1273
+ }
1274
+ }
1275
+
1276
  $extGlob = $extension->getGlobals();
1277
  if (!is_array($extGlob)) {
1278
  throw new UnexpectedValueException(sprintf('"%s::getGlobals()" must return an array of globals.', get_class($extension)));
1371
  }
1372
  }
1373
 
1374
+ /**
1375
+ * @deprecated since 1.22 (to be removed in 2.0)
1376
+ */
1377
  protected function writeCacheFile($file, $content)
1378
  {
1379
+ $this->cache->write($file, $content);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1380
  }
1381
  }
vendor/twig/twig/lib/Twig/Error.php CHANGED
@@ -155,6 +155,15 @@ class Twig_Error extends Exception
155
  throw new BadMethodCallException(sprintf('Method "Twig_Error::%s()" does not exist.', $method));
156
  }
157
 
 
 
 
 
 
 
 
 
 
158
  protected function updateRepr()
159
  {
160
  $this->message = $this->rawMessage;
@@ -165,6 +174,12 @@ class Twig_Error extends Exception
165
  $dot = true;
166
  }
167
 
 
 
 
 
 
 
168
  if ($this->filename) {
169
  if (is_string($this->filename) || (is_object($this->filename) && method_exists($this->filename, '__toString'))) {
170
  $filename = sprintf('"%s"', $this->filename);
@@ -181,8 +196,15 @@ class Twig_Error extends Exception
181
  if ($dot) {
182
  $this->message .= '.';
183
  }
 
 
 
 
184
  }
185
 
 
 
 
186
  protected function guessTemplateInfo()
187
  {
188
  $template = null;
155
  throw new BadMethodCallException(sprintf('Method "Twig_Error::%s()" does not exist.', $method));
156
  }
157
 
158
+ public function appendMessage($rawMessage)
159
+ {
160
+ $this->rawMessage .= $rawMessage;
161
+ $this->updateRepr();
162
+ }
163
+
164
+ /**
165
+ * @internal
166
+ */
167
  protected function updateRepr()
168
  {
169
  $this->message = $this->rawMessage;
174
  $dot = true;
175
  }
176
 
177
+ $questionMark = false;
178
+ if ('?' === substr($this->message, -1)) {
179
+ $this->message = substr($this->message, 0, -1);
180
+ $questionMark = true;
181
+ }
182
+
183
  if ($this->filename) {
184
  if (is_string($this->filename) || (is_object($this->filename) && method_exists($this->filename, '__toString'))) {
185
  $filename = sprintf('"%s"', $this->filename);
196
  if ($dot) {
197
  $this->message .= '.';
198
  }
199
+
200
+ if ($questionMark) {
201
+ $this->message .= '?';
202
+ }
203
  }
204
 
205
+ /**
206
+ * @internal
207
+ */
208
  protected function guessTemplateInfo()
209
  {
210
  $template = null;
vendor/twig/twig/lib/Twig/Error/Syntax.php CHANGED
@@ -17,4 +17,37 @@
17
  */
18
  class Twig_Error_Syntax extends Twig_Error
19
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  }
17
  */
18
  class Twig_Error_Syntax extends Twig_Error
19
  {
20
+ /**
21
+ * Tweaks the error message to include suggestions.
22
+ *
23
+ * @param string $name The original name of the item that does not exist
24
+ * @param array $items An array of possible items
25
+ */
26
+ public function addSuggestions($name, array $items)
27
+ {
28
+ if (!$alternatives = self::computeAlternatives($name, $items)) {
29
+ return;
30
+ }
31
+
32
+ $this->appendMessage(sprintf(' Did you mean "%s"?', implode('", "', $alternatives)));
33
+ }
34
+
35
+ /**
36
+ * @internal
37
+ *
38
+ * To be merged with the addSuggestions() method in 2.0.
39
+ */
40
+ public static function computeAlternatives($name, $items)
41
+ {
42
+ $alternatives = array();
43
+ foreach ($items as $item) {
44
+ $lev = levenshtein($name, $item);
45
+ if ($lev <= strlen($name) / 3 || false !== strpos($item, $name)) {
46
+ $alternatives[$item] = $lev;
47
+ }
48
+ }
49
+ asort($alternatives);
50
+
51
+ return array_keys($alternatives);
52
+ }
53
  }
vendor/twig/twig/lib/Twig/ExpressionParser.php CHANGED
@@ -171,7 +171,7 @@ class Twig_ExpressionParser
171
  $negClass = 'Twig_Node_Expression_Unary_Neg';
172
  $posClass = 'Twig_Node_Expression_Unary_Pos';
173
  if (!(in_array($ref->getName(), array($negClass, $posClass)) || $ref->isSubclassOf($negClass) || $ref->isSubclassOf($posClass))) {
174
- throw new Twig_Error_Syntax(sprintf('Unexpected unary operator "%s"', $token->getValue()), $token->getLine(), $this->parser->getFilename());
175
  }
176
 
177
  $this->parser->getStream()->next();
@@ -187,7 +187,7 @@ class Twig_ExpressionParser
187
  } elseif ($token->test(Twig_Token::PUNCTUATION_TYPE, '{')) {
188
  $node = $this->parseHashExpression();
189
  } else {
190
- throw new Twig_Error_Syntax(sprintf('Unexpected token "%s" of value "%s"', Twig_Token::typeToEnglish($token->getType()), $token->getValue()), $token->getLine(), $this->parser->getFilename());
191
  }
192
  }
193
 
@@ -278,7 +278,7 @@ class Twig_ExpressionParser
278
  } else {
279
  $current = $stream->getCurrent();
280
 
281
- 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(), $this->parser->getFilename());
282
  }
283
 
284
  $stream->expect(Twig_Token::PUNCTUATION_TYPE, ':', 'A hash key must be followed by a colon (:)');
@@ -317,11 +317,11 @@ class Twig_ExpressionParser
317
  case 'parent':
318
  $this->parseArguments();
319
  if (!count($this->parser->getBlockStack())) {
320
- throw new Twig_Error_Syntax('Calling "parent" outside a block is forbidden', $line, $this->parser->getFilename());
321
  }
322
 
323
  if (!$this->parser->getParent() && !$this->parser->hasTraits()) {
324
- throw new Twig_Error_Syntax('Calling "parent" on a template that does not extend nor "use" another template is forbidden', $line, $this->parser->getFilename());
325
  }
326
 
327
  return new Twig_Node_Expression_Parent($this->parser->peekBlockStack(), $line);
@@ -330,7 +330,7 @@ class Twig_ExpressionParser
330
  case 'attribute':
331
  $args = $this->parseArguments();
332
  if (count($args) < 2) {
333
- throw new Twig_Error_Syntax('The "attribute" function takes at least two arguments (the variable and the attributes)', $line, $this->parser->getFilename());
334
  }
335
 
336
  return new Twig_Node_Expression_GetAttr($args->getNode(0), $args->getNode(1), count($args) > 2 ? $args->getNode(2) : null, Twig_Template::ANY_CALL, $line);
@@ -384,13 +384,13 @@ class Twig_ExpressionParser
384
 
385
  if ($node instanceof Twig_Node_Expression_Name && null !== $this->parser->getImportedSymbol('template', $node->getAttribute('name'))) {
386
  if (!$arg instanceof Twig_Node_Expression_Constant) {
387
- throw new Twig_Error_Syntax(sprintf('Dynamic macro names are not supported (called on "%s")', $node->getAttribute('name')), $token->getLine(), $this->parser->getFilename());
388
  }
389
 
390
  $name = $arg->getAttribute('value');
391
 
392
  if ($this->parser->isReservedMacroName($name)) {
393
- throw new Twig_Error_Syntax(sprintf('"%s" cannot be called as macro as it is a reserved keyword', $name), $token->getLine(), $this->parser->getFilename());
394
  }
395
 
396
  $node = new Twig_Node_Expression_MethodCall($node, 'get'.$name, $arguments, $lineno);
@@ -500,7 +500,7 @@ class Twig_ExpressionParser
500
  $name = null;
501
  if ($namedArguments && $token = $stream->nextIf(Twig_Token::OPERATOR_TYPE, '=')) {
502
  if (!$value instanceof Twig_Node_Expression_Name) {
503
- throw new Twig_Error_Syntax(sprintf('A parameter name must be a string, "%s" given', get_class($value)), $token->getLine(), $this->parser->getFilename());
504
  }
505
  $name = $value->getAttribute('name');
506
 
@@ -540,7 +540,7 @@ class Twig_ExpressionParser
540
  while (true) {
541
  $token = $this->parser->getStream()->expect(Twig_Token::NAME_TYPE, null, 'Only variables can be assigned to');
542
  if (in_array($token->getValue(), array('true', 'false', 'none'))) {
543
- throw new Twig_Error_Syntax(sprintf('You cannot assign a value to "%s"', $token->getValue()), $token->getLine(), $this->parser->getFilename());
544
  }
545
  $targets[] = new Twig_Node_Expression_AssignName($token->getValue(), $token->getLine());
546
 
@@ -570,17 +570,15 @@ class Twig_ExpressionParser
570
  $env = $this->parser->getEnvironment();
571
 
572
  if (false === $function = $env->getFunction($name)) {
573
- $message = sprintf('The function "%s" does not exist', $name);
574
- if ($alternatives = $env->computeAlternatives($name, array_keys($env->getFunctions()))) {
575
- $message = sprintf('%s. Did you mean "%s"', $message, implode('", "', $alternatives));
576
- }
577
 
578
- throw new Twig_Error_Syntax($message, $line, $this->parser->getFilename());
579
  }
580
 
581
  if ($function instanceof Twig_SimpleFunction && $function->isDeprecated()) {
582
  $message = sprintf('Twig Function "%s" is deprecated', $function->getName());
583
- if ($test->getAlternative()) {
584
  $message .= sprintf('. Use "%s" instead', $function->getAlternative());
585
  }
586
  $message .= sprintf(' in %s at line %d.', $this->parser->getFilename(), $line);
@@ -600,17 +598,15 @@ class Twig_ExpressionParser
600
  $env = $this->parser->getEnvironment();
601
 
602
  if (false === $filter = $env->getFilter($name)) {
603
- $message = sprintf('The filter "%s" does not exist', $name);
604
- if ($alternatives = $env->computeAlternatives($name, array_keys($env->getFilters()))) {
605
- $message = sprintf('%s. Did you mean "%s"', $message, implode('", "', $alternatives));
606
- }
607
 
608
- throw new Twig_Error_Syntax($message, $line, $this->parser->getFilename());
609
  }
610
 
611
  if ($filter instanceof Twig_SimpleFilter && $filter->isDeprecated()) {
612
  $message = sprintf('Twig Filter "%s" is deprecated', $filter->getName());
613
- if ($test->getAlternative()) {
614
  $message .= sprintf('. Use "%s" instead', $filter->getAlternative());
615
  }
616
  $message .= sprintf(' in %s at line %d.', $this->parser->getFilename(), $line);
171
  $negClass = 'Twig_Node_Expression_Unary_Neg';
172
  $posClass = 'Twig_Node_Expression_Unary_Pos';
173
  if (!(in_array($ref->getName(), array($negClass, $posClass)) || $ref->isSubclassOf($negClass) || $ref->isSubclassOf($posClass))) {
174
+ throw new Twig_Error_Syntax(sprintf('Unexpected unary operator "%s".', $token->getValue()), $token->getLine(), $this->parser->getFilename());
175
  }
176
 
177
  $this->parser->getStream()->next();
187
  } elseif ($token->test(Twig_Token::PUNCTUATION_TYPE, '{')) {
188
  $node = $this->parseHashExpression();
189
  } else {
190
+ throw new Twig_Error_Syntax(sprintf('Unexpected token "%s" of value "%s".', Twig_Token::typeToEnglish($token->getType()), $token->getValue()), $token->getLine(), $this->parser->getFilename());
191
  }
192
  }
193
 
278
  } else {
279
  $current = $stream->getCurrent();
280
 
281
+ 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(), $this->parser->getFilename());
282
  }
283
 
284
  $stream->expect(Twig_Token::PUNCTUATION_TYPE, ':', 'A hash key must be followed by a colon (:)');
317
  case 'parent':
318
  $this->parseArguments();
319
  if (!count($this->parser->getBlockStack())) {
320
+ throw new Twig_Error_Syntax('Calling "parent" outside a block is forbidden.', $line, $this->parser->getFilename());
321
  }
322
 
323
  if (!$this->parser->getParent() && !$this->parser->hasTraits()) {
324
+ throw new Twig_Error_Syntax('Calling "parent" on a template that does not extend nor "use" another template is forbidden.', $line, $this->parser->getFilename());
325
  }
326
 
327
  return new Twig_Node_Expression_Parent($this->parser->peekBlockStack(), $line);
330
  case 'attribute':
331
  $args = $this->parseArguments();
332
  if (count($args) < 2) {
333
+ throw new Twig_Error_Syntax('The "attribute" function takes at least two arguments (the variable and the attributes).', $line, $this->parser->getFilename());
334
  }
335
 
336
  return new Twig_Node_Expression_GetAttr($args->getNode(0), $args->getNode(1), count($args) > 2 ? $args->getNode(2) : null, Twig_Template::ANY_CALL, $line);
384
 
385
  if ($node instanceof Twig_Node_Expression_Name && null !== $this->parser->getImportedSymbol('template', $node->getAttribute('name'))) {
386
  if (!$arg instanceof Twig_Node_Expression_Constant) {
387
+ throw new Twig_Error_Syntax(sprintf('Dynamic macro names are not supported (called on "%s").', $node->getAttribute('name')), $token->getLine(), $this->parser->getFilename());
388
  }
389
 
390
  $name = $arg->getAttribute('value');
391
 
392
  if ($this->parser->isReservedMacroName($name)) {
393
+ throw new Twig_Error_Syntax(sprintf('"%s" cannot be called as macro as it is a reserved keyword.', $name), $token->getLine(), $this->parser->getFilename());
394
  }
395
 
396
  $node = new Twig_Node_Expression_MethodCall($node, 'get'.$name, $arguments, $lineno);
500
  $name = null;
501
  if ($namedArguments && $token = $stream->nextIf(Twig_Token::OPERATOR_TYPE, '=')) {
502
  if (!$value instanceof Twig_Node_Expression_Name) {
503
+ throw new Twig_Error_Syntax(sprintf('A parameter name must be a string, "%s" given.', get_class($value)), $token->getLine(), $this->parser->getFilename());
504
  }
505
  $name = $value->getAttribute('name');
506
 
540
  while (true) {
541
  $token = $this->parser->getStream()->expect(Twig_Token::NAME_TYPE, null, 'Only variables can be assigned to');
542
  if (in_array($token->getValue(), array('true', 'false', 'none'))) {
543
+ throw new Twig_Error_Syntax(sprintf('You cannot assign a value to "%s".', $token->getValue()), $token->getLine(), $this->parser->getFilename());
544
  }
545
  $targets[] = new Twig_Node_Expression_AssignName($token->getValue(), $token->getLine());
546
 
570
  $env = $this->parser->getEnvironment();
571
 
572
  if (false === $function = $env->getFunction($name)) {
573
+ $e = new Twig_Error_Syntax(sprintf('Unknown "%s" function.', $name), $line, $this->parser->getFilename());
574
+ $e->addSuggestions($name, array_keys($env->getFunctions()));
 
 
575
 
576
+ throw $e;
577
  }
578
 
579
  if ($function instanceof Twig_SimpleFunction && $function->isDeprecated()) {
580
  $message = sprintf('Twig Function "%s" is deprecated', $function->getName());
581
+ if ($function->getAlternative()) {
582
  $message .= sprintf('. Use "%s" instead', $function->getAlternative());
583
  }
584
  $message .= sprintf(' in %s at line %d.', $this->parser->getFilename(), $line);
598
  $env = $this->parser->getEnvironment();
599
 
600
  if (false === $filter = $env->getFilter($name)) {
601
+ $e = new Twig_Error_Syntax(sprintf('Unknown "%s" filter.', $name), $line, $this->parser->getFilename());
602
+ $e->addSuggestions($name, array_keys($env->getFilters()));
 
 
603
 
604
+ throw $e;
605
  }
606
 
607
  if ($filter instanceof Twig_SimpleFilter && $filter->isDeprecated()) {
608
  $message = sprintf('Twig Filter "%s" is deprecated', $filter->getName());
609
+ if ($filter->getAlternative()) {
610
  $message .= sprintf('. Use "%s" instead', $filter->getAlternative());
611
  }
612
  $message .= sprintf(' in %s at line %d.', $this->parser->getFilename(), $line);
vendor/twig/twig/lib/Twig/Extension.php CHANGED
@@ -11,20 +11,16 @@
11
  abstract class Twig_Extension implements Twig_ExtensionInterface
12
  {
13
  /**
14
- * Initializes the runtime environment.
15
  *
16
- * This is where you can load some file that contains filter functions for instance.
17
- *
18
- * @param Twig_Environment $environment The current Twig_Environment instance
19
  */
20
  public function initRuntime(Twig_Environment $environment)
21
  {
22
  }
23
 
24
  /**
25
- * Returns the token parser instances to add to the existing list.
26
- *
27
- * @return array An array of Twig_TokenParserInterface or Twig_TokenParserBrokerInterface instances
28
  */
29
  public function getTokenParsers()
30
  {
@@ -32,9 +28,7 @@ abstract class Twig_Extension implements Twig_ExtensionInterface
32
  }
33
 
34
  /**
35
- * Returns the node visitor instances to add to the existing list.
36
- *
37
- * @return Twig_NodeVisitorInterface[] An array of Twig_NodeVisitorInterface instances
38
  */
39
  public function getNodeVisitors()
40
  {
@@ -42,9 +36,7 @@ abstract class Twig_Extension implements Twig_ExtensionInterface
42
  }
43
 
44
  /**
45
- * Returns a list of filters to add to the existing list.
46
- *
47
- * @return array An array of filters
48
  */
49
  public function getFilters()
50
  {
@@ -52,9 +44,7 @@ abstract class Twig_Extension implements Twig_ExtensionInterface
52
  }
53
 
54
  /**
55
- * Returns a list of tests to add to the existing list.
56
- *
57
- * @return array An array of tests
58
  */
59
  public function getTests()
60
  {
@@ -62,9 +52,7 @@ abstract class Twig_Extension implements Twig_ExtensionInterface
62
  }
63
 
64
  /**
65
- * Returns a list of functions to add to the existing list.
66
- *
67
- * @return array An array of functions
68
  */
69
  public function getFunctions()
70
  {
@@ -72,9 +60,7 @@ abstract class Twig_Extension implements Twig_ExtensionInterface
72
  }
73
 
74
  /**
75
- * Returns a list of operators to add to the existing list.
76
- *
77
- * @return array An array of operators
78
  */
79
  public function getOperators()
80
  {
@@ -82,9 +68,9 @@ abstract class Twig_Extension implements Twig_ExtensionInterface
82
  }
83
 
84
  /**
85
- * Returns a list of global variables to add to the existing list.
86
  *
87
- * @return array An array of global variables
88
  */
89
  public function getGlobals()
90
  {
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
  {
28
  }
29
 
30
  /**
31
+ * {@inheritdoc}
 
 
32
  */
33
  public function getNodeVisitors()
34
  {
36
  }
37
 
38
  /**
39
+ * {@inheritdoc}
 
 
40
  */
41
  public function getFilters()
42
  {
44
  }
45
 
46
  /**
47
+ * {@inheritdoc}
 
 
48
  */
49
  public function getTests()
50
  {
52
  }
53
 
54
  /**
55
+ * {@inheritdoc}
 
 
56
  */
57
  public function getFunctions()
58
  {
60
  }
61
 
62
  /**
63
+ * {@inheritdoc}
 
 
64
  */
65
  public function getOperators()
66
  {
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()
76
  {
vendor/twig/twig/lib/Twig/Extension/Core.php CHANGED
@@ -114,11 +114,6 @@ class Twig_Extension_Core extends Twig_Extension
114
  return $this->numberFormat;
115
  }
116
 
117
- /**
118
- * Returns the token parser instance to add to the existing list.
119
- *
120
- * @return Twig_TokenParser[] An array of Twig_TokenParser instances
121
- */
122
  public function getTokenParsers()
123
  {
124
  return array(
@@ -140,11 +135,6 @@ class Twig_Extension_Core extends Twig_Extension
140
  );
141
  }
142
 
143
- /**
144
- * Returns a list of filters to add to the existing list.
145
- *
146
- * @return array An array of filters
147
- */
148
  public function getFilters()
149
  {
150
  $filters = array(
@@ -152,7 +142,7 @@ class Twig_Extension_Core extends Twig_Extension
152
  new Twig_SimpleFilter('date', 'twig_date_format_filter', array('needs_environment' => true)),
153
  new Twig_SimpleFilter('date_modify', 'twig_date_modify_filter', array('needs_environment' => true)),
154
  new Twig_SimpleFilter('format', 'sprintf'),
155
- new Twig_SimpleFilter('replace', 'strtr'),
156
  new Twig_SimpleFilter('number_format', 'twig_number_format_filter', array('needs_environment' => true)),
157
  new Twig_SimpleFilter('abs', 'abs'),
158
  new Twig_SimpleFilter('round', 'twig_round'),
@@ -202,11 +192,6 @@ class Twig_Extension_Core extends Twig_Extension
202
  return $filters;
203
  }
204
 
205
- /**
206
- * Returns a list of global functions to add to the existing list.
207
- *
208
- * @return array An array of global functions
209
- */
210
  public function getFunctions()
211
  {
212
  return array(
@@ -222,11 +207,6 @@ class Twig_Extension_Core extends Twig_Extension
222
  );
223
  }
224
 
225
- /**
226
- * Returns a list of tests to add to the existing list.
227
- *
228
- * @return array An array of tests
229
- */
230
  public function getTests()
231
  {
232
  return array(
@@ -245,11 +225,6 @@ class Twig_Extension_Core extends Twig_Extension
245
  );
246
  }
247
 
248
- /**
249
- * Returns a list of operators to add to the existing list.
250
- *
251
- * @return array An array of operators
252
- */
253
  public function getOperators()
254
  {
255
  return array(
@@ -340,12 +315,10 @@ class Twig_Extension_Core extends Twig_Extension
340
  }
341
  }
342
 
343
- $message = sprintf('The test "%s" does not exist', $name);
344
- if ($alternatives = $env->computeAlternatives($name, array_keys($env->getTests()))) {
345
- $message = sprintf('%s. Did you mean "%s"', $message, implode('", "', $alternatives));
346
- }
347
 
348
- throw new Twig_Error_Syntax($message, $line, $parser->getFilename());
349
  }
350
 
351
  protected function getTestNodeClass(Twig_Parser $parser, $test)
@@ -357,11 +330,6 @@ class Twig_Extension_Core extends Twig_Extension
357
  return $test instanceof Twig_Test_Node ? $test->getClass() : 'Twig_Node_Expression_Test';
358
  }
359
 
360
- /**
361
- * Returns the name of the extension.
362
- *
363
- * @return string The extension name
364
- */
365
  public function getName()
366
  {
367
  return 'core';
@@ -536,12 +504,17 @@ function twig_date_converter(Twig_Environment $env, $date = null, $timezone = nu
536
  return $date;
537
  }
538
 
 
 
 
 
539
  $asString = (string) $date;
540
  if (ctype_digit($asString) || (!empty($asString) && '-' === $asString[0] && ctype_digit(substr($asString, 1)))) {
541
- $date = '@'.$date;
 
 
542
  }
543
 
544
- $date = new DateTime($date, $env->getExtension('core')->getTimezone());
545
  if (false !== $timezone) {
546
  $date->setTimezone($timezone);
547
  }
@@ -549,6 +522,30 @@ function twig_date_converter(Twig_Environment $env, $date = null, $timezone = nu
549
  return $date;
550
  }
551
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
552
  /**
553
  * Rounds a number.
554
  *
@@ -682,15 +679,23 @@ function _twig_markup2string(&$value)
682
  * {# items now contains { 'apple': 'fruit', 'orange': 'fruit', 'peugeot': 'car' } #}
683
  * </pre>
684
  *
685
- * @param array $arr1 An array
686
- * @param array $arr2 An array
687
  *
688
  * @return array The merged array
689
  */
690
  function twig_array_merge($arr1, $arr2)
691
  {
692
- if (!is_array($arr1) || !is_array($arr2)) {
693
- throw new Twig_Error_Runtime(sprintf('The merge filter only works with arrays or hashes; %s and %s given.', gettype($arr1), gettype($arr2)));
 
 
 
 
 
 
 
 
694
  }
695
 
696
  return array_merge($arr1, $arr2);
@@ -812,9 +817,10 @@ function twig_join_filter($value, $glue = '')
812
  * {# returns [aa, bb, cc] #}
813
  * </pre>
814
  *
815
- * @param string $value A string
816
- * @param string $delimiter The delimiter
817
- * @param int $limit The limit
 
818
  *
819
  * @return array The split string as an array
820
  */
@@ -848,6 +854,9 @@ function twig_split_filter(Twig_Environment $env, $value, $delimiter, $limit = n
848
  // The '_default' filter is used internally to avoid using the ternary operator
849
  // which costs a lot for big contexts (before PHP 5.4). So, on average,
850
  // a function call is cheaper.
 
 
 
851
  function _twig_default_filter($value, $default = '')
852
  {
853
  if (twig_test_empty($value)) {
@@ -874,7 +883,7 @@ function _twig_default_filter($value, $default = '')
874
  */
875
  function twig_get_array_keys_filter($array)
876
  {
877
- if (is_object($array) && $array instanceof Traversable) {
878
  return array_keys(iterator_to_array($array));
879
  }
880
 
@@ -896,7 +905,7 @@ function twig_get_array_keys_filter($array)
896
  */
897
  function twig_reverse_filter(Twig_Environment $env, $item, $preserveKeys = false)
898
  {
899
- if (is_object($item) && $item instanceof Traversable) {
900
  return array_reverse(iterator_to_array($item), $preserveKeys);
901
  }
902
 
@@ -928,18 +937,26 @@ function twig_reverse_filter(Twig_Environment $env, $item, $preserveKeys = false
928
  /**
929
  * Sorts an array.
930
  *
931
- * @param array $array
932
  *
933
  * @return array
934
  */
935
  function twig_sort_filter($array)
936
  {
 
 
 
 
 
 
937
  asort($array);
938
 
939
  return $array;
940
  }
941
 
942
- /* used internally */
 
 
943
  function twig_in_filter($value, $compare)
944
  {
945
  if (is_array($compare)) {
@@ -973,7 +990,7 @@ function twig_escape_filter(Twig_Environment $env, $string, $strategy = 'html',
973
  if (!is_string($string)) {
974
  if (is_object($string) && method_exists($string, '__toString')) {
975
  $string = (string) $string;
976
- } else {
977
  return $string;
978
  }
979
  }
@@ -1107,7 +1124,9 @@ function twig_escape_filter(Twig_Environment $env, $string, $strategy = 'html',
1107
  }
1108
  }
1109
 
1110
- /* used internally */
 
 
1111
  function twig_escape_filter_is_safe(Twig_Node $filterArgs)
1112
  {
1113
  foreach ($filterArgs as $arg) {
@@ -1304,9 +1323,8 @@ if (function_exists('mb_get_info')) {
1304
  */
1305
  function twig_capitalize_string_filter(Twig_Environment $env, $string)
1306
  {
1307
- if (null !== ($charset = $env->getCharset())) {
1308
- return mb_strtoupper(mb_substr($string, 0, 1, $charset), $charset).
1309
- mb_strtolower(mb_substr($string, 1, mb_strlen($string, $charset), $charset), $charset);
1310
  }
1311
 
1312
  return ucfirst(strtolower($string));
@@ -1354,7 +1372,9 @@ else {
1354
  }
1355
  }
1356
 
1357
- /* used internally */
 
 
1358
  function twig_ensure_traversable($seq)
1359
  {
1360
  if ($seq instanceof Traversable || is_array($seq)) {
@@ -1457,8 +1477,9 @@ function twig_include(Twig_Environment $env, $context, $template, $variables = a
1457
  /**
1458
  * Returns a template content without rendering it.
1459
  *
1460
- * @param string $name The template name
1461
- * @param bool $ignoreMissing Whether to ignore missing templates or not
 
1462
  *
1463
  * @return string The template source
1464
  */
114
  return $this->numberFormat;
115
  }
116
 
 
 
 
 
 
117
  public function getTokenParsers()
118
  {
119
  return array(
135
  );
136
  }
137
 
 
 
 
 
 
138
  public function getFilters()
139
  {
140
  $filters = array(
142
  new Twig_SimpleFilter('date', 'twig_date_format_filter', array('needs_environment' => true)),
143
  new Twig_SimpleFilter('date_modify', 'twig_date_modify_filter', array('needs_environment' => true)),
144
  new Twig_SimpleFilter('format', 'sprintf'),
145
+ new Twig_SimpleFilter('replace', 'twig_replace_filter'),
146
  new Twig_SimpleFilter('number_format', 'twig_number_format_filter', array('needs_environment' => true)),
147
  new Twig_SimpleFilter('abs', 'abs'),
148
  new Twig_SimpleFilter('round', 'twig_round'),
192
  return $filters;
193
  }
194
 
 
 
 
 
 
195
  public function getFunctions()
196
  {
197
  return array(
207
  );
208
  }
209
 
 
 
 
 
 
210
  public function getTests()
211
  {
212
  return array(
225
  );
226
  }
227
 
 
 
 
 
 
228
  public function getOperators()
229
  {
230
  return array(
315
  }
316
  }
317
 
318
+ $e = new Twig_Error_Syntax(sprintf('Unknown "%s" test.', $name), $line, $parser->getFilename());
319
+ $e->addSuggestions($name, array_keys($env->getTests()));
 
 
320
 
321
+ throw $e;
322
  }
323
 
324
  protected function getTestNodeClass(Twig_Parser $parser, $test)
330
  return $test instanceof Twig_Test_Node ? $test->getClass() : 'Twig_Node_Expression_Test';
331
  }
332
 
 
 
 
 
 
333
  public function getName()
334
  {
335
  return 'core';
504
  return $date;
505
  }
506
 
507
+ if (null === $date || 'now' === $date) {
508
+ return new DateTime($date, false !== $timezone ? $timezone : $env->getExtension('core')->getTimezone());
509
+ }
510
+
511
  $asString = (string) $date;
512
  if (ctype_digit($asString) || (!empty($asString) && '-' === $asString[0] && ctype_digit(substr($asString, 1)))) {
513
+ $date = new DateTime('@'.$date);
514
+ } else {
515
+ $date = new DateTime($date, $env->getExtension('core')->getTimezone());
516
  }
517
 
 
518
  if (false !== $timezone) {
519
  $date->setTimezone($timezone);
520
  }
522
  return $date;
523
  }
524
 
525
+ /**
526
+ * Replaces strings within a string.
527
+ *
528
+ * @param string $str String to replace in
529
+ * @param array|Traversable $from Replace values
530
+ * @param string|null $to Replace to, deprecated (@see http://php.net/manual/en/function.strtr.php)
531
+ *
532
+ * @return string
533
+ */
534
+ function twig_replace_filter($str, $from, $to = null)
535
+ {
536
+ if ($from instanceof Traversable) {
537
+ $from = iterator_to_array($from);
538
+ } elseif (is_string($from) && is_string($to)) {
539
+ @trigger_error('Using "replace" with character by character replacement is deprecated and will be removed in Twig 2.0', E_USER_DEPRECATED);
540
+
541
+ return strtr($str, $from, $to);
542
+ } elseif (!is_array($from)) {
543
+ throw new Twig_Error_Runtime(sprintf('The "replace" filter expects an array or "Traversable" as replace values, got "%s".',is_object($from) ? get_class($from) : gettype($from)));
544
+ }
545
+
546
+ return strtr($str, $from);
547
+ }
548
+
549
  /**
550
  * Rounds a number.
551
  *
679
  * {# items now contains { 'apple': 'fruit', 'orange': 'fruit', 'peugeot': 'car' } #}
680
  * </pre>
681
  *
682
+ * @param array|Traversable $arr1 An array
683
+ * @param array|Traversable $arr2 An array
684
  *
685
  * @return array The merged array
686
  */
687
  function twig_array_merge($arr1, $arr2)
688
  {
689
+ if ($arr1 instanceof Traversable) {
690
+ $arr1 = iterator_to_array($arr1);
691
+ } elseif (!is_array($arr1)) {
692
+ throw new Twig_Error_Runtime(sprintf('The merge filter only works with arrays or "Traversable", got "%s" as first argument.', gettype($arr1)));
693
+ }
694
+
695
+ if ($arr2 instanceof Traversable) {
696
+ $arr2 = iterator_to_array($arr2);
697
+ } elseif (!is_array($arr2)) {
698
+ throw new Twig_Error_Runtime(sprintf('The merge filter only works with arrays or "Traversable", got "%s" as second argument.', gettype($arr2)));
699
  }
700
 
701
  return array_merge($arr1, $arr2);
817
  * {# returns [aa, bb, cc] #}
818
  * </pre>
819
  *
820
+ * @param Twig_Environment $env A Twig_Environment instance
821
+ * @param string $value A string
822
+ * @param string $delimiter The delimiter
823
+ * @param int $limit The limit
824
  *
825
  * @return array The split string as an array
826
  */
854
  // The '_default' filter is used internally to avoid using the ternary operator
855
  // which costs a lot for big contexts (before PHP 5.4). So, on average,
856
  // a function call is cheaper.
857
+ /**
858
+ * @internal
859
+ */
860
  function _twig_default_filter($value, $default = '')
861
  {
862
  if (twig_test_empty($value)) {
883
  */
884
  function twig_get_array_keys_filter($array)
885
  {
886
+ if ($array instanceof Traversable) {
887
  return array_keys(iterator_to_array($array));
888
  }
889
 
905
  */
906
  function twig_reverse_filter(Twig_Environment $env, $item, $preserveKeys = false)
907
  {
908
+ if ($item instanceof Traversable) {
909
  return array_reverse(iterator_to_array($item), $preserveKeys);
910
  }
911
 
937
  /**
938
  * Sorts an array.
939
  *
940
+ * @param array|Traversable $array
941
  *
942
  * @return array
943
  */
944
  function twig_sort_filter($array)
945
  {
946
+ if ($array instanceof Traversable) {
947
+ $array = iterator_to_array($array);
948
+ } elseif (!is_array($array)) {
949
+ throw new Twig_Error_Runtime(sprintf('The sort filter only works with arrays or "Traversable", got "%s".', gettype($array)));
950
+ }
951
+
952
  asort($array);
953
 
954
  return $array;
955
  }
956
 
957
+ /**
958
+ * @internal
959
+ */
960
  function twig_in_filter($value, $compare)
961
  {
962
  if (is_array($compare)) {
990
  if (!is_string($string)) {
991
  if (is_object($string) && method_exists($string, '__toString')) {
992
  $string = (string) $string;
993
+ } elseif (in_array($strategy, array('html', 'js', 'css', 'html_attr', 'url'))) {
994
  return $string;
995
  }
996
  }
1124
  }
1125
  }
1126
 
1127
+ /**
1128
+ * @internal
1129
+ */
1130
  function twig_escape_filter_is_safe(Twig_Node $filterArgs)
1131
  {
1132
  foreach ($filterArgs as $arg) {
1323
  */
1324
  function twig_capitalize_string_filter(Twig_Environment $env, $string)
1325
  {
1326
+ if (null !== $charset = $env->getCharset()) {
1327
+ return mb_strtoupper(mb_substr($string, 0, 1, $charset), $charset).mb_strtolower(mb_substr($string, 1, mb_strlen($string, $charset), $charset), $charset);
 
1328
  }
1329
 
1330
  return ucfirst(strtolower($string));
1372
  }
1373
  }
1374
 
1375
+ /**
1376
+ * @internal
1377
+ */
1378
  function twig_ensure_traversable($seq)
1379
  {
1380
  if ($seq instanceof Traversable || is_array($seq)) {
1477
  /**
1478
  * Returns a template content without rendering it.
1479
  *
1480
+ * @param Twig_Environment $env
1481
+ * @param string $name The template name
1482
+ * @param bool $ignoreMissing Whether to ignore missing templates or not
1483
  *
1484
  * @return string The template source
1485
  */
vendor/twig/twig/lib/Twig/Extension/Debug.php CHANGED
@@ -10,11 +10,6 @@
10
  */
11
  class Twig_Extension_Debug extends Twig_Extension
12
  {
13
- /**
14
- * Returns a list of global functions to add to the existing list.
15
- *
16
- * @return array An array of global functions
17
- */
18
  public function getFunctions()
19
  {
20
  // dump is safe if var_dump is overridden by xdebug
@@ -32,11 +27,6 @@ class Twig_Extension_Debug extends Twig_Extension
32
  );
33
  }
34
 
35
- /**
36
- * Returns the name of the extension.
37
- *
38
- * @return string The extension name
39
- */
40
  public function getName()
41
  {
42
  return 'debug';
10
  */
11
  class Twig_Extension_Debug extends Twig_Extension
12
  {
 
 
 
 
 
13
  public function getFunctions()
14
  {
15
  // dump is safe if var_dump is overridden by xdebug
27
  );
28
  }
29
 
 
 
 
 
 
30
  public function getName()
31
  {
32
  return 'debug';
vendor/twig/twig/lib/Twig/Extension/Escaper.php CHANGED
@@ -24,31 +24,16 @@ class Twig_Extension_Escaper extends Twig_Extension
24
  $this->setDefaultStrategy($defaultStrategy);
25
  }
26
 
27
- /**
28
- * Returns the token parser instances to add to the existing list.
29
- *
30
- * @return array An array of Twig_TokenParserInterface or Twig_TokenParserBrokerInterface instances
31
- */
32
  public function getTokenParsers()
33
  {
34
  return array(new Twig_TokenParser_AutoEscape());
35
  }
36
 
37
- /**
38
- * Returns the node visitor instances to add to the existing list.
39
- *
40
- * @return Twig_NodeVisitorInterface[] An array of Twig_NodeVisitorInterface instances
41
- */
42
  public function getNodeVisitors()
43
  {
44
  return array(new Twig_NodeVisitor_Escaper());
45
  }
46
 
47
- /**
48
- * Returns a list of filters to add to the existing list.
49
- *
50
- * @return array An array of filters
51
- */
52
  public function getFilters()
53
  {
54
  return array(
@@ -98,11 +83,6 @@ class Twig_Extension_Escaper extends Twig_Extension
98
  return $this->defaultStrategy;
99
  }
100
 
101
- /**
102
- * Returns the name of the extension.
103
- *
104
- * @return string The extension name
105
- */
106
  public function getName()
107
  {
108
  return 'escaper';
24
  $this->setDefaultStrategy($defaultStrategy);
25
  }
26
 
 
 
 
 
 
27
  public function getTokenParsers()
28
  {
29
  return array(new Twig_TokenParser_AutoEscape());
30
  }
31
 
 
 
 
 
 
32
  public function getNodeVisitors()
33
  {
34
  return array(new Twig_NodeVisitor_Escaper());
35
  }
36
 
 
 
 
 
 
37
  public function getFilters()
38
  {
39
  return array(
83
  return $this->defaultStrategy;
84
  }
85
 
 
 
 
 
 
86
  public function getName()
87
  {
88
  return 'escaper';
vendor/twig/twig/lib/Twig/Extension/GlobalsInterface.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ * Enables usage of the deprecated Twig_Extension::getGlobals() method.
14
+ *
15
+ * Explicitly implement this interface if you really need to implement the
16
+ * deprecated getGlobals() method in your extensions.
17
+ *
18
+ * @author Fabien Potencier <fabien@symfony.com>
19
+ */
20
+ interface Twig_Extension_GlobalsInterface
21
+ {
22
+ }
vendor/twig/twig/lib/Twig/Extension/InitRuntimeInterface.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ * Enables usage of the deprecated Twig_Extension::initRuntime() method.
14
+ *
15
+ * Explicitly implement this interface if you really need to implement the
16
+ * deprecated initRuntime() method in your extensions.
17
+ *
18
+ * @author Fabien Potencier <fabien@symfony.com>
19
+ */
20
+ interface Twig_Extension_InitRuntimeInterface
21
+ {
22
+ }
vendor/twig/twig/lib/Twig/Extension/Optimizer.php CHANGED
@@ -17,17 +17,11 @@ class Twig_Extension_Optimizer extends Twig_Extension
17
  $this->optimizers = $optimizers;
18
  }
19
 
20
- /**
21
- * {@inheritdoc}
22
- */
23
  public function getNodeVisitors()
24
  {
25
  return array(new Twig_NodeVisitor_Optimizer($this->optimizers));
26
  }
27
 
28
- /**
29
- * {@inheritdoc}
30
- */
31
  public function getName()
32
  {
33
  return 'optimizer';
17
  $this->optimizers = $optimizers;
18
  }
19
 
 
 
 
20
  public function getNodeVisitors()
21
  {
22
  return array(new Twig_NodeVisitor_Optimizer($this->optimizers));
23
  }
24
 
 
 
 
25
  public function getName()
26
  {
27
  return 'optimizer';
vendor/twig/twig/lib/Twig/Extension/Profiler.php CHANGED
@@ -34,17 +34,11 @@ class Twig_Extension_Profiler extends Twig_Extension
34
  }
35
  }
36
 
37
- /**
38
- * {@inheritdoc}
39
- */
40
  public function getNodeVisitors()
41
  {
42
  return array(new Twig_Profiler_NodeVisitor_Profiler($this->getName()));
43
  }
44
 
45
- /**
46
- * {@inheritdoc}
47
- */
48
  public function getName()
49
  {
50
  return 'profiler';
34
  }
35
  }
36
 
 
 
 
37
  public function getNodeVisitors()
38
  {
39
  return array(new Twig_Profiler_NodeVisitor_Profiler($this->getName()));
40
  }
41
 
 
 
 
42
  public function getName()
43
  {
44
  return 'profiler';
vendor/twig/twig/lib/Twig/Extension/Sandbox.php CHANGED
@@ -20,21 +20,11 @@ class Twig_Extension_Sandbox extends Twig_Extension
20
  $this->sandboxedGlobally = $sandboxed;
21
  }
22
 
23
- /**
24
- * Returns the token parser instances to add to the existing list.
25
- *
26
- * @return array An array of Twig_TokenParserInterface or Twig_TokenParserBrokerInterface instances
27
- */
28
  public function getTokenParsers()
29
  {
30
  return array(new Twig_TokenParser_Sandbox());
31
  }
32
 
33
- /**
34
- * Returns the node visitor instances to add to the existing list.
35
- *
36
- * @return Twig_NodeVisitorInterface[] An array of Twig_NodeVisitorInterface instances
37
- */
38
  public function getNodeVisitors()
39
  {
40
  return array(new Twig_NodeVisitor_Sandbox());
@@ -100,11 +90,6 @@ class Twig_Extension_Sandbox extends Twig_Extension
100
  return $obj;
101
  }
102
 
103
- /**
104
- * Returns the name of the extension.
105
- *
106
- * @return string The extension name
107
- */
108
  public function getName()
109
  {
110
  return 'sandbox';
20
  $this->sandboxedGlobally = $sandboxed;
21
  }
22
 
 
 
 
 
 
23
  public function getTokenParsers()
24
  {
25
  return array(new Twig_TokenParser_Sandbox());
26
  }
27
 
 
 
 
 
 
28
  public function getNodeVisitors()
29
  {
30
  return array(new Twig_NodeVisitor_Sandbox());
90
  return $obj;
91
  }
92
 
 
 
 
 
 
93
  public function getName()
94
  {
95
  return 'sandbox';
vendor/twig/twig/lib/Twig/Extension/Staging.php CHANGED
@@ -15,6 +15,8 @@
15
  * This class is used by Twig_Environment as a staging area and must not be used directly.
16
  *
17
  * @author Fabien Potencier <fabien@symfony.com>
 
 
18
  */
19
  class Twig_Extension_Staging extends Twig_Extension
20
  {
@@ -30,9 +32,6 @@ class Twig_Extension_Staging extends Twig_Extension
30
  $this->functions[$name] = $function;
31
  }
32
 
33
- /**
34
- * {@inheritdoc}
35
- */
36
  public function getFunctions()
37
  {
38
  return $this->functions;
@@ -43,9 +42,6 @@ class Twig_Extension_Staging extends Twig_Extension
43
  $this->filters[$name] = $filter;
44
  }
45
 
46
- /**
47
- * {@inheritdoc}
48
- */
49
  public function getFilters()
50
  {
51
  return $this->filters;
@@ -56,9 +52,6 @@ class Twig_Extension_Staging extends Twig_Extension
56
  $this->visitors[] = $visitor;
57
  }
58
 
59
- /**
60
- * {@inheritdoc}
61
- */
62
  public function getNodeVisitors()
63
  {
64
  return $this->visitors;
@@ -69,9 +62,6 @@ class Twig_Extension_Staging extends Twig_Extension
69
  $this->tokenParsers[] = $parser;
70
  }
71
 
72
- /**
73
- * {@inheritdoc}
74
- */
75
  public function getTokenParsers()
76
  {
77
  return $this->tokenParsers;
@@ -82,9 +72,6 @@ class Twig_Extension_Staging extends Twig_Extension
82
  $this->globals[$name] = $value;
83
  }
84
 
85
- /**
86
- * {@inheritdoc}
87
- */
88
  public function getGlobals()
89
  {
90
  return $this->globals;
@@ -95,17 +82,11 @@ class Twig_Extension_Staging extends Twig_Extension
95
  $this->tests[$name] = $test;
96
  }
97
 
98
- /**
99
- * {@inheritdoc}
100
- */
101
  public function getTests()
102
  {
103
  return $this->tests;
104
  }
105
 
106
- /**
107
- * {@inheritdoc}
108
- */
109
  public function getName()
110
  {
111
  return 'staging';
15
  * This class is used by Twig_Environment as a staging area and must not be used directly.
16
  *
17
  * @author Fabien Potencier <fabien@symfony.com>
18
+ *
19
+ * @internal
20
  */
21
  class Twig_Extension_Staging extends Twig_Extension
22
  {
32
  $this->functions[$name] = $function;
33
  }
34
 
 
 
 
35
  public function getFunctions()
36
  {
37
  return $this->functions;
42
  $this->filters[$name] = $filter;
43
  }
44
 
 
 
 
45
  public function getFilters()
46
  {
47
  return $this->filters;
52
  $this->visitors[] = $visitor;
53
  }
54
 
 
 
 
55
  public function getNodeVisitors()
56
  {
57
  return $this->visitors;
62
  $this->tokenParsers[] = $parser;
63
  }
64
 
 
 
 
65
  public function getTokenParsers()
66
  {
67
  return $this->tokenParsers;
72
  $this->globals[$name] = $value;
73
  }
74
 
 
 
 
75
  public function getGlobals()
76
  {
77
  return $this->globals;
82
  $this->tests[$name] = $test;
83
  }
84
 
 
 
 
85
  public function getTests()
86
  {
87
  return $this->tests;
88
  }
89
 
 
 
 
90
  public function getName()
91
  {
92
  return 'staging';
vendor/twig/twig/lib/Twig/Extension/StringLoader.php CHANGED
@@ -10,9 +10,6 @@
10
  */
11
  class Twig_Extension_StringLoader extends Twig_Extension
12
  {
13
- /**
14
- * {@inheritdoc}
15
- */
16
  public function getFunctions()
17
  {
18
  return array(
@@ -20,9 +17,6 @@ class Twig_Extension_StringLoader extends Twig_Extension
20
  );
21
  }
22
 
23
- /**
24
- * {@inheritdoc}
25
- */
26
  public function getName()
27
  {
28
  return 'string_loader';
@@ -37,11 +31,11 @@ class Twig_Extension_StringLoader extends Twig_Extension
37
  * </pre>
38
  *
39
  * @param Twig_Environment $env A Twig_Environment instance
40
- * @param string $template A template as a string
41
  *
42
  * @return Twig_Template A Twig_Template instance
43
  */
44
  function twig_template_from_string(Twig_Environment $env, $template)
45
  {
46
- return $env->createTemplate($template);
47
  }
10
  */
11
  class Twig_Extension_StringLoader extends Twig_Extension
12
  {
 
 
 
13
  public function getFunctions()
14
  {
15
  return array(
17
  );
18
  }
19
 
 
 
 
20
  public function getName()
21
  {
22
  return 'string_loader';
31
  * </pre>
32
  *
33
  * @param Twig_Environment $env A Twig_Environment instance
34
+ * @param string $template A template as a string or object implementing __toString()
35
  *
36
  * @return Twig_Template A Twig_Template instance
37
  */
38
  function twig_template_from_string(Twig_Environment $env, $template)
39
  {
40
+ return $env->createTemplate((string) $template);
41
  }
vendor/twig/twig/lib/Twig/ExtensionInterface.php CHANGED
@@ -22,13 +22,15 @@ interface Twig_ExtensionInterface
22
  * This is where you can load some file that contains filter functions for instance.
23
  *
24
  * @param Twig_Environment $environment The current Twig_Environment instance
 
 
25
  */
26
  public function initRuntime(Twig_Environment $environment);
27
 
28
  /**
29
  * Returns the token parser instances to add to the existing list.
30
  *
31
- * @return array An array of Twig_TokenParserInterface or Twig_TokenParserBrokerInterface instances
32
  */
33
  public function getTokenParsers();
34
 
@@ -42,21 +44,21 @@ interface Twig_ExtensionInterface
42
  /**
43
  * Returns a list of filters to add to the existing list.
44
  *
45
- * @return array An array of filters
46
  */
47
  public function getFilters();
48
 
49
  /**
50
  * Returns a list of tests to add to the existing list.
51
  *
52
- * @return array An array of tests
53
  */
54
  public function getTests();
55
 
56
  /**
57
  * Returns a list of functions to add to the existing list.
58
  *
59
- * @return array An array of functions
60
  */
61
  public function getFunctions();
62
 
@@ -71,6 +73,8 @@ interface Twig_ExtensionInterface
71
  * Returns a list of global variables to add to the existing list.
72
  *
73
  * @return array An array of global variables
 
 
74
  */
75
  public function getGlobals();
76
 
22
  * This is where you can load some file that contains filter functions for instance.
23
  *
24
  * @param Twig_Environment $environment The current Twig_Environment instance
25
+ *
26
+ * @deprecated since 1.23 (to be removed in 2.0), implement Twig_Extension_InitRuntimeInterace instead
27
  */
28
  public function initRuntime(Twig_Environment $environment);
29
 
30
  /**
31
  * Returns the token parser instances to add to the existing list.
32
  *
33
+ * @return Twig_TokenParserInterface[]
34
  */
35
  public function getTokenParsers();
36
 
44
  /**
45
  * Returns a list of filters to add to the existing list.
46
  *
47
+ * @return Twig_SimpleFilter[]
48
  */
49
  public function getFilters();
50
 
51
  /**
52
  * Returns a list of tests to add to the existing list.
53
  *
54
+ * @return Twig_SimpleTest[]
55
  */
56
  public function getTests();
57
 
58
  /**
59
  * Returns a list of functions to add to the existing list.
60
  *
61
+ * @return Twig_SimpleFunction[]
62
  */
63
  public function getFunctions();
64
 
73
  * Returns a list of global variables to add to the existing list.
74
  *
75
  * @return array An array of global variables
76
+ *
77
+ * @deprecated since 1.23 (to be removed in 2.0), implement Twig_Extension_GlobalsInterface instead
78
  */
79
  public function getGlobals();
80
 
vendor/twig/twig/lib/Twig/FileExtensionEscapingStrategy.php CHANGED
@@ -27,15 +27,21 @@ class Twig_FileExtensionEscapingStrategy
27
  *
28
  * @param string $filename The template file name
29
  *
30
- * @return string The escaping strategy name to use
31
  */
32
  public static function guess($filename)
33
  {
34
- if (!preg_match('{\.(js|css|txt)(?:\.[^/\\\\]+)?$}', $filename, $match)) {
35
- return 'html';
36
  }
37
 
38
- switch ($match[1]) {
 
 
 
 
 
 
39
  case 'js':
40
  return 'js';
41
 
@@ -44,6 +50,9 @@ class Twig_FileExtensionEscapingStrategy
44
 
45
  case 'txt':
46
  return false;
 
 
 
47
  }
48
  }
49
  }
27
  *
28
  * @param string $filename The template file name
29
  *
30
+ * @return string|false The escaping strategy name to use or false to disable
31
  */
32
  public static function guess($filename)
33
  {
34
+ if (in_array(substr($filename, -1), array('/', '\\'))) {
35
+ return 'html'; // return html for directories
36
  }
37
 
38
+ if ('.twig' === substr($filename, -5)) {
39
+ $filename = substr($filename, 0, -5);
40
+ }
41
+
42
+ $extension = pathinfo($filename, PATHINFO_EXTENSION);
43
+
44
+ switch ($extension) {
45
  case 'js':
46
  return 'js';
47
 
50
 
51
  case 'txt':
52
  return false;
53
+
54
+ default:
55
+ return 'html';
56
  }
57
  }
58
  }
vendor/twig/twig/lib/Twig/Lexer.php CHANGED
@@ -129,7 +129,7 @@ class Twig_Lexer implements Twig_LexerInterface
129
 
130
  if (!empty($this->brackets)) {
131
  list($expect, $lineno) = array_pop($this->brackets);
132
- throw new Twig_Error_Syntax(sprintf('Unclosed "%s"', $expect), $lineno, $this->filename);
133
  }
134
 
135
  if ($mbEncoding) {
@@ -224,7 +224,7 @@ class Twig_Lexer implements Twig_LexerInterface
224
  $this->moveCursor($match[0]);
225
 
226
  if ($this->cursor >= $this->end) {
227
- throw new Twig_Error_Syntax(sprintf('Unclosed "%s"', $this->state === self::STATE_BLOCK ? 'block' : 'variable'), $this->currentVarBlockLine, $this->filename);
228
  }
229
  }
230
 
@@ -256,12 +256,12 @@ class Twig_Lexer implements Twig_LexerInterface
256
  // closing bracket
257
  elseif (false !== strpos(')]}', $this->code[$this->cursor])) {
258
  if (empty($this->brackets)) {
259
- throw new Twig_Error_Syntax(sprintf('Unexpected "%s"', $this->code[$this->cursor]), $this->lineno, $this->filename);
260
  }
261
 
262
  list($expect, $lineno) = array_pop($this->brackets);
263
  if ($this->code[$this->cursor] != strtr($expect, '([{', ')]}')) {
264
- throw new Twig_Error_Syntax(sprintf('Unclosed "%s"', $expect), $lineno, $this->filename);
265
  }
266
  }
267
 
@@ -281,7 +281,7 @@ class Twig_Lexer implements Twig_LexerInterface
281
  }
282
  // unlexable
283
  else {
284
- throw new Twig_Error_Syntax(sprintf('Unexpected character "%s"', $this->code[$this->cursor]), $this->lineno, $this->filename);
285
  }
286
  }
287
 
@@ -292,7 +292,7 @@ class Twig_Lexer implements Twig_LexerInterface
292
  }
293
 
294
  if (!preg_match(str_replace('%s', $tag, $this->regexes['lex_raw_data']), $this->code, $match, PREG_OFFSET_CAPTURE, $this->cursor)) {
295
- throw new Twig_Error_Syntax(sprintf('Unexpected end of file: Unclosed "%s" block', $tag), $this->lineno, $this->filename);
296
  }
297
 
298
  $text = substr($this->code, $this->cursor, $match[0][1] - $this->cursor);
@@ -308,7 +308,7 @@ class Twig_Lexer implements Twig_LexerInterface
308
  protected function lexComment()
309
  {
310
  if (!preg_match($this->regexes['lex_comment'], $this->code, $match, PREG_OFFSET_CAPTURE, $this->cursor)) {
311
- throw new Twig_Error_Syntax('Unclosed comment', $this->lineno, $this->filename);
312
  }
313
 
314
  $this->moveCursor(substr($this->code, $this->cursor, $match[0][1] - $this->cursor).$match[0][0]);
@@ -327,7 +327,7 @@ class Twig_Lexer implements Twig_LexerInterface
327
  } elseif (preg_match(self::REGEX_DQ_STRING_DELIM, $this->code, $match, null, $this->cursor)) {
328
  list($expect, $lineno) = array_pop($this->brackets);
329
  if ($this->code[$this->cursor] != '"') {
330
- throw new Twig_Error_Syntax(sprintf('Unclosed "%s"', $expect), $lineno, $this->filename);
331
  }
332
 
333
  $this->popState();
129
 
130
  if (!empty($this->brackets)) {
131
  list($expect, $lineno) = array_pop($this->brackets);
132
+ throw new Twig_Error_Syntax(sprintf('Unclosed "%s".', $expect), $lineno, $this->filename);
133
  }
134
 
135
  if ($mbEncoding) {
224
  $this->moveCursor($match[0]);
225
 
226
  if ($this->cursor >= $this->end) {
227
+ throw new Twig_Error_Syntax(sprintf('Unclosed "%s".', $this->state === self::STATE_BLOCK ? 'block' : 'variable'), $this->currentVarBlockLine, $this->filename);
228
  }
229
  }
230
 
256
  // closing bracket
257
  elseif (false !== strpos(')]}', $this->code[$this->cursor])) {
258
  if (empty($this->brackets)) {
259
+ throw new Twig_Error_Syntax(sprintf('Unexpected "%s".', $this->code[$this->cursor]), $this->lineno, $this->filename);
260
  }
261
 
262
  list($expect, $lineno) = array_pop($this->brackets);
263
  if ($this->code[$this->cursor] != strtr($expect, '([{', ')]}')) {
264
+ throw new Twig_Error_Syntax(sprintf('Unclosed "%s".', $expect), $lineno, $this->filename);
265
  }
266
  }
267
 
281
  }
282
  // unlexable
283
  else {
284
+ throw new Twig_Error_Syntax(sprintf('Unexpected character "%s".', $this->code[$this->cursor]), $this->lineno, $this->filename);
285
  }
286
  }
287
 
292
  }
293
 
294
  if (!preg_match(str_replace('%s', $tag, $this->regexes['lex_raw_data']), $this->code, $match, PREG_OFFSET_CAPTURE, $this->cursor)) {
295
+ throw new Twig_Error_Syntax(sprintf('Unexpected end of file: Unclosed "%s" block.', $tag), $this->lineno, $this->filename);
296
  }
297
 
298
  $text = substr($this->code, $this->cursor, $match[0][1] - $this->cursor);
308
  protected function lexComment()
309
  {
310
  if (!preg_match($this->regexes['lex_comment'], $this->code, $match, PREG_OFFSET_CAPTURE, $this->cursor)) {
311
+ throw new Twig_Error_Syntax('Unclosed comment.', $this->lineno, $this->filename);
312
  }
313
 
314
  $this->moveCursor(substr($this->code, $this->cursor, $match[0][1] - $this->cursor).$match[0][0]);
327
  } elseif (preg_match(self::REGEX_DQ_STRING_DELIM, $this->code, $match, null, $this->cursor)) {
328
  list($expect, $lineno) = array_pop($this->brackets);
329
  if ($this->code[$this->cursor] != '"') {
330
+ throw new Twig_Error_Syntax(sprintf('Unclosed "%s".', $expect), $lineno, $this->filename);
331
  }
332
 
333
  $this->popState();
vendor/twig/twig/lib/Twig/Loader/Chain.php CHANGED
@@ -60,7 +60,7 @@ class Twig_Loader_Chain implements Twig_LoaderInterface, Twig_ExistsLoaderInterf
60
  }
61
  }
62
 
63
- throw new Twig_Error_Loader(sprintf('Template "%s" is not defined (%s).', $name, implode(', ', $exceptions)));
64
  }
65
 
66
  /**
@@ -112,7 +112,7 @@ class Twig_Loader_Chain implements Twig_LoaderInterface, Twig_ExistsLoaderInterf
112
  }
113
  }
114
 
115
- throw new Twig_Error_Loader(sprintf('Template "%s" is not defined (%s).', $name, implode(' ', $exceptions)));
116
  }
117
 
118
  /**
@@ -133,6 +133,6 @@ class Twig_Loader_Chain implements Twig_LoaderInterface, Twig_ExistsLoaderInterf
133
  }
134
  }
135
 
136
- throw new Twig_Error_Loader(sprintf('Template "%s" is not defined (%s).', $name, implode(' ', $exceptions)));
137
  }
138
  }
60
  }
61
  }
62
 
63
+ throw new Twig_Error_Loader(sprintf('Template "%s" is not defined%s.', $name, $exceptions ? ' ('.implode(', ', $exceptions).')' : ''));
64
  }
65
 
66
  /**
112
  }
113
  }
114
 
115
+ throw new Twig_Error_Loader(sprintf('Template "%s" is not defined%s.', $name, $exceptions ? ' ('.implode(', ', $exceptions).')' : ''));
116
  }
117
 
118
  /**
133
  }
134
  }
135
 
136
+ throw new Twig_Error_Loader(sprintf('Template "%s" is not defined%s.', $name, $exceptions ? ' ('.implode(', ', $exceptions).')' : ''));
137
  }
138
  }
vendor/twig/twig/lib/Twig/Loader/Filesystem.php CHANGED
@@ -233,7 +233,7 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface, Twig_ExistsLoaderI
233
 
234
  protected function normalizeName($name)
235
  {
236
- return preg_replace('#/{2,}#', '/', strtr((string) $name, '\\', '/'));
237
  }
238
 
239
  protected function validateName($name)
233
 
234
  protected function normalizeName($name)
235
  {
236
+ return preg_replace('#/{2,}#', '/', str_replace('\\', '/', (string) $name));
237
  }
238
 
239
  protected function validateName($name)
vendor/twig/twig/lib/Twig/Loader/String.php CHANGED
@@ -9,7 +9,7 @@
9
  * file that was distributed with this source code.
10
  */
11
 
12
- @trigger_error('The Twig_Loader_String class is deprecated since version 1.18.1 and will be removed in 2.0. Use Twig_Loader_Array instead.', E_USER_DEPRECATED);
13
 
14
  /**
15
  * Loads a template from a string.
@@ -23,6 +23,8 @@
23
  *
24
  * @deprecated since 1.18.1 (to be removed in 2.0)
25
  *
 
 
26
  * @author Fabien Potencier <fabien@symfony.com>
27
  */
28
  class Twig_Loader_String implements Twig_LoaderInterface, Twig_ExistsLoaderInterface
9
  * file that was distributed with this source code.
10
  */
11
 
12
+ @trigger_error('The Twig_Loader_String class is deprecated since version 1.18.1 and will be removed in 2.0. Use Twig_Loader_Array instead or Twig_Environment::createTemplate().', E_USER_DEPRECATED);
13
 
14
  /**
15
  * Loads a template from a string.
23
  *
24
  * @deprecated since 1.18.1 (to be removed in 2.0)
25
  *
26
+ * @internal
27
+ *
28
  * @author Fabien Potencier <fabien@symfony.com>
29
  */
30
  class Twig_Loader_String implements Twig_LoaderInterface, Twig_ExistsLoaderInterface
vendor/twig/twig/lib/Twig/Node.php CHANGED
@@ -101,7 +101,7 @@ class Twig_Node implements Twig_NodeInterface
101
  $node->appendChild($child);
102
  }
103
 
104
- return $asDom ? $dom : $dom->saveXml();
105
  }
106
 
107
  public function compile(Twig_Compiler $compiler)
101
  $node->appendChild($child);
102
  }
103
 
104
+ return $asDom ? $dom : $dom->saveXML();
105
  }
106
 
107
  public function compile(Twig_Compiler $compiler)
vendor/twig/twig/lib/Twig/Node/AutoEscape.php CHANGED
@@ -27,11 +27,6 @@ class Twig_Node_AutoEscape extends Twig_Node
27
  parent::__construct(array('body' => $body), array('value' => $value), $lineno, $tag);
28
  }
29
 
30
- /**
31
- * Compiles the node to PHP.
32
- *
33
- * @param Twig_Compiler $compiler A Twig_Compiler instance
34
- */
35
  public function compile(Twig_Compiler $compiler)
36
  {
37
  $compiler->subcompile($this->getNode('body'));
27
  parent::__construct(array('body' => $body), array('value' => $value), $lineno, $tag);
28
  }
29
 
 
 
 
 
 
30
  public function compile(Twig_Compiler $compiler)
31
  {
32
  $compiler->subcompile($this->getNode('body'));
vendor/twig/twig/lib/Twig/Node/Block.php CHANGED
@@ -22,11 +22,6 @@ class Twig_Node_Block extends Twig_Node
22
  parent::__construct(array('body' => $body), array('name' => $name), $lineno, $tag);
23
  }
24
 
25
- /**
26
- * Compiles the node to PHP.
27
- *
28
- * @param Twig_Compiler $compiler A Twig_Compiler instance
29
- */
30
  public function compile(Twig_Compiler $compiler)
31
  {
32
  $compiler
22
  parent::__construct(array('body' => $body), array('name' => $name), $lineno, $tag);
23
  }
24
 
 
 
 
 
 
25
  public function compile(Twig_Compiler $compiler)
26
  {
27
  $compiler
vendor/twig/twig/lib/Twig/Node/BlockReference.php CHANGED
@@ -22,11 +22,6 @@ class Twig_Node_BlockReference extends Twig_Node implements Twig_NodeOutputInter
22
  parent::__construct(array(), array('name' => $name), $lineno, $tag);
23
  }
24
 
25
- /**
26
- * Compiles the node to PHP.
27
- *
28
- * @param Twig_Compiler $compiler A Twig_Compiler instance
29
- */
30
  public function compile(Twig_Compiler $compiler)
31
  {
32
  $compiler
22
  parent::__construct(array(), array('name' => $name), $lineno, $tag);
23
  }
24
 
 
 
 
 
 
25
  public function compile(Twig_Compiler $compiler)
26
  {
27
  $compiler
vendor/twig/twig/lib/Twig/Node/Do.php CHANGED
@@ -21,11 +21,6 @@ class Twig_Node_Do extends Twig_Node
21
  parent::__construct(array('expr' => $expr), array(), $lineno, $tag);
22
  }
23
 
24
- /**
25
- * Compiles the node to PHP.
26
- *
27
- * @param Twig_Compiler $compiler A Twig_Compiler instance
28
- */
29
  public function compile(Twig_Compiler $compiler)
30
  {
31
  $compiler
21
  parent::__construct(array('expr' => $expr), array(), $lineno, $tag);
22
  }
23
 
 
 
 
 
 
24
  public function compile(Twig_Compiler $compiler)
25
  {
26
  $compiler
vendor/twig/twig/lib/Twig/Node/Expression/Array.php CHANGED
@@ -60,11 +60,6 @@ class Twig_Node_Expression_Array extends Twig_Node_Expression
60
  array_push($this->nodes, $key, $value);
61
  }
62
 
63
- /**
64
- * Compiles the node to PHP.
65
- *
66
- * @param Twig_Compiler $compiler A Twig_Compiler instance
67
- */
68
  public function compile(Twig_Compiler $compiler)
69
  {
70
  $compiler->raw('array(');
60
  array_push($this->nodes, $key, $value);
61
  }
62
 
 
 
 
 
 
63
  public function compile(Twig_Compiler $compiler)
64
  {
65
  $compiler->raw('array(');
vendor/twig/twig/lib/Twig/Node/Expression/AssignName.php CHANGED
@@ -12,11 +12,6 @@
12
 
13
  class Twig_Node_Expression_AssignName extends Twig_Node_Expression_Name
14
  {
15
- /**
16
- * Compiles the node to PHP.
17
- *
18
- * @param Twig_Compiler $compiler A Twig_Compiler instance
19
- */
20
  public function compile(Twig_Compiler $compiler)
21
  {
22
  $compiler
12
 
13
  class Twig_Node_Expression_AssignName extends Twig_Node_Expression_Name
14
  {
 
 
 
 
 
15
  public function compile(Twig_Compiler $compiler)
16
  {
17
  $compiler
vendor/twig/twig/lib/Twig/Node/Expression/Binary.php CHANGED
@@ -16,11 +16,6 @@ abstract class Twig_Node_Expression_Binary extends Twig_Node_Expression
16
  parent::__construct(array('left' => $left, 'right' => $right), array(), $lineno);
17
  }
18
 
19
- /**
20
- * Compiles the node to PHP.
21
- *
22
- * @param Twig_Compiler $compiler A Twig_Compiler instance
23
- */
24
  public function compile(Twig_Compiler $compiler)
25
  {
26
  $compiler
16
  parent::__construct(array('left' => $left, 'right' => $right), array(), $lineno);
17
  }
18
 
 
 
 
 
 
19
  public function compile(Twig_Compiler $compiler)
20
  {
21
  $compiler
vendor/twig/twig/lib/Twig/Node/Expression/Binary/FloorDiv.php CHANGED
@@ -10,11 +10,6 @@
10
  */
11
  class Twig_Node_Expression_Binary_FloorDiv extends Twig_Node_Expression_Binary
12
  {
13
- /**
14
- * Compiles the node to PHP.
15
- *
16
- * @param Twig_Compiler $compiler A Twig_Compiler instance
17
- */
18
  public function compile(Twig_Compiler $compiler)
19
  {
20
  $compiler->raw('intval(floor(');
10
  */
11
  class Twig_Node_Expression_Binary_FloorDiv extends Twig_Node_Expression_Binary
12
  {
 
 
 
 
 
13
  public function compile(Twig_Compiler $compiler)
14
  {
15
  $compiler->raw('intval(floor(');
vendor/twig/twig/lib/Twig/Node/Expression/Binary/In.php CHANGED
@@ -10,11 +10,6 @@
10
  */
11
  class Twig_Node_Expression_Binary_In extends Twig_Node_Expression_Binary
12
  {
13
- /**
14
- * Compiles the node to PHP.
15
- *
16
- * @param Twig_Compiler $compiler A Twig_Compiler instance
17
- */
18
  public function compile(Twig_Compiler $compiler)
19
  {
20
  $compiler
10
  */
11
  class Twig_Node_Expression_Binary_In extends Twig_Node_Expression_Binary
12
  {
 
 
 
 
 
13
  public function compile(Twig_Compiler $compiler)
14
  {
15
  $compiler
vendor/twig/twig/lib/Twig/Node/Expression/Binary/NotIn.php CHANGED
@@ -10,11 +10,6 @@
10
  */
11
  class Twig_Node_Expression_Binary_NotIn extends Twig_Node_Expression_Binary
12
  {
13
- /**
14
- * Compiles the node to PHP.
15
- *
16
- * @param Twig_Compiler $compiler A Twig_Compiler instance
17
- */
18
  public function compile(Twig_Compiler $compiler)
19
  {
20
  $compiler
10
  */
11
  class Twig_Node_Expression_Binary_NotIn extends Twig_Node_Expression_Binary
12
  {
 
 
 
 
 
13
  public function compile(Twig_Compiler $compiler)
14
  {
15
  $compiler
vendor/twig/twig/lib/Twig/Node/Expression/Binary/Power.php CHANGED
@@ -10,11 +10,6 @@
10
  */
11
  class Twig_Node_Expression_Binary_Power extends Twig_Node_Expression_Binary
12
  {
13
- /**
14
- * Compiles the node to PHP.
15
- *
16
- * @param Twig_Compiler $compiler A Twig_Compiler instance
17
- */
18
  public function compile(Twig_Compiler $compiler)
19
  {
20
  $compiler
10
  */
11
  class Twig_Node_Expression_Binary_Power extends Twig_Node_Expression_Binary
12
  {
 
 
 
 
 
13
  public function compile(Twig_Compiler $compiler)
14
  {
15
  $compiler
vendor/twig/twig/lib/Twig/Node/Expression/Binary/Range.php CHANGED
@@ -10,11 +10,6 @@
10
  */
11
  class Twig_Node_Expression_Binary_Range extends Twig_Node_Expression_Binary
12
  {
13
- /**
14
- * Compiles the node to PHP.
15
- *
16
- * @param Twig_Compiler $compiler A Twig_Compiler instance
17
- */
18
  public function compile(Twig_Compiler $compiler)
19
  {
20
  $compiler
10
  */
11
  class Twig_Node_Expression_Binary_Range extends Twig_Node_Expression_Binary
12
  {
 
 
 
 
 
13
  public function compile(Twig_Compiler $compiler)
14
  {
15
  $compiler
vendor/twig/twig/lib/Twig/Node/Expression/BlockReference.php CHANGED
@@ -22,11 +22,6 @@ class Twig_Node_Expression_BlockReference extends Twig_Node_Expression
22
  parent::__construct(array('name' => $name), array('as_string' => $asString, 'output' => false), $lineno, $tag);
23
  }
24
 
25
- /**
26
- * Compiles the node to PHP.
27
- *
28
- * @param Twig_Compiler $compiler A Twig_Compiler instance
29
- */
30
  public function compile(Twig_Compiler $compiler)
31
  {
32
  if ($this->getAttribute('as_string')) {
22
  parent::__construct(array('name' => $name), array('as_string' => $asString, 'output' => false), $lineno, $tag);
23
  }
24
 
 
 
 
 
 
25
  public function compile(Twig_Compiler $compiler)
26
  {
27
  if ($this->getAttribute('as_string')) {
vendor/twig/twig/lib/Twig/Node/Expression/ExtensionReference.php CHANGED
@@ -21,11 +21,6 @@ class Twig_Node_Expression_ExtensionReference extends Twig_Node_Expression
21
  parent::__construct(array(), array('name' => $name), $lineno, $tag);
22
  }
23
 
24
- /**
25
- * Compiles the node to PHP.
26
- *
27
- * @param Twig_Compiler $compiler A Twig_Compiler instance
28
- */
29
  public function compile(Twig_Compiler $compiler)
30
  {
31
  $compiler->raw(sprintf("\$this->env->getExtension('%s')", $this->getAttribute('name')));
21
  parent::__construct(array(), array('name' => $name), $lineno, $tag);
22
  }
23
 
 
 
 
 
 
24
  public function compile(Twig_Compiler $compiler)
25
  {
26
  $compiler->raw(sprintf("\$this->env->getExtension('%s')", $this->getAttribute('name')));
vendor/twig/twig/lib/Twig/Node/Expression/Parent.php CHANGED
@@ -22,11 +22,6 @@ class Twig_Node_Expression_Parent extends Twig_Node_Expression
22
  parent::__construct(array(), array('output' => false, 'name' => $name), $lineno, $tag);
23
  }
24
 
25
- /**
26
- * Compiles the node to PHP.
27
- *
28
- * @param Twig_Compiler $compiler A Twig_Compiler instance
29
- */
30
  public function compile(Twig_Compiler $compiler)
31
  {
32
  if ($this->getAttribute('output')) {
22
  parent::__construct(array(), array('output' => false, 'name' => $name), $lineno, $tag);
23
  }
24
 
 
 
 
 
 
25
  public function compile(Twig_Compiler $compiler)
26
  {
27
  if ($this->getAttribute('output')) {
vendor/twig/twig/lib/Twig/Node/Expression/Test/Defined.php CHANGED
@@ -34,7 +34,7 @@ class Twig_Node_Expression_Test_Defined extends Twig_Node_Expression_Test
34
 
35
  $this->changeIgnoreStrictCheck($node);
36
  } else {
37
- throw new Twig_Error_Syntax('The "defined" test only works with simple variables', $this->getLine());
38
  }
39
  }
40
 
34
 
35
  $this->changeIgnoreStrictCheck($node);
36
  } else {
37
+ throw new Twig_Error_Syntax('The "defined" test only works with simple variables.', $this->getLine());
38
  }
39
  }
40
 
vendor/twig/twig/lib/Twig/Node/Flush.php CHANGED
@@ -21,11 +21,6 @@ class Twig_Node_Flush extends Twig_Node
21
  parent::__construct(array(), array(), $lineno, $tag);
22
  }
23
 
24
- /**
25
- * Compiles the node to PHP.
26
- *
27
- * @param Twig_Compiler $compiler A Twig_Compiler instance
28
- */
29
  public function compile(Twig_Compiler $compiler)
30
  {
31
  $compiler
21
  parent::__construct(array(), array(), $lineno, $tag);
22
  }
23
 
 
 
 
 
 
24
  public function compile(Twig_Compiler $compiler)
25
  {
26
  $compiler
vendor/twig/twig/lib/Twig/Node/For.php CHANGED
@@ -30,17 +30,11 @@ class Twig_Node_For extends Twig_Node
30
  parent::__construct(array('key_target' => $keyTarget, 'value_target' => $valueTarget, 'seq' => $seq, 'body' => $body, 'else' => $else), array('with_loop' => true, 'ifexpr' => null !== $ifexpr), $lineno, $tag);
31
  }
32
 
33
- /**
34
- * Compiles the node to PHP.
35
- *
36
- * @param Twig_Compiler $compiler A Twig_Compiler instance
37
- */
38
  public function compile(Twig_Compiler $compiler)
39
  {
40
  $compiler
41
  ->addDebugInfo($this)
42
- // the (array) cast bypasses a PHP 5.2.6 bug
43
- ->write("\$context['_parent'] = (array) \$context;\n")
44
  ->write("\$context['_seq'] = twig_ensure_traversable(")
45
  ->subcompile($this->getNode('seq'))
46
  ->raw(");\n")
30
  parent::__construct(array('key_target' => $keyTarget, 'value_target' => $valueTarget, 'seq' => $seq, 'body' => $body, 'else' => $else), array('with_loop' => true, 'ifexpr' => null !== $ifexpr), $lineno, $tag);
31
  }
32
 
 
 
 
 
 
33
  public function compile(Twig_Compiler $compiler)
34
  {
35
  $compiler
36
  ->addDebugInfo($this)
37
+ ->write("\$context['_parent'] = \$context;\n")
 
38
  ->write("\$context['_seq'] = twig_ensure_traversable(")
39
  ->subcompile($this->getNode('seq'))
40
  ->raw(");\n")
vendor/twig/twig/lib/Twig/Node/ForLoop.php CHANGED
@@ -21,11 +21,6 @@ class Twig_Node_ForLoop extends Twig_Node
21
  parent::__construct(array(), array('with_loop' => false, 'ifexpr' => false, 'else' => false), $lineno, $tag);
22
  }
23
 
24
- /**
25
- * Compiles the node to PHP.
26
- *
27
- * @param Twig_Compiler $compiler A Twig_Compiler instance
28
- */
29
  public function compile(Twig_Compiler $compiler)
30
  {
31
  if ($this->getAttribute('else')) {
21
  parent::__construct(array(), array('with_loop' => false, 'ifexpr' => false, 'else' => false), $lineno, $tag);
22
  }
23
 
 
 
 
 
 
24
  public function compile(Twig_Compiler $compiler)
25
  {
26
  if ($this->getAttribute('else')) {
vendor/twig/twig/lib/Twig/Node/If.php CHANGED
@@ -22,11 +22,6 @@ class Twig_Node_If extends Twig_Node
22
  parent::__construct(array('tests' => $tests, 'else' => $else), array(), $lineno, $tag);
23
  }
24
 
25
- /**
26
- * Compiles the node to PHP.
27
- *
28
- * @param Twig_Compiler $compiler A Twig_Compiler instance
29
- */
30
  public function compile(Twig_Compiler $compiler)
31
  {
32
  $compiler->addDebugInfo($this);
22
  parent::__construct(array('tests' => $tests, 'else' => $else), array(), $lineno, $tag);
23
  }
24
 
 
 
 
 
 
25
  public function compile(Twig_Compiler $compiler)
26
  {
27
  $compiler->addDebugInfo($this);
vendor/twig/twig/lib/Twig/Node/Import.php CHANGED
@@ -21,11 +21,6 @@ class Twig_Node_Import extends Twig_Node
21
  parent::__construct(array('expr' => $expr, 'var' => $var), array(), $lineno, $tag);
22
  }
23
 
24
- /**
25
- * Compiles the node to PHP.
26
- *
27
- * @param Twig_Compiler $compiler A Twig_Compiler instance
28
- */
29
  public function compile(Twig_Compiler $compiler)
30
  {
31
  $compiler
21
  parent::__construct(array('expr' => $expr, 'var' => $var), array(), $lineno, $tag);
22
  }
23
 
 
 
 
 
 
24
  public function compile(Twig_Compiler $compiler)
25
  {
26
  $compiler
vendor/twig/twig/lib/Twig/Node/Include.php CHANGED
@@ -22,11 +22,6 @@ class Twig_Node_Include extends Twig_Node implements Twig_NodeOutputInterface
22
  parent::__construct(array('expr' => $expr, 'variables' => $variables), array('only' => (bool) $only, 'ignore_missing' => (bool) $ignoreMissing), $lineno, $tag);
23
  }
24
 
25
- /**
26
- * Compiles the node to PHP.
27
- *
28
- * @param Twig_Compiler $compiler A Twig_Compiler instance
29
- */
30
  public function compile(Twig_Compiler $compiler)
31
  {
32
  $compiler->addDebugInfo($this);
22
  parent::__construct(array('expr' => $expr, 'variables' => $variables), array('only' => (bool) $only, 'ignore_missing' => (bool) $ignoreMissing), $lineno, $tag);
23
  }
24
 
 
 
 
 
 
25
  public function compile(Twig_Compiler $compiler)
26
  {
27
  $compiler->addDebugInfo($this);
vendor/twig/twig/lib/Twig/Node/Macro.php CHANGED
@@ -22,18 +22,13 @@ class Twig_Node_Macro extends Twig_Node
22
  {
23
  foreach ($arguments as $argumentName => $argument) {
24
  if (self::VARARGS_NAME === $argumentName) {
25
- throw new Twig_Error_Syntax(sprintf('The argument "%s" in macro "%s" cannot be defined because the variable "%s" is reserved for arbitrary arguments', self::VARARGS_NAME, $name, self::VARARGS_NAME), $argument->getLine());
26
  }
27
  }
28
 
29
  parent::__construct(array('body' => $body, 'arguments' => $arguments), array('name' => $name), $lineno, $tag);
30
  }
31
 
32
- /**
33
- * Compiles the node to PHP.
34
- *
35
- * @param Twig_Compiler $compiler A Twig_Compiler instance
36
- */
37
  public function compile(Twig_Compiler $compiler)
38
  {
39
  $compiler
22
  {
23
  foreach ($arguments as $argumentName => $argument) {
24
  if (self::VARARGS_NAME === $argumentName) {
25
+ throw new Twig_Error_Syntax(sprintf('The argument "%s" in macro "%s" cannot be defined because the variable "%s" is reserved for arbitrary arguments.', self::VARARGS_NAME, $name, self::VARARGS_NAME), $argument->getLine());
26
  }
27
  }
28
 
29
  parent::__construct(array('body' => $body, 'arguments' => $arguments), array('name' => $name), $lineno, $tag);
30
  }
31
 
 
 
 
 
 
32
  public function compile(Twig_Compiler $compiler)
33
  {
34
  $compiler
vendor/twig/twig/lib/Twig/Node/Module.php CHANGED
@@ -47,11 +47,6 @@ class Twig_Node_Module extends Twig_Node
47
  $this->setAttribute('index', $index);
48
  }
49
 
50
- /**
51
- * Compiles the node to PHP.
52
- *
53
- * @param Twig_Compiler $compiler A Twig_Compiler instance
54
- */
55
  public function compile(Twig_Compiler $compiler)
56
  {
57
  $this->compileTemplate($compiler);
47
  $this->setAttribute('index', $index);
48
  }
49
 
 
 
 
 
 
50
  public function compile(Twig_Compiler $compiler)
51
  {
52
  $this->compileTemplate($compiler);
vendor/twig/twig/lib/Twig/Node/Print.php CHANGED
@@ -22,11 +22,6 @@ class Twig_Node_Print extends Twig_Node implements Twig_NodeOutputInterface
22
  parent::__construct(array('expr' => $expr), array(), $lineno, $tag);
23
  }
24
 
25
- /**
26
- * Compiles the node to PHP.
27
- *
28
- * @param Twig_Compiler $compiler A Twig_Compiler instance
29
- */
30
  public function compile(Twig_Compiler $compiler)
31
  {
32
  $compiler
22
  parent::__construct(array('expr' => $expr), array(), $lineno, $tag);
23
  }
24
 
 
 
 
 
 
25
  public function compile(Twig_Compiler $compiler)
26
  {
27
  $compiler
vendor/twig/twig/lib/Twig/Node/Sandbox.php CHANGED
@@ -21,11 +21,6 @@ class Twig_Node_Sandbox extends Twig_Node
21
  parent::__construct(array('body' => $body), array(), $lineno, $tag);
22
  }
23
 
24
- /**
25
- * Compiles the node to PHP.
26
- *
27
- * @param Twig_Compiler $compiler A Twig_Compiler instance
28
- */
29
  public function compile(Twig_Compiler $compiler)
30
  {
31
  $compiler
21
  parent::__construct(array('body' => $body), array(), $lineno, $tag);
22
  }
23
 
 
 
 
 
 
24
  public function compile(Twig_Compiler $compiler)
25
  {
26
  $compiler
vendor/twig/twig/lib/Twig/Node/SandboxedPrint.php CHANGED
@@ -21,16 +21,6 @@
21
  */
22
  class Twig_Node_SandboxedPrint extends Twig_Node_Print
23
  {
24
- public function __construct(Twig_Node_Expression $expr, $lineno, $tag = null)
25
- {
26
- parent::__construct($expr, $lineno, $tag);
27
- }
28
-
29
- /**
30
- * Compiles the node to PHP.
31
- *
32
- * @param Twig_Compiler $compiler A Twig_Compiler instance
33
- */
34
  public function compile(Twig_Compiler $compiler)
35
  {
36
  $compiler
21
  */
22
  class Twig_Node_SandboxedPrint extends Twig_Node_Print
23
  {
 
 
 
 
 
 
 
 
 
 
24
  public function compile(Twig_Compiler $compiler)
25
  {
26
  $compiler
vendor/twig/twig/lib/Twig/Node/Set.php CHANGED
@@ -36,11 +36,6 @@ class Twig_Node_Set extends Twig_Node
36
  }
37
  }
38
 
39
- /**
40
- * Compiles the node to PHP.
41
- *
42
- * @param Twig_Compiler $compiler A Twig_Compiler instance
43
- */
44
  public function compile(Twig_Compiler $compiler)
45
  {
46
  $compiler->addDebugInfo($this);
36
  }
37
  }
38
 
 
 
 
 
 
39
  public function compile(Twig_Compiler $compiler)
40
  {
41
  $compiler->addDebugInfo($this);
vendor/twig/twig/lib/Twig/Node/Spaceless.php CHANGED
@@ -23,11 +23,6 @@ class Twig_Node_Spaceless extends Twig_Node
23
  parent::__construct(array('body' => $body), array(), $lineno, $tag);
24
  }
25
 
26
- /**
27
- * Compiles the node to PHP.
28
- *
29
- * @param Twig_Compiler $compiler A Twig_Compiler instance
30
- */
31
  public function compile(Twig_Compiler $compiler)
32
  {
33
  $compiler
23
  parent::__construct(array('body' => $body), array(), $lineno, $tag);
24
  }
25
 
 
 
 
 
 
26
  public function compile(Twig_Compiler $compiler)
27
  {
28
  $compiler
vendor/twig/twig/lib/Twig/Node/Text.php CHANGED
@@ -22,11 +22,6 @@ class Twig_Node_Text extends Twig_Node implements Twig_NodeOutputInterface
22
  parent::__construct(array(), array('data' => $data), $lineno);
23
  }
24
 
25
- /**
26
- * Compiles the node to PHP.
27
- *
28
- * @param Twig_Compiler $compiler A Twig_Compiler instance
29
- */
30
  public function compile(Twig_Compiler $compiler)
31
  {
32
  $compiler
22
  parent::__construct(array(), array('data' => $data), $lineno);
23
  }
24
 
 
 
 
 
 
25
  public function compile(Twig_Compiler $compiler)
26
  {
27
  $compiler
vendor/twig/twig/lib/Twig/Parser.php CHANGED
@@ -94,10 +94,8 @@ class Twig_Parser implements Twig_ParserInterface
94
  try {
95
  $body = $this->subparse($test, $dropNeedle);
96
 
97
- if (null !== $this->parent) {
98
- if (null === $body = $this->filterBodyNodes($body)) {
99
- $body = new Twig_Node();
100
- }
101
  }
102
  } catch (Twig_Error_Syntax $e) {
103
  if (!$e->getTemplateFile()) {
@@ -148,7 +146,7 @@ class Twig_Parser implements Twig_ParserInterface
148
  $token = $this->getCurrentToken();
149
 
150
  if ($token->getType() !== Twig_Token::NAME_TYPE) {
151
- throw new Twig_Error_Syntax('A block must start with a tag name', $token->getLine(), $this->getFilename());
152
  }
153
 
154
  if (null !== $test && call_user_func($test, $token)) {
@@ -166,20 +164,17 @@ class Twig_Parser implements Twig_ParserInterface
166
  $subparser = $this->handlers->getTokenParser($token->getValue());
167
  if (null === $subparser) {
168
  if (null !== $test) {
169
- $error = sprintf('Unexpected tag name "%s"', $token->getValue());
 
170
  if (is_array($test) && isset($test[0]) && $test[0] instanceof Twig_TokenParserInterface) {
171
- $error .= sprintf(' (expecting closing tag for the "%s" tag defined near line %s)', $test[0]->getTag(), $lineno);
172
  }
173
-
174
- throw new Twig_Error_Syntax($error, $token->getLine(), $this->getFilename());
175
- }
176
-
177
- $message = sprintf('Unknown tag name "%s"', $token->getValue());
178
- if ($alternatives = $this->env->computeAlternatives($token->getValue(), array_keys($this->env->getTags()))) {
179
- $message = sprintf('%s. Did you mean "%s"', $message, implode('", "', $alternatives));
180
  }
181
 
182
- throw new Twig_Error_Syntax($message, $token->getLine(), $this->getFilename());
183
  }
184
 
185
  $this->stream->next();
@@ -255,7 +250,7 @@ class Twig_Parser implements Twig_ParserInterface
255
  public function setMacro($name, Twig_Node_Macro $node)
256
  {
257
  if ($this->isReservedMacroName($name)) {
258
- throw new Twig_Error_Syntax(sprintf('"%s" cannot be used as a macro name as it is a reserved keyword', $name), $node->getLine(), $this->getFilename());
259
  }
260
 
261
  $this->macros[$name] = $node;
94
  try {
95
  $body = $this->subparse($test, $dropNeedle);
96
 
97
+ if (null !== $this->parent && null === $body = $this->filterBodyNodes($body)) {
98
+ $body = new Twig_Node();
 
 
99
  }
100
  } catch (Twig_Error_Syntax $e) {
101
  if (!$e->getTemplateFile()) {
146
  $token = $this->getCurrentToken();
147
 
148
  if ($token->getType() !== Twig_Token::NAME_TYPE) {
149
+ throw new Twig_Error_Syntax('A block must start with a tag name.', $token->getLine(), $this->getFilename());
150
  }
151
 
152
  if (null !== $test && call_user_func($test, $token)) {
164
  $subparser = $this->handlers->getTokenParser($token->getValue());
165
  if (null === $subparser) {
166
  if (null !== $test) {
167
+ $e = new Twig_Error_Syntax(sprintf('Unexpected "%s" tag', $token->getValue()), $token->getLine(), $this->getFilename());
168
+
169
  if (is_array($test) && isset($test[0]) && $test[0] instanceof Twig_TokenParserInterface) {
170
+ $e->appendMessage(sprintf(' (expecting closing tag for the "%s" tag defined near line %s).', $test[0]->getTag(), $lineno));
171
  }
172
+ } else {
173
+ $e = new Twig_Error_Syntax(sprintf('Unknown "%s" tag.', $token->getValue()), $token->getLine(), $this->getFilename());
174
+ $e->addSuggestions($token->getValue(), array_keys($this->env->getTags()));
 
 
 
 
175
  }
176
 
177
+ throw $e;
178
  }
179
 
180
  $this->stream->next();
250
  public function setMacro($name, Twig_Node_Macro $node)
251
  {
252
  if ($this->isReservedMacroName($name)) {
253
+ throw new Twig_Error_Syntax(sprintf('"%s" cannot be used as a macro name as it is a reserved keyword.', $name), $node->getLine(), $this->getFilename());
254
  }
255
 
256
  $this->macros[$name] = $node;
vendor/twig/twig/lib/Twig/Profiler/Profile.php CHANGED
@@ -86,6 +86,16 @@ class Twig_Profiler_Profile implements IteratorAggregate, Serializable
86
  */
87
  public function getDuration()
88
  {
 
 
 
 
 
 
 
 
 
 
89
  return isset($this->ends['wt']) && isset($this->starts['wt']) ? $this->ends['wt'] - $this->starts['wt'] : 0;
90
  }
91
 
86
  */
87
  public function getDuration()
88
  {
89
+ if ($this->isRoot() && $this->profiles) {
90
+ // for the root node with children, duration is the sum of all child durations
91
+ $duration = 0;
92
+ foreach ($this->profiles as $profile) {
93
+ $duration += $profile->getDuration();
94
+ }
95
+
96
+ return $duration;
97
+ }
98
+
99
  return isset($this->ends['wt']) && isset($this->starts['wt']) ? $this->ends['wt'] - $this->starts['wt'] : 0;
100
  }
101
 
vendor/twig/twig/lib/Twig/Template.php CHANGED
@@ -61,6 +61,8 @@ abstract class Twig_Template implements Twig_TemplateInterface
61
  * @param array $context
62
  *
63
  * @return Twig_TemplateInterface|false The parent template or false if there is no parent
 
 
64
  */
65
  public function getParent(array $context)
66
  {
@@ -111,6 +113,8 @@ abstract class Twig_Template implements Twig_TemplateInterface
111
  * @param string $name The block name to display from the parent
112
  * @param array $context The context
113
  * @param array $blocks The current set of blocks
 
 
114
  */
115
  public function displayParentBlock($name, array $context, array $blocks = array())
116
  {
@@ -135,6 +139,8 @@ abstract class Twig_Template implements Twig_TemplateInterface
135
  * @param array $context The context
136
  * @param array $blocks The current set of blocks
137
  * @param bool $useBlocks Whether to use the current set of blocks
 
 
138
  */
139
  public function displayBlock($name, array $context, array $blocks = array(), $useBlocks = true)
140
  {
@@ -191,6 +197,8 @@ abstract class Twig_Template implements Twig_TemplateInterface
191
  * @param array $blocks The current set of blocks
192
  *
193
  * @return string The rendered block
 
 
194
  */
195
  public function renderParentBlock($name, array $context, array $blocks = array())
196
  {
@@ -212,6 +220,8 @@ abstract class Twig_Template implements Twig_TemplateInterface
212
  * @param bool $useBlocks Whether to use the current set of blocks
213
  *
214
  * @return string The rendered block
 
 
215
  */
216
  public function renderBlock($name, array $context, array $blocks = array(), $useBlocks = true)
217
  {
@@ -237,6 +247,8 @@ abstract class Twig_Template implements Twig_TemplateInterface
237
  * @param string $name The block name
238
  *
239
  * @return bool true if the block exists, false otherwise
 
 
240
  */
241
  public function hasBlock($name)
242
  {
@@ -252,6 +264,8 @@ abstract class Twig_Template implements Twig_TemplateInterface
252
  * @return array An array of block names
253
  *
254
  * @see hasBlock
 
 
255
  */
256
  public function getBlockNames()
257
  {
@@ -298,12 +312,41 @@ abstract class Twig_Template implements Twig_TemplateInterface
298
  * @return array An array of blocks
299
  *
300
  * @see hasBlock
 
 
301
  */
302
  public function getBlocks()
303
  {
304
  return $this->blocks;
305
  }
306
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
307
  /**
308
  * {@inheritdoc}
309
  */
@@ -380,6 +423,8 @@ abstract class Twig_Template implements Twig_TemplateInterface
380
  * @return mixed The content of the context variable
381
  *
382
  * @throws Twig_Error_Runtime if the variable does not exist and Twig is running in strict mode
 
 
383
  */
384
  final protected function getContext($context, $item, $ignoreStrictCheck = false)
385
  {
61
  * @param array $context
62
  *
63
  * @return Twig_TemplateInterface|false The parent template or false if there is no parent
64
+ *
65
+ * @internal
66
  */
67
  public function getParent(array $context)
68
  {
113
  * @param string $name The block name to display from the parent
114
  * @param array $context The context
115
  * @param array $blocks The current set of blocks
116
+ *
117
+ * @internal
118
  */
119
  public function displayParentBlock($name, array $context, array $blocks = array())
120
  {
139
  * @param array $context The context
140
  * @param array $blocks The current set of blocks
141
  * @param bool $useBlocks Whether to use the current set of blocks
142
+ *
143
+ * @internal
144
  */
145
  public function displayBlock($name, array $context, array $blocks = array(), $useBlocks = true)
146
  {
197
  * @param array $blocks The current set of blocks
198
  *
199
  * @return string The rendered block
200
+ *
201
+ * @internal
202
  */
203
  public function renderParentBlock($name, array $context, array $blocks = array())
204
  {
220
  * @param bool $useBlocks Whether to use the current set of blocks
221
  *
222
  * @return string The rendered block
223
+ *
224
+ * @internal
225
  */
226
  public function renderBlock($name, array $context, array $blocks = array(), $useBlocks = true)
227
  {
247
  * @param string $name The block name
248
  *
249
  * @return bool true if the block exists, false otherwise
250
+ *
251
+ * @internal
252
  */
253
  public function hasBlock($name)
254
  {
264
  * @return array An array of block names
265
  *
266
  * @see hasBlock
267
+ *
268
+ * @internal
269
  */
270
  public function getBlockNames()
271
  {
312
  * @return array An array of blocks
313
  *
314
  * @see hasBlock
315
+ *
316
+ * @internal
317
  */
318
  public function getBlocks()
319
  {
320
  return $this->blocks;
321
  }
322
 
323
+ /**
324
+ * Returns the template source code.
325
+ *
326
+ * @return string|null The template source code or null if it is not available
327
+ */
328
+ public function getSource()
329
+ {
330
+ $reflector = new ReflectionClass($this);
331
+ $file = $reflector->getFileName();
332
+
333
+ if (!file_exists($file)) {
334
+ return;
335
+ }
336
+
337
+ $source = file($file, FILE_IGNORE_NEW_LINES);
338
+ array_splice($source, 0, $reflector->getEndLine());
339
+
340
+ $i = 0;
341
+ while (isset($source[$i]) && '/* */' === substr_replace($source[$i], '', 3, -2)) {
342
+ $source[$i] = str_replace('*//* ', '*/', substr($source[$i], 3, -2));
343
+ ++$i;
344
+ }
345
+ array_splice($source, $i);
346
+
347
+ return implode("\n", $source);
348
+ }
349
+
350
  /**
351
  * {@inheritdoc}
352
  */
423
  * @return mixed The content of the context variable
424
  *
425
  * @throws Twig_Error_Runtime if the variable does not exist and Twig is running in strict mode
426
+ *
427
+ * @internal
428
  */
429
  final protected function getContext($context, $item, $ignoreStrictCheck = false)
430
  {
vendor/twig/twig/lib/Twig/Test/IntegrationTestCase.php CHANGED
@@ -17,9 +17,43 @@
17
  */
18
  abstract class Twig_Test_IntegrationTestCase extends PHPUnit_Framework_TestCase
19
  {
20
- abstract protected function getExtensions();
 
 
21
  abstract protected function getFixturesDir();
22
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  /**
24
  * @dataProvider getTests
25
  */
@@ -34,7 +68,7 @@ abstract class Twig_Test_IntegrationTestCase extends PHPUnit_Framework_TestCase
34
  */
35
  public function testLegacyIntegration($file, $message, $condition, $templates, $exception, $outputs)
36
  {
37
- $this->testIntegration($file, $message, $condition, $templates, $exception, $outputs);
38
  }
39
 
40
  public function getTests($name, $legacyTests = false)
@@ -56,13 +90,13 @@ abstract class Twig_Test_IntegrationTestCase extends PHPUnit_Framework_TestCase
56
  if (preg_match('/--TEST--\s*(.*?)\s*(?:--CONDITION--\s*(.*))?\s*((?:--TEMPLATE(?:\(.*?\))?--(?:.*?))+)\s*(?:--DATA--\s*(.*))?\s*--EXCEPTION--\s*(.*)/sx', $test, $match)) {
57
  $message = $match[1];
58
  $condition = $match[2];
59
- $templates = $this->parseTemplates($match[3]);
60
  $exception = $match[5];
61
  $outputs = array(array(null, $match[4], null, ''));
62
  } elseif (preg_match('/--TEST--\s*(.*?)\s*(?:--CONDITION--\s*(.*))?\s*((?:--TEMPLATE(?:\(.*?\))?--(?:.*?))+)--DATA--.*?--EXPECT--.*/s', $test, $match)) {
63
  $message = $match[1];
64
  $condition = $match[2];
65
- $templates = $this->parseTemplates($match[3]);
66
  $exception = false;
67
  preg_match_all('/--DATA--(.*?)(?:--CONFIG--(.*?))?--EXPECT--(.*?)(?=\-\-DATA\-\-|$)/s', $test, $outputs, PREG_SET_ORDER);
68
  } else {
@@ -72,7 +106,7 @@ abstract class Twig_Test_IntegrationTestCase extends PHPUnit_Framework_TestCase
72
  $tests[] = array(str_replace($fixturesDir.'/', '', $file), $message, $condition, $templates, $exception, $outputs);
73
  }
74
 
75
- if (!$tests) {
76
  // add a dummy test to avoid a PHPUnit message
77
  return array(array('not', '-', '', array(), '', array()));
78
  }
@@ -107,6 +141,18 @@ abstract class Twig_Test_IntegrationTestCase extends PHPUnit_Framework_TestCase
107
  $twig->addExtension($extension);
108
  }
109
 
 
 
 
 
 
 
 
 
 
 
 
 
110
  // avoid using the same PHP class name for different cases
111
  // only for PHP 5.2+
112
  if (PHP_VERSION_ID >= 50300) {
@@ -119,7 +165,9 @@ abstract class Twig_Test_IntegrationTestCase extends PHPUnit_Framework_TestCase
119
  $template = $twig->loadTemplate('index.twig');
120
  } catch (Exception $e) {
121
  if (false !== $exception) {
122
- $this->assertEquals(trim($exception), trim(sprintf('%s: %s', get_class($e), $e->getMessage())));
 
 
123
 
124
  return;
125
  }
@@ -137,7 +185,7 @@ abstract class Twig_Test_IntegrationTestCase extends PHPUnit_Framework_TestCase
137
  $output = trim($template->render(eval($match[1].';')), "\n ");
138
  } catch (Exception $e) {
139
  if (false !== $exception) {
140
- $this->assertEquals(trim($exception), trim(sprintf('%s: %s', get_class($e), $e->getMessage())));
141
 
142
  return;
143
  }
@@ -158,7 +206,7 @@ abstract class Twig_Test_IntegrationTestCase extends PHPUnit_Framework_TestCase
158
 
159
  $expected = trim($match[3], "\n ");
160
 
161
- if ($expected != $output) {
162
  printf("Compiled templates that failed on case %d:\n", $i + 1);
163
 
164
  foreach (array_keys($templates) as $name) {
17
  */
18
  abstract class Twig_Test_IntegrationTestCase extends PHPUnit_Framework_TestCase
19
  {
20
+ /**
21
+ * @return string
22
+ */
23
  abstract protected function getFixturesDir();
24
 
25
+ /**
26
+ * @return Twig_ExtensionInterface[]
27
+ */
28
+ protected function getExtensions()
29
+ {
30
+ return array();
31
+ }
32
+
33
+ /**
34
+ * @return Twig_SimpleFilter[]
35
+ */
36
+ protected function getTwigFilters()
37
+ {
38
+ return array();
39
+ }
40
+
41
+ /**
42
+ * @return Twig_SimpleFunction[]
43
+ */
44
+ protected function getTwigFunctions()
45
+ {
46
+ return array();
47
+ }
48
+
49
+ /**
50
+ * @return Twig_SimpleTest[]
51
+ */
52
+ protected function getTwigTests()
53
+ {
54
+ return array();
55
+ }
56
+
57
  /**
58
  * @dataProvider getTests
59
  */
68
  */
69
  public function testLegacyIntegration($file, $message, $condition, $templates, $exception, $outputs)
70
  {
71
+ $this->doIntegrationTest($file, $message, $condition, $templates, $exception, $outputs);
72
  }
73
 
74
  public function getTests($name, $legacyTests = false)
90
  if (preg_match('/--TEST--\s*(.*?)\s*(?:--CONDITION--\s*(.*))?\s*((?:--TEMPLATE(?:\(.*?\))?--(?:.*?))+)\s*(?:--DATA--\s*(.*))?\s*--EXCEPTION--\s*(.*)/sx', $test, $match)) {
91
  $message = $match[1];
92
  $condition = $match[2];
93
+ $templates = self::parseTemplates($match[3]);
94
  $exception = $match[5];
95
  $outputs = array(array(null, $match[4], null, ''));
96
  } elseif (preg_match('/--TEST--\s*(.*?)\s*(?:--CONDITION--\s*(.*))?\s*((?:--TEMPLATE(?:\(.*?\))?--(?:.*?))+)--DATA--.*?--EXPECT--.*/s', $test, $match)) {
97
  $message = $match[1];
98
  $condition = $match[2];
99
+ $templates = self::parseTemplates($match[3]);
100
  $exception = false;
101
  preg_match_all('/--DATA--(.*?)(?:--CONFIG--(.*?))?--EXPECT--(.*?)(?=\-\-DATA\-\-|$)/s', $test, $outputs, PREG_SET_ORDER);
102
  } else {
106
  $tests[] = array(str_replace($fixturesDir.'/', '', $file), $message, $condition, $templates, $exception, $outputs);
107
  }
108
 
109
+ if ($legacyTests && empty($tests)) {
110
  // add a dummy test to avoid a PHPUnit message
111
  return array(array('not', '-', '', array(), '', array()));
112
  }
141
  $twig->addExtension($extension);
142
  }
143
 
144
+ foreach ($this->getTwigFilters() as $filter) {
145
+ $twig->addFilter($filter);
146
+ }
147
+
148
+ foreach ($this->getTwigTests() as $test) {
149
+ $twig->addTest($test);
150
+ }
151
+
152
+ foreach ($this->getTwigFunctions() as $function) {
153
+ $twig->addFunction($function);
154
+ }
155
+
156
  // avoid using the same PHP class name for different cases
157
  // only for PHP 5.2+
158
  if (PHP_VERSION_ID >= 50300) {
165
  $template = $twig->loadTemplate('index.twig');
166
  } catch (Exception $e) {
167
  if (false !== $exception) {
168
+ $message = $e->getMessage();
169
+ $this->assertSame(trim($exception), trim(sprintf('%s: %s', get_class($e), $message)));
170
+ $this->assertSame('.', substr($message, strlen($message) - 1), $message, 'Exception message must end with a dot.');
171
 
172
  return;
173
  }
185
  $output = trim($template->render(eval($match[1].';')), "\n ");
186
  } catch (Exception $e) {
187
  if (false !== $exception) {
188
+ $this->assertSame(trim($exception), trim(sprintf('%s: %s', get_class($e), $e->getMessage())));
189
 
190
  return;
191
  }
206
 
207
  $expected = trim($match[3], "\n ");
208
 
209
+ if ($expected !== $output) {
210
  printf("Compiled templates that failed on case %d:\n", $i + 1);
211
 
212
  foreach (array_keys($templates) as $name) {
vendor/twig/twig/lib/Twig/Test/NodeTestCase.php CHANGED
@@ -15,17 +15,21 @@ abstract class Twig_Test_NodeTestCase extends PHPUnit_Framework_TestCase
15
  /**
16
  * @dataProvider getTests
17
  */
18
- public function testCompile($node, $source, $environment = null)
19
  {
20
- $this->assertNodeCompilation($source, $node, $environment);
21
  }
22
 
23
- public function assertNodeCompilation($source, Twig_Node $node, Twig_Environment $environment = null)
24
  {
25
  $compiler = $this->getCompiler($environment);
26
  $compiler->compile($node);
27
 
28
- $this->assertEquals($source, trim($compiler->getSource()));
 
 
 
 
29
  }
30
 
31
  protected function getCompiler(Twig_Environment $environment = null)
15
  /**
16
  * @dataProvider getTests
17
  */
18
+ public function testCompile($node, $source, $environment = null, $isPattern = false)
19
  {
20
+ $this->assertNodeCompilation($source, $node, $environment, $isPattern);
21
  }
22
 
23
+ public function assertNodeCompilation($source, Twig_Node $node, Twig_Environment $environment = null, $isPattern = false)
24
  {
25
  $compiler = $this->getCompiler($environment);
26
  $compiler->compile($node);
27
 
28
+ if ($isPattern) {
29
+ $this->assertStringMatchesFormat($source, trim($compiler->getSource()));
30
+ } else {
31
+ $this->assertEquals($source, trim($compiler->getSource()));
32
+ }
33
  }
34
 
35
  protected function getCompiler(Twig_Environment $environment = null)
vendor/twig/twig/lib/Twig/TokenParser/AutoEscape.php CHANGED
@@ -29,13 +29,6 @@
29
  */
30
  class Twig_TokenParser_AutoEscape extends Twig_TokenParser
31
  {
32
- /**
33
- * Parses a token and returns a node.
34
- *
35
- * @param Twig_Token $token A Twig_Token instance
36
- *
37
- * @return Twig_NodeInterface A Twig_NodeInterface instance
38
- */
39
  public function parse(Twig_Token $token)
40
  {
41
  $lineno = $token->getLine();
@@ -46,7 +39,7 @@ class Twig_TokenParser_AutoEscape extends Twig_TokenParser
46
  } else {
47
  $expr = $this->parser->getExpressionParser()->parseExpression();
48
  if (!$expr instanceof Twig_Node_Expression_Constant) {
49
- throw new Twig_Error_Syntax('An escaping strategy must be a string or a Boolean.', $stream->getCurrent()->getLine(), $stream->getFilename());
50
  }
51
  $value = $expr->getAttribute('value');
52
 
@@ -79,11 +72,6 @@ class Twig_TokenParser_AutoEscape extends Twig_TokenParser
79
  return $token->test('endautoescape');
80
  }
81
 
82
- /**
83
- * Gets the tag name associated with this token parser.
84
- *
85
- * @return string The tag name
86
- */
87
  public function getTag()
88
  {
89
  return 'autoescape';
29
  */
30
  class Twig_TokenParser_AutoEscape extends Twig_TokenParser
31
  {
 
 
 
 
 
 
 
32
  public function parse(Twig_Token $token)
33
  {
34
  $lineno = $token->getLine();
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->getFilename());
43
  }
44
  $value = $expr->getAttribute('value');
45
 
72
  return $token->test('endautoescape');
73
  }
74
 
 
 
 
 
 
75
  public function getTag()
76
  {
77
  return 'autoescape';
vendor/twig/twig/lib/Twig/TokenParser/Block.php CHANGED
@@ -22,20 +22,13 @@
22
  */
23
  class Twig_TokenParser_Block extends Twig_TokenParser
24
  {
25
- /**
26
- * Parses a token and returns a node.
27
- *
28
- * @param Twig_Token $token A Twig_Token instance
29
- *
30
- * @return Twig_NodeInterface A Twig_NodeInterface instance
31
- */
32
  public function parse(Twig_Token $token)
33
  {
34
  $lineno = $token->getLine();
35
  $stream = $this->parser->getStream();
36
  $name = $stream->expect(Twig_Token::NAME_TYPE)->getValue();
37
  if ($this->parser->hasBlock($name)) {
38
- throw new Twig_Error_Syntax(sprintf("The block '$name' has already been defined line %d", $this->parser->getBlock($name)->getLine()), $stream->getCurrent()->getLine(), $stream->getFilename());
39
  }
40
  $this->parser->setBlock($name, $block = new Twig_Node_Block($name, new Twig_Node(array()), $lineno));
41
  $this->parser->pushLocalScope();
@@ -47,7 +40,7 @@ class Twig_TokenParser_Block extends Twig_TokenParser
47
  $value = $token->getValue();
48
 
49
  if ($value != $name) {
50
- throw new Twig_Error_Syntax(sprintf('Expected endblock for block "%s" (but "%s" given)', $name, $value), $stream->getCurrent()->getLine(), $stream->getFilename());
51
  }
52
  }
53
  } else {
@@ -69,11 +62,6 @@ class Twig_TokenParser_Block extends Twig_TokenParser
69
  return $token->test('endblock');
70
  }
71
 
72
- /**
73
- * Gets the tag name associated with this token parser.
74
- *
75
- * @return string The tag name
76
- */
77
  public function getTag()
78
  {
79
  return 'block';
22
  */
23
  class Twig_TokenParser_Block extends Twig_TokenParser
24
  {
 
 
 
 
 
 
 
25
  public function parse(Twig_Token $token)
26
  {
27
  $lineno = $token->getLine();
28
  $stream = $this->parser->getStream();
29
  $name = $stream->expect(Twig_Token::NAME_TYPE)->getValue();
30
  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)->getLine()), $stream->getCurrent()->getLine(), $stream->getFilename());
32
  }
33
  $this->parser->setBlock($name, $block = new Twig_Node_Block($name, new Twig_Node(array()), $lineno));
34
  $this->parser->pushLocalScope();
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->getFilename());
44
  }
45
  }
46
  } else {
62
  return $token->test('endblock');
63
  }
64
 
 
 
 
 
 
65
  public function getTag()
66
  {
67
  return 'block';
vendor/twig/twig/lib/Twig/TokenParser/Do.php CHANGED
@@ -14,13 +14,6 @@
14
  */
15
  class Twig_TokenParser_Do extends Twig_TokenParser
16
  {
17
- /**
18
- * Parses a token and returns a node.
19
- *
20
- * @param Twig_Token $token A Twig_Token instance
21
- *
22
- * @return Twig_NodeInterface A Twig_NodeInterface instance
23
- */
24
  public function parse(Twig_Token $token)
25
  {
26
  $expr = $this->parser->getExpressionParser()->parseExpression();
@@ -30,11 +23,6 @@ class Twig_TokenParser_Do extends Twig_TokenParser
30
  return new Twig_Node_Do($expr, $token->getLine(), $this->getTag());
31
  }
32
 
33
- /**
34
- * Gets the tag name associated with this token parser.
35
- *
36
- * @return string The tag name
37
- */
38
  public function getTag()
39
  {
40
  return 'do';
14
  */
15
  class Twig_TokenParser_Do extends Twig_TokenParser
16
  {
 
 
 
 
 
 
 
17
  public function parse(Twig_Token $token)
18
  {
19
  $expr = $this->parser->getExpressionParser()->parseExpression();
23
  return new Twig_Node_Do($expr, $token->getLine(), $this->getTag());
24
  }
25
 
 
 
 
 
 
26
  public function getTag()
27
  {
28
  return 'do';
vendor/twig/twig/lib/Twig/TokenParser/Embed.php CHANGED
@@ -14,13 +14,6 @@
14
  */
15
  class Twig_TokenParser_Embed extends Twig_TokenParser_Include
16
  {
17
- /**
18
- * Parses a token and returns a node.
19
- *
20
- * @param Twig_Token $token A Twig_Token instance
21
- *
22
- * @return Twig_NodeInterface A Twig_NodeInterface instance
23
- */
24
  public function parse(Twig_Token $token)
25
  {
26
  $stream = $this->parser->getStream();
@@ -54,11 +47,6 @@ class Twig_TokenParser_Embed extends Twig_TokenParser_Include
54
  return $token->test('endembed');
55
  }
56
 
57
- /**
58
- * Gets the tag name associated with this token parser.
59
- *
60
- * @return string The tag name
61
- */
62
  public function getTag()
63
  {
64
  return 'embed';
14
  */
15
  class Twig_TokenParser_Embed extends Twig_TokenParser_Include
16
  {
 
 
 
 
 
 
 
17
  public function parse(Twig_Token $token)
18
  {
19
  $stream = $this->parser->getStream();
47
  return $token->test('endembed');
48
  }
49
 
 
 
 
 
 
50
  public function getTag()
51
  {
52
  return 'embed';
vendor/twig/twig/lib/Twig/TokenParser/Extends.php CHANGED
@@ -19,32 +19,20 @@
19
  */
20
  class Twig_TokenParser_Extends extends Twig_TokenParser
21
  {
22
- /**
23
- * Parses a token and returns a node.
24
- *
25
- * @param Twig_Token $token A Twig_Token instance
26
- *
27
- * @return Twig_NodeInterface A Twig_NodeInterface instance
28
- */
29
  public function parse(Twig_Token $token)
30
  {
31
  if (!$this->parser->isMainScope()) {
32
- throw new Twig_Error_Syntax('Cannot extend from a block', $token->getLine(), $this->parser->getFilename());
33
  }
34
 
35
  if (null !== $this->parser->getParent()) {
36
- throw new Twig_Error_Syntax('Multiple extends tags are forbidden', $token->getLine(), $this->parser->getFilename());
37
  }
38
  $this->parser->setParent($this->parser->getExpressionParser()->parseExpression());
39
 
40
  $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
41
  }
42
 
43
- /**
44
- * Gets the tag name associated with this token parser.
45
- *
46
- * @return string The tag name
47
- */
48
  public function getTag()
49
  {
50
  return 'extends';
19
  */
20
  class Twig_TokenParser_Extends extends Twig_TokenParser
21
  {
 
 
 
 
 
 
 
22
  public function parse(Twig_Token $token)
23
  {
24
  if (!$this->parser->isMainScope()) {
25
+ throw new Twig_Error_Syntax('Cannot extend from a block.', $token->getLine(), $this->parser->getFilename());
26
  }
27
 
28
  if (null !== $this->parser->getParent()) {
29
+ throw new Twig_Error_Syntax('Multiple extends tags are forbidden.', $token->getLine(), $this->parser->getFilename());
30
  }
31
  $this->parser->setParent($this->parser->getExpressionParser()->parseExpression());
32
 
33
  $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
34
  }
35
 
 
 
 
 
 
36
  public function getTag()
37
  {
38
  return 'extends';
vendor/twig/twig/lib/Twig/TokenParser/Filter.php CHANGED
@@ -20,13 +20,6 @@
20
  */
21
  class Twig_TokenParser_Filter extends Twig_TokenParser
22
  {
23
- /**
24
- * Parses a token and returns a node.
25
- *
26
- * @param Twig_Token $token A Twig_Token instance
27
- *
28
- * @return Twig_NodeInterface A Twig_NodeInterface instance
29
- */
30
  public function parse(Twig_Token $token)
31
  {
32
  $name = $this->parser->getVarName();
@@ -49,11 +42,6 @@ class Twig_TokenParser_Filter extends Twig_TokenParser
49
  return $token->test('endfilter');
50
  }
51
 
52
- /**
53
- * Gets the tag name associated with this token parser.
54
- *
55
- * @return string The tag name
56
- */
57
  public function getTag()
58
  {
59
  return 'filter';
20
  */
21
  class Twig_TokenParser_Filter extends Twig_TokenParser
22
  {
 
 
 
 
 
 
 
23
  public function parse(Twig_Token $token)
24
  {
25
  $name = $this->parser->getVarName();
42
  return $token->test('endfilter');
43
  }
44
 
 
 
 
 
 
45
  public function getTag()
46
  {
47
  return 'filter';
vendor/twig/twig/lib/Twig/TokenParser/Flush.php CHANGED
@@ -16,13 +16,6 @@
16
  */
17
  class Twig_TokenParser_Flush extends Twig_TokenParser
18
  {
19
- /**
20
- * Parses a token and returns a node.
21
- *
22
- * @param Twig_Token $token A Twig_Token instance
23
- *
24
- * @return Twig_NodeInterface A Twig_NodeInterface instance
25
- */
26
  public function parse(Twig_Token $token)
27
  {
28
  $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
@@ -30,11 +23,6 @@ class Twig_TokenParser_Flush extends Twig_TokenParser
30
  return new Twig_Node_Flush($token->getLine(), $this->getTag());
31
  }
32
 
33
- /**
34
- * Gets the tag name associated with this token parser.
35
- *
36
- * @return string The tag name
37
- */
38
  public function getTag()
39
  {
40
  return 'flush';
16
  */
17
  class Twig_TokenParser_Flush extends Twig_TokenParser
18
  {
 
 
 
 
 
 
 
19
  public function parse(Twig_Token $token)
20
  {
21
  $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
23
  return new Twig_Node_Flush($token->getLine(), $this->getTag());
24
  }
25
 
 
 
 
 
 
26
  public function getTag()
27
  {
28
  return 'flush';
vendor/twig/twig/lib/Twig/TokenParser/For.php CHANGED
@@ -23,13 +23,6 @@
23
  */
24
  class Twig_TokenParser_For extends Twig_TokenParser
25
  {
26
- /**
27
- * Parses a token and returns a node.
28
- *
29
- * @param Twig_Token $token A Twig_Token instance
30
- *
31
- * @return Twig_NodeInterface A Twig_NodeInterface instance
32
- */
33
  public function parse(Twig_Token $token)
34
  {
35
  $lineno = $token->getLine();
@@ -86,7 +79,7 @@ class Twig_TokenParser_For extends Twig_TokenParser
86
  protected function checkLoopUsageCondition(Twig_TokenStream $stream, Twig_NodeInterface $node)
87
  {
88
  if ($node instanceof Twig_Node_Expression_GetAttr && $node->getNode('node') instanceof Twig_Node_Expression_Name && 'loop' == $node->getNode('node')->getAttribute('name')) {
89
- throw new Twig_Error_Syntax('The "loop" variable cannot be used in a looping condition', $node->getLine(), $stream->getFilename());
90
  }
91
 
92
  foreach ($node as $n) {
@@ -105,7 +98,7 @@ class Twig_TokenParser_For extends Twig_TokenParser
105
  if ($node instanceof Twig_Node_Expression_GetAttr && $node->getNode('node') instanceof Twig_Node_Expression_Name && 'loop' == $node->getNode('node')->getAttribute('name')) {
106
  $attribute = $node->getNode('attribute');
107
  if ($attribute instanceof Twig_Node_Expression_Constant && in_array($attribute->getAttribute('value'), array('length', 'revindex0', 'revindex', 'last'))) {
108
- throw new Twig_Error_Syntax(sprintf('The "loop.%s" variable is not defined when looping with a condition', $attribute->getAttribute('value')), $node->getLine(), $stream->getFilename());
109
  }
110
  }
111
 
@@ -123,11 +116,6 @@ class Twig_TokenParser_For extends Twig_TokenParser
123
  }
124
  }
125
 
126
- /**
127
- * Gets the tag name associated with this token parser.
128
- *
129
- * @return string The tag name
130
- */
131
  public function getTag()
132
  {
133
  return 'for';
23
  */
24
  class Twig_TokenParser_For extends Twig_TokenParser
25
  {
 
 
 
 
 
 
 
26
  public function parse(Twig_Token $token)
27
  {
28
  $lineno = $token->getLine();
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->getLine(), $stream->getFilename());
83
  }
84
 
85
  foreach ($node as $n) {
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->getLine(), $stream->getFilename());
102
  }
103
  }
104
 
116
  }
117
  }
118
 
 
 
 
 
 
119
  public function getTag()
120
  {
121
  return 'for';
vendor/twig/twig/lib/Twig/TokenParser/From.php CHANGED
@@ -18,13 +18,6 @@
18
  */
19
  class Twig_TokenParser_From extends Twig_TokenParser
20
  {
21
- /**
22
- * Parses a token and returns a node.
23
- *
24
- * @param Twig_Token $token A Twig_Token instance
25
- *
26
- * @return Twig_NodeInterface A Twig_NodeInterface instance
27
- */
28
  public function parse(Twig_Token $token)
29
  {
30
  $macro = $this->parser->getExpressionParser()->parseExpression();
@@ -53,7 +46,7 @@ class Twig_TokenParser_From extends Twig_TokenParser
53
 
54
  foreach ($targets as $name => $alias) {
55
  if ($this->parser->isReservedMacroName($name)) {
56
- throw new Twig_Error_Syntax(sprintf('"%s" cannot be an imported macro as it is a reserved keyword', $name), $token->getLine(), $stream->getFilename());
57
  }
58
 
59
  $this->parser->addImportedSymbol('function', $alias, 'get'.$name, $node->getNode('var'));
@@ -62,11 +55,6 @@ class Twig_TokenParser_From extends Twig_TokenParser
62
  return $node;
63
  }
64
 
65
- /**
66
- * Gets the tag name associated with this token parser.
67
- *
68
- * @return string The tag name
69
- */
70
  public function getTag()
71
  {
72
  return 'from';
18
  */
19
  class Twig_TokenParser_From extends Twig_TokenParser
20
  {
 
 
 
 
 
 
 
21
  public function parse(Twig_Token $token)
22
  {
23
  $macro = $this->parser->getExpressionParser()->parseExpression();
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->getFilename());
50
  }
51
 
52
  $this->parser->addImportedSymbol('function', $alias, 'get'.$name, $node->getNode('var'));
55
  return $node;
56
  }
57
 
 
 
 
 
 
58
  public function getTag()
59
  {
60
  return 'from';
vendor/twig/twig/lib/Twig/TokenParser/If.php CHANGED
@@ -25,13 +25,6 @@
25
  */
26
  class Twig_TokenParser_If extends Twig_TokenParser
27
  {
28
- /**
29
- * Parses a token and returns a node.
30
- *
31
- * @param Twig_Token $token A Twig_Token instance
32
- *
33
- * @return Twig_NodeInterface A Twig_NodeInterface instance
34
- */
35
  public function parse(Twig_Token $token)
36
  {
37
  $lineno = $token->getLine();
@@ -63,7 +56,7 @@ class Twig_TokenParser_If extends Twig_TokenParser
63
  break;
64
 
65
  default:
66
- 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->getFilename());
67
  }
68
  }
69
 
@@ -82,11 +75,6 @@ class Twig_TokenParser_If extends Twig_TokenParser
82
  return $token->test(array('endif'));
83
  }
84
 
85
- /**
86
- * Gets the tag name associated with this token parser.
87
- *
88
- * @return string The tag name
89
- */
90
  public function getTag()
91
  {
92
  return 'if';
25
  */
26
  class Twig_TokenParser_If extends Twig_TokenParser
27
  {
 
 
 
 
 
 
 
28
  public function parse(Twig_Token $token)
29
  {
30
  $lineno = $token->getLine();
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->getFilename());
60
  }
61
  }
62
 
75
  return $token->test(array('endif'));
76
  }
77
 
 
 
 
 
 
78
  public function getTag()
79
  {
80
  return 'if';
vendor/twig/twig/lib/Twig/TokenParser/Import.php CHANGED
@@ -18,13 +18,6 @@
18
  */
19
  class Twig_TokenParser_Import extends Twig_TokenParser
20
  {
21
- /**
22
- * Parses a token and returns a node.
23
- *
24
- * @param Twig_Token $token A Twig_Token instance
25
- *
26
- * @return Twig_NodeInterface A Twig_NodeInterface instance
27
- */
28
  public function parse(Twig_Token $token)
29
  {
30
  $macro = $this->parser->getExpressionParser()->parseExpression();
@@ -37,11 +30,6 @@ class Twig_TokenParser_Import extends Twig_TokenParser
37
  return new Twig_Node_Import($macro, $var, $token->getLine(), $this->getTag());
38
  }
39
 
40
- /**
41
- * Gets the tag name associated with this token parser.
42
- *
43
- * @return string The tag name
44
- */
45
  public function getTag()
46
  {
47
  return 'import';
18
  */
19
  class Twig_TokenParser_Import extends Twig_TokenParser
20
  {
 
 
 
 
 
 
 
21
  public function parse(Twig_Token $token)
22
  {
23
  $macro = $this->parser->getExpressionParser()->parseExpression();
30
  return new Twig_Node_Import($macro, $var, $token->getLine(), $this->getTag());
31
  }
32
 
 
 
 
 
 
33
  public function getTag()
34
  {
35
  return 'import';
vendor/twig/twig/lib/Twig/TokenParser/Include.php CHANGED
@@ -21,13 +21,6 @@
21
  */
22
  class Twig_TokenParser_Include extends Twig_TokenParser
23
  {
24
- /**
25
- * Parses a token and returns a node.
26
- *
27
- * @param Twig_Token $token A Twig_Token instance
28
- *
29
- * @return Twig_NodeInterface A Twig_NodeInterface instance
30
- */
31
  public function parse(Twig_Token $token)
32
  {
33
  $expr = $this->parser->getExpressionParser()->parseExpression();
@@ -63,11 +56,6 @@ class Twig_TokenParser_Include extends Twig_TokenParser
63
  return array($variables, $only, $ignoreMissing);
64
  }
65
 
66
- /**
67
- * Gets the tag name associated with this token parser.
68
- *
69
- * @return string The tag name
70
- */
71
  public function getTag()
72
  {
73
  return 'include';
21
  */
22
  class Twig_TokenParser_Include extends Twig_TokenParser
23
  {
 
 
 
 
 
 
 
24
  public function parse(Twig_Token $token)
25
  {
26
  $expr = $this->parser->getExpressionParser()->parseExpression();
56
  return array($variables, $only, $ignoreMissing);
57
  }
58
 
 
 
 
 
 
59
  public function getTag()
60
  {
61
  return 'include';
vendor/twig/twig/lib/Twig/TokenParser/Macro.php CHANGED
@@ -20,13 +20,6 @@
20
  */
21
  class Twig_TokenParser_Macro extends Twig_TokenParser
22
  {
23
- /**
24
- * Parses a token and returns a node.
25
- *
26
- * @param Twig_Token $token A Twig_Token instance
27
- *
28
- * @return Twig_NodeInterface A Twig_NodeInterface instance
29
- */
30
  public function parse(Twig_Token $token)
31
  {
32
  $lineno = $token->getLine();
@@ -42,7 +35,7 @@ class Twig_TokenParser_Macro extends Twig_TokenParser
42
  $value = $token->getValue();
43
 
44
  if ($value != $name) {
45
- throw new Twig_Error_Syntax(sprintf('Expected endmacro for macro "%s" (but "%s" given)', $name, $value), $stream->getCurrent()->getLine(), $stream->getFilename());
46
  }
47
  }
48
  $this->parser->popLocalScope();
@@ -56,11 +49,6 @@ class Twig_TokenParser_Macro extends Twig_TokenParser
56
  return $token->test('endmacro');
57
  }
58
 
59
- /**
60
- * Gets the tag name associated with this token parser.
61
- *
62
- * @return string The tag name
63
- */
64
  public function getTag()
65
  {
66
  return 'macro';
20
  */
21
  class Twig_TokenParser_Macro extends Twig_TokenParser
22
  {
 
 
 
 
 
 
 
23
  public function parse(Twig_Token $token)
24
  {
25
  $lineno = $token->getLine();
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->getFilename());
39
  }
40
  }
41
  $this->parser->popLocalScope();
49
  return $token->test('endmacro');
50
  }
51
 
 
 
 
 
 
52
  public function getTag()
53
  {
54
  return 'macro';
vendor/twig/twig/lib/Twig/TokenParser/Sandbox.php CHANGED
@@ -22,13 +22,6 @@
22
  */
23
  class Twig_TokenParser_Sandbox extends Twig_TokenParser
24
  {
25
- /**
26
- * Parses a token and returns a node.
27
- *
28
- * @param Twig_Token $token A Twig_Token instance
29
- *
30
- * @return Twig_NodeInterface A Twig_NodeInterface instance
31
- */
32
  public function parse(Twig_Token $token)
33
  {
34
  $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
@@ -43,7 +36,7 @@ class Twig_TokenParser_Sandbox extends Twig_TokenParser
43
  }
44
 
45
  if (!$node instanceof Twig_Node_Include) {
46
- throw new Twig_Error_Syntax('Only "include" tags are allowed within a "sandbox" section', $node->getLine(), $this->parser->getFilename());
47
  }
48
  }
49
  }
@@ -56,11 +49,6 @@ class Twig_TokenParser_Sandbox extends Twig_TokenParser
56
  return $token->test('endsandbox');
57
  }
58
 
59
- /**
60
- * Gets the tag name associated with this token parser.
61
- *
62
- * @return string The tag name
63
- */
64
  public function getTag()
65
  {
66
  return 'sandbox';
22
  */
23
  class Twig_TokenParser_Sandbox extends Twig_TokenParser
24
  {
 
 
 
 
 
 
 
25
  public function parse(Twig_Token $token)
26
  {
27
  $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
36
  }
37
 
38
  if (!$node instanceof Twig_Node_Include) {
39
+ throw new Twig_Error_Syntax('Only "include" tags are allowed within a "sandbox" section.', $node->getLine(), $this->parser->getFilename());
40
  }
41
  }
42
  }
49
  return $token->test('endsandbox');
50
  }
51
 
 
 
 
 
 
52
  public function getTag()
53
  {
54
  return 'sandbox';
vendor/twig/twig/lib/Twig/TokenParser/Set.php CHANGED
@@ -28,13 +28,6 @@
28
  */
29
  class Twig_TokenParser_Set extends Twig_TokenParser
30
  {
31
- /**
32
- * Parses a token and returns a node.
33
- *
34
- * @param Twig_Token $token A Twig_Token instance
35
- *
36
- * @return Twig_NodeInterface A Twig_NodeInterface instance
37
- */
38
  public function parse(Twig_Token $token)
39
  {
40
  $lineno = $token->getLine();
@@ -71,11 +64,6 @@ class Twig_TokenParser_Set extends Twig_TokenParser
71
  return $token->test('endset');
72
  }
73
 
74
- /**
75
- * Gets the tag name associated with this token parser.
76
- *
77
- * @return string The tag name
78
- */
79
  public function getTag()
80
  {
81
  return 'set';
28
  */
29
  class Twig_TokenParser_Set extends Twig_TokenParser
30
  {
 
 
 
 
 
 
 
31
  public function parse(Twig_Token $token)
32
  {
33
  $lineno = $token->getLine();
64
  return $token->test('endset');
65
  }
66
 
 
 
 
 
 
67
  public function getTag()
68
  {
69
  return 'set';
vendor/twig/twig/lib/Twig/TokenParser/Spaceless.php CHANGED
@@ -24,13 +24,6 @@
24
  */
25
  class Twig_TokenParser_Spaceless extends Twig_TokenParser
26
  {
27
- /**
28
- * Parses a token and returns a node.
29
- *
30
- * @param Twig_Token $token A Twig_Token instance
31
- *
32
- * @return Twig_NodeInterface A Twig_NodeInterface instance
33
- */
34
  public function parse(Twig_Token $token)
35
  {
36
  $lineno = $token->getLine();
@@ -47,11 +40,6 @@ class Twig_TokenParser_Spaceless extends Twig_TokenParser
47
  return $token->test('endspaceless');
48
  }
49
 
50
- /**
51
- * Gets the tag name associated with this token parser.
52
- *
53
- * @return string The tag name
54
- */
55
  public function getTag()
56
  {
57
  return 'spaceless';
24
  */
25
  class Twig_TokenParser_Spaceless extends Twig_TokenParser
26
  {
 
 
 
 
 
 
 
27
  public function parse(Twig_Token $token)
28
  {
29
  $lineno = $token->getLine();
40
  return $token->test('endspaceless');
41
  }
42
 
 
 
 
 
 
43
  public function getTag()
44
  {
45
  return 'spaceless';
vendor/twig/twig/lib/Twig/TokenParser/Use.php CHANGED
@@ -25,13 +25,6 @@
25
  */
26
  class Twig_TokenParser_Use extends Twig_TokenParser
27
  {
28
- /**
29
- * Parses a token and returns a node.
30
- *
31
- * @param Twig_Token $token A Twig_Token instance
32
- *
33
- * @return Twig_NodeInterface A Twig_NodeInterface instance
34
- */
35
  public function parse(Twig_Token $token)
36
  {
37
  $template = $this->parser->getExpressionParser()->parseExpression();
@@ -64,11 +57,6 @@ class Twig_TokenParser_Use extends Twig_TokenParser
64
  $this->parser->addTrait(new Twig_Node(array('template' => $template, 'targets' => new Twig_Node($targets))));
65
  }
66
 
67
- /**
68
- * Gets the tag name associated with this token parser.
69
- *
70
- * @return string The tag name
71
- */
72
  public function getTag()
73
  {
74
  return 'use';
25
  */
26
  class Twig_TokenParser_Use extends Twig_TokenParser
27
  {
 
 
 
 
 
 
 
28
  public function parse(Twig_Token $token)
29
  {
30
  $template = $this->parser->getExpressionParser()->parseExpression();
57
  $this->parser->addTrait(new Twig_Node(array('template' => $template, 'targets' => new Twig_Node($targets))));
58
  }
59
 
 
 
 
 
 
60
  public function getTag()
61
  {
62
  return 'use';
vendor/twig/twig/lib/Twig/TokenParserBroker.php CHANGED
@@ -26,8 +26,9 @@ class Twig_TokenParserBroker implements Twig_TokenParserBrokerInterface
26
  /**
27
  * Constructor.
28
  *
29
- * @param array|Traversable $parsers A Traversable of Twig_TokenParserInterface instances
30
- * @param array|Traversable $brokers A Traversable of Twig_TokenParserBrokerInterface instances
 
31
  */
32
  public function __construct($parsers = array(), $brokers = array(), $triggerDeprecationError = true)
33
  {
@@ -37,13 +38,13 @@ class Twig_TokenParserBroker implements Twig_TokenParserBrokerInterface
37
 
38
  foreach ($parsers as $parser) {
39
  if (!$parser instanceof Twig_TokenParserInterface) {
40
- throw new LogicException('$parsers must a an array of Twig_TokenParserInterface');
41
  }
42
  $this->parsers[$parser->getTag()] = $parser;
43
  }
44
  foreach ($brokers as $broker) {
45
  if (!$broker instanceof Twig_TokenParserBrokerInterface) {
46
- throw new LogicException('$brokers must a an array of Twig_TokenParserBrokerInterface');
47
  }
48
  $this->brokers[] = $broker;
49
  }
26
  /**
27
  * Constructor.
28
  *
29
+ * @param array|Traversable $parsers A Traversable of Twig_TokenParserInterface instances
30
+ * @param array|Traversable $brokers A Traversable of Twig_TokenParserBrokerInterface instances
31
+ * @param bool $triggerDeprecationError
32
  */
33
  public function __construct($parsers = array(), $brokers = array(), $triggerDeprecationError = true)
34
  {
38
 
39
  foreach ($parsers as $parser) {
40
  if (!$parser instanceof Twig_TokenParserInterface) {
41
+ throw new LogicException('$parsers must a an array of Twig_TokenParserInterface.');
42
  }
43
  $this->parsers[$parser->getTag()] = $parser;
44
  }
45
  foreach ($brokers as $broker) {
46
  if (!$broker instanceof Twig_TokenParserBrokerInterface) {
47
+ throw new LogicException('$brokers must a an array of Twig_TokenParserBrokerInterface.');
48
  }
49
  $this->brokers[] = $broker;
50
  }
vendor/twig/twig/lib/Twig/TokenStream.php CHANGED
@@ -56,7 +56,7 @@ class Twig_TokenStream
56
  public function next()
57
  {
58
  if (!isset($this->tokens[++$this->current])) {
59
- throw new Twig_Error_Syntax('Unexpected end of template', $this->tokens[$this->current - 1]->getLine(), $this->filename);
60
  }
61
 
62
  return $this->tokens[$this->current - 1];
@@ -84,7 +84,7 @@ class Twig_TokenStream
84
  $token = $this->tokens[$this->current];
85
  if (!$token->test($type, $value)) {
86
  $line = $token->getLine();
87
- throw new Twig_Error_Syntax(sprintf('%sUnexpected token "%s" of value "%s" ("%s" expected%s)',
88
  $message ? $message.'. ' : '',
89
  Twig_Token::typeToEnglish($token->getType()), $token->getValue(),
90
  Twig_Token::typeToEnglish($type), $value ? sprintf(' with value "%s"', $value) : ''),
@@ -107,7 +107,7 @@ class Twig_TokenStream
107
  public function look($number = 1)
108
  {
109
  if (!isset($this->tokens[$this->current + $number])) {
110
- throw new Twig_Error_Syntax('Unexpected end of template', $this->tokens[$this->current + $number - 1]->getLine(), $this->filename);
111
  }
112
 
113
  return $this->tokens[$this->current + $number];
56
  public function next()
57
  {
58
  if (!isset($this->tokens[++$this->current])) {
59
+ throw new Twig_Error_Syntax('Unexpected end of template.', $this->tokens[$this->current - 1]->getLine(), $this->filename);
60
  }
61
 
62
  return $this->tokens[$this->current - 1];
84
  $token = $this->tokens[$this->current];
85
  if (!$token->test($type, $value)) {
86
  $line = $token->getLine();
87
+ throw new Twig_Error_Syntax(sprintf('%sUnexpected token "%s" of value "%s" ("%s" expected%s).',
88
  $message ? $message.'. ' : '',
89
  Twig_Token::typeToEnglish($token->getType()), $token->getValue(),
90
  Twig_Token::typeToEnglish($type), $value ? sprintf(' with value "%s"', $value) : ''),
107
  public function look($number = 1)
108
  {
109
  if (!isset($this->tokens[$this->current + $number])) {
110
+ throw new Twig_Error_Syntax('Unexpected end of template.', $this->tokens[$this->current + $number - 1]->getLine(), $this->filename);
111
  }
112
 
113
  return $this->tokens[$this->current + $number];
vendor/twig/twig/test/Twig/Tests/Cache/FilesystemTest.php ADDED
@@ -0,0 +1,169 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_Cache_FilesystemTest extends PHPUnit_Framework_TestCase
13
+ {
14
+ private $nonce;
15
+ private $classname;
16
+ private $directory;
17
+ private $cache;
18
+
19
+ protected function setUp()
20
+ {
21
+ $this->nonce = hash('sha256', uniqid(mt_rand(), true));
22
+ $this->classname = '__Twig_Tests_Cache_FilesystemTest_Template_'.$this->nonce;
23
+ $this->directory = sys_get_temp_dir().'/twig-test-'.$this->nonce;
24
+ $this->cache = new Twig_Cache_Filesystem($this->directory);
25
+ }
26
+
27
+ protected function tearDown()
28
+ {
29
+ if (file_exists($this->directory)) {
30
+ $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($this->directory), RecursiveIteratorIterator::CHILD_FIRST);
31
+ foreach ($iterator as $filename => $fileInfo) {
32
+ if (!$iterator->isDot()) {
33
+ if ($fileInfo->isDir()) {
34
+ rmdir($filename);
35
+ } else {
36
+ unlink($filename);
37
+ }
38
+ }
39
+ }
40
+ rmdir($this->directory);
41
+ }
42
+ }
43
+
44
+ public function testLoad()
45
+ {
46
+ $key = $this->directory.'/cache/cachefile.php';
47
+
48
+ $dir = dirname($key);
49
+ @mkdir($dir, 0777, true);
50
+ $this->assertTrue(is_dir($dir));
51
+ $this->assertFalse(class_exists($this->classname, false));
52
+
53
+ $content = $this->generateSource();
54
+ file_put_contents($key, $content);
55
+
56
+ $this->cache->load($key);
57
+
58
+ $this->assertTrue(class_exists($this->classname, false));
59
+ }
60
+
61
+ public function testLoadMissing()
62
+ {
63
+ $key = $this->directory.'/cache/cachefile.php';
64
+
65
+ $this->assertFalse(class_exists($this->classname, false));
66
+
67
+ $this->cache->load($key);
68
+
69
+ $this->assertFalse(class_exists($this->classname, false));
70
+ }
71
+
72
+ public function testWrite()
73
+ {
74
+ $key = $this->directory.'/cache/cachefile.php';
75
+ $content = $this->generateSource();
76
+
77
+ $this->assertFalse(file_exists($key));
78
+ $this->assertFalse(file_exists($this->directory));
79
+
80
+ $this->cache->write($key, $content);
81
+
82
+ $this->assertTrue(file_exists($this->directory));
83
+ $this->assertTrue(file_exists($key));
84
+ $this->assertSame(file_get_contents($key), $content);
85
+ }
86
+
87
+ /**
88
+ * @expectedException RuntimeException
89
+ * @expectedExceptionMessageRegExp #^Unable to create the cache directory #
90
+ */
91
+ public function testWriteFailMkdir()
92
+ {
93
+ $key = $this->directory.'/cache/cachefile.php';
94
+ $content = $this->generateSource();
95
+
96
+ $this->assertFalse(file_exists($key));
97
+
98
+ // Create read-only root directory.
99
+ @mkdir($this->directory, 0555, true);
100
+ $this->assertTrue(is_dir($this->directory));
101
+
102
+ $this->cache->write($key, $content);
103
+ }
104
+
105
+ /**
106
+ * @expectedException RuntimeException
107
+ * @expectedExceptionMessageRegExp #^Unable to write in the cache directory #
108
+ */
109
+ public function testWriteFailDirWritable()
110
+ {
111
+ $key = $this->directory.'/cache/cachefile.php';
112
+ $content = $this->generateSource();
113
+
114
+ $this->assertFalse(file_exists($key));
115
+
116
+ // Create root directory.
117
+ @mkdir($this->directory, 0777, true);
118
+ // Create read-only subdirectory.
119
+ @mkdir($this->directory.'/cache' , 0555);
120
+ $this->assertTrue(is_dir($this->directory.'/cache'));
121
+
122
+ $this->cache->write($key, $content);
123
+ }
124
+
125
+ /**
126
+ * @expectedException RuntimeException
127
+ * @expectedExceptionMessageRegExp #^Failed to write cache file #
128
+ */
129
+ public function testWriteFailWriteFile()
130
+ {
131
+ $key = $this->directory.'/cache/cachefile.php';
132
+ $content = $this->generateSource();
133
+
134
+ $this->assertFalse(file_exists($key));
135
+
136
+ // Create a directory in the place of the cache file.
137
+ @mkdir($key, 0777, true);
138
+ $this->assertTrue(is_dir($key));
139
+
140
+ $this->cache->write($key, $content);
141
+ }
142
+
143
+ public function testGetTimestamp()
144
+ {
145
+ $key = $this->directory.'/cache/cachefile.php';
146
+
147
+ $dir = dirname($key);
148
+ @mkdir($dir, 0777, true);
149
+ $this->assertTrue(is_dir($dir));
150
+
151
+ // Create the file with a specific modification time.
152
+ touch($key, 1234567890);
153
+
154
+ $this->assertSame(1234567890, $this->cache->getTimestamp($key));
155
+ }
156
+
157
+ public function testGetTimestampMissingFile()
158
+ {
159
+ $key = $this->directory.'/cache/cachefile.php';
160
+ $this->assertSame(0, $this->cache->getTimestamp($key));
161
+ }
162
+
163
+ private function generateSource()
164
+ {
165
+ return strtr('<?php class {{classname}} {}', array(
166
+ '{{classname}}' => $this->classname,
167
+ ));
168
+ }
169
+ }
vendor/twig/twig/test/Twig/Tests/EnvironmentTest.php CHANGED
@@ -11,6 +11,8 @@
11
 
12
  class Twig_Tests_EnvironmentTest extends PHPUnit_Framework_TestCase
13
  {
 
 
14
  /**
15
  * @expectedException LogicException
16
  * @expectedExceptionMessage You must set a loader first.
@@ -54,11 +56,11 @@ class Twig_Tests_EnvironmentTest extends PHPUnit_Framework_TestCase
54
  $globals = $twig->getGlobals();
55
  $this->assertEquals('bar', $globals['foo']);
56
 
57
- // globals can be modified after runtime init
58
  $twig = new Twig_Environment($this->getMock('Twig_LoaderInterface'));
59
  $twig->addGlobal('foo', 'foo');
60
  $twig->getGlobals();
61
- $twig->initRuntime();
62
  $twig->addGlobal('foo', 'bar');
63
  $globals = $twig->getGlobals();
64
  $this->assertEquals('bar', $globals['foo']);
@@ -72,12 +74,12 @@ class Twig_Tests_EnvironmentTest extends PHPUnit_Framework_TestCase
72
  $globals = $twig->getGlobals();
73
  $this->assertEquals('bar', $globals['foo']);
74
 
75
- // globals can be modified after extensions and runtime init
76
  $twig = new Twig_Environment($loader = new Twig_Loader_Array(array('index' => '{{foo}}')));
77
  $twig->addGlobal('foo', 'foo');
78
  $twig->getGlobals();
79
  $twig->getFunctions();
80
- $twig->initRuntime();
81
  $twig->addGlobal('foo', 'bar');
82
  $globals = $twig->getGlobals();
83
  $this->assertEquals('bar', $globals['foo']);
@@ -89,11 +91,11 @@ class Twig_Tests_EnvironmentTest extends PHPUnit_Framework_TestCase
89
  $this->assertEquals('bar', $template->render(array()));
90
 
91
  /* to be uncomment in Twig 2.0
92
- // globals cannot be added after runtime init
93
  $twig = new Twig_Environment($this->getMock('Twig_LoaderInterface'));
94
  $twig->addGlobal('foo', 'foo');
95
  $twig->getGlobals();
96
- $twig->initRuntime();
97
  try {
98
  $twig->addGlobal('bar', 'bar');
99
  $this->fail();
@@ -113,12 +115,12 @@ class Twig_Tests_EnvironmentTest extends PHPUnit_Framework_TestCase
113
  $this->assertFalse(array_key_exists('bar', $twig->getGlobals()));
114
  }
115
 
116
- // globals cannot be added after extensions and runtime init
117
  $twig = new Twig_Environment($this->getMock('Twig_LoaderInterface'));
118
  $twig->addGlobal('foo', 'foo');
119
  $twig->getGlobals();
120
  $twig->getFunctions();
121
- $twig->initRuntime();
122
  try {
123
  $twig->addGlobal('bar', 'bar');
124
  $this->fail();
@@ -126,9 +128,9 @@ class Twig_Tests_EnvironmentTest extends PHPUnit_Framework_TestCase
126
  $this->assertFalse(array_key_exists('bar', $twig->getGlobals()));
127
  }
128
 
129
- // test adding globals after initRuntime without call to getGlobals
130
  $twig = new Twig_Environment($this->getMock('Twig_LoaderInterface'));
131
- $twig->initRuntime();
132
  try {
133
  $twig->addGlobal('bar', 'bar');
134
  $this->fail();
@@ -138,17 +140,29 @@ class Twig_Tests_EnvironmentTest extends PHPUnit_Framework_TestCase
138
  */
139
  }
140
 
 
 
 
 
 
 
 
 
 
 
 
 
141
  public function testExtensionsAreNotInitializedWhenRenderingACompiledTemplate()
142
  {
143
- $options = array('cache' => sys_get_temp_dir().'/twig', 'auto_reload' => false, 'debug' => false);
 
 
144
 
145
  // force compilation
146
  $twig = new Twig_Environment($loader = new Twig_Loader_Array(array('index' => '{{ foo }}')), $options);
147
- $cache = $twig->getCacheFilename('index');
148
- if (!is_dir(dirname($cache))) {
149
- mkdir(dirname($cache), 0777, true);
150
- }
151
- file_put_contents($cache, $twig->compileSource('{{ foo }}', 'index'));
152
 
153
  // check that extensions won't be initialized when rendering a template that is already in the cache
154
  $twig = $this
@@ -164,7 +178,86 @@ class Twig_Tests_EnvironmentTest extends PHPUnit_Framework_TestCase
164
  $output = $twig->render('index', array('foo' => 'bar'));
165
  $this->assertEquals('bar', $output);
166
 
167
- unlink($cache);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
168
  }
169
 
170
  public function testAddExtension()
@@ -183,6 +276,25 @@ class Twig_Tests_EnvironmentTest extends PHPUnit_Framework_TestCase
183
  $this->assertEquals('Twig_Tests_EnvironmentTest_NodeVisitor', get_class($visitors[2]));
184
  }
185
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
186
  /**
187
  * @group legacy
188
  */
@@ -201,9 +313,109 @@ class Twig_Tests_EnvironmentTest extends PHPUnit_Framework_TestCase
201
  $this->assertFalse(array_key_exists('foo_global', $twig->getGlobals()));
202
  $this->assertCount(2, $twig->getNodeVisitors());
203
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
204
  }
205
 
206
- class Twig_Tests_EnvironmentTest_Extension extends Twig_Extension
207
  {
208
  public function getTokenParsers()
209
  {
@@ -290,3 +502,27 @@ class Twig_Tests_EnvironmentTest_NodeVisitor implements Twig_NodeVisitorInterfac
290
  return 0;
291
  }
292
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
 
12
  class Twig_Tests_EnvironmentTest extends PHPUnit_Framework_TestCase
13
  {
14
+ private $deprecations = array();
15
+
16
  /**
17
  * @expectedException LogicException
18
  * @expectedExceptionMessage You must set a loader first.
56
  $globals = $twig->getGlobals();
57
  $this->assertEquals('bar', $globals['foo']);
58
 
59
+ // globals can be modified after a template has been loaded
60
  $twig = new Twig_Environment($this->getMock('Twig_LoaderInterface'));
61
  $twig->addGlobal('foo', 'foo');
62
  $twig->getGlobals();
63
+ $twig->loadTemplate('index');
64
  $twig->addGlobal('foo', 'bar');
65
  $globals = $twig->getGlobals();
66
  $this->assertEquals('bar', $globals['foo']);
74
  $globals = $twig->getGlobals();
75
  $this->assertEquals('bar', $globals['foo']);
76
 
77
+ // globals can be modified after extensions and a template has been loaded
78
  $twig = new Twig_Environment($loader = new Twig_Loader_Array(array('index' => '{{foo}}')));
79
  $twig->addGlobal('foo', 'foo');
80
  $twig->getGlobals();
81
  $twig->getFunctions();
82
+ $twig->loadTemplate('index');
83
  $twig->addGlobal('foo', 'bar');
84
  $globals = $twig->getGlobals();
85
  $this->assertEquals('bar', $globals['foo']);
91
  $this->assertEquals('bar', $template->render(array()));
92
 
93
  /* to be uncomment in Twig 2.0
94
+ // globals cannot be added after a template has been loaded
95
  $twig = new Twig_Environment($this->getMock('Twig_LoaderInterface'));
96
  $twig->addGlobal('foo', 'foo');
97
  $twig->getGlobals();
98
+ $twig->loadTemplate('index');
99
  try {
100
  $twig->addGlobal('bar', 'bar');
101
  $this->fail();
115
  $this->assertFalse(array_key_exists('bar', $twig->getGlobals()));
116
  }
117
 
118
+ // globals cannot be added after extensions and a template has been loaded
119
  $twig = new Twig_Environment($this->getMock('Twig_LoaderInterface'));
120
  $twig->addGlobal('foo', 'foo');
121
  $twig->getGlobals();
122
  $twig->getFunctions();
123
+ $twig->loadTemplate('index');
124
  try {
125
  $twig->addGlobal('bar', 'bar');
126
  $this->fail();
128
  $this->assertFalse(array_key_exists('bar', $twig->getGlobals()));
129
  }
130
 
131
+ // test adding globals after a template has been loaded without call to getGlobals
132
  $twig = new Twig_Environment($this->getMock('Twig_LoaderInterface'));
133
+ $twig->loadTemplate('index');
134
  try {
135
  $twig->addGlobal('bar', 'bar');
136
  $this->fail();
140
  */
141
  }
142
 
143
+ public function testCompileSourceInlinesSource()
144
+ {
145
+ $twig = new Twig_Environment($this->getMock('Twig_LoaderInterface'));
146
+
147
+ $source = "<? */*foo*/ ?>\r\nbar\n";
148
+ $expected = "/* <? *//* *foo*//* ?>*/\n/* bar*/\n/* */\n";
149
+ $compiled = $twig->compileSource($source, 'index');
150
+
151
+ $this->assertContains($expected, $compiled);
152
+ $this->assertNotContains('/**', $compiled);
153
+ }
154
+
155
  public function testExtensionsAreNotInitializedWhenRenderingACompiledTemplate()
156
  {
157
+ $uid = function_exists('posix_getuid') ? posix_getuid() : '';
158
+ $cache = new Twig_Cache_Filesystem($dir = sys_get_temp_dir().'/twig'.$uid);
159
+ $options = array('cache' => $cache, 'auto_reload' => false, 'debug' => false);
160
 
161
  // force compilation
162
  $twig = new Twig_Environment($loader = new Twig_Loader_Array(array('index' => '{{ foo }}')), $options);
163
+
164
+ $key = $cache->generateKey('index', $twig->getTemplateClass('index'));
165
+ $cache->write($key, $twig->compileSource('{{ foo }}', 'index'));
 
 
166
 
167
  // check that extensions won't be initialized when rendering a template that is already in the cache
168
  $twig = $this
178
  $output = $twig->render('index', array('foo' => 'bar'));
179
  $this->assertEquals('bar', $output);
180
 
181
+ unlink($key);
182
+ }
183
+
184
+ public function testAutoReloadCacheMiss()
185
+ {
186
+ $templateName = __FUNCTION__;
187
+ $templateContent = __FUNCTION__;
188
+
189
+ $cache = $this->getMock('Twig_CacheInterface');
190
+ $loader = $this->getMockLoader($templateName, $templateContent);
191
+ $twig = new Twig_Environment($loader, array('cache' => $cache, 'auto_reload' => true, 'debug' => false));
192
+
193
+ // Cache miss: getTimestamp returns 0 and as a result the load() is
194
+ // skipped.
195
+ $cache->expects($this->once())
196
+ ->method('generateKey')
197
+ ->will($this->returnValue('key'));
198
+ $cache->expects($this->once())
199
+ ->method('getTimestamp')
200
+ ->will($this->returnValue(0));
201
+ $loader->expects($this->never())
202
+ ->method('isFresh');
203
+ $cache->expects($this->never())
204
+ ->method('load');
205
+
206
+ $twig->loadTemplate($templateName);
207
+ }
208
+
209
+ public function testAutoReloadCacheHit()
210
+ {
211
+ $templateName = __FUNCTION__;
212
+ $templateContent = __FUNCTION__;
213
+
214
+ $cache = $this->getMock('Twig_CacheInterface');
215
+ $loader = $this->getMockLoader($templateName, $templateContent);
216
+ $twig = new Twig_Environment($loader, array('cache' => $cache, 'auto_reload' => true, 'debug' => false));
217
+
218
+ $now = time();
219
+
220
+ // Cache hit: getTimestamp returns something > extension timestamps and
221
+ // the loader returns true for isFresh().
222
+ $cache->expects($this->once())
223
+ ->method('generateKey')
224
+ ->will($this->returnValue('key'));
225
+ $cache->expects($this->once())
226
+ ->method('getTimestamp')
227
+ ->will($this->returnValue($now));
228
+ $loader->expects($this->once())
229
+ ->method('isFresh')
230
+ ->will($this->returnValue(true));
231
+ $cache->expects($this->once())
232
+ ->method('load');
233
+
234
+ $twig->loadTemplate($templateName);
235
+ }
236
+
237
+ public function testAutoReloadOutdatedCacheHit()
238
+ {
239
+ $templateName = __FUNCTION__;
240
+ $templateContent = __FUNCTION__;
241
+
242
+ $cache = $this->getMock('Twig_CacheInterface');
243
+ $loader = $this->getMockLoader($templateName, $templateContent);
244
+ $twig = new Twig_Environment($loader, array('cache' => $cache, 'auto_reload' => true, 'debug' => false));
245
+
246
+ $now = time();
247
+
248
+ $cache->expects($this->once())
249
+ ->method('generateKey')
250
+ ->will($this->returnValue('key'));
251
+ $cache->expects($this->once())
252
+ ->method('getTimestamp')
253
+ ->will($this->returnValue($now));
254
+ $loader->expects($this->once())
255
+ ->method('isFresh')
256
+ ->will($this->returnValue(false));
257
+ $cache->expects($this->never())
258
+ ->method('load');
259
+
260
+ $twig->loadTemplate($templateName);
261
  }
262
 
263
  public function testAddExtension()
276
  $this->assertEquals('Twig_Tests_EnvironmentTest_NodeVisitor', get_class($visitors[2]));
277
  }
278
 
279
+ /**
280
+ * @requires PHP 5.3
281
+ */
282
+ public function testAddExtensionWithDeprecatedGetGlobals()
283
+ {
284
+ $twig = new Twig_Environment($this->getMock('Twig_LoaderInterface'));
285
+ $twig->addExtension(new Twig_Tests_EnvironmentTest_Extension_WithGlobals());
286
+
287
+ $this->deprecations = array();
288
+ set_error_handler(array($this, 'handleError'));
289
+
290
+ $this->assertArrayHasKey('foo_global', $twig->getGlobals());
291
+
292
+ $this->assertCount(1, $this->deprecations);
293
+ $this->assertContains('Defining the getGlobals() method in the "environment_test" extension is deprecated', $this->deprecations[0]);
294
+
295
+ restore_error_handler();
296
+ }
297
+
298
  /**
299
  * @group legacy
300
  */
313
  $this->assertFalse(array_key_exists('foo_global', $twig->getGlobals()));
314
  $this->assertCount(2, $twig->getNodeVisitors());
315
  }
316
+
317
+ public function testAddMockExtension()
318
+ {
319
+ $extension = $this->getMock('Twig_ExtensionInterface');
320
+ $extension->expects($this->once())
321
+ ->method('getName')
322
+ ->will($this->returnValue('mock'));
323
+
324
+ $loader = new Twig_Loader_Array(array('page' => 'hey'));
325
+
326
+ $twig = new Twig_Environment($loader);
327
+ $twig->addExtension($extension);
328
+
329
+ $this->assertInstanceOf('Twig_ExtensionInterface', $twig->getExtension('mock'));
330
+ $this->assertTrue($twig->isTemplateFresh('page', time()));
331
+ }
332
+
333
+ public function testInitRuntimeWithAnExtensionUsingInitRuntimeNoDeprecation()
334
+ {
335
+ $twig = new Twig_Environment($this->getMock('Twig_LoaderInterface'));
336
+ $twig->addExtension(new Twig_Tests_EnvironmentTest_ExtensionWithoutDeprecationInitRuntime());
337
+
338
+ $twig->initRuntime();
339
+ }
340
+
341
+ /**
342
+ * @requires PHP 5.3
343
+ */
344
+ public function testInitRuntimeWithAnExtensionUsingInitRuntimeDeprecation()
345
+ {
346
+ $twig = new Twig_Environment($this->getMock('Twig_LoaderInterface'));
347
+ $twig->addExtension(new Twig_Tests_EnvironmentTest_ExtensionWithDeprecationInitRuntime());
348
+
349
+ $this->deprecations = array();
350
+ set_error_handler(array($this, 'handleError'));
351
+
352
+ $twig->initRuntime();
353
+
354
+ $this->assertCount(1, $this->deprecations);
355
+ $this->assertContains('Defining the initRuntime() method in the "with_deprecation" extension is deprecated.', $this->deprecations[0]);
356
+
357
+ restore_error_handler();
358
+ }
359
+
360
+ public function handleError($type, $msg)
361
+ {
362
+ if (E_USER_DEPRECATED === $type) {
363
+ $this->deprecations[] = $msg;
364
+ }
365
+ }
366
+
367
+ /**
368
+ * @requires PHP 5.3
369
+ */
370
+ public function testOverrideExtension()
371
+ {
372
+ $twig = new Twig_Environment($this->getMock('Twig_LoaderInterface'));
373
+ $twig->addExtension(new Twig_Tests_EnvironmentTest_ExtensionWithDeprecationInitRuntime());
374
+
375
+ $this->deprecations = array();
376
+ set_error_handler(array($this, 'handleError'));
377
+
378
+ $twig->addExtension(new Twig_Tests_EnvironmentTest_Extension());
379
+ $twig->addExtension(new Twig_Tests_EnvironmentTest_Extension());
380
+
381
+ $this->assertCount(1, $this->deprecations);
382
+ $this->assertContains('The possibility to register the same extension twice', $this->deprecations[0]);
383
+
384
+ restore_error_handler();
385
+ }
386
+
387
+ protected function getMockLoader($templateName, $templateContent)
388
+ {
389
+ $loader = $this->getMock('Twig_LoaderInterface');
390
+ $loader->expects($this->any())
391
+ ->method('getSource')
392
+ ->with($templateName)
393
+ ->will($this->returnValue($templateContent));
394
+ $loader->expects($this->any())
395
+ ->method('getCacheKey')
396
+ ->with($templateName)
397
+ ->will($this->returnValue($templateName));
398
+
399
+ return $loader;
400
+ }
401
+ }
402
+
403
+ class Twig_Tests_EnvironmentTest_Extension_WithGlobals extends Twig_Extension
404
+ {
405
+ public function getGlobals()
406
+ {
407
+ return array(
408
+ 'foo_global' => 'foo_global',
409
+ );
410
+ }
411
+
412
+ public function getName()
413
+ {
414
+ return 'environment_test';
415
+ }
416
  }
417
 
418
+ class Twig_Tests_EnvironmentTest_Extension extends Twig_Extension implements Twig_Extension_GlobalsInterface
419
  {
420
  public function getTokenParsers()
421
  {
502
  return 0;
503
  }
504
  }
505
+
506
+ class Twig_Tests_EnvironmentTest_ExtensionWithDeprecationInitRuntime extends Twig_Extension
507
+ {
508
+ public function initRuntime(Twig_Environment $env)
509
+ {
510
+ }
511
+
512
+ public function getName()
513
+ {
514
+ return 'with_deprecation';
515
+ }
516
+ }
517
+
518
+ class Twig_Tests_EnvironmentTest_ExtensionWithoutDeprecationInitRuntime extends Twig_Extension implements Twig_Extension_InitRuntimeInterface
519
+ {
520
+ public function initRuntime(Twig_Environment $env)
521
+ {
522
+ }
523
+
524
+ public function getName()
525
+ {
526
+ return 'without_deprecation';
527
+ }
528
+ }
vendor/twig/twig/test/Twig/Tests/ExpressionParserTest.php CHANGED
@@ -239,7 +239,7 @@ class Twig_Tests_ExpressionParserTest extends PHPUnit_Framework_TestCase
239
 
240
  /**
241
  * @expectedException Twig_Error_Syntax
242
- * @expectedExceptionMessage An argument must be a name. Unexpected token "string" of value "a" ("name" expected) in "index" at line 1
243
  */
244
  public function testMacroDefinitionDoesNotSupportNonNameVariableName()
245
  {
@@ -296,7 +296,7 @@ class Twig_Tests_ExpressionParserTest extends PHPUnit_Framework_TestCase
296
 
297
  /**
298
  * @expectedException Twig_Error_Syntax
299
- * @expectedExceptionMessage The function "cycl" does not exist. Did you mean "cycle" in "index" at line 1
300
  */
301
  public function testUnknownFunction()
302
  {
@@ -308,7 +308,19 @@ class Twig_Tests_ExpressionParserTest extends PHPUnit_Framework_TestCase
308
 
309
  /**
310
  * @expectedException Twig_Error_Syntax
311
- * @expectedExceptionMessage The filter "lowe" does not exist. Did you mean "lower" in "index" at line 1
 
 
 
 
 
 
 
 
 
 
 
 
312
  */
313
  public function testUnknownFilter()
314
  {
@@ -320,7 +332,19 @@ class Twig_Tests_ExpressionParserTest extends PHPUnit_Framework_TestCase
320
 
321
  /**
322
  * @expectedException Twig_Error_Syntax
323
- * @expectedExceptionMessage The test "nul" does not exist. Did you mean "null" in "index" at line 1
 
 
 
 
 
 
 
 
 
 
 
 
324
  */
325
  public function testUnknownTest()
326
  {
@@ -329,4 +353,16 @@ class Twig_Tests_ExpressionParserTest extends PHPUnit_Framework_TestCase
329
 
330
  $parser->parse($env->tokenize('{{ 1 is nul }}', 'index'));
331
  }
 
 
 
 
 
 
 
 
 
 
 
 
332
  }
239
 
240
  /**
241
  * @expectedException Twig_Error_Syntax
242
+ * @expectedExceptionMessage An argument must be a name. Unexpected token "string" of value "a" ("name" expected) in "index" at line 1.
243
  */
244
  public function testMacroDefinitionDoesNotSupportNonNameVariableName()
245
  {
296
 
297
  /**
298
  * @expectedException Twig_Error_Syntax
299
+ * @expectedExceptionMessage Unknown "cycl" function. Did you mean "cycle" in "index" at line 1?
300
  */
301
  public function testUnknownFunction()
302
  {
308
 
309
  /**
310
  * @expectedException Twig_Error_Syntax
311
+ * @expectedExceptionMessage Unknown "foobar" function in "index" at line 1.
312
+ */
313
+ public function testUnknownFunctionWithoutSuggestions()
314
+ {
315
+ $env = new Twig_Environment($this->getMock('Twig_LoaderInterface'), array('cache' => false, 'autoescape' => false));
316
+ $parser = new Twig_Parser($env);
317
+
318
+ $parser->parse($env->tokenize('{{ foobar() }}', 'index'));
319
+ }
320
+
321
+ /**
322
+ * @expectedException Twig_Error_Syntax
323
+ * @expectedExceptionMessage Unknown "lowe" filter. Did you mean "lower" in "index" at line 1?
324
  */
325
  public function testUnknownFilter()
326
  {
332
 
333
  /**
334
  * @expectedException Twig_Error_Syntax
335
+ * @expectedExceptionMessage Unknown "foobar" filter in "index" at line 1.
336
+ */
337
+ public function testUnknownFilterWithoutSuggestions()
338
+ {
339
+ $env = new Twig_Environment($this->getMock('Twig_LoaderInterface'), array('cache' => false, 'autoescape' => false));
340
+ $parser = new Twig_Parser($env);
341
+
342
+ $parser->parse($env->tokenize('{{ 1|foobar }}', 'index'));
343
+ }
344
+
345
+ /**
346
+ * @expectedException Twig_Error_Syntax
347
+ * @expectedExceptionMessage Unknown "nul" test. Did you mean "null" in "index" at line 1
348
  */
349
  public function testUnknownTest()
350
  {
353
 
354
  $parser->parse($env->tokenize('{{ 1 is nul }}', 'index'));
355
  }
356
+
357
+ /**
358
+ * @expectedException Twig_Error_Syntax
359
+ * @expectedExceptionMessage Unknown "foobar" test in "index" at line 1.
360
+ */
361
+ public function testUnknownTestWithoutSuggestions()
362
+ {
363
+ $env = new Twig_Environment($this->getMock('Twig_LoaderInterface'), array('cache' => false, 'autoescape' => false));
364
+ $parser = new Twig_Parser($env);
365
+
366
+ $parser->parse($env->tokenize('{{ 1 is foobar }}', 'index'));
367
+ }
368
  }
vendor/twig/twig/test/Twig/Tests/Extension/CoreTest.php CHANGED
@@ -121,6 +121,8 @@ class Twig_Tests_Extension_CoreTest extends PHPUnit_Framework_TestCase
121
  $twig->getExtension('core')->setEscaper('foo', 'foo_escaper_for_test');
122
 
123
  $this->assertEquals('fooUTF-8', twig_escape_filter($twig, 'foo', 'foo'));
 
 
124
  }
125
 
126
  /**
121
  $twig->getExtension('core')->setEscaper('foo', 'foo_escaper_for_test');
122
 
123
  $this->assertEquals('fooUTF-8', twig_escape_filter($twig, 'foo', 'foo'));
124
+ $this->assertEquals('UTF-8', twig_escape_filter($twig, null, 'foo'));
125
+ $this->assertEquals('42UTF-8', twig_escape_filter($twig, 42, 'foo'));
126
  }
127
 
128
  /**
vendor/twig/twig/test/Twig/Tests/FileCachingTest.php CHANGED
@@ -38,6 +38,9 @@ class Twig_Tests_FileCachingTest extends PHPUnit_Framework_TestCase
38
  $this->removeDir($this->tmpDir);
39
  }
40
 
 
 
 
41
  public function testWritingCacheFiles()
42
  {
43
  $name = 'index';
@@ -48,6 +51,9 @@ class Twig_Tests_FileCachingTest extends PHPUnit_Framework_TestCase
48
  $this->fileName = $cacheFileName;
49
  }
50
 
 
 
 
51
  public function testClearingCacheFiles()
52
  {
53
  $name = 'index2';
38
  $this->removeDir($this->tmpDir);
39
  }
40
 
41
+ /**
42
+ * @group legacy
43
+ */
44
  public function testWritingCacheFiles()
45
  {
46
  $name = 'index';
51
  $this->fileName = $cacheFileName;
52
  }
53
 
54
+ /**
55
+ * @group legacy
56
+ */
57
  public function testClearingCacheFiles()
58
  {
59
  $name = 'index2';
vendor/twig/twig/test/Twig/Tests/FileExtensionEscapingStrategyTest.php CHANGED
@@ -16,7 +16,7 @@ class Twig_Tests_FileExtensionEscapingStrategyTest extends PHPUnit_Framework_Tes
16
  */
17
  public function testGuess($strategy, $filename)
18
  {
19
- $this->assertEquals($strategy, Twig_FileExtensionEscapingStrategy::guess($filename));
20
  }
21
 
22
  public function getGuessData()
@@ -34,6 +34,8 @@ class Twig_Tests_FileExtensionEscapingStrategyTest extends PHPUnit_Framework_Tes
34
  array('css', 'foo.css'),
35
  array('css', 'foo.css.twig'),
36
  array('css', 'foo.twig.css'),
 
 
37
 
38
  // js
39
  array('js', 'foo.js'),
16
  */
17
  public function testGuess($strategy, $filename)
18
  {
19
+ $this->assertSame($strategy, Twig_FileExtensionEscapingStrategy::guess($filename));
20
  }
21
 
22
  public function getGuessData()
34
  array('css', 'foo.css'),
35
  array('css', 'foo.css.twig'),
36
  array('css', 'foo.twig.css'),
37
+ array('css', 'foo.js.css'),
38
+ array('css', 'foo.js.css.twig'),
39
 
40
  // js
41
  array('js', 'foo.js'),
vendor/twig/twig/test/Twig/Tests/Fixtures/exceptions/syntax_error_in_reused_template.test CHANGED
@@ -7,4 +7,4 @@ Exception for syntax error in reused template
7
  {% do node.data = 5 %}
8
  {% endblock %}
9
  --EXCEPTION--
10
- Twig_Error_Syntax: Unexpected token "operator" of value "=" ("end of statement block" expected) in "foo.twig" at line 3
7
  {% do node.data = 5 %}
8
  {% endblock %}
9
  --EXCEPTION--
10
+ Twig_Error_Syntax: Unexpected token "operator" of value "=" ("end of statement block" expected) in "foo.twig" at line 3.
vendor/twig/twig/test/Twig/Tests/Fixtures/exceptions/unclosed_tag.test CHANGED
@@ -17,4 +17,4 @@ Exception for an unclosed tag
17
 
18
  {% endblock %}
19
  --EXCEPTION--
20
- Twig_Error_Syntax: Unexpected tag name "endblock" (expecting closing tag for the "if" tag defined near line 4) in "index.twig" at line 16
17
 
18
  {% endblock %}
19
  --EXCEPTION--
20
+ Twig_Error_Syntax: Unexpected "endblock" tag (expecting closing tag for the "if" tag defined near line 4) in "index.twig" at line 16.
vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/two_word_operators_as_variables.test CHANGED
@@ -5,4 +5,4 @@ Twig does not allow to use two-word named operators as variable names
5
  --DATA--
6
  return array()
7
  --EXCEPTION--
8
- Twig_Error_Syntax: Unexpected token "operator" of value "starts with" in "index.twig" at line 2
5
  --DATA--
6
  return array()
7
  --EXCEPTION--
8
+ Twig_Error_Syntax: Unexpected token "operator" of value "starts with" in "index.twig" at line 2.
vendor/twig/twig/test/Twig/Tests/Fixtures/filters/merge.test CHANGED
@@ -6,11 +6,13 @@
6
  {{ {'bar': 'foo'}|merge(items)|join }}
7
  {{ {'bar': 'foo'}|merge(items)|keys|join }}
8
  {{ numerics|merge([4, 5, 6])|join }}
 
9
  --DATA--
10
- return array('items' => array('foo' => 'bar'), 'numerics' => array(1, 2, 3))
11
  --EXPECT--
12
  barfoo
13
  foobar
14
  foobar
15
  barfoo
16
  123456
 
6
  {{ {'bar': 'foo'}|merge(items)|join }}
7
  {{ {'bar': 'foo'}|merge(items)|keys|join }}
8
  {{ numerics|merge([4, 5, 6])|join }}
9
+ {{ traversable.a|merge(traversable.b)|join }}
10
  --DATA--
11
+ return array('items' => array('foo' => 'bar'), 'numerics' => array(1, 2, 3), 'traversable' => array('a' => new ArrayObject(array(0 => 1, 1 => 2, 2 => 3)), 'b' => new ArrayObject(array('a' => 'b'))))
12
  --EXPECT--
13
  barfoo
14
  foobar
15
  foobar
16
  barfoo
17
  123456
18
+ 123b
vendor/twig/twig/test/Twig/Tests/Fixtures/filters/replace.test CHANGED
@@ -1,8 +1,12 @@
1
  --TEST--
2
  "replace" filter
3
  --TEMPLATE--
4
- {{ "I like %this% and %that%."|replace({'%this%': "foo", '%that%': "bar"}) }}
 
 
5
  --DATA--
6
- return array()
7
  --EXPECT--
 
 
8
  I like foo and bar.
1
  --TEST--
2
  "replace" filter
3
  --TEMPLATE--
4
+ {{ "I liké %this% and %that%."|replace({'%this%': "foo", '%that%': "bar"}) }}
5
+ {{ 'I like single replace operation only %that%'|replace({'%that%' : '%that%1'}) }}
6
+ {{ 'I like %this% and %that%.'|replace(traversable) }}
7
  --DATA--
8
+ return array('traversable' => new ArrayObject(array('%this%' => 'foo', '%that%' => 'bar')))
9
  --EXPECT--
10
+ I liké foo and bar.
11
+ I like single replace operation only %that%1
12
  I like foo and bar.
vendor/twig/twig/test/Twig/Tests/Fixtures/filters/replace_invalid_arg.test ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ --TEST--
2
+ Exception for invalid argument type in replace call
3
+ --TEMPLATE--
4
+ {{ 'test %foo%'|replace(stdClass) }}
5
+ --DATA--
6
+ return array('stdClass' => new stdClass())
7
+ --EXCEPTION--
8
+ Twig_Error_Runtime: The "replace" filter expects an array or "Traversable" as replace values, got "stdClass" in "index.twig" at line 2.
vendor/twig/twig/test/Twig/Tests/Fixtures/filters/sort.test CHANGED
@@ -3,8 +3,10 @@
3
  --TEMPLATE--
4
  {{ array1|sort|join }}
5
  {{ array2|sort|join }}
 
6
  --DATA--
7
- return array('array1' => array(4, 1), 'array2' => array('foo', 'bar'))
8
  --EXPECT--
9
  14
10
  barfoo
 
3
  --TEMPLATE--
4
  {{ array1|sort|join }}
5
  {{ array2|sort|join }}
6
+ {{ traversable|sort|join }}
7
  --DATA--
8
+ return array('array1' => array(4, 1), 'array2' => array('foo', 'bar'), 'traversable' => new ArrayObject(array(0 => 3, 1 => 2, 2 => 1)))
9
  --EXPECT--
10
  14
11
  barfoo
12
+ 123
vendor/twig/twig/test/Twig/Tests/Fixtures/macros/varargs_argument.test CHANGED
@@ -4,5 +4,5 @@ macro with varargs argument
4
  {% macro test(varargs) %}
5
  {% endmacro %}
6
  --EXCEPTION--
7
- Twig_Error_Syntax: The argument "varargs" in macro "test" cannot be defined because the variable "varargs" is reserved for arbitrary arguments in "index.twig" at line 2
8
 
4
  {% macro test(varargs) %}
5
  {% endmacro %}
6
  --EXCEPTION--
7
+ Twig_Error_Syntax: The argument "varargs" in macro "test" cannot be defined because the variable "varargs" is reserved for arbitrary arguments in "index.twig" at line 2.
8
 
vendor/twig/twig/test/Twig/Tests/Fixtures/tags/block/block_unique_name.test CHANGED
@@ -8,4 +8,4 @@
8
  --DATA--
9
  return array()
10
  --EXCEPTION--
11
- Twig_Error_Syntax: The block 'content' has already been defined line 2 in "index.twig" at line 3
8
  --DATA--
9
  return array()
10
  --EXCEPTION--
11
+ Twig_Error_Syntax: The block 'content' has already been defined line 2 in "index.twig" at line 3.
vendor/twig/twig/test/Twig/Tests/Fixtures/tags/for/loop_not_defined.test CHANGED
@@ -7,4 +7,4 @@
7
  --DATA--
8
  return array('items' => array('a', 'b'))
9
  --EXCEPTION--
10
- Twig_Error_Syntax: The "loop.last" variable is not defined when looping with a condition in "index.twig" at line 3
7
  --DATA--
8
  return array('items' => array('a', 'b'))
9
  --EXCEPTION--
10
+ Twig_Error_Syntax: The "loop.last" variable is not defined when looping with a condition in "index.twig" at line 3.
vendor/twig/twig/test/Twig/Tests/Fixtures/tags/for/loop_not_defined_cond.test CHANGED
@@ -6,4 +6,4 @@
6
  --DATA--
7
  return array('items' => array('a', 'b'))
8
  --EXCEPTION--
9
- Twig_Error_Syntax: The "loop" variable cannot be used in a looping condition in "index.twig" at line 2
6
  --DATA--
7
  return array('items' => array('a', 'b'))
8
  --EXCEPTION--
9
+ Twig_Error_Syntax: The "loop" variable cannot be used in a looping condition in "index.twig" at line 2.
vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/parent_in_a_block.test CHANGED
@@ -5,4 +5,4 @@
5
  {% extends "foo.twig" %}
6
  {% endblock %}
7
  --EXCEPTION--
8
- Twig_Error_Syntax: Cannot extend from a block in "index.twig" at line 3
5
  {% extends "foo.twig" %}
6
  {% endblock %}
7
  --EXCEPTION--
8
+ Twig_Error_Syntax: Cannot extend from a block in "index.twig" at line 3.
vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/parent_without_extends.test CHANGED
@@ -5,4 +5,4 @@
5
  {{ parent() }}
6
  {% endblock %}
7
  --EXCEPTION--
8
- Twig_Error_Syntax: Calling "parent" on a template that does not extend nor "use" another template is forbidden in "index.twig" at line 3
5
  {{ parent() }}
6
  {% endblock %}
7
  --EXCEPTION--
8
+ Twig_Error_Syntax: Calling "parent" on a template that does not extend nor "use" another template is forbidden in "index.twig" at line 3.
vendor/twig/twig/test/Twig/Tests/Fixtures/tags/macro/from_with_reserved_name.test CHANGED
@@ -6,4 +6,4 @@
6
  --DATA--
7
  return array()
8
  --EXCEPTION--
9
- Twig_Error_Syntax: "templateName" cannot be an imported macro as it is a reserved keyword in "index.twig" at line 2
6
  --DATA--
7
  return array()
8
  --EXCEPTION--
9
+ Twig_Error_Syntax: "templateName" cannot be an imported macro as it is a reserved keyword in "index.twig" at line 2.
vendor/twig/twig/test/Twig/Tests/Fixtures/tags/macro/import_with_reserved_nam.test CHANGED
@@ -8,4 +8,4 @@
8
  --DATA--
9
  return array()
10
  --EXCEPTION--
11
- Twig_Error_Syntax: "parent" cannot be called as macro as it is a reserved keyword in "index.twig" at line 4
8
  --DATA--
9
  return array()
10
  --EXCEPTION--
11
+ Twig_Error_Syntax: "parent" cannot be called as macro as it is a reserved keyword in "index.twig" at line 4.
vendor/twig/twig/test/Twig/Tests/Fixtures/tags/macro/reserved_name.test CHANGED
@@ -7,4 +7,4 @@
7
  --DATA--
8
  return array()
9
  --EXCEPTION--
10
- Twig_Error_Syntax: "parent" cannot be used as a macro name as it is a reserved keyword in "index.twig" at line 2
7
  --DATA--
8
  return array()
9
  --EXCEPTION--
10
+ Twig_Error_Syntax: "parent" cannot be used as a macro name as it is a reserved keyword in "index.twig" at line 2.
vendor/twig/twig/test/Twig/Tests/Fixtures/tags/raw/mixed_usage_with_raw.legacy.test CHANGED
@@ -7,4 +7,4 @@
7
  --DATA--
8
  return array()
9
  --EXCEPTION--
10
- Twig_Error_Syntax: Unexpected end of file: Unclosed "raw" block in "index.twig" at line 2
7
  --DATA--
8
  return array()
9
  --EXCEPTION--
10
+ Twig_Error_Syntax: Unexpected end of file: Unclosed "raw" block in "index.twig" at line 2.
vendor/twig/twig/test/Twig/Tests/Fixtures/tags/sandbox/not_valid1.test CHANGED
@@ -8,4 +8,4 @@ sandbox tag
8
  --TEMPLATE(foo.twig)--
9
  foo
10
  --EXCEPTION--
11
- Twig_Error_Syntax: Only "include" tags are allowed within a "sandbox" section in "index.twig" at line 4
8
  --TEMPLATE(foo.twig)--
9
  foo
10
  --EXCEPTION--
11
+ Twig_Error_Syntax: Only "include" tags are allowed within a "sandbox" section in "index.twig" at line 4.
vendor/twig/twig/test/Twig/Tests/Fixtures/tags/sandbox/not_valid2.test CHANGED
@@ -11,4 +11,4 @@ sandbox tag
11
  --TEMPLATE(foo.twig)--
12
  foo
13
  --EXCEPTION--
14
- Twig_Error_Syntax: Only "include" tags are allowed within a "sandbox" section in "index.twig" at line 5
11
  --TEMPLATE(foo.twig)--
12
  foo
13
  --EXCEPTION--
14
+ Twig_Error_Syntax: Only "include" tags are allowed within a "sandbox" section in "index.twig" at line 5.
vendor/twig/twig/test/Twig/Tests/Fixtures/tags/use/inheritance.test CHANGED
@@ -8,7 +8,7 @@
8
  {% use "ancestor.twig" %}
9
 
10
  {% block sub_container %}
11
- <div class="overriden_sub_container">overriden sub_container</div>
12
  {% endblock %}
13
  --TEMPLATE(ancestor.twig)--
14
  {% block container %}
@@ -21,5 +21,5 @@
21
  --DATA--
22
  return array()
23
  --EXPECT--
24
- <div class="container"> <div class="overriden_sub_container">overriden sub_container</div>
25
  </div>
8
  {% use "ancestor.twig" %}
9
 
10
  {% block sub_container %}
11
+ <div class="overridden_sub_container">overridden sub_container</div>
12
  {% endblock %}
13
  --TEMPLATE(ancestor.twig)--
14
  {% block container %}
21
  --DATA--
22
  return array()
23
  --EXPECT--
24
+ <div class="container"> <div class="overridden_sub_container">overridden sub_container</div>
25
  </div>
vendor/twig/twig/test/Twig/Tests/Fixtures/tags/use/inheritance2.test CHANGED
@@ -7,7 +7,7 @@
7
  {{ block('container') }}
8
  --TEMPLATE(parent.twig)--
9
  {% block sub_container %}
10
- <div class="overriden_sub_container">overriden sub_container</div>
11
  {% endblock %}
12
  --TEMPLATE(ancestor.twig)--
13
  {% block container %}
@@ -20,5 +20,5 @@
20
  --DATA--
21
  return array()
22
  --EXPECT--
23
- <div class="container"> <div class="overriden_sub_container">overriden sub_container</div>
24
  </div>
7
  {{ block('container') }}
8
  --TEMPLATE(parent.twig)--
9
  {% block sub_container %}
10
+ <div class="overridden_sub_container">overridden sub_container</div>
11
  {% endblock %}
12
  --TEMPLATE(ancestor.twig)--
13
  {% block container %}
20
  --DATA--
21
  return array()
22
  --EXPECT--
23
+ <div class="container"> <div class="overridden_sub_container">overridden sub_container</div>
24
  </div>
vendor/twig/twig/test/Twig/Tests/Fixtures/tags/verbatim/mixed_usage_with_raw.test CHANGED
@@ -7,4 +7,4 @@
7
  --DATA--
8
  return array()
9
  --EXCEPTION--
10
- Twig_Error_Syntax: Unexpected end of file: Unclosed "verbatim" block in "index.twig" at line 2
7
  --DATA--
8
  return array()
9
  --EXCEPTION--
10
+ Twig_Error_Syntax: Unexpected end of file: Unclosed "verbatim" block in "index.twig" at line 2.
vendor/twig/twig/test/Twig/Tests/LegacyIntegrationTest.php CHANGED
@@ -22,6 +22,15 @@ class Twig_Tests_LegacyIntegrationTest extends Twig_Test_IntegrationTestCase
22
  {
23
  return dirname(__FILE__).'/LegacyFixtures/';
24
  }
 
 
 
 
 
 
 
 
 
25
  }
26
 
27
  class LegacyTwigTestExtension extends Twig_Extension
22
  {
23
  return dirname(__FILE__).'/LegacyFixtures/';
24
  }
25
+
26
+ public function getTests($name, $legacyTests = false)
27
+ {
28
+ if (!$legacyTests) {
29
+ return array(array('not', '-', '', array(), '', array()));
30
+ }
31
+
32
+ return parent::getTests($name, true);
33
+ }
34
  }
35
 
36
  class LegacyTwigTestExtension extends Twig_Extension
vendor/twig/twig/test/Twig/Tests/Node/ForTest.php CHANGED
@@ -51,7 +51,7 @@ class Twig_Tests_Node_ForTest extends Twig_Test_NodeTestCase
51
 
52
  $tests[] = array($node, <<<EOF
53
  // line 1
54
- \$context['_parent'] = (array) \$context;
55
  \$context['_seq'] = twig_ensure_traversable({$this->getVariableGetter('items')});
56
  foreach (\$context['_seq'] as \$context["key"] => \$context["item"]) {
57
  echo {$this->getVariableGetter('foo')};
@@ -73,7 +73,7 @@ EOF
73
 
74
  $tests[] = array($node, <<<EOF
75
  // line 1
76
- \$context['_parent'] = (array) \$context;
77
  \$context['_seq'] = twig_ensure_traversable({$this->getVariableGetter('values')});
78
  \$context['loop'] = array(
79
  'parent' => \$context['_parent'],
@@ -116,7 +116,7 @@ EOF
116
 
117
  $tests[] = array($node, <<<EOF
118
  // line 1
119
- \$context['_parent'] = (array) \$context;
120
  \$context['_seq'] = twig_ensure_traversable({$this->getVariableGetter('values')});
121
  \$context['loop'] = array(
122
  'parent' => \$context['_parent'],
@@ -149,7 +149,7 @@ EOF
149
 
150
  $tests[] = array($node, <<<EOF
151
  // line 1
152
- \$context['_parent'] = (array) \$context;
153
  \$context['_seq'] = twig_ensure_traversable({$this->getVariableGetter('values')});
154
  \$context['_iterated'] = false;
155
  \$context['loop'] = array(
51
 
52
  $tests[] = array($node, <<<EOF
53
  // line 1
54
+ \$context['_parent'] = \$context;
55
  \$context['_seq'] = twig_ensure_traversable({$this->getVariableGetter('items')});
56
  foreach (\$context['_seq'] as \$context["key"] => \$context["item"]) {
57
  echo {$this->getVariableGetter('foo')};
73
 
74
  $tests[] = array($node, <<<EOF
75
  // line 1
76
+ \$context['_parent'] = \$context;
77
  \$context['_seq'] = twig_ensure_traversable({$this->getVariableGetter('values')});
78
  \$context['loop'] = array(
79
  'parent' => \$context['_parent'],
116
 
117
  $tests[] = array($node, <<<EOF
118
  // line 1
119
+ \$context['_parent'] = \$context;
120
  \$context['_seq'] = twig_ensure_traversable({$this->getVariableGetter('values')});
121
  \$context['loop'] = array(
122
  'parent' => \$context['_parent'],
149
 
150
  $tests[] = array($node, <<<EOF
151
  // line 1
152
+ \$context['_parent'] = \$context;
153
  \$context['_seq'] = twig_ensure_traversable({$this->getVariableGetter('values')});
154
  \$context['_iterated'] = false;
155
  \$context['loop'] = array(
vendor/twig/twig/test/Twig/Tests/Node/ModuleTest.php CHANGED
@@ -46,7 +46,7 @@ class Twig_Tests_Node_ModuleTest extends Twig_Test_NodeTestCase
46
  <?php
47
 
48
  /* foo.twig */
49
- class __TwigTemplate_e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 extends Twig_Template
50
  {
51
  public function __construct(Twig_Environment \$env)
52
  {
@@ -75,7 +75,7 @@ class __TwigTemplate_e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b785
75
  }
76
  }
77
  EOF
78
- , $twig);
79
 
80
  $import = new Twig_Node_Import(new Twig_Node_Expression_Constant('foo.twig', 1), new Twig_Node_Expression_AssignName('macro', 1), 2);
81
 
@@ -87,7 +87,7 @@ EOF
87
  <?php
88
 
89
  /* foo.twig */
90
- class __TwigTemplate_e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 extends Twig_Template
91
  {
92
  public function __construct(Twig_Environment \$env)
93
  {
@@ -128,7 +128,7 @@ class __TwigTemplate_e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b785
128
  }
129
  }
130
  EOF
131
- , $twig);
132
 
133
  $set = new Twig_Node_Set(false, new Twig_Node(array(new Twig_Node_Expression_AssignName('foo', 4))), new Twig_Node(array(new Twig_Node_Expression_Constant('foo', 4))), 4);
134
  $body = new Twig_Node(array($set));
@@ -144,7 +144,7 @@ EOF
144
  <?php
145
 
146
  /* foo.twig */
147
- class __TwigTemplate_e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 extends Twig_Template
148
  {
149
  protected function doGetParent(array \$context)
150
  {
@@ -176,7 +176,7 @@ class __TwigTemplate_e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b785
176
  }
177
  }
178
  EOF
179
- , $twig);
180
 
181
  return $tests;
182
  }
46
  <?php
47
 
48
  /* foo.twig */
49
+ class __TwigTemplate_%x extends Twig_Template
50
  {
51
  public function __construct(Twig_Environment \$env)
52
  {
75
  }
76
  }
77
  EOF
78
+ , $twig, true);
79
 
80
  $import = new Twig_Node_Import(new Twig_Node_Expression_Constant('foo.twig', 1), new Twig_Node_Expression_AssignName('macro', 1), 2);
81
 
87
  <?php
88
 
89
  /* foo.twig */
90
+ class __TwigTemplate_%x extends Twig_Template
91
  {
92
  public function __construct(Twig_Environment \$env)
93
  {
128
  }
129
  }
130
  EOF
131
+ , $twig, true);
132
 
133
  $set = new Twig_Node_Set(false, new Twig_Node(array(new Twig_Node_Expression_AssignName('foo', 4))), new Twig_Node(array(new Twig_Node_Expression_Constant('foo', 4))), 4);
134
  $body = new Twig_Node(array($set));
144
  <?php
145
 
146
  /* foo.twig */
147
+ class __TwigTemplate_%x extends Twig_Template
148
  {
149
  protected function doGetParent(array \$context)
150
  {
176
  }
177
  }
178
  EOF
179
+ , $twig, true);
180
 
181
  return $tests;
182
  }
vendor/twig/twig/test/Twig/Tests/ParserTest.php CHANGED
@@ -21,7 +21,7 @@ class Twig_Tests_ParserTest extends PHPUnit_Framework_TestCase
21
 
22
  /**
23
  * @expectedException Twig_Error_Syntax
24
- * @expectedExceptionMessage Unknown tag name "foo". Did you mean "for" at line 1
25
  */
26
  public function testUnknownTag()
27
  {
@@ -35,6 +35,22 @@ class Twig_Tests_ParserTest extends PHPUnit_Framework_TestCase
35
  $parser->parse($stream);
36
  }
37
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
  /**
39
  * @dataProvider getFilterBodyNodesData
40
  */
21
 
22
  /**
23
  * @expectedException Twig_Error_Syntax
24
+ * @expectedExceptionMessage Unknown "foo" tag. Did you mean "for" at line 1?
25
  */
26
  public function testUnknownTag()
27
  {
35
  $parser->parse($stream);
36
  }
37
 
38
+ /**
39
+ * @expectedException Twig_Error_Syntax
40
+ * @expectedExceptionMessage Unknown "foobar" tag at line 1.
41
+ */
42
+ public function testUnknownTagWithoutSuggestions()
43
+ {
44
+ $stream = new Twig_TokenStream(array(
45
+ new Twig_Token(Twig_Token::BLOCK_START_TYPE, '', 1),
46
+ new Twig_Token(Twig_Token::NAME_TYPE, 'foobar', 1),
47
+ new Twig_Token(Twig_Token::BLOCK_END_TYPE, '', 1),
48
+ new Twig_Token(Twig_Token::EOF_TYPE, '', 1),
49
+ ));
50
+ $parser = new Twig_Parser(new Twig_Environment($this->getMock('Twig_LoaderInterface')));
51
+ $parser->parse($stream);
52
+ }
53
+
54
  /**
55
  * @dataProvider getFilterBodyNodesData
56
  */
vendor/twig/twig/test/Twig/Tests/TemplateTest.php CHANGED
@@ -84,6 +84,13 @@ class Twig_Tests_TemplateTest extends PHPUnit_Framework_TestCase
84
  return $tests;
85
  }
86
 
 
 
 
 
 
 
 
87
  /**
88
  * @dataProvider getGetAttributeWithSandbox
89
  */
@@ -463,6 +470,8 @@ class Twig_TemplateTest extends Twig_Template
463
  }
464
  }
465
  }
 
 
466
 
467
  class Twig_TemplateArrayAccessObject implements ArrayAccess
468
  {
@@ -657,7 +666,7 @@ class Twig_TemplateMagicMethodExceptionObject
657
  {
658
  public function __call($method, $arguments)
659
  {
660
- throw new BadMethodCallException(sprintf('Unkown method %s', $method));
661
  }
662
  }
663
 
84
  return $tests;
85
  }
86
 
87
+ public function testGetSource()
88
+ {
89
+ $template = new Twig_TemplateTest(new Twig_Environment($this->getMock('Twig_LoaderInterface')), false);
90
+
91
+ $this->assertSame("<? */*bar*/ ?>\n", $template->getSource());
92
+ }
93
+
94
  /**
95
  * @dataProvider getGetAttributeWithSandbox
96
  */
470
  }
471
  }
472
  }
473
+ /* <? *//* *bar*//* ?>*/
474
+ /* */
475
 
476
  class Twig_TemplateArrayAccessObject implements ArrayAccess
477
  {
666
  {
667
  public function __call($method, $arguments)
668
  {
669
+ throw new BadMethodCallException(sprintf('Unknown method "%s".', $method));
670
  }
671
  }
672