Timber - Version 0.20.9

Version Description

Download this release

Release Info

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

Code changes from version 0.20.8 to 0.20.9

Files changed (459) hide show
  1. README.md +1 -4
  2. functions/functions/cache/KeyGenerator.php +0 -30
  3. functions/functions/cache/TimberKeyGeneratorInterface.php +0 -8
  4. functions/functions/cache/WPObjectCacheAdapter.php +0 -29
  5. functions/functions/cache/loader.php +0 -24
  6. functions/functions/integrations/acf-timber.php +0 -62
  7. functions/functions/integrations/wpcli-timber.php +0 -88
  8. functions/functions/timber-admin.php +0 -31
  9. functions/functions/timber-archives.php +0 -272
  10. functions/functions/timber-comment.php +0 -239
  11. functions/functions/timber-core-interface.php +0 -16
  12. functions/functions/timber-core.php +0 -109
  13. functions/functions/timber-function-wrapper.php +0 -70
  14. functions/functions/timber-helper.php +0 -684
  15. functions/functions/timber-image-helper.php +0 -613
  16. functions/functions/timber-image-retina-helper.php +0 -54
  17. functions/functions/timber-image.php +0 -309
  18. functions/functions/timber-loader.php +0 -410
  19. functions/functions/timber-menu-item.php +0 -234
  20. functions/functions/timber-menu.php +0 -174
  21. functions/functions/timber-page.php +0 -6
  22. functions/functions/timber-post-getter.php +0 -137
  23. functions/functions/timber-post.php +0 -1007
  24. functions/functions/timber-posts-collection.php +0 -97
  25. functions/functions/timber-query-iterator.php +0 -141
  26. functions/functions/timber-routes.php +0 -111
  27. functions/functions/timber-site.php +0 -149
  28. functions/functions/timber-term-getter.php +0 -182
  29. functions/functions/timber-term.php +0 -328
  30. functions/functions/timber-theme.php +0 -58
  31. functions/functions/timber-twig.php +0 -289
  32. functions/functions/timber-url-helper.php +0 -246
  33. functions/functions/timber-user.php +0 -193
  34. functions/timber-admin.php +1 -1
  35. functions/timber-menu-item.php +20 -12
  36. readme.txt +2 -2
  37. timber-starter-theme/timber-starter-theme/404.php +0 -13
  38. timber-starter-theme/timber-starter-theme/archive.php +0 -40
  39. timber-starter-theme/timber-starter-theme/author.php +0 -20
  40. timber-starter-theme/timber-starter-theme/footer.php +0 -13
  41. timber-starter-theme/timber-starter-theme/functions.php +0 -54
  42. timber-starter-theme/timber-starter-theme/header.php +0 -7
  43. timber-starter-theme/timber-starter-theme/index.php +0 -29
  44. timber-starter-theme/timber-starter-theme/js/site.js +0 -5
  45. timber-starter-theme/timber-starter-theme/page.php +0 -27
  46. timber-starter-theme/timber-starter-theme/screenshot.png +0 -0
  47. timber-starter-theme/timber-starter-theme/search.php +0 -19
  48. timber-starter-theme/timber-starter-theme/sidebar.php +0 -10
  49. timber-starter-theme/timber-starter-theme/single.php +0 -24
  50. timber-starter-theme/timber-starter-theme/style.css +0 -4
  51. timber-starter-theme/timber-starter-theme/views/404.twig +0 -5
  52. timber-starter-theme/timber-starter-theme/views/author.twig +0 -8
  53. timber-starter-theme/timber-starter-theme/views/base.twig +0 -51
  54. timber-starter-theme/timber-starter-theme/views/comment.twig +0 -4
  55. timber-starter-theme/timber-starter-theme/views/footer.twig +0 -1
  56. timber-starter-theme/timber-starter-theme/views/html-header.twig +0 -15
  57. timber-starter-theme/timber-starter-theme/views/index.twig +0 -10
  58. timber-starter-theme/timber-starter-theme/views/page-plugin.twig +0 -7
  59. timber-starter-theme/timber-starter-theme/views/page.twig +0 -18
  60. timber-starter-theme/timber-starter-theme/views/sidebar.twig +0 -1
  61. timber-starter-theme/timber-starter-theme/views/single-password.twig +0 -8
  62. timber-starter-theme/timber-starter-theme/views/single.twig +0 -35
  63. timber-starter-theme/timber-starter-theme/views/tease-post.twig +0 -9
  64. timber-starter-theme/timber-starter-theme/views/tease.twig +0 -10
  65. timber-starter-theme/views/base.twig +17 -7
  66. timber.php +1 -1
  67. vendor/autoload.php +1 -1
  68. vendor/composer/ClassLoader.php +13 -4
  69. vendor/composer/autoload_real.php +4 -7
  70. vendor/composer/installed.json +34 -32
  71. vendor/composer/installers/.travis.yml +3 -0
  72. vendor/composer/installers/README.md +10 -3
  73. vendor/composer/installers/composer.json +5 -0
  74. vendor/composer/installers/src/Composer/Installers/AsgardInstaller.php +45 -0
  75. vendor/composer/installers/src/Composer/Installers/BitrixInstaller.php +1 -0
  76. vendor/composer/installers/src/Composer/Installers/CakePHPInstaller.php +92 -5
  77. vendor/composer/installers/src/Composer/Installers/ChefInstaller.php +11 -0
  78. vendor/composer/installers/src/Composer/Installers/DokuWikiInstaller.php +50 -0
  79. vendor/composer/installers/src/Composer/Installers/FuelInstaller.php +1 -1
  80. vendor/composer/installers/src/Composer/Installers/FuelphpInstaller.php +9 -0
  81. vendor/composer/installers/src/Composer/Installers/GravInstaller.php +30 -0
  82. vendor/composer/installers/src/Composer/Installers/HuradInstaller.php +9 -5
  83. vendor/composer/installers/src/Composer/Installers/Installer.php +17 -7
  84. vendor/composer/installers/src/Composer/Installers/MoodleInstaller.php +1 -1
  85. vendor/composer/installers/src/Composer/Installers/OctoberInstaller.php +37 -1
  86. vendor/{vendor/composer/installers/src/Composer/Installers/PPIInstaller.php → composer/installers/src/Composer/Installers/PuppetInstaller.php} +3 -1
  87. vendor/composer/installers/src/Composer/Installers/RedaxoInstaller.php +10 -0
  88. vendor/composer/installers/src/Composer/Installers/TheliaInstaller.php +12 -0
  89. vendor/composer/installers/src/Composer/Installers/WHMCSInstaller.php +10 -0
  90. vendor/composer/installers/tests/Composer/Installers/Test/AsgardInstallerTest.php +61 -0
  91. vendor/composer/installers/tests/Composer/Installers/Test/CakePHPInstallerTest.php +50 -0
  92. vendor/composer/installers/tests/Composer/Installers/Test/DokuWikiInstallerTest.php +89 -0
  93. vendor/composer/installers/tests/Composer/Installers/Test/GravInstallerTest.php +63 -0
  94. vendor/composer/installers/tests/Composer/Installers/Test/InstallerTest.php +33 -2
  95. vendor/composer/installers/tests/Composer/Installers/Test/OctoberInstallerTest.php +66 -0
  96. vendor/symfony/yaml/Symfony/Component/Yaml/Dumper.php +7 -7
  97. vendor/symfony/yaml/Symfony/Component/Yaml/Escaper.php +6 -6
  98. vendor/symfony/yaml/Symfony/Component/Yaml/Exception/ParseException.php +12 -12
  99. vendor/symfony/yaml/Symfony/Component/Yaml/Inline.php +81 -33
  100. vendor/symfony/yaml/Symfony/Component/Yaml/Parser.php +111 -74
  101. vendor/symfony/yaml/Symfony/Component/Yaml/README.md +5 -3
  102. vendor/symfony/yaml/Symfony/Component/Yaml/Tests/DumperTest.php +36 -6
  103. vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/YtsBasicTests.yml +24 -0
  104. vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/YtsSpecificationExamples.yml +4 -2
  105. vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/sfComments.yml +8 -0
  106. vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/sfMergeKey.yml +20 -2
  107. vendor/symfony/yaml/Symfony/Component/Yaml/Tests/InlineTest.php +229 -96
  108. vendor/symfony/yaml/Symfony/Component/Yaml/Tests/ParseExceptionTest.php +13 -1
  109. vendor/symfony/yaml/Symfony/Component/Yaml/Tests/ParserTest.php +51 -4
  110. vendor/symfony/yaml/Symfony/Component/Yaml/Unescaper.php +3 -3
  111. vendor/symfony/yaml/Symfony/Component/Yaml/Yaml.php +8 -8
  112. vendor/symfony/yaml/Symfony/Component/Yaml/composer.json +1 -1
  113. vendor/symfony/yaml/Symfony/Component/Yaml/phpunit.xml.dist +3 -8
  114. vendor/twig/twig/.travis.yml +1 -0
  115. vendor/twig/twig/CHANGELOG +35 -1
  116. vendor/twig/twig/composer.json +2 -2
  117. vendor/twig/twig/doc/advanced.rst +3 -3
  118. vendor/twig/twig/doc/advanced_legacy.rst +3 -3
  119. vendor/twig/twig/doc/api.rst +1 -36
  120. vendor/twig/twig/doc/deprecated.rst +8 -2
  121. vendor/twig/twig/doc/filters/batch.rst +1 -1
  122. vendor/twig/twig/doc/filters/convert_encoding.rst +1 -1
  123. vendor/twig/twig/doc/filters/first.rst +1 -1
  124. vendor/twig/twig/doc/filters/index.rst +2 -2
  125. vendor/twig/twig/doc/filters/json_encode.rst +1 -1
  126. vendor/twig/twig/doc/filters/last.rst +1 -1
  127. vendor/twig/twig/doc/filters/length.rst +1 -1
  128. vendor/twig/twig/doc/filters/merge.rst +6 -0
  129. vendor/twig/twig/doc/filters/nl2br.rst +1 -1
  130. vendor/twig/twig/doc/filters/number_format.rst +1 -1
  131. vendor/twig/twig/doc/filters/raw.rst +24 -0
  132. vendor/twig/twig/doc/filters/slice.rst +4 -3
  133. vendor/twig/twig/doc/filters/split.rst +9 -9
  134. vendor/twig/twig/doc/filters/trim.rst +1 -1
  135. vendor/twig/twig/doc/filters/url_encode.rst +8 -2
  136. vendor/twig/twig/doc/functions/date.rst +2 -2
  137. vendor/twig/twig/doc/functions/dump.rst +1 -1
  138. vendor/twig/twig/doc/functions/include.rst +1 -1
  139. vendor/twig/twig/doc/functions/max.rst +3 -2
  140. vendor/twig/twig/doc/functions/min.rst +3 -2
  141. vendor/twig/twig/doc/functions/random.rst +1 -1
  142. vendor/twig/twig/doc/functions/source.rst +1 -1
  143. vendor/twig/twig/doc/functions/template_from_string.rst +1 -1
  144. vendor/twig/twig/doc/index.rst +2 -2
  145. vendor/twig/twig/doc/installation.rst +43 -48
  146. vendor/twig/twig/doc/internals.rst +1 -1
  147. vendor/twig/twig/doc/intro.rst +6 -4
  148. vendor/twig/twig/doc/recipes.rst +1 -1
  149. vendor/twig/twig/doc/tags/autoescape.rst +12 -0
  150. vendor/twig/twig/doc/tags/do.rst +1 -1
  151. vendor/twig/twig/doc/tags/extends.rst +2 -2
  152. vendor/twig/twig/doc/tags/if.rst +25 -0
  153. vendor/twig/twig/doc/tags/index.rst +1 -1
  154. vendor/twig/twig/doc/tags/use.rst +2 -1
  155. vendor/twig/twig/doc/templates.rst +20 -18
  156. vendor/twig/twig/doc/tests/sameas.rst +2 -2
  157. vendor/twig/twig/ext/twig/LICENSE +0 -31
  158. vendor/twig/twig/ext/twig/php_twig.h +1 -1
  159. vendor/twig/twig/ext/twig/twig.c +10 -2
  160. vendor/twig/twig/lib/Twig/Autoloader.php +1 -1
  161. vendor/twig/twig/lib/Twig/Compiler.php +11 -5
  162. vendor/twig/twig/lib/Twig/CompilerInterface.php +2 -1
  163. vendor/twig/twig/lib/Twig/Environment.php +14 -11
  164. vendor/twig/twig/lib/Twig/Error.php +5 -3
  165. vendor/twig/twig/lib/Twig/ExistsLoaderInterface.php +3 -2
  166. vendor/twig/twig/lib/Twig/ExpressionParser.php +21 -4
  167. vendor/twig/twig/lib/Twig/Extension/Core.php +117 -81
  168. vendor/twig/twig/lib/Twig/Extension/Sandbox.php +1 -1
  169. vendor/twig/twig/lib/Twig/LexerInterface.php +2 -1
  170. vendor/twig/twig/lib/Twig/Loader/Array.php +2 -0
  171. vendor/twig/twig/lib/Twig/Loader/Filesystem.php +17 -10
  172. vendor/twig/twig/lib/Twig/Loader/String.php +1 -3
  173. vendor/twig/twig/lib/Twig/LoaderInterface.php +1 -1
  174. vendor/twig/twig/lib/Twig/Node.php +6 -3
  175. vendor/twig/twig/lib/Twig/Node/AutoEscape.php +1 -1
  176. vendor/twig/twig/lib/Twig/Node/Block.php +1 -1
  177. vendor/twig/twig/lib/Twig/Node/BlockReference.php +1 -1
  178. vendor/twig/twig/lib/Twig/Node/Do.php +1 -1
  179. vendor/twig/twig/lib/Twig/Node/Expression/Array.php +1 -1
  180. vendor/twig/twig/lib/Twig/Node/Expression/AssignName.php +1 -1
  181. vendor/twig/twig/lib/Twig/Node/Expression/Binary.php +1 -1
  182. vendor/twig/twig/lib/Twig/Node/Expression/Binary/EndsWith.php +5 -5
  183. vendor/twig/twig/lib/Twig/Node/Expression/Binary/FloorDiv.php +1 -1
  184. vendor/twig/twig/lib/Twig/Node/Expression/Binary/In.php +1 -1
  185. vendor/twig/twig/lib/Twig/Node/Expression/Binary/NotIn.php +1 -1
  186. vendor/twig/twig/lib/Twig/Node/Expression/Binary/Power.php +1 -1
  187. vendor/twig/twig/lib/Twig/Node/Expression/Binary/Range.php +1 -1
  188. vendor/twig/twig/lib/Twig/Node/Expression/Binary/StartsWith.php +5 -3
  189. vendor/twig/twig/lib/Twig/Node/Expression/BlockReference.php +1 -1
  190. vendor/twig/twig/lib/Twig/Node/Expression/Call.php +7 -5
  191. vendor/twig/twig/lib/Twig/Node/Expression/ExtensionReference.php +1 -1
  192. vendor/twig/twig/lib/Twig/Node/Expression/GetAttr.php +22 -12
  193. vendor/twig/twig/lib/Twig/Node/Expression/Parent.php +1 -1
  194. vendor/twig/twig/lib/Twig/Node/Expression/Test/Divisibleby.php +1 -1
  195. vendor/twig/twig/lib/Twig/Node/Expression/Unary.php +2 -5
  196. vendor/twig/twig/lib/Twig/Node/Flush.php +1 -1
  197. vendor/twig/twig/lib/Twig/Node/For.php +1 -1
  198. vendor/twig/twig/lib/Twig/Node/ForLoop.php +1 -1
  199. vendor/twig/twig/lib/Twig/Node/If.php +1 -1
  200. vendor/twig/twig/lib/Twig/Node/Import.php +1 -1
  201. vendor/twig/twig/lib/Twig/Node/Include.php +17 -31
  202. vendor/twig/twig/lib/Twig/Node/Macro.php +3 -3
  203. vendor/twig/twig/lib/Twig/Node/Module.php +22 -9
  204. vendor/twig/twig/lib/Twig/Node/Print.php +1 -1
  205. vendor/twig/twig/lib/Twig/Node/Sandbox.php +1 -1
  206. vendor/twig/twig/lib/Twig/Node/SandboxedModule.php +40 -4
  207. vendor/twig/twig/lib/Twig/Node/SandboxedPrint.php +1 -1
  208. vendor/twig/twig/lib/Twig/Node/Set.php +1 -1
  209. vendor/twig/twig/lib/Twig/Node/Spaceless.php +1 -1
  210. vendor/twig/twig/lib/Twig/Node/Text.php +1 -1
  211. vendor/twig/twig/lib/Twig/NodeInterface.php +3 -2
  212. vendor/twig/twig/lib/Twig/NodeTraverser.php +1 -1
  213. vendor/twig/twig/lib/Twig/NodeVisitor/Optimizer.php +22 -1
  214. vendor/twig/twig/lib/Twig/NodeVisitor/Sandbox.php +7 -7
  215. vendor/twig/twig/lib/Twig/NodeVisitorInterface.php +1 -1
  216. vendor/twig/twig/lib/Twig/ParserInterface.php +2 -1
  217. vendor/twig/twig/lib/Twig/Sandbox/SecurityNotAllowedFilterError.php +31 -0
  218. vendor/twig/twig/lib/Twig/Sandbox/SecurityNotAllowedFunctionError.php +31 -0
  219. vendor/twig/twig/lib/Twig/Sandbox/SecurityNotAllowedTagError.php +31 -0
  220. vendor/twig/twig/lib/Twig/Sandbox/SecurityPolicy.php +3 -3
  221. vendor/twig/twig/lib/Twig/Template.php +52 -37
  222. vendor/twig/twig/lib/Twig/TemplateInterface.php +2 -1
  223. vendor/twig/twig/lib/Twig/Token.php +9 -9
  224. vendor/twig/twig/lib/Twig/TokenStream.php +3 -3
  225. vendor/twig/twig/test/Twig/Tests/EnvironmentTest.php +3 -3
  226. vendor/twig/twig/test/Twig/Tests/Extension/CoreTest.php +18 -0
  227. vendor/twig/twig/test/Twig/Tests/Extension/SandboxTest.php +7 -2
  228. vendor/twig/twig/test/Twig/Tests/FileCachingTest.php +2 -2
  229. vendor/twig/twig/test/Twig/Tests/Fixtures/exceptions/undefined_parent.test +8 -0
  230. vendor/twig/twig/test/Twig/Tests/Fixtures/exceptions/undefined_trait.test +1 -1
  231. vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/bitwise.test +1 -1
  232. vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/divisibleby.test +0 -4
  233. vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/ends_with.test +14 -0
  234. vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/negative_numbers.test +18 -0
  235. vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/sameas.test +2 -2
  236. vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/starts_with.test +10 -0
  237. vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/unary_macro_arguments.test +22 -0
  238. vendor/twig/twig/test/Twig/Tests/Fixtures/filters/{batch_float.php → batch_float.test} +2 -4
  239. vendor/twig/twig/test/Twig/Tests/Fixtures/filters/date.test +16 -2
  240. vendor/twig/twig/test/Twig/Tests/Fixtures/filters/date_immutable.test +2 -0
  241. vendor/twig/twig/test/Twig/Tests/Fixtures/filters/default.test +29 -29
  242. vendor/twig/twig/test/Twig/Tests/Fixtures/filters/first.test +1 -0
  243. vendor/twig/twig/test/Twig/Tests/Fixtures/filters/last.test +1 -0
  244. vendor/twig/twig/test/Twig/Tests/Fixtures/filters/slice.test +10 -0
  245. vendor/twig/twig/test/Twig/Tests/Fixtures/filters/split.test +2 -0
  246. vendor/twig/twig/test/Twig/Tests/Fixtures/filters/split_utf8.test +24 -0
  247. vendor/twig/twig/test/Twig/Tests/Fixtures/filters/urlencode.test +6 -2
  248. vendor/{vendor/twig/twig/test/Twig/Tests/Fixtures/filters/urlencode.test → twig/twig/test/Twig/Tests/Fixtures/filters/urlencode_deprecated.test} +7 -3
  249. vendor/twig/twig/test/Twig/Tests/Fixtures/functions/attribute.test +3 -1
  250. vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/sandbox.test +4 -1
  251. vendor/twig/twig/test/Twig/Tests/Fixtures/functions/recursive_block_with_inheritance.test +21 -0
  252. vendor/twig/twig/test/Twig/Tests/Fixtures/regression/combined_debug_info.test +15 -0
  253. vendor/twig/twig/test/Twig/Tests/Fixtures/regression/multi_word_tests.test +10 -0
  254. vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/block_expr.test +32 -0
  255. vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/block_expr2.test +34 -0
  256. vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/multiple_dynamic.test +22 -0
  257. vendor/{vendor/twig/twig/test/Twig/Tests/Fixtures/tags/macro/special_chars.test → twig/twig/test/Twig/Tests/Fixtures/tags/macro/super_globals.test} +5 -5
  258. vendor/twig/twig/test/Twig/Tests/Fixtures/tags/use/inheritance.test +25 -0
  259. vendor/twig/twig/test/Twig/Tests/Fixtures/tags/use/inheritance2.test +24 -0
  260. vendor/twig/twig/test/Twig/Tests/Fixtures/tags/use/parent_block.test +24 -0
  261. vendor/twig/twig/test/Twig/Tests/Fixtures/tags/use/parent_block2.test +24 -0
  262. vendor/twig/twig/test/Twig/Tests/Fixtures/tags/use/parent_block3.test +38 -0
  263. vendor/twig/twig/test/Twig/Tests/Fixtures/tests/in.test +80 -2
  264. vendor/twig/twig/test/Twig/Tests/IntegrationTest.php +12 -0
  265. vendor/twig/twig/test/Twig/Tests/LexerTest.php +6 -11
  266. vendor/twig/twig/test/Twig/Tests/NativeExtensionTest.php +4 -4
  267. vendor/twig/twig/test/Twig/Tests/Node/AutoEscapeTest.php +0 -12
  268. vendor/twig/twig/test/Twig/Tests/Node/BlockReferenceTest.php +0 -12
  269. vendor/twig/twig/test/Twig/Tests/Node/BlockTest.php +0 -12
  270. vendor/twig/twig/test/Twig/Tests/Node/DoTest.php +0 -12
  271. vendor/twig/twig/test/Twig/Tests/Node/Expression/ArrayTest.php +0 -12
  272. vendor/twig/twig/test/Twig/Tests/Node/Expression/AssignNameTest.php +0 -12
  273. vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/AddTest.php +0 -13
  274. vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/AndTest.php +0 -13
  275. vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/ConcatTest.php +0 -13
  276. vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/DivTest.php +0 -13
  277. vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/FloorDivTest.php +0 -13
  278. vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/ModTest.php +0 -13
  279. vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/MulTest.php +0 -13
  280. vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/OrTest.php +0 -13
  281. vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/SubTest.php +0 -13
  282. vendor/twig/twig/test/Twig/Tests/Node/Expression/CallTest.php +2 -2
  283. vendor/twig/twig/test/Twig/Tests/Node/Expression/ConditionalTest.php +0 -12
  284. vendor/twig/twig/test/Twig/Tests/Node/Expression/ConstantTest.php +0 -12
  285. vendor/twig/twig/test/Twig/Tests/Node/Expression/FilterTest.php +1 -13
  286. vendor/twig/twig/test/Twig/Tests/Node/Expression/FunctionTest.php +0 -12
  287. vendor/twig/twig/test/Twig/Tests/Node/Expression/GetAttrTest.php +1 -13
  288. vendor/twig/twig/test/Twig/Tests/Node/Expression/NameTest.php +0 -12
  289. vendor/twig/twig/test/Twig/Tests/Node/Expression/ParentTest.php +0 -12
  290. vendor/twig/twig/test/Twig/Tests/Node/Expression/TestTest.php +0 -12
  291. vendor/twig/twig/test/Twig/Tests/Node/Expression/Unary/NegTest.php +2 -14
  292. vendor/twig/twig/test/Twig/Tests/Node/Expression/Unary/NotTest.php +1 -14
  293. vendor/twig/twig/test/Twig/Tests/Node/Expression/Unary/PosTest.php +1 -14
  294. vendor/twig/twig/test/Twig/Tests/Node/ForTest.php +0 -12
  295. vendor/twig/twig/test/Twig/Tests/Node/IfTest.php +0 -12
  296. vendor/twig/twig/test/Twig/Tests/Node/ImportTest.php +0 -12
  297. vendor/twig/twig/test/Twig/Tests/Node/IncludeTest.php +1 -14
  298. vendor/twig/twig/test/Twig/Tests/Node/MacroTest.php +3 -15
  299. vendor/twig/twig/test/Twig/Tests/Node/ModuleTest.php +24 -29
  300. vendor/twig/twig/test/Twig/Tests/Node/PrintTest.php +0 -12
  301. vendor/twig/twig/test/Twig/Tests/Node/SandboxTest.php +0 -12
  302. vendor/twig/twig/test/Twig/Tests/Node/SandboxedModuleTest.php +56 -26
  303. vendor/twig/twig/test/Twig/Tests/Node/SandboxedPrintTest.php +0 -12
  304. vendor/twig/twig/test/Twig/Tests/Node/SetTest.php +0 -12
  305. vendor/twig/twig/test/Twig/Tests/Node/SpacelessTest.php +0 -12
  306. vendor/twig/twig/test/Twig/Tests/Node/TextTest.php +0 -12
  307. vendor/twig/twig/test/Twig/Tests/NodeVisitor/OptimizerTest.php +10 -0
  308. vendor/twig/twig/test/Twig/Tests/TemplateTest.php +4 -2
  309. vendor/twig/twig/test/Twig/Tests/escapingTest.php +2 -2
  310. vendor/vendor/asm89/twig-cache-extension/.gitignore +0 -4
  311. vendor/vendor/asm89/twig-cache-extension/.travis.yml +0 -14
  312. vendor/vendor/asm89/twig-cache-extension/LICENSE +0 -19
  313. vendor/vendor/asm89/twig-cache-extension/README.md +0 -195
  314. vendor/vendor/asm89/twig-cache-extension/composer.json +0 -29
  315. vendor/vendor/asm89/twig-cache-extension/lib/Asm89/Twig/CacheExtension/CacheProvider/DoctrineCacheAdapter.php +0 -49
  316. vendor/vendor/asm89/twig-cache-extension/lib/Asm89/Twig/CacheExtension/CacheProviderInterface.php +0 -34
  317. vendor/vendor/asm89/twig-cache-extension/lib/Asm89/Twig/CacheExtension/CacheStrategy/GenerationalCacheStrategy.php +0 -79
  318. vendor/vendor/asm89/twig-cache-extension/lib/Asm89/Twig/CacheExtension/CacheStrategy/IndexedChainingCacheStrategy.php +0 -75
  319. vendor/vendor/asm89/twig-cache-extension/lib/Asm89/Twig/CacheExtension/CacheStrategy/KeyGeneratorInterface.php +0 -29
  320. vendor/vendor/asm89/twig-cache-extension/lib/Asm89/Twig/CacheExtension/CacheStrategy/LifetimeCacheStrategy.php +0 -68
  321. vendor/vendor/asm89/twig-cache-extension/lib/Asm89/Twig/CacheExtension/CacheStrategyInterface.php +0 -47
  322. vendor/vendor/asm89/twig-cache-extension/lib/Asm89/Twig/CacheExtension/Extension.php +0 -56
  323. vendor/vendor/asm89/twig-cache-extension/lib/Asm89/Twig/CacheExtension/Node/CacheNode.php +0 -63
  324. vendor/vendor/asm89/twig-cache-extension/lib/Asm89/Twig/CacheExtension/TokenParser/Cache.php +0 -56
  325. vendor/vendor/asm89/twig-cache-extension/phpunit.xml.dist +0 -25
  326. vendor/vendor/asm89/twig-cache-extension/test/Asm89/Twig/CacheExtension/Tests/CacheProvider/DoctrineCacheAdapterTest.php +0 -46
  327. vendor/vendor/asm89/twig-cache-extension/test/Asm89/Twig/CacheExtension/Tests/CacheStrategy/GenerationCacheStrategyTest.php +0 -80
  328. vendor/vendor/asm89/twig-cache-extension/test/Asm89/Twig/CacheExtension/Tests/CacheStrategy/IndexedChainingCacheStrategyTest.php +0 -72
  329. vendor/vendor/asm89/twig-cache-extension/test/Asm89/Twig/CacheExtension/Tests/CacheStrategy/LifetimeCacheStrategyTest.php +0 -68
  330. vendor/vendor/asm89/twig-cache-extension/test/Asm89/Twig/CacheExtension/Tests/FunctionalExtensionTest.php +0 -185
  331. vendor/vendor/asm89/twig-cache-extension/test/Asm89/Twig/CacheExtension/Tests/fixtures/annotation_not_string.twig +0 -2
  332. vendor/vendor/asm89/twig-cache-extension/test/Asm89/Twig/CacheExtension/Tests/fixtures/gcs_value.twig +0 -1
  333. vendor/vendor/asm89/twig-cache-extension/test/Asm89/Twig/CacheExtension/Tests/fixtures/gcs_value_v2.twig +0 -1
  334. vendor/vendor/asm89/twig-cache-extension/test/Asm89/Twig/CacheExtension/Tests/fixtures/ics_no_key.twig +0 -1
  335. vendor/vendor/asm89/twig-cache-extension/test/Asm89/Twig/CacheExtension/Tests/fixtures/ics_value.twig +0 -1
  336. vendor/vendor/asm89/twig-cache-extension/test/Asm89/Twig/CacheExtension/Tests/fixtures/lcs_value.twig +0 -1
  337. vendor/vendor/asm89/twig-cache-extension/test/bootstrap.php +0 -16
  338. vendor/vendor/autoload.php +0 -7
  339. vendor/vendor/composer/ClassLoader.php +0 -378
  340. vendor/vendor/composer/autoload_classmap.php +0 -9
  341. vendor/vendor/composer/autoload_namespaces.php +0 -14
  342. vendor/vendor/composer/autoload_psr4.php +0 -9
  343. vendor/vendor/composer/autoload_real.php +0 -53
  344. vendor/vendor/composer/installed.json +0 -311
  345. vendor/vendor/composer/installers/.editorconfig +0 -10
  346. vendor/vendor/composer/installers/.gitignore +0 -3
  347. vendor/vendor/composer/installers/.travis.yml +0 -11
  348. vendor/vendor/composer/installers/LICENSE +0 -19
  349. vendor/vendor/composer/installers/README.md +0 -180
  350. vendor/vendor/composer/installers/composer.json +0 -70
  351. vendor/vendor/composer/installers/phpunit.xml.dist +0 -25
  352. vendor/vendor/composer/installers/src/Composer/Installers/AglInstaller.php +0 -21
  353. vendor/vendor/composer/installers/src/Composer/Installers/AnnotateCmsInstaller.php +0 -11
  354. vendor/vendor/composer/installers/src/Composer/Installers/BaseInstaller.php +0 -131
  355. vendor/vendor/composer/installers/src/Composer/Installers/BitrixInstaller.php +0 -10
  356. vendor/vendor/composer/installers/src/Composer/Installers/CakePHPInstaller.php +0 -58
  357. vendor/vendor/composer/installers/src/Composer/Installers/CodeIgniterInstaller.php +0 -11
  358. vendor/vendor/composer/installers/src/Composer/Installers/Concrete5Installer.php +0 -12
  359. vendor/vendor/composer/installers/src/Composer/Installers/CraftInstaller.php +0 -9
  360. vendor/vendor/composer/installers/src/Composer/Installers/CroogoInstaller.php +0 -21
  361. vendor/vendor/composer/installers/src/Composer/Installers/DolibarrInstaller.php +0 -16
  362. vendor/vendor/composer/installers/src/Composer/Installers/DrupalInstaller.php +0 -13
  363. vendor/vendor/composer/installers/src/Composer/Installers/ElggInstaller.php +0 -9
  364. vendor/vendor/composer/installers/src/Composer/Installers/FuelInstaller.php +0 -11
  365. vendor/vendor/composer/installers/src/Composer/Installers/HuradInstaller.php +0 -21
  366. vendor/vendor/composer/installers/src/Composer/Installers/Installer.php +0 -149
  367. vendor/vendor/composer/installers/src/Composer/Installers/JoomlaInstaller.php +0 -15
  368. vendor/vendor/composer/installers/src/Composer/Installers/KirbyInstaller.php +0 -9
  369. vendor/vendor/composer/installers/src/Composer/Installers/KohanaInstaller.php +0 -9
  370. vendor/vendor/composer/installers/src/Composer/Installers/LaravelInstaller.php +0 -9
  371. vendor/vendor/composer/installers/src/Composer/Installers/LithiumInstaller.php +0 -10
  372. vendor/vendor/composer/installers/src/Composer/Installers/MODULEWorkInstaller.php +0 -9
  373. vendor/vendor/composer/installers/src/Composer/Installers/MODXEvoInstaller.php +0 -16
  374. vendor/vendor/composer/installers/src/Composer/Installers/MagentoInstaller.php +0 -11
  375. vendor/vendor/composer/installers/src/Composer/Installers/MakoInstaller.php +0 -9
  376. vendor/vendor/composer/installers/src/Composer/Installers/MediaWikiInstaller.php +0 -50
  377. vendor/vendor/composer/installers/src/Composer/Installers/MicroweberInstaller.php +0 -111
  378. vendor/vendor/composer/installers/src/Composer/Installers/MoodleInstaller.php +0 -47
  379. vendor/vendor/composer/installers/src/Composer/Installers/OctoberInstaller.php +0 -10
  380. vendor/vendor/composer/installers/src/Composer/Installers/OxidInstaller.php +0 -11
  381. vendor/vendor/composer/installers/src/Composer/Installers/PhpBBInstaller.php +0 -11
  382. vendor/vendor/composer/installers/src/Composer/Installers/PimcoreInstaller.php +0 -21
  383. vendor/vendor/composer/installers/src/Composer/Installers/PiwikInstaller.php +0 -32
  384. vendor/vendor/composer/installers/src/Composer/Installers/RoundcubeInstaller.php +0 -22
  385. vendor/vendor/composer/installers/src/Composer/Installers/ShopwareInstaller.php +0 -58
  386. vendor/vendor/composer/installers/src/Composer/Installers/SilverStripeInstaller.php +0 -36
  387. vendor/vendor/composer/installers/src/Composer/Installers/Symfony1Installer.php +0 -26
  388. vendor/vendor/composer/installers/src/Composer/Installers/TYPO3CmsInstaller.php +0 -14
  389. vendor/vendor/composer/installers/src/Composer/Installers/TYPO3FlowInstaller.php +0 -38
  390. vendor/vendor/composer/installers/src/Composer/Installers/TuskInstaller.php +0 -14
  391. vendor/vendor/composer/installers/src/Composer/Installers/WolfCMSInstaller.php +0 -9
  392. vendor/vendor/composer/installers/src/Composer/Installers/WordPressInstaller.php +0 -11
  393. vendor/vendor/composer/installers/src/Composer/Installers/ZendInstaller.php +0 -11
  394. vendor/vendor/composer/installers/src/Composer/Installers/ZikulaInstaller.php +0 -10
  395. vendor/vendor/composer/installers/src/bootstrap.php +0 -13
  396. vendor/vendor/composer/installers/tests/Composer/Installers/Test/CakePHPInstallerTest.php +0 -113
  397. vendor/vendor/composer/installers/tests/Composer/Installers/Test/InstallerTest.php +0 -381
  398. vendor/vendor/composer/installers/tests/Composer/Installers/Test/MediaWikiInstallerTest.php +0 -66
  399. vendor/vendor/composer/installers/tests/Composer/Installers/Test/PimcoreInstallerTest.php +0 -44
  400. vendor/vendor/composer/installers/tests/Composer/Installers/Test/PiwikInstallerTest.php +0 -63
  401. vendor/vendor/composer/installers/tests/Composer/Installers/Test/TestCase.php +0 -64
  402. vendor/vendor/composer/installers/tests/bootstrap.php +0 -4
  403. vendor/vendor/dannyvankooten/php-router/.gitignore +0 -36
  404. vendor/vendor/dannyvankooten/php-router/.htaccess +0 -3
  405. vendor/vendor/dannyvankooten/php-router/LICENSE +0 -7
  406. vendor/vendor/dannyvankooten/php-router/README.md +0 -43
  407. vendor/vendor/dannyvankooten/php-router/composer.json +0 -26
  408. vendor/vendor/dannyvankooten/php-router/example.php +0 -37
  409. vendor/vendor/dannyvankooten/php-router/src/PHPRouter/Route.php +0 -115
  410. vendor/vendor/dannyvankooten/php-router/src/PHPRouter/Router.php +0 -164
  411. vendor/vendor/symfony/yaml/Symfony/Component/Yaml/.gitignore +0 -3
  412. vendor/vendor/symfony/yaml/Symfony/Component/Yaml/CHANGELOG.md +0 -8
  413. vendor/vendor/symfony/yaml/Symfony/Component/Yaml/Dumper.php +0 -73
  414. vendor/vendor/symfony/yaml/Symfony/Component/Yaml/Escaper.php +0 -89
  415. vendor/vendor/symfony/yaml/Symfony/Component/Yaml/Exception/DumpException.php +0 -23
  416. vendor/vendor/symfony/yaml/Symfony/Component/Yaml/Exception/ExceptionInterface.php +0 -23
  417. vendor/vendor/symfony/yaml/Symfony/Component/Yaml/Exception/ParseException.php +0 -148
  418. vendor/vendor/symfony/yaml/Symfony/Component/Yaml/Exception/RuntimeException.php +0 -23
  419. vendor/vendor/symfony/yaml/Symfony/Component/Yaml/Inline.php +0 -487
  420. vendor/vendor/symfony/yaml/Symfony/Component/Yaml/LICENSE +0 -19
  421. vendor/vendor/symfony/yaml/Symfony/Component/Yaml/Parser.php +0 -655
  422. vendor/vendor/symfony/yaml/Symfony/Component/Yaml/README.md +0 -19
  423. vendor/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/DumperTest.php +0 -207
  424. vendor/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/YtsAnchorAlias.yml +0 -31
  425. vendor/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/YtsBasicTests.yml +0 -178
  426. vendor/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/YtsBlockMapping.yml +0 -51
  427. vendor/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/YtsDocumentSeparator.yml +0 -85
  428. vendor/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/YtsErrorTests.yml +0 -25
  429. vendor/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/YtsFlowCollections.yml +0 -60
  430. vendor/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/YtsFoldedScalars.yml +0 -176
  431. vendor/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/YtsNullsAndEmpties.yml +0 -45
  432. vendor/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/YtsSpecificationExamples.yml +0 -1695
  433. vendor/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/YtsTypeTransfers.yml +0 -244
  434. vendor/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/embededPhp.yml +0 -1
  435. vendor/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/escapedCharacters.yml +0 -147
  436. vendor/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/index.yml +0 -18
  437. vendor/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/sfComments.yml +0 -65
  438. vendor/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/sfCompact.yml +0 -159
  439. vendor/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/sfMergeKey.yml +0 -27
  440. vendor/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/sfObjects.yml +0 -11
  441. vendor/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/sfQuotes.yml +0 -33
  442. vendor/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/sfTests.yml +0 -135
  443. vendor/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/unindentedCollections.yml +0 -62
  444. vendor/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/InlineTest.php +0 -231
  445. vendor/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/ParseExceptionTest.php +0 -30
  446. vendor/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/ParserTest.php +0 -660
  447. vendor/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/YamlTest.php +0 -31
  448. vendor/vendor/symfony/yaml/Symfony/Component/Yaml/Unescaper.php +0 -141
  449. vendor/vendor/symfony/yaml/Symfony/Component/Yaml/Yaml.php +0 -100
  450. vendor/vendor/symfony/yaml/Symfony/Component/Yaml/composer.json +0 -31
  451. vendor/vendor/symfony/yaml/Symfony/Component/Yaml/phpunit.xml.dist +0 -29
  452. vendor/vendor/twig/twig/.editorconfig +0 -18
  453. vendor/vendor/twig/twig/.gitignore +0 -2
  454. vendor/vendor/twig/twig/.travis.yml +0 -21
  455. vendor/vendor/twig/twig/CHANGELOG +0 -677
  456. vendor/vendor/twig/twig/LICENSE +0 -31
  457. vendor/vendor/twig/twig/README.rst +0 -15
  458. vendor/vendor/twig/twig/composer.json +0 -42
  459. vendor/vendor/twig/twig/doc/advanced.rst +0 -807
README.md CHANGED
@@ -39,10 +39,7 @@ Once Timber is installed and activated in your plugin directory, it gives any Wo
39
  **NEW!** The GitHub version of Timber now requires [Composer](https://getcomposer.org/download/). If you'd prefer one-click installation, you should use the [WordPress.org](http://wordpress.org/plugins/timber-library/) version.
40
 
41
  ```shell
42
- cd ~/MYSITE/wp-content/plugins
43
- git clone git@github.com:jarednova/timber.git
44
- cd timber
45
- composer install
46
  ```
47
 
48
  Once this is complete, activate Timber your WordPress admin. If you're looking for a 'blank' theme to start developing with, drag the `timber-starter-theme` from the timber directory into your themes directory.
39
  **NEW!** The GitHub version of Timber now requires [Composer](https://getcomposer.org/download/). If you'd prefer one-click installation, you should use the [WordPress.org](http://wordpress.org/plugins/timber-library/) version.
40
 
41
  ```shell
42
+ composer create-project --no-dev jarednova/timber ~/MYSITE/wp-content/plugins/timber
 
 
 
43
  ```
44
 
45
  Once this is complete, activate Timber your WordPress admin. If you're looking for a 'blank' theme to start developing with, drag the `timber-starter-theme` from the timber directory into your themes directory.
functions/functions/cache/KeyGenerator.php DELETED
@@ -1,30 +0,0 @@
1
- <?php
2
-
3
- namespace Timber\Cache;
4
-
5
- use Asm89\Twig\CacheExtension\CacheStrategy\KeyGeneratorInterface;
6
-
7
- class KeyGenerator implements KeyGeneratorInterface {
8
-
9
- /**
10
- * @param mixed $value
11
- * @return string
12
- */
13
- public function generateKey($value) {
14
- if (is_a($value, 'TimberKeyGeneratorInterface')) {
15
- return $value->_get_cache_key();
16
- }
17
-
18
- if (is_array($value) && isset($value['_cache_key'])) {
19
- return $value['_cache_key'];
20
- }
21
-
22
- $key = md5(json_encode($value));
23
- if (is_object($value)) {
24
- $key = get_class($value) . '|' . $key;
25
- }
26
-
27
- return $key;
28
- }
29
-
30
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
functions/functions/cache/TimberKeyGeneratorInterface.php DELETED
@@ -1,8 +0,0 @@
1
- <?php
2
-
3
- namespace Timber\Cache;
4
-
5
- interface TimberKeyGeneratorInterface
6
- {
7
- public function _get_cache_key();
8
- }
 
 
 
 
 
 
 
 
functions/functions/cache/WPObjectCacheAdapter.php DELETED
@@ -1,29 +0,0 @@
1
- <?php namespace Timber\Cache;
2
-
3
- use Asm89\Twig\CacheExtension\CacheProviderInterface;
4
- use TimberLoader;
5
-
6
- class WPObjectCacheAdapter implements CacheProviderInterface
7
- {
8
-
9
- private $cache_group;
10
-
11
- /**
12
- * @var TimberLoader
13
- */
14
- private $timberloader;
15
-
16
- public function __construct(TimberLoader $timberloader, $cache_group = 'timber') {
17
- $this->cache_group = $cache_group;
18
- $this->timberloader = $timberloader;
19
- }
20
-
21
- public function fetch($key) {
22
- return $this->timberloader->get_cache($key, $this->cache_group, TimberLoader::CACHE_USE_DEFAULT);
23
- }
24
-
25
- public function save($key, $value, $expire = 0) {
26
- return $this->timberloader->set_cache($key, $value, $this->cache_group, $expire, TimberLoader::CACHE_USE_DEFAULT);
27
- }
28
-
29
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
functions/functions/cache/loader.php DELETED
@@ -1,24 +0,0 @@
1
- <?php
2
-
3
- class TimberCache_Loader
4
- {
5
-
6
- public static function register($prepend = false) {
7
- if (version_compare(phpversion(), '5.3.0', '>=')) {
8
- spl_autoload_register(array(new self, 'autoload'), true, $prepend);
9
- } else {
10
- spl_autoload_register(array(new self, 'autoload'));
11
- }
12
- }
13
-
14
- public static function autoload($class) {
15
- if (0 === strpos($class, 'Timber\Cache')) {
16
- $classes = explode('\\', $class);
17
- array_splice($classes, 0, 2);
18
- $path = implode($classes, '/');
19
- if (is_file($file = dirname(__FILE__) . '/' . $path . '.php')) {
20
- require $file;
21
- }
22
- }
23
- }
24
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
functions/functions/integrations/acf-timber.php DELETED
@@ -1,62 +0,0 @@
1
- <?php
2
-
3
- class ACFTimber {
4
-
5
- function __construct() {
6
- add_filter( 'timber_post_get_meta', array( $this, 'post_get_meta' ), 10, 2 );
7
- add_filter( 'timber_post_get_meta_field', array( $this, 'post_get_meta_field' ), 10, 3 );
8
- add_filter( 'timber_term_get_meta', array( $this, 'term_get_meta' ), 10, 3 );
9
- add_filter( 'timber_term_get_meta_field', array( $this, 'term_get_meta_field' ), 10, 4 );
10
- add_filter( 'timber_user_get_meta_field_pre', array( $this, 'user_get_meta_field' ), 10, 3 );
11
- add_filter( 'timber_term_set_meta', array( $this, 'term_set_meta'), 10, 4 );
12
- }
13
-
14
- function post_get_meta( $customs, $post_id ) {
15
- return $customs;
16
- }
17
-
18
- function post_get_meta_field( $value, $post_id, $field_name ) {
19
- return get_field( $field_name, $post_id );
20
- }
21
-
22
- function term_get_meta_field( $value, $term_id, $field_name, $term ) {
23
- $searcher = $term->taxonomy . "_" . $term->ID;
24
- return get_field( $field_name, $searcher );
25
- }
26
-
27
- function term_set_meta( $value, $field, $term_id, $term ) {
28
- $searcher = $term->taxonomy . "_" . $term->ID;
29
- update_field( $field, $value, $searcher );
30
- return $value;
31
- }
32
-
33
- function term_get_meta( $fields, $term_id, $term ) {
34
- $searcher = $term->taxonomy . "_" . $term->ID; // save to a specific category
35
- $fds = get_fields( $searcher );
36
- if ( is_array( $fds ) ) {
37
- foreach ( $fds as $key => $value ) {
38
- $key = preg_replace( '/_/', '', $key, 1 );
39
- $key = str_replace( $searcher, '', $key );
40
- $key = preg_replace( '/_/', '', $key, 1 );
41
- $field = get_field( $key, $searcher );
42
- $fields[$key] = $field;
43
- }
44
- $fields = array_merge( $fields, $fds );
45
- }
46
- return $fields;
47
- }
48
-
49
- function user_get_meta( $fields, $user_id ) {
50
- return $fields;
51
- }
52
-
53
- function user_get_meta_field( $value, $uid, $field ) {
54
- return get_field( $field, 'user_' . $uid );
55
- }
56
- }
57
-
58
- add_action( 'init', function () {
59
- if ( class_exists( 'ACF' ) ) {
60
- new ACFTimber();
61
- }
62
- } );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
functions/functions/integrations/wpcli-timber.php DELETED
@@ -1,88 +0,0 @@
1
- <?php
2
- if (class_exists('WP_CLI_Command')) {
3
- class Timber_WP_CLI_Command extends WP_CLI_Command {
4
-
5
- /**
6
- * Clears Timber and Twig's Cache
7
- *
8
- * ## EXAMPLES
9
- *
10
- * wp timber clear_cache
11
- *
12
- */
13
- public function clear_cache($mode = 'all') {
14
- TimberCommand::clear_cache($mode);
15
- }
16
-
17
- /**
18
- * Clears Twig's Cache
19
- *
20
- * ## EXAMPLES
21
- *
22
- * wp timber clear_cache_twig
23
- *
24
- */
25
- function clear_cache_twig(){
26
- $clear = TimberCommand::clear_cache_twig();
27
- if ($clear){
28
- WP_CLI::success('Cleared contents of twig cache');
29
- } else {
30
- WP_CLI::warning('Failed to clear twig cache');
31
- }
32
- }
33
-
34
- /**
35
- * Clears Timber's Cache
36
- *
37
- * ## EXAMPLES
38
- *
39
- * wp timber clear_cache_timber
40
- *
41
- */
42
- function clear_cache_timber() {
43
- $clear = TimberCommand::clear_cache_timber();
44
- $message = 'Failed to clear timber cache';
45
- if ($clear){
46
- $message = "Cleared contents of Timber's Cache";
47
- WP_CLI::success($message);
48
- } else {
49
- WP_CLI::warning($message);
50
- }
51
- return $message;
52
- }
53
-
54
- }
55
-
56
- WP_CLI::add_command('timber', 'Timber_WP_CLI_Command');
57
- }
58
-
59
- class TimberCommand {
60
-
61
- public static function clear_cache($mode = 'all'){
62
- if (is_array($mode)){
63
- $mode = reset($mode);
64
- }
65
- if ($mode == 'all') {
66
- $twig_cache = self::clear_cache_twig();
67
- $timber_cache = self::clear_cache_timber();
68
- if ($twig_cache && $timber_cache){
69
- return true;
70
- }
71
- } else if ($mode == 'twig') {
72
- return self::clear_cache_twig();
73
- } else if ($mode == 'timber') {
74
- return self::clear_cache_timber();
75
- }
76
- }
77
-
78
- static function clear_cache_timber(){
79
- $loader = new TimberLoader();
80
- return $loader->clear_cache_timber();
81
- }
82
-
83
- static function clear_cache_twig(){
84
- $loader = new TimberLoader();
85
- return $loader->clear_cache_twig();
86
- }
87
-
88
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
functions/functions/timber-admin.php DELETED
@@ -1,31 +0,0 @@
1
- <?php
2
-
3
- class TimberAdmin {
4
-
5
- function __construct() {
6
- add_filter( 'plugin_row_meta', array( $this, 'meta_links' ), 10, 2 );
7
- }
8
-
9
- /**
10
- *
11
- *
12
- * @param array $links
13
- * @param string $file
14
- * @return array
15
- */
16
- function meta_links( $links, $file ) {
17
- if ( strstr( $file, '/timber.php' ) ) {
18
- unset($links[2]);
19
- $links[] = '<a href="http://localhost/wp-admin/plugin-install.php?tab=plugin-information&amp;plugin=timber-library&amp;TB_iframe=true&amp;width=600&amp;height=550" class="thickbox" aria-label="More information about Timber" data-title="Timber">View details</a>';
20
- $links[] = '<a href="http://upstatement.com/timber" target="_blank">Homepage</a>';
21
- $links[] = '<a href="https://github.com/jarednova/timber/wiki" target="_blank">Documentation</a>';
22
- $links[] = '<a href="https://github.com/jarednova/timber/wiki/getting-started" target="_blank">Starter Guide</a>';
23
- return $links;
24
- }
25
- return $links;
26
- }
27
-
28
- }
29
-
30
- global $timber_admin;
31
- $timber_admin = new TimberAdmin();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
functions/functions/timber-archives.php DELETED
@@ -1,272 +0,0 @@
1
- <?php
2
-
3
- class TimberArchives extends TimberCore
4
- {
5
-
6
- public $base = '';
7
- public $items;
8
-
9
- function __construct($args = null, $base = '') {
10
- $this->init($args, $base);
11
- }
12
-
13
- /**
14
- * @param array|string $args
15
- * @param string $base
16
- */
17
- function init($args = null, $base = '') {
18
- $this->base = $base;
19
- $this->items = $this->get_items($args);
20
- }
21
-
22
- /**
23
- * @param string $url
24
- * @param string $text
25
- * @return mixed
26
- */
27
- function get_archives_link($url, $text) {
28
- $ret = array();
29
- $ret['text'] = $ret['title'] = $ret['name'] = wptexturize($text);
30
- $ret['url'] = $ret['link'] = esc_url(TimberURLHelper::prepend_to_url($url, $this->base));
31
- return $ret;
32
- }
33
-
34
- /**
35
- * @param array|string $args
36
- * @param string $last_changed
37
- * @param string $join
38
- * @param string $where
39
- * @param string $order
40
- * @param string $limit
41
- * @return array
42
- */
43
- function get_items_yearly($args, $last_changed, $join, $where, $order, $limit) {
44
- global $wpdb;
45
- $output = array();
46
- $query = "SELECT YEAR(post_date) AS `year`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date) ORDER BY post_date $order $limit";
47
- $key = md5($query);
48
- $key = "wp_get_archives:$key:$last_changed";
49
- if (!$results = wp_cache_get($key, 'posts')) {
50
- $results = $wpdb->get_results($query);
51
- wp_cache_set($key, $results, 'posts');
52
- }
53
- if ($results) {
54
- foreach ((array)$results as $result) {
55
- $url = get_year_link($result->year);
56
- $text = sprintf('%d', $result->year);
57
- $output[] = $this->get_archives_link($url, $text);
58
- }
59
- }
60
- return $output;
61
- }
62
-
63
- /**
64
- * @param array|string $args
65
- * @param string $last_changed
66
- * @param string $join
67
- * @param string $where
68
- * @param string $order
69
- * @param int $limit
70
- * @param bool $nested
71
- * @return array
72
- */
73
- function get_items_montly($args, $last_changed, $join, $where, $order, $limit = 1000, $nested = true) {
74
- global $wpdb, $wp_locale;
75
- $output = array();
76
- $defaults = array(
77
- 'show_year' => true,
78
- );
79
- $r = wp_parse_args($args, $defaults);
80
-
81
- $show_year = null;
82
- extract($r, EXTR_SKIP);
83
-
84
- //will need to specify which year we're looking for
85
- $query = "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts "
86
- . "FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date) "
87
- . "ORDER BY post_date $order $limit";
88
- $key = md5($query);
89
- $key = "wp_get_archives:$key:$last_changed";
90
- if (!$results = wp_cache_get($key, 'posts')) {
91
- $results = $wpdb->get_results($query);
92
- wp_cache_set($key, $results, 'posts');
93
- }
94
- if ($results) {
95
- foreach ((array)$results as $result) {
96
- $url = get_month_link($result->year, $result->month);
97
- /* translators: 1: month name, 2: 4-digit year */
98
-
99
- if ($show_year && !$nested) {
100
- $text = sprintf(__('%1$s %2$d'), $wp_locale->get_month($result->month), $result->year);
101
- } else {
102
- $text = sprintf(__('%1$s'), $wp_locale->get_month($result->month));
103
- }
104
- if ($nested) {
105
- $output[$result->year][] = $this->get_archives_link($url, $text);
106
- } else {
107
- $output[] = $this->get_archives_link($url, $text);
108
- }
109
- }
110
- }
111
- if ($nested) {
112
- $out2 = array();
113
- foreach ($output as $year => $months) {
114
- $out2[] = array('name' => $year, 'children' => $months);
115
- }
116
- return $out2;
117
- }
118
- return $output;
119
- }
120
-
121
- /**
122
- * @param array|string $args
123
- * @return array|string
124
- */
125
- function get_items($args = null) {
126
- global $wpdb;
127
-
128
- $defaults = array(
129
- 'type' => 'monthly', 'limit' => '',
130
- 'format' => 'html', 'before' => '',
131
- 'after' => '', 'show_post_count' => false,
132
- 'order' => 'DESC',
133
- 'post_type' => 'post',
134
- 'nested' => true
135
- );
136
-
137
- $r = wp_parse_args($args, $defaults);
138
- $type = $limit = $order = $post_type = $nested = $format = $before = $after = null;
139
- extract($r, EXTR_SKIP);
140
-
141
- if (empty($order)){
142
- $order = 'DESC';
143
- }
144
-
145
- if (empty($post_type)){
146
- $post_type = 'post';
147
- }
148
- if (empty($type)) {
149
- $type = 'monthly';
150
- }
151
-
152
- if (!empty($limit)) {
153
- $limit = absint($limit);
154
- $limit = ' LIMIT ' . $limit;
155
- }
156
-
157
- $order = strtoupper($order);
158
- if ($order !== 'ASC') {
159
- $order = 'DESC';
160
- }
161
-
162
- // this is what will separate dates on weekly archive links
163
- $archive_week_separator = '&#8211;';
164
-
165
- // over-ride general date format ? 0 = no: use the date format set in Options, 1 = yes: over-ride
166
- $archive_date_format_over_ride = 0;
167
-
168
- // options for daily archive (only if you over-ride the general date format)
169
- $archive_day_date_format = 'Y/m/d';
170
-
171
- // options for weekly archive (only if you over-ride the general date format)
172
- $archive_week_start_date_format = 'Y/m/d';
173
- $archive_week_end_date_format = 'Y/m/d';
174
-
175
- if (!$archive_date_format_over_ride) {
176
- $archive_day_date_format = get_option('date_format');
177
- $archive_week_start_date_format = get_option('date_format');
178
- $archive_week_end_date_format = get_option('date_format');
179
- }
180
-
181
- $where = apply_filters('getarchives_where', 'WHERE post_type = "' . $post_type . '" AND post_status = "publish"', $r);
182
- $join = apply_filters('getarchives_join', '', $r);
183
-
184
- $output = array();
185
-
186
- $last_changed = wp_cache_get('last_changed', 'posts');
187
- if (!$last_changed) {
188
- $last_changed = microtime();
189
- wp_cache_set('last_changed', $last_changed, 'posts');
190
- }
191
- if ('monthly' == $type) {
192
- $output = $this->get_items_montly($args, $last_changed, $join, $where, $order, $limit, $nested);
193
- } elseif ('yearly' == $type) {
194
- $output = $this->get_items_yearly($args, $last_changed, $join, $where, $order, $limit);
195
- } elseif ('yearlymonthly' == $type || 'yearmonth' == $type) {
196
- $years = $this->get_items_yearly($args, $last_changed, $join, $where, $order, $limit);
197
- foreach ($years as &$year) {
198
- $args = array('show_year' => false);
199
- $year['children'] = $this->get_items_montly($args, $last_changed, $join, $where, $order, $limit);
200
- }
201
- $output = $years;
202
- } elseif ('daily' == $type) {
203
- $query = "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date), DAYOFMONTH(post_date) ORDER BY post_date $order $limit";
204
- $key = md5($query);
205
- $key = "wp_get_archives:$key:$last_changed";
206
- if (!$results = wp_cache_get($key, 'posts')) {
207
- $results = $wpdb->get_results($query);
208
- $cache = array();
209
- $cache[$key] = $results;
210
- wp_cache_set($key, $results, 'posts');
211
- }
212
- if ($results) {
213
- foreach ((array)$results as $result) {
214
- $url = get_day_link($result->year, $result->month, $result->dayofmonth);
215
- $date = sprintf('%1$d-%2$02d-%3$02d 00:00:00', $result->year, $result->month, $result->dayofmonth);
216
- $text = mysql2date($archive_day_date_format, $date);
217
- $output[] = $this->get_archives_link($url, $text);
218
- }
219
- }
220
- } elseif ('weekly' == $type) {
221
- $week = _wp_mysql_week('`post_date`');
222
- $query = "SELECT DISTINCT $week AS `week`, YEAR( `post_date` ) AS `yr`, DATE_FORMAT( `post_date`, '%Y-%m-%d' ) AS `yyyymmdd`, "
223
- . "count( `ID` ) AS `posts` FROM `$wpdb->posts` $join $where GROUP BY $week, YEAR( `post_date` ) ORDER BY `post_date` $order $limit";
224
- $key = md5($query);
225
- $key = "wp_get_archives:$key:$last_changed";
226
- if (!$results = wp_cache_get($key, 'posts')) {
227
- $results = $wpdb->get_results($query);
228
- wp_cache_set($key, $results, 'posts');
229
- }
230
- $arc_w_last = '';
231
- if ($results) {
232
- foreach ((array)$results as $result) {
233
- if ($result->week != $arc_w_last) {
234
- $arc_year = $result->yr;
235
- $arc_w_last = $result->week;
236
- $arc_week = get_weekstartend($result->yyyymmdd, get_option('start_of_week'));
237
- $arc_week_start = date_i18n($archive_week_start_date_format, $arc_week['start']);
238
- $arc_week_end = date_i18n($archive_week_end_date_format, $arc_week['end']);
239
- $url = sprintf('%1$s/%2$s%3$sm%4$s%5$s%6$sw%7$s%8$d', home_url(), '', '?', '=', $arc_year, '&amp;', '=', $result->week);
240
- $text = $arc_week_start . $archive_week_separator . $arc_week_end;
241
- $output[] = $this->get_archives_link($url, $text);
242
- }
243
- }
244
- }
245
- } elseif ('postbypost' == $type || 'alpha' == $type) {
246
- $orderby = 'alpha' == $type ? 'post_title ASC ' : 'post_date DESC ';
247
- $query = "SELECT * FROM $wpdb->posts $join $where ORDER BY $orderby $limit";
248
- $key = md5($query);
249
- $key = "wp_get_archives:$key:$last_changed";
250
- if (!$results = wp_cache_get($key, 'posts')) {
251
- $results = $wpdb->get_results($query);
252
- wp_cache_set($key, $results, 'posts');
253
- }
254
- if ($results) {
255
- foreach ((array)$results as $result) {
256
- if ($result->post_date != '0000-00-00 00:00:00') {
257
- $url = get_permalink($result);
258
- if ($result->post_title) {
259
- /** This filter is documented in wp-includes/post-template.php */
260
- $text = strip_tags(apply_filters('the_title', $result->post_title, $result->ID));
261
- } else {
262
- $text = $result->ID;
263
- }
264
- $output .= get_archives_link($url, $text, $format, $before, $after);
265
- }
266
- }
267
- }
268
- }
269
- return $output;
270
- }
271
-
272
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
functions/functions/timber-comment.php DELETED
@@ -1,239 +0,0 @@
1
- <?php
2
-
3
- class TimberComment extends TimberCore implements TimberCoreInterface {
4
-
5
- public $PostClass = 'TimberPost';
6
- public $object_type = 'comment';
7
-
8
- public static $representation = 'comment';
9
-
10
- public $ID;
11
- public $id;
12
- public $comment_author_email;
13
- public $comment_content;
14
- public $comment_date;
15
- public $comment_ID;
16
- public $user_id;
17
- public $comment_author;
18
-
19
- /**
20
- * @param int $cid
21
- */
22
- function __construct($cid) {
23
- $this->init($cid);
24
- }
25
-
26
- function __toString(){
27
- return $this->content();
28
- }
29
-
30
- /**
31
- * @param integer $cid
32
- */
33
- function init($cid) {
34
- $comment_data = $cid;
35
- if (is_integer($cid)) {
36
- $comment_data = get_comment($cid);
37
- }
38
- $this->import($comment_data);
39
- $this->ID = $this->comment_ID;
40
- $this->id = $this->comment_ID;
41
- $comment_meta_data = $this->get_meta_fields($this->ID);
42
- $this->import($comment_meta_data);
43
- }
44
-
45
- /**
46
- * @return TimberUser
47
- */
48
- public function author() {
49
- if ($this->user_id) {
50
- return new TimberUser($this->user_id);
51
- } else {
52
- $author = new TimberUser(0);
53
- if (isset($this->comment_author) && $this->comment_author) {
54
- $author->name = $this->comment_author;
55
- } else {
56
- $author->name = 'Anonymous';
57
- }
58
- }
59
- return $author;
60
- }
61
-
62
- /**
63
- * @param int $size
64
- * @param string $default
65
- * @return bool|mixed|string
66
- */
67
- public function avatar($size = 92, $default = '') {
68
- // Fetches the Gravatar
69
- // use it like this
70
- // {{comment.avatar(36,template_uri~"/img/dude.jpg")}}
71
-
72
- if (!get_option('show_avatars')) {
73
- return false;
74
- }
75
- if (!is_numeric($size)) {
76
- $size = '92';
77
- }
78
-
79
- $email = $this->avatar_email();
80
- $email_hash = '';
81
- if (!empty($email)) {
82
- $email_hash = md5(strtolower(trim($email)));
83
- }
84
- $host = $this->avatar_host($email_hash);
85
- $default = $this->avatar_default($default, $email, $size, $host);
86
- if (!empty($email)) {
87
- $avatar = $this->avatar_out($email, $default, $host, $email_hash, $size);
88
- } else {
89
- $avatar = $default;
90
- }
91
- return $avatar;
92
- }
93
-
94
- /**
95
- * @return string
96
- */
97
- public function content() {
98
- return $this->comment_content;
99
- }
100
-
101
- /**
102
- * @return string
103
- */
104
- public function date() {
105
- return $this->comment_date;
106
- }
107
-
108
- /**
109
- * @param string $field_name
110
- * @return mixed
111
- */
112
- public function meta($field_name) {
113
- return $this->get_meta_field($field_name);
114
- }
115
-
116
- /**
117
- * @param int $comment_id
118
- * @return mixed
119
- */
120
- private function get_meta_fields($comment_id = null) {
121
- if ($comment_id === null) {
122
- $comment_id = $this->ID;
123
- }
124
- //Could not find a WP function to fetch all comment meta data, so I made one.
125
- apply_filters('timber_comment_get_meta_pre', array(), $comment_id);
126
- $comment_metas = get_comment_meta($comment_id);
127
- foreach ($comment_metas as &$cm) {
128
- if (is_array($cm) && count($cm) == 1) {
129
- $cm = $cm[0];
130
- }
131
- }
132
- $comment_metas = apply_filters('timber_comment_get_meta', $comment_metas, $comment_id);
133
- return $comment_metas;
134
- }
135
-
136
- /**
137
- * @param string $field_name
138
- * @return mixed
139
- */
140
- private function get_meta_field($field_name) {
141
- $value = apply_filters('timber_comment_get_meta_field_pre', null, $this->ID, $field_name, $this);
142
- if ($value === null) {
143
- $value = get_comment_meta($this->ID, $field_name, true);
144
- }
145
- $value = apply_filters('timber_comment_get_meta_field', $value, $this->ID, $field_name, $this);
146
- return $value;
147
- }
148
-
149
- /* AVATAR Stuff
150
- ======================= */
151
-
152
- /**
153
- * @return string
154
- */
155
- private function avatar_email() {
156
- $id = (int)$this->user_id;
157
- $user = get_userdata($id);
158
- if ($user) {
159
- $email = $user->user_email;
160
- } else {
161
- $email = $this->comment_author_email;
162
- }
163
- return $email;
164
- }
165
-
166
- /**
167
- * @param string $email_hash
168
- * @return string
169
- */
170
- private function avatar_host($email_hash) {
171
- if (is_ssl()) {
172
- $host = 'https://secure.gravatar.com';
173
- } else {
174
- if (!empty($email_hash)) {
175
- $host = sprintf("http://%d.gravatar.com", (hexdec($email_hash[0]) % 2));
176
- } else {
177
- $host = 'http://0.gravatar.com';
178
- }
179
- }
180
- return $host;
181
- }
182
-
183
- /**
184
- * @param string $default
185
- * @param string $email
186
- * @param string $size
187
- * @param string $host
188
- * @return string
189
- */
190
- private function avatar_default($default, $email, $size, $host) {
191
- # what if its relative.
192
- if (substr($default, 0, 1) == '/') {
193
- $default = home_url() . $default;
194
- }
195
-
196
- if (empty($default)) {
197
- $avatar_default = get_option('avatar_default');
198
- if (empty($avatar_default)) {
199
- $default = 'mystery';
200
- } else {
201
- $default = $avatar_default;
202
- }
203
- }
204
- if ('mystery' == $default) {
205
- $default = $host . '/avatar/ad516503a11cd5ca435acc9bb6523536?s=' . $size;
206
- // ad516503a11cd5ca435acc9bb6523536 == md5('unknown@gravatar.com')
207
- } else if ('blank' == $default) {
208
- $default = $email ? 'blank' : includes_url('images/blank.gif');
209
- } else if (!empty($email) && 'gravatar_default' == $default) {
210
- $default = '';
211
- } else if ('gravatar_default' == $default) {
212
- $default = $host . '/avatar/?s=' . $size;
213
- } else if (empty($email) && !strstr($default, 'http://')) {
214
- $default = $host . '/avatar/?d=' . $default . '&amp;s=' . $size;
215
- } else if (strpos($default, 'http://') === 0) {
216
- //theyre just linking to an image so don't do anything else
217
- //$default = add_query_arg( 's', $size, $default );
218
- }
219
- return $default;
220
- }
221
-
222
- /**
223
- * @param string $email
224
- * @param string $default
225
- * @param string $host
226
- * @param string $email_hash
227
- * @param string $size
228
- * @return mixed
229
- */
230
- private function avatar_out($email, $default, $host, $email_hash, $size) {
231
- $out = $host . '/avatar/' . $email_hash . '?s=' . $size . '&amp;d=' . urlencode($default);
232
- $rating = get_option('avatar_rating');
233
- if (!empty($rating)) {
234
- $out .= '&amp;r=' . $rating;
235
- }
236
- return str_replace('&#038;', '&amp;', esc_url($out));
237
- }
238
-
239
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
functions/functions/timber-core-interface.php DELETED
@@ -1,16 +0,0 @@
1
- <?php
2
-
3
- interface TimberCoreInterface {
4
-
5
- public function __call( $field, $args );
6
-
7
- public function __get( $field );
8
-
9
- /**
10
- * @return boolean
11
- */
12
- public function __isset( $field );
13
-
14
- public function meta( $key );
15
-
16
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
functions/functions/timber-core.php DELETED
@@ -1,109 +0,0 @@
1
- <?php
2
-
3
- abstract class TimberCore {
4
-
5
- public $id;
6
- public $ID;
7
- public $object_type;
8
- public $_can_edit;
9
-
10
- /**
11
- *
12
- *
13
- * @return boolean
14
- */
15
- function __isset( $field ) {
16
- if ( isset( $this->$field ) ) {
17
- return $this->$field;
18
- }
19
- return false;
20
- }
21
-
22
- /**
23
- * This is helpful for twig to return properties and methods see: https://github.com/fabpot/Twig/issues/2
24
- * @return mixed
25
- */
26
- function __call( $field, $args ) {
27
- return $this->__get( $field );
28
- }
29
-
30
- /**
31
- * This is helpful for twig to return properties and methods see: https://github.com/fabpot/Twig/issues/2
32
- *
33
- * @return mixed
34
- */
35
- function __get( $field ) {
36
- if ( isset( $this->$field ) ) {
37
- return $this->$field;
38
- }
39
- if ( $meta_value = $this->meta( $field ) ) {
40
- return $this->$field = $meta_value;
41
- }
42
- if (method_exists($this, $field)) {
43
- return $this->$field = $this->$field();
44
- }
45
- return $this->$field = false;
46
- }
47
-
48
- /**
49
- *
50
- *
51
- * @param array|object $info an object or array you want to grab data from to attach to the Timber object
52
- */
53
- function import( $info, $force = false ) {
54
- if ( is_object( $info ) ) {
55
- $info = get_object_vars( $info );
56
- }
57
- if ( is_array( $info ) ) {
58
- foreach ( $info as $key => $value ) {
59
- if ( !empty( $key ) && $force ) {
60
- $this->$key = $value;
61
- } else if ( !empty( $key ) && !method_exists($this, $key) ){
62
- $this->$key = $value;
63
- }
64
- }
65
- }
66
- }
67
-
68
-
69
- /**
70
- *
71
- *
72
- * @param string $key
73
- * @param mixed $value
74
- */
75
- function update( $key, $value ) {
76
- update_metadata( $this->object_type, $this->ID, $key, $value );
77
- }
78
-
79
- /**
80
- *
81
- *
82
- * @return bool
83
- */
84
- function can_edit() {
85
- if ( isset( $this->_can_edit ) ) {
86
- return $this->_can_edit;
87
- }
88
- $this->_can_edit = false;
89
- if ( !function_exists( 'current_user_can' ) ) {
90
- return false;
91
- }
92
- if ( current_user_can( 'edit_post', $this->ID ) ) {
93
- $this->_can_edit = true;
94
- }
95
- return $this->_can_edit;
96
- }
97
-
98
- /**
99
- *
100
- *
101
- * @return array
102
- */
103
- function get_method_values() {
104
- $ret = array();
105
- $ret['can_edit'] = $this->can_edit();
106
- return $ret;
107
- }
108
-
109
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
functions/functions/timber-function-wrapper.php DELETED
@@ -1,70 +0,0 @@
1
- <?php
2
-
3
- class TimberFunctionWrapper
4
- {
5
-
6
- private $_function;
7
- private $_args;
8
- private $_use_ob;
9
-
10
- public function __toString() {
11
- return $this->call();
12
- }
13
-
14
- /**
15
- * @param callable $function
16
- * @param array $args
17
- * @param bool $return_output_buffer
18
- */
19
- public function __construct($function, $args = array(), $return_output_buffer = false) {
20
- $this->_function = $function;
21
- $this->_args = $args;
22
- $this->_use_ob = $return_output_buffer;
23
-
24
- add_filter('get_twig', array(&$this, 'add_to_twig'));
25
- }
26
-
27
- /**
28
- * @param Twig_Environment $twig
29
- * @return Twig_Environment
30
- */
31
- public function add_to_twig($twig) {
32
- $wrapper = $this;
33
-
34
- $twig->addFunction(new Twig_SimpleFunction($this->_function, function () use ($wrapper) {
35
- return call_user_func_array(array($wrapper, 'call'), func_get_args());
36
- }));
37
-
38
- return $twig;
39
- }
40
-
41
- /**
42
- * @return string
43
- */
44
- public function call() {
45
- $args = $this->_parse_args(func_get_args(), $this->_args);
46
-
47
- if ($this->_use_ob) {
48
- return TimberHelper::ob_function($this->_function, $args);
49
- } else {
50
- return (string)call_user_func_array($this->_function, $args);
51
- }
52
- }
53
-
54
- /**
55
- * @param array $args
56
- * @param array $defaults
57
- * @return array
58
- */
59
- private function _parse_args($args, $defaults) {
60
- $_arg = reset($defaults);
61
-
62
- foreach ($args as $index => $arg) {
63
- $defaults[$index] = is_null($arg) ? $_arg : $arg;
64
- $_arg = next($defaults);
65
- }
66
-
67
- return $defaults;
68
- }
69
-
70
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
functions/functions/timber-helper.php DELETED
@@ -1,684 +0,0 @@
1
- <?php
2
-
3
- class TimberHelper {
4
-
5
- /**
6
- *
7
- *
8
- * @param string $slug Unique identifier for transient
9
- * @param callable $callback Callback that generates the data that's to be cached
10
- * @param int $transient_time (optional) Expiration of transients in seconds
11
- * @param int $lock_timeout (optional) How long to lock the transient to prevent race conditions
12
- * @param bool $force (optional) Force callback to be executed when transient is locked
13
- * @return mixed
14
- */
15
- public static function transient( $slug, $callback, $transient_time = 0, $lock_timeout = 5, $force = false ) {
16
-
17
- $enable_transients = ( $transient_time === false || ( defined( 'WP_DISABLE_TRANSIENTS' ) && WP_DISABLE_TRANSIENTS ) ) ? false : true;
18
- $data = $enable_transients ? get_transient( $slug ) : false;
19
-
20
- if ( false === $data ) {
21
-
22
- if ( $enable_transients && self::_is_transient_locked( $slug ) ) {
23
-
24
- $force = apply_filters( 'timber_force_transients', $force );
25
- $force = apply_filters( 'timber_force_transient_' . $slug, $force );
26
-
27
- if ( !$force ) {
28
- //the server is currently executing the process.
29
- //We're just gonna dump these users. Sorry!
30
- return false;
31
- }
32
-
33
- $enable_transients = false;
34
- }
35
-
36
- // lock timeout shouldn't be higher than 5 seconds, unless
37
- // remote calls with high timeouts are made here
38
- if ( $enable_transients )
39
- self::_lock_transient( $slug, $lock_timeout );
40
-
41
- $data = $callback();
42
-
43
- if ( $enable_transients ) {
44
- set_transient( $slug, $data, $transient_time );
45
- self::_unlock_transient( $slug );
46
- }
47
-
48
- }
49
-
50
- return $data;
51
-
52
- }
53
-
54
- /**
55
- * @param string $slug
56
- * @param integer $lock_timeout
57
- */
58
- public static function _lock_transient( $slug, $lock_timeout ) {
59
- set_transient( $slug . '_lock', true, $lock_timeout );
60
- }
61
-
62
- /**
63
- * @param string $slug
64
- */
65
- public static function _unlock_transient( $slug ) {
66
- delete_transient( $slug . '_lock', true );
67
- }
68
-
69
- /**
70
- * @param string $slug
71
- */
72
- public static function _is_transient_locked( $slug ) {
73
- return (bool)get_transient( $slug . '_lock' );
74
- }
75
-
76
- /* These are for measuring page render time */
77
-
78
- /**
79
- *
80
- *
81
- * @return float
82
- */
83
- public static function start_timer() {
84
- $time = microtime();
85
- $time = explode( ' ', $time );
86
- $time = $time[1] + $time[0];
87
- return $time;
88
- }
89
-
90
- /**
91
- *
92
- *
93
- * @param int $start
94
- * @return string
95
- */
96
- public static function stop_timer( $start ) {
97
- $time = microtime();
98
- $time = explode( ' ', $time );
99
- $time = $time[1] + $time[0];
100
- $finish = $time;
101
- $total_time = round( ( $finish - $start ), 4 );
102
- return $total_time . ' seconds.';
103
- }
104
-
105
- /* Function Utilities
106
- ======================== */
107
-
108
- /**
109
- *
110
- *
111
- * @param callback $function
112
- * @param array $args
113
- * @return string
114
- */
115
- public static function ob_function( $function, $args = array( null ) ) {
116
- ob_start();
117
- call_user_func_array( $function, $args );
118
- $data = ob_get_contents();
119
- ob_end_clean();
120
- return $data;
121
- }
122
-
123
- /**
124
- *
125
- *
126
- * @param string $function_name
127
- * @param integer[] $defaults
128
- * @param bool $return_output_buffer
129
- * @return TimberFunctionWrapper
130
- */
131
- public static function function_wrapper( $function_name, $defaults = array(), $return_output_buffer = false ) {
132
- return new TimberFunctionWrapper( $function_name, $defaults, $return_output_buffer );
133
- }
134
-
135
- /**
136
- *
137
- *
138
- * @param unknown $arg
139
- * @return void
140
- */
141
- public static function error_log( $arg ) {
142
- if ( !WP_DEBUG ) {
143
- return;
144
- }
145
- if ( is_object( $arg ) || is_array( $arg ) ) {
146
- $arg = print_r( $arg, true );
147
- }
148
- error_log( $arg );
149
- }
150
-
151
- /**
152
- *
153
- *
154
- * @param string $separator
155
- * @param string $seplocation
156
- * @return string
157
- */
158
- public static function get_wp_title( $separator = ' ', $seplocation = 'left' ) {
159
- $separator = apply_filters( 'timber_wp_title_seperator', $separator );
160
- return trim( wp_title( $separator, false, $seplocation ) );
161
- }
162
-
163
- /* Text Utilities
164
- ======================== */
165
-
166
- /**
167
- *
168
- *
169
- * @param string $text
170
- * @param int $num_words
171
- * @param string $more
172
- * @param string $allowed_tags
173
- * @return string
174
- */
175
- public static function trim_words( $text, $num_words = 55, $more = null, $allowed_tags = 'p a span b i br' ) {
176
- if ( null === $more ) {
177
- $more = __( '&hellip;' );
178
- }
179
- $original_text = $text;
180
- $allowed_tag_string = '';
181
- foreach ( explode( ' ', $allowed_tags ) as $tag ) {
182
- $allowed_tag_string .= '<' . $tag . '>';
183
- }
184
- $text = strip_tags( $text, $allowed_tag_string );
185
- /* translators: If your word count is based on single characters (East Asian characters),
186
- enter 'characters'. Otherwise, enter 'words'. Do not translate into your own language. */
187
- if ( 'characters' == _x( 'words', 'word count: words or characters?' ) && preg_match( '/^utf\-?8$/i', get_option( 'blog_charset' ) ) ) {
188
- $text = trim( preg_replace( "/[\n\r\t ]+/", ' ', $text ), ' ' );
189
- preg_match_all( '/./u', $text, $words_array );
190
- $words_array = array_slice( $words_array[0], 0, $num_words + 1 );
191
- $sep = '';
192
- } else {
193
- $words_array = preg_split( "/[\n\r\t ]+/", $text, $num_words + 1, PREG_SPLIT_NO_EMPTY );
194
- $sep = ' ';
195
- }
196
- if ( count( $words_array ) > $num_words ) {
197
- array_pop( $words_array );
198
- $text = implode( $sep, $words_array );
199
- $text = $text . $more;
200
- } else {
201
- $text = implode( $sep, $words_array );
202
- }
203
- $text = self::close_tags( $text );
204
- return apply_filters( 'wp_trim_words', $text, $num_words, $more, $original_text );
205
- }
206
-
207
- /**
208
- *
209
- *
210
- * @param string $html
211
- * @return string
212
- */
213
- public static function close_tags( $html ) {
214
- //put all opened tags into an array
215
- preg_match_all( '#<([a-z]+)(?: .*)?(?<![/|/ ])>#iU', $html, $result );
216
- $openedtags = $result[1];
217
- //put all closed tags into an array
218
- preg_match_all( '#</([a-z]+)>#iU', $html, $result );
219
- $closedtags = $result[1];
220
- $len_opened = count( $openedtags );
221
- // all tags are closed
222
- if ( count( $closedtags ) == $len_opened ) {
223
- return $html;
224
- }
225
- $openedtags = array_reverse( $openedtags );
226
- // close tags
227
- for ( $i = 0; $i < $len_opened; $i++ ) {
228
- if ( !in_array( $openedtags[$i], $closedtags ) ) {
229
- $html .= '</' . $openedtags[$i] . '>';
230
- } else {
231
- unset( $closedtags[array_search( $openedtags[$i], $closedtags )] );
232
- }
233
- }
234
- $html = str_replace(array('</br>','</hr>','</wbr>'), '', $html);
235
- $html = str_replace(array('<br>','<hr>','<wbr>'), array('<br />','<hr />','<wbr />'), $html);
236
- return $html;
237
- }
238
-
239
- /**
240
- *
241
- *
242
- * @param string $ret
243
- * @return string
244
- * @deprecated since 0.20.0
245
- */
246
- public static function twitterify( $ret ) {
247
- $ret = preg_replace( "#(^|[\n ])([\w]+?://[\w]+[^ \"\n\r\t< ]*)#", "\\1<a href=\"\\2\" target=\"_blank\">\\2</a>", $ret );
248
- $ret = preg_replace( "#(^|[\n ])((www|ftp)\.[^ \"\t\n\r< ]*)#", "\\1<a href=\"http://\\2\" target=\"_blank\">\\2</a>", $ret );
249
- $pattern = '#([0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.';
250
- $pattern .= '[a-wyz][a-z](fo|g|l|m|mes|o|op|pa|ro|seum|t|u|v|z)?)#i';
251
- $ret = preg_replace( $pattern, '<a href="mailto:\\1">\\1</a>', $ret );
252
- $ret = preg_replace( "/\B@(\w+)/", " <a href=\"http://www.twitter.com/\\1\" target=\"_blank\">@\\1</a>", $ret );
253
- $ret = preg_replace( "/\B#(\w+)/", " <a href=\"http://twitter.com/search?q=\\1\" target=\"_blank\">#\\1</a>", $ret );
254
- return $ret;
255
- }
256
-
257
- /* WordPress Query Utilities
258
- ======================== */
259
-
260
- /**
261
- *
262
- *
263
- * @param string $key
264
- * @param string $value
265
- * @return array|int
266
- * @deprecated since 0.20.0
267
- */
268
- public static function get_posts_by_meta( $key, $value ) {
269
- global $wpdb;
270
- $query = $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = %s AND meta_value = %s", $key, $value );
271
- $results = $wpdb->get_col( $query );
272
- $pids = array();
273
- foreach ( $results as $result ) {
274
- if ( get_post( $result ) ) {
275
- $pids[] = $result;
276
- }
277
- }
278
- if ( count( $pids ) ) {
279
- return $pids;
280
- }
281
- return 0;
282
- }
283
-
284
- /**
285
- *
286
- *
287
- * @param string $key
288
- * @param string $value
289
- * @return int
290
- * @deprecated since 0.20.0
291
- */
292
- public static function get_post_by_meta( $key, $value ) {
293
- global $wpdb;
294
- $query = $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = %s AND meta_value = %s ORDER BY post_id", $key, $value );
295
- $results = $wpdb->get_col( $query );
296
- foreach ( $results as $result ) {
297
- if ( $result && get_post( $result ) ) {
298
- return $result;
299
- }
300
- }
301
- return 0;
302
- }
303
-
304
- /**
305
- *
306
- *
307
- * @param int $ttid
308
- * @return mixed
309
- */
310
- public static function get_term_id_by_term_taxonomy_id( $ttid ) {
311
- global $wpdb;
312
- $query = $wpdb->prepare( "SELECT term_id FROM $wpdb->term_taxonomy WHERE term_taxonomy_id = %s", $ttid );
313
- return $wpdb->get_var( $query );
314
- }
315
-
316
- /* Object Utilities
317
- ======================== */
318
-
319
- /**
320
- *
321
- *
322
- * @param array $array
323
- * @param string $prop
324
- * @return void
325
- */
326
- public static function osort( &$array, $prop ) {
327
- usort( $array, function ( $a, $b ) use ( $prop ) {
328
- return $a->$prop > $b->$prop ? 1 : -1;
329
- } );
330
- }
331
-
332
- /**
333
- *
334
- *
335
- * @param array $arr
336
- * @return bool
337
- */
338
- public static function is_array_assoc( $arr ) {
339
- if ( !is_array( $arr ) ) {
340
- return false;
341
- }
342
- return (bool)count( array_filter( array_keys( $arr ), 'is_string' ) );
343
- }
344
-
345
- /**
346
- *
347
- *
348
- * @param array $array
349
- * @return stdClass
350
- */
351
- public static function array_to_object( $array ) {
352
- $obj = new stdClass;
353
- foreach ( $array as $k => $v ) {
354
- if ( is_array( $v ) ) {
355
- $obj->{$k} = self::array_to_object( $v ); //RECURSION
356
- } else {
357
- $obj->{$k} = $v;
358
- }
359
- }
360
- return $obj;
361
- }
362
-
363
- /**
364
- *
365
- *
366
- * @param array $array
367
- * @param string $key
368
- * @param mixed $value
369
- * @return bool|int
370
- */
371
- public static function get_object_index_by_property( $array, $key, $value ) {
372
- if ( is_array( $array ) ) {
373
- $i = 0;
374
- foreach ( $array as $arr ) {
375
- if ( is_array( $arr ) ) {
376
- if ( $arr[$key] == $value ) {
377
- return $i;
378
- }
379
- } else {
380
- if ( $arr->$key == $value ) {
381
- return $i;
382
- }
383
- }
384
- $i++;
385
- }
386
- }
387
- return false;
388
- }
389
-
390
- /**
391
- *
392
- *
393
- * @param array $array
394
- * @param string $key
395
- * @param mixed $value
396
- * @return array|null
397
- * @throws Exception
398
- */
399
- public static function get_object_by_property( $array, $key, $value ) {
400
- if ( is_array( $array ) ) {
401
- foreach ( $array as $arr ) {
402
- if ( $arr->$key == $value ) {
403
- return $arr;
404
- }
405
- }
406
- } else {
407
- throw new Exception( '$array is not an array, given value: ' . $array );
408
- }
409
- return null;
410
- }
411
-
412
- /**
413
- *
414
- *
415
- * @param array $array
416
- * @param int $len
417
- * @return array
418
- */
419
- public static function array_truncate( $array, $len ) {
420
- if ( sizeof( $array ) > $len ) {
421
- $array = array_splice( $array, 0, $len );
422
- }
423
- return $array;
424
- }
425
-
426
- /* Bool Utilities
427
- ======================== */
428
-
429
- /**
430
- *
431
- *
432
- * @param mixed $property
433
- * @return bool
434
- */
435
- public static function is_true( $property ) {
436
- if ( isset( $property ) ) {
437
- if ( $property == 'true' || $property == 1 || $property == '1' || $property == true ) {
438
- return true;
439
- }
440
- }
441
- return false;
442
- }
443
-
444
- /**
445
- *
446
- *
447
- * @param int $i
448
- * @return bool
449
- */
450
- public static function iseven( $i ) {
451
- return ( $i % 2 ) == 0;
452
- }
453
-
454
- /**
455
- *
456
- *
457
- * @param int $i
458
- * @return bool
459
- */
460
- public static function isodd( $i ) {
461
- return ( $i % 2 ) != 0;
462
- }
463
-
464
- /* Links, Forms, Etc. Utilities
465
- ======================== */
466
-
467
- /* this $args thing is a fucking mess, fix at some point:
468
-
469
- http://codex.wordpress.org/Function_Reference/comment_form */
470
-
471
- /**
472
- *
473
- *
474
- * @param int $post_id
475
- * @param array $args
476
- * @return string
477
- */
478
- public static function get_comment_form( $post_id = null, $args = array() ) {
479
- return self::ob_function( 'comment_form', array( $args, $post_id ) );
480
- }
481
-
482
- /**
483
- *
484
- *
485
- * @param string $args
486
- * @return array
487
- */
488
- public static function paginate_links( $args = '' ) {
489
- $defaults = array(
490
- 'base' => '%_%', // http://example.com/all_posts.php%_% : %_% is replaced by format (below)
491
- 'format' => '?page=%#%', // ?page=%#% : %#% is replaced by the page number
492
- 'total' => 1,
493
- 'current' => 0,
494
- 'show_all' => false,
495
- 'prev_next' => true,
496
- 'prev_text' => __( '&laquo; Previous' ),
497
- 'next_text' => __( 'Next &raquo;' ),
498
- 'end_size' => 1,
499
- 'mid_size' => 2,
500
- 'type' => 'array',
501
- 'add_args' => false, // array of query args to add
502
- 'add_fragment' => ''
503
- );
504
- $args = wp_parse_args( $args, $defaults );
505
- // Who knows what else people pass in $args
506
- $args['total'] = intval( (int)$args['total'] );
507
- if ( $args['total'] < 2 ) {
508
- return array();
509
- }
510
- $args['current'] = (int)$args['current'];
511
- $args['end_size'] = 0 < (int)$args['end_size'] ? (int)$args['end_size'] : 1; // Out of bounds? Make it the default.
512
- $args['mid_size'] = 0 <= (int)$args['mid_size'] ? (int)$args['mid_size'] : 2;
513
- $args['add_args'] = is_array( $args['add_args'] ) ? $args['add_args'] : false;
514
- $page_links = array();
515
- $dots = false;
516
- if ( $args['prev_next'] && $args['current'] && 1 < $args['current'] ) {
517
- $link = str_replace( '%_%', 2 == $args['current'] ? '' : $args['format'], $args['base'] );
518
- $link = str_replace( '%#%', $args['current'] - 1, $link );
519
- if ( $args['add_args'] ) {
520
- $link = add_query_arg( $args['add_args'], $link );
521
- }
522
- $link .= $args['add_fragment'];
523
- $link = untrailingslashit( $link );
524
- $page_links[] = array(
525
- 'class' => 'prev page-numbers',
526
- 'link' => esc_url( apply_filters( 'paginate_links', $link ) ),
527
- 'title' => $args['prev_text']
528
- );
529
- }
530
- for ( $n = 1; $n <= $args['total']; $n++ ) {
531
- $n_display = number_format_i18n( $n );
532
- if ( $n == $args['current'] ) {
533
- $page_links[] = array(
534
- 'class' => 'page-number page-numbers current',
535
- 'title' => $n_display,
536
- 'text' => $n_display,
537
- 'name' => $n_display,
538
- 'current' => true
539
- );
540
- $dots = true;
541
- } else {
542
- if ( $args['show_all'] || ( $n <= $args['end_size'] || ( $args['current'] && $n >= $args['current'] - $args['mid_size'] && $n <= $args['current'] + $args['mid_size'] ) || $n > $args['total'] - $args['end_size'] ) ) {
543
- $link = str_replace( '%_%', 1 == $n ? '' : $args['format'], $args['base'] );
544
- $link = str_replace( '%#%', $n, $link );
545
- $link = trailingslashit( $link ) . ltrim( $args['add_fragment'], '/' );
546
- if ( $args['add_args'] ) {
547
- $link = rtrim( add_query_arg( $args['add_args'], $link ), '/' );
548
- }
549
- $link = str_replace(' ', '+', $link);
550
- $link = untrailingslashit( $link );
551
- $page_links[] = array(
552
- 'class' => 'page-number page-numbers',
553
- 'link' => esc_url( apply_filters( 'paginate_links', $link ) ),
554
- 'title' => $n_display,
555
- 'name' => $n_display,
556
- 'current' => $args['current'] == $n
557
- );
558
- $dots = true;
559
- } elseif ( $dots && !$args['show_all'] ) {
560
- $page_links[] = array(
561
- 'class' => 'dots',
562
- 'title' => __( '&hellip;' )
563
- );
564
- $dots = false;
565
- }
566
- }
567
- }
568
- if ( $args['prev_next'] && $args['current'] && ( $args['current'] < $args['total'] || -1 == $args['total'] ) ) {
569
- $link = str_replace( '%_%', $args['format'], $args['base'] );
570
- $link = str_replace( '%#%', $args['current'] + 1, $link );
571
- if ( $args['add_args'] ) {
572
- $link = add_query_arg( $args['add_args'], $link );
573
- }
574
- $link = untrailingslashit( trailingslashit( $link ) . $args['add_fragment'] );
575
- $page_links[] = array(
576
- 'class' => 'next page-numbers',
577
- 'link' => esc_url( apply_filters( 'paginate_links', $link ) ),
578
- 'title' => $args['next_text']
579
- );
580
- }
581
- return $page_links;
582
- }
583
-
584
- /* LEGACY These have since been re-organized; but keeping linkages for backwards-compatibility */
585
-
586
- /**
587
- * @deprecated
588
- */
589
- static function get_image_path( $iid ) {
590
- return TimberImageHelper::get_image_path( $iid );
591
- }
592
-
593
- /**
594
- * @deprecated
595
- */
596
- static function get_current_url() {
597
- return TimberURLHelper::get_current_url();
598
- }
599
-
600
- /**
601
- * @deprecated
602
- */
603
- static function is_url( $url ) {
604
- return TimberURLHelper::is_url( $url );
605
- }
606
-
607
- /**
608
- * @deprecated
609
- */
610
- static function get_path_base() {
611
- return TimberURLHelper::get_path_base();
612
- }
613
-
614
- /**
615
- * @deprecated
616
- */
617
- static function get_rel_url( $url, $force = false ) {
618
- return TimberURLHelper::get_rel_url( $url, $force );
619
- }
620
-
621
- /**
622
- * @deprecated
623
- */
624
- static function is_local( $url ) {
625
- return TimberURLHelper::is_local( $url );
626
- }
627
-
628
- /**
629
- * @deprecated
630
- */
631
- static function get_full_path( $src ) {
632
- return TimberURLHelper::get_full_path( $src );
633
- }
634
-
635
- /**
636
- * @deprecated
637
- */
638
- static function get_rel_path( $src ) {
639
- return TimberURLHelper::get_rel_path( $src );
640
- }
641
-
642
- /**
643
- * @deprecated
644
- */
645
- static function remove_double_slashes( $url ) {
646
- return TimberURLHelper::remove_double_slashes( $url );
647
- }
648
-
649
- /**
650
- * @deprecated
651
- */
652
- static function prepend_to_url( $url, $path ) {
653
- return TimberURLHelper::prepend_to_url( $url, $path );
654
- }
655
-
656
- /**
657
- * @deprecated
658
- */
659
- static function preslashit( $path ) {
660
- return TimberURLHelper::preslashit( $path );
661
- }
662
-
663
- /**
664
- * @deprecated
665
- */
666
- static function is_external( $url ) {
667
- return TimberURLHelper::is_external( $url );
668
- }
669
-
670
- /**
671
- * @deprecated
672
- */
673
- static function download_url( $url, $timeout = 300 ) {
674
- return TimberURLHelper::download_url( $url, $timeout );
675
- }
676
-
677
- /**
678
- * @deprecated
679
- */
680
- static function get_params( $i = -1 ) {
681
- return TimberURLHelper::get_params( $i );
682
- }
683
-
684
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
functions/functions/timber-image-helper.php DELETED
@@ -1,613 +0,0 @@
1
- <?php
2
-
3
- require_once 'timber-image-retina-helper.php';
4
-
5
- class TimberImageHelper {
6
-
7
- static function add_actions() {
8
- add_action( 'delete_post', function ( $post_id ) {
9
- $post = get_post( $post_id );
10
- $image_types = array( 'image/jpeg', 'image/png', 'image/gif', 'image/jpg' );
11
- if ( $post->post_type == 'attachment' && in_array( $post->post_mime_type, $image_types ) ) {
12
- TimberImageHelper::delete_resized_files_from_url( $post->guid );
13
- TimberImageHelper::delete_letterboxed_files_from_url( $post->guid );
14
- }
15
- } );
16
- }
17
-
18
- /**
19
- * Adds a constant defining the path to the content directory relative to the site
20
- * for example /wp-content or /content
21
- */
22
- static function add_constants() {
23
- if ( !defined( 'WP_CONTENT_SUBDIR' ) ) {
24
- $wp_content_path = str_replace( home_url(), '', WP_CONTENT_URL );
25
- define( 'WP_CONTENT_SUBDIR', $wp_content_path );
26
- }
27
- }
28
-
29
- static function add_filters() {
30
- add_filter( 'upload_dir', function ( $arr ) {
31
- $arr['relative'] = str_replace( home_url(), '', $arr['baseurl'] );
32
- return $arr;
33
- } );
34
- }
35
-
36
- /**
37
- *
38
- *
39
- * @param string $hexstr
40
- * @return array
41
- */
42
- public static function hexrgb( $hexstr ) {
43
- if ( !strstr( $hexstr, '#' ) ) {
44
- $hexstr = '#' . $hexstr;
45
- }
46
- if ( strlen( $hexstr ) == 4 ) {
47
- $hexstr = '#' . $hexstr[1] . $hexstr[1] . $hexstr[2] . $hexstr[2] . $hexstr[3] . $hexstr[3];
48
- }
49
- $int = hexdec( $hexstr );
50
- return array( "red" => 0xFF & ( $int >> 0x10 ), "green" => 0xFF & ( $int >> 0x8 ), "blue" => 0xFF & $int );
51
- }
52
-
53
- static function delete_resized_files_from_url( $src ) {
54
- $local = TimberURLHelper::url_to_file_system( $src );
55
- self::delete_resized_files( $local );
56
- }
57
-
58
- static function delete_letterboxed_files_from_url( $src ) {
59
- $local = TimberURLHelper::url_to_file_system( $src );
60
- self::delete_letterboxed_files( $local );
61
- }
62
-
63
- /**
64
- *
65
- *
66
- * @param string $local_file
67
- */
68
- static function delete_resized_files( $local_file ) {
69
- $info = pathinfo( $local_file );
70
- $dir = $info['dirname'];
71
- $ext = $info['extension'];
72
- $filename = $info['filename'];
73
- $searcher = '/' . $filename . '-[0-9999999]*';
74
- foreach ( glob( $dir . $searcher ) as $found_file ) {
75
- $regexdir = str_replace( '/', '\/', $dir );
76
- $pattern = '/' . ( $regexdir ) . '\/' . $filename . '-[0-9]*x[0-9]*-c-[a-z]*.' . $ext . '/';
77
- $match = preg_match( $pattern, $found_file );
78
- //keeping these here so I know what the hell we're matching
79
- //$match = preg_match("/\/srv\/www\/wordpress-develop\/src\/wp-content\/uploads\/2014\/05\/$filename-[0-9]*x[0-9]*-c-[a-z]*.jpg/", $found_file);
80
- //$match = preg_match("/\/srv\/www\/wordpress-develop\/src\/wp-content\/uploads\/2014\/05\/arch-[0-9]*x[0-9]*-c-[a-z]*.jpg/", $filename);
81
- if ( $match ) {
82
- unlink( $found_file );
83
- }
84
- }
85
- }
86
-
87
- /**
88
- *
89
- *
90
- * @param string $local_file
91
- */
92
- static function delete_letterboxed_files( $local_file ) {
93
- $info = pathinfo( $local_file );
94
- $dir = $info['dirname'];
95
- $ext = $info['extension'];
96
- $filename = $info['filename'];
97
- $searcher = '/' . $filename . '-lbox-[0-9999999]*';
98
- foreach ( glob( $dir . $searcher ) as $found_file ) {
99
- $regexdir = str_replace( '/', '\/', $dir );
100
- $pattern = '/' . ( $regexdir ) . '\/' . $filename . '-lbox-[0-9]*x[0-9]*-[a-zA-Z0-9]*.' . $ext . '/';
101
- $match = preg_match( $pattern, $found_file );
102
- if ( $match ) {
103
- unlink( $found_file );
104
- }
105
- }
106
- }
107
-
108
- /**
109
- *
110
- *
111
- * @param string $src
112
- * @param int $w
113
- * @param int $h
114
- * @param string $color
115
- * @return string
116
- */
117
- public static function get_letterbox_file_rel( $src, $w, $h, $color ) {
118
- if ( !strlen( $src ) ) {
119
- return null;
120
- }
121
- $new_path = self::get_letterbox_file_name_relative_to_content( $src, $w, $h, $color );
122
- return WP_CONTENT_SUBDIR . $new_path;
123
- }
124
-
125
- /**
126
- *
127
- *
128
- * @param string $src The src of an image can be absolute, relative or server location
129
- * @return mixed|null
130
- */
131
- static function get_directory_relative_to_content( $src ) {
132
- if ( !strlen( $src ) ) {
133
- return null;
134
- }
135
- if ( !strlen( $src ) ) {
136
- return null;
137
- }
138
- $abs = false;
139
- if ( strstr( $src, 'http' ) ) {
140
- $abs = true;
141
- }
142
- $path_parts = pathinfo( $src );
143
- if ( $abs ) {
144
- $dir_relative_to_content = str_replace( WP_CONTENT_URL, '', $path_parts['dirname'] );
145
- } else {
146
- $dir_relative_to_content = str_replace( WP_CONTENT_DIR, '', $path_parts['dirname'] );
147
- $dir_relative_to_content = str_replace( WP_CONTENT_SUBDIR, '', $dir_relative_to_content );
148
- }
149
- return $dir_relative_to_content;
150
- }
151
-
152
- /**
153
- *
154
- *
155
- * @param string $src
156
- * @param int $w
157
- * @param int $h
158
- * @param string $color
159
- * @return string
160
- */
161
- static function get_letterbox_file_name_relative_to_content( $src, $w, $h, $color ) {
162
- $path_parts = pathinfo( $src );
163
- $dir_relative_to_content = self::get_directory_relative_to_content( $src );
164
- $color = str_replace( '#', '', $color );
165
- $newbase = $path_parts['filename'] . '-lbox-' . $w . 'x' . $h . '-' . $color;
166
- $new_name = $newbase . '.' . $path_parts['extension'];
167
- return $dir_relative_to_content . '/' . $new_name;
168
- }
169
-
170
- /**
171
- *
172
- *
173
- * @param string $src
174
- * @param int $w
175
- * @param int $h
176
- * @param string $color
177
- * @return string
178
- */
179
- public static function get_letterbox_file_path( $src, $w, $h, $color ) {
180
- $new_name = self::get_letterbox_file_name_relative_to_content( $src, $w, $h, $color );
181
- $new_server_path = WP_CONTENT_DIR . $new_name;
182
- $new_server_path = TimberURLHelper::remove_double_slashes( $new_server_path );
183
- return $new_server_path;
184
- }
185
-
186
- /**
187
- *
188
- *
189
- * @param string $src
190
- * @param int $w
191
- * @param int $h
192
- * @param string $crop
193
- * @return string
194
- */
195
- static function get_resize_file_rel( $src, $w, $h, $crop ) {
196
- if ( !strlen( $src ) ) {
197
- return null;
198
- }
199
- $new_path = self::get_resize_file_name_relative_to_content( $src, $w, $h, $crop );
200
- return WP_CONTENT_SUBDIR . $new_path;
201
- }
202
-
203
- /**
204
- *
205
- *
206
- * @param string $src
207
- * @param int $w
208
- * @param int $h
209
- * @param string $crop
210
- * @return string
211
- */
212
- static function get_resize_file_name_relative_to_content( $src, $w, $h, $crop ) {
213
- $path_parts = pathinfo( $src );
214
- $dir_relative_to_content = self::get_directory_relative_to_content( $src );
215
- $newbase = $path_parts['filename'] . '-' . $w . 'x' . $h . '-c-' . ( $crop ? $crop : 'f' ); // Crop will be either user named or f (false)
216
- $new_name = $newbase . '.' . $path_parts['extension'];
217
- return $dir_relative_to_content . '/' . $new_name;
218
- }
219
-
220
- /**
221
- *
222
- *
223
- * @param string $src
224
- */
225
- public static function in_uploads( $src ) {
226
- $upload_dir = wp_upload_dir();
227
- if ( strstr( $src, $upload_dir['relative'] ) ) {
228
- return true;
229
- }
230
- return false;
231
- }
232
-
233
- /**
234
- *
235
- *
236
- * @param string $src
237
- * @param int $w
238
- * @param int $h
239
- * @param string $crop
240
- * @return string
241
- */
242
- static function get_resize_file_path( $src, $w, $h, $crop ) {
243
- $new_name = self::get_resize_file_name_relative_to_content( $src, $w, $h, $crop );
244
- $new_server_path = WP_CONTENT_DIR . $new_name;
245
- $new_server_path = TimberURLHelper::remove_double_slashes( $new_server_path );
246
- return $new_server_path;
247
- }
248
-
249
- /**
250
- *
251
- *
252
- * @param int $iid
253
- * @return string
254
- */
255
- public static function get_image_path( $iid ) {
256
- $size = 'full';
257
- $src = wp_get_attachment_image_src( $iid, $size );
258
- $src = $src[0];
259
- return self::get_rel_path( $src );
260
- }
261
-
262
- /**
263
- *
264
- *
265
- * @param string $url
266
- */
267
- public static function get_server_location( $url ) {
268
- if ( strpos( $url, ABSPATH ) === 0 ) {
269
- return $url;
270
- }
271
- $upload_dir = wp_upload_dir();
272
- $abs = false;
273
- if ( strstr( $url, 'http' ) ) {
274
- $abs = true;
275
- }
276
- if ( self::in_uploads( $url ) ) {
277
- if ( $abs ) {
278
- $relative_to_uploads_dir = str_replace( $upload_dir['baseurl'], '', $url );
279
- } else {
280
- $relative_to_uploads_dir = str_replace( $upload_dir['relative'], '', $url );
281
- }
282
- return $upload_dir['basedir'] . $relative_to_uploads_dir;
283
- } else {
284
- if ( $abs ) {
285
- $relative_to_wp_content = str_replace( WP_CONTENT_URL, '', $url );
286
- } else {
287
- $relative_to_wp_content = str_replace( WP_CONTENT_SUBDIR, '', $url );
288
- }
289
- return WP_CONTENT_DIR . $relative_to_wp_content;
290
- }
291
- }
292
-
293
- /**
294
- *
295
- *
296
- * @param string $src
297
- * @param int $w
298
- * @param int $h
299
- * @param string $color
300
- * @param bool $force
301
- * @return mixed|null|string
302
- */
303
- public static function letterbox( $src, $w, $h, $color = '#000000', $force = false ) {
304
- if ( strstr( $src, 'http' ) && !strstr( $src, home_url() ) ) {
305
- $src = self::sideload_image( $src );
306
- }
307
- $abs = false;
308
- if ( strstr( $src, 'http' ) ) {
309
- $abs = true;
310
- }
311
- $new_file_rel = self::get_letterbox_file_rel( $src, $w, $h, $color );
312
- $new_server_path = self::get_letterbox_file_path( $src, $w, $h, $color );
313
- $old_server_path = self::get_server_location( $src );
314
- $old_server_path = TimberURLHelper::remove_double_slashes( $old_server_path );
315
- $new_server_path = TimberURLHelper::remove_double_slashes( $new_server_path );
316
- if ( file_exists( $new_server_path ) && !$force ) {
317
- if ( $abs ) {
318
- return untrailingslashit( home_url() ) . $new_file_rel;
319
- } else {
320
- return TimberURLHelper::preslashit( $new_file_rel );
321
- }
322
- }
323
- $bg = imagecreatetruecolor( $w, $h );
324
- $c = self::hexrgb( $color );
325
- $white = imagecolorallocate( $bg, $c['red'], $c['green'], $c['blue'] );
326
- imagefill( $bg, 0, 0, $white );
327
- $image = wp_get_image_editor( $old_server_path );
328
- if ( !is_wp_error( $image ) ) {
329
- $current_size = $image->get_size();
330
- $ow = $current_size['width'];
331
- $oh = $current_size['height'];
332
- $new_aspect = $w / $h;
333
- $old_aspect = $ow / $oh;
334
- if ( $new_aspect > $old_aspect ) {
335
- //taller than goal
336
- $h_scale = $h / $oh;
337
- $owt = $ow * $h_scale;
338
- $y = 0;
339
- $x = $w / 2 - $owt / 2;
340
- $oht = $h;
341
- $image->crop( 0, 0, $ow, $oh, $owt, $oht );
342
- } else {
343
- $w_scale = $w / $ow;
344
- $oht = $oh * $w_scale;
345
- $x = 0;
346
- $y = $h / 2 - $oht / 2;
347
- $owt = $w;
348
- $image->crop( 0, 0, $ow, $oh, $owt, $oht );
349
- }
350
- $image->save( $new_server_path );
351
- $func = 'imagecreatefromjpeg';
352
- $ext = pathinfo( $new_server_path, PATHINFO_EXTENSION );
353
- if ( $ext == 'gif' ) {
354
- $func = 'imagecreatefromgif';
355
- } else if ( $ext == 'png' ) {
356
- $func = 'imagecreatefrompng';
357
- }
358
- $image = $func( $new_server_path );
359
- imagecopy( $bg, $image, $x, $y, 0, 0, $owt, $oht );
360
- imagejpeg( $bg, $new_server_path );
361
- $new_relative_path = TimberURLHelper::get_rel_path( $new_server_path );
362
- if ( $abs ) {
363
- return home_url( $new_relative_path );
364
- }
365
- return $new_relative_path;
366
- } else {
367
- TimberHelper::error_log( $image );
368
- }
369
- return null;
370
- }
371
-
372
- /**
373
- *
374
- *
375
- * @param string $src a url or path to the image (http://example.org/wp-content/uploads/2014/image.jpg) or (/wp-content/uploads/2014/image.jpg)
376
- * @param string $bghex
377
- * @return string
378
- */
379
- public static function img_to_jpg( $src, $bghex = '#FFFFFF' ) {
380
- $path = str_replace( home_url(), '', $src );
381
- $output = str_replace( '.png', '.jpg', $path );
382
- $input_file = self::get_server_location( $path );
383
- $output_file = self::get_server_location( $output );
384
- if ( file_exists( $output_file ) ) {
385
- return $output;
386
- }
387
- $filename = $output;
388
- $input = imagecreatefrompng( $input_file );
389
- list( $width, $height ) = getimagesize( $input_file );
390
- $output = imagecreatetruecolor( $width, $height );
391
- $c = self::hexrgb( $bghex );
392
- $white = imagecolorallocate( $output, $c['red'], $c['green'], $c['blue'] );
393
- imagefilledrectangle( $output, 0, 0, $width, $height, $white );
394
- imagecopy( $output, $input, 0, 0, 0, 0, $width, $height );
395
- imagejpeg( $output, $output_file );
396
- return $filename;
397
- }
398
-
399
- /**
400
- *
401
- *
402
- * @param string $file
403
- * @return string
404
- */
405
- public static function get_sideloaded_file_loc( $file ) {
406
- $upload = wp_upload_dir();
407
- $dir = $upload['path'];
408
- $filename = $file;
409
- $file = parse_url( $file );
410
- $path_parts = pathinfo( $file['path'] );
411
- $basename = md5( $filename );
412
- $ext = 'jpg';
413
- if ( isset( $path_parts['extension'] ) ) {
414
- $ext = $path_parts['extension'];
415
- }
416
- return $dir . '/' . $basename . '.' . $ext;
417
- }
418
-
419
- /**
420
- *
421
- *
422
- * @param string $file
423
- * @return string
424
- */
425
- public static function sideload_image( $file ) {
426
- $loc = self::get_sideloaded_file_loc( $file );
427
- if ( file_exists( $loc ) ) {
428
- return TimberURLHelper::preslashit( TimberURLHelper::get_rel_path( $loc ) );
429
- }
430
- // Download file to temp location
431
- if ( !function_exists( 'download_url' ) ) {
432
- require_once ABSPATH . '/wp-admin/includes/file.php';
433
- }
434
- $tmp = download_url( $file );
435
- preg_match( '/[^\?]+\.(jpe?g|jpe|gif|png)\b/i', $file, $matches );
436
- $file_array = array();
437
- $file_array['name'] = basename( $matches[0] );
438
- $file_array['tmp_name'] = $tmp;
439
- // If error storing temporarily, unlink
440
- if ( is_wp_error( $tmp ) ) {
441
- @unlink( $file_array['tmp_name'] );
442
- $file_array['tmp_name'] = '';
443
- }
444
- // do the validation and storage stuff
445
- $locinfo = pathinfo( $loc );
446
- $file = wp_upload_bits( $locinfo['basename'], null, file_get_contents( $file_array['tmp_name'] ) );
447
- return $file['url'];
448
- }
449
-
450
- /**
451
- *
452
- *
453
- * @param string $src
454
- * @param float $multiplier
455
- */
456
- public static function retina_resize( $src, $factor = 2 ) {
457
- if ( empty( $src ) ) {
458
- return '';
459
- }
460
- $abs = false;
461
- if ( strstr( $src, 'http' ) ) {
462
- $abs = true;
463
- }
464
- if ( strstr( $src, 'http' ) && !strstr( $src, home_url() ) ) {
465
- $src = self::sideload_image( $src );
466
- }
467
- $old_server_path = self::get_server_location( $src );
468
- $new_path = TimberImageRetinaHelper::get_retina_file_rel( $src, $factor );
469
- $new_server_path = TimberImageRetinaHelper::get_retina_file_path( $src, $factor );
470
-
471
- $old_server_path = TimberURLHelper::remove_double_slashes( $old_server_path );
472
- $new_server_path = TimberURLHelper::remove_double_slashes( $new_server_path );
473
- if ( file_exists( $new_server_path ) ) {
474
- if ( !$abs ) {
475
- return TimberURLHelper::preslashit( $new_path );
476
- }
477
- return untrailingslashit( home_url() ) . $new_path;
478
- }
479
- $image = wp_get_image_editor( $old_server_path );
480
- if ( !is_wp_error( $image ) ) {
481
- $current_size = $image->get_size();
482
-
483
- $src_w = $current_size['width'];
484
- $src_h = $current_size['height'];
485
-
486
- $src_ratio = $src_w / $src_h;
487
-
488
- // Get ratios
489
- $w = $src_w * $factor;
490
- $h = $src_h * $factor;
491
- $image->crop( 0, 0, $src_w, $src_h, $w, $h );
492
- $result = $image->save( $new_server_path );
493
- return $new_path;
494
- }
495
- return $src;
496
-
497
- }
498
-
499
- /**
500
- *
501
- *
502
- * @param string $src
503
- * @param int $w
504
- * @param int $h
505
- * @param string $crop
506
- * @param bool $force_resize
507
- * @return string
508
- */
509
- public static function resize( $src, $w, $h = 0, $crop = 'default', $force_resize = false ) {
510
- if ( empty( $src ) ) {
511
- return '';
512
- }
513
- if ( strstr( $src, 'http' ) && !strstr( $src, home_url() ) ) {
514
- $src = self::sideload_image( $src );
515
- }
516
- $abs = false;
517
- if ( strstr( $src, 'http' ) ) {
518
- $abs = true;
519
- }
520
- // Sanitize crop position
521
- $allowed_crop_positions = array( 'default', 'center', 'top', 'bottom', 'left', 'right' );
522
- if ( $crop !== false && !in_array( $crop, $allowed_crop_positions ) ) {
523
- $crop = $allowed_crop_positions[0];
524
- }
525
- //oh good, it's a relative image in the uploads folder!
526
- $new_path = self::get_resize_file_rel( $src, $w, $h, $crop );
527
- $new_server_path = self::get_resize_file_path( $src, $w, $h, $crop );
528
- $old_server_path = self::get_server_location( $src );
529
- $old_server_path = TimberURLHelper::remove_double_slashes( $old_server_path );
530
- $new_server_path = TimberURLHelper::remove_double_slashes( $new_server_path );
531
- if ( file_exists( $new_server_path ) ) {
532
- if ( $force_resize ) {
533
- // Force resize - warning: will regenerate the image on every pageload, use for testing purposes only!
534
- unlink( $new_server_path );
535
- } else {
536
- if ( !$abs ) {
537
- return TimberURLHelper::preslashit( $new_path );
538
- }
539
- return untrailingslashit( home_url() ) . $new_path;
540
- }
541
- }
542
- $image = wp_get_image_editor( $old_server_path );
543
-
544
- if ( !is_wp_error( $image ) ) {
545
- $current_size = $image->get_size();
546
-
547
- $src_w = $current_size['width'];
548
- $src_h = $current_size['height'];
549
-
550
- $src_ratio = $src_w / $src_h;
551
- if ( !$h ) {
552
- $h = round( $w / $src_ratio );
553
- }
554
- if ( !$w ) {
555
- //the user wants to resize based on constant height
556
- $w = round( $h * $src_ratio );
557
- }
558
- // Get ratios
559
- $dest_ratio = $w / $h;
560
- $src_wt = $src_h * $dest_ratio;
561
- $src_ht = $src_w / $dest_ratio;
562
-
563
- if ( !$crop ) {
564
- // Always crop, to allow resizing upwards
565
- $image->crop( 0, 0, $src_w, $src_h, $w, $h );
566
- } else {
567
- //start with defaults:
568
- $src_x = $src_w / 2 - $src_wt / 2;
569
- $src_y = ( $src_h - $src_ht ) / 6;
570
- //now specific overrides based on options:
571
- if ( $crop == 'center' ) {
572
- // Get source x and y
573
- $src_x = round( ( $src_w - $src_wt ) / 2 );
574
- $src_y = round( ( $src_h - $src_ht ) / 2 );
575
- } else if ( $crop == 'top' ) {
576
- $src_y = 0;
577
- } else if ( $crop == 'bottom' ) {
578
- $src_y = $src_h - $src_ht;
579
- } else if ( $crop == 'left' ) {
580
- $src_x = 0;
581
- } else if ( $crop == 'right' ) {
582
- $src_x = $src_w - $src_wt;
583
- }
584
-
585
- // Crop the image
586
- if ( $dest_ratio > $src_ratio ) {
587
- $image->crop( 0, $src_y, $src_w, $src_ht, $w, $h );
588
- } else {
589
- $image->crop( $src_x, 0, $src_wt, $src_h, $w, $h );
590
- }
591
-
592
- }
593
- $result = $image->save( $new_server_path );
594
- if ( is_wp_error( $result ) ) {
595
- error_log( 'Error resizing image' );
596
- error_log( print_r( $result, true ) );
597
- }
598
- if ( $abs ) {
599
- return untrailingslashit( home_url() ) . $new_path;
600
- }
601
- return $new_path;
602
- } else if ( isset( $image->error_data['error_loading_image'] ) ) {
603
- TimberHelper::error_log( 'Error loading ' . $image->error_data['error_loading_image'] );
604
- } else {
605
- TimberHelper::error_log( $image );
606
- }
607
- return $src;
608
- }
609
- }
610
-
611
- TimberImageHelper::add_constants();
612
- TimberImageHelper::add_actions();
613
- TimberImageHelper::add_filters();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
functions/functions/timber-image-retina-helper.php DELETED
@@ -1,54 +0,0 @@
1
- <?php
2
-
3
- class TimberImageRetinaHelper {
4
-
5
- /**
6
- * @param string $src
7
- * @param int $w
8
- * @param int $h
9
- * @param string $crop
10
- * @return string
11
- */
12
- static function get_retina_file_path( $src, $mult = 2 ) {
13
- $new_name = self::get_retina_file_name_relative_to_content( $src, $mult );
14
- $new_server_path = WP_CONTENT_DIR . $new_name;
15
- $new_server_path = TimberURLHelper::remove_double_slashes( $new_server_path );
16
- return $new_server_path;
17
- }
18
-
19
-
20
- /**
21
- *
22
- *
23
- * @param string $src
24
- * @param int $w
25
- * @param int $h
26
- * @param string $crop
27
- * @return string
28
- */
29
- public static function get_retina_file_rel( $src, $factor = 2 ) {
30
- if ( !strlen( $src ) ) {
31
- return null;
32
- }
33
- $new_path = self::get_retina_file_name_relative_to_content( $src, $factor );
34
- return WP_CONTENT_SUBDIR . $new_path;
35
- }
36
-
37
- /**
38
- *
39
- *
40
- * @param string $src
41
- * @param int $w
42
- * @param int $h
43
- * @param string $crop
44
- * @return string
45
- */
46
- private static function get_retina_file_name_relative_to_content( $src, $mult = 2 ) {
47
- $path_parts = pathinfo( $src );
48
- $dir_relative_to_content = TimberImageHelper::get_directory_relative_to_content( $src );
49
- $newbase = $path_parts['filename'] . '@' . $mult . 'x'; // add @2x, @3x, @1.5x, etc.
50
- $new_name = $newbase . '.' . $path_parts['extension'];
51
- return $dir_relative_to_content . '/' . $new_name;
52
- }
53
-
54
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
functions/functions/timber-image.php DELETED
@@ -1,309 +0,0 @@
1
- <?php
2
-
3
- class TimberImage extends TimberPost implements TimberCoreInterface {
4
-
5
- public $_can_edit;
6
- public $_dimensions;
7
- public $abs_url;
8
- public $PostClass = 'TimberPost';
9
- public $object_type = 'image';
10
-
11
- public static $representation = 'image';
12
-
13
- public $file_loc;
14
- public $file;
15
- public $sizes = array();
16
- public $post_parent;
17
- public $caption;
18
- public $_wp_attached_file;
19
-
20
- /**
21
- * @param int $iid
22
- */
23
- function __construct($iid) {
24
- $this->init($iid);
25
- }
26
-
27
- /**
28
- * @return string
29
- */
30
- function __toString() {
31
- if ($this->get_src()) {
32
- return $this->get_src();
33
- }
34
- return '';
35
- }
36
-
37
- /**
38
- * @return mixed
39
- */
40
- function get_pathinfo() {
41
- return pathinfo($this->file);
42
- }
43
-
44
- /**
45
- * @param string $dim
46
- * @return array|int
47
- */
48
- function get_dimensions($dim = null) {
49
- if (isset($this->_dimensions)) {
50
- return $this->get_dimensions_loaded($dim);
51
- }
52
- list($width, $height) = getimagesize($this->file_loc);
53
- $this->_dimensions = array();
54
- $this->_dimensions[0] = $width;
55
- $this->_dimensions[1] = $height;
56
- return $this->get_dimensions_loaded($dim);
57
- }
58
-
59
- /**
60
- * @param string $dim
61
- * @return array|int
62
- */
63
- function get_dimensions_loaded($dim) {
64
- if ($dim == null) {
65
- return $this->_dimensions;
66
- }
67
- if ($dim == 'w' || $dim == 'width') {
68
- return $this->_dimensions[0];
69
- }
70
- if ($dim == 'h' || $dim == 'height') {
71
- return $this->_dimensions[1];
72
- }
73
- return null;
74
- }
75
-
76
- /**
77
- * @return int
78
- */
79
- function get_width() {
80
- return $this->get_dimensions('width');
81
- }
82
-
83
- /**
84
- * @return int
85
- */
86
- function get_height() {
87
- return $this->get_dimensions('height');
88
- }
89
-
90
- /**
91
- * @param string $size
92
- * @return bool|string
93
- */
94
- function get_src($size = '') {
95
- if (isset($this->abs_url)) {
96
- return $this->_maybe_secure_url($this->abs_url);
97
- }
98
-
99
- if ($size && is_string($size) && isset($this->sizes[$size])) {
100
- $image = image_downsize($this->ID, $size);
101
- return $this->_maybe_secure_url(reset($image));
102
- }
103
-
104
- if (!isset($this->file) && isset($this->_wp_attached_file)) {
105
- $this->file = $this->_wp_attached_file;
106
- }
107
-
108
- if (!isset($this->file)) {
109
- return false;
110
- }
111
-
112
- $dir = self::wp_upload_dir();
113
- $base = ($dir["baseurl"]);
114
-
115
- $src = trailingslashit($this->_maybe_secure_url($base)) . $this->file;
116
- return apply_filters('timber_image_src', $src);
117
- }
118
-
119
- private static function _maybe_secure_url($url) {
120
- if (is_ssl() && strpos($url, 'https') !== 0 && strpos($url, 'http') === 0) {
121
- $url = 'https' . substr($url, strlen('http'));
122
- }
123
-
124
- return $url;
125
- }
126
-
127
- public static function wp_upload_dir() {
128
- static $wp_upload_dir = false;
129
-
130
- if (!$wp_upload_dir) {
131
- $wp_upload_dir = wp_upload_dir();
132
- }
133
-
134
- return $wp_upload_dir;
135
- }
136
-
137
- /**
138
- * @return string
139
- */
140
- function get_path() {
141
- if (strlen($this->abs_url)) {
142
- return $this->abs_url;
143
- }
144
- return get_permalink($this->ID);
145
- }
146
-
147
- /**
148
- * @return bool|TimberImage
149
- */
150
- function get_parent() {
151
- if (!$this->post_parent) {
152
- return false;
153
- }
154
- return new $this->PostClass($this->post_parent);
155
- }
156
-
157
- function get_alt() {
158
- $alt = trim(strip_tags(get_post_meta($this->ID, '_wp_attachment_image_alt', true)));
159
- return $alt;
160
- }
161
-
162
-
163
- /**
164
- * @param int $iid
165
- */
166
- function init( $iid = false ) {
167
- if ( !is_numeric( $iid ) && is_string( $iid ) ) {
168
- if (strstr($iid, '://')) {
169
- $this->init_with_url($iid);
170
- return;
171
- }
172
- if ( strstr($iid, ABSPATH) ) {
173
- $this->init_with_file_path($iid);
174
- return;
175
- }
176
- if (strstr(strtolower($iid), '.jpg')) {
177
- $this->init_with_relative_path($iid);
178
- return;
179
- }
180
- }
181
-
182
- $image_info = $this->get_image_info($iid);
183
-
184
- $this->import($image_info);
185
- $basedir = self::wp_upload_dir();
186
- $basedir = $basedir['basedir'];
187
- if (isset($this->file)) {
188
- $this->file_loc = $basedir . DIRECTORY_SEPARATOR . $this->file;
189
- } else if (isset($this->_wp_attached_file)) {
190
- $this->file = reset($this->_wp_attached_file);
191
- $this->file_loc = $basedir . DIRECTORY_SEPARATOR . $this->file;
192
- }
193
- if (isset($image_info['id'])) {
194
- $this->ID = $image_info['id'];
195
- } else if (is_numeric($iid)) {
196
- $this->ID = $iid;
197
- }
198
- if (isset($this->ID)) {
199
- $custom = get_post_custom($this->ID);
200
- foreach ($custom as $key => $value) {
201
- $this->$key = $value[0];
202
- }
203
- } else {
204
- if (is_array($iid)) {
205
- TimberHelper::error_log('Not able to init in TimberImage with iid=');
206
- TimberHelper::error_log($iid);
207
- } else {
208
- TimberHelper::error_log('Not able to init in TimberImage with iid=' . $iid);
209
- }
210
- }
211
- }
212
-
213
- private function get_image_info( $iid ) {
214
- $image_info = $iid;
215
- if (is_numeric($iid)) {
216
- $image_info = wp_get_attachment_metadata($iid);
217
- if (!is_array($image_info)) {
218
- $image_info = array();
219
- }
220
- $image_custom = get_post_custom($iid);
221
- $basic = get_post($iid);
222
- if ($basic) {
223
- if (isset($basic->post_excerpt)) {
224
- $this->caption = $basic->post_excerpt;
225
- }
226
- $image_custom = array_merge($image_custom, get_object_vars($basic));
227
- }
228
- return array_merge($image_info, $image_custom);
229
- }
230
- if (is_array($image_info) && isset($image_info['image'])) {
231
- return $image_info['image'];
232
- }
233
- if (is_object($image_info)) {
234
- return get_object_vars($image_info);
235
- }
236
- return $iid;
237
- }
238
-
239
- private function init_with_relative_path( $relative_path ) {
240
- $this->abs_url = home_url( $relative_path );
241
- $file_path = TimberURLHelper::get_full_path( $relative_path );
242
- $this->file_loc = $file_path;
243
- $this->file = $file_path;
244
- }
245
-
246
- private function init_with_file_path( $file_path ) {
247
- $url = TimberURLHelper::file_system_to_url( $file_path );
248
- $this->abs_url = $url;
249
- $this->file_loc = $file_path;
250
- $this->file = $file_path;
251
- }
252
-
253
- /**
254
- * @param string $url
255
- */
256
- private function init_with_url($url) {
257
- $this->abs_url = $url;
258
- if (TimberURLHelper::is_local($url)) {
259
- $this->file = ABSPATH . TimberURLHelper::get_rel_url($url);
260
- $this->file_loc = ABSPATH . TimberURLHelper::get_rel_url($url);
261
- }
262
- }
263
-
264
- /**
265
- * @deprecated
266
- * @return string
267
- */
268
- function get_url() {
269
- return $this->get_src();
270
- }
271
-
272
- /* Alias */
273
-
274
- /**
275
- * @return float
276
- */
277
- public function aspect() {
278
- $w = intval($this->width());
279
- $h = intval($this->height());
280
- return $w / $h;
281
- }
282
-
283
- /**
284
- * @return int
285
- */
286
- public function height() {
287
- return $this->get_height();
288
- }
289
-
290
- /**
291
- * @param string $size
292
- * @return bool|string
293
- */
294
- public function src($size = '') {
295
- return $this->get_src($size);
296
- }
297
-
298
- /**
299
- * @return int
300
- */
301
- public function width() {
302
- return $this->get_width();
303
- }
304
-
305
- public function alt() {
306
- return $this->get_alt();
307
- }
308
-
309
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
functions/functions/timber-loader.php DELETED
@@ -1,410 +0,0 @@
1
- <?php
2
-
3
- class TimberLoader {
4
-
5
- const CACHEGROUP = 'timberloader';
6
-
7
- const TRANS_KEY_LEN = 50;
8
-
9
- const CACHE_NONE = 'none';
10
- const CACHE_OBJECT = 'cache';
11
- const CACHE_TRANSIENT = 'transient';
12
- const CACHE_SITE_TRANSIENT = 'site-transient';
13
- const CACHE_USE_DEFAULT = 'default';
14
-
15
- public static $cache_modes = array(
16
- self::CACHE_NONE,
17
- self::CACHE_OBJECT,
18
- self::CACHE_TRANSIENT,
19
- self::CACHE_SITE_TRANSIENT
20
- );
21
-
22
- protected $cache_mode = self::CACHE_TRANSIENT;
23
-
24
- public $locations;
25
-
26
- /**
27
- * @param bool $caller
28
- */
29
- function __construct($caller = false) {
30
- $this->locations = $this->get_locations($caller);
31
- $this->cache_mode = apply_filters('timber_cache_mode', $this->cache_mode);
32
- }
33
-
34
- /**
35
- * @param string $file
36
- * @param array $data
37
- * @param bool $expires
38
- * @param string $cache_mode
39
- * @return bool|string
40
- */
41
- function render($file, $data = null, $expires = false, $cache_mode = self::CACHE_USE_DEFAULT) {
42
- // Different $expires if user is anonymous or logged in
43
- if (is_array($expires)) {
44
- if (is_user_logged_in() && isset($expires[1])) {
45
- $expires = $expires[1];
46
- } else {
47
- $expires = $expires[0];
48
- }
49
- }
50
-
51
- $key = null;
52
- $output = false;
53
- if (false !== $expires) {
54
- ksort($data);
55
- $key = md5($file . json_encode($data));
56
- $output = $this->get_cache($key, self::CACHEGROUP, $cache_mode);
57
- }
58
-
59
- if (false === $output || null === $output) {
60
- $twig = $this->get_twig();
61
- if (strlen($file)) {
62
- $loader = $this->get_loader();
63
- $result = $loader->getCacheKey($file);
64
- do_action('timber_loader_render_file', $result);
65
- }
66
- $data = apply_filters('timber_loader_render_data', $data);
67
- $output = $twig->render($file, $data);
68
- }
69
-
70
- if (false !== $output && false !== $expires && null !== $key) {
71
- $this->set_cache($key, $output, self::CACHEGROUP, $expires, $cache_mode);
72
- }
73
-
74
- return apply_filters('timber_output', $output);
75
- }
76
-
77
- /**
78
- * @param array $filenames
79
- * @return bool
80
- */
81
- function choose_template($filenames) {
82
- if (is_array($filenames)) {
83
- /* its an array so we have to figure out which one the dev wants */
84
- foreach ($filenames as $filename) {
85
- if ($this->template_exists($filename)) {
86
- return $filename;
87
- }
88
- }
89
- return false;
90
- }
91
- return $filenames;
92
- }
93
-
94
- /**
95
- * @param string $file
96
- * @return bool
97
- */
98
- function template_exists($file) {
99
- foreach ($this->locations as $dir) {
100
- $look_for = trailingslashit($dir) . $file;
101
- if (file_exists($look_for)) {
102
- return true;
103
- }
104
- }
105
- return false;
106
- }
107
-
108
- /**
109
- * @return array
110
- */
111
- function get_locations_theme() {
112
- $theme_locs = array();
113
- $child_loc = get_stylesheet_directory();
114
- $parent_loc = get_template_directory();
115
- if (DIRECTORY_SEPARATOR == '\\') {
116
- $child_loc = str_replace('/', '\\', $child_loc);
117
- $parent_loc = str_replace('/', '\\', $parent_loc);
118
- }
119
- $theme_locs[] = $child_loc;
120
- foreach ($this->get_locations_theme_dir() as $dirname) {
121
- $theme_locs[] = trailingslashit($child_loc) . trailingslashit($dirname);
122
- }
123
- if ($child_loc != $parent_loc) {
124
- $theme_locs[] = $parent_loc;
125
- foreach ($this->get_locations_theme_dir() as $dirname) {
126
- $theme_locs[] = trailingslashit($parent_loc) . trailingslashit($dirname);
127
- }
128
- }
129
- //now make sure theres a trailing slash on everything
130
- $theme_locs = array_map('trailingslashit', $theme_locs);
131
- return $theme_locs;
132
- }
133
-
134
- /**
135
- * returns an array of the directory inside themes that holds twig files
136
- * @return string[] the names of directores, ie: array('templats', 'views');
137
- */
138
- private function get_locations_theme_dir() {
139
- if (is_string(Timber::$dirname)) {
140
- return array(Timber::$dirname);
141
- }
142
- return Timber::$dirname;
143
- }
144
-
145
- /**
146
- * @return array
147
- */
148
- function get_locations_user() {
149
- $locs = array();
150
- if (isset(Timber::$locations)) {
151
- if (is_string(Timber::$locations)) {
152
- Timber::$locations = array(Timber::$locations);
153
- }
154
- foreach (Timber::$locations as $tloc) {
155
- $tloc = realpath($tloc);
156
- if (is_dir($tloc)) {
157
- $locs[] = $tloc;
158
- }
159
- }
160
- }
161
- return $locs;
162
- }
163
-
164
- /**
165
- * @param bool $caller
166
- * @return array
167
- */
168
- function get_locations_caller($caller = false) {
169
- $locs = array();
170
- if ($caller && is_string($caller)) {
171
- $caller = trailingslashit($caller);
172
- if (is_dir($caller)) {
173
- $locs[] = $caller;
174
- }
175
- foreach ($this->get_locations_theme_dir() as $dirname) {
176
- $caller_sub = $caller . trailingslashit($dirname);
177
- if (is_dir($caller_sub)) {
178
- $locs[] = $caller_sub;
179
- }
180
- }
181
- }
182
- return $locs;
183
- }
184
-
185
- /**
186
- * @param bool $caller
187
- * @return array
188
- */
189
- function get_locations($caller = false) {
190
- //prioirty: user locations, caller (but not theme), child theme, parent theme, caller
191
- $locs = array();
192
- $locs = array_merge($locs, $this->get_locations_user());
193
- $locs = array_merge($locs, $this->get_locations_caller($caller));
194
- //remove themes from caller
195
- $locs = array_diff($locs, $this->get_locations_theme());
196
- $locs = array_merge($locs, $this->get_locations_theme());
197
- $locs = array_merge($locs, $this->get_locations_caller($caller));
198
- $locs = array_unique($locs);
199
- $locs = apply_filters('timber_locations', $locs);
200
- return $locs;
201
- }
202
-
203
- /**
204
- * @return Twig_Loader_Filesystem
205
- */
206
- function get_loader() {
207
- $paths = array();
208
- foreach ($this->locations as $loc) {
209
- $loc = realpath($loc);
210
- if (is_dir($loc)) {
211
- $loc = realpath($loc);
212
- $paths[] = $loc;
213
- } else {
214
- //error_log($loc.' is not a directory');
215
- }
216
- }
217
- if (!ini_get('open_basedir')) {
218
- $paths[] = '/';
219
- } else {
220
- $paths[] = ABSPATH;
221
- }
222
- $loader = new Twig_Loader_Filesystem($paths);
223
- return $loader;
224
- }
225
-
226
- /**
227
- * @return Twig_Environment
228
- */
229
- function get_twig() {
230
- $loader = $this->get_loader();
231
- $params = array('debug' => WP_DEBUG, 'autoescape' => false);
232
- if (isset(Timber::$autoescape)) {
233
- $params['autoescape'] = Timber::$autoescape;
234
- }
235
- if (Timber::$cache == true) {
236
- Timber::$twig_cache = true;
237
- }
238
- if (Timber::$twig_cache) {
239
- $twig_cache_loc = TIMBER_LOC . '/cache/twig';
240
- if (!file_exists($twig_cache_loc)) {
241
- mkdir($twig_cache_loc, 0777, true);
242
- }
243
- $params['cache'] = $twig_cache_loc;
244
- }
245
- $twig = new Twig_Environment($loader, $params);
246
- if (WP_DEBUG) {
247
- $twig->addExtension(new Twig_Extension_Debug());
248
- }
249
- $twig->addExtension($this->_get_cache_extension());
250
-
251
- $twig = apply_filters('twig_apply_filters', $twig);
252
- return $twig;
253
- }
254
-
255
- public function clear_cache_timber($cache_mode = self::CACHE_USE_DEFAULT){
256
- //_transient_timberloader
257
- $object_cache = false;
258
- if (isset($GLOBALS['wp_object_cache']) && is_object($GLOBALS['wp_object_cache'])) {
259
- $object_cache = true;
260
- }
261
- $cache_mode = $this->_get_cache_mode($cache_mode);
262
- if (self::CACHE_TRANSIENT === $cache_mode) {
263
- global $wpdb;
264
- $query = $wpdb->prepare("DELETE FROM $wpdb->options WHERE option_name LIKE '%s'", '_transient_timberloader_%');
265
- $wpdb->query( $query );
266
- return true;
267
- } else if (self::CACHE_SITE_TRANSIENT === $cache_mode) {
268
- global $wpdb;
269
- $query = $wpdb->prepare("DELETE FROM $wpdb->options WHERE option_name LIKE '%s'", '_transient_timberloader_%');
270
- $wpdb->query( $query );
271
- return true;
272
- } else if (self::CACHE_OBJECT === $cache_mode && $object_cache) {
273
- global $wp_object_cache;
274
- if (isset($wp_object_cache->cache[self::CACHEGROUP])){
275
- unset($wp_object_cache->cache[self::CACHEGROUP]);
276
- return true;
277
- }
278
- }
279
- return false;
280
- }
281
-
282
- public function clear_cache_twig() {
283
- $twig = $this->get_twig();
284
- $twig->clearCacheFiles();
285
- $cache = $twig->getCache();
286
- if ($cache){
287
- self::rrmdir($twig->getCache());
288
- return true;
289
- }
290
- return false;
291
- }
292
-
293
- /**
294
- * @param string|false $dirPath
295
- */
296
- public static function rrmdir($dirPath) {
297
- if (! is_dir($dirPath)) {
298
- throw new InvalidArgumentException("$dirPath must be a directory");
299
- }
300
- if (substr($dirPath, strlen($dirPath) - 1, 1) != '/') {
301
- $dirPath .= '/';
302
- }
303
- $files = glob($dirPath . '*', GLOB_MARK);
304
- foreach ($files as $file) {
305
- if (is_dir($file)) {
306
- self::rrmdir($file);
307
- } else {
308
- unlink($file);
309
- }
310
- }
311
- rmdir($dirPath);
312
- }
313
-
314
- /**
315
- * @return \Asm89\Twig\CacheExtension\Extension
316
- */
317
- private function _get_cache_extension() {
318
- $loader_loc = trailingslashit(TIMBER_LOC) . 'functions/cache/loader.php';
319
- require_once($loader_loc);
320
- TimberCache_Loader::register();
321
-
322
- $key_generator = new \Timber\Cache\KeyGenerator();
323
- $cache_provider = new \Timber\Cache\WPObjectCacheAdapter($this);
324
- $cache_strategy = new \Asm89\Twig\CacheExtension\CacheStrategy\GenerationalCacheStrategy($cache_provider, $key_generator);
325
- $cache_extension = new \Asm89\Twig\CacheExtension\Extension($cache_strategy);
326
-
327
- return $cache_extension;
328
- }
329
-
330
- /**
331
- * @param string $key
332
- * @param string $group
333
- * @param string $cache_mode
334
- * @return bool
335
- */
336
- public function get_cache($key, $group = self::CACHEGROUP, $cache_mode = self::CACHE_USE_DEFAULT) {
337
- $object_cache = false;
338
-
339
- if (isset($GLOBALS['wp_object_cache']) && is_object($GLOBALS['wp_object_cache'])) {
340
- $object_cache = true;
341
- }
342
-
343
- $cache_mode = $this->_get_cache_mode($cache_mode);
344
-
345
- $value = false;
346
-
347
- $trans_key = substr($group . '_' . $key, 0, self::TRANS_KEY_LEN);
348
- if (self::CACHE_TRANSIENT === $cache_mode)
349
- $value = get_transient($trans_key);
350
-
351
- elseif (self::CACHE_SITE_TRANSIENT === $cache_mode)
352
- $value = get_site_transient($trans_key);
353
-
354
- elseif (self::CACHE_OBJECT === $cache_mode && $object_cache)
355
- $value = wp_cache_get($key, $group);
356
-
357
- return $value;
358
- }
359
-
360
- /**
361
- * @param string $key
362
- * @param string|boolean $value
363
- * @param string $group
364
- * @param int $expires
365
- * @param string $cache_mode
366
- * @return string|boolean
367
- */
368
- public function set_cache($key, $value, $group = self::CACHEGROUP, $expires = 0, $cache_mode = self::CACHE_USE_DEFAULT) {
369
- $object_cache = false;
370
-
371
- if (isset($GLOBALS['wp_object_cache']) && is_object($GLOBALS['wp_object_cache'])) {
372
- $object_cache = true;
373
- }
374
-
375
- if ((int)$expires < 1)
376
- $expires = 0;
377
-
378
- $cache_mode = self::_get_cache_mode($cache_mode);
379
- $trans_key = substr($group . '_' . $key, 0, self::TRANS_KEY_LEN);
380
-
381
- if (self::CACHE_TRANSIENT === $cache_mode)
382
- set_transient($trans_key, $value, $expires);
383
-
384
- elseif (self::CACHE_SITE_TRANSIENT === $cache_mode)
385
- set_site_transient($trans_key, $value, $expires);
386
-
387
- elseif (self::CACHE_OBJECT === $cache_mode && $object_cache)
388
- wp_cache_set($key, $value, $group, $expires);
389
-
390
- return $value;
391
- }
392
-
393
- /**
394
- * @param string $cache_mode
395
- * @return string
396
- */
397
- private function _get_cache_mode($cache_mode) {
398
- if (empty($cache_mode) || self::CACHE_USE_DEFAULT === $cache_mode) {
399
- $cache_mode = $this->cache_mode;
400
- }
401
-
402
- // Fallback if self::$cache_mode did not get a valid value
403
- if (!in_array($cache_mode, self::$cache_modes)) {
404
- $cache_mode = self::CACHE_OBJECT;
405
- }
406
-
407
- return $cache_mode;
408
- }
409
-
410
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
functions/functions/timber-menu-item.php DELETED
@@ -1,234 +0,0 @@
1
- <?php
2
-
3
- class TimberMenuItem extends TimberCore implements TimberCoreInterface {
4
-
5
- public $children;
6
- public $has_child_class = false;
7
-
8
- public $classes = array();
9
- public $class = '';
10
- public $post_name;
11
- public $type;
12
-
13
- public $PostClass = 'TimberPost';
14
-
15
- private $menu_object;
16
- private $parent_object;
17
-
18
- /**
19
- *
20
- *
21
- * @param array|object $data
22
- */
23
- function __construct( $data ) {
24
- $this->import( $data );
25
- $this->import_classes( $data );
26
- if ( isset( $this->name ) ) {
27
- $this->_name = $this->name;
28
- }
29
- $this->name = $this->name();
30
- $this->add_class( 'menu-item-' . $this->ID );
31
- $this->menu_object = $data;
32
- if ( isset( $this->url ) && $this->url ) {
33
- $this->url = TimberURLHelper::remove_trailing_slash( $this->url );
34
- }
35
- }
36
-
37
- function __toString() {
38
- return $this->name();
39
- }
40
-
41
- /**
42
- *
43
- *
44
- * @param string $class_name
45
- */
46
- function add_class( $class_name ) {
47
- $this->classes[] = $class_name;
48
- $this->class .= ' ' . $class_name;
49
- }
50
-
51
- /**
52
- *
53
- *
54
- * @return string
55
- */
56
- function name() {
57
- if ( isset( $this->title ) ) {
58
- return $this->title;
59
- }
60
- if ( isset( $this->_name ) ) {
61
- return $this->_name;
62
- }
63
- return '';
64
- }
65
-
66
- /**
67
- *
68
- *
69
- * @return string
70
- */
71
- function slug() {
72
- if ( !isset( $this->parent_object ) ) {
73
- $this->parent_object = $this->get_parent_object();
74
- }
75
- if ( isset( $this->parent_object->post_name ) && $this->parent_object->post_name ) {
76
- return $this->parent_object->post_name;
77
- }
78
- return $this->post_name;
79
- }
80
-
81
- function get_parent_object() {
82
- if ( isset( $this->_menu_item_object_id ) ) {
83
- return new $this->PostClass( $this->_menu_item_object_id );
84
- }
85
- }
86
-
87
- /**
88
- *
89
- *
90
- * @return string
91
- */
92
- function get_link() {
93
- if ( !isset( $this->url ) || !$this->url ) {
94
- if ( isset( $this->_menu_item_type ) && $this->_menu_item_type == 'custom' ) {
95
- $this->url = $this->_menu_item_url;
96
- } else if ( isset( $this->menu_object ) && method_exists( $this->menu_object, 'get_link' ) ) {
97
- $this->url = $this->menu_object->get_link();
98
- }
99
- }
100
- return TimberURLHelper::remove_trailing_slash( $this->url );
101
- }
102
-
103
- /**
104
- *
105
- *
106
- * @return string
107
- */
108
- function get_path() {
109
- return TimberURLHelper::remove_trailing_slash( TimberURLHelper::get_rel_url( $this->get_link() ) );
110
- }
111
-
112
- /**
113
- *
114
- *
115
- * @param TimberMenuItem $item
116
- */
117
- function add_child( $item ) {
118
- if ( !$this->has_child_class ) {
119
- $this->add_class( 'menu-item-has-children' );
120
- $this->has_child_class = true;
121
- }
122
- if ( !isset( $this->children ) ) {
123
- $this->children = array();
124
- }
125
- $this->children[] = $item;
126
- }
127
-
128
- /**
129
- *
130
- *
131
- * @param object $data
132
- */
133
- function import_classes( $data ) {
134
- $this->classes = array_merge($this->classes, $data->classes);
135
- $this->classes = array_unique($this->classes);
136
- $this->class = trim( implode( ' ', $this->classes ) );
137
- }
138
-
139
- /**
140
- *
141
- *
142
- * @return array|bool
143
- */
144
- function get_children() {
145
- if ( isset( $this->children ) ) {
146
- return $this->children;
147
- }
148
- return false;
149
- }
150
-
151
- /**
152
- *
153
- *
154
- * @return bool
155
- */
156
- function is_external() {
157
- if ( $this->type != 'custom' ) {
158
- return false;
159
- }
160
- return TimberURLHelper::is_external( $this->url );
161
- }
162
-
163
- public function meta( $key ) {
164
- if ( is_object( $this->menu_object ) && method_exists( $this->menu_object, 'meta' ) ) {
165
- return $this->menu_object->meta( $key );
166
- }
167
- if ( isset( $this->$key ) ) {
168
- return $this->$key;
169
- }
170
- }
171
-
172
- /* Aliases */
173
-
174
- /**
175
- *
176
- *
177
- * @return array|bool
178
- */
179
- public function children() {
180
- return $this->get_children();
181
- }
182
-
183
- /**
184
- *
185
- *
186
- * @return bool
187
- */
188
- public function external() {
189
- return $this->is_external();
190
- }
191
-
192
- /**
193
- *
194
- *
195
- * @return string
196
- */
197
- public function link() {
198
- return $this->get_link();
199
- }
200
-
201
- /**
202
- *
203
- *
204
- * @return string
205
- */
206
- public function path() {
207
- return $this->get_path();
208
- }
209
-
210
- /**
211
- *
212
- *
213
- * @return string
214
- */
215
- public function permalink() {
216
- return $this->get_link();
217
- }
218
-
219
- /**
220
- *
221
- *
222
- * @return string
223
- */
224
- public function get_permalink() {
225
- return $this->get_link();
226
- }
227
-
228
- public function title() {
229
- if (isset($this->__title)){
230
- return $this->__title;
231
- }
232
- }
233
-
234
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
functions/functions/timber-menu.php DELETED
@@ -1,174 +0,0 @@
1
- <?php
2
-
3
- class TimberMenu extends TimberCore {
4
-
5
- public $MenuItemClass = 'TimberMenuItem';
6
- public $PostClass = 'TimberPost';
7
-
8
- public $items = null;
9
- public $id = null;
10
- public $ID = null;
11
- public $name = null;
12
- public $term_id;
13
- public $title;
14
-
15
- /**
16
- * @param int $slug
17
- */
18
- function __construct($slug = 0) {
19
- $locations = get_nav_menu_locations();
20
- if ($slug != 0 && is_numeric($slug)) {
21
- $menu_id = $slug;
22
- } else if (is_array($locations) && count($locations)) {
23
- $menu_id = $this->get_menu_id_from_locations($slug, $locations);
24
- } else if ($slug === false) {
25
- $menu_id = false;
26
- } else {
27
- $menu_id = $this->get_menu_id_from_terms($slug);
28
- }
29
- if ($menu_id) {
30
- $this->init($menu_id);
31
- } else {
32
- $this->init_as_page_menu();
33
- //TimberHelper::error_log("Sorry, the menu you were looking for wasn't found ('" . $slug . "'). Here's what Timber did find:");
34
- }
35
- return null;
36
- }
37
-
38
- /**
39
- * @param int $menu_id
40
- */
41
- private function init($menu_id) {
42
- $menu = wp_get_nav_menu_items($menu_id);
43
- if ($menu) {
44
- _wp_menu_item_classes_by_context($menu);
45
- if (is_array($menu)){
46
- $menu = self::order_children($menu);
47
- }
48
- $this->items = $menu;
49
- $menu_info = wp_get_nav_menu_object($menu_id);
50
- $this->import($menu_info);
51
- $this->ID = $this->term_id;
52
- $this->id = $this->term_id;
53
- $this->title = $this->name;
54
- }
55
- }
56
-
57
- private function init_as_page_menu() {
58
- $menu = get_pages();
59
- if ($menu) {
60
- foreach($menu as $mi) {
61
- $mi->__title = $mi->post_title;
62
- }
63
- _wp_menu_item_classes_by_context($menu);
64
- if (is_array($menu)){
65
- $menu = self::order_children($menu);
66
- }
67
- $this->items = $menu;
68
- }
69
- }
70
-
71
- /**
72
- * @param string $slug
73
- * @param array $locations
74
- * @return integer
75
- */
76
- private function get_menu_id_from_locations($slug, $locations) {
77
- if ($slug === 0) {
78
- $slug = $this->get_menu_id_from_terms($slug);
79
- }
80
- if (is_numeric($slug)) {
81
- $slug = array_search($slug, $locations);
82
- }
83
- if (isset($locations[$slug])) {
84
- return $locations[$slug];
85
- }
86
- return null;
87
- }
88
-
89
- /**
90
- * @param int $slug
91
- * @return int
92
- */
93
- private function get_menu_id_from_terms($slug = 0) {
94
- if (!is_numeric($slug) && is_string($slug)) {
95
- //we have a string so lets search for that
96
- $menu_id = get_term_by('slug', $slug, 'nav_menu');
97
- if ($menu_id) {
98
- return $menu_id;
99
- }
100
- $menu_id = get_term_by('name', $slug, 'nav_menu');
101
- if ($menu_id) {
102
- return $menu_id;
103
- }
104
- }
105
- $menus = get_terms('nav_menu', array('hide_empty' => true));
106
- if (is_array($menus) && count($menus)) {
107
- if (isset($menus[0]->term_id)) {
108
- return $menus[0]->term_id;
109
- }
110
- }
111
- return 0;
112
- }
113
-
114
- /**
115
- * @param array $menu_items
116
- * @param int $parent_id
117
- * @return TimberMenuItem|null
118
- */
119
- function find_parent_item_in_menu($menu_items, $parent_id) {
120
- foreach ($menu_items as &$item) {
121
- if ($item->ID == $parent_id) {
122
- return $item;
123
- }
124
- }
125
- return null;
126
- }
127
-
128
- /**
129
- * @param array $items
130
- * @return array
131
- */
132
- function order_children($items) {
133
- $index = array();
134
- $menu = array();
135
- foreach ($items as $item) {
136
- if (isset($item->title)) {
137
- //items from wp can come with a $title property which conflicts with methods
138
- $item->__title = $item->title;
139
- unset($item->title);
140
- }
141
- if(isset($item->ID)){
142
- if (is_object($item) && get_class($item) == 'WP_Post'){
143
- $old_menu_item = $item;
144
- $item = new $this->PostClass($item);
145
- }
146
- $menu_item = new $this->MenuItemClass($item);
147
- if (isset($old_menu_item)){
148
- $menu_item->import_classes($old_menu_item);
149
- }
150
- $index[$item->ID] = $menu_item;
151
- }
152
- }
153
- foreach ($index as $item) {
154
- if (isset($item->menu_item_parent) && $item->menu_item_parent && isset($index[$item->menu_item_parent])) {
155
- $index[$item->menu_item_parent]->add_child($item);
156
- } else {
157
- $menu[] = $item;
158
- }
159
- }
160
- return $menu;
161
- }
162
-
163
- /**
164
- * @return array
165
- */
166
- function get_items() {
167
- if (is_array($this->items)) {
168
- return $this->items;
169
- }
170
- return array();
171
- }
172
- }
173
-
174
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
functions/functions/timber-page.php DELETED
@@ -1,6 +0,0 @@
1
- <?php
2
-
3
- class TimberPage extends TimberPost
4
- {
5
-
6
- }
 
 
 
 
 
 
functions/functions/timber-post-getter.php DELETED
@@ -1,137 +0,0 @@
1
- <?php
2
-
3
- class TimberPostGetter {
4
-
5
- /**
6
- * @param mixed $query
7
- * @param string $PostClass
8
- * @return array|bool|null
9
- */
10
- static function get_post($query = false, $PostClass = 'TimberPost') {
11
- $posts = self::get_posts( $query, $PostClass );
12
- if ( $post = reset($posts ) ) {
13
- return $post;
14
- }
15
- return false;
16
- }
17
-
18
- static function get_posts( $query = false, $PostClass = 'TimberPost', $return_collection = false ) {
19
- $posts = self::query_posts( $query, $PostClass );
20
- return apply_filters('timber_post_getter_get_posts', $posts->get_posts( $return_collection ));
21
- }
22
-
23
- static function query_post( $query = false, $PostClass = 'TimberPost' ) {
24
- $posts = self::query_posts( $query, $PostClass );
25
- if ( $post = $posts->current() ) {
26
- return $post;
27
- }
28
- return false;
29
- }
30
-
31
- /**
32
- * @param mixed $query
33
- * @param string $PostClass
34
- * @return array|bool|null
35
- */
36
- static function query_posts($query = false, $PostClass = 'TimberPost' ){
37
- if (self::is_post_class_or_class_map($query)) {
38
- $PostClass = $query;
39
- $query = false;
40
- }
41
-
42
- if (is_object($query) && !is_a($query, 'WP_Query') ){
43
- // The only object other than a query is a type of post object
44
- $query = array( $query );
45
- }
46
-
47
- if ( is_array( $query ) && count( $query ) && isset( $query[0] ) && is_object( $query[0] ) ) {
48
- // We have an array of post objects that already have data
49
- return new TimberPostsCollection( $query, $PostClass );
50
- } else {
51
- // We have a query (of sorts) to work with
52
- $tqi = new TimberQueryIterator( $query, $PostClass );
53
- return $tqi;
54
- }
55
- }
56
-
57
- static function get_pids($query){
58
- $posts = self::get_posts($query);
59
- $pids = array();
60
- foreach($posts as $post){
61
- if (isset($post->ID)){
62
- $pids[] = $post->ID;
63
- }
64
- }
65
- return $pids;
66
- }
67
-
68
- /**
69
- * @param array $results
70
- * @param string $PostClass
71
- * @return TimberPostsCollection
72
- */
73
- static function handle_post_results($results, $PostClass = 'TimberPost') {
74
- $posts = array();
75
- foreach ($results as $rid) {
76
- $PostClassUse = $PostClass;
77
- if (is_array($PostClass)) {
78
- $post_type = get_post_type($rid);
79
- $PostClassUse = 'TimberPost';
80
- if (isset($PostClass[$post_type])) {
81
- $PostClassUse = $PostClass[$post_type];
82
- } else {
83
- if (is_array($PostClass)) {
84
- TimberHelper::error_log($post_type.' of '.$rid.' not found in ' . print_r($PostClass, true));
85
- } else {
86
- TimberHelper::error_log($post_type.' not found in '.$PostClass);
87
- }
88
- }
89
- }
90
- $post = new $PostClassUse($rid);
91
- if (isset($post->ID)) {
92
- $posts[] = $post;
93
- }
94
- }
95
- return new TimberPostsCollection( $posts, $PostClass );
96
- }
97
-
98
- static function loop_to_id() {
99
- if (!self::wp_query_has_posts()) { return false; }
100
-
101
- global $wp_query;
102
- $post_num = property_exists($wp_query, 'current_post')
103
- ? $wp_query->current_post + 1
104
- : 0
105
- ;
106
-
107
- if (!isset($wp_query->posts[$post_num])) { return false; }
108
-
109
- return $wp_query->posts[$post_num]->ID;
110
- }
111
-
112
- /**
113
- * @return bool
114
- */
115
- static function wp_query_has_posts() {
116
- global $wp_query;
117
- return ($wp_query && property_exists($wp_query, 'posts') && $wp_query->posts);
118
- }
119
-
120
- /**
121
- * @param string|array $arg
122
- * @return bool
123
- */
124
- static function is_post_class_or_class_map($arg){
125
- if (is_string($arg) && class_exists($arg)) {
126
- return true;
127
- }
128
- if (is_array($arg)) {
129
- foreach ($arg as $item) {
130
- if (is_string($item) && class_exists($item)) {
131
- return true;
132
- }
133
- }
134
- }
135
- return false;
136
- }
137
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
functions/functions/timber-post.php DELETED
@@ -1,1007 +0,0 @@
1
- <?php
2
-
3
- class TimberPost extends TimberCore implements TimberCoreInterface {
4
-
5
- public $ImageClass = 'TimberImage';
6
- public $PostClass = 'TimberPost';
7
-
8
- public $object_type = 'post';
9
- public static $representation = 'post';
10
-
11
- public $_can_edit;
12
- public $_custom_imported = false;
13
- public $_content;
14
- public $_get_terms;
15
-
16
- private $_next = array();
17
- private $_prev = array();
18
-
19
- public $class;
20
- public $display_date;
21
- public $id;
22
- public $ID;
23
- public $post_content;
24
- public $post_date;
25
- public $post_parent;
26
- public $post_title;
27
- public $post_type;
28
- public $slug;
29
-
30
- /**
31
- * If you send the constructor nothing it will try to figure out the current post id based on being inside The_Loop
32
- * @param mixed $pid
33
- * @return \TimberPost TimberPost object -- woo!
34
- */
35
- function __construct($pid = null) {
36
- global $wp_query;
37
- if ($pid === null && isset($wp_query->queried_object_id) && $wp_query->queried_object_id) {
38
- $pid = $wp_query->queried_object_id;
39
- $this->ID = $pid;
40
- } else if ($pid === null && get_the_ID()) {
41
- $pid = get_the_ID();
42
- $this->ID = $pid;
43
- } else if ($pid === null && ($pid_from_loop = TimberPostGetter::loop_to_id())) {
44
- $this->ID = $pid_from_loop;
45
- }
46
- if (is_numeric($pid)) {
47
- $this->ID = $pid;
48
- }
49
- $this->init($pid);
50
- }
51
-
52
- /**
53
- * @return string
54
- */
55
- function __toString() {
56
- return $this->title();
57
- }
58
-
59
-
60
- /**
61
- * @param int|bool $pid
62
- */
63
- function init($pid = false) {
64
- if ($pid === false) {
65
- $pid = get_the_ID();
66
- }
67
- $post_info = $this->get_info($pid);
68
- $this->import($post_info);
69
- /* deprecated, adding for support for older themes */
70
- $this->display_date = $this->date();
71
- //cant have a function, so gots to do it this way
72
- $post_class = $this->post_class();
73
- $this->class = $post_class;
74
- }
75
-
76
- /**
77
- * Get the URL that will edit the current post/object
78
- *
79
- * @return bool|string
80
- */
81
- function get_edit_url() {
82
- if ($this->can_edit()) {
83
- return get_edit_post_link($this->ID);
84
- }
85
- return false;
86
- }
87
-
88
- /**
89
- * updates the post_meta of the current object with the given value
90
- *
91
- * @param string $field
92
- * @param mixed $value
93
- */
94
- public function update($field, $value) {
95
- if (isset($this->ID)) {
96
- update_post_meta($this->ID, $field, $value);
97
- $this->$field = $value;
98
- }
99
- }
100
-
101
-
102
- /**
103
- * takes a mix of integer (post ID), string (post slug), or object to return a WordPress post object from WP's built-in get_post() function
104
- *
105
- * @param mixed $pid
106
- * @return WP_Post on success
107
- */
108
- private function prepare_post_info($pid = 0) {
109
- if (is_string($pid) || is_numeric($pid) || (is_object($pid) && !isset($pid->post_title)) || $pid === 0) {
110
- $pid = self::check_post_id($pid);
111
- $post = get_post($pid);
112
- if ($post) {
113
- return $post;
114
- } else {
115
- $post = get_page($pid);
116
- return $post;
117
- }
118
- }
119
- //we can skip if already is WP_Post
120
- return $pid;
121
- }
122
-
123
-
124
- /**
125
- * helps you find the post id regardless of whetehr you send a string or whatever
126
- *
127
- * @param integer $pid ;
128
- * @return integer ID number of a post
129
- */
130
- private function check_post_id($pid) {
131
- if (is_numeric($pid) && $pid === 0) {
132
- $pid = get_the_ID();
133
- return $pid;
134
- }
135
- if (!is_numeric($pid) && is_string($pid)) {
136
- $pid = self::get_post_id_by_name($pid);
137
- return $pid;
138
- }
139
- if (!$pid) {
140
- return null;
141
- }
142
- return $pid;
143
- }
144
-
145
-
146
- /**
147
- * get_post_id_by_name($post_name)
148
- *
149
- * @param string $post_name
150
- * @return int
151
- */
152
- public static function get_post_id_by_name($post_name) {
153
- global $wpdb;
154
- $query = $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_name = %s LIMIT 1", $post_name);
155
- $result = $wpdb->get_row($query);
156
- if (!$result) {
157
- return null;
158
- }
159
- return $result->ID;
160
- }
161
-
162
-
163
- /**
164
- * ## get a preview of your post, if you have an excerpt it will use that,
165
- * ## otherwise it will pull from the post_content.
166
- * ## If there's a <!-- more --> tag it will use that to mark where to pull through.
167
- * <p>{{post.get_preview(50)}}</p>
168
- */
169
-
170
- /**
171
- * @param int $len
172
- * @param bool $force
173
- * @param string $readmore
174
- * @param bool $strip
175
- * @return string
176
- */
177
- function get_preview($len = 50, $force = false, $readmore = 'Read More', $strip = true) {
178
- $text = '';
179
- $trimmed = false;
180
- if (isset($this->post_excerpt) && strlen($this->post_excerpt)) {
181
- if ($force) {
182
- $text = TimberHelper::trim_words($this->post_excerpt, $len, false);
183
- $trimmed = true;
184
- } else {
185
- $text = $this->post_excerpt;
186
- }
187
- }
188
- if (!strlen($text) && strpos($this->post_content, '<!--more-->') !== false) {
189
- $pieces = explode('<!--more-->', $this->post_content);
190
- $text = $pieces[0];
191
- if ($force) {
192
- $text = TimberHelper::trim_words($text, $len, false);
193
- $trimmed = true;
194
- }
195
- }
196
- if (!strlen($text)) {
197
- $text = TimberHelper::trim_words($this->get_content(), $len, false);
198
- $trimmed = true;
199
- }
200
- if (!strlen(trim($text))) {
201
- return $text;
202
- }
203
- if ($strip) {
204
- $text = trim(strip_tags($text));
205
- }
206
- if (strlen($text)) {
207
- $text = trim($text);
208
- $last = $text[strlen($text) - 1];
209
- if ($last != '.' && $trimmed) {
210
- $text .= ' &hellip; ';
211
- }
212
- if (!$strip) {
213
- $last_p_tag = strrpos($text, '</p>');
214
- if ($last_p_tag !== false) {
215
- $text = substr($text, 0, $last_p_tag);
216
- }
217
- if ($last != '.' && $trimmed) {
218
- $text .= ' &hellip; ';
219
- }
220
- }
221
-
222
- if ($readmore) {
223
- $text .= ' <a href="' . $this->get_permalink() . '" class="read-more">' . $readmore . '</a>';
224
- }
225
- if (!$strip) {
226
- $text .= '</p>';
227
- }
228
- }
229
- return $text;
230
- }
231
-
232
- /**
233
- * gets the post custom and attaches it to the current object
234
- * @param bool|int $pid a post ID number
235
- * @nodoc
236
- */
237
- function import_custom($pid = false) {
238
- if (!$pid) {
239
- $pid = $this->ID;
240
- }
241
- $customs = $this->get_post_custom($pid);
242
- $this->import($customs);
243
- }
244
-
245
- /**
246
- * @param int $pid
247
- * @return array
248
- */
249
- function get_post_custom($pid) {
250
- apply_filters('timber_post_get_meta_pre', array(), $pid, $this);
251
- $customs = get_post_custom($pid);
252
- if (!is_array($customs) || empty($customs)) {
253
- return array();
254
- }
255
- foreach ($customs as $key => $value) {
256
- if (is_array($value) && count($value) == 1 && isset($value[0])) {
257
- $value = $value[0];
258
- }
259
- $customs[$key] = maybe_unserialize($value);
260
- }
261
- $customs = apply_filters('timber_post_get_meta', $customs, $pid, $this);
262
- return $customs;
263
- }
264
-
265
- /**
266
- * ## get the featured image as a TimberImage
267
- * <img src="{{post.get_thumbnail.get_src}}" />
268
- */
269
-
270
- /**
271
- * @return null|TimberImage
272
- */
273
- function get_thumbnail() {
274
- if (function_exists('get_post_thumbnail_id')) {
275
- $tid = get_post_thumbnail_id($this->ID);
276
- if ($tid) {
277
- return new $this->ImageClass($tid);
278
- }
279
- }
280
- return null;
281
- }
282
-
283
- /**
284
- * @return string
285
- */
286
- function get_permalink() {
287
- if (isset($this->permalink)) {
288
- return $this->permalink;
289
- }
290
- $this->permalink = get_permalink($this->ID);
291
- return $this->permalink;
292
- }
293
-
294
- /**
295
- * @return string
296
- */
297
- function get_link() {
298
- return $this->get_permalink();
299
- }
300
-
301
- /**
302
- * @param bool $taxonomy
303
- * @return mixed
304
- */
305
- function get_next($taxonomy = false) {
306
- if (!isset($this->_next) || !isset($this->_next[$taxonomy])) {
307
- global $post;
308
- $this->_next = array();
309
- $old_global = $post;
310
- $post = $this;
311
- if ($taxonomy) {
312
- $adjacent = get_adjacent_post(true, '', false, $taxonomy);
313
- } else {
314
- $adjacent = get_adjacent_post(false, '', false);
315
- }
316
-
317
- if ($adjacent) {
318
- $this->_next[$taxonomy] = new $this->PostClass($adjacent);
319
- } else {
320
- $this->_next[$taxonomy] = false;
321
- }
322
- $post = $old_global;
323
- }
324
- return $this->_next[$taxonomy];
325
- }
326
-
327
- /**
328
- * @return array
329
- */
330
- public function get_pagination() {
331
- global $post, $page, $numpages, $multipage;
332
- $post = $this;
333
- $ret = array();
334
- if ($multipage) {
335
- for ($i = 1; $i <= $numpages; $i++) {
336
- $link = self::get_wp_link_page($i);
337
- $data = array('name' => $i, 'title' => $i, 'text' => $i, 'link' => $link);
338
- if ($i == $page) {
339
- $data['current'] = true;
340
- }
341
- $ret['pages'][] = $data;
342
- }
343
- $i = $page - 1;
344
- if ($i) {
345
- $link = self::get_wp_link_page($i);
346
- $ret['prev'] = array('link' => $link);
347
- }
348
- $i = $page + 1;
349
- if ($i <= $numpages) {
350
- $link = self::get_wp_link_page($i);
351
- $ret['next'] = array('link' => $link);
352
- }
353
- }
354
- return $ret;
355
- }
356
-
357
- /**
358
- * @param int $i
359
- * @return string
360
- */
361
- private static function get_wp_link_page($i) {
362
- $link = _wp_link_page($i);
363
- $link = new SimpleXMLElement($link . '</a>');
364
- if (isset($link['href'])) {
365
- return $link['href'];
366
- }
367
- return '';
368
- }
369
-
370
- /**
371
- * @return string
372
- */
373
- function get_path() {
374
- return TimberURLHelper::get_rel_url($this->get_link());
375
- }
376
-
377
- /**
378
- * @param bool $taxonomy
379
- * @return mixed
380
- */
381
- function get_prev($taxonomy = false) {
382
- if (isset($this->_prev) && isset($this->_prev[$taxonomy])) {
383
- return $this->_prev[$taxonomy];
384
- }
385
- global $post;
386
- $old_global = $post;
387
- $post = $this;
388
- $within_taxonomy = ($taxonomy) ? $taxonomy : 'category';
389
- $adjacent = get_adjacent_post(($taxonomy), '', true, $within_taxonomy);
390
-
391
- $prev_in_taxonomy = false;
392
- if ($adjacent) {
393
- $prev_in_taxonomy = new $this->PostClass($adjacent);
394
- }
395
- $this->_prev[$taxonomy] = $prev_in_taxonomy;
396
- $post = $old_global;
397
- return $this->_prev[$taxonomy];
398
- }
399
-
400
- /**
401
- * @return bool|TimberPost
402
- */
403
- function get_parent() {
404
- if (!$this->post_parent) {
405
- return false;
406
- }
407
- return new $this->PostClass($this->post_parent);
408
- }
409
-
410
- /**
411
- * ## Gets a User object from the author of the post
412
- * <p class="byline">{{post.get_author.name}}</p>
413
- */
414
-
415
- /**
416
- * @return bool|TimberUser
417
- */
418
- function get_author() {
419
- if (isset($this->post_author)) {
420
- return new TimberUser($this->post_author);
421
- }
422
- return false;
423
- }
424
-
425
- /**
426
- * @return bool|TimberUser
427
- */
428
- function get_modified_author() {
429
- $user_id = get_post_meta($this->ID, '_edit_last', true);
430
- return ($user_id ? new TimberUser($user_id) : $this->get_author());
431
- }
432
-
433
- /**
434
- * @param int $pid
435
- * @return null|object|WP_Post
436
- */
437
- function get_info($pid) {
438
- $post = $this->prepare_post_info($pid);
439
- if (!isset($post->post_status)) {
440
- return null;
441
- }
442
- $post->status = $post->post_status;
443
- $post->id = $post->ID;
444
- $post->slug = $post->post_name;
445
- $customs = $this->get_post_custom($post->ID);
446
- $post->custom = $customs;
447
- $post = (object)array_merge((array)$customs, (array)$post);
448
- return $post;
449
- }
450
-
451
- /**
452
- * This is deprecated!
453
- * @param string $use
454
- * @return string
455
- */
456
- function get_display_date($use = 'post_date') {
457
- return date(get_option('date_format'), strtotime($this->$use));
458
- }
459
-
460
- /**
461
- * @param string $date_format
462
- * @return string
463
- */
464
- function get_date($date_format = '') {
465
- $df = $date_format ? $date_format : get_option('date_format');
466
- $the_date = (string)mysql2date($df, $this->post_date);
467
- return apply_filters('get_the_date', $the_date, $date_format);
468
- }
469
-
470
- /**
471
- * @param string $date_format
472
- * @return string
473
- */
474
- function get_modified_date($date_format = '') {
475
- $df = $date_format ? $date_format : get_option('date_format');
476
- $the_time = $this->get_modified_time($df, null, $this->ID, true);
477
- return apply_filters('get_the_modified_date', $the_time, $date_format);
478
- }
479
-
480
- /**
481
- * @param string $time_format
482
- * @return string
483
- */
484
- function get_modified_time($time_format = '') {
485
- $tf = $time_format ? $time_format : get_option('time_format');
486
- $the_time = get_post_modified_time($tf, false, $this->ID, true);
487
- return apply_filters('get_the_modified_time', $the_time, $time_format);
488
- }
489
-
490
- /**
491
- * @param string $post_type
492
- * @param bool $childPostClass
493
- * @return array
494
- */
495
- function get_children($post_type = 'any', $childPostClass = false) {
496
- if ($childPostClass == false) {
497
- $childPostClass = $this->PostClass;
498
- }
499
- if ($post_type == 'parent') {
500
- $post_type = $this->post_type;
501
- }
502
- $children = get_children('post_parent=' . $this->ID . '&post_type=' . $post_type . '&numberposts=-1&orderby=menu_order title&order=ASC');
503
- foreach ($children as &$child) {
504
- $child = new $childPostClass($child->ID);
505
- }
506
- $children = array_values($children);
507
- return $children;
508
- }
509
-
510
- /**
511
- * {% for comment in post.get_comments %}
512
- * <p>{{comment.content}}</p>
513
- * {% endfor %}
514
- */
515
-
516
- /**
517
- * @param int $ct
518
- * @param string $order
519
- * @param string $type
520
- * @param string $status
521
- * @param string $CommentClass
522
- * @return mixed
523
- */
524
- function get_comments($ct = 0, $order = 'wp', $type = 'comment', $status = 'approve', $CommentClass = 'TimberComment') {
525
- $args = array('post_id' => $this->ID, 'status' => $status, 'order' => $order);
526
- if ($ct > 0) {
527
- $args['number'] = $ct;
528
- }
529
- if ($order == 'wp') {
530
- $args['order'] = get_option('comment_order');
531
- }
532
- $comments = get_comments($args);
533
- foreach ($comments as &$comment) {
534
- $comment = new $CommentClass($comment);
535
- }
536
- return $comments;
537
- }
538
-
539
- /**
540
- * <ul class="categories">
541
- * {% for category in post.get_categories %}
542
- * <li>{{category.name}}</li>
543
- * {% endfor %}
544
- * </ul>
545
- */
546
-
547
- /**
548
- * @return array
549
- */
550
- function get_categories() {
551
- return $this->get_terms('category');
552
- }
553
-
554
- /**
555
- * @return mixed
556
- */
557
- function get_category() {
558
- $cats = $this->get_categories();
559
- if (count($cats) && isset($cats[0])) {
560
- return $cats[0];
561
- }
562
- return null;
563
- }
564
-
565
- /** # get terms is good
566
- *
567
- */
568
-
569
- /**
570
- * @param string $tax
571
- * @param bool $merge
572
- * @param string $TermClass
573
- * @return array
574
- */
575
- function get_terms($tax = '', $merge = true, $TermClass = 'TimberTerm') {
576
- if (is_string($merge) && class_exists($merge)){
577
- $TermClass = $merge;
578
- }
579
- if (is_string($tax)) {
580
- if (isset($this->_get_terms) && isset($this->_get_terms[$tax])) {
581
- return $this->_get_terms[$tax];
582
- }
583
- }
584
- if (!strlen($tax) || $tax == 'all' || $tax == 'any') {
585
- $taxs = get_object_taxonomies($this->post_type);
586
- } else if (is_array($tax)) {
587
- $taxs = $tax;
588
- } else {
589
- $taxs = array($tax);
590
- }
591
- $ret = array();
592
- foreach ($taxs as $tax) {
593
- if ($tax == 'tags' || $tax == 'tag') {
594
- $tax = 'post_tag';
595
- } else if ($tax == 'categories') {
596
- $tax = 'category';
597
- }
598
- $terms = wp_get_post_terms($this->ID, $tax);
599
- if (!is_array($terms) && is_object($terms) && get_class($terms) == 'WP_Error') {
600
- //something is very wrong
601
- TimberHelper::error_log('You have an error retrieving terms on a post in timber-post.php:367');
602
- TimberHelper::error_log('tax = ' . $tax);
603
- TimberHelper::error_log($terms);
604
-
605
- } else {
606
- foreach ($terms as &$term) {
607
- $term = new $TermClass($term->term_id, $tax);
608
- }
609
- if ($merge && is_array($terms)) {
610
- $ret = array_merge($ret, $terms);
611
- } else if (count($terms)) {
612
- $ret[$tax] = $terms;
613
- }
614
- }
615
- }
616
- if (!isset($this->_get_terms)) {
617
- $this->_get_terms = array();
618
- }
619
- $this->_get_terms[$tax] = $ret;
620
- return $ret;
621
- }
622
-
623
- /**
624
- * @param string|int $term_name_or_id
625
- * @param string $taxonomy
626
- * @return bool
627
- */
628
- function has_term($term_name_or_id, $taxonomy = 'all') {
629
- if ($taxonomy == 'all' || $taxonomy == 'any') {
630
- $taxes = get_object_taxonomies($this->post_type, 'names');
631
- $ret = false;
632
- foreach ($taxes as $tax) {
633
- if (has_term($term_name_or_id, $tax, $this->ID)) {
634
- $ret = true;
635
- break;
636
- }
637
- }
638
- return $ret;
639
- }
640
- return has_term($term_name_or_id, $taxonomy, $this->ID);
641
- }
642
-
643
- /**
644
- * @param string $field
645
- * @return TimberImage
646
- */
647
- function get_image($field) {
648
- return new $this->ImageClass($this->$field);
649
- }
650
-
651
- /**
652
- * ## Gets an array of tags for you to use
653
- * <ul class="tags">
654
- * {% for tag in post.tags %}
655
- * <li>{{tag.name}}</li>
656
- * {% endfor %}
657
- * </ul>
658
- */
659
-
660
- /**
661
- * @return array
662
- */
663
- function get_tags() {
664
- return $this->get_terms('tags');
665
- }
666
-
667
- /**
668
- * ## Outputs the title with filters applied
669
- * <h1>{{post.get_title}}</h1>
670
- */
671
-
672
- /**
673
- * @return string
674
- */
675
- function get_title() {
676
- return apply_filters('the_title', $this->post_title, $this->ID);
677
- }
678
-
679
- /**
680
- * ## Displays the content of the post with filters, shortcodes and wpautop applied
681
- * <div class="article-text">{{post.get_content}}</div>
682
- */
683
-
684
- /**
685
- * @param int $len
686
- * @param int $page
687
- * @return string
688
- */
689
- function get_content($len = 0, $page = 0) {
690
- if ($len == 0 && $page == 0 && $this->_content) {
691
- return $this->_content;
692
- }
693
- $content = $this->post_content;
694
- if ($len) {
695
- $content = wp_trim_words($content, $len);
696
- }
697
- if ($page) {
698
- $contents = explode('<!--nextpage-->', $content);
699
- $page--;
700
- if (count($contents) > $page) {
701
- $content = $contents[$page];
702
- }
703
- }
704
- $content = apply_filters('the_content', ($content));
705
- if ($len == 0 && $page == 0) {
706
- $this->_content = $content;
707
- }
708
- return $content;
709
- }
710
-
711
- /**
712
- * @return string
713
- */
714
- function get_paged_content() {
715
- global $page;
716
- return $this->get_content(0, $page);
717
- }
718
- /**
719
- * @return mixed
720
- */
721
- public function get_post_type() {
722
- return get_post_type_object($this->post_type);
723
- }
724
-
725
- /**
726
- * @return int
727
- */
728
- public function get_comment_count() {
729
- if (isset($this->ID)) {
730
- return get_comments_number($this->ID);
731
- } else {
732
- return 0;
733
- }
734
- }
735
-
736
- /**
737
- * @param string $field_name
738
- * @return mixed
739
- */
740
- public function get_field($field_name) {
741
- $value = apply_filters('timber_post_get_meta_field_pre', null, $this->ID, $field_name, $this);
742
- if ($value === null) {
743
- $value = get_post_meta($this->ID, $field_name);
744
- if (is_array($value) && count($value) == 1) {
745
- $value = $value[0];
746
- }
747
- if (is_array($value) && count($value) == 0) {
748
- $value = null;
749
- }
750
- }
751
- $value = apply_filters('timber_post_get_meta_field', $value, $this->ID, $field_name, $this);
752
- return $value;
753
- }
754
-
755
- /**
756
- * @param string $field_name
757
- */
758
- function import_field($field_name) {
759
- $this->$field_name = $this->get_field($field_name);
760
- }
761
-
762
- /**
763
- * @return mixed
764
- */
765
- function get_format() {
766
- return get_post_format($this->ID);
767
- }
768
-
769
- /**
770
- * @param string $class
771
- * @return string
772
- */
773
- public function post_class($class='') {
774
- global $post;
775
- $old_global_post = $post;
776
- $post = $this;
777
- $class_array = get_post_class($class, $this->ID);
778
- $post = $old_global_post;
779
- if (is_array($class_array)){
780
- return implode(' ', $class_array);
781
- }
782
- return $class_array;
783
- }
784
-
785
- // Docs
786
-
787
- /**
788
- * @return array
789
- */
790
- public function get_method_values() {
791
- $ret = parent::get_method_values();
792
- $ret['author'] = $this->author();
793
- $ret['categories'] = $this->categories();
794
- $ret['category'] = $this->category();
795
- $ret['children'] = $this->children();
796
- $ret['comments'] = $this->comments();
797
- $ret['content'] = $this->content();
798
- $ret['edit_link'] = $this->edit_link();
799
- $ret['format'] = $this->format();
800
- $ret['link'] = $this->link();
801
- $ret['next'] = $this->next();
802
- $ret['pagination'] = $this->pagination();
803
- $ret['parent'] = $this->parent();
804
- $ret['path'] = $this->path();
805
- $ret['prev'] = $this->prev();
806
- $ret['terms'] = $this->terms();
807
- $ret['tags'] = $this->tags();
808
- $ret['thumbnail'] = $this->thumbnail();
809
- $ret['title'] = $this->title();
810
- return $ret;
811
- }
812
-
813
- // Aliases
814
- /**
815
- * @return bool|TimberUser
816
- */
817
- public function author() {
818
- return $this->get_author();
819
- }
820
-
821
- /**
822
- * @return bool|TimberUser
823
- */
824
- public function modified_author() {
825
- return $this->get_modified_author();
826
- }
827
-
828
- /**
829
- * @return array
830
- */
831
- public function categories() {
832
- return $this->get_terms('category');
833
- }
834
-
835
- /**
836
- * @return mixed
837
- */
838
- public function category() {
839
- return $this->get_category();
840
- }
841
-
842
- /**
843
- * @return array
844
- */
845
- public function children( $post_type = 'any', $childPostClass = false ) {
846
- return $this->get_children( $post_type, $childPostClass );
847
- }
848
-
849
- /**
850
- * @return mixed
851
- */
852
- public function comments() {
853
- return $this->get_comments();
854
- }
855
-
856
- /**
857
- * @param int $page
858
- * @return string
859
- */
860
- public function content($page = 0) {
861
- return $this->get_content(0, $page);
862
- }
863
-
864
- /**
865
- * @return string
866
- */
867
- public function paged_content() {
868
- return $this->get_paged_content();
869
- }
870
-
871
- /**
872
- * @param string $date_format
873
- * @return string
874
- */
875
- public function date($date_format = '') {
876
- return $this->get_date($date_format);
877
- }
878
-
879
- /**
880
- * @return bool|string
881
- */
882
- public function edit_link() {
883
- return $this->get_edit_url();
884
- }
885
-
886
- /**
887
- * @return mixed
888
- */
889
- public function format() {
890
- return $this->get_format();
891
- }
892
-
893
- /**
894
- * @return string
895
- */
896
- public function link() {
897
- return $this->get_permalink();
898
- }
899
-
900
- /**
901
- * @param string $field_name
902
- * @return mixed
903
- */
904
- public function meta($field_name = null) {
905
- if ($field_name == null) {
906
- $field_name = 'meta';
907
- }
908
- return $this->get_field($field_name);
909
- }
910
-
911
- /**
912
- * @return string
913
- */
914
- public function name(){
915
- return $this->title();
916
- }
917
-
918
- /**
919
- * @param string $date_format
920
- * @return string
921
- */
922
- public function modified_date($date_format = '') {
923
- return $this->get_modified_date($date_format);
924
- }
925
-
926
- /**
927
- * @param string $time_format
928
- * @return string
929
- */
930
- public function modified_time($time_format = '') {
931
- return $this->get_modified_time($time_format);
932
- }
933
-
934
- /**
935
- * @param bool $in_same_cat
936
- * @return mixed
937
- */
938
- public function next($in_same_cat = false) {
939
- return $this->get_next($in_same_cat);
940
- }
941
-
942
- /**
943
- * @return array
944
- */
945
- public function pagination() {
946
- return $this->get_pagination();
947
- }
948
-
949
- /**
950
- * @return bool|TimberPost
951
- */
952
- public function parent() {
953
- return $this->get_parent();
954
- }
955
-
956
- /**
957
- * @return string
958
- */
959
- public function path() {
960
- return $this->get_path();
961
- }
962
-
963
- /**
964
- * @return string
965
- */
966
- public function permalink() {
967
- return $this->get_permalink();
968
- }
969
-
970
- /**
971
- * @param bool $in_same_cat
972
- * @return mixed
973
- */
974
- public function prev($in_same_cat = false) {
975
- return $this->get_prev($in_same_cat);
976
- }
977
-
978
- /**
979
- * @param string $tax
980
- * @return array
981
- */
982
- public function terms($tax = '') {
983
- return $this->get_terms($tax);
984
- }
985
-
986
- /**
987
- * @return array
988
- */
989
- public function tags() {
990
- return $this->get_tags();
991
- }
992
-
993
- /**
994
- * @return null|TimberImage
995
- */
996
- public function thumbnail() {
997
- return $this->get_thumbnail();
998
- }
999
-
1000
- /**
1001
- * @return string
1002
- */
1003
- public function title() {
1004
- return $this->get_title();
1005
- }
1006
-
1007
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
functions/functions/timber-posts-collection.php DELETED
@@ -1,97 +0,0 @@
1
- <?php
2
-
3
- // Exit if accessed directly
4
- if ( !defined( 'ABSPATH' ) )
5
- exit;
6
-
7
- class TimberPostsCollection extends ArrayObject {
8
-
9
- public function __construct( $array = array(), $post_class = 'TimberPost' ) {
10
- $posts = array();
11
- if ( is_null( $array ) ){
12
- $array = array();
13
- }
14
- foreach ( $array as $rid ) {
15
- $post_class_use = $post_class;
16
-
17
- if ( is_array( $post_class ) ) {
18
- $post_type = get_post_type( $rid );
19
- $post_class_use = 'TimberPost';
20
-
21
- if ( isset( $post_class[$post_type] ) ) {
22
- $post_class_use = $post_class[$post_type];
23
-
24
- } else {
25
- if ( is_array( $post_class ) ) {
26
- TimberHelper::error_log( $post_type . ' of ' . $rid . ' not found in ' . print_r( $post_class, true ) );
27
- } else {
28
- TimberHelper::error_log( $post_type . ' not found in ' . $post_class );
29
- }
30
- }
31
- }
32
-
33
- // Don't create yet another object if $rid is already of the right type
34
- if ( is_a( $rid, $post_class_use ) ) {
35
- $post = $rid;
36
- } else {
37
- $post = new $post_class_use( $rid );
38
- }
39
-
40
- if ( isset( $post->ID ) ) {
41
- $posts[] = $post;
42
- }
43
- }
44
-
45
- $posts = self::maybe_set_preview($posts);
46
-
47
- parent::__construct( $posts, $flags = 0, 'TimberPostsIterator' );
48
- }
49
-
50
- public function get_posts() {
51
- return $this->getArrayCopy();
52
- }
53
-
54
- /**
55
- * @param array $posts
56
- * @return array
57
- */
58
- static function maybe_set_preview( $posts ) {
59
- if ( is_array( $posts ) && isset( $_GET['preview'] ) && $_GET['preview']
60
- && isset( $_GET['preview_id'] ) && $_GET['preview_id']
61
- && current_user_can( 'edit_post', $_GET['preview_id'] ) ) {
62
- // No need to check the nonce, that already happened in _show_post_preview on init
63
-
64
- $preview_id = $_GET['preview_id'];
65
- foreach( $posts as &$post ) {
66
- if ( is_object( $post ) && $post->ID == $preview_id ) {
67
- // Based on _set_preview( $post ), but adds import_custom
68
- $preview = wp_get_post_autosave( $preview_id );
69
- if ( is_object($preview) ) {
70
-
71
- $preview = sanitize_post($preview);
72
-
73
- $post->post_content = $preview->post_content;
74
- $post->post_title = $preview->post_title;
75
- $post->post_excerpt = $preview->post_excerpt;
76
- $post->import_custom( $preview_id );
77
-
78
- add_filter( 'get_the_terms', '_wp_preview_terms_filter', 10, 3 );
79
- }
80
- }
81
- }
82
-
83
- }
84
-
85
- return $posts;
86
- }
87
-
88
- }
89
-
90
- class TimberPostsIterator extends ArrayIterator {
91
-
92
- public function current() {
93
- global $post;
94
- $post = parent::current();
95
- return $post;
96
- }
97
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
functions/functions/timber-query-iterator.php DELETED
@@ -1,141 +0,0 @@
1
- <?php
2
- // Exit if accessed directly
3
- if ( !defined( 'ABSPATH' ) )
4
- exit;
5
-
6
- class TimberQueryIterator implements Iterator {
7
-
8
- /**
9
- *
10
- *
11
- * @var WP_Query
12
- */
13
- private $_query = null;
14
- private $_posts_class = 'TimberPost';
15
-
16
- public function __construct( $query = false, $posts_class = 'TimberPost' ) {
17
- add_action( 'pre_get_posts', array($this, 'fix_number_posts_wp_quirk' ));
18
- if ( $posts_class )
19
- $this->_posts_class = $posts_class;
20
-
21
- if ( is_a( $query, 'WP_Query' ) ) {
22
- // We got a full-fledged WP Query, look no further!
23
- $the_query = $query;
24
-
25
- } elseif ( false === $query ) {
26
- // If query is explicitly set to false, use the main loop
27
- global $wp_query;
28
- $the_query =& $wp_query;
29
-
30
- } elseif ( TimberHelper::is_array_assoc( $query ) || ( is_string( $query ) && strstr( $query, '=' ) ) ) {
31
- // We have a regularly formed WP query string or array to use
32
- $the_query = new WP_Query( $query );
33
-
34
- } elseif ( is_numeric( $query ) || is_string( $query ) ) {
35
- // We have what could be a post name or post ID to pull out
36
- $the_query = self::get_query_from_string( $query );
37
-
38
- } elseif ( is_array( $query ) && count( $query ) && ( is_integer( $query[0] ) || is_string( $query[0] ) ) ) {
39
- // We have a list of pids (post IDs) to extract from
40
- $the_query = self::get_query_from_array_of_ids( $query );
41
- } elseif ( is_array($query) && empty($query)) {
42
- // it's an empty array
43
- $the_query = array();
44
- } else {
45
- TimberHelper::error_log( 'I have failed you! in ' . basename( __FILE__ ) . '::' . __LINE__ );
46
- TimberHelper::error_log( $query );
47
-
48
- // We have failed hard, at least let get something.
49
- $the_query = new WP_Query();
50
- }
51
-
52
- $this->_query = $the_query;
53
-
54
- }
55
-
56
- public function get_posts( $return_collection = false ) {
57
- if (isset($this->_query->posts)){
58
- $posts = new TimberPostsCollection( $this->_query->posts, $this->_posts_class );
59
- return ( $return_collection ) ? $posts : $posts->get_posts();
60
- }
61
- }
62
-
63
- //
64
- // GET POSTS
65
- //
66
- public static function get_query_from_array_of_ids( $query = array() ) {
67
- if ( !is_array( $query ) || !count( $query ) )
68
- return null;
69
-
70
- return new WP_Query( array(
71
- 'post_type'=> 'any',
72
- 'ignore_sticky_posts' => true,
73
- 'post__in' => $query,
74
- 'orderby' => 'post__in',
75
- 'nopaging' => true
76
- ) );
77
- }
78
-
79
- public static function get_query_from_string( $string = '' ) {
80
- $post_type = false;
81
-
82
- if ( is_string( $string ) && strstr( $string, '#' ) ) {
83
- //we have a post_type directive here
84
- list( $post_type, $string ) = explode( '#', $string );
85
- }
86
-
87
- $query = array(
88
- 'post_type' => ( $post_type ) ? $post_type : 'any'
89
- );
90
-
91
- if ( is_numeric( $string ) ) {
92
- $query['p'] = $string;
93
-
94
- } else {
95
- $query['name'] = $string;
96
- }
97
-
98
- return new WP_Query( $query );
99
- }
100
-
101
- //
102
- // Iterator Interface
103
- //
104
-
105
- public function valid() {
106
- return $this->_query->have_posts();
107
- }
108
-
109
- public function current() {
110
- global $post;
111
-
112
- $this->_query->the_post();
113
-
114
- // Sets up the global post, but also return the post, for use in Twig template
115
- $posts_class = $this->_posts_class;
116
- return new $posts_class( $post );
117
- }
118
-
119
- /**
120
- * Don't implement next, because current already advances the loop
121
- */
122
- final public function next() {}
123
-
124
- public function rewind() {
125
- $this->_query->rewind_posts();
126
- }
127
-
128
- public function key() {
129
- $this->_query->current_post;
130
- }
131
-
132
- //get_posts users numberposts
133
- static function fix_number_posts_wp_quirk( $query ) {
134
- if (isset($query->query) && isset($query->query['numberposts'])
135
- && !isset($query->query['posts_per_page'])) {
136
- $query->set( 'posts_per_page', $query->query['numberposts'] );
137
- }
138
- return $query;
139
- }
140
-
141
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
functions/functions/timber-routes.php DELETED
@@ -1,111 +0,0 @@
1
- <?php
2
-
3
- class TimberRoutes {
4
-
5
- protected $router;
6
-
7
- function __construct(){
8
- add_action('init', array($this, 'init'));
9
- }
10
-
11
- function init() {
12
- global $timber;
13
- if (isset($timber->router)) {
14
- $route = $timber->router->matchCurrentRequest();
15
- if ($route) {
16
- $callback = $route->getTarget();
17
- $params = $route->getParameters();
18
- $callback($params);
19
- }
20
- }
21
- }
22
-
23
- /**
24
- * @param string $route
25
- * @param callable $callback
26
- */
27
- public static function add_route($route, $callback, $args = array()) {
28
- global $timber;
29
- if (!isset($timber->router)) {
30
- if (class_exists('PHPRouter\Router')){
31
- $timber->router = new PHPRouter\Router();
32
- $site_url = get_bloginfo('url');
33
- $site_url_parts = explode('/', $site_url);
34
- $site_url_parts = array_slice($site_url_parts, 3);
35
- $base_path = implode('/', $site_url_parts);
36
- if (!$base_path || strpos($route, $base_path) === 0) {
37
- $base_path = '/';
38
- } else {
39
- $base_path = '/' . $base_path . '/';
40
- }
41
- $timber->router->setBasePath($base_path);
42
- }
43
- }
44
- if (class_exists('PHPRouter\Router')){
45
- $timber->router->map($route, $callback, $args);
46
- }
47
- }
48
-
49
- /**
50
- * @param array $template
51
- * @param mixed $query
52
- * @param int $status_code
53
- * @param bool $tparams
54
- * @return bool
55
- */
56
- public static function load_view($template, $query = false, $status_code = 200, $tparams = false) {
57
- $fullPath = is_readable($template);
58
- if (!$fullPath) {
59
- $template = locate_template($template);
60
- }
61
- if ($tparams){
62
- global $params;
63
- $params = $tparams;
64
- }
65
- if ($status_code) {
66
- add_filter('status_header', function($status_header, $header, $text, $protocol) use ($status_code) {
67
- $text = get_status_header_desc($status_code);
68
- $header_string = "$protocol $status_code $text";
69
- return $header_string;
70
- }, 10, 4 );
71
- if (404 != $status_code) {
72
- add_action('parse_query', function($query) {
73
- if ($query->is_main_query()){
74
- $query->is_404 = false;
75
- }
76
- },1);
77
- add_action('template_redirect', function(){
78
- global $wp_query;
79
- $wp_query->is_404 = false;
80
- },1);
81
- }
82
- }
83
-
84
- if ($query) {
85
- add_action('do_parse_request', function() use ($query) {
86
- global $wp;
87
- if ( is_callable($query) )
88
- $query = call_user_func($query);
89
-
90
- if ( is_array($query) )
91
- $wp->query_vars = $query;
92
- elseif ( !empty($query) )
93
- parse_str($query, $wp->query_vars);
94
- else
95
- return true; // Could not interpret query. Let WP try.
96
-
97
- return false;
98
- });
99
- }
100
- if ($template) {
101
- add_filter('template_include', function($t) use ($template) {
102
- return $template;
103
- });
104
- return true;
105
- }
106
- return false;
107
- }
108
- }
109
-
110
- global $timberRoutes;
111
- $timberRoutes = new TimberRoutes();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
functions/functions/timber-site.php DELETED
@@ -1,149 +0,0 @@
1
- <?php
2
-
3
- class TimberSite extends TimberCore implements TimberCoreInterface {
4
-
5
- public $admin_email;
6
- public $blogname;
7
- public $charset;
8
- public $description;
9
- public $id;
10
- public $language;
11
- public $language_attributes;
12
- public $multisite;
13
- public $name;
14
- public $pingback_url;
15
- public $siteurl;
16
- public $theme;
17
- public $title;
18
- public $url;
19
-
20
- /**
21
- *
22
- *
23
- * @param string|int $site_name_or_id
24
- */
25
- function __construct( $site_name_or_id = null ) {
26
- if ( is_multisite() ) {
27
- $this->init_with_multisite( $site_name_or_id );
28
- } else {
29
- $this->init();
30
- }
31
- }
32
-
33
- /**
34
- *
35
- *
36
- * @param string|int $site_name_or_id
37
- */
38
- function init_with_multisite( $site_name_or_id ) {
39
- if ( $site_name_or_id === null ) {
40
- //this is necessary for some reason, otherwise returns 1 all the time
41
- if ( is_multisite() ) {
42
- restore_current_blog();
43
- $site_name_or_id = get_current_blog_id();
44
- }
45
- }
46
- $info = get_blog_details( $site_name_or_id );
47
- $this->import( $info );
48
- $this->ID = $info->blog_id;
49
- $this->name = $this->blogname;
50
- $this->title = $this->blogname;
51
- $this->url = $this->siteurl;
52
- $this->id = $this->ID;
53
- $theme_slug = get_blog_option( $info->blog_id, 'stylesheet' );
54
- $this->theme = new TimberTheme( $theme_slug );
55
- $this->description = get_blog_option( $info->blog_id, 'blogdescription' );
56
- $this->multisite = true;
57
- }
58
-
59
- function init() {
60
- $this->admin_email = get_bloginfo( 'admin_email' );
61
- $this->name = get_bloginfo( 'name' );
62
- $this->title = $this->name;
63
- $this->description = get_bloginfo( 'description' );
64
- $this->url = get_bloginfo( 'url' );
65
- $this->language = get_bloginfo( 'language' );
66
- $this->charset = get_bloginfo( 'charset' );
67
- $this->pingback_url = get_bloginfo( 'pingback_url' );
68
- $this->theme = new TimberTheme();
69
- $this->language_attributes = TimberHelper::function_wrapper( 'language_attributes' );
70
- $this->multisite = false;
71
- }
72
-
73
- /**
74
- *
75
- *
76
- * @param string $field
77
- * @return mixed
78
- */
79
- function __get( $field ) {
80
- if ( !isset( $this->$field ) ) {
81
- if ( is_multisite() ) {
82
- $this->$field = get_blog_option( $this->ID, $field );
83
- } else {
84
- $this->$field = get_option( $field );
85
- }
86
- }
87
- return $this->$field;
88
- }
89
-
90
- /**
91
- *
92
- *
93
- * @return string
94
- */
95
- function get_link() {
96
- return $this->url;
97
- }
98
-
99
- /**
100
- *
101
- *
102
- * @return string
103
- */
104
- function get_url() {
105
- return $this->get_link();
106
- }
107
-
108
- /**
109
- *
110
- *
111
- * @return string
112
- */
113
- function link() {
114
- return $this->get_link();
115
- }
116
-
117
- /**
118
- *
119
- */
120
- function meta( $field ) {
121
- return $this->__get( $field );
122
- }
123
-
124
- /**
125
- *
126
- *
127
- * @param string $key
128
- * @param mixed $value
129
- */
130
- function update( $key, $value ) {
131
- $value = apply_filters( 'timber_site_set_meta', $value, $key, $this->ID, $this );
132
- if ( is_multisite() ) {
133
- update_blog_option( $this->ID, $key, $value );
134
- } else {
135
- update_option( $key, $value );
136
- }
137
- $this->$key = $value;
138
- }
139
-
140
- /**
141
- *
142
- *
143
- * @return string
144
- */
145
- function url() {
146
- return $this->get_link();
147
- }
148
-
149
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
functions/functions/timber-term-getter.php DELETED
@@ -1,182 +0,0 @@
1
- <?php
2
-
3
- class TimberTermGetter
4
- {
5
-
6
- /**
7
- * @param string|array $args
8
- * @param array $maybe_args
9
- * @param string $TermClass
10
- * @return mixed
11
- */
12
- public static function get_terms($args = null, $maybe_args = array(), $TermClass = 'TimberTerm'){
13
- if (is_string($maybe_args) && !strstr($maybe_args, '=')){
14
- //the user is sending the $TermClass in the second argument
15
- $TermClass = $maybe_args;
16
- }
17
- if (is_string($maybe_args) && strstr($maybe_args, '=')){
18
- parse_str($maybe_args, $maybe_args);
19
- }
20
- if (is_string($args) && strstr($args, '=')){
21
- //a string and a query string!
22
- $parsed = TimberTermGetter::get_term_query_from_query_string($args);
23
- if (is_array($maybe_args)){
24
- $parsed->args = array_merge($parsed->args, $maybe_args);
25
- }
26
- return self::handle_term_query($parsed->taxonomies, $parsed->args, $TermClass);
27
- } else if (is_string($args)){
28
- //its just a string with a single taxonomy
29
- $parsed = TimberTermGetter::get_term_query_from_string($args);
30
- if (is_array($maybe_args)){
31
- $parsed->args = array_merge($parsed->args, $maybe_args);
32
- }
33
- return self::handle_term_query($parsed->taxonomies, $parsed->args, $TermClass);
34
- } else if (is_array($args) && TimberHelper::is_array_assoc($args)){
35
- //its an associative array, like a good ole query
36
- $parsed = TimberTermGetter::get_term_query_from_assoc_array($args);
37
- return self::handle_term_query($parsed->taxonomies, $parsed->args, $TermClass);
38
- } else if (is_array($args)){
39
- //its just an array of strings or IDs (hopefully)
40
- $parsed = TimberTermGetter::get_term_query_from_array($args);
41
- if (is_array($maybe_args)){
42
- $parsed->args = array_merge($parsed->args, $maybe_args);
43
- }
44
- return self::handle_term_query($parsed->taxonomies, $parsed->args, $TermClass);
45
- } else if (is_null($args)) {
46
- return self::handle_term_query(get_taxonomies(), array(), $TermClass);
47
- }
48
- return null;
49
- }
50
-
51
- /**
52
- * @param string|array $taxonomies
53
- * @param string|array $args
54
- * @param string $TermClass
55
- * @return mixed
56
- */
57
- public static function handle_term_query($taxonomies, $args, $TermClass){
58
- if (!isset($args['hide_empty'])){
59
- $args['hide_empty'] = false;
60
- }
61
- if (isset($args['term_id']) && is_int($args['term_id'])){
62
- $args['term_id'] = array($args['term_id']);
63
- }
64
- if (isset($args['term_id'])){
65
- $args['include'] = $args['term_id'];
66
- }
67
- $terms = get_terms($taxonomies, $args);
68
- foreach($terms as &$term){
69
- $term = new $TermClass($term->term_id, $term->taxonomy);
70
- }
71
- return $terms;
72
- }
73
-
74
- /**
75
- * @param string $query_string
76
- * @return stdClass
77
- */
78
- public static function get_term_query_from_query_string($query_string) {
79
- $args = array();
80
- parse_str($query_string, $args);
81
- $ret = self::get_term_query_from_assoc_array($args);
82
- return $ret;
83
- }
84
-
85
- /**
86
- * @param string $taxs
87
- * @return stdClass
88
- */
89
- public static function get_term_query_from_string($taxs) {
90
- $ret = new stdClass();
91
- $ret->args = array();
92
- if (is_string($taxs)) {
93
- $taxs = array($taxs);
94
- }
95
- $ret->taxonomies = self::correct_taxonomy_names($taxs);
96
- return $ret;
97
- }
98
-
99
- /**
100
- * @param array $args
101
- * @return stdClass
102
- */
103
- public static function get_term_query_from_assoc_array($args) {
104
- $ret = new stdClass();
105
- $ret->args = $args;
106
- if (isset($ret->args['tax'])) {
107
- $ret->taxonomies = $ret->args['tax'];
108
- } else if (isset($ret->args['taxonomies'])) {
109
- $ret->taxonomies = $ret->args['taxonomies'];
110
- } else if (isset($ret->args['taxs'])) {
111
- $ret->taxonomies = $ret->args['taxs'];
112
- } else if (isset($ret->args['taxonomy'])) {
113
- $ret->taxonomies = $ret->args['taxonomy'];
114
- }
115
- if (isset($ret->taxonomies)) {
116
- if (is_string($ret->taxonomies)) {
117
- $ret->taxonomies = array($ret->taxonomies);
118
- }
119
- $ret->taxonomies = self::correct_taxonomy_names($ret->taxonomies);
120
- } else {
121
- $ret->taxonomies = get_taxonomies();
122
- }
123
- return $ret;
124
- }
125
-
126
- /**
127
- * @param array $args
128
- * @return stdClass
129
- */
130
- public static function get_term_query_from_array($args) {
131
- if (is_array($args) && !empty($args)) {
132
- //okay its an array with content
133
- if (is_int($args[0])) {
134
- return self::get_term_query_from_array_of_ids($args);
135
- } else if (is_string($args[0])) {
136
- return self::get_term_query_from_array_of_strings($args);
137
- }
138
- }
139
- return null;
140
- }
141
-
142
- /**
143
- * @param integer[] $args
144
- * @return stdClass
145
- */
146
- public static function get_term_query_from_array_of_ids($args) {
147
- $ret = new stdClass();
148
- $ret->taxonomies = get_taxonomies();
149
- $ret->args['include'] = $args;
150
- return $ret;
151
- }
152
-
153
- /**
154
- * @param string[] $args
155
- * @return stdClass
156
- */
157
- public static function get_term_query_from_array_of_strings($args) {
158
- $ret = new stdClass();
159
- $ret->taxonomies = self::correct_taxonomy_names($args);
160
- $ret->args = array();
161
- return $ret;
162
- }
163
-
164
- /**
165
- * @param string|array $taxs
166
- * @return array
167
- */
168
- private static function correct_taxonomy_names($taxs) {
169
- if (is_string($taxs)) {
170
- $taxs = array($taxs);
171
- }
172
- foreach ($taxs as &$tax) {
173
- if ($tax == 'tags' || $tax == 'tag') {
174
- $tax = 'post_tag';
175
- } else if ($tax == 'categories') {
176
- $tax = 'category';
177
- }
178
- }
179
- return $taxs;
180
- }
181
-
182
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
functions/functions/timber-term.php DELETED
@@ -1,328 +0,0 @@
1
- <?php
2
-
3
- class TimberTerm extends TimberCore implements TimberCoreInterface {
4
-
5
- public $PostClass = 'TimberPost';
6
- public $TermClass = 'TimberTerm';
7
-
8
- public $object_type = 'term';
9
- public static $representation = 'term';
10
-
11
- public $_children;
12
- public $name;
13
- public $taxonomy;
14
-
15
- /**
16
- * @param int $tid
17
- * @param string $tax
18
- */
19
- function __construct($tid = null, $tax = '') {
20
- if ($tid === null) {
21
- $tid = $this->get_term_from_query();
22
- }
23
- if (strlen($tax)) {
24
- $this->taxonomy = $tax;
25
- }
26
- $this->init($tid);
27
- }
28
-
29
- /**
30
- * @return string
31
- */
32
- function __toString() {
33
- return $this->name;
34
- }
35
-
36
-
37
-
38
- /* Setup
39
- ===================== */
40
-
41
- /**
42
- * @return integer
43
- */
44
- private function get_term_from_query() {
45
- global $wp_query;
46
- $qo = $wp_query->queried_object;
47
- return $qo->term_id;
48
- }
49
-
50
- /**
51
- * @param int $tid
52
- */
53
- private function init($tid) {
54
- $term = $this->get_term($tid);
55
- if (isset($term->id)) {
56
- $term->ID = $term->id;
57
- } else if (isset($term->term_id)) {
58
- $term->ID = $term->term_id;
59
- } else if (is_string($tid)) {
60
- //echo 'bad call using '.$tid;
61
- //TimberHelper::error_log(debug_backtrace());
62
- }
63
- if (isset($term->ID)){
64
- $term->id = $term->ID;
65
- $this->import($term);
66
- if (isset($term->term_id)) {
67
- $custom = $this->get_term_meta($term->term_id);
68
- $this->import($custom);
69
- }
70
- }
71
- }
72
-
73
- /**
74
- * @param int $tid
75
- * @return array
76
- */
77
- private function get_term_meta($tid) {
78
- $customs = array();
79
- $customs = apply_filters('timber_term_get_meta', $customs, $tid, $this);
80
- return $customs;
81
- }
82
-
83
- /**
84
- * @param int $tid
85
- * @return mixed
86
- */
87
- private function get_term($tid) {
88
- if (is_object($tid) || is_array($tid)) {
89
- return $tid;
90
- }
91
- $tid = self::get_tid($tid);
92
-
93
- if (isset($this->taxonomy) && strlen($this->taxonomy)) {
94
- return get_term($tid, $this->taxonomy);
95
- } else {
96
- global $wpdb;
97
- $query = $wpdb->prepare("SELECT taxonomy FROM $wpdb->term_taxonomy WHERE term_id = %d LIMIT 1", $tid);
98
- $tax = $wpdb->get_var($query);
99
- if (isset($tax) && strlen($tax)) {
100
- return get_term($tid, $tax);
101
- }
102
- }
103
- return null;
104
- }
105
-
106
- /**
107
- * @param int $tid
108
- * @return int
109
- */
110
- private function get_tid($tid) {
111
- global $wpdb;
112
- if (is_numeric($tid)) {
113
- return $tid;
114
- }
115
- if (gettype($tid) == 'object') {
116
- $tid = $tid->term_id;
117
- }
118
- if (is_numeric($tid)) {
119
- $query = $wpdb->prepare("SELECT * FROM $wpdb->terms WHERE term_id = %d", $tid);
120
- } else {
121
- $query = $wpdb->prepare("SELECT * FROM $wpdb->terms WHERE slug = %s", $tid);
122
- }
123
- $result = $wpdb->get_row($query);
124
- if (isset($result->term_id)) {
125
- $result->ID = $result->term_id;
126
- $result->id = $result->term_id;
127
- return $result->ID;
128
- }
129
- return 0;
130
- }
131
-
132
- /* Public methods
133
- ===================== */
134
-
135
- /**
136
- * @return string
137
- */
138
- public function get_edit_url() {
139
- return get_edit_term_link($this->ID, $this->taxonomy);
140
- }
141
-
142
- /**
143
- * @param string $field_name
144
- * @return string
145
- */
146
- public function get_meta_field($field_name) {
147
- if (!isset($this->$field_name)) {
148
- $field_value = '';
149
- $field_value = apply_filters('timber_term_get_meta_field', $field_value, $this->ID, $field_name, $this);
150
- $this->$field_name = $field_value;
151
- }
152
- return $this->$field_name;
153
- }
154
-
155
- /**
156
- * @return string
157
- */
158
- public function get_path() {
159
- $link = $this->get_link();
160
- $rel = TimberURLHelper::get_rel_url($link, true);
161
- return apply_filters('timber_term_path', $rel, $this);
162
- }
163
-
164
- /**
165
- * @return string
166
- */
167
- public function get_link() {
168
- $link = get_term_link($this);
169
- return apply_filters('timber_term_link', $link, $this);
170
- }
171
-
172
- /**
173
- * @param int $numberposts
174
- * @param string $post_type
175
- * @param string $PostClass
176
- * @return array|bool|null
177
- */
178
- public function get_posts($numberposts = 10, $post_type = 'any', $PostClass = '') {
179
- if (!strlen($PostClass)) {
180
- $PostClass = $this->PostClass;
181
- }
182
- $default_tax_query = array(array(
183
- 'field' => 'id',
184
- 'terms' => $this->ID,
185
- 'taxonomy' => $this->taxonomy,
186
- ));
187
- if (is_string($numberposts) && strstr($numberposts, '=')) {
188
- $args = $numberposts;
189
- $new_args = array();
190
- parse_str($args, $new_args);
191
- $args = $new_args;
192
- $args['tax_query'] = $default_tax_query;
193
- if (!isset($args['post_type'])) {
194
- $args['post_type'] = 'any';
195
- }
196
- if (class_exists($post_type)) {
197
- $PostClass = $post_type;
198
- }
199
- } else if (is_array($numberposts)) {
200
- //they sent us an array already baked
201
- $args = $numberposts;
202
- if (!isset($args['tax_query'])) {
203
- $args['tax_query'] = $default_tax_query;
204
- }
205
- if (class_exists($post_type)) {
206
- $PostClass = $post_type;
207
- }
208
- if (!isset($args['post_type'])) {
209
- $args['post_type'] = 'any';
210
- }
211
- } else {
212
- $args = array(
213
- 'numberposts' => $numberposts,
214
- 'tax_query' => $default_tax_query,
215
- 'post_type' => $post_type
216
- );
217
- }
218
- return Timber::get_posts($args, $PostClass);
219
- }
220
-
221
- /**
222
- * @return array
223
- */
224
- public function get_children() {
225
- if (!isset($this->_children)) {
226
- $children = get_term_children($this->ID, $this->taxonomy);
227
- foreach ($children as &$child) {
228
- $child = new TimberTerm($child);
229
- }
230
- $this->_children = $children;
231
- }
232
- return $this->_children;
233
- }
234
-
235
- /**
236
- *
237
- *
238
- * @param string $key
239
- * @param mixed $value
240
- */
241
- function update( $key, $value ) {
242
- $value = apply_filters( 'timber_term_set_meta', $value, $key, $this->ID, $this );
243
- $this->$key = $value;
244
- }
245
-
246
- /* Alias
247
- ====================== */
248
-
249
- /**
250
- * @return array
251
- */
252
- public function children() {
253
- return $this->get_children();
254
- }
255
-
256
- /**
257
- * @return string
258
- */
259
- public function edit_link() {
260
- return $this->get_edit_url();
261
- }
262
-
263
- /**
264
- * @return string
265
- */
266
- public function get_url() {
267
- return $this->get_link();
268
- }
269
-
270
- /**
271
- * @return string
272
- */
273
- public function link() {
274
- return $this->get_link();
275
- }
276
-
277
- /**
278
- * @param string $field_name
279
- * @return string
280
- */
281
- public function meta($field_name) {
282
- return $this->get_meta_field($field_name);
283
- }
284
-
285
- /**
286
- * @return string
287
- */
288
- public function path() {
289
- return $this->get_path();
290
- }
291
-
292
- /**
293
- * @param int $numberposts_or_args
294
- * @param string $post_type_or_class
295
- * @param string $post_class
296
- * @return array|bool|null
297
- */
298
- public function posts($numberposts_or_args = 10, $post_type_or_class = 'any', $post_class = '') {
299
- return $this->get_posts($numberposts_or_args, $post_type_or_class, $post_class);
300
- }
301
-
302
- /**
303
- * @return string
304
- */
305
- public function title() {
306
- return $this->name;
307
- }
308
-
309
- /**
310
- * @return string
311
- */
312
- public function url() {
313
- return $this->get_url();
314
- }
315
-
316
- /* Deprecated
317
- ===================== */
318
-
319
- /**
320
- * @deprecated
321
- * @param int $i
322
- * @return string
323
- */
324
- function get_page($i) {
325
- return $this->get_path() . '/page/' . $i;
326
- }
327
-
328
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
functions/functions/timber-theme.php DELETED
@@ -1,58 +0,0 @@
1
- <?php
2
-
3
- class TimberTheme extends TimberCore
4
- {
5
-
6
- public $link;
7
- public $name;
8
- public $path;
9
- public $parent;
10
- public $parent_slug;
11
- public $slug;
12
- public $uri;
13
-
14
- /**
15
- * @param string $slug
16
- */
17
- function __construct($slug = null) {
18
- $this->init($slug);
19
- }
20
-
21
- /**
22
- * @param string $slug
23
- */
24
- function init($slug = null) {
25
- $data = wp_get_theme($slug);
26
- $this->name = $data->get('Name');
27
- $ss = $data->get_stylesheet();
28
- $this->slug = $ss;
29
- $this->path = WP_CONTENT_SUBDIR . str_replace(WP_CONTENT_DIR, '', get_stylesheet_directory());
30
- $this->uri = get_stylesheet_directory_uri();
31
- $this->link = $this->uri;
32
- $this->parent_slug = $data->get('Template');
33
- if (!$this->parent_slug) {
34
- $this->path = WP_CONTENT_SUBDIR . str_replace(WP_CONTENT_DIR, '', get_template_directory());
35
- $this->uri = get_template_directory_uri();
36
- }
37
- if ($this->parent_slug && $this->parent_slug != $this->slug) {
38
- $this->parent = new TimberTheme($this->parent_slug);
39
- }
40
- }
41
-
42
- /**
43
- * @param string $name
44
- * @param bool $default
45
- * @return string
46
- */
47
- public function theme_mod($name, $default = false) {
48
- return get_theme_mod($name, $default);
49
- }
50
-
51
- /**
52
- * @return string
53
- */
54
- public function theme_mods() {
55
- return get_theme_mods();
56
- }
57
-
58
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
functions/functions/timber-twig.php DELETED
@@ -1,289 +0,0 @@
1
- <?php
2
-
3
- class TimberTwig {
4
-
5
- public static $dir_name;
6
-
7
- function __construct() {
8
- add_action( 'twig_apply_filters', array( $this, 'add_timber_filters_deprecated' ) );
9
- add_action( 'twig_apply_filters', array( $this, 'add_timber_filters' ) );
10
- }
11
-
12
- /**
13
- * These are all deprecated and will be removed in 0.21.0
14
- *
15
- * @param Twig_Environment $twig
16
- * @deprecated since 0.20.7
17
- * @return Twig_Environment
18
- */
19
- function add_timber_filters_deprecated( $twig ) {
20
- $twig->addFilter( new Twig_SimpleFilter( 'get_src_from_attachment_id', 'twig_get_src_from_attachment_id' ) );
21
- $twig->addFilter( new Twig_SimpleFilter( 'wp_body_class', array( $this, 'body_class' ) ) );
22
- $twig->addFilter( new Twig_SimpleFilter( 'twitterify', array( 'TimberHelper', 'twitterify' ) ) );
23
- $twig->addFilter( new Twig_SimpleFilter( 'twitterfy', array( 'TimberHelper', 'twitterify' ) ) );
24
- return $twig;
25
- }
26
-
27
- /**
28
- *
29
- *
30
- * @param Twig_Environment $twig
31
- * @return Twig_Environment
32
- */
33
- function add_timber_filters( $twig ) {
34
- /* image filters */
35
- $twig->addFilter( new Twig_SimpleFilter( 'resize', array( 'TimberImageHelper', 'resize' ) ) );
36
- $twig->addFilter( new Twig_SimpleFilter( 'retina', array( 'TimberImageHelper', 'retina_resize' ) ) );
37
- $twig->addFilter( new Twig_SimpleFilter( 'letterbox', array( 'TimberImageHelper', 'letterbox' ) ) );
38
- $twig->addFilter( new Twig_SimpleFilter( 'tojpg', array( 'TimberImageHelper', 'img_to_jpg' ) ) );
39
-
40
- /* debugging filters */
41
- $twig->addFilter( new Twig_SimpleFilter( 'docs', 'twig_object_docs' ) );
42
- $twig->addFilter( new Twig_SimpleFilter( 'get_class', 'get_class' ) );
43
- $twig->addFilter( new Twig_SimpleFilter( 'get_type', 'get_type' ) );
44
- $twig->addFilter( new Twig_SimpleFilter( 'print_r', function( $arr ) {
45
- return print_r( $arr, true );
46
- } ) );
47
- $twig->addFilter( new Twig_SimpleFilter( 'print_a', function( $arr ) {
48
- return '<pre>' . self::object_docs( $arr, true ) . '</pre>';
49
- } ) );
50
-
51
- /* other filters */
52
- $twig->addFilter( new Twig_SimpleFilter( 'stripshortcodes', 'strip_shortcodes' ) );
53
- $twig->addFilter( new Twig_SimpleFilter( 'array', array( $this, 'to_array' ) ) );
54
- $twig->addFilter( new Twig_SimpleFilter( 'string', array( $this, 'to_string' ) ) );
55
- $twig->addFilter( new Twig_SimpleFilter( 'excerpt', 'wp_trim_words' ) );
56
- $twig->addFilter( new Twig_SimpleFilter( 'function', array( $this, 'exec_function' ) ) );
57
- $twig->addFilter( new Twig_SimpleFilter( 'pretags', array( $this, 'twig_pretags' ) ) );
58
- $twig->addFilter( new Twig_SimpleFilter( 'sanitize', 'sanitize_title' ) );
59
- $twig->addFilter( new Twig_SimpleFilter( 'shortcodes', 'do_shortcode' ) );
60
- $twig->addFilter( new Twig_SimpleFilter( 'time_ago', array( $this, 'time_ago' ) ) );
61
- $twig->addFilter( new Twig_SimpleFilter( 'wpautop', 'wpautop' ) );
62
-
63
- $twig->addFilter( new Twig_SimpleFilter( 'relative', function ( $link ) {
64
- return TimberURLHelper::get_rel_url( $link, true );
65
- } ) );
66
-
67
- $twig->addFilter( new Twig_SimpleFilter( 'date', array( $this, 'intl_date' ) ) );
68
-
69
- $twig->addFilter( new Twig_SimpleFilter( 'truncate', function ( $text, $len ) {
70
- return TimberHelper::trim_words( $text, $len );
71
- } ) );
72
-
73
- /* actions and filters */
74
- $twig->addFunction( new Twig_SimpleFunction( 'action', function ( $context ) {
75
- $args = func_get_args();
76
- array_shift( $args );
77
- $args[] = $context;
78
- call_user_func_array( 'do_action', $args );
79
- }, array( 'needs_context' => true ) ) );
80
-
81
- $twig->addFilter( new Twig_SimpleFilter( 'apply_filters', function () {
82
- $args = func_get_args();
83
- $tag = current( array_splice( $args, 1, 1 ) );
84
-
85
- return apply_filters_ref_array( $tag, $args );
86
- } ) );
87
- $twig->addFunction( new Twig_SimpleFunction( 'function', array( &$this, 'exec_function' ) ) );
88
- $twig->addFunction( new Twig_SimpleFunction( 'fn', array( &$this, 'exec_function' ) ) );
89
-
90
- /* TimberObjects */
91
- $twig->addFunction( new Twig_SimpleFunction( 'TimberPost', function ( $pid, $PostClass = 'TimberPost' ) {
92
- if ( is_array( $pid ) && !TimberHelper::is_array_assoc( $pid ) ) {
93
- foreach ( $pid as &$p ) {
94
- $p = new $PostClass( $p );
95
- }
96
- return $pid;
97
- }
98
- return new $PostClass( $pid );
99
- } ) );
100
- $twig->addFunction( new Twig_SimpleFunction( 'TimberImage', function ( $pid, $ImageClass = 'TimberImage' ) {
101
- if ( is_array( $pid ) && !TimberHelper::is_array_assoc( $pid ) ) {
102
- foreach ( $pid as &$p ) {
103
- $p = new $ImageClass( $p );
104
- }
105
- return $pid;
106
- }
107
- return new $ImageClass( $pid );
108
- } ) );
109
- $twig->addFunction( new Twig_SimpleFunction( 'TimberTerm', function ( $pid, $TermClass = 'TimberTerm' ) {
110
- if ( is_array( $pid ) && !TimberHelper::is_array_assoc( $pid ) ) {
111
- foreach ( $pid as &$p ) {
112
- $p = new $TermClass( $p );
113
- }
114
- return $pid;
115
- }
116
- return new $TermClass( $pid );
117
- } ) );
118
- $twig->addFunction( new Twig_SimpleFunction( 'TimberUser', function ( $pid, $UserClass = 'TimberUser' ) {
119
- if ( is_array( $pid ) && !TimberHelper::is_array_assoc( $pid ) ) {
120
- foreach ( $pid as &$p ) {
121
- $p = new $UserClass( $p );
122
- }
123
- return $pid;
124
- }
125
- return new $UserClass( $pid );
126
- } ) );
127
-
128
- /* bloginfo and translate */
129
- $twig->addFunction( 'bloginfo', new Twig_SimpleFunction( 'bloginfo', function ( $show = '', $filter = 'raw' ) {
130
- return get_bloginfo( $show, $filter );
131
- } ) );
132
- $twig->addFunction( '__', new Twig_SimpleFunction( '__', function ( $text, $domain = 'default' ) {
133
- return __( $text, $domain );
134
- } ) );
135
-
136
- $twig = apply_filters( 'get_twig', $twig );
137
-
138
- return $twig;
139
- }
140
-
141
- /**
142
- *
143
- *
144
- * @param mixed $arr
145
- * @return array
146
- */
147
- function to_array( $arr ) {
148
- if ( is_array( $arr ) ) {
149
- return $arr;
150
- }
151
- $arr = array( $arr );
152
- return $arr;
153
- }
154
-
155
- /**
156
- *
157
- *
158
- * @param mixed $arr
159
- * @param string $glue
160
- * @return string
161
- */
162
- function to_string( $arr, $glue = ' ' ) {
163
- if ( is_string( $arr ) ) {
164
- return $arr;
165
- }
166
- if ( is_array( $arr ) && count( $arr ) == 1 ) {
167
- return $arr[0];
168
- }
169
- if ( is_array( $arr ) ) {
170
- return implode( $glue, $arr );
171
- }
172
- return null;
173
- }
174
-
175
- /**
176
- *
177
- *
178
- * @param string $function_name
179
- * @return mixed
180
- */
181
- function exec_function( $function_name ) {
182
- $args = func_get_args();
183
- array_shift( $args );
184
- return call_user_func_array( trim( $function_name ), ( $args ) );
185
- }
186
-
187
- /**
188
- *
189
- *
190
- * @param string $content
191
- * @return string
192
- */
193
- function twig_pretags( $content ) {
194
- return preg_replace_callback( '|<pre.*>(.*)</pre|isU', array( &$this, 'convert_pre_entities' ), $content );
195
- }
196
-
197
- /**
198
- *
199
- *
200
- * @param array $matches
201
- * @return string
202
- */
203
- function convert_pre_entities( $matches ) {
204
- return str_replace( $matches[1], htmlentities( $matches[1] ), $matches[0] );
205
- }
206
-
207
- /**
208
- *
209
- *
210
- * @param mixed $body_classes
211
- * @return string
212
- */
213
- function body_class( $body_classes ) {
214
- ob_start();
215
- if ( is_array( $body_classes ) ) {
216
- $body_classes = explode( ' ', $body_classes );
217
- }
218
- body_class( $body_classes );
219
- $return = ob_get_contents();
220
- ob_end_clean();
221
- return $return;
222
- }
223
-
224
- /**
225
- *
226
- *
227
- * @param string $date
228
- * @param string $format (optional)
229
- * @return string
230
- */
231
- function intl_date( $date, $format = null ) {
232
- if ( $format === null ) {
233
- $format = get_option( 'date_format' );
234
- }
235
-
236
- if ( $date instanceof DateTime ) {
237
- $timestamp = $date->getTimestamp();
238
- } else {
239
- $timestamp = strtotime( $date );
240
- }
241
-
242
- return date_i18n( $format, $timestamp );
243
- }
244
-
245
- //debug
246
-
247
- /**
248
- *
249
- *
250
- * @param mixed $obj
251
- * @param bool $methods
252
- * @return string
253
- */
254
- function object_docs( $obj, $methods = true ) {
255
- $class = get_class( $obj );
256
- $properties = (array)$obj;
257
- if ( $methods ) {
258
- /** @var array $methods */
259
- $methods = $obj->get_method_values();
260
- }
261
- $rets = array_merge( $properties, $methods );
262
- ksort( $rets );
263
- $str = print_r( $rets, true );
264
- $str = str_replace( 'Array', $class . ' Object', $str );
265
- return $str;
266
- }
267
-
268
- /**
269
- * @param int|string $from
270
- * @param int|string $to
271
- * @param string $format_past
272
- * @param string $format_future
273
- * @return string
274
- */
275
- function time_ago( $from, $to = null, $format_past = '%s ago', $format_future = '%s from now' ) {
276
- $to = $to === null ? time() : $to;
277
- $to = is_int( $to ) ? $to : strtotime( $to );
278
- $from = is_int( $from ) ? $from : strtotime( $from );
279
-
280
- if ( $from < $to ) {
281
- return sprintf( $format_past, human_time_diff( $from, $to ) );
282
- } else {
283
- return sprintf( $format_future, human_time_diff( $to, $from ) );
284
- }
285
- }
286
-
287
- }
288
-
289
- new TimberTwig();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
functions/functions/timber-url-helper.php DELETED
@@ -1,246 +0,0 @@
1
- <?php
2
-
3
- class TimberURLHelper {
4
-
5
- /**
6
- * @return string
7
- */
8
- public static function get_current_url() {
9
- $pageURL = "http://";
10
- if (isset($_SERVER['HTTPS']) && $_SERVER["HTTPS"] == "on") {
11
- $pageURL = "https://";;
12
- }
13
- if ($_SERVER["SERVER_PORT"] != "80") {
14
- $pageURL .= $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"];
15
- } else {
16
- $pageURL .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
17
- }
18
- return $pageURL;
19
- }
20
-
21
- /**
22
- * @param string $url
23
- * @return bool
24
- */
25
- public static function is_url($url) {
26
- if (!is_string($url)) {
27
- return false;
28
- }
29
- $url = strtolower($url);
30
- if (strstr($url, '://')) {
31
- return true;
32
- }
33
- return false;
34
- }
35
-
36
- /**
37
- * @return string
38
- */
39
- public static function get_path_base() {
40
- $struc = get_option('permalink_structure');
41
- $struc = explode('/', $struc);
42
- $p = '/';
43
- foreach ($struc as $s) {
44
- if (!strstr($s, '%') && strlen($s)) {
45
- $p .= $s . '/';
46
- }
47
- }
48
- return $p;
49
- }
50
-
51
- /**
52
- * @param string $url
53
- * @param bool $force
54
- * @return string
55
- */
56
- public static function get_rel_url($url, $force = false) {
57
- $url_info = parse_url($url);
58
- if (isset($url_info['host']) && $url_info['host'] != $_SERVER['HTTP_HOST'] && !$force) {
59
- return $url;
60
- }
61
- $link = '';
62
- if (isset($url_info['path'])){
63
- $link = $url_info['path'];
64
- }
65
- if (isset($url_info['query']) && strlen($url_info['query'])) {
66
- $link .= '?' . $url_info['query'];
67
- }
68
- if (isset($url_info['fragment']) && strlen($url_info['fragment'])) {
69
- $link .= '#' . $url_info['fragment'];
70
- }
71
- $link = TimberURLHelper::remove_double_slashes($link);
72
- return $link;
73
- }
74
-
75
- /**
76
- * @param string $url
77
- * @return bool
78
- */
79
- public static function is_local($url) {
80
- if (strstr($url, $_SERVER['HTTP_HOST'])) {
81
- return true;
82
- }
83
- return false;
84
- }
85
-
86
- /**
87
- * @param string $src
88
- * @return string
89
- */
90
- public static function get_full_path($src) {
91
- $root = ABSPATH;
92
- $old_root_path = $root . $src;
93
- $old_root_path = str_replace('//', '/', $old_root_path);
94
- return $old_root_path;
95
- }
96
-
97
- /**
98
- * Takes a url and figures out its place based in the file system based on path
99
- * NOTE: Not fool-proof, makes a lot of assumptions about the file path
100
- * matching the URL path
101
- * @param string $url
102
- * @return string
103
- */
104
- public static function url_to_file_system($url) {
105
- $url_parts = parse_url($url);
106
- $path = ABSPATH . $url_parts['path'];
107
- $path = str_replace('//', '/', $path);
108
- return $path;
109
- }
110
-
111
- public static function file_system_to_url( $fs ) {
112
- $relative_path = self::get_rel_path($fs);
113
- $home = home_url('/'.$relative_path);
114
- return $home;
115
- }
116
-
117
- /**
118
- * @param string $src
119
- * @return string
120
- */
121
- public static function get_rel_path($src) {
122
- if (strstr($src, ABSPATH)) {
123
- return str_replace(ABSPATH, '', $src);
124
- }
125
- //its outside the wordpress directory, alternate setups:
126
- $src = str_replace(WP_CONTENT_DIR, '', $src);
127
- return WP_CONTENT_SUBDIR . $src;
128
- }
129
-
130
- /**
131
- * @param string $url
132
- * @return string
133
- */
134
- public static function remove_double_slashes($url) {
135
- $url = str_replace('//', '/', $url);
136
- if (strstr($url, 'http:') && !strstr($url, 'http://')) {
137
- $url = str_replace('http:/', 'http://', $url);
138
- }
139
- return $url;
140
- }
141
-
142
- /**
143
- * @param string $url
144
- * @param string $path
145
- * @return string
146
- */
147
- public static function prepend_to_url($url, $path) {
148
- if (strstr(strtolower($url), 'http')) {
149
- $url_parts = parse_url($url);
150
- $url = $url_parts['scheme'] . '://' . $url_parts['host'] . $path . $url_parts['path'];
151
- } else {
152
- $url = $url . $path;
153
- }
154
- return self::remove_double_slashes($url);
155
- }
156
-
157
- /**
158
- * @param string $path
159
- * @return string
160
- */
161
- public static function preslashit($path) {
162
- if (strpos($path, '/') != 0) {
163
- $path = '/' . $path;
164
- }
165
- return $path;
166
- }
167
-
168
- /**
169
- * @param string $url
170
- * @return bool
171
- */
172
- public static function is_external($url) {
173
- $has_http = strstr(strtolower($url), 'http');
174
- $on_domain = strstr($url, $_SERVER['HTTP_HOST']);
175
- if ($has_http && !$on_domain) {
176
- return true;
177
- }
178
- return false;
179
- }
180
-
181
- /**
182
- * Pass links through untrailingslashit unless they are a single /
183
- *
184
- * @param string $link
185
- * @return string
186
- */
187
- public static function remove_trailing_slash($link) {
188
- if ( $link != "/")
189
- $link = untrailingslashit( $link );
190
- return $link;
191
- }
192
-
193
- /**
194
- * @param string $url
195
- * @param int $timeout
196
- * @return string|WP_Error
197
- * @deprecated since 0.20.0
198
- */
199
- static function download_url($url, $timeout = 300) {
200
- if (!$url) {
201
- return new WP_Error('http_no_url', __('Invalid URL Provided.'));
202
- }
203
-
204
- $tmpfname = wp_tempnam($url);
205
- if (!$tmpfname) {
206
- return new WP_Error('http_no_file', __('Could not create Temporary file.'));
207
- }
208
-
209
- $response = wp_remote_get($url, array('timeout' => $timeout, 'stream' => true, 'filename' => $tmpfname));
210
-
211
- if (is_wp_error($response)) {
212
- unlink($tmpfname);
213
- return $response;
214
- }
215
- if (200 != wp_remote_retrieve_response_code($response)) {
216
- unlink($tmpfname);
217
- return new WP_Error('http_404', trim(wp_remote_retrieve_response_message($response)));
218
- }
219
- return $tmpfname;
220
- }
221
-
222
- /**
223
- * @param int $i
224
- * @return array
225
- */
226
- public static function get_params($i = false) {
227
- $args = explode('/', trim(strtolower($_SERVER['REQUEST_URI'])));
228
- $newargs = array();
229
- foreach ($args as $arg) {
230
- if (strlen($arg)) {
231
- $newargs[] = $arg;
232
- }
233
- }
234
- if ($i === false){
235
- return $newargs;
236
- }
237
- if ($i < 0){
238
- //count from end
239
- $i = count($newargs) + $i;
240
- }
241
- if (isset($newargs[$i])) {
242
- return $newargs[$i];
243
- }
244
- }
245
-
246
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
functions/functions/timber-user.php DELETED
@@ -1,193 +0,0 @@
1
- <?php
2
-
3
- class TimberUser extends TimberCore implements TimberCoreInterface {
4
-
5
- public $object_type = 'user';
6
- public static $representation = 'user';
7
-
8
- public $_link;
9
-
10
- public $display_name;
11
- public $id;
12
- public $name;
13
- public $user_nicename;
14
-
15
- /**
16
- * @param int|bool $uid
17
- */
18
- function __construct($uid = false) {
19
- $this->init($uid);
20
- }
21
-
22
- /**
23
- * @return string
24
- */
25
- function __toString() {
26
- $name = $this->name();
27
- if (strlen($name)) {
28
- return $name;
29
- }
30
- if (strlen($this->name)) {
31
- return $this->name;
32
- }
33
- return '';
34
- }
35
-
36
- /**
37
- * @param string $field_name
38
- * @return null
39
- */
40
- function get_meta($field_name) {
41
- return $this->get_meta_field( $field_name );
42
- }
43
-
44
- /**
45
- * @param string $field
46
- * @param mixed $value
47
- */
48
- function __set($field, $value) {
49
- if ($field == 'name') {
50
- $this->display_name = $value;
51
- }
52
- $this->$field = $value;
53
- }
54
-
55
- /**
56
- * @return string
57
- */
58
- public function get_link() {
59
- if (!$this->_link) {
60
- $this->_link = get_author_posts_url($this->ID);
61
- }
62
- return $this->_link;
63
- }
64
-
65
- /**
66
- * @param int|bool $uid
67
- */
68
- function init($uid = false) {
69
- if ($uid === false) {
70
- $uid = get_current_user_id();
71
- }
72
- if (is_object($uid) || is_array($uid)){
73
- $data = $uid;
74
- if (is_array($uid)){
75
- $data = (object) $uid;
76
- }
77
- $uid = $data->ID;
78
- }
79
- if (is_numeric($uid)) {
80
- $data = get_userdata($uid);
81
- }
82
- if (isset($data) && is_object($data)) {
83
- if (isset($data->data)){
84
- $this->import($data->data);
85
- } else {
86
- $this->import($data);
87
- }
88
- }
89
- $this->id = $this->ID;
90
- $this->name = $this->name();
91
- $this->import_custom();
92
- }
93
-
94
- /**
95
- * @param string $field_name
96
- * @return mixed
97
- */
98
- function get_meta_field($field_name) {
99
- $value = null;
100
- $value = apply_filters('timber_user_get_meta_field_pre', $value, $this->ID, $field_name, $this);
101
- if ($value === null) {
102
- $value = get_user_meta($this->ID, $field_name, true);
103
- }
104
- $value = apply_filters('timber_user_get_meta_field', $value, $this->ID, $field_name, $this);
105
- return $value;
106
- }
107
-
108
- /**
109
- * @return array|null
110
- */
111
- function get_custom() {
112
- if ($this->ID) {
113
- $um = array();
114
- $um = apply_filters('timber_user_get_meta_pre', $um, $this->ID, $this);
115
- if (empty($um)) {
116
- $um = get_user_meta($this->ID);
117
- }
118
- $custom = array();
119
- foreach ($um as $key => $value) {
120
- if (is_array($value) && count($value) == 1) {
121
- $value = $value[0];
122
- }
123
- $custom[$key] = maybe_unserialize($value);
124
- }
125
- $custom = apply_filters('timber_user_get_meta', $custom, $this->ID, $this);
126
- return $custom;
127
- }
128
- return null;
129
- }
130
-
131
- function import_custom() {
132
- $custom = $this->get_custom();
133
- $this->import($custom);
134
- }
135
-
136
- /**
137
- * @return string
138
- */
139
- function name() {
140
- return $this->display_name;
141
- }
142
-
143
- /**
144
- * @return string
145
- */
146
- function get_permalink() {
147
- return $this->get_link();
148
- }
149
-
150
- /**
151
- * @return string
152
- */
153
- function permalink() {
154
- return $this->get_link();
155
- }
156
-
157
- /**
158
- * @return string
159
- */
160
- function get_path() {
161
- return $this->get_link();
162
- }
163
-
164
- /**
165
- * @param string $field_name
166
- * @return mixed
167
- */
168
- function meta($field_name) {
169
- return $this->get_meta_field($field_name);
170
- }
171
-
172
- /**
173
- * @return string
174
- */
175
- function path() {
176
- return $this->get_path();
177
- }
178
-
179
- /**
180
- * @return string
181
- */
182
- function slug() {
183
- return $this->user_nicename;
184
- }
185
-
186
- /**
187
- * @return string
188
- */
189
- function link() {
190
- return $this->get_link();
191
- }
192
-
193
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
functions/timber-admin.php CHANGED
@@ -16,7 +16,7 @@ class TimberAdmin {
16
  function meta_links( $links, $file ) {
17
  if ( strstr( $file, '/timber.php' ) ) {
18
  unset($links[2]);
19
- $links[] = '<a href="http://localhost/wp-admin/plugin-install.php?tab=plugin-information&amp;plugin=timber-library&amp;TB_iframe=true&amp;width=600&amp;height=550" class="thickbox" aria-label="More information about Timber" data-title="Timber">View details</a>';
20
  $links[] = '<a href="http://upstatement.com/timber" target="_blank">Homepage</a>';
21
  $links[] = '<a href="https://github.com/jarednova/timber/wiki" target="_blank">Documentation</a>';
22
  $links[] = '<a href="https://github.com/jarednova/timber/wiki/getting-started" target="_blank">Starter Guide</a>';
16
  function meta_links( $links, $file ) {
17
  if ( strstr( $file, '/timber.php' ) ) {
18
  unset($links[2]);
19
+ $links[] = '<a href="/wp-admin/plugin-install.php?tab=plugin-information&amp;plugin=timber-library&amp;TB_iframe=true&amp;width=600&amp;height=550" class="thickbox" aria-label="More information about Timber" data-title="Timber">View details</a>';
20
  $links[] = '<a href="http://upstatement.com/timber" target="_blank">Homepage</a>';
21
  $links[] = '<a href="https://github.com/jarednova/timber/wiki" target="_blank">Documentation</a>';
22
  $links[] = '<a href="https://github.com/jarednova/timber/wiki/getting-started" target="_blank">Starter Guide</a>';
functions/timber-menu-item.php CHANGED
@@ -29,9 +29,6 @@ class TimberMenuItem extends TimberCore implements TimberCoreInterface {
29
  $this->name = $this->name();
30
  $this->add_class( 'menu-item-' . $this->ID );
31
  $this->menu_object = $data;
32
- if ( isset( $this->url ) && $this->url ) {
33
- $this->url = TimberURLHelper::remove_trailing_slash( $this->url );
34
- }
35
  }
36
 
37
  function __toString() {
@@ -97,7 +94,7 @@ class TimberMenuItem extends TimberCore implements TimberCoreInterface {
97
  $this->url = $this->menu_object->get_link();
98
  }
99
  }
100
- return TimberURLHelper::remove_trailing_slash( $this->url );
101
  }
102
 
103
  /**
@@ -106,7 +103,7 @@ class TimberMenuItem extends TimberCore implements TimberCoreInterface {
106
  * @return string
107
  */
108
  function get_path() {
109
- return TimberURLHelper::remove_trailing_slash( TimberURLHelper::get_rel_url( $this->get_link() ) );
110
  }
111
 
112
  /**
@@ -133,6 +130,7 @@ class TimberMenuItem extends TimberCore implements TimberCoreInterface {
133
  function import_classes( $data ) {
134
  $this->classes = array_merge($this->classes, $data->classes);
135
  $this->classes = array_unique($this->classes);
 
136
  $this->class = trim( implode( ' ', $this->classes ) );
137
  }
138
 
@@ -160,6 +158,11 @@ class TimberMenuItem extends TimberCore implements TimberCoreInterface {
160
  return TimberURLHelper::is_external( $this->url );
161
  }
162
 
 
 
 
 
 
163
  public function meta( $key ) {
164
  if ( is_object( $this->menu_object ) && method_exists( $this->menu_object, 'meta' ) ) {
165
  return $this->menu_object->meta( $key );
@@ -192,7 +195,7 @@ class TimberMenuItem extends TimberCore implements TimberCoreInterface {
192
  /**
193
  *
194
  *
195
- * @return string
196
  */
197
  public function link() {
198
  return $this->get_link();
@@ -200,8 +203,8 @@ class TimberMenuItem extends TimberCore implements TimberCoreInterface {
200
 
201
  /**
202
  *
203
- *
204
- * @return string
205
  */
206
  public function path() {
207
  return $this->get_path();
@@ -209,8 +212,8 @@ class TimberMenuItem extends TimberCore implements TimberCoreInterface {
209
 
210
  /**
211
  *
212
- *
213
- * @return string
214
  */
215
  public function permalink() {
216
  return $this->get_link();
@@ -218,13 +221,18 @@ class TimberMenuItem extends TimberCore implements TimberCoreInterface {
218
 
219
  /**
220
  *
221
- *
222
- * @return string
223
  */
224
  public function get_permalink() {
225
  return $this->get_link();
226
  }
227
 
 
 
 
 
 
228
  public function title() {
229
  if (isset($this->__title)){
230
  return $this->__title;
29
  $this->name = $this->name();
30
  $this->add_class( 'menu-item-' . $this->ID );
31
  $this->menu_object = $data;
 
 
 
32
  }
33
 
34
  function __toString() {
94
  $this->url = $this->menu_object->get_link();
95
  }
96
  }
97
+ return $this->url;
98
  }
99
 
100
  /**
103
  * @return string
104
  */
105
  function get_path() {
106
+ return TimberURLHelper::get_rel_url( $this->get_link() );
107
  }
108
 
109
  /**
130
  function import_classes( $data ) {
131
  $this->classes = array_merge($this->classes, $data->classes);
132
  $this->classes = array_unique($this->classes);
133
+ $this->classes = apply_filters( 'nav_menu_css_class', $this->classes, $this );
134
  $this->class = trim( implode( ' ', $this->classes ) );
135
  }
136
 
158
  return TimberURLHelper::is_external( $this->url );
159
  }
160
 
161
+ /**
162
+ *
163
+ * @param $key string lookup key
164
+ * @return mixed whatever value is storied in the database
165
+ */
166
  public function meta( $key ) {
167
  if ( is_object( $this->menu_object ) && method_exists( $this->menu_object, 'meta' ) ) {
168
  return $this->menu_object->meta( $key );
195
  /**
196
  *
197
  *
198
+ * @return string a full URL like http://mysite.com/thing/
199
  */
200
  public function link() {
201
  return $this->get_link();
203
 
204
  /**
205
  *
206
+ * @see get_path()
207
+ * @return string the path of a URL like /foo
208
  */
209
  public function path() {
210
  return $this->get_path();
212
 
213
  /**
214
  *
215
+ * @see link()
216
+ * @return string a full URL like http://mysite.com/thing/
217
  */
218
  public function permalink() {
219
  return $this->get_link();
221
 
222
  /**
223
  *
224
+ * @see link()
225
+ * @return string a full URL like http://mysite.com/thing/
226
  */
227
  public function get_permalink() {
228
  return $this->get_link();
229
  }
230
 
231
+ /**
232
+ *
233
+ *
234
+ * @return string the public label like Foo
235
+ */
236
  public function title() {
237
  if (isset($this->__title)){
238
  return $this->__title;
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: jarednova
3
  Tags: template engine, templates, twig
4
  Requires at least: 3.7
5
- Stable tag: 0.20.8
6
- Tested up to: 4.0
7
  PHP version: 5.3.0 or greater
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
2
  Contributors: jarednova
3
  Tags: template engine, templates, twig
4
  Requires at least: 3.7
5
+ Stable tag: 0.20.9
6
+ Tested up to: 4.1
7
  PHP version: 5.3.0 or greater
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
timber-starter-theme/timber-starter-theme/404.php DELETED
@@ -1,13 +0,0 @@
1
- <?php
2
- /**
3
- * The template for displaying 404 pages (Not Found)
4
- *
5
- * Methods for TimberHelper can be found in the /functions sub-directory
6
- *
7
- * @package WordPress
8
- * @subpackage Timber
9
- * @since Timber 0.1
10
- */
11
-
12
- $context = Timber::get_context();
13
- Timber::render('404.twig', $context);
 
 
 
 
 
 
 
 
 
 
 
 
 
timber-starter-theme/timber-starter-theme/archive.php DELETED
@@ -1,40 +0,0 @@
1
- <?php
2
- /**
3
- * The template for displaying Archive pages.
4
- *
5
- * Used to display archive-type pages if nothing more specific matches a query.
6
- * For example, puts together date-based pages if no date.php file exists.
7
- *
8
- * Learn more: http://codex.wordpress.org/Template_Hierarchy
9
- *
10
- * Methods for TimberHelper can be found in the /functions sub-directory
11
- *
12
- * @package WordPress
13
- * @subpackage Timber
14
- * @since Timber 0.2
15
- */
16
-
17
- $templates = array('archive.twig', 'index.twig');
18
-
19
- $data = Timber::get_context();
20
-
21
- $data['title'] = 'Archive';
22
- if (is_day()){
23
- $data['title'] = 'Archive: '.get_the_date( 'D M Y' );
24
- } else if (is_month()){
25
- $data['title'] = 'Archive: '.get_the_date( 'M Y' );
26
- } else if (is_year()){
27
- $data['title'] = 'Archive: '.get_the_date( 'Y' );
28
- } else if (is_tag()){
29
- $data['title'] = single_tag_title('', false);
30
- } else if (is_category()){
31
- $data['title'] = single_cat_title('', false);
32
- array_unshift($templates, 'archive-'.get_query_var('cat').'.twig');
33
- } else if (is_post_type_archive()){
34
- $data['title'] = post_type_archive_title('', false);
35
- array_unshift($templates, 'archive-'.get_post_type().'.twig');
36
- }
37
-
38
- $data['posts'] = Timber::get_posts();
39
-
40
- Timber::render($templates, $data);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
timber-starter-theme/timber-starter-theme/author.php DELETED
@@ -1,20 +0,0 @@
1
- <?php
2
- /**
3
- * The template for displaying Author Archive pages
4
- *
5
- * Methods for TimberHelper can be found in the /functions sub-directory
6
- *
7
- * @package WordPress
8
- * @subpackage Timber
9
- * @since Timber 0.1
10
- */
11
- global $wp_query;
12
-
13
- $data = Timber::get_context();
14
- $data['posts'] = Timber::get_posts();
15
- if (isset($wp_query->query_vars['author'])){
16
- $author = new TimberUser($wp_query->query_vars['author']);
17
- $data['author'] = $author;
18
- $data['title'] = 'Author Archives: ' . $author->name();
19
- }
20
- Timber::render(array('author.twig', 'archive.twig'), $data);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
timber-starter-theme/timber-starter-theme/footer.php DELETED
@@ -1,13 +0,0 @@
1
- <?php
2
- /*
3
- * Third party plugins that hijack the theme will call wp_footer() to get the footer template.
4
- * We use this to end our output buffer (started in header.php) and render into the view/page-plugin.twig template.
5
- */
6
- $timberContext = $GLOBALS['timberContext'];
7
- if (!isset($timberContext)) {
8
- throw new \Exception('Timber context not set in footer.');
9
- }
10
- $timberContext['content'] = ob_get_contents();
11
- ob_end_clean();
12
- $templates = array('page-plugin.twig');
13
- Timber::render($templates, $timberContext);
 
 
 
 
 
 
 
 
 
 
 
 
 
timber-starter-theme/timber-starter-theme/functions.php DELETED
@@ -1,54 +0,0 @@
1
- <?php
2
-
3
- if (!class_exists('Timber')){
4
- add_action( 'admin_notices', function(){
5
- echo '<div class="error"><p>Timber not activated. Make sure you activate the plugin in <a href="' . admin_url('plugins.php#timber') . '">' . admin_url('plugins.php') . '</a></p></div>';
6
- });
7
- return;
8
- }
9
-
10
- class StarterSite extends TimberSite {
11
-
12
- function __construct(){
13
- add_theme_support('post-formats');
14
- add_theme_support('post-thumbnails');
15
- add_theme_support('menus');
16
- add_filter('timber_context', array($this, 'add_to_context'));
17
- add_filter('get_twig', array($this, 'add_to_twig'));
18
- add_action('init', array($this, 'register_post_types'));
19
- add_action('init', array($this, 'register_taxonomies'));
20
- parent::__construct();
21
- }
22
-
23
- function register_post_types(){
24
- //this is where you can register custom post types
25
- }
26
-
27
- function register_taxonomies(){
28
- //this is where you can register custom taxonomies
29
- }
30
-
31
- function add_to_context($context){
32
- $context['foo'] = 'bar';
33
- $context['stuff'] = 'I am a value set in your functions.php file';
34
- $context['notes'] = 'These values are available everytime you call Timber::get_context();';
35
- $context['menu'] = new TimberMenu();
36
- $context['site'] = $this;
37
- return $context;
38
- }
39
-
40
- function add_to_twig($twig){
41
- /* this is where you can add your own fuctions to twig */
42
- $twig->addExtension(new Twig_Extension_StringLoader());
43
- $twig->addFilter('myfoo', new Twig_Filter_Function('myfoo'));
44
- return $twig;
45
- }
46
-
47
- }
48
-
49
- new StarterSite();
50
-
51
- function myfoo($text){
52
- $text .= ' bar!';
53
- return $text;
54
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
timber-starter-theme/timber-starter-theme/header.php DELETED
@@ -1,7 +0,0 @@
1
- <?php
2
- /*
3
- * Third party plugins that hijack the theme will call wp_head() to get the header template.
4
- * We use this to start our output buffer and render into the view/page-plugin.twig template in footer.php
5
- */
6
- $GLOBALS['timberContext'] = Timber::get_context();
7
- ob_start();
 
 
 
 
 
 
 
timber-starter-theme/timber-starter-theme/index.php DELETED
@@ -1,29 +0,0 @@
1
- <?php
2
- /**
3
- * The main template file
4
- * This is the most generic template file in a WordPress theme
5
- * and one of the two required files for a theme (the other being style.css).
6
- * It is used to display a page when nothing more specific matches a query.
7
- * E.g., it puts together the home page when no home.php file exists
8
- *
9
- * Methods for TimberHelper can be found in the /functions sub-directory
10
- *
11
- * @package WordPress
12
- * @subpackage Timber
13
- * @since Timber 0.1
14
- */
15
-
16
- if (!class_exists('Timber')){
17
- echo 'Timber not activated. Make sure you activate the plugin in <a href="/wp-admin/plugins.php#timber">/wp-admin/plugins.php</a>';
18
- return;
19
- }
20
- $context = Timber::get_context();
21
- $context['posts'] = Timber::get_posts();
22
- $context['foo'] = 'bar';
23
- $templates = array('index.twig');
24
- if (is_home()){
25
- array_unshift($templates, 'home.twig');
26
- }
27
- Timber::render($templates, $context);
28
-
29
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
timber-starter-theme/timber-starter-theme/js/site.js DELETED
@@ -1,5 +0,0 @@
1
- jQuery(document).ready(function($) {
2
-
3
- // Your JavaScript goes here
4
-
5
- });
 
 
 
 
 
timber-starter-theme/timber-starter-theme/page.php DELETED
@@ -1,27 +0,0 @@
1
- <?php
2
- /**
3
- * The template for displaying all pages.
4
- *
5
- * This is the template that displays all pages by default.
6
- * Please note that this is the WordPress construct of pages
7
- * and that other 'pages' on your WordPress site will use a
8
- * different template.
9
- *
10
- * To generate specific templates for your pages you can use:
11
- * /mytheme/views/page-mypage.twig
12
- * (which will still route through this PHP file)
13
- * OR
14
- * /mytheme/page-mypage.php
15
- * (in which case you'll want to duplicate this file and save to the above path)
16
- *
17
- * Methods for TimberHelper can be found in the /functions sub-directory
18
- *
19
- * @package WordPress
20
- * @subpackage Timber
21
- * @since Timber 0.1
22
- */
23
-
24
- $context = Timber::get_context();
25
- $post = new TimberPost();
26
- $context['post'] = $post;
27
- Timber::render(array('page-' . $post->post_name . '.twig', 'page.twig'), $context);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
timber-starter-theme/timber-starter-theme/screenshot.png DELETED
Binary file
timber-starter-theme/timber-starter-theme/search.php DELETED
@@ -1,19 +0,0 @@
1
- <?php
2
- /**
3
- * Search results page
4
- *
5
- * Methods for TimberHelper can be found in the /functions sub-directory
6
- *
7
- * @package WordPress
8
- * @subpackage Timber
9
- * @since Timber 0.1
10
- */
11
-
12
-
13
- $templates = array('search.twig', 'archive.twig', 'index.twig');
14
- $context = Timber::get_context();
15
-
16
- $context['title'] = 'Search results for '. get_search_query();
17
- $context['posts'] = Timber::get_posts();
18
-
19
- Timber::render($templates, $context);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
timber-starter-theme/timber-starter-theme/sidebar.php DELETED
@@ -1,10 +0,0 @@
1
- <?php
2
- /**
3
- * The Template for displaying all single posts
4
- *
5
- *
6
- * @package WordPress
7
- * @subpackage Timber
8
- */
9
-
10
- Timber::render(array('sidebar.twig'), $data);
 
 
 
 
 
 
 
 
 
 
timber-starter-theme/timber-starter-theme/single.php DELETED
@@ -1,24 +0,0 @@
1
- <?php
2
- /**
3
- * The Template for displaying all single posts
4
- *
5
- * Methods for TimberHelper can be found in the /functions sub-directory
6
- *
7
- * @package WordPress
8
- * @subpackage Timber
9
- * @since Timber 0.1
10
- */
11
-
12
- $context = Timber::get_context();
13
- $post = Timber::query_post();
14
- $context['post'] = $post;
15
- $context['wp_title'] .= ' - ' . $post->title();
16
- $context['comment_form'] = TimberHelper::get_comment_form();
17
-
18
- if (post_password_required($post->ID)){
19
- Timber::render('single-password.twig', $context);
20
- } else {
21
- Timber::render(array('single-' . $post->ID . '.twig', 'single-' . $post->post_type . '.twig', 'single.twig'), $context);
22
- }
23
-
24
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
timber-starter-theme/timber-starter-theme/style.css DELETED
@@ -1,4 +0,0 @@
1
- /* Theme Name: My Timber Starter Theme
2
- Description: Starter Theme to use with Timber
3
- Author: Upstatement and YOU!
4
- */
 
 
 
 
timber-starter-theme/timber-starter-theme/views/404.twig DELETED
@@ -1,5 +0,0 @@
1
- {% extends "base.twig" %}
2
-
3
- {% block content %}
4
- Sorry, we couldn't find what you're looking for.
5
- {% endblock %}
 
 
 
 
 
timber-starter-theme/timber-starter-theme/views/author.twig DELETED
@@ -1,8 +0,0 @@
1
- {% extends "base.twig" %}
2
- {% block content %}
3
-
4
- {% for post in posts %}
5
- {% include ["tease-"~post.post_type~".twig", "tease.twig"] %}
6
- {% endfor %}
7
-
8
- {% endblock %}
 
 
 
 
 
 
 
 
timber-starter-theme/timber-starter-theme/views/base.twig DELETED
@@ -1,51 +0,0 @@
1
- {% block html_head_container %}
2
- {% include 'html-header.twig' %}
3
- {% block head %}
4
- {% endblock %}
5
- </head>
6
- {% endblock %}
7
- <body class="{{body_class}}" data-template="base.twig">
8
- <header class="header" >
9
- {% block header %}
10
- <div class="wrapper">
11
-
12
- <h1 class="hdr-logo" role="banner">
13
- <a class="hdr-logo-link" href="/" title="Timber" rel="home">{{site.name}}</a>
14
- </h1>
15
- <nav id="access" class="main-navigation" role="navigation">
16
- <ul>
17
- {% for item in menu.items %}
18
- <li id="menu-item-{{item.ID}}" class="menu-item menu-item-type-{{item.type}} menu-item-object-{{item.object}} menu-item-{{item.ID}}">
19
- <a href="{{item.link}}">{{item.title}}</a>
20
- </li>
21
- {% endfor %}
22
- </ul>
23
- </nav><!-- #access -->
24
-
25
- </div>
26
- {% endblock %}
27
- </header>
28
-
29
-
30
- <section id="content" role="main" class="content-wrapper">
31
- {% if title %}<h1>{{title}}</h1>{% endif %}
32
- <div class="wrapper {{sidebar_class}}">
33
- {% block content %}
34
- Sorry, no content
35
- {% endblock %}
36
- </div>
37
- {% if sidebar %}
38
- <aside class="layout-sidebar">
39
- {{sidebar}}
40
- </aside>
41
- {% endif %}
42
- </section>
43
-
44
- {% block footer %}
45
- <footer id="footer">
46
- {% include 'footer.twig' %}
47
- </footer>
48
- {{ function('wp_footer') }}
49
- {% endblock %}
50
- </body>
51
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
timber-starter-theme/timber-starter-theme/views/comment.twig DELETED
@@ -1,4 +0,0 @@
1
- <div class="blog-comment {{comment.comment_type}}" id="blog-comment-{{comment.ID}}">
2
- <h5 class="comment-author">{{comment.author.name}} says</h5>
3
- <div class="comment-content">{{comment.comment_content|wpautop}}</div>
4
- </div>
 
 
 
 
timber-starter-theme/timber-starter-theme/views/footer.twig DELETED
@@ -1 +0,0 @@
1
- Copyright {{"now"|date('Y')}}
 
timber-starter-theme/timber-starter-theme/views/html-header.twig DELETED
@@ -1,15 +0,0 @@
1
- <!doctype html>
2
- <!--[if lt IE 7]><html class="no-js ie ie6 lt-ie9 lt-ie8 lt-ie7" {{site.language_attributes}}> <![endif]-->
3
- <!--[if IE 7]><html class="no-js ie ie7 lt-ie9 lt-ie8" {{site.language_attributes}}> <![endif]-->
4
- <!--[if IE 8]><html class="no-js ie ie8 lt-ie9" {{site.language_attributes}}> <![endif]-->
5
- <!--[if gt IE 8]><!--><html class="no-js" {{site.language_attributes}}> <!--<![endif]-->
6
- <head>
7
- <meta charset="{{site.charset}}" />
8
- <title>{{wp_title}}</title>
9
- <meta name="description" content="{{site.description}}">
10
- <link rel="stylesheet" href="{{site.theme.link}}/style.css" type="text/css" media="screen" />
11
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
12
- <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
13
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
14
- <link rel="pingback" href="{{site.pingback_url}}" />
15
- {{function('wp_head')}}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
timber-starter-theme/timber-starter-theme/views/index.twig DELETED
@@ -1,10 +0,0 @@
1
- {% extends "base.twig" %}
2
-
3
- {% block content %}
4
- <h2>{{foo}}</h2>
5
- <p>{{qux}}</p>
6
- {% for post in posts %}
7
- {% include ['tease-'~post.post_type~'.twig', 'tease.twig'] %}
8
- {% endfor %}
9
-
10
- {% endblock %}
 
 
 
 
 
 
 
 
 
 
timber-starter-theme/timber-starter-theme/views/page-plugin.twig DELETED
@@ -1,7 +0,0 @@
1
- {% extends "base.twig" %}
2
-
3
- {% block content %}
4
- <div class="container content-wrapper">
5
- {{content}}
6
- </div> <!-- /content-wrapper -->
7
- {% endblock %}
 
 
 
 
 
 
 
timber-starter-theme/timber-starter-theme/views/page.twig DELETED
@@ -1,18 +0,0 @@
1
- {% extends "base.twig" %}
2
-
3
- {% block content %}
4
-
5
- <div class="content-wrapper">
6
- <article class="post-type-{{post.post_type}}" id="post-{{post.ID}}">
7
- <section class="article-content">
8
- <h1 class="article-h1">{{post.title}}</h1>
9
-
10
- <div class="article-body">
11
- {{post.content}}
12
- </div>
13
- </section>
14
-
15
- </article>
16
- </div> <!-- /content-wrapper -->
17
-
18
- {% endblock %}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
timber-starter-theme/timber-starter-theme/views/sidebar.twig DELETED
@@ -1 +0,0 @@
1
- Sidebar in Timber. Add HTML to your hearts content.
 
timber-starter-theme/timber-starter-theme/views/single-password.twig DELETED
@@ -1,8 +0,0 @@
1
- {% extends "base.twig" %}
2
- {% block content %}
3
- <form class="password-form" action="/wp-login.php?action=postpass" method="post">
4
- <label for="pwbox-{{post.ID}}">Password:</label>
5
- <input class="password-box" name="post_password" id="pwbox-{{post.ID}}" type="password" placeholder="Password" size="20" maxlength="20" />
6
- <input class="password-btn" type="submit" name="Submit" value="Submit" />
7
- </form>
8
- {% endblock %}
 
 
 
 
 
 
 
 
timber-starter-theme/timber-starter-theme/views/single.twig DELETED
@@ -1,35 +0,0 @@
1
- {% extends "base.twig" %}
2
-
3
- {% block content %}
4
-
5
- <div class="content-wrapper">
6
- <article class="post-type-{{post.post_type}}" id="post-{{post.ID}}">
7
- <section class="article-content">
8
- <h1 class="article-h1">{{post.title}}</h1>
9
-
10
- <p class="blog-author">
11
- <span>By</span><a href="{{post.author.path}}"> {{ post.author.name }} </a><span>&bull;</span> {{ post.post_date|date}}
12
- </p>
13
-
14
- <div class="article-body">
15
- {{post.content}}
16
- </div>
17
- </section>
18
-
19
- <section class="comments">
20
- <div class="respond">
21
- <h3 class="h2">Comments</h3>
22
- {{ comment_form }}
23
- </div>
24
- <div class="responses">
25
- {% for cmt in post.get_comments() %}
26
- {% include "comment.twig" with {comment:cmt} %}
27
- {% endfor %}
28
- </div>
29
-
30
- </section>
31
-
32
- </article>
33
- </div> <!-- /content-wrapper -->
34
-
35
- {% endblock %}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
timber-starter-theme/timber-starter-theme/views/tease-post.twig DELETED
@@ -1,9 +0,0 @@
1
- {% extends "tease.twig" %}
2
- {% block content %}
3
- <h2 class="h2"><a href="{{post.link}}">{{post.title}}</a></h2>
4
- <p>{{post.get_preview(25)}}</p>
5
-
6
- {% if post.thumbnail.src %}
7
- <img src="{{post.thumbnail.src}}" />
8
- {% endif %}
9
- {% endblock %}
 
 
 
 
 
 
 
 
 
timber-starter-theme/timber-starter-theme/views/tease.twig DELETED
@@ -1,10 +0,0 @@
1
- <article class="tease tease-{{post.post_type}}" id="tease-{{post.ID}}">
2
- {% block content %}
3
- <h2 class="h2"><a href="{{post.link}}">{{post.title}}</a></h2>
4
- <p>{{post.get_preview}}</p>
5
-
6
- {% if post.get_thumbnail %}
7
- <img src="{{post.thumbnail.src}}" />
8
- {% endif %}
9
- {% endblock %}
10
- </article>
 
 
 
 
 
 
 
 
 
 
timber-starter-theme/views/base.twig CHANGED
@@ -10,17 +10,27 @@
10
  <div class="wrapper">
11
 
12
  <h1 class="hdr-logo" role="banner">
13
- <a class="hdr-logo-link" href="/" title="Timber" rel="home">{{site.name}}</a>
14
  </h1>
15
- <nav id="access" class="main-navigation" role="navigation">
16
- <ul>
17
- {% for item in menu.items %}
18
- <li id="menu-item-{{item.ID}}" class="menu-item menu-item-type-{{item.type}} menu-item-object-{{item.object}} menu-item-{{item.ID}}">
19
- <a href="{{item.link}}">{{item.title}}</a>
 
 
 
 
 
 
 
 
 
 
20
  </li>
21
  {% endfor %}
22
  </ul>
23
- </nav><!-- #access -->
24
 
25
  </div>
26
  {% endblock %}
10
  <div class="wrapper">
11
 
12
  <h1 class="hdr-logo" role="banner">
13
+ <a class="hdr-logo-link" href="/" rel="home">{{site.name}}</a>
14
  </h1>
15
+
16
+ <nav id="nav-main" class="nav-main" role="navigation">
17
+ <ul class="nav">
18
+ {% for item in menu.get_items %}
19
+ <li class="nav-item {{item.classes | join(' ')}}">
20
+ <a class="nav-link" href="{{item.get_link}}">{{item.title}}</a>
21
+ {% if item.get_children %}
22
+ <ul class="nav nav-drop">
23
+ {% for child in item.get_children %}
24
+ <li class="nav-drop-item">
25
+ <a class="nav-link" href="{{child.get_link}}">{{child.title}}</a>
26
+ </li>
27
+ {% endfor %}
28
+ </ul>
29
+ {% endif %}
30
  </li>
31
  {% endfor %}
32
  </ul>
33
+ </nav><!-- #nav -->
34
 
35
  </div>
36
  {% endblock %}
timber.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: Timber
4
  Plugin URI: http://timber.upstatement.com
5
  Description: The WordPress Timber Library allows you to write themes using the power Twig templates
6
  Author: Jared Novack + Upstatement
7
- Version: 0.20.8
8
  Author URI: http://upstatement.com/
9
  */
10
 
4
  Plugin URI: http://timber.upstatement.com
5
  Description: The WordPress Timber Library allows you to write themes using the power Twig templates
6
  Author: Jared Novack + Upstatement
7
+ Version: 0.20.9
8
  Author URI: http://upstatement.com/
9
  */
10
 
vendor/autoload.php CHANGED
@@ -4,4 +4,4 @@
4
 
5
  require_once __DIR__ . '/composer' . '/autoload_real.php';
6
 
7
- return ComposerAutoloaderInitba2f6a6f731944fa517757b2bd6a18c4::getLoader();
4
 
5
  require_once __DIR__ . '/composer' . '/autoload_real.php';
6
 
7
+ return ComposerAutoloaderInit6a8f2a8653a1bfa1858986237611e8be::getLoader();
vendor/composer/ClassLoader.php CHANGED
@@ -56,7 +56,11 @@ class ClassLoader
56
 
57
  public function getPrefixes()
58
  {
59
- return call_user_func_array('array_merge', $this->prefixesPsr0);
 
 
 
 
60
  }
61
 
62
  public function getPrefixesPsr4()
@@ -143,6 +147,8 @@ class ClassLoader
143
  * @param string $prefix The prefix/namespace, with trailing '\\'
144
  * @param array|string $paths The PSR-0 base directories
145
  * @param bool $prepend Whether to prepend the directories
 
 
146
  */
147
  public function addPsr4($prefix, $paths, $prepend = false)
148
  {
@@ -202,10 +208,13 @@ class ClassLoader
202
  * Registers a set of PSR-4 directories for a given namespace,
203
  * replacing any others previously set for this namespace.
204
  *
205
- * @param string $prefix The prefix/namespace, with trailing '\\'
206
- * @param array|string $paths The PSR-4 base directories
 
 
207
  */
208
- public function setPsr4($prefix, $paths) {
 
209
  if (!$prefix) {
210
  $this->fallbackDirsPsr4 = (array) $paths;
211
  } else {
56
 
57
  public function getPrefixes()
58
  {
59
+ if (!empty($this->prefixesPsr0)) {
60
+ return call_user_func_array('array_merge', $this->prefixesPsr0);
61
+ }
62
+
63
+ return array();
64
  }
65
 
66
  public function getPrefixesPsr4()
147
  * @param string $prefix The prefix/namespace, with trailing '\\'
148
  * @param array|string $paths The PSR-0 base directories
149
  * @param bool $prepend Whether to prepend the directories
150
+ *
151
+ * @throws \InvalidArgumentException
152
  */
153
  public function addPsr4($prefix, $paths, $prepend = false)
154
  {
208
  * Registers a set of PSR-4 directories for a given namespace,
209
  * replacing any others previously set for this namespace.
210
  *
211
+ * @param string $prefix The prefix/namespace, with trailing '\\'
212
+ * @param array|string $paths The PSR-4 base directories
213
+ *
214
+ * @throws \InvalidArgumentException
215
  */
216
+ public function setPsr4($prefix, $paths)
217
+ {
218
  if (!$prefix) {
219
  $this->fallbackDirsPsr4 = (array) $paths;
220
  } else {
vendor/composer/autoload_real.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
- class ComposerAutoloaderInitba2f6a6f731944fa517757b2bd6a18c4
6
  {
7
  private static $loader;
8
 
@@ -19,12 +19,9 @@ class ComposerAutoloaderInitba2f6a6f731944fa517757b2bd6a18c4
19
  return self::$loader;
20
  }
21
 
22
- spl_autoload_register(array('ComposerAutoloaderInitba2f6a6f731944fa517757b2bd6a18c4', 'loadClassLoader'), true, true);
23
  self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
- spl_autoload_unregister(array('ComposerAutoloaderInitba2f6a6f731944fa517757b2bd6a18c4', 'loadClassLoader'));
25
-
26
- $vendorDir = dirname(__DIR__);
27
- $baseDir = dirname($vendorDir);
28
 
29
  $map = require __DIR__ . '/autoload_namespaces.php';
30
  foreach ($map as $namespace => $path) {
@@ -47,7 +44,7 @@ class ComposerAutoloaderInitba2f6a6f731944fa517757b2bd6a18c4
47
  }
48
  }
49
 
50
- function composerRequireba2f6a6f731944fa517757b2bd6a18c4($file)
51
  {
52
  require $file;
53
  }
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
+ class ComposerAutoloaderInit6a8f2a8653a1bfa1858986237611e8be
6
  {
7
  private static $loader;
8
 
19
  return self::$loader;
20
  }
21
 
22
+ spl_autoload_register(array('ComposerAutoloaderInit6a8f2a8653a1bfa1858986237611e8be', 'loadClassLoader'), true, true);
23
  self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
+ spl_autoload_unregister(array('ComposerAutoloaderInit6a8f2a8653a1bfa1858986237611e8be', 'loadClassLoader'));
 
 
 
25
 
26
  $map = require __DIR__ . '/autoload_namespaces.php';
27
  foreach ($map as $namespace => $path) {
44
  }
45
  }
46
 
47
+ function composerRequire6a8f2a8653a1bfa1858986237611e8be($file)
48
  {
49
  require $file;
50
  }
vendor/composer/installed.json CHANGED
@@ -1,17 +1,17 @@
1
  [
2
  {
3
  "name": "composer/installers",
4
- "version": "v1.0.15",
5
- "version_normalized": "1.0.15.0",
6
  "source": {
7
  "type": "git",
8
  "url": "https://github.com/composer/installers.git",
9
- "reference": "8e6a72a78f6cfd537fde3350720dfdc9ae3c5621"
10
  },
11
  "dist": {
12
  "type": "zip",
13
- "url": "https://api.github.com/repos/composer/installers/zipball/8e6a72a78f6cfd537fde3350720dfdc9ae3c5621",
14
- "reference": "8e6a72a78f6cfd537fde3350720dfdc9ae3c5621",
15
  "shasum": ""
16
  },
17
  "replace": {
@@ -22,7 +22,7 @@
22
  "composer/composer": "1.0.*@dev",
23
  "phpunit/phpunit": "4.1.*"
24
  },
25
- "time": "2014-06-23 16:25:28",
26
  "type": "composer-installer",
27
  "extra": {
28
  "class": "Composer\\Installers\\Installer",
@@ -44,8 +44,7 @@
44
  {
45
  "name": "Kyle Robinson Young",
46
  "email": "kyle@dontkry.com",
47
- "homepage": "https://github.com/shama",
48
- "role": "Developer"
49
  }
50
  ],
51
  "description": "A multi-framework Composer library installer",
@@ -56,17 +55,21 @@
56
  "Hurad",
57
  "MODX Evo",
58
  "OXID",
 
59
  "WolfCMS",
60
  "agl",
61
  "annotatecms",
62
  "bitrix",
63
  "cakephp",
 
64
  "codeigniter",
65
  "concrete5",
66
  "croogo",
 
67
  "drupal",
68
  "elgg",
69
  "fuelphp",
 
70
  "installer",
71
  "joomla",
72
  "kohana",
@@ -80,6 +83,7 @@
80
  "phpbb",
81
  "piwik",
82
  "ppi",
 
83
  "roundcube",
84
  "shopware",
85
  "silverstripe",
@@ -92,27 +96,27 @@
92
  },
93
  {
94
  "name": "twig/twig",
95
- "version": "v1.15.1",
96
- "version_normalized": "1.15.1.0",
97
  "source": {
98
  "type": "git",
99
- "url": "https://github.com/fabpot/Twig.git",
100
- "reference": "1fb5784662f438d7d96a541e305e28b812e2eeed"
101
  },
102
  "dist": {
103
  "type": "zip",
104
- "url": "https://api.github.com/repos/fabpot/Twig/zipball/1fb5784662f438d7d96a541e305e28b812e2eeed",
105
- "reference": "1fb5784662f438d7d96a541e305e28b812e2eeed",
106
  "shasum": ""
107
  },
108
  "require": {
109
  "php": ">=5.2.4"
110
  },
111
- "time": "2014-02-13 10:19:29",
112
  "type": "library",
113
  "extra": {
114
  "branch-alias": {
115
- "dev-master": "1.15-dev"
116
  }
117
  },
118
  "installation-source": "dist",
@@ -133,13 +137,13 @@
133
  "role": "Lead Developer"
134
  },
135
  {
136
- "name": "Armin Ronacher2",
137
  "email": "armin.ronacher@active-4.com",
138
  "role": "Project Founder"
139
  },
140
  {
141
  "name": "Twig Team",
142
- "homepage": "https://github.com/fabpot/Twig/graphs/contributors",
143
  "role": "Contributors"
144
  }
145
  ],
@@ -205,28 +209,28 @@
205
  },
206
  {
207
  "name": "symfony/yaml",
208
- "version": "v2.5.0",
209
- "version_normalized": "2.5.0.0",
210
  "target-dir": "Symfony/Component/Yaml",
211
  "source": {
212
  "type": "git",
213
  "url": "https://github.com/symfony/Yaml.git",
214
- "reference": "b4b09c68ec2f2727574544ef0173684281a5033c"
215
  },
216
  "dist": {
217
  "type": "zip",
218
- "url": "https://api.github.com/repos/symfony/Yaml/zipball/b4b09c68ec2f2727574544ef0173684281a5033c",
219
- "reference": "b4b09c68ec2f2727574544ef0173684281a5033c",
220
  "shasum": ""
221
  },
222
  "require": {
223
  "php": ">=5.3.3"
224
  },
225
- "time": "2014-05-16 14:25:18",
226
  "type": "library",
227
  "extra": {
228
  "branch-alias": {
229
- "dev-master": "2.5-dev"
230
  }
231
  },
232
  "installation-source": "dist",
@@ -240,15 +244,13 @@
240
  "MIT"
241
  ],
242
  "authors": [
243
- {
244
- "name": "Fabien Potencier",
245
- "email": "fabien@symfony.com",
246
- "homepage": "http://fabien.potencier.org",
247
- "role": "Lead Developer"
248
- },
249
  {
250
  "name": "Symfony Community",
251
  "homepage": "http://symfony.com/contributors"
 
 
 
 
252
  }
253
  ],
254
  "description": "Symfony Yaml Component",
@@ -265,7 +267,7 @@
265
  },
266
  "dist": {
267
  "type": "zip",
268
- "url": "https://api.github.com/repos/dannyvankooten/PHP-Router/zipball/896472302cd1c0d0b6269b3837e7ca636a5b9b3a",
269
  "reference": "e9a479820b871ae4493fec30d5e433456767a505",
270
  "shasum": ""
271
  },
1
  [
2
  {
3
  "name": "composer/installers",
4
+ "version": "v1.0.19",
5
+ "version_normalized": "1.0.19.0",
6
  "source": {
7
  "type": "git",
8
  "url": "https://github.com/composer/installers.git",
9
+ "reference": "89d77bfbee79e16653f7162c86e602cc188471db"
10
  },
11
  "dist": {
12
  "type": "zip",
13
+ "url": "https://api.github.com/repos/composer/installers/zipball/89d77bfbee79e16653f7162c86e602cc188471db",
14
+ "reference": "89d77bfbee79e16653f7162c86e602cc188471db",
15
  "shasum": ""
16
  },
17
  "replace": {
22
  "composer/composer": "1.0.*@dev",
23
  "phpunit/phpunit": "4.1.*"
24
  },
25
+ "time": "2014-11-29 01:29:17",
26
  "type": "composer-installer",
27
  "extra": {
28
  "class": "Composer\\Installers\\Installer",
44
  {
45
  "name": "Kyle Robinson Young",
46
  "email": "kyle@dontkry.com",
47
+ "homepage": "https://github.com/shama"
 
48
  }
49
  ],
50
  "description": "A multi-framework Composer library installer",
55
  "Hurad",
56
  "MODX Evo",
57
  "OXID",
58
+ "Thelia",
59
  "WolfCMS",
60
  "agl",
61
  "annotatecms",
62
  "bitrix",
63
  "cakephp",
64
+ "chef",
65
  "codeigniter",
66
  "concrete5",
67
  "croogo",
68
+ "dokuwiki",
69
  "drupal",
70
  "elgg",
71
  "fuelphp",
72
+ "grav",
73
  "installer",
74
  "joomla",
75
  "kohana",
83
  "phpbb",
84
  "piwik",
85
  "ppi",
86
+ "puppet",
87
  "roundcube",
88
  "shopware",
89
  "silverstripe",
96
  },
97
  {
98
  "name": "twig/twig",
99
+ "version": "v1.16.3",
100
+ "version_normalized": "1.16.3.0",
101
  "source": {
102
  "type": "git",
103
+ "url": "https://github.com/twigphp/Twig.git",
104
+ "reference": "6dc11a1e8ecfc30e2c68aaeb218148409d8e68af"
105
  },
106
  "dist": {
107
  "type": "zip",
108
+ "url": "https://api.github.com/repos/twigphp/Twig/zipball/6dc11a1e8ecfc30e2c68aaeb218148409d8e68af",
109
+ "reference": "6dc11a1e8ecfc30e2c68aaeb218148409d8e68af",
110
  "shasum": ""
111
  },
112
  "require": {
113
  "php": ">=5.2.4"
114
  },
115
+ "time": "2014-12-25 19:58:19",
116
  "type": "library",
117
  "extra": {
118
  "branch-alias": {
119
+ "dev-master": "1.16-dev"
120
  }
121
  },
122
  "installation-source": "dist",
137
  "role": "Lead Developer"
138
  },
139
  {
140
+ "name": "Armin Ronacher",
141
  "email": "armin.ronacher@active-4.com",
142
  "role": "Project Founder"
143
  },
144
  {
145
  "name": "Twig Team",
146
+ "homepage": "http://twig.sensiolabs.org/contributors",
147
  "role": "Contributors"
148
  }
149
  ],
209
  },
210
  {
211
  "name": "symfony/yaml",
212
+ "version": "v2.6.1",
213
+ "version_normalized": "2.6.1.0",
214
  "target-dir": "Symfony/Component/Yaml",
215
  "source": {
216
  "type": "git",
217
  "url": "https://github.com/symfony/Yaml.git",
218
+ "reference": "3346fc090a3eb6b53d408db2903b241af51dcb20"
219
  },
220
  "dist": {
221
  "type": "zip",
222
+ "url": "https://api.github.com/repos/symfony/Yaml/zipball/3346fc090a3eb6b53d408db2903b241af51dcb20",
223
+ "reference": "3346fc090a3eb6b53d408db2903b241af51dcb20",
224
  "shasum": ""
225
  },
226
  "require": {
227
  "php": ">=5.3.3"
228
  },
229
+ "time": "2014-12-02 20:19:20",
230
  "type": "library",
231
  "extra": {
232
  "branch-alias": {
233
+ "dev-master": "2.6-dev"
234
  }
235
  },
236
  "installation-source": "dist",
244
  "MIT"
245
  ],
246
  "authors": [
 
 
 
 
 
 
247
  {
248
  "name": "Symfony Community",
249
  "homepage": "http://symfony.com/contributors"
250
+ },
251
+ {
252
+ "name": "Fabien Potencier",
253
+ "email": "fabien@symfony.com"
254
  }
255
  ],
256
  "description": "Symfony Yaml Component",
267
  },
268
  "dist": {
269
  "type": "zip",
270
+ "url": "https://api.github.com/repos/dannyvankooten/PHP-Router/zipball/274b75c1618f69b695caa91d2c7ba0f67f0e774c",
271
  "reference": "e9a479820b871ae4493fec30d5e433456767a505",
272
  "shasum": ""
273
  },
vendor/composer/installers/.travis.yml CHANGED
@@ -3,6 +3,9 @@ language: php
3
  php:
4
  - 5.3
5
  - 5.4
 
 
 
6
 
7
  before_script:
8
  - curl -s http://getcomposer.org/installer | php -- --quiet
3
  php:
4
  - 5.3
5
  - 5.4
6
+ - 5.5
7
+ - 5.6
8
+ - hhvm
9
 
10
  before_script:
11
  - curl -s http://getcomposer.org/installer | php -- --quiet
vendor/composer/installers/README.md CHANGED
@@ -1,6 +1,6 @@
1
  # A Multi-Framework [Composer](http://getcomposer.org) Library Installer
2
 
3
- [![Build Status](https://secure.travis-ci.org/composer/installers.png)](http://travis-ci.org/composer/installers)
4
 
5
  This is for PHP package authors to require in their `composer.json`. It will
6
  install their package to the correct location based on the specified package
@@ -33,18 +33,23 @@ is not needed to install packages with these frameworks:
33
 
34
  | Framework | Types
35
  | --------- | -----
 
36
  | AGL | `agl-module`
37
  | AnnotateCms | `annotatecms-module`<br>`annotatecms-component`<br>`annotatecms-service`
38
- | Bitrix | `bitrix-module`<br>`bitrix-component`
39
  | CakePHP 2+ | **`cakephp-plugin`**
 
40
  | CodeIgniter | `codeigniter-library`<br>`codeigniter-third-party`<br>`codeigniter-module`
41
  | concrete5 | `concrete5-block`<br>`concrete5-package`<br>`concrete5-theme`<br>`concrete5-update`
42
  | Craft | `craft-plugin`
43
  | Croogo | `croogo-plugin`<br>`croogo-theme`
 
44
  | Dolibarr | `dolibarr-module`
45
  | Drupal | <b>`drupal-module`<br>`drupal-theme`</b><br>`drupal-library`<br>`drupal-profile`<br>`drupal-drush`
46
  | Elgg | `elgg-plugin`
47
  | FuelPHP v1.x | `fuel-module`<br>`fuel-package`<br/>`fuel-theme`
 
 
48
  | Hurad | `hurad-plugin`<br>`hurad-theme`
49
  | Joomla | `joomla-component`<br>`joomla-module`<br>`joomla-template`<br>`joomla-plugin`<br>`joomla-library`
50
  | Kirby | **`kirby-plugin`**
@@ -55,7 +60,7 @@ is not needed to install packages with these frameworks:
55
  | Mako | `mako-package`
56
  | MODX Evo | `modxevo-snippet`<br>`modxevo-plugin`<br>`modxevo-module`<br>`modxevo-template`<br>`modxevo-lib`
57
  | MediaWiki | `mediawiki-extension`
58
- | October | **`october-module`<br>`october-plugin`**
59
  | OXID | `oxid-module`<br>`oxid-theme`<br>`oxid-out`
60
  | MODULEWork | `modulework-module`
61
  | Moodle | `moodle-*` (Please [check source](https://raw.githubusercontent.com/composer/installers/master/src/Composer/Installers/MoodleInstaller.php) for all supported types)
@@ -63,6 +68,8 @@ is not needed to install packages with these frameworks:
63
  | phpBB | `phpbb-extension`<br>`phpbb-style`<br>`phpbb-language`
64
  | Pimcore | `pimcore-plugin`
65
  | PPI | **`ppi-module`**
 
 
66
  | Roundcube | `roundcube-plugin`
67
  | shopware | `shopware-backend-plugin`<br/>`shopware-core-plugin`<br/>`shopware-frontend-plugin`<br/>`shopware-theme`
68
  | SilverStripe | `silverstripe-module`<br>`silverstripe-theme`
1
  # A Multi-Framework [Composer](http://getcomposer.org) Library Installer
2
 
3
+ [![Build Status](http://img.shields.io/travis/composer/installers.svg)](http://travis-ci.org/composer/installers)
4
 
5
  This is for PHP package authors to require in their `composer.json`. It will
6
  install their package to the correct location based on the specified package
33
 
34
  | Framework | Types
35
  | --------- | -----
36
+ | Asgard | `asgard-module`<br>`asgard-theme`
37
  | AGL | `agl-module`
38
  | AnnotateCms | `annotatecms-module`<br>`annotatecms-component`<br>`annotatecms-service`
39
+ | Bitrix | `bitrix-module`<br>`bitrix-component`<br>`bitrix-theme`
40
  | CakePHP 2+ | **`cakephp-plugin`**
41
+ | Chef | `chef-recipe`<br>`chef-role`
42
  | CodeIgniter | `codeigniter-library`<br>`codeigniter-third-party`<br>`codeigniter-module`
43
  | concrete5 | `concrete5-block`<br>`concrete5-package`<br>`concrete5-theme`<br>`concrete5-update`
44
  | Craft | `craft-plugin`
45
  | Croogo | `croogo-plugin`<br>`croogo-theme`
46
+ | DokuWiki | `dokuwiki-plugin`<br>`dokuwiki-template`
47
  | Dolibarr | `dolibarr-module`
48
  | Drupal | <b>`drupal-module`<br>`drupal-theme`</b><br>`drupal-library`<br>`drupal-profile`<br>`drupal-drush`
49
  | Elgg | `elgg-plugin`
50
  | FuelPHP v1.x | `fuel-module`<br>`fuel-package`<br/>`fuel-theme`
51
+ | FuelPHP v2.x | `fuelphp-component`
52
+ | Grav | `grav-plugin`<br>`grav-theme`
53
  | Hurad | `hurad-plugin`<br>`hurad-theme`
54
  | Joomla | `joomla-component`<br>`joomla-module`<br>`joomla-template`<br>`joomla-plugin`<br>`joomla-library`
55
  | Kirby | **`kirby-plugin`**
60
  | Mako | `mako-package`
61
  | MODX Evo | `modxevo-snippet`<br>`modxevo-plugin`<br>`modxevo-module`<br>`modxevo-template`<br>`modxevo-lib`
62
  | MediaWiki | `mediawiki-extension`
63
+ | October | **`october-module`<br>`october-plugin`<br>`october-theme`**
64
  | OXID | `oxid-module`<br>`oxid-theme`<br>`oxid-out`
65
  | MODULEWork | `modulework-module`
66
  | Moodle | `moodle-*` (Please [check source](https://raw.githubusercontent.com/composer/installers/master/src/Composer/Installers/MoodleInstaller.php) for all supported types)
68
  | phpBB | `phpbb-extension`<br>`phpbb-style`<br>`phpbb-language`
69
  | Pimcore | `pimcore-plugin`
70
  | PPI | **`ppi-module`**
71
+ | Puppet | `puppet-module`
72
+ | REDAXO | `redaxo-addon`
73
  | Roundcube | `roundcube-plugin`
74
  | shopware | `shopware-backend-plugin`<br/>`shopware-core-plugin`<br/>`shopware-frontend-plugin`<br/>`shopware-theme`
75
  | SilverStripe | `silverstripe-module`<br>`silverstripe-theme`
vendor/composer/installers/composer.json CHANGED
@@ -9,14 +9,17 @@
9
  "AnnotateCms",
10
  "Bitrix",
11
  "CakePHP",
 
12
  "CodeIgniter",
13
  "concrete5",
14
  "Craft",
15
  "Croogo",
 
16
  "Dolibarr",
17
  "Drupal",
18
  "Elgg",
19
  "FuelPHP",
 
20
  "Hurad",
21
  "Joomla",
22
  "Kohana",
@@ -32,10 +35,12 @@
32
  "Piwik",
33
  "phpBB",
34
  "PPI",
 
35
  "Roundcube",
36
  "shopware",
37
  "SilverStripe",
38
  "symfony",
 
39
  "TYPO3",
40
  "WolfCMS",
41
  "WordPress",
9
  "AnnotateCms",
10
  "Bitrix",
11
  "CakePHP",
12
+ "Chef",
13
  "CodeIgniter",
14
  "concrete5",
15
  "Craft",
16
  "Croogo",
17
+ "DokuWiki",
18
  "Dolibarr",
19
  "Drupal",
20
  "Elgg",
21
  "FuelPHP",
22
+ "Grav",
23
  "Hurad",
24
  "Joomla",
25
  "Kohana",
35
  "Piwik",
36
  "phpBB",
37
  "PPI",
38
+ "Puppet",
39
  "Roundcube",
40
  "shopware",
41
  "SilverStripe",
42
  "symfony",
43
+ "Thelia",
44
  "TYPO3",
45
  "WolfCMS",
46
  "WordPress",
vendor/composer/installers/src/Composer/Installers/AsgardInstaller.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Composer\Installers;
3
+
4
+ class AsgardInstaller extends BaseInstaller
5
+ {
6
+ protected $locations = array(
7
+ 'module' => 'Modules/{$name}/',
8
+ 'theme' => 'Themes/{$name}/'
9
+ );
10
+
11
+ /**
12
+ * Format package name.
13
+ *
14
+ * For package type asgard-module, cut off a trailing '-plugin' if present.
15
+ *
16
+ * For package type asgard-theme, cut off a trailing '-theme' if present.
17
+ *
18
+ */
19
+ public function inflectPackageVars($vars)
20
+ {
21
+ if ($vars['type'] === 'asgard-module') {
22
+ return $this->inflectPluginVars($vars);
23
+ }
24
+
25
+ if ($vars['type'] === 'asgard-theme') {
26
+ return $this->inflectThemeVars($vars);
27
+ }
28
+
29
+ return $vars;
30
+ }
31
+
32
+ protected function inflectPluginVars($vars)
33
+ {
34
+ $vars['name'] = ucfirst(preg_replace('/-module/', '', $vars['name']));
35
+
36
+ return $vars;
37
+ }
38
+
39
+ protected function inflectThemeVars($vars)
40
+ {
41
+ $vars['name'] = ucfirst(preg_replace('/-theme$/', '', $vars['name']));
42
+
43
+ return $vars;
44
+ }
45
+ }
vendor/composer/installers/src/Composer/Installers/BitrixInstaller.php CHANGED
@@ -6,5 +6,6 @@ class BitrixInstaller extends BaseInstaller
6
  protected $locations = array(
7
  'module' => 'local/modules/{$name}/',
8
  'component' => 'local/components/{$name}/',
 
9
  );
10
  }
6
  protected $locations = array(
7
  'module' => 'local/modules/{$name}/',
8
  'component' => 'local/components/{$name}/',
9
+ 'theme' => 'local/templates/{$name}/'
10
  );
11
  }
vendor/composer/installers/src/Composer/Installers/CakePHPInstaller.php CHANGED
@@ -31,15 +31,47 @@ class CakePHPInstaller extends BaseInstaller
31
  /**
32
  * Change the default plugin location when cakephp >= 3.0
33
  */
34
- public function getLocations() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
  $repositoryManager = $this->composer->getRepositoryManager();
36
  if ($repositoryManager) {
37
  $repos = $repositoryManager->getLocalRepository();
38
  if (!$repos) {
39
- return $this->locations;
40
  }
41
  $cake3 = new MultiConstraint(array(
42
- new VersionConstraint('>=', '3.0.0'),
43
  new VersionConstraint('!=', '9999999-dev'),
44
  ));
45
  $pool = new Pool('dev');
@@ -48,11 +80,66 @@ class CakePHPInstaller extends BaseInstaller
48
  foreach ($packages as $package) {
49
  $installed = new VersionConstraint('=', $package->getVersion());
50
  if ($cake3->matches($installed)) {
51
- $this->locations['plugin'] = 'plugins/{$name}/';
52
  break;
53
  }
54
  }
55
  }
56
- return $this->locations;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
  }
 
58
  }
31
  /**
32
  * Change the default plugin location when cakephp >= 3.0
33
  */
34
+ public function getLocations()
35
+ {
36
+ if ($this->matchesCakeVersion('>=', '3.0.0')) {
37
+ $this->locations['plugin'] = 'plugins/{$name}/';
38
+ }
39
+ return $this->locations;
40
+ }
41
+
42
+ /**
43
+ * Add installer-name for CakePHP >= 3.0.0
44
+ *
45
+ * @param PackageInterface $package
46
+ * @param string $frameworkType
47
+ * @return string
48
+ */
49
+ public function getInstallPath(PackageInterface $package, $frameworkType = '')
50
+ {
51
+ $extra = $package->getExtra();
52
+ if (empty($extra['installer-name']) && $this->matchesCakeVersion('>=', '3.0.0')) {
53
+ $this->setInstallerName($package);
54
+ }
55
+ return parent::getInstallPath($package, $frameworkType);
56
+ }
57
+
58
+ /**
59
+ * Check if CakePHP version matches against a version
60
+ *
61
+ * @param string $matcher
62
+ * @param string $version
63
+ * @return bool
64
+ */
65
+ protected function matchesCakeVersion($matcher, $version)
66
+ {
67
  $repositoryManager = $this->composer->getRepositoryManager();
68
  if ($repositoryManager) {
69
  $repos = $repositoryManager->getLocalRepository();
70
  if (!$repos) {
71
+ return false;
72
  }
73
  $cake3 = new MultiConstraint(array(
74
+ new VersionConstraint($matcher, $version),
75
  new VersionConstraint('!=', '9999999-dev'),
76
  ));
77
  $pool = new Pool('dev');
80
  foreach ($packages as $package) {
81
  $installed = new VersionConstraint('=', $package->getVersion());
82
  if ($cake3->matches($installed)) {
83
+ return true;
84
  break;
85
  }
86
  }
87
  }
88
+ return false;
89
+ }
90
+
91
+ /**
92
+ * Set installer-name based on namespace for the source path checking in
93
+ * following order:
94
+ *
95
+ * - With only one autoload path the namespace for that path will be used.
96
+ * - With multiple paths if path 'src' exists it's namespace will be used.
97
+ * - With two autoload paths provided, the namespace of path other than
98
+ * 'tests' will be used.
99
+ *
100
+ * No installer-name is set if PSR-4 autoload block is not found or if none
101
+ * of the above conditions are met.
102
+ *
103
+ * @param PackageInterface $package
104
+ */
105
+ protected function setInstallerName(PackageInterface $package)
106
+ {
107
+ $primaryNS = null;
108
+ $autoLoad = $package->getAutoload();
109
+ foreach ($autoLoad as $type => $typeConfig) {
110
+ if ($type !== 'psr-4') {
111
+ continue;
112
+ }
113
+ $count = count($typeConfig);
114
+
115
+ if ($count === 1) {
116
+ $primaryNS = key($typeConfig);
117
+ break;
118
+ }
119
+
120
+ $matches = preg_grep('#^(\./)?src/?$#', $typeConfig);
121
+ if ($matches) {
122
+ $primaryNS = key($matches);
123
+ break;
124
+ }
125
+
126
+ if ($count === 2) {
127
+ reset($typeConfig);
128
+ if (preg_match('#^(\./)?tests/?$#', current($typeConfig))) {
129
+ next($typeConfig);
130
+ }
131
+ $primaryNS = key($typeConfig);
132
+ break;
133
+ }
134
+
135
+ break;
136
+ }
137
+
138
+ if ($primaryNS) {
139
+ $package->setExtra(array(
140
+ 'installer-name' => trim(str_replace('\\', '/', $primaryNS), '/')
141
+ ));
142
+ }
143
  }
144
+
145
  }
vendor/composer/installers/src/Composer/Installers/ChefInstaller.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Composer\Installers;
3
+
4
+ class ChefInstaller extends BaseInstaller
5
+ {
6
+ protected $locations = array(
7
+ 'cookbook' => 'Chef/{$vendor}/{$name}/',
8
+ 'role' => 'Chef/roles/{$name}/',
9
+ );
10
+ }
11
+
vendor/composer/installers/src/Composer/Installers/DokuWikiInstaller.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Composer\Installers;
3
+
4
+ class DokuWikiInstaller extends BaseInstaller
5
+ {
6
+ protected $locations = array(
7
+ 'plugin' => 'lib/plugins/{$name}/',
8
+ 'template' => 'lib/tpl/{$name}/',
9
+ );
10
+
11
+ /**
12
+ * Format package name.
13
+ *
14
+ * For package type dokuwiki-plugin, cut off a trailing '-plugin',
15
+ * or leading dokuwiki_ if present.
16
+ *
17
+ * For package type dokuwiki-template, cut off a trailing '-template' if present.
18
+ *
19
+ */
20
+ public function inflectPackageVars($vars)
21
+ {
22
+
23
+ if ($vars['type'] === 'dokuwiki-plugin') {
24
+ return $this->inflectPluginVars($vars);
25
+ }
26
+
27
+ if ($vars['type'] === 'dokuwiki-template') {
28
+ return $this->inflectTemplateVars($vars);
29
+ }
30
+
31
+ return $vars;
32
+ }
33
+
34
+ protected function inflectPluginVars($vars)
35
+ {
36
+ $vars['name'] = preg_replace('/-plugin$/', '', $vars['name']);
37
+ $vars['name'] = preg_replace('/^dokuwiki_?-?/', '', $vars['name']);
38
+
39
+ return $vars;
40
+ }
41
+
42
+ protected function inflectTemplateVars($vars)
43
+ {
44
+ $vars['name'] = preg_replace('/-template$/', '', $vars['name']);
45
+ $vars['name'] = preg_replace('/^dokuwiki_?-?/', '', $vars['name']);
46
+
47
+ return $vars;
48
+ }
49
+
50
+ }
vendor/composer/installers/src/Composer/Installers/FuelInstaller.php CHANGED
@@ -6,6 +6,6 @@ class FuelInstaller extends BaseInstaller
6
  protected $locations = array(
7
  'module' => 'fuel/app/modules/{$name}/',
8
  'package' => 'fuel/packages/{$name}/',
9
- 'theme' => 'fuel/themes/{$name}/',
10
  );
11
  }
6
  protected $locations = array(
7
  'module' => 'fuel/app/modules/{$name}/',
8
  'package' => 'fuel/packages/{$name}/',
9
+ 'theme' => 'fuel/app/themes/{$name}/',
10
  );
11
  }
vendor/composer/installers/src/Composer/Installers/FuelphpInstaller.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Composer\Installers;
3
+
4
+ class FuelphpInstaller extends BaseInstaller
5
+ {
6
+ protected $locations = array(
7
+ 'component' => 'components/{$name}/',
8
+ );
9
+ }
vendor/composer/installers/src/Composer/Installers/GravInstaller.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Composer\Installers;
3
+
4
+ class GravInstaller extends BaseInstaller
5
+ {
6
+ protected $locations = array(
7
+ 'plugin' => 'user/plugins/{$name}/',
8
+ 'theme' => 'user/themes/{$name}/',
9
+ );
10
+
11
+ /**
12
+ * Format package name
13
+ *
14
+ * @param array $vars
15
+ *
16
+ * @return array
17
+ */
18
+ public function inflectPackageVars($vars)
19
+ {
20
+ $restrictedWords = implode('|', array_keys($this->locations));
21
+
22
+ $vars['name'] = strtolower($vars['name']);
23
+ $vars['name'] = preg_replace('/^(?:grav-)?(?:(?:'.$restrictedWords.')-)?(.*?)(?:-(?:'.$restrictedWords.'))?$/ui',
24
+ '$1',
25
+ $vars['name']
26
+ );
27
+
28
+ return $vars;
29
+ }
30
+ }
vendor/composer/installers/src/Composer/Installers/HuradInstaller.php CHANGED
@@ -4,8 +4,8 @@ namespace Composer\Installers;
4
  class HuradInstaller extends BaseInstaller
5
  {
6
  protected $locations = array(
7
- 'plugin' => 'Plugin/{$name}/',
8
- 'theme' => 'View/Themed/{$name}/',
9
  );
10
 
11
  /**
@@ -13,9 +13,13 @@ class HuradInstaller extends BaseInstaller
13
  */
14
  public function inflectPackageVars($vars)
15
  {
16
- $vars['name'] = strtolower(str_replace(array('-', '_'), ' ', $vars['name']));
17
- $vars['name'] = str_replace(' ', '', ucwords($vars['name']));
18
-
 
 
 
 
19
  return $vars;
20
  }
21
  }
4
  class HuradInstaller extends BaseInstaller
5
  {
6
  protected $locations = array(
7
+ 'plugin' => 'plugins/{$name}/',
8
+ 'theme' => 'plugins/{$name}/',
9
  );
10
 
11
  /**
13
  */
14
  public function inflectPackageVars($vars)
15
  {
16
+ $nameParts = explode('/', $vars['name']);
17
+ foreach ($nameParts as &$value) {
18
+ $value = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $value));
19
+ $value = str_replace(array('-', '_'), ' ', $value);
20
+ $value = str_replace(' ', '', ucwords($value));
21
+ }
22
+ $vars['name'] = implode('/', $nameParts);
23
  return $vars;
24
  }
25
  }
vendor/composer/installers/src/Composer/Installers/Installer.php CHANGED
@@ -13,19 +13,23 @@ class Installer extends LibraryInstaller
13
  * @var array
14
  */
15
  private $supportedTypes = array(
 
16
  'agl' => 'AglInstaller',
17
  'annotatecms' => 'AnnotateCmsInstaller',
18
  'bitrix' => 'BitrixInstaller',
19
  'cakephp' => 'CakePHPInstaller',
 
20
  'codeigniter' => 'CodeIgniterInstaller',
21
  'concrete5' => 'Concrete5Installer',
22
  'craft' => 'CraftInstaller',
23
  'croogo' => 'CroogoInstaller',
24
- 'drupal' => 'DrupalInstaller',
25
  'dolibarr' => 'DolibarrInstaller',
 
26
  'elgg' => 'ElggInstaller',
27
- 'piwik' => 'PiwikInstaller',
28
  'fuel' => 'FuelInstaller',
 
 
29
  'hurad' => 'HuradInstaller',
30
  'joomla' => 'JoomlaInstaller',
31
  'kirby' => 'KirbyInstaller',
@@ -34,28 +38,32 @@ class Installer extends LibraryInstaller
34
  'lithium' => 'LithiumInstaller',
35
  'magento' => 'MagentoInstaller',
36
  'mako' => 'MakoInstaller',
37
- 'modxevo' => 'MODXEvoInstaller',
38
  'mediawiki' => 'MediaWikiInstaller',
39
  'microweber' => 'MicroweberInstaller',
40
  'modulework' => 'MODULEWorkInstaller',
 
41
  'moodle' => 'MoodleInstaller',
42
  'october' => 'OctoberInstaller',
43
  'oxid' => 'OxidInstaller',
44
  'phpbb' => 'PhpBBInstaller',
45
- 'piwik' => 'PiwikInstaller',
46
  'pimcore' => 'PimcoreInstaller',
 
47
  'ppi' => 'PPIInstaller',
 
 
48
  'roundcube' => 'RoundcubeInstaller',
49
  'shopware' => 'ShopwareInstaller',
50
  'silverstripe' => 'SilverStripeInstaller',
51
  'symfony1' => 'Symfony1Installer',
 
 
 
 
 
52
  'wolfcms' => 'WolfCMSInstaller',
53
  'wordpress' => 'WordPressInstaller',
54
  'zend' => 'ZendInstaller',
55
  'zikula' => 'ZikulaInstaller',
56
- 'typo3-flow' => 'TYPO3FlowInstaller',
57
- 'typo3-cms' => 'TYPO3CmsInstaller',
58
- 'tusk' => 'TuskInstaller',
59
  );
60
 
61
  /**
@@ -116,6 +124,8 @@ class Installer extends LibraryInstaller
116
  {
117
  $frameworkType = false;
118
 
 
 
119
  foreach ($this->supportedTypes as $key => $val) {
120
  if ($key === substr($type, 0, strlen($key))) {
121
  $frameworkType = substr($type, 0, strlen($key));
13
  * @var array
14
  */
15
  private $supportedTypes = array(
16
+ 'asgard' => 'AsgardInstaller',
17
  'agl' => 'AglInstaller',
18
  'annotatecms' => 'AnnotateCmsInstaller',
19
  'bitrix' => 'BitrixInstaller',
20
  'cakephp' => 'CakePHPInstaller',
21
+ 'chef' => 'ChefInstaller',
22
  'codeigniter' => 'CodeIgniterInstaller',
23
  'concrete5' => 'Concrete5Installer',
24
  'craft' => 'CraftInstaller',
25
  'croogo' => 'CroogoInstaller',
26
+ 'dokuwiki' => 'DokuWikiInstaller',
27
  'dolibarr' => 'DolibarrInstaller',
28
+ 'drupal' => 'DrupalInstaller',
29
  'elgg' => 'ElggInstaller',
 
30
  'fuel' => 'FuelInstaller',
31
+ 'fuelphp' => 'FuelphpInstaller',
32
+ 'grav' => 'GravInstaller',
33
  'hurad' => 'HuradInstaller',
34
  'joomla' => 'JoomlaInstaller',
35
  'kirby' => 'KirbyInstaller',
38
  'lithium' => 'LithiumInstaller',
39
  'magento' => 'MagentoInstaller',
40
  'mako' => 'MakoInstaller',
 
41
  'mediawiki' => 'MediaWikiInstaller',
42
  'microweber' => 'MicroweberInstaller',
43
  'modulework' => 'MODULEWorkInstaller',
44
+ 'modxevo' => 'MODXEvoInstaller',
45
  'moodle' => 'MoodleInstaller',
46
  'october' => 'OctoberInstaller',
47
  'oxid' => 'OxidInstaller',
48
  'phpbb' => 'PhpBBInstaller',
 
49
  'pimcore' => 'PimcoreInstaller',
50
+ 'piwik' => 'PiwikInstaller',
51
  'ppi' => 'PPIInstaller',
52
+ 'puppet' => 'PuppetInstaller',
53
+ 'redaxo' => 'RedaxoInstaller',
54
  'roundcube' => 'RoundcubeInstaller',
55
  'shopware' => 'ShopwareInstaller',
56
  'silverstripe' => 'SilverStripeInstaller',
57
  'symfony1' => 'Symfony1Installer',
58
+ 'thelia' => 'TheliaInstaller',
59
+ 'tusk' => 'TuskInstaller',
60
+ 'typo3-cms' => 'TYPO3CmsInstaller',
61
+ 'typo3-flow' => 'TYPO3FlowInstaller',
62
+ 'whmcs' => 'WHMCSInstaller',
63
  'wolfcms' => 'WolfCMSInstaller',
64
  'wordpress' => 'WordPressInstaller',
65
  'zend' => 'ZendInstaller',
66
  'zikula' => 'ZikulaInstaller',
 
 
 
67
  );
68
 
69
  /**
124
  {
125
  $frameworkType = false;
126
 
127
+ krsort($this->supportedTypes);
128
+
129
  foreach ($this->supportedTypes as $key => $val) {
130
  if ($key === substr($type, 0, strlen($key))) {
131
  $frameworkType = substr($type, 0, strlen($key));
vendor/composer/installers/src/Composer/Installers/MoodleInstaller.php CHANGED
@@ -5,7 +5,7 @@ class MoodleInstaller extends BaseInstaller
5
  {
6
  protected $locations = array(
7
  'mod' => 'mod/{$name}/',
8
- 'report' => 'admin/report/{$name}/',
9
  'tool' => 'admin/tool/{$name}/',
10
  'assignment' => 'mod/assignment/type/{$name}/',
11
  'assignsubmission' => 'mod/assign/submission/{$name}/',
5
  {
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}/',
vendor/composer/installers/src/Composer/Installers/OctoberInstaller.php CHANGED
@@ -6,5 +6,41 @@ class OctoberInstaller extends BaseInstaller
6
  protected $locations = array(
7
  'module' => 'modules/{$name}/',
8
  'plugin' => 'plugins/{$vendor}/{$name}/',
 
9
  );
10
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  protected $locations = array(
7
  'module' => 'modules/{$name}/',
8
  'plugin' => 'plugins/{$vendor}/{$name}/',
9
+ 'theme' => 'themes/{$name}/'
10
  );
11
+
12
+ /**
13
+ * Format package name.
14
+ *
15
+ * For package type october-plugin, cut off a trailing '-plugin' if present.
16
+ *
17
+ * For package type october-theme, cut off a trailing '-theme' if present.
18
+ *
19
+ */
20
+ public function inflectPackageVars($vars)
21
+ {
22
+ if ($vars['type'] === 'october-plugin') {
23
+ return $this->inflectPluginVars($vars);
24
+ }
25
+
26
+ if ($vars['type'] === 'october-theme') {
27
+ return $this->inflectThemeVars($vars);
28
+ }
29
+
30
+ return $vars;
31
+ }
32
+
33
+ protected function inflectPluginVars($vars)
34
+ {
35
+ $vars['name'] = preg_replace('/-plugin$/', '', $vars['name']);
36
+
37
+ return $vars;
38
+ }
39
+
40
+ protected function inflectThemeVars($vars)
41
+ {
42
+ $vars['name'] = preg_replace('/-theme$/', '', $vars['name']);
43
+
44
+ return $vars;
45
+ }
46
+ }
vendor/{vendor/composer/installers/src/Composer/Installers/PPIInstaller.php → composer/installers/src/Composer/Installers/PuppetInstaller.php} RENAMED
@@ -1,8 +1,10 @@
1
  <?php
 
2
  namespace Composer\Installers;
3
 
4
- class PPIInstaller extends BaseInstaller
5
  {
 
6
  protected $locations = array(
7
  'module' => 'modules/{$name}/',
8
  );
1
  <?php
2
+
3
  namespace Composer\Installers;
4
 
5
+ class PuppetInstaller extends BaseInstaller
6
  {
7
+
8
  protected $locations = array(
9
  'module' => 'modules/{$name}/',
10
  );
vendor/composer/installers/src/Composer/Installers/RedaxoInstaller.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Composer\Installers;
3
+
4
+ class RedaxoInstaller extends BaseInstaller
5
+ {
6
+ protected $locations = array(
7
+ 'addon' => 'redaxo/include/addons/{$name}/',
8
+ 'bestyle-plugin' => 'redaxo/include/addons/be_style/plugins/{$name}/'
9
+ );
10
+ }
vendor/composer/installers/src/Composer/Installers/TheliaInstaller.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Composer\Installers;
3
+
4
+ class TheliaInstaller extends BaseInstaller
5
+ {
6
+ protected $locations = array(
7
+ 'module' => 'local/modules/{$name}/',
8
+ 'frontoffice-template' => 'templates/frontOffice/{$name}/',
9
+ 'backoffice-template' => 'templates/backOffice/{$name}/',
10
+ 'email-template' => 'templates/email/{$name}/',
11
+ );
12
+ }
vendor/composer/installers/src/Composer/Installers/WHMCSInstaller.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Composer\Installers;
4
+
5
+ class WHMCSInstaller extends BaseInstaller
6
+ {
7
+ protected $locations = array(
8
+ 'gateway' => 'modules/gateways/{$name}/',
9
+ );
10
+ }
vendor/composer/installers/tests/Composer/Installers/Test/AsgardInstallerTest.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Composer\Installers\Test;
3
+
4
+ use Composer\Installers\AsgardInstaller;
5
+ use Composer\Package\Package;
6
+ use Composer\Composer;
7
+
8
+ class AsgardInstallerTest extends \PHPUnit_Framework_TestCase
9
+ {
10
+ /**
11
+ * @var OctoberInstaller
12
+ */
13
+ private $installer;
14
+
15
+ public function setUp()
16
+ {
17
+ $this->installer = new AsgardInstaller(
18
+ new Package('NyanCat', '4.2', '4.2'),
19
+ new Composer()
20
+ );
21
+ }
22
+
23
+ /**
24
+ * @dataProvider packageNameInflectionProvider
25
+ */
26
+ public function testInflectPackageVars($type, $name, $expected)
27
+ {
28
+ $this->assertEquals(
29
+ $this->installer->inflectPackageVars(array('name' => $name, 'type' => $type)),
30
+ array('name' => $expected, 'type' => $type)
31
+ );
32
+ }
33
+
34
+ public function packageNameInflectionProvider()
35
+ {
36
+ return array(
37
+ array(
38
+ 'asgard-module',
39
+ 'asgard-module',
40
+ 'Asgard'
41
+ ),
42
+ array(
43
+ 'asgard-module',
44
+ 'blog',
45
+ 'Blog'
46
+ ),
47
+ // tests that exactly one '-theme' is cut off
48
+ array(
49
+ 'asgard-theme',
50
+ 'some-theme-theme',
51
+ 'Some-theme',
52
+ ),
53
+ // tests that names without '-theme' suffix stay valid
54
+ array(
55
+ 'asgard-theme',
56
+ 'someothertheme',
57
+ 'Someothertheme',
58
+ ),
59
+ );
60
+ }
61
+ }
vendor/composer/installers/tests/Composer/Installers/Test/CakePHPInstallerTest.php CHANGED
@@ -101,6 +101,56 @@ class CakePHPInstallerTest extends TestCase
101
  $this->assertContains('plugins/', $result['plugin']);
102
  }
103
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
104
  protected function setCakephpVersion($rm, $version) {
105
  $parser = new VersionParser();
106
  list(, $version) = explode(' ', $parser->parseConstraints($version));
101
  $this->assertContains('plugins/', $result['plugin']);
102
  }
103
 
104
+ /**
105
+ * Test if installer-name was set
106
+ *
107
+ */
108
+ public function testGetInstallPath() {
109
+ $autoload = array(
110
+ 'psr-4' => array(
111
+ 'FOC\\Authenticate' => ''
112
+ )
113
+ );
114
+ $this->package->setAutoload($autoload);
115
+ $this->package->setType('cakephp-plugin');
116
+ $rm = new RepositoryManager(
117
+ $this->getMock('Composer\IO\IOInterface'),
118
+ $this->getMock('Composer\Config')
119
+ );
120
+ $this->composer->setRepositoryManager($rm);
121
+ $installer = new CakePHPInstaller($this->package, $this->composer);
122
+
123
+ $this->setCakephpVersion($rm, '3.0.0');
124
+ $installer->getInstallPath($this->package, 'cakephp');
125
+ $extra = $this->package->getExtra();
126
+ $this->assertEquals('FOC/Authenticate', $extra['installer-name']);
127
+
128
+ $autoload = array(
129
+ 'psr-4' => array(
130
+ 'FOC\Acl\Test' => './tests',
131
+ 'FOC\Acl' => ''
132
+ )
133
+ );
134
+ $this->package->setAutoload($autoload);
135
+ $this->package->setExtra(array());
136
+ $installer->getInstallPath($this->package, 'cakephp');
137
+ $extra = $this->package->getExtra();
138
+ $this->assertEquals('FOC/Acl', $extra['installer-name']);
139
+
140
+ $autoload = array(
141
+ 'psr-4' => array(
142
+ 'Foo\Bar' => 'foo',
143
+ 'Acme\Plugin\Test' => 'tests',
144
+ 'Acme\Plugin' => './src'
145
+ )
146
+ );
147
+ $this->package->setAutoload($autoload);
148
+ $this->package->setExtra(array());
149
+ $installer->getInstallPath($this->package, 'cakephp');
150
+ $extra = $this->package->getExtra();
151
+ $this->assertEquals('Acme/Plugin', $extra['installer-name']);
152
+ }
153
+
154
  protected function setCakephpVersion($rm, $version) {
155
  $parser = new VersionParser();
156
  list(, $version) = explode(' ', $parser->parseConstraints($version));
vendor/composer/installers/tests/Composer/Installers/Test/DokuWikiInstallerTest.php ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Composer\Installers\Test;
3
+
4
+ use Composer\Installers\DokuWikiInstaller;
5
+ use Composer\Package\Package;
6
+ use Composer\Composer;
7
+
8
+ class DokuWikiInstallerTest extends \PHPUnit_Framework_TestCase
9
+ {
10
+ /**
11
+ * @var DokuWikiInstaller
12
+ */
13
+ private $installer;
14
+
15
+ public function setUp()
16
+ {
17
+ $this->installer = new DokuWikiInstaller(
18
+ new Package('NyanCat', '4.2', '4.2'),
19
+ new Composer()
20
+ );
21
+ }
22
+
23
+ /**
24
+ * @dataProvider packageNameInflectionProvider
25
+ */
26
+ public function testInflectPackageVars($type, $name, $expected)
27
+ {
28
+ $this->assertEquals(
29
+ $this->installer->inflectPackageVars(array('name' => $name, 'type'=>$type)),
30
+ array('name' => $expected, 'type'=>$type)
31
+ );
32
+ }
33
+
34
+ public function packageNameInflectionProvider()
35
+ {
36
+ return array(
37
+ array(
38
+ 'dokuwiki-plugin',
39
+ 'dokuwiki-test-plugin',
40
+ 'test',
41
+ ),
42
+ array(
43
+ 'dokuwiki-plugin',
44
+ 'test-plugin',
45
+ 'test',
46
+ ),
47
+ array(
48
+ 'dokuwiki-plugin',
49
+ 'dokuwiki_test',
50
+ 'test',
51
+ ),
52
+ array(
53
+ 'dokuwiki-plugin',
54
+ 'test',
55
+ 'test',
56
+ ),
57
+ array(
58
+ 'dokuwiki-plugin',
59
+ 'test-template',
60
+ 'test-template',
61
+ ),
62
+ array(
63
+ 'dokuwiki-template',
64
+ 'dokuwiki-test-template',
65
+ 'test',
66
+ ),
67
+ array(
68
+ 'dokuwiki-template',
69
+ 'test-template',
70
+ 'test',
71
+ ),
72
+ array(
73
+ 'dokuwiki-template',
74
+ 'dokuwiki_test',
75
+ 'test',
76
+ ),
77
+ array(
78
+ 'dokuwiki-template',
79
+ 'test',
80
+ 'test',
81
+ ),
82
+ array(
83
+ 'dokuwiki-template',
84
+ 'test-plugin',
85
+ 'test-plugin',
86
+ ),
87
+ );
88
+ }
89
+ }
vendor/composer/installers/tests/Composer/Installers/Test/GravInstallerTest.php ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Composer\Installers\Test;
3
+
4
+ use Composer\Composer;
5
+ use Composer\Installers\GravInstaller;
6
+
7
+ class GravInstallerTest extends TestCase
8
+ {
9
+ /* @var \Composer\Composer */
10
+ protected $composer;
11
+
12
+ public function setUp()
13
+ {
14
+ $this->composer = new Composer();
15
+ }
16
+
17
+ public function testInflectPackageVars()
18
+ {
19
+ $package = $this->getPackage('vendor/name', '0.0.0');
20
+ $installer = new GravInstaller($package, $this->composer);
21
+ $packageVars = $this->getPackageVars($package);
22
+
23
+ $result = $installer->inflectPackageVars(array_merge($packageVars, array('name' => 'test')));
24
+ $this->assertEquals('test', $result['name']);
25
+
26
+ foreach ($installer->getLocations() as $name => $location) {
27
+ $result = $installer->inflectPackageVars(array_merge($packageVars, array('name' => "$name-test")));
28
+ $this->assertEquals('test', $result['name']);
29
+ $result = $installer->inflectPackageVars(array_merge($packageVars, array('name' => "test-$name")));
30
+ $this->assertEquals('test', $result['name']);
31
+ $result = $installer->inflectPackageVars(array_merge($packageVars, array('name' => "$name-test-test")));
32
+ $this->assertEquals('test-test', $result['name']);
33
+ $result = $installer->inflectPackageVars(array_merge($packageVars, array('name' => "test-test-$name")));
34
+ $this->assertEquals('test-test', $result['name']);
35
+ $result = $installer->inflectPackageVars(array_merge($packageVars, array('name' => "grav-$name-test")));
36
+ $this->assertEquals('test', $result['name']);
37
+ $result = $installer->inflectPackageVars(array_merge($packageVars, array('name' => "grav-test-$name")));
38
+ $this->assertEquals('test', $result['name']);
39
+ $result = $installer->inflectPackageVars(array_merge($packageVars, array('name' => "grav-$name-test-test")));
40
+ $this->assertEquals('test-test', $result['name']);
41
+ $result = $installer->inflectPackageVars(array_merge($packageVars, array('name' => "grav-test-test-$name")));
42
+ $this->assertEquals('test-test', $result['name']);
43
+ }
44
+ }
45
+
46
+ /**
47
+ * @param $package \Composer\Package\PackageInterface
48
+ */
49
+ public function getPackageVars($package)
50
+ {
51
+ $type = $package->getType();
52
+
53
+ $prettyName = $package->getPrettyName();
54
+ if (strpos($prettyName, '/') !== false) {
55
+ list($vendor, $name) = explode('/', $prettyName);
56
+ } else {
57
+ $vendor = '';
58
+ $name = $prettyName;
59
+ }
60
+
61
+ return compact('name', 'vendor', 'type');
62
+ }
63
+ }
vendor/composer/installers/tests/Composer/Installers/Test/InstallerTest.php CHANGED
@@ -90,10 +90,13 @@ class InstallerTest extends TestCase
90
  array('annotatecms-service', true),
91
  array('bitrix-module', true),
92
  array('bitrix-component', true),
 
93
  array('cakephp', false),
94
  array('cakephp-', false),
95
  array('cakephp-app', false),
96
  array('cakephp-plugin', true),
 
 
97
  array('codeigniter-app', false),
98
  array('codeigniter-library', true),
99
  array('codeigniter-third-party', true),
@@ -105,11 +108,15 @@ class InstallerTest extends TestCase
105
  array('craft-plugin', true),
106
  array('croogo-plugin', true),
107
  array('croogo-theme', true),
 
 
108
  array('drupal-module', true),
109
  array('dolibarr-module', true),
110
  array('elgg-plugin', true),
111
  array('fuel-module', true),
112
  array('fuel-package', true),
 
 
113
  array('hurad-plugin', true),
114
  array('hurad-theme', true),
115
  array('joomla-library', true),
@@ -135,6 +142,9 @@ class InstallerTest extends TestCase
135
  array('phpbb-extension', true),
136
  array('pimcore-plugin', true),
137
  array('ppi-module', true),
 
 
 
138
  array('roundcube-plugin', true),
139
  array('shopware-backend-plugin', true),
140
  array('shopware-core-plugin', true),
@@ -143,10 +153,15 @@ class InstallerTest extends TestCase
143
  array('silverstripe-module', true),
144
  array('silverstripe-theme', true),
145
  array('symfony1-plugin', true),
 
 
 
 
146
  array('tusk-task', true),
147
  array('tusk-asset', true),
148
  array('typo3-flow-plugin', true),
149
  array('typo3-cms-extension', true),
 
150
  array('wolfcms-plugin', true),
151
  array('wordpress-plugin', true),
152
  array('wordpress-core', false),
@@ -183,7 +198,10 @@ class InstallerTest extends TestCase
183
  array('annotatecms-service', 'addons/services/my_service/', 'vysinsky/my_service'),
184
  array('bitrix-module', 'local/modules/my_module/', 'author/my_module'),
185
  array('bitrix-component', 'local/components/my_component/', 'author/my_component'),
 
186
  array('cakephp-plugin', 'Plugin/Ftp/', 'shama/ftp'),
 
 
187
  array('codeigniter-library', 'application/libraries/my_package/', 'shama/my_package'),
188
  array('codeigniter-module', 'application/modules/my_package/', 'shama/my_package'),
189
  array('concrete5-block', 'blocks/concrete5_block/', 'remo/concrete5_block'),
@@ -193,6 +211,8 @@ class InstallerTest extends TestCase
193
  array('craft-plugin', 'craft/plugins/my_plugin/', 'mdcpepper/my_plugin'),
194
  array('croogo-plugin', 'Plugin/Sitemaps/', 'fahad19/sitemaps'),
195
  array('croogo-theme', 'View/Themed/Readable/', 'rchavik/readable'),
 
 
196
  array('dolibarr-module', 'htdocs/custom/my_module/', 'shama/my_module'),
197
  array('drupal-module', 'modules/my_module/', 'shama/my_module'),
198
  array('drupal-theme', 'themes/my_module/', 'shama/my_module'),
@@ -201,8 +221,10 @@ class InstallerTest extends TestCase
201
  array('elgg-plugin', 'mod/sample_plugin/', 'test/sample_plugin'),
202
  array('fuel-module', 'fuel/app/modules/module/', 'fuel/module'),
203
  array('fuel-package', 'fuel/packages/orm/', 'fuel/orm'),
204
- array('hurad-plugin', 'Plugin/Akismet/', 'atkrad/akismet'),
205
- array('hurad-theme', 'View/Themed/Hurad2013/', 'atkrad/Hurad2013'),
 
 
206
  array('joomla-plugin', 'plugins/my_plugin/', 'shama/my_plugin'),
207
  array('kirby-plugin', 'site/plugins/my_plugin/', 'shama/my_plugin'),
208
  array('kohana-module', 'modules/my_package/', 'shama/my_package'),
@@ -226,12 +248,16 @@ class InstallerTest extends TestCase
226
  array('moodle-mod', 'mod/my_package/', 'shama/my_package'),
227
  array('october-module', 'modules/my_plugin/', 'shama/my_plugin'),
228
  array('october-plugin', 'plugins/shama/my_plugin/', 'shama/my_plugin'),
 
229
  array('piwik-plugin', 'plugins/VisitSummary/', 'shama/visit-summary'),
230
  array('phpbb-extension', 'ext/test/foo/', 'test/foo'),
231
  array('phpbb-style', 'styles/foo/', 'test/foo'),
232
  array('phpbb-language', 'language/foo/', 'test/foo'),
233
  array('pimcore-plugin', 'plugins/MyPlugin/', 'ubikz/my_plugin'),
234
  array('ppi-module', 'modules/foo/', 'test/foo'),
 
 
 
235
  array('roundcube-plugin', 'plugins/base/', 'test/base'),
236
  array('roundcube-plugin', 'plugins/replace_dash/', 'test/replace-dash'),
237
  array('shopware-backend-plugin', 'engine/Shopware/Plugins/Local/Backend/ShamaMyBackendPlugin/', 'shama/my-backend-plugin'),
@@ -246,10 +272,15 @@ class InstallerTest extends TestCase
246
  array('silverstripe-theme', 'themes/my_theme/', 'shama/my_theme'),
247
  array('symfony1-plugin', 'plugins/sfShamaPlugin/', 'shama/sfShamaPlugin'),
248
  array('symfony1-plugin', 'plugins/sfShamaPlugin/', 'shama/sf-shama-plugin'),
 
 
 
 
249
  array('tusk-task', '.tusk/tasks/my_task/', 'shama/my_task'),
250
  array('typo3-flow-package', 'Packages/Application/my_package/', 'shama/my_package'),
251
  array('typo3-flow-build', 'Build/my_package/', 'shama/my_package'),
252
  array('typo3-cms-extension', 'typo3conf/ext/my_extension/', 'shama/my_extension'),
 
253
  array('wolfcms-plugin', 'wolf/plugins/my_plugin/', 'shama/my_plugin'),
254
  array('wordpress-plugin', 'wp-content/plugins/my_plugin/', 'shama/my_plugin'),
255
  array('wordpress-muplugin', 'wp-content/mu-plugins/my_plugin/', 'shama/my_plugin'),
90
  array('annotatecms-service', true),
91
  array('bitrix-module', true),
92
  array('bitrix-component', true),
93
+ array('bitrix-theme', true),
94
  array('cakephp', false),
95
  array('cakephp-', false),
96
  array('cakephp-app', false),
97
  array('cakephp-plugin', true),
98
+ array('chef-cookbook', true),
99
+ array('chef-role', true),
100
  array('codeigniter-app', false),
101
  array('codeigniter-library', true),
102
  array('codeigniter-third-party', true),
108
  array('craft-plugin', true),
109
  array('croogo-plugin', true),
110
  array('croogo-theme', true),
111
+ array('dokuwiki-plugin', true),
112
+ array('dokuwiki-template', true),
113
  array('drupal-module', true),
114
  array('dolibarr-module', true),
115
  array('elgg-plugin', true),
116
  array('fuel-module', true),
117
  array('fuel-package', true),
118
+ array('fuel-theme', true),
119
+ array('fuelphp-component', true),
120
  array('hurad-plugin', true),
121
  array('hurad-theme', true),
122
  array('joomla-library', true),
142
  array('phpbb-extension', true),
143
  array('pimcore-plugin', true),
144
  array('ppi-module', true),
145
+ array('puppet-module', true),
146
+ array('redaxo-addon', true),
147
+ array('redaxo-bestyle-plugin', true),
148
  array('roundcube-plugin', true),
149
  array('shopware-backend-plugin', true),
150
  array('shopware-core-plugin', true),
153
  array('silverstripe-module', true),
154
  array('silverstripe-theme', true),
155
  array('symfony1-plugin', true),
156
+ array('thelia-module', true),
157
+ array('thelia-frontoffice-template', true),
158
+ array('thelia-backoffice-template', true),
159
+ array('thelia-email-template', true),
160
  array('tusk-task', true),
161
  array('tusk-asset', true),
162
  array('typo3-flow-plugin', true),
163
  array('typo3-cms-extension', true),
164
+ array('whmcs-gateway', true),
165
  array('wolfcms-plugin', true),
166
  array('wordpress-plugin', true),
167
  array('wordpress-core', false),
198
  array('annotatecms-service', 'addons/services/my_service/', 'vysinsky/my_service'),
199
  array('bitrix-module', 'local/modules/my_module/', 'author/my_module'),
200
  array('bitrix-component', 'local/components/my_component/', 'author/my_component'),
201
+ array('bitrix-theme', 'local/templates/my_theme/', 'author/my_theme'),
202
  array('cakephp-plugin', 'Plugin/Ftp/', 'shama/ftp'),
203
+ array('chef-cookbook', 'Chef/mre/my_cookbook/', 'mre/my_cookbook'),
204
+ array('chef-role', 'Chef/roles/my_role/', 'mre/my_role'),
205
  array('codeigniter-library', 'application/libraries/my_package/', 'shama/my_package'),
206
  array('codeigniter-module', 'application/modules/my_package/', 'shama/my_package'),
207
  array('concrete5-block', 'blocks/concrete5_block/', 'remo/concrete5_block'),
211
  array('craft-plugin', 'craft/plugins/my_plugin/', 'mdcpepper/my_plugin'),
212
  array('croogo-plugin', 'Plugin/Sitemaps/', 'fahad19/sitemaps'),
213
  array('croogo-theme', 'View/Themed/Readable/', 'rchavik/readable'),
214
+ array('dokuwiki-plugin', 'lib/plugins/someplugin/', 'author/someplugin'),
215
+ array('dokuwiki-template', 'lib/tpl/sometemplate/', 'author/sometemplate'),
216
  array('dolibarr-module', 'htdocs/custom/my_module/', 'shama/my_module'),
217
  array('drupal-module', 'modules/my_module/', 'shama/my_module'),
218
  array('drupal-theme', 'themes/my_module/', 'shama/my_module'),
221
  array('elgg-plugin', 'mod/sample_plugin/', 'test/sample_plugin'),
222
  array('fuel-module', 'fuel/app/modules/module/', 'fuel/module'),
223
  array('fuel-package', 'fuel/packages/orm/', 'fuel/orm'),
224
+ array('fuel-theme', 'fuel/app/themes/theme/', 'fuel/theme'),
225
+ array('fuelphp-component', 'components/demo/', 'fuelphp/demo'),
226
+ array('hurad-plugin', 'plugins/Akismet/', 'atkrad/akismet'),
227
+ array('hurad-theme', 'plugins/Hurad2013/', 'atkrad/Hurad2013'),
228
  array('joomla-plugin', 'plugins/my_plugin/', 'shama/my_plugin'),
229
  array('kirby-plugin', 'site/plugins/my_plugin/', 'shama/my_plugin'),
230
  array('kohana-module', 'modules/my_package/', 'shama/my_package'),
248
  array('moodle-mod', 'mod/my_package/', 'shama/my_package'),
249
  array('october-module', 'modules/my_plugin/', 'shama/my_plugin'),
250
  array('october-plugin', 'plugins/shama/my_plugin/', 'shama/my_plugin'),
251
+ array('october-theme', 'themes/my_theme/', 'shama/my_theme'),
252
  array('piwik-plugin', 'plugins/VisitSummary/', 'shama/visit-summary'),
253
  array('phpbb-extension', 'ext/test/foo/', 'test/foo'),
254
  array('phpbb-style', 'styles/foo/', 'test/foo'),
255
  array('phpbb-language', 'language/foo/', 'test/foo'),
256
  array('pimcore-plugin', 'plugins/MyPlugin/', 'ubikz/my_plugin'),
257
  array('ppi-module', 'modules/foo/', 'test/foo'),
258
+ array('puppet-module', 'modules/puppet-name/', 'puppet/puppet-name'),
259
+ array('redaxo-addon', 'redaxo/include/addons/my_plugin/', 'shama/my_plugin'),
260
+ array('redaxo-bestyle-plugin', 'redaxo/include/addons/be_style/plugins/my_plugin/', 'shama/my_plugin'),
261
  array('roundcube-plugin', 'plugins/base/', 'test/base'),
262
  array('roundcube-plugin', 'plugins/replace_dash/', 'test/replace-dash'),
263
  array('shopware-backend-plugin', 'engine/Shopware/Plugins/Local/Backend/ShamaMyBackendPlugin/', 'shama/my-backend-plugin'),
272
  array('silverstripe-theme', 'themes/my_theme/', 'shama/my_theme'),
273
  array('symfony1-plugin', 'plugins/sfShamaPlugin/', 'shama/sfShamaPlugin'),
274
  array('symfony1-plugin', 'plugins/sfShamaPlugin/', 'shama/sf-shama-plugin'),
275
+ array('thelia-module', 'local/modules/my_module/', 'shama/my_module'),
276
+ array('thelia-frontoffice-template', 'templates/frontOffice/my_template_fo/', 'shama/my_template_fo'),
277
+ array('thelia-backoffice-template', 'templates/backOffice/my_template_bo/', 'shama/my_template_bo'),
278
+ array('thelia-email-template', 'templates/email/my_template_email/', 'shama/my_template_email'),
279
  array('tusk-task', '.tusk/tasks/my_task/', 'shama/my_task'),
280
  array('typo3-flow-package', 'Packages/Application/my_package/', 'shama/my_package'),
281
  array('typo3-flow-build', 'Build/my_package/', 'shama/my_package'),
282
  array('typo3-cms-extension', 'typo3conf/ext/my_extension/', 'shama/my_extension'),
283
+ array('whmcs-gateway', 'modules/gateways/gateway_name/', 'vendor/gateway_name'),
284
  array('wolfcms-plugin', 'wolf/plugins/my_plugin/', 'shama/my_plugin'),
285
  array('wordpress-plugin', 'wp-content/plugins/my_plugin/', 'shama/my_plugin'),
286
  array('wordpress-muplugin', 'wp-content/mu-plugins/my_plugin/', 'shama/my_plugin'),
vendor/composer/installers/tests/Composer/Installers/Test/OctoberInstallerTest.php ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Composer\Installers\Test;
3
+
4
+ use Composer\Installers\OctoberInstaller;
5
+ use Composer\Package\Package;
6
+ use Composer\Composer;
7
+
8
+ class OctoberInstallerTest extends \PHPUnit_Framework_TestCase
9
+ {
10
+ /**
11
+ * @var OctoberInstaller
12
+ */
13
+ private $installer;
14
+
15
+ public function setUp()
16
+ {
17
+ $this->installer = new OctoberInstaller(
18
+ new Package('NyanCat', '4.2', '4.2'),
19
+ new Composer()
20
+ );
21
+ }
22
+
23
+ /**
24
+ * @dataProvider packageNameInflectionProvider
25
+ */
26
+ public function testInflectPackageVars($type, $name, $expected)
27
+ {
28
+ $this->assertEquals(
29
+ $this->installer->inflectPackageVars(array('name' => $name, 'type' => $type)),
30
+ array('name' => $expected, 'type' => $type)
31
+ );
32
+ }
33
+
34
+ public function packageNameInflectionProvider()
35
+ {
36
+ return array(
37
+ array(
38
+ 'october-plugin',
39
+ 'subpagelist',
40
+ 'subpagelist',
41
+ ),
42
+ array(
43
+ 'october-plugin',
44
+ 'subpagelist-plugin',
45
+ 'subpagelist',
46
+ ),
47
+ array(
48
+ 'october-plugin',
49
+ 'semanticoctober',
50
+ 'semanticoctober',
51
+ ),
52
+ // tests that exactly one '-theme' is cut off
53
+ array(
54
+ 'october-theme',
55
+ 'some-theme-theme',
56
+ 'some-theme',
57
+ ),
58
+ // tests that names without '-theme' suffix stay valid
59
+ array(
60
+ 'october-theme',
61
+ 'someothertheme',
62
+ 'someothertheme',
63
+ ),
64
+ );
65
+ }
66
+ }
vendor/symfony/yaml/Symfony/Component/Yaml/Dumper.php CHANGED
@@ -28,7 +28,7 @@ class Dumper
28
  /**
29
  * Sets the indentation.
30
  *
31
- * @param int $num The amount of spaces to use for indentation of nested nodes.
32
  */
33
  public function setIndentation($num)
34
  {
@@ -38,13 +38,13 @@ class Dumper
38
  /**
39
  * Dumps a PHP value to YAML.
40
  *
41
- * @param mixed $input The PHP value
42
- * @param int $inline The level where you switch to inline YAML
43
- * @param int $indent The level of indentation (used internally)
44
- * @param bool $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise
45
- * @param bool $objectSupport true if object support is enabled, false otherwise
46
  *
47
- * @return string The YAML representation of the PHP value
48
  */
49
  public function dump($input, $inline = 0, $indent = 0, $exceptionOnInvalidType = false, $objectSupport = false)
50
  {
28
  /**
29
  * Sets the indentation.
30
  *
31
+ * @param int $num The amount of spaces to use for indentation of nested nodes.
32
  */
33
  public function setIndentation($num)
34
  {
38
  /**
39
  * Dumps a PHP value to YAML.
40
  *
41
+ * @param mixed $input The PHP value
42
+ * @param int $inline The level where you switch to inline YAML
43
+ * @param int $indent The level of indentation (used internally)
44
+ * @param bool $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise
45
+ * @param bool $objectSupport true if object support is enabled, false otherwise
46
  *
47
+ * @return string The YAML representation of the PHP value
48
  */
49
  public function dump($input, $inline = 0, $indent = 0, $exceptionOnInvalidType = false, $objectSupport = false)
50
  {
vendor/symfony/yaml/Symfony/Component/Yaml/Escaper.php CHANGED
@@ -26,25 +26,25 @@ class Escaper
26
  // first to ensure proper escaping because str_replace operates iteratively
27
  // on the input arrays. This ordering of the characters avoids the use of strtr,
28
  // which performs more slowly.
29
- private static $escapees = array('\\\\', '\\"', '"',
30
  "\x00", "\x01", "\x02", "\x03", "\x04", "\x05", "\x06", "\x07",
31
  "\x08", "\x09", "\x0a", "\x0b", "\x0c", "\x0d", "\x0e", "\x0f",
32
  "\x10", "\x11", "\x12", "\x13", "\x14", "\x15", "\x16", "\x17",
33
  "\x18", "\x19", "\x1a", "\x1b", "\x1c", "\x1d", "\x1e", "\x1f",
34
- "\xc2\x85", "\xc2\xa0", "\xe2\x80\xa8", "\xe2\x80\xa9");
35
- private static $escaped = array('\\"', '\\\\', '\\"',
36
  "\\0", "\\x01", "\\x02", "\\x03", "\\x04", "\\x05", "\\x06", "\\a",
37
  "\\b", "\\t", "\\n", "\\v", "\\f", "\\r", "\\x0e", "\\x0f",
38
  "\\x10", "\\x11", "\\x12", "\\x13", "\\x14", "\\x15", "\\x16", "\\x17",
39
  "\\x18", "\\x19", "\\x1a", "\\e", "\\x1c", "\\x1d", "\\x1e", "\\x1f",
40
- "\\N", "\\_", "\\L", "\\P");
41
 
42
  /**
43
  * Determines if a PHP value would require double quoting in YAML.
44
  *
45
  * @param string $value A PHP value
46
  *
47
- * @return bool True if the value would require double quotes.
48
  */
49
  public static function requiresDoubleQuoting($value)
50
  {
@@ -68,7 +68,7 @@ class Escaper
68
  *
69
  * @param string $value A PHP value
70
  *
71
- * @return bool True if the value would require single quotes.
72
  */
73
  public static function requiresSingleQuoting($value)
74
  {
26
  // first to ensure proper escaping because str_replace operates iteratively
27
  // on the input arrays. This ordering of the characters avoids the use of strtr,
28
  // which performs more slowly.
29
+ private static $escapees = array('\\', '\\\\', '\\"', '"',
30
  "\x00", "\x01", "\x02", "\x03", "\x04", "\x05", "\x06", "\x07",
31
  "\x08", "\x09", "\x0a", "\x0b", "\x0c", "\x0d", "\x0e", "\x0f",
32
  "\x10", "\x11", "\x12", "\x13", "\x14", "\x15", "\x16", "\x17",
33
  "\x18", "\x19", "\x1a", "\x1b", "\x1c", "\x1d", "\x1e", "\x1f",
34
+ "\xc2\x85", "\xc2\xa0", "\xe2\x80\xa8", "\xe2\x80\xa9",);
35
+ private static $escaped = array('\\\\', '\\"', '\\\\', '\\"',
36
  "\\0", "\\x01", "\\x02", "\\x03", "\\x04", "\\x05", "\\x06", "\\a",
37
  "\\b", "\\t", "\\n", "\\v", "\\f", "\\r", "\\x0e", "\\x0f",
38
  "\\x10", "\\x11", "\\x12", "\\x13", "\\x14", "\\x15", "\\x16", "\\x17",
39
  "\\x18", "\\x19", "\\x1a", "\\e", "\\x1c", "\\x1d", "\\x1e", "\\x1f",
40
+ "\\N", "\\_", "\\L", "\\P",);
41
 
42
  /**
43
  * Determines if a PHP value would require double quoting in YAML.
44
  *
45
  * @param string $value A PHP value
46
  *
47
+ * @return bool True if the value would require double quotes.
48
  */
49
  public static function requiresDoubleQuoting($value)
50
  {
68
  *
69
  * @param string $value A PHP value
70
  *
71
+ * @return bool True if the value would require single quotes.
72
  */
73
  public static function requiresSingleQuoting($value)
74
  {
vendor/symfony/yaml/Symfony/Component/Yaml/Exception/ParseException.php CHANGED
@@ -11,11 +11,6 @@
11
 
12
  namespace Symfony\Component\Yaml\Exception;
13
 
14
- if (!defined('JSON_UNESCAPED_UNICODE')) {
15
- define('JSON_UNESCAPED_SLASHES', 64);
16
- define('JSON_UNESCAPED_UNICODE', 256);
17
- }
18
-
19
  /**
20
  * Exception class thrown when an error occurs during parsing.
21
  *
@@ -33,10 +28,10 @@ class ParseException extends RuntimeException
33
  /**
34
  * Constructor.
35
  *
36
- * @param string $message The error message
37
- * @param int $parsedLine The line where the error occurred
38
- * @param int $snippet The snippet of code near the problem
39
- * @param string $parsedFile The file name where the error occurred
40
  * @param \Exception $previous The previous exception
41
  */
42
  public function __construct($message, $parsedLine = -1, $snippet = null, $parsedFile = null, \Exception $previous = null)
@@ -100,7 +95,7 @@ class ParseException extends RuntimeException
100
  /**
101
  * Gets the line where the error occurred.
102
  *
103
- * @return int The file line
104
  */
105
  public function getParsedLine()
106
  {
@@ -110,7 +105,7 @@ class ParseException extends RuntimeException
110
  /**
111
  * Sets the line where the error occurred.
112
  *
113
- * @param int $parsedLine The file line
114
  */
115
  public function setParsedLine($parsedLine)
116
  {
@@ -130,7 +125,12 @@ class ParseException extends RuntimeException
130
  }
131
 
132
  if (null !== $this->parsedFile) {
133
- $this->message .= sprintf(' in %s', json_encode($this->parsedFile, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
 
 
 
 
 
134
  }
135
 
136
  if ($this->parsedLine >= 0) {
11
 
12
  namespace Symfony\Component\Yaml\Exception;
13
 
 
 
 
 
 
14
  /**
15
  * Exception class thrown when an error occurs during parsing.
16
  *
28
  /**
29
  * Constructor.
30
  *
31
+ * @param string $message The error message
32
+ * @param int $parsedLine The line where the error occurred
33
+ * @param int $snippet The snippet of code near the problem
34
+ * @param string $parsedFile The file name where the error occurred
35
  * @param \Exception $previous The previous exception
36
  */
37
  public function __construct($message, $parsedLine = -1, $snippet = null, $parsedFile = null, \Exception $previous = null)
95
  /**
96
  * Gets the line where the error occurred.
97
  *
98
+ * @return int The file line
99
  */
100
  public function getParsedLine()
101
  {
105
  /**
106
  * Sets the line where the error occurred.
107
  *
108
+ * @param int $parsedLine The file line
109
  */
110
  public function setParsedLine($parsedLine)
111
  {
125
  }
126
 
127
  if (null !== $this->parsedFile) {
128
+ if (PHP_VERSION_ID >= 50400) {
129
+ $jsonOptions = JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE;
130
+ } else {
131
+ $jsonOptions = 0;
132
+ }
133
+ $this->message .= sprintf(' in %s', json_encode($this->parsedFile, $jsonOptions));
134
  }
135
 
136
  if ($this->parsedLine >= 0) {
vendor/symfony/yaml/Symfony/Component/Yaml/Inline.php CHANGED
@@ -25,22 +25,26 @@ class Inline
25
 
26
  private static $exceptionOnInvalidType = false;
27
  private static $objectSupport = false;
 
28
 
29
  /**
30
  * Converts a YAML string to a PHP array.
31
  *
32
- * @param string $value A YAML string
33
- * @param bool $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise
34
- * @param bool $objectSupport true if object support is enabled, false otherwise
 
 
35
  *
36
  * @return array A PHP array representing the YAML string
37
  *
38
  * @throws ParseException
39
  */
40
- public static function parse($value, $exceptionOnInvalidType = false, $objectSupport = false)
41
  {
42
  self::$exceptionOnInvalidType = $exceptionOnInvalidType;
43
  self::$objectSupport = $objectSupport;
 
44
 
45
  $value = trim($value);
46
 
@@ -56,15 +60,15 @@ class Inline
56
  $i = 0;
57
  switch ($value[0]) {
58
  case '[':
59
- $result = self::parseSequence($value, $i);
60
  ++$i;
61
  break;
62
  case '{':
63
- $result = self::parseMapping($value, $i);
64
  ++$i;
65
  break;
66
  default:
67
- $result = self::parseScalar($value, null, array('"', "'"), $i);
68
  }
69
 
70
  // some comments are allowed at the end
@@ -82,9 +86,9 @@ class Inline
82
  /**
83
  * Dumps a given PHP variable to a YAML string.
84
  *
85
- * @param mixed $value The PHP variable to convert
86
- * @param bool $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise
87
- * @param bool $objectSupport true if object support is enabled, false otherwise
88
  *
89
  * @return string The YAML string representing the PHP array
90
  *
@@ -124,8 +128,17 @@ class Inline
124
  if (false !== $locale) {
125
  setlocale(LC_NUMERIC, 'C');
126
  }
127
- $repr = is_string($value) ? "'$value'" : (is_infinite($value) ? str_ireplace('INF', '.Inf', strval($value)) : strval($value));
128
-
 
 
 
 
 
 
 
 
 
129
  if (false !== $locale) {
130
  setlocale(LC_NUMERIC, $locale);
131
  }
@@ -148,9 +161,9 @@ class Inline
148
  /**
149
  * Dumps a PHP array to a YAML string.
150
  *
151
- * @param array $value The PHP array to dump
152
- * @param bool $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise
153
- * @param bool $objectSupport true if object support is enabled, false otherwise
154
  *
155
  * @return string The YAML string representing the PHP array
156
  */
@@ -184,14 +197,15 @@ class Inline
184
  * @param scalar $scalar
185
  * @param string $delimiters
186
  * @param array $stringDelimiters
187
- * @param int &$i
188
- * @param bool $evaluate
 
189
  *
190
  * @return string A YAML string
191
  *
192
  * @throws ParseException When malformed inline YAML string is parsed
193
  */
194
- public static function parseScalar($scalar, $delimiters = null, $stringDelimiters = array('"', "'"), &$i = 0, $evaluate = true)
195
  {
196
  if (in_array($scalar[$i], $stringDelimiters)) {
197
  // quoted scalar
@@ -221,7 +235,7 @@ class Inline
221
  }
222
 
223
  if ($evaluate) {
224
- $output = self::evaluateScalar($output);
225
  }
226
  }
227
 
@@ -232,7 +246,7 @@ class Inline
232
  * Parses a quoted scalar to YAML.
233
  *
234
  * @param string $scalar
235
- * @param int &$i
236
  *
237
  * @return string A YAML string
238
  *
@@ -262,13 +276,14 @@ class Inline
262
  * Parses a sequence to a YAML string.
263
  *
264
  * @param string $sequence
265
- * @param int &$i
 
266
  *
267
  * @return string A YAML string
268
  *
269
  * @throws ParseException When malformed inline YAML string is parsed
270
  */
271
- private static function parseSequence($sequence, &$i = 0)
272
  {
273
  $output = array();
274
  $len = strlen($sequence);
@@ -279,11 +294,11 @@ class Inline
279
  switch ($sequence[$i]) {
280
  case '[':
281
  // nested sequence
282
- $output[] = self::parseSequence($sequence, $i);
283
  break;
284
  case '{':
285
  // nested mapping
286
- $output[] = self::parseMapping($sequence, $i);
287
  break;
288
  case ']':
289
  return $output;
@@ -292,12 +307,14 @@ class Inline
292
  break;
293
  default:
294
  $isQuoted = in_array($sequence[$i], array('"', "'"));
295
- $value = self::parseScalar($sequence, array(',', ']'), array('"', "'"), $i);
296
 
297
- if (!$isQuoted && false !== strpos($value, ': ')) {
 
298
  // embedded mapping?
299
  try {
300
- $value = self::parseMapping('{'.$value.'}');
 
301
  } catch (\InvalidArgumentException $e) {
302
  // no, it's not
303
  }
@@ -318,13 +335,14 @@ class Inline
318
  * Parses a mapping to a YAML string.
319
  *
320
  * @param string $mapping
321
- * @param int &$i
 
322
  *
323
  * @return string A YAML string
324
  *
325
  * @throws ParseException When malformed inline YAML string is parsed
326
  */
327
- private static function parseMapping($mapping, &$i = 0)
328
  {
329
  $output = array();
330
  $len = strlen($mapping);
@@ -338,6 +356,10 @@ class Inline
338
  ++$i;
339
  continue 2;
340
  case '}':
 
 
 
 
341
  return $output;
342
  }
343
 
@@ -346,11 +368,12 @@ class Inline
346
 
347
  // value
348
  $done = false;
 
349
  while ($i < $len) {
350
  switch ($mapping[$i]) {
351
  case '[':
352
  // nested sequence
353
- $value = self::parseSequence($mapping, $i);
354
  // Spec: Keys MUST be unique; first one wins.
355
  // Parser cannot abort this mapping earlier, since lines
356
  // are processed sequentially.
@@ -361,7 +384,7 @@ class Inline
361
  break;
362
  case '{':
363
  // nested mapping
364
- $value = self::parseMapping($mapping, $i);
365
  // Spec: Keys MUST be unique; first one wins.
366
  // Parser cannot abort this mapping earlier, since lines
367
  // are processed sequentially.
@@ -374,7 +397,7 @@ class Inline
374
  case ' ':
375
  break;
376
  default:
377
- $value = self::parseScalar($mapping, array(',', '}'), array('"', "'"), $i);
378
  // Spec: Keys MUST be unique; first one wins.
379
  // Parser cannot abort this mapping earlier, since lines
380
  // are processed sequentially.
@@ -400,13 +423,36 @@ class Inline
400
  * Evaluates scalars and replaces magic values.
401
  *
402
  * @param string $scalar
 
403
  *
404
  * @return string A YAML string
 
 
405
  */
406
- private static function evaluateScalar($scalar)
407
  {
408
  $scalar = trim($scalar);
409
  $scalarLower = strtolower($scalar);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
410
  switch (true) {
411
  case 'null' === $scalarLower:
412
  case '' === $scalar:
@@ -433,6 +479,8 @@ class Inline
433
  }
434
 
435
  return;
 
 
436
  case ctype_digit($scalar):
437
  $raw = $scalar;
438
  $cast = intval($scalar);
25
 
26
  private static $exceptionOnInvalidType = false;
27
  private static $objectSupport = false;
28
+ private static $objectForMap = false;
29
 
30
  /**
31
  * Converts a YAML string to a PHP array.
32
  *
33
+ * @param string $value A YAML string
34
+ * @param bool $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise
35
+ * @param bool $objectSupport true if object support is enabled, false otherwise
36
+ * @param bool $objectForMap true if maps should return a stdClass instead of array()
37
+ * @param array $references Mapping of variable names to values
38
  *
39
  * @return array A PHP array representing the YAML string
40
  *
41
  * @throws ParseException
42
  */
43
+ public static function parse($value, $exceptionOnInvalidType = false, $objectSupport = false, $objectForMap = false, $references = array())
44
  {
45
  self::$exceptionOnInvalidType = $exceptionOnInvalidType;
46
  self::$objectSupport = $objectSupport;
47
+ self::$objectForMap = $objectForMap;
48
 
49
  $value = trim($value);
50
 
60
  $i = 0;
61
  switch ($value[0]) {
62
  case '[':
63
+ $result = self::parseSequence($value, $i, $references);
64
  ++$i;
65
  break;
66
  case '{':
67
+ $result = self::parseMapping($value, $i, $references);
68
  ++$i;
69
  break;
70
  default:
71
+ $result = self::parseScalar($value, null, array('"', "'"), $i, true, $references);
72
  }
73
 
74
  // some comments are allowed at the end
86
  /**
87
  * Dumps a given PHP variable to a YAML string.
88
  *
89
+ * @param mixed $value The PHP variable to convert
90
+ * @param bool $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise
91
+ * @param bool $objectSupport true if object support is enabled, false otherwise
92
  *
93
  * @return string The YAML string representing the PHP array
94
  *
128
  if (false !== $locale) {
129
  setlocale(LC_NUMERIC, 'C');
130
  }
131
+ if (is_float($value)) {
132
+ $repr = strval($value);
133
+ if (is_infinite($value)) {
134
+ $repr = str_ireplace('INF', '.Inf', $repr);
135
+ } elseif (floor($value) == $value && $repr == $value) {
136
+ // Preserve float data type since storing a whole number will result in integer value.
137
+ $repr = '!!float '.$repr;
138
+ }
139
+ } else {
140
+ $repr = is_string($value) ? "'$value'" : strval($value);
141
+ }
142
  if (false !== $locale) {
143
  setlocale(LC_NUMERIC, $locale);
144
  }
161
  /**
162
  * Dumps a PHP array to a YAML string.
163
  *
164
+ * @param array $value The PHP array to dump
165
+ * @param bool $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise
166
+ * @param bool $objectSupport true if object support is enabled, false otherwise
167
  *
168
  * @return string The YAML string representing the PHP array
169
  */
197
  * @param scalar $scalar
198
  * @param string $delimiters
199
  * @param array $stringDelimiters
200
+ * @param int &$i
201
+ * @param bool $evaluate
202
+ * @param array $references
203
  *
204
  * @return string A YAML string
205
  *
206
  * @throws ParseException When malformed inline YAML string is parsed
207
  */
208
+ public static function parseScalar($scalar, $delimiters = null, $stringDelimiters = array('"', "'"), &$i = 0, $evaluate = true, $references = array())
209
  {
210
  if (in_array($scalar[$i], $stringDelimiters)) {
211
  // quoted scalar
235
  }
236
 
237
  if ($evaluate) {
238
+ $output = self::evaluateScalar($output, $references);
239
  }
240
  }
241
 
246
  * Parses a quoted scalar to YAML.
247
  *
248
  * @param string $scalar
249
+ * @param int &$i
250
  *
251
  * @return string A YAML string
252
  *
276
  * Parses a sequence to a YAML string.
277
  *
278
  * @param string $sequence
279
+ * @param int &$i
280
+ * @param array $references
281
  *
282
  * @return string A YAML string
283
  *
284
  * @throws ParseException When malformed inline YAML string is parsed
285
  */
286
+ private static function parseSequence($sequence, &$i = 0, $references = array())
287
  {
288
  $output = array();
289
  $len = strlen($sequence);
294
  switch ($sequence[$i]) {
295
  case '[':
296
  // nested sequence
297
+ $output[] = self::parseSequence($sequence, $i, $references);
298
  break;
299
  case '{':
300
  // nested mapping
301
+ $output[] = self::parseMapping($sequence, $i, $references);
302
  break;
303
  case ']':
304
  return $output;
307
  break;
308
  default:
309
  $isQuoted = in_array($sequence[$i], array('"', "'"));
310
+ $value = self::parseScalar($sequence, array(',', ']'), array('"', "'"), $i, true, $references);
311
 
312
+ // the value can be an array if a reference has been resolved to an array var
313
+ if (!is_array($value) && !$isQuoted && false !== strpos($value, ': ')) {
314
  // embedded mapping?
315
  try {
316
+ $pos = 0;
317
+ $value = self::parseMapping('{'.$value.'}', $pos, $references);
318
  } catch (\InvalidArgumentException $e) {
319
  // no, it's not
320
  }
335
  * Parses a mapping to a YAML string.
336
  *
337
  * @param string $mapping
338
+ * @param int &$i
339
+ * @param array $references
340
  *
341
  * @return string A YAML string
342
  *
343
  * @throws ParseException When malformed inline YAML string is parsed
344
  */
345
+ private static function parseMapping($mapping, &$i = 0, $references = array())
346
  {
347
  $output = array();
348
  $len = strlen($mapping);
356
  ++$i;
357
  continue 2;
358
  case '}':
359
+ if (self::$objectForMap) {
360
+ return (object) $output;
361
+ }
362
+
363
  return $output;
364
  }
365
 
368
 
369
  // value
370
  $done = false;
371
+
372
  while ($i < $len) {
373
  switch ($mapping[$i]) {
374
  case '[':
375
  // nested sequence
376
+ $value = self::parseSequence($mapping, $i, $references);
377
  // Spec: Keys MUST be unique; first one wins.
378
  // Parser cannot abort this mapping earlier, since lines
379
  // are processed sequentially.
384
  break;
385
  case '{':
386
  // nested mapping
387
+ $value = self::parseMapping($mapping, $i, $references);
388
  // Spec: Keys MUST be unique; first one wins.
389
  // Parser cannot abort this mapping earlier, since lines
390
  // are processed sequentially.
397
  case ' ':
398
  break;
399
  default:
400
+ $value = self::parseScalar($mapping, array(',', '}'), array('"', "'"), $i, true, $references);
401
  // Spec: Keys MUST be unique; first one wins.
402
  // Parser cannot abort this mapping earlier, since lines
403
  // are processed sequentially.
423
  * Evaluates scalars and replaces magic values.
424
  *
425
  * @param string $scalar
426
+ * @param array $references
427
  *
428
  * @return string A YAML string
429
+ *
430
+ * @throws ParseException when object parsing support was disabled and the parser detected a PHP object or when a reference could not be resolved
431
  */
432
+ private static function evaluateScalar($scalar, $references = array())
433
  {
434
  $scalar = trim($scalar);
435
  $scalarLower = strtolower($scalar);
436
+
437
+ if (0 === strpos($scalar, '*')) {
438
+ if (false !== $pos = strpos($scalar, '#')) {
439
+ $value = substr($scalar, 1, $pos - 2);
440
+ } else {
441
+ $value = substr($scalar, 1);
442
+ }
443
+
444
+ // an unquoted *
445
+ if (false === $value || '' === $value) {
446
+ throw new ParseException('A reference must contain at least one character.');
447
+ }
448
+
449
+ if (!array_key_exists($value, $references)) {
450
+ throw new ParseException(sprintf('Reference "%s" does not exist.', $value));
451
+ }
452
+
453
+ return $references[$value];
454
+ }
455
+
456
  switch (true) {
457
  case 'null' === $scalarLower:
458
  case '' === $scalar:
479
  }
480
 
481
  return;
482
+ case 0 === strpos($scalar, '!!float '):
483
+ return (float) substr($scalar, 8);
484
  case ctype_digit($scalar):
485
  $raw = $scalar;
486
  $cast = intval($scalar);
vendor/symfony/yaml/Symfony/Component/Yaml/Parser.php CHANGED
@@ -22,16 +22,16 @@ class Parser
22
  {
23
  const FOLDED_SCALAR_PATTERN = '(?P<separator>\||>)(?P<modifiers>\+|\-|\d+|\+\d+|\-\d+|\d+\+|\d+\-)?(?P<comments> +#.*)?';
24
 
25
- private $offset = 0;
26
- private $lines = array();
27
- private $currentLineNb = -1;
28
- private $currentLine = '';
29
- private $refs = array();
30
 
31
  /**
32
  * Constructor
33
  *
34
- * @param int $offset The offset of YAML document (used for line numbers in error messages)
35
  */
36
  public function __construct($offset = 0)
37
  {
@@ -44,12 +44,13 @@ class Parser
44
  * @param string $value A YAML string
45
  * @param bool $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise
46
  * @param bool $objectSupport true if object support is enabled, false otherwise
 
47
  *
48
- * @return mixed A PHP value
49
  *
50
  * @throws ParseException If the YAML is not valid
51
  */
52
- public function parse($value, $exceptionOnInvalidType = false, $objectSupport = false)
53
  {
54
  $this->currentLineNb = -1;
55
  $this->currentLine = '';
@@ -66,6 +67,7 @@ class Parser
66
 
67
  $data = array();
68
  $context = null;
 
69
  while ($this->moveToNextLine()) {
70
  if ($this->isCurrentLineEmpty()) {
71
  continue;
@@ -76,7 +78,7 @@ class Parser
76
  throw new ParseException('A YAML file cannot contain tabs as indentation.', $this->getRealCurrentLineNb() + 1, $this->currentLine);
77
  }
78
 
79
- $isRef = $isInPlace = $isProcessed = false;
80
  if (preg_match('#^\-((?P<leadspaces>\s+)(?P<value>.+?))?\s*$#u', $this->currentLine, $values)) {
81
  if ($context && 'mapping' == $context) {
82
  throw new ParseException('You cannot define a sequence item when in a mapping');
@@ -92,8 +94,8 @@ class Parser
92
  if (!isset($values['value']) || '' == trim($values['value'], ' ') || 0 === strpos(ltrim($values['value'], ' '), '#')) {
93
  $c = $this->getRealCurrentLineNb() + 1;
94
  $parser = new Parser($c);
95
- $parser->refs =& $this->refs;
96
- $data[] = $parser->parse($this->getNextEmbedBlock(), $exceptionOnInvalidType, $objectSupport);
97
  } else {
98
  if (isset($values['leadspaces'])
99
  && ' ' == $values['leadspaces']
@@ -102,26 +104,26 @@ class Parser
102
  // this is a compact notation element, add to next block and parse
103
  $c = $this->getRealCurrentLineNb();
104
  $parser = new Parser($c);
105
- $parser->refs =& $this->refs;
106
 
107
  $block = $values['value'];
108
  if ($this->isNextLineIndented()) {
109
  $block .= "\n".$this->getNextEmbedBlock($this->getCurrentLineIndentation() + 2);
110
  }
111
 
112
- $data[] = $parser->parse($block, $exceptionOnInvalidType, $objectSupport);
113
  } else {
114
- $data[] = $this->parseValue($values['value'], $exceptionOnInvalidType, $objectSupport);
115
  }
116
  }
117
- } elseif (preg_match('#^(?P<key>'.Inline::REGEX_QUOTED_STRING.'|[^ \'"\[\{].*?) *\:(\s+(?P<value>.+?))?\s*$#u', $this->currentLine, $values) && false === strpos($values['key'],' #')) {
118
  if ($context && 'sequence' == $context) {
119
  throw new ParseException('You cannot define a mapping item when in a sequence');
120
  }
121
  $context = 'mapping';
122
 
123
  // force correct settings
124
- Inline::parse(null, $exceptionOnInvalidType, $objectSupport);
125
  try {
126
  $key = Inline::parseScalar($values['key']);
127
  } catch (ParseException $e) {
@@ -132,10 +134,24 @@ class Parser
132
  }
133
 
134
  if ('<<' === $key) {
 
 
135
  if (isset($values['value']) && 0 === strpos($values['value'], '*')) {
136
- $isInPlace = substr($values['value'], 1);
137
- if (!array_key_exists($isInPlace, $this->refs)) {
138
- throw new ParseException(sprintf('Reference "%s" does not exist.', $isInPlace), $this->getRealCurrentLineNb() + 1, $this->currentLine);
 
 
 
 
 
 
 
 
 
 
 
 
139
  }
140
  } else {
141
  if (isset($values['value']) && $values['value'] !== '') {
@@ -145,76 +161,84 @@ class Parser
145
  }
146
  $c = $this->getRealCurrentLineNb() + 1;
147
  $parser = new Parser($c);
148
- $parser->refs =& $this->refs;
149
- $parsed = $parser->parse($value, $exceptionOnInvalidType, $objectSupport);
150
 
151
- $merged = array();
152
  if (!is_array($parsed)) {
153
  throw new ParseException('YAML merge keys used with a scalar value instead of an array.', $this->getRealCurrentLineNb() + 1, $this->currentLine);
154
- } elseif (isset($parsed[0])) {
155
- // Numeric array, merge individual elements
156
- foreach (array_reverse($parsed) as $parsedItem) {
 
 
 
 
157
  if (!is_array($parsedItem)) {
158
  throw new ParseException('Merge items must be arrays.', $this->getRealCurrentLineNb() + 1, $parsedItem);
159
  }
160
- $merged = array_merge($parsedItem, $merged);
 
 
 
 
 
161
  }
162
  } else {
163
- // Associative array, merge
164
- $merged = array_merge($merged, $parsed);
 
 
 
 
 
165
  }
166
-
167
- $isProcessed = $merged;
168
  }
169
  } elseif (isset($values['value']) && preg_match('#^&(?P<ref>[^ ]+) *(?P<value>.*)#u', $values['value'], $matches)) {
170
  $isRef = $matches['ref'];
171
  $values['value'] = $matches['value'];
172
  }
173
 
174
- if ($isProcessed) {
175
  // Merge keys
176
- $data = $isProcessed;
177
- // hash
178
  } elseif (!isset($values['value']) || '' == trim($values['value'], ' ') || 0 === strpos(ltrim($values['value'], ' '), '#')) {
 
179
  // if next line is less indented or equal, then it means that the current value is null
180
  if (!$this->isNextLineIndented() && !$this->isNextLineUnIndentedCollection()) {
181
  // Spec: Keys MUST be unique; first one wins.
182
- // Parser cannot abort this mapping earlier, since lines
183
- // are processed sequentially.
184
- if (!isset($data[$key])) {
185
  $data[$key] = null;
186
  }
187
  } else {
188
  $c = $this->getRealCurrentLineNb() + 1;
189
  $parser = new Parser($c);
190
- $parser->refs =& $this->refs;
191
- $value = $parser->parse($this->getNextEmbedBlock(), $exceptionOnInvalidType, $objectSupport);
192
  // Spec: Keys MUST be unique; first one wins.
193
- // Parser cannot abort this mapping earlier, since lines
194
- // are processed sequentially.
195
- if (!isset($data[$key])) {
196
  $data[$key] = $value;
197
  }
198
  }
199
  } else {
200
- if ($isInPlace) {
201
- $data = $this->refs[$isInPlace];
202
- } else {
203
- $value = $this->parseValue($values['value'], $exceptionOnInvalidType, $objectSupport);;
204
- // Spec: Keys MUST be unique; first one wins.
205
- // Parser cannot abort this mapping earlier, since lines
206
- // are processed sequentially.
207
- if (!isset($data[$key])) {
208
- $data[$key] = $value;
209
- }
210
  }
211
  }
212
  } else {
 
 
 
 
 
213
  // 1-liner optionally followed by newline
214
  $lineCount = count($this->lines);
215
  if (1 === $lineCount || (2 === $lineCount && empty($this->lines[1]))) {
216
  try {
217
- $value = Inline::parse($this->lines[0], $exceptionOnInvalidType, $objectSupport);
218
  } catch (ParseException $e) {
219
  $e->setParsedLine($this->getRealCurrentLineNb() + 1);
220
  $e->setSnippet($this->currentLine);
@@ -278,7 +302,7 @@ class Parser
278
  /**
279
  * Returns the current line number (takes the offset into account).
280
  *
281
- * @return int The current line number
282
  */
283
  private function getRealCurrentLineNb()
284
  {
@@ -288,7 +312,7 @@ class Parser
288
  /**
289
  * Returns the current line indentation.
290
  *
291
- * @return int The current line indentation
292
  */
293
  private function getCurrentLineIndentation()
294
  {
@@ -298,15 +322,20 @@ class Parser
298
  /**
299
  * Returns the next embed block of YAML.
300
  *
301
- * @param int $indentation The indent level at which the block is to be read, or null for default
 
302
  *
303
  * @return string A YAML string
304
  *
305
  * @throws ParseException When indentation problem are detected
306
  */
307
- private function getNextEmbedBlock($indentation = null)
308
  {
309
- $this->moveToNextLine();
 
 
 
 
310
 
311
  if (null === $indentation) {
312
  $newIndent = $this->getCurrentLineIndentation();
@@ -322,6 +351,14 @@ class Parser
322
 
323
  $data = array(substr($this->currentLine, $newIndent));
324
 
 
 
 
 
 
 
 
 
325
  $isItUnindentedCollection = $this->isStringUnIndentedCollectionItem($this->currentLine);
326
 
327
  // Comments must not be removed inside a string block (ie. after a line ending with "|")
@@ -390,15 +427,16 @@ class Parser
390
  /**
391
  * Parses a YAML value.
392
  *
393
- * @param string $value A YAML value
394
- * @param bool $exceptionOnInvalidType True if an exception must be thrown on invalid types false otherwise
395
- * @param bool $objectSupport True if object support is enabled, false otherwise
 
396
  *
397
- * @return mixed A PHP value
398
  *
399
  * @throws ParseException When reference does not exist
400
  */
401
- private function parseValue($value, $exceptionOnInvalidType, $objectSupport)
402
  {
403
  if (0 === strpos($value, '*')) {
404
  if (false !== $pos = strpos($value, '#')) {
@@ -421,7 +459,7 @@ class Parser
421
  }
422
 
423
  try {
424
- return Inline::parse($value, $exceptionOnInvalidType, $objectSupport);
425
  } catch (ParseException $e) {
426
  $e->setParsedLine($this->getRealCurrentLineNb() + 1);
427
  $e->setSnippet($this->currentLine);
@@ -433,11 +471,11 @@ class Parser
433
  /**
434
  * Parses a folded scalar.
435
  *
436
- * @param string $separator The separator that was used to begin this folded scalar (| or >)
437
- * @param string $indicator The indicator that was used to begin this folded scalar (+ or -)
438
- * @param int $indentation The indentation that was used to begin this folded scalar
439
  *
440
- * @return string The text value
441
  */
442
  private function parseFoldedScalar($separator, $indicator = '', $indentation = 0)
443
  {
@@ -514,7 +552,7 @@ class Parser
514
  /**
515
  * Returns true if the next line is indented.
516
  *
517
- * @return bool Returns true if the next line is indented, false otherwise
518
  */
519
  private function isNextLineIndented()
520
  {
@@ -542,7 +580,7 @@ class Parser
542
  /**
543
  * Returns true if the current line is blank or if it is a comment line.
544
  *
545
- * @return bool Returns true if the current line is empty or if it is a comment line, false otherwise
546
  */
547
  private function isCurrentLineEmpty()
548
  {
@@ -552,7 +590,7 @@ class Parser
552
  /**
553
  * Returns true if the current line is blank.
554
  *
555
- * @return bool Returns true if the current line is blank, false otherwise
556
  */
557
  private function isCurrentLineBlank()
558
  {
@@ -562,7 +600,7 @@ class Parser
562
  /**
563
  * Returns true if the current line is a comment line.
564
  *
565
- * @return bool Returns true if the current line is a comment line, false otherwise
566
  */
567
  private function isCurrentLineComment()
568
  {
@@ -613,7 +651,7 @@ class Parser
613
  /**
614
  * Returns true if the next line starts unindented collection
615
  *
616
- * @return bool Returns true if the next line starts unindented collection, false otherwise
617
  */
618
  private function isNextLineUnIndentedCollection()
619
  {
@@ -645,11 +683,10 @@ class Parser
645
  /**
646
  * Returns true if the string is un-indented collection item
647
  *
648
- * @return bool Returns true if the string is un-indented collection item, false otherwise
649
  */
650
  private function isStringUnIndentedCollectionItem()
651
  {
652
  return (0 === strpos($this->currentLine, '- '));
653
  }
654
-
655
  }
22
  {
23
  const FOLDED_SCALAR_PATTERN = '(?P<separator>\||>)(?P<modifiers>\+|\-|\d+|\+\d+|\-\d+|\d+\+|\d+\-)?(?P<comments> +#.*)?';
24
 
25
+ private $offset = 0;
26
+ private $lines = array();
27
+ private $currentLineNb = -1;
28
+ private $currentLine = '';
29
+ private $refs = array();
30
 
31
  /**
32
  * Constructor
33
  *
34
+ * @param int $offset The offset of YAML document (used for line numbers in error messages)
35
  */
36
  public function __construct($offset = 0)
37
  {
44
  * @param string $value A YAML string
45
  * @param bool $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise
46
  * @param bool $objectSupport true if object support is enabled, false otherwise
47
+ * @param bool $objectForMap true if maps should return a stdClass instead of array()
48
  *
49
+ * @return mixed A PHP value
50
  *
51
  * @throws ParseException If the YAML is not valid
52
  */
53
+ public function parse($value, $exceptionOnInvalidType = false, $objectSupport = false, $objectForMap = false)
54
  {
55
  $this->currentLineNb = -1;
56
  $this->currentLine = '';
67
 
68
  $data = array();
69
  $context = null;
70
+ $allowOverwrite = false;
71
  while ($this->moveToNextLine()) {
72
  if ($this->isCurrentLineEmpty()) {
73
  continue;
78
  throw new ParseException('A YAML file cannot contain tabs as indentation.', $this->getRealCurrentLineNb() + 1, $this->currentLine);
79
  }
80
 
81
+ $isRef = $mergeNode = false;
82
  if (preg_match('#^\-((?P<leadspaces>\s+)(?P<value>.+?))?\s*$#u', $this->currentLine, $values)) {
83
  if ($context && 'mapping' == $context) {
84
  throw new ParseException('You cannot define a sequence item when in a mapping');
94
  if (!isset($values['value']) || '' == trim($values['value'], ' ') || 0 === strpos(ltrim($values['value'], ' '), '#')) {
95
  $c = $this->getRealCurrentLineNb() + 1;
96
  $parser = new Parser($c);
97
+ $parser->refs = & $this->refs;
98
+ $data[] = $parser->parse($this->getNextEmbedBlock(null, true), $exceptionOnInvalidType, $objectSupport, $objectForMap);
99
  } else {
100
  if (isset($values['leadspaces'])
101
  && ' ' == $values['leadspaces']
104
  // this is a compact notation element, add to next block and parse
105
  $c = $this->getRealCurrentLineNb();
106
  $parser = new Parser($c);
107
+ $parser->refs = & $this->refs;
108
 
109
  $block = $values['value'];
110
  if ($this->isNextLineIndented()) {
111
  $block .= "\n".$this->getNextEmbedBlock($this->getCurrentLineIndentation() + 2);
112
  }
113
 
114
+ $data[] = $parser->parse($block, $exceptionOnInvalidType, $objectSupport, $objectForMap);
115
  } else {
116
+ $data[] = $this->parseValue($values['value'], $exceptionOnInvalidType, $objectSupport, $objectForMap);
117
  }
118
  }
119
+ } elseif (preg_match('#^(?P<key>'.Inline::REGEX_QUOTED_STRING.'|[^ \'"\[\{].*?) *\:(\s+(?P<value>.+?))?\s*$#u', $this->currentLine, $values) && (false === strpos($values['key'], ' #') || in_array($values['key'][0], array('"', "'")))) {
120
  if ($context && 'sequence' == $context) {
121
  throw new ParseException('You cannot define a mapping item when in a sequence');
122
  }
123
  $context = 'mapping';
124
 
125
  // force correct settings
126
+ Inline::parse(null, $exceptionOnInvalidType, $objectSupport, $objectForMap, $this->refs);
127
  try {
128
  $key = Inline::parseScalar($values['key']);
129
  } catch (ParseException $e) {
134
  }
135
 
136
  if ('<<' === $key) {
137
+ $mergeNode = true;
138
+ $allowOverwrite = true;
139
  if (isset($values['value']) && 0 === strpos($values['value'], '*')) {
140
+ $refName = substr($values['value'], 1);
141
+ if (!array_key_exists($refName, $this->refs)) {
142
+ throw new ParseException(sprintf('Reference "%s" does not exist.', $refName), $this->getRealCurrentLineNb() + 1, $this->currentLine);
143
+ }
144
+
145
+ $refValue = $this->refs[$refName];
146
+
147
+ if (!is_array($refValue)) {
148
+ throw new ParseException('YAML merge keys used with a scalar value instead of an array.', $this->getRealCurrentLineNb() + 1, $this->currentLine);
149
+ }
150
+
151
+ foreach ($refValue as $key => $value) {
152
+ if (!isset($data[$key])) {
153
+ $data[$key] = $value;
154
+ }
155
  }
156
  } else {
157
  if (isset($values['value']) && $values['value'] !== '') {
161
  }
162
  $c = $this->getRealCurrentLineNb() + 1;
163
  $parser = new Parser($c);
164
+ $parser->refs = & $this->refs;
165
+ $parsed = $parser->parse($value, $exceptionOnInvalidType, $objectSupport, $objectForMap);
166
 
 
167
  if (!is_array($parsed)) {
168
  throw new ParseException('YAML merge keys used with a scalar value instead of an array.', $this->getRealCurrentLineNb() + 1, $this->currentLine);
169
+ }
170
+
171
+ if (isset($parsed[0])) {
172
+ // If the value associated with the merge key is a sequence, then this sequence is expected to contain mapping nodes
173
+ // and each of these nodes is merged in turn according to its order in the sequence. Keys in mapping nodes earlier
174
+ // in the sequence override keys specified in later mapping nodes.
175
+ foreach ($parsed as $parsedItem) {
176
  if (!is_array($parsedItem)) {
177
  throw new ParseException('Merge items must be arrays.', $this->getRealCurrentLineNb() + 1, $parsedItem);
178
  }
179
+
180
+ foreach ($parsedItem as $key => $value) {
181
+ if (!isset($data[$key])) {
182
+ $data[$key] = $value;
183
+ }
184
+ }
185
  }
186
  } else {
187
+ // If the value associated with the key is a single mapping node, each of its key/value pairs is inserted into the
188
+ // current mapping, unless the key already exists in it.
189
+ foreach ($parsed as $key => $value) {
190
+ if (!isset($data[$key])) {
191
+ $data[$key] = $value;
192
+ }
193
+ }
194
  }
 
 
195
  }
196
  } elseif (isset($values['value']) && preg_match('#^&(?P<ref>[^ ]+) *(?P<value>.*)#u', $values['value'], $matches)) {
197
  $isRef = $matches['ref'];
198
  $values['value'] = $matches['value'];
199
  }
200
 
201
+ if ($mergeNode) {
202
  // Merge keys
 
 
203
  } elseif (!isset($values['value']) || '' == trim($values['value'], ' ') || 0 === strpos(ltrim($values['value'], ' '), '#')) {
204
+ // hash
205
  // if next line is less indented or equal, then it means that the current value is null
206
  if (!$this->isNextLineIndented() && !$this->isNextLineUnIndentedCollection()) {
207
  // Spec: Keys MUST be unique; first one wins.
208
+ // But overwriting is allowed when a merge node is used in current block.
209
+ if ($allowOverwrite || !isset($data[$key])) {
 
210
  $data[$key] = null;
211
  }
212
  } else {
213
  $c = $this->getRealCurrentLineNb() + 1;
214
  $parser = new Parser($c);
215
+ $parser->refs = & $this->refs;
216
+ $value = $parser->parse($this->getNextEmbedBlock(), $exceptionOnInvalidType, $objectSupport, $objectForMap);
217
  // Spec: Keys MUST be unique; first one wins.
218
+ // But overwriting is allowed when a merge node is used in current block.
219
+ if ($allowOverwrite || !isset($data[$key])) {
 
220
  $data[$key] = $value;
221
  }
222
  }
223
  } else {
224
+ $value = $this->parseValue($values['value'], $exceptionOnInvalidType, $objectSupport, $objectForMap);
225
+ // Spec: Keys MUST be unique; first one wins.
226
+ // But overwriting is allowed when a merge node is used in current block.
227
+ if ($allowOverwrite || !isset($data[$key])) {
228
+ $data[$key] = $value;
 
 
 
 
 
229
  }
230
  }
231
  } else {
232
+ // multiple documents are not supported
233
+ if ('---' === $this->currentLine) {
234
+ throw new ParseException('Multiple documents are not supported.');
235
+ }
236
+
237
  // 1-liner optionally followed by newline
238
  $lineCount = count($this->lines);
239
  if (1 === $lineCount || (2 === $lineCount && empty($this->lines[1]))) {
240
  try {
241
+ $value = Inline::parse($this->lines[0], $exceptionOnInvalidType, $objectSupport, $objectForMap, $this->refs);
242
  } catch (ParseException $e) {
243
  $e->setParsedLine($this->getRealCurrentLineNb() + 1);
244
  $e->setSnippet($this->currentLine);
302
  /**
303
  * Returns the current line number (takes the offset into account).
304
  *
305
+ * @return int The current line number
306
  */
307
  private function getRealCurrentLineNb()
308
  {
312
  /**
313
  * Returns the current line indentation.
314
  *
315
+ * @return int The current line indentation
316
  */
317
  private function getCurrentLineIndentation()
318
  {
322
  /**
323
  * Returns the next embed block of YAML.
324
  *
325
+ * @param int $indentation The indent level at which the block is to be read, or null for default
326
+ * @param bool $inSequence True if the enclosing data structure is a sequence
327
  *
328
  * @return string A YAML string
329
  *
330
  * @throws ParseException When indentation problem are detected
331
  */
332
+ private function getNextEmbedBlock($indentation = null, $inSequence = false)
333
  {
334
+ $oldLineIndentation = $this->getCurrentLineIndentation();
335
+
336
+ if (!$this->moveToNextLine()) {
337
+ return;
338
+ }
339
 
340
  if (null === $indentation) {
341
  $newIndent = $this->getCurrentLineIndentation();
351
 
352
  $data = array(substr($this->currentLine, $newIndent));
353
 
354
+ if ($inSequence && $oldLineIndentation === $newIndent && '-' === $data[0][0]) {
355
+ // the previous line contained a dash but no item content, this line is a sequence item with the same indentation
356
+ // and therefore no nested list or mapping
357
+ $this->moveToPreviousLine();
358
+
359
+ return;
360
+ }
361
+
362
  $isItUnindentedCollection = $this->isStringUnIndentedCollectionItem($this->currentLine);
363
 
364
  // Comments must not be removed inside a string block (ie. after a line ending with "|")
427
  /**
428
  * Parses a YAML value.
429
  *
430
+ * @param string $value A YAML value
431
+ * @param bool $exceptionOnInvalidType True if an exception must be thrown on invalid types false otherwise
432
+ * @param bool $objectSupport True if object support is enabled, false otherwise
433
+ * @param bool $objectForMap true if maps should return a stdClass instead of array()
434
  *
435
+ * @return mixed A PHP value
436
  *
437
  * @throws ParseException When reference does not exist
438
  */
439
+ private function parseValue($value, $exceptionOnInvalidType, $objectSupport, $objectForMap)
440
  {
441
  if (0 === strpos($value, '*')) {
442
  if (false !== $pos = strpos($value, '#')) {
459
  }
460
 
461
  try {
462
+ return Inline::parse($value, $exceptionOnInvalidType, $objectSupport, $objectForMap, $this->refs);
463
  } catch (ParseException $e) {
464
  $e->setParsedLine($this->getRealCurrentLineNb() + 1);
465
  $e->setSnippet($this->currentLine);
471
  /**
472
  * Parses a folded scalar.
473
  *
474
+ * @param string $separator The separator that was used to begin this folded scalar (| or >)
475
+ * @param string $indicator The indicator that was used to begin this folded scalar (+ or -)
476
+ * @param int $indentation The indentation that was used to begin this folded scalar
477
  *
478
+ * @return string The text value
479
  */
480
  private function parseFoldedScalar($separator, $indicator = '', $indentation = 0)
481
  {
552
  /**
553
  * Returns true if the next line is indented.
554
  *
555
+ * @return bool Returns true if the next line is indented, false otherwise
556
  */
557
  private function isNextLineIndented()
558
  {
580
  /**
581
  * Returns true if the current line is blank or if it is a comment line.
582
  *
583
+ * @return bool Returns true if the current line is empty or if it is a comment line, false otherwise
584
  */
585
  private function isCurrentLineEmpty()
586
  {
590
  /**
591
  * Returns true if the current line is blank.
592
  *
593
+ * @return bool Returns true if the current line is blank, false otherwise
594
  */
595
  private function isCurrentLineBlank()
596
  {
600
  /**
601
  * Returns true if the current line is a comment line.
602
  *
603
+ * @return bool Returns true if the current line is a comment line, false otherwise
604
  */
605
  private function isCurrentLineComment()
606
  {
651
  /**
652
  * Returns true if the next line starts unindented collection
653
  *
654
+ * @return bool Returns true if the next line starts unindented collection, false otherwise
655
  */
656
  private function isNextLineUnIndentedCollection()
657
  {
683
  /**
684
  * Returns true if the string is un-indented collection item
685
  *
686
+ * @return bool Returns true if the string is un-indented collection item, false otherwise
687
  */
688
  private function isStringUnIndentedCollectionItem()
689
  {
690
  return (0 === strpos($this->currentLine, '- '));
691
  }
 
692
  }
vendor/symfony/yaml/Symfony/Component/Yaml/README.md CHANGED
@@ -3,11 +3,13 @@ Yaml Component
3
 
4
  YAML implements most of the YAML 1.2 specification.
5
 
6
- use Symfony\Component\Yaml\Yaml;
 
7
 
8
- $array = Yaml::parse($file);
9
 
10
- print Yaml::dump($array);
 
11
 
12
  Resources
13
  ---------
3
 
4
  YAML implements most of the YAML 1.2 specification.
5
 
6
+ ```php
7
+ use Symfony\Component\Yaml\Yaml;
8
 
9
+ $array = Yaml::parse($file);
10
 
11
+ print Yaml::dump($array);
12
+ ```
13
 
14
  Resources
15
  ---------
vendor/symfony/yaml/Symfony/Component/Yaml/Tests/DumperTest.php CHANGED
@@ -55,7 +55,7 @@ class DumperTest extends \PHPUnit_Framework_TestCase
55
  {
56
  $this->dumper->setIndentation(7);
57
 
58
- $expected = <<<EOF
59
  '': bar
60
  foo: '#bar'
61
  'foo''bar': { }
@@ -96,8 +96,7 @@ EOF;
96
  // TODO
97
  } else {
98
  eval('$expected = '.trim($test['php']).';');
99
-
100
- $this->assertEquals($expected, $this->parser->parse($this->dumper->dump($expected, 10)), $test['test']);
101
  }
102
  }
103
  }
@@ -108,10 +107,10 @@ EOF;
108
  $expected = <<<EOF
109
  { '': bar, foo: '#bar', 'foo''bar': { }, bar: [1, foo], foobar: { foo: bar, bar: [1, foo], foobar: { foo: bar, bar: [1, foo] } } }
110
  EOF;
111
- $this->assertEquals($expected, $this->dumper->dump($this->array, -10), '->dump() takes an inline level argument');
112
- $this->assertEquals($expected, $this->dumper->dump($this->array, 0), '->dump() takes an inline level argument');
113
 
114
- $expected = <<<EOF
115
  '': bar
116
  foo: '#bar'
117
  'foo''bar': { }
@@ -199,6 +198,37 @@ EOF;
199
  {
200
  $this->dumper->dump(array('foo' => new A(), 'bar' => 1), 0, 0, true, false);
201
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
202
  }
203
 
204
  class A
55
  {
56
  $this->dumper->setIndentation(7);
57
 
58
+ $expected = <<<EOF
59
  '': bar
60
  foo: '#bar'
61
  'foo''bar': { }
96
  // TODO
97
  } else {
98
  eval('$expected = '.trim($test['php']).';');
99
+ $this->assertSame($expected, $this->parser->parse($this->dumper->dump($expected, 10)), $test['test']);
 
100
  }
101
  }
102
  }
107
  $expected = <<<EOF
108
  { '': bar, foo: '#bar', 'foo''bar': { }, bar: [1, foo], foobar: { foo: bar, bar: [1, foo], foobar: { foo: bar, bar: [1, foo] } } }
109
  EOF;
110
+ $this->assertEquals($expected, $this->dumper->dump($this->array, -10), '->dump() takes an inline level argument');
111
+ $this->assertEquals($expected, $this->dumper->dump($this->array, 0), '->dump() takes an inline level argument');
112
 
113
+ $expected = <<<EOF
114
  '': bar
115
  foo: '#bar'
116
  'foo''bar': { }
198
  {
199
  $this->dumper->dump(array('foo' => new A(), 'bar' => 1), 0, 0, true, false);
200
  }
201
+
202
+ /**
203
+ * @dataProvider getEscapeSequences
204
+ */
205
+ public function testEscapedEscapeSequencesInQuotedScalar($input, $expected)
206
+ {
207
+ $this->assertEquals($expected, $this->dumper->dump($input));
208
+ }
209
+
210
+ public function getEscapeSequences()
211
+ {
212
+ return array(
213
+ 'null' => array("\t\\0", '"\t\\\\0"'),
214
+ 'bell' => array("\t\\a", '"\t\\\\a"'),
215
+ 'backspace' => array("\t\\b", '"\t\\\\b"'),
216
+ 'horizontal-tab' => array("\t\\t", '"\t\\\\t"'),
217
+ 'line-feed' => array("\t\\n", '"\t\\\\n"'),
218
+ 'vertical-tab' => array("\t\\v", '"\t\\\\v"'),
219
+ 'form-feed' => array("\t\\f", '"\t\\\\f"'),
220
+ 'carriage-return' => array("\t\\r", '"\t\\\\r"'),
221
+ 'escape' => array("\t\\e", '"\t\\\\e"'),
222
+ 'space' => array("\t\\ ", '"\t\\\\ "'),
223
+ 'double-quote' => array("\t\\\"", '"\t\\\\\\""'),
224
+ 'slash' => array("\t\\/", '"\t\\\\/"'),
225
+ 'backslash' => array("\t\\\\", '"\t\\\\\\\\"'),
226
+ 'next-line' => array("\t\\N", '"\t\\\\N"'),
227
+ 'non-breaking-space' => array("\t\\�", '"\t\\\\�"'),
228
+ 'line-separator' => array("\t\\L", '"\t\\\\L"'),
229
+ 'paragraph-separator' => array("\t\\P", '"\t\\\\P"'),
230
+ );
231
+ }
232
  }
233
 
234
  class A
vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/YtsBasicTests.yml CHANGED
@@ -11,6 +11,30 @@ yaml: |
11
  php: |
12
  array('apple', 'banana', 'carrot')
13
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  test: Nested Sequences
15
  brief: |
16
  You can include a sequence within another
11
  php: |
12
  array('apple', 'banana', 'carrot')
13
  ---
14
+ test: Sequence With Item Being Null In The Middle
15
+ brief: |
16
+ You can specify a list in YAML by placing each
17
+ member of the list on a new line with an opening
18
+ dash. These lists are called sequences.
19
+ yaml: |
20
+ - apple
21
+ -
22
+ - carrot
23
+ php: |
24
+ array('apple', null, 'carrot')
25
+ ---
26
+ test: Sequence With Last Item Being Null
27
+ brief: |
28
+ You can specify a list in YAML by placing each
29
+ member of the list on a new line with an opening
30
+ dash. These lists are called sequences.
31
+ yaml: |
32
+ - apple
33
+ - banana
34
+ -
35
+ php: |
36
+ array('apple', 'banana', null)
37
+ ---
38
  test: Nested Sequences
39
  brief: |
40
  You can include a sequence within another
vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/YtsSpecificationExamples.yml CHANGED
@@ -463,9 +463,9 @@ yaml: |
463
  0.278 Batting Average
464
  php: |
465
  array(
466
- 'name' => 'Mark McGwire',
467
  'accomplishment' => "Mark set a major league home run record in 1998.\n",
468
- 'stats' => "65 Home Runs\n0.278 Batting Average\n"
469
  )
470
  ---
471
  test: Quoted scalars
@@ -529,6 +529,7 @@ yaml: |
529
  fixed: 1,230.15
530
  negative infinity: -.inf
531
  not a number: .NaN
 
532
  php: |
533
  array(
534
  'canonical' => 1230.15,
@@ -536,6 +537,7 @@ php: |
536
  'fixed' => 1230.15,
537
  'negative infinity' => log(0),
538
  'not a number' => -log(0),
 
539
  )
540
  ---
541
  test: Miscellaneous
463
  0.278 Batting Average
464
  php: |
465
  array(
466
+ 'name' => 'Mark McGwire',
467
  'accomplishment' => "Mark set a major league home run record in 1998.\n",
468
+ 'stats' => "65 Home Runs\n0.278 Batting Average\n"
469
  )
470
  ---
471
  test: Quoted scalars
529
  fixed: 1,230.15
530
  negative infinity: -.inf
531
  not a number: .NaN
532
+ float as whole number: !!float 1
533
  php: |
534
  array(
535
  'canonical' => 1230.15,
537
  'fixed' => 1230.15,
538
  'negative infinity' => log(0),
539
  'not a number' => -log(0),
540
+ 'float as whole number' => (float) 1
541
  )
542
  ---
543
  test: Miscellaneous
vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/sfComments.yml CHANGED
@@ -63,3 +63,11 @@ brief: >
63
  yaml: 'foo#bar: baz'
64
  php: |
65
  array('foo#bar' => 'baz')
 
 
 
 
 
 
 
 
63
  yaml: 'foo#bar: baz'
64
  php: |
65
  array('foo#bar' => 'baz')
66
+ ---
67
+ test: 'Hash key ending with a space and a #'
68
+ brief: >
69
+ 'Hash key ending with a space and a #'
70
+ yaml: |
71
+ 'foo #': baz
72
+ php: |
73
+ array('foo #' => 'baz')
vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/sfMergeKey.yml CHANGED
@@ -10,9 +10,19 @@ yaml: |
10
  a: Steve
11
  b: Clark
12
  c: Brian
13
- bar: &bar
 
 
14
  <<: *foo
 
15
  x: Oren
 
 
 
 
 
 
 
16
  foo2: &foo2
17
  a: Ballmer
18
  ding: &dong [ fi, fei, fo, fam]
@@ -24,4 +34,12 @@ yaml: |
24
  head:
25
  <<: [ *foo , *dong , *foo2 ]
26
  php: |
27
- array('foo' => array('a' => 'Steve', 'b' => 'Clark', 'c' => 'Brian'), 'bar' => array('a' => 'Steve', 'b' => 'Clark', 'c' => 'Brian', 'x' => 'Oren'), 'foo2' => array('a' => 'Ballmer'), 'ding' => array('fi', 'fei', 'fo', 'fam'), 'check' => array('a' => 'Steve', 'b' => 'Clark', 'c' => 'Brian', 'fi', 'fei', 'fo', 'fam', 'isit' => 'tested'), 'head' => array('a' => 'Ballmer', 'b' => 'Clark', 'c' => 'Brian', 'fi', 'fei', 'fo', 'fam'))
 
 
 
 
 
 
 
 
10
  a: Steve
11
  b: Clark
12
  c: Brian
13
+ bar:
14
+ a: before
15
+ d: other
16
  <<: *foo
17
+ b: new
18
  x: Oren
19
+ c:
20
+ foo: bar
21
+ foo: ignore
22
+ bar: foo
23
+ duplicate:
24
+ foo: bar
25
+ foo: ignore
26
  foo2: &foo2
27
  a: Ballmer
28
  ding: &dong [ fi, fei, fo, fam]
34
  head:
35
  <<: [ *foo , *dong , *foo2 ]
36
  php: |
37
+ array(
38
+ 'foo' => array('a' => 'Steve', 'b' => 'Clark', 'c' => 'Brian'),
39
+ 'bar' => array('a' => 'before', 'd' => 'other', 'b' => 'new', 'c' => array('foo' => 'bar', 'bar' => 'foo'), 'x' => 'Oren'),
40
+ 'duplicate' => array('foo' => 'bar'),
41
+ 'foo2' => array('a' => 'Ballmer'),
42
+ 'ding' => array('fi', 'fei', 'fo', 'fam'),
43
+ 'check' => array('a' => 'Steve', 'b' => 'Clark', 'c' => 'Brian', 'fi', 'fei', 'fo', 'fam', 'isit' => 'tested'),
44
+ 'head' => array('a' => 'Steve', 'b' => 'Clark', 'c' => 'Brian', 'fi', 'fei', 'fo', 'fam')
45
+ )
vendor/symfony/yaml/Symfony/Component/Yaml/Tests/InlineTest.php CHANGED
@@ -15,28 +15,32 @@ use Symfony\Component\Yaml\Inline;
15
 
16
  class InlineTest extends \PHPUnit_Framework_TestCase
17
  {
18
- public function testParse()
 
 
 
19
  {
20
- foreach ($this->getTestsForParse() as $yaml => $value) {
21
- $this->assertSame($value, Inline::parse($yaml), sprintf('::parse() converts an inline YAML to a PHP structure (%s)', $yaml));
22
- }
23
  }
24
 
25
- public function testDump()
 
 
 
26
  {
27
- $testsForDump = $this->getTestsForDump();
28
 
29
- foreach ($testsForDump as $yaml => $value) {
30
- $this->assertEquals($yaml, Inline::dump($value), sprintf('::dump() converts a PHP structure to an inline YAML (%s)', $yaml));
31
- }
32
 
33
- foreach ($this->getTestsForParse() as $value) {
34
- $this->assertEquals($value, Inline::parse(Inline::dump($value)), 'check consistency');
35
- }
 
 
 
36
 
37
- foreach ($testsForDump as $value) {
38
- $this->assertEquals($value, Inline::parse(Inline::dump($value)), 'check consistency');
39
- }
40
  }
41
 
42
  public function testDumpNumericValueWithLocale()
@@ -115,117 +119,246 @@ class InlineTest extends \PHPUnit_Framework_TestCase
115
  $this->assertSame($expect, Inline::parseScalar($value));
116
  }
117
 
118
- protected function getTestsForParse()
 
 
 
 
 
 
 
 
119
  {
120
  return array(
121
- '' => '',
122
- 'null' => null,
123
- 'false' => false,
124
- 'true' => true,
125
- '12' => 12,
126
- '-12' => -12,
127
- '"quoted string"' => 'quoted string',
128
- "'quoted string'" => 'quoted string',
129
- '12.30e+02' => 12.30e+02,
130
- '0x4D2' => 0x4D2,
131
- '02333' => 02333,
132
- '.Inf' => -log(0),
133
- '-.Inf' => log(0),
134
- "'686e444'" => '686e444',
135
- '686e444' => 646e444,
136
- '123456789123456789123456789123456789' => '123456789123456789123456789123456789',
137
- '"foo\r\nbar"' => "foo\r\nbar",
138
- "'foo#bar'" => 'foo#bar',
139
- "'foo # bar'" => 'foo # bar',
140
- "'#cfcfcf'" => '#cfcfcf',
141
- '::form_base.html.twig' => '::form_base.html.twig',
142
-
143
- '2007-10-30' => mktime(0, 0, 0, 10, 30, 2007),
144
- '2007-10-30T02:59:43Z' => gmmktime(2, 59, 43, 10, 30, 2007),
145
- '2007-10-30 02:59:43 Z' => gmmktime(2, 59, 43, 10, 30, 2007),
146
- '1960-10-30 02:59:43 Z' => gmmktime(2, 59, 43, 10, 30, 1960),
147
- '1730-10-30T02:59:43Z' => gmmktime(2, 59, 43, 10, 30, 1730),
148
-
149
- '"a \\"string\\" with \'quoted strings inside\'"' => 'a "string" with \'quoted strings inside\'',
150
- "'a \"string\" with ''quoted strings inside'''" => 'a "string" with \'quoted strings inside\'',
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
151
 
152
  // sequences
153
  // urls are no key value mapping. see #3609. Valid yaml "key: value" mappings require a space after the colon
154
- '[foo, http://urls.are/no/mappings, false, null, 12]' => array('foo', 'http://urls.are/no/mappings', false, null, 12),
155
- '[ foo , bar , false , null , 12 ]' => array('foo', 'bar', false, null, 12),
156
- '[\'foo,bar\', \'foo bar\']' => array('foo,bar', 'foo bar'),
157
 
158
  // mappings
159
- '{foo:bar,bar:foo,false:false,null:null,integer:12}' => array('foo' => 'bar', 'bar' => 'foo', 'false' => false, 'null' => null, 'integer' => 12),
160
- '{ foo : bar, bar : foo, false : false, null : null, integer : 12 }' => array('foo' => 'bar', 'bar' => 'foo', 'false' => false, 'null' => null, 'integer' => 12),
161
- '{foo: \'bar\', bar: \'foo: bar\'}' => array('foo' => 'bar', 'bar' => 'foo: bar'),
162
- '{\'foo\': \'bar\', "bar": \'foo: bar\'}' => array('foo' => 'bar', 'bar' => 'foo: bar'),
163
- '{\'foo\'\'\': \'bar\', "bar\"": \'foo: bar\'}' => array('foo\'' => 'bar', "bar\"" => 'foo: bar'),
164
- '{\'foo: \': \'bar\', "bar: ": \'foo: bar\'}' => array('foo: ' => 'bar', "bar: " => 'foo: bar'),
165
 
166
  // nested sequences and mappings
167
- '[foo, [bar, foo]]' => array('foo', array('bar', 'foo')),
168
- '[foo, {bar: foo}]' => array('foo', array('bar' => 'foo')),
169
- '{ foo: {bar: foo} }' => array('foo' => array('bar' => 'foo')),
170
- '{ foo: [bar, foo] }' => array('foo' => array('bar', 'foo')),
 
 
 
 
171
 
172
- '[ foo, [ bar, foo ] ]' => array('foo', array('bar', 'foo')),
173
 
174
- '[{ foo: {bar: foo} }]' => array(array('foo' => array('bar' => 'foo'))),
175
 
176
- '[foo, [bar, [foo, [bar, foo]], foo]]' => array('foo', array('bar', array('foo', array('bar', 'foo')), 'foo')),
 
177
 
178
- '[foo, {bar: foo, foo: [foo, {bar: foo}]}, [foo, {bar: foo}]]' => array('foo', array('bar' => 'foo', 'foo' => array('foo', array('bar' => 'foo'))), array('foo', array('bar' => 'foo'))),
 
 
 
 
 
179
 
180
- '[foo, bar: { foo: bar }]' => array('foo', '1' => array('bar' => array('foo' => 'bar'))),
181
- '[foo, \'@foo.baz\', { \'%foo%\': \'foo is %foo%\', bar: \'%foo%\' }, true, \'@service_container\']' => array('foo', '@foo.baz', array('%foo%' => 'foo is %foo%', 'bar' => '%foo%',), true, '@service_container',),
 
 
182
  );
183
  }
184
 
185
- protected function getTestsForDump()
186
  {
187
  return array(
188
- 'null' => null,
189
- 'false' => false,
190
- 'true' => true,
191
- '12' => 12,
192
- "'quoted string'" => 'quoted string',
193
- '12.30e+02' => 12.30e+02,
194
- '1234' => 0x4D2,
195
- '1243' => 02333,
196
- '.Inf' => -log(0),
197
- '-.Inf' => log(0),
198
- "'686e444'" => '686e444',
199
- '"foo\r\nbar"' => "foo\r\nbar",
200
- "'foo#bar'" => 'foo#bar',
201
- "'foo # bar'" => 'foo # bar',
202
- "'#cfcfcf'" => '#cfcfcf',
203
-
204
- "'a \"string\" with ''quoted strings inside'''" => 'a "string" with \'quoted strings inside\'',
205
-
206
- "'-dash'" => '-dash',
207
- "'-'" => '-',
208
 
209
  // sequences
210
- '[foo, bar, false, null, 12]' => array('foo', 'bar', false, null, 12),
211
- '[\'foo,bar\', \'foo bar\']' => array('foo,bar', 'foo bar'),
212
 
213
  // mappings
214
- '{ foo: bar, bar: foo, \'false\': false, \'null\': null, integer: 12 }' => array('foo' => 'bar', 'bar' => 'foo', 'false' => false, 'null' => null, 'integer' => 12),
215
- '{ foo: bar, bar: \'foo: bar\' }' => array('foo' => 'bar', 'bar' => 'foo: bar'),
216
 
217
  // nested sequences and mappings
218
- '[foo, [bar, foo]]' => array('foo', array('bar', 'foo')),
219
 
220
- '[foo, [bar, [foo, [bar, foo]], foo]]' => array('foo', array('bar', array('foo', array('bar', 'foo')), 'foo')),
221
 
222
- '{ foo: { bar: foo } }' => array('foo' => array('bar' => 'foo')),
223
 
224
- '[foo, { bar: foo }]' => array('foo', array('bar' => 'foo')),
225
 
226
- '[foo, { bar: foo, foo: [foo, { bar: foo }] }, [foo, { bar: foo }]]' => array('foo', array('bar' => 'foo', 'foo' => array('foo', array('bar' => 'foo'))), array('foo', array('bar' => 'foo'))),
227
 
228
- '[foo, \'@foo.baz\', { \'%foo%\': \'foo is %foo%\', bar: \'%foo%\' }, true, \'@service_container\']' => array('foo', '@foo.baz', array('%foo%' => 'foo is %foo%', 'bar' => '%foo%',), true, '@service_container',),
229
  );
230
  }
231
  }
15
 
16
  class InlineTest extends \PHPUnit_Framework_TestCase
17
  {
18
+ /**
19
+ * @dataProvider getTestsForParse
20
+ */
21
+ public function testParse($yaml, $value)
22
  {
23
+ $this->assertSame($value, Inline::parse($yaml), sprintf('::parse() converts an inline YAML to a PHP structure (%s)', $yaml));
 
 
24
  }
25
 
26
+ /**
27
+ * @dataProvider getTestsForParseWithMapObjects
28
+ */
29
+ public function testParseWithMapObjects($yaml, $value)
30
  {
31
+ $actual = Inline::parse($yaml, false, false, true);
32
 
33
+ $this->assertSame(serialize($value), serialize($actual));
34
+ }
 
35
 
36
+ /**
37
+ * @dataProvider getTestsForDump
38
+ */
39
+ public function testDump($yaml, $value)
40
+ {
41
+ $this->assertEquals($yaml, Inline::dump($value), sprintf('::dump() converts a PHP structure to an inline YAML (%s)', $yaml));
42
 
43
+ $this->assertSame($value, Inline::parse(Inline::dump($value)), 'check consistency');
 
 
44
  }
45
 
46
  public function testDumpNumericValueWithLocale()
119
  $this->assertSame($expect, Inline::parseScalar($value));
120
  }
121
 
122
+ /**
123
+ * @dataProvider getDataForParseReferences
124
+ */
125
+ public function testParseReferences($yaml, $expected)
126
+ {
127
+ $this->assertSame($expected, Inline::parse($yaml, false, false, false, array('var' => 'var-value')));
128
+ }
129
+
130
+ public function getDataForParseReferences()
131
  {
132
  return array(
133
+ 'scalar' => array('*var', 'var-value'),
134
+ 'list' => array('[ *var ]', array('var-value')),
135
+ 'list-in-list' => array('[[ *var ]]', array(array('var-value'))),
136
+ 'map-in-list' => array('[ { key: *var } ]', array(array('key' => 'var-value'))),
137
+ 'embedded-mapping-in-list' => array('[ key: *var ]', array(array('key' => 'var-value'))),
138
+ 'map' => array('{ key: *var }', array('key' => 'var-value')),
139
+ 'list-in-map' => array('{ key: [*var] }', array('key' => array('var-value'))),
140
+ 'map-in-map' => array('{ foo: { bar: *var } }', array('foo' => array('bar' => 'var-value'))),
141
+ );
142
+ }
143
+
144
+ public function testParseMapReferenceInSequence()
145
+ {
146
+ $foo = array(
147
+ 'a' => 'Steve',
148
+ 'b' => 'Clark',
149
+ 'c' => 'Brian',
150
+ );
151
+ $this->assertSame(array($foo), Inline::parse('[*foo]', false, false, false, array('foo' => $foo)));
152
+ }
153
+
154
+ /**
155
+ * @expectedException \Symfony\Component\Yaml\Exception\ParseException
156
+ * @expectedExceptionMessage A reference must contain at least one character.
157
+ */
158
+ public function testParseUnquotedAsterisk()
159
+ {
160
+ Inline::parse('{ foo: * }');
161
+ }
162
+
163
+ /**
164
+ * @expectedException \Symfony\Component\Yaml\Exception\ParseException
165
+ * @expectedExceptionMessage A reference must contain at least one character.
166
+ */
167
+ public function testParseUnquotedAsteriskFollowedByAComment()
168
+ {
169
+ Inline::parse('{ foo: * #foo }');
170
+ }
171
+
172
+ public function getTestsForParse()
173
+ {
174
+ return array(
175
+ array('', ''),
176
+ array('null', null),
177
+ array('false', false),
178
+ array('true', true),
179
+ array('12', 12),
180
+ array('-12', -12),
181
+ array('"quoted string"', 'quoted string'),
182
+ array("'quoted string'", 'quoted string'),
183
+ array('12.30e+02', 12.30e+02),
184
+ array('0x4D2', 0x4D2),
185
+ array('02333', 02333),
186
+ array('.Inf', -log(0)),
187
+ array('-.Inf', log(0)),
188
+ array("'686e444'", '686e444'),
189
+ array('686e444', 646e444),
190
+ array('123456789123456789123456789123456789', '123456789123456789123456789123456789'),
191
+ array('"foo\r\nbar"', "foo\r\nbar"),
192
+ array("'foo#bar'", 'foo#bar'),
193
+ array("'foo # bar'", 'foo # bar'),
194
+ array("'#cfcfcf'", '#cfcfcf'),
195
+ array('::form_base.html.twig', '::form_base.html.twig'),
196
+
197
+ array('2007-10-30', mktime(0, 0, 0, 10, 30, 2007)),
198
+ array('2007-10-30T02:59:43Z', gmmktime(2, 59, 43, 10, 30, 2007)),
199
+ array('2007-10-30 02:59:43 Z', gmmktime(2, 59, 43, 10, 30, 2007)),
200
+ array('1960-10-30 02:59:43 Z', gmmktime(2, 59, 43, 10, 30, 1960)),
201
+ array('1730-10-30T02:59:43Z', gmmktime(2, 59, 43, 10, 30, 1730)),
202
+
203
+ array('"a \\"string\\" with \'quoted strings inside\'"', 'a "string" with \'quoted strings inside\''),
204
+ array("'a \"string\" with ''quoted strings inside'''", 'a "string" with \'quoted strings inside\''),
205
+
206
+ // sequences
207
+ // urls are no key value mapping. see #3609. Valid yaml "key: value" mappings require a space after the colon
208
+ array('[foo, http://urls.are/no/mappings, false, null, 12]', array('foo', 'http://urls.are/no/mappings', false, null, 12)),
209
+ array('[ foo , bar , false , null , 12 ]', array('foo', 'bar', false, null, 12)),
210
+ array('[\'foo,bar\', \'foo bar\']', array('foo,bar', 'foo bar')),
211
+
212
+ // mappings
213
+ array('{foo:bar,bar:foo,false:false,null:null,integer:12}', array('foo' => 'bar', 'bar' => 'foo', 'false' => false, 'null' => null, 'integer' => 12)),
214
+ array('{ foo : bar, bar : foo, false : false, null : null, integer : 12 }', array('foo' => 'bar', 'bar' => 'foo', 'false' => false, 'null' => null, 'integer' => 12)),
215
+ array('{foo: \'bar\', bar: \'foo: bar\'}', array('foo' => 'bar', 'bar' => 'foo: bar')),
216
+ array('{\'foo\': \'bar\', "bar": \'foo: bar\'}', array('foo' => 'bar', 'bar' => 'foo: bar')),
217
+ array('{\'foo\'\'\': \'bar\', "bar\"": \'foo: bar\'}', array('foo\'' => 'bar', "bar\"" => 'foo: bar')),
218
+ array('{\'foo: \': \'bar\', "bar: ": \'foo: bar\'}', array('foo: ' => 'bar', "bar: " => 'foo: bar')),
219
+
220
+ // nested sequences and mappings
221
+ array('[foo, [bar, foo]]', array('foo', array('bar', 'foo'))),
222
+ array('[foo, {bar: foo}]', array('foo', array('bar' => 'foo'))),
223
+ array('{ foo: {bar: foo} }', array('foo' => array('bar' => 'foo'))),
224
+ array('{ foo: [bar, foo] }', array('foo' => array('bar', 'foo'))),
225
+
226
+ array('[ foo, [ bar, foo ] ]', array('foo', array('bar', 'foo'))),
227
+
228
+ array('[{ foo: {bar: foo} }]', array(array('foo' => array('bar' => 'foo')))),
229
+
230
+ array('[foo, [bar, [foo, [bar, foo]], foo]]', array('foo', array('bar', array('foo', array('bar', 'foo')), 'foo'))),
231
+
232
+ array('[foo, {bar: foo, foo: [foo, {bar: foo}]}, [foo, {bar: foo}]]', array('foo', array('bar' => 'foo', 'foo' => array('foo', array('bar' => 'foo'))), array('foo', array('bar' => 'foo')))),
233
+
234
+ array('[foo, bar: { foo: bar }]', array('foo', '1' => array('bar' => array('foo' => 'bar')))),
235
+ array('[foo, \'@foo.baz\', { \'%foo%\': \'foo is %foo%\', bar: \'%foo%\' }, true, \'@service_container\']', array('foo', '@foo.baz', array('%foo%' => 'foo is %foo%', 'bar' => '%foo%'), true, '@service_container')),
236
+ );
237
+ }
238
+
239
+ public function getTestsForParseWithMapObjects()
240
+ {
241
+ return array(
242
+ array('', ''),
243
+ array('null', null),
244
+ array('false', false),
245
+ array('true', true),
246
+ array('12', 12),
247
+ array('-12', -12),
248
+ array('"quoted string"', 'quoted string'),
249
+ array("'quoted string'", 'quoted string'),
250
+ array('12.30e+02', 12.30e+02),
251
+ array('0x4D2', 0x4D2),
252
+ array('02333', 02333),
253
+ array('.Inf', -log(0)),
254
+ array('-.Inf', log(0)),
255
+ array("'686e444'", '686e444'),
256
+ array('686e444', 646e444),
257
+ array('123456789123456789123456789123456789', '123456789123456789123456789123456789'),
258
+ array('"foo\r\nbar"', "foo\r\nbar"),
259
+ array("'foo#bar'", 'foo#bar'),
260
+ array("'foo # bar'", 'foo # bar'),
261
+ array("'#cfcfcf'", '#cfcfcf'),
262
+ array('::form_base.html.twig', '::form_base.html.twig'),
263
+
264
+ array('2007-10-30', mktime(0, 0, 0, 10, 30, 2007)),
265
+ array('2007-10-30T02:59:43Z', gmmktime(2, 59, 43, 10, 30, 2007)),
266
+ array('2007-10-30 02:59:43 Z', gmmktime(2, 59, 43, 10, 30, 2007)),
267
+ array('1960-10-30 02:59:43 Z', gmmktime(2, 59, 43, 10, 30, 1960)),
268
+ array('1730-10-30T02:59:43Z', gmmktime(2, 59, 43, 10, 30, 1730)),
269
+
270
+ array('"a \\"string\\" with \'quoted strings inside\'"', 'a "string" with \'quoted strings inside\''),
271
+ array("'a \"string\" with ''quoted strings inside'''", 'a "string" with \'quoted strings inside\''),
272
 
273
  // sequences
274
  // urls are no key value mapping. see #3609. Valid yaml "key: value" mappings require a space after the colon
275
+ array('[foo, http://urls.are/no/mappings, false, null, 12]', array('foo', 'http://urls.are/no/mappings', false, null, 12)),
276
+ array('[ foo , bar , false , null , 12 ]', array('foo', 'bar', false, null, 12)),
277
+ array('[\'foo,bar\', \'foo bar\']', array('foo,bar', 'foo bar')),
278
 
279
  // mappings
280
+ array('{foo:bar,bar:foo,false:false,null:null,integer:12}', (object) array('foo' => 'bar', 'bar' => 'foo', 'false' => false, 'null' => null, 'integer' => 12)),
281
+ array('{ foo : bar, bar : foo, false : false, null : null, integer : 12 }', (object) array('foo' => 'bar', 'bar' => 'foo', 'false' => false, 'null' => null, 'integer' => 12)),
282
+ array('{foo: \'bar\', bar: \'foo: bar\'}', (object) array('foo' => 'bar', 'bar' => 'foo: bar')),
283
+ array('{\'foo\': \'bar\', "bar": \'foo: bar\'}', (object) array('foo' => 'bar', 'bar' => 'foo: bar')),
284
+ array('{\'foo\'\'\': \'bar\', "bar\"": \'foo: bar\'}', (object) array('foo\'' => 'bar', "bar\"" => 'foo: bar')),
285
+ array('{\'foo: \': \'bar\', "bar: ": \'foo: bar\'}', (object) array('foo: ' => 'bar', "bar: " => 'foo: bar')),
286
 
287
  // nested sequences and mappings
288
+ array('[foo, [bar, foo]]', array('foo', array('bar', 'foo'))),
289
+ array('[foo, {bar: foo}]', array('foo', (object) array('bar' => 'foo'))),
290
+ array('{ foo: {bar: foo} }', (object) array('foo' => (object) array('bar' => 'foo'))),
291
+ array('{ foo: [bar, foo] }', (object) array('foo' => array('bar', 'foo'))),
292
+
293
+ array('[ foo, [ bar, foo ] ]', array('foo', array('bar', 'foo'))),
294
+
295
+ array('[{ foo: {bar: foo} }]', array((object) array('foo' => (object) array('bar' => 'foo')))),
296
 
297
+ array('[foo, [bar, [foo, [bar, foo]], foo]]', array('foo', array('bar', array('foo', array('bar', 'foo')), 'foo'))),
298
 
299
+ array('[foo, {bar: foo, foo: [foo, {bar: foo}]}, [foo, {bar: foo}]]', array('foo', (object) array('bar' => 'foo', 'foo' => array('foo', (object) array('bar' => 'foo'))), array('foo', (object) array('bar' => 'foo')))),
300
 
301
+ array('[foo, bar: { foo: bar }]', array('foo', '1' => (object) array('bar' => (object) array('foo' => 'bar')))),
302
+ array('[foo, \'@foo.baz\', { \'%foo%\': \'foo is %foo%\', bar: \'%foo%\' }, true, \'@service_container\']', array('foo', '@foo.baz', (object) array('%foo%' => 'foo is %foo%', 'bar' => '%foo%'), true, '@service_container')),
303
 
304
+ array('{}', new \stdClass()),
305
+ array('{ foo : bar, bar : {} }', (object) array('foo' => 'bar', 'bar' => new \stdClass())),
306
+ array('{ foo : [], bar : {} }', (object) array('foo' => array(), 'bar' => new \stdClass())),
307
+ array('{foo: \'bar\', bar: {} }', (object) array('foo' => 'bar', 'bar' => new \stdClass())),
308
+ array('{\'foo\': \'bar\', "bar": {}}', (object) array('foo' => 'bar', 'bar' => new \stdClass())),
309
+ array('{\'foo\': \'bar\', "bar": \'{}\'}', (object) array('foo' => 'bar', 'bar' => '{}')),
310
 
311
+ array('[foo, [{}, {}]]', array('foo', array(new \stdClass(), new \stdClass()))),
312
+ array('[foo, [[], {}]]', array('foo', array(array(), new \stdClass()))),
313
+ array('[foo, [[{}, {}], {}]]', array('foo', array(array(new \stdClass(), new \stdClass()), new \stdClass()))),
314
+ array('[foo, {bar: {}}]', array('foo', '1' => (object) array('bar' => new \stdClass()))),
315
  );
316
  }
317
 
318
+ public function getTestsForDump()
319
  {
320
  return array(
321
+ array('null', null),
322
+ array('false', false),
323
+ array('true', true),
324
+ array('12', 12),
325
+ array("'quoted string'", 'quoted string'),
326
+ array('!!float 1230', 12.30e+02),
327
+ array('1234', 0x4D2),
328
+ array('1243', 02333),
329
+ array('.Inf', -log(0)),
330
+ array('-.Inf', log(0)),
331
+ array("'686e444'", '686e444'),
332
+ array('"foo\r\nbar"', "foo\r\nbar"),
333
+ array("'foo#bar'", 'foo#bar'),
334
+ array("'foo # bar'", 'foo # bar'),
335
+ array("'#cfcfcf'", '#cfcfcf'),
336
+
337
+ array("'a \"string\" with ''quoted strings inside'''", 'a "string" with \'quoted strings inside\''),
338
+
339
+ array("'-dash'", '-dash'),
340
+ array("'-'", '-'),
341
 
342
  // sequences
343
+ array('[foo, bar, false, null, 12]', array('foo', 'bar', false, null, 12)),
344
+ array('[\'foo,bar\', \'foo bar\']', array('foo,bar', 'foo bar')),
345
 
346
  // mappings
347
+ array('{ foo: bar, bar: foo, \'false\': false, \'null\': null, integer: 12 }', array('foo' => 'bar', 'bar' => 'foo', 'false' => false, 'null' => null, 'integer' => 12)),
348
+ array('{ foo: bar, bar: \'foo: bar\' }', array('foo' => 'bar', 'bar' => 'foo: bar')),
349
 
350
  // nested sequences and mappings
351
+ array('[foo, [bar, foo]]', array('foo', array('bar', 'foo'))),
352
 
353
+ array('[foo, [bar, [foo, [bar, foo]], foo]]', array('foo', array('bar', array('foo', array('bar', 'foo')), 'foo'))),
354
 
355
+ array('{ foo: { bar: foo } }', array('foo' => array('bar' => 'foo'))),
356
 
357
+ array('[foo, { bar: foo }]', array('foo', array('bar' => 'foo'))),
358
 
359
+ array('[foo, { bar: foo, foo: [foo, { bar: foo }] }, [foo, { bar: foo }]]', array('foo', array('bar' => 'foo', 'foo' => array('foo', array('bar' => 'foo'))), array('foo', array('bar' => 'foo')))),
360
 
361
+ array('[foo, \'@foo.baz\', { \'%foo%\': \'foo is %foo%\', bar: \'%foo%\' }, true, \'@service_container\']', array('foo', '@foo.baz', array('%foo%' => 'foo is %foo%', 'bar' => '%foo%'), true, '@service_container')),
362
  );
363
  }
364
  }
vendor/symfony/yaml/Symfony/Component/Yaml/Tests/ParseExceptionTest.php CHANGED
@@ -19,7 +19,7 @@ class ParseExceptionTest extends \PHPUnit_Framework_TestCase
19
  public function testGetMessage()
20
  {
21
  $exception = new ParseException('Error message', 42, 'foo: bar', '/var/www/app/config.yml');
22
- if (version_compare(PHP_VERSION, '5.4.0', '>=')) {
23
  $message = 'Error message in "/var/www/app/config.yml" at line 42 (near "foo: bar")';
24
  } else {
25
  $message = 'Error message in "\\/var\\/www\\/app\\/config.yml" at line 42 (near "foo: bar")';
@@ -27,4 +27,16 @@ class ParseExceptionTest extends \PHPUnit_Framework_TestCase
27
 
28
  $this->assertEquals($message, $exception->getMessage());
29
  }
 
 
 
 
 
 
 
 
 
 
 
 
30
  }
19
  public function testGetMessage()
20
  {
21
  $exception = new ParseException('Error message', 42, 'foo: bar', '/var/www/app/config.yml');
22
+ if (PHP_VERSION_ID >= 50400) {
23
  $message = 'Error message in "/var/www/app/config.yml" at line 42 (near "foo: bar")';
24
  } else {
25
  $message = 'Error message in "\\/var\\/www\\/app\\/config.yml" at line 42 (near "foo: bar")';
27
 
28
  $this->assertEquals($message, $exception->getMessage());
29
  }
30
+
31
+ public function testGetMessageWithUnicodeInFilename()
32
+ {
33
+ $exception = new ParseException('Error message', 42, 'foo: bar', 'äöü.yml');
34
+ if (PHP_VERSION_ID >= 50400) {
35
+ $message = 'Error message in "äöü.yml" at line 42 (near "foo: bar")';
36
+ } else {
37
+ $message = 'Error message in "\u00e4\u00f6\u00fc.yml" at line 42 (near "foo: bar")';
38
+ }
39
+
40
+ $this->assertEquals($message, $exception->getMessage());
41
+ }
42
  }
vendor/symfony/yaml/Symfony/Component/Yaml/Tests/ParserTest.php CHANGED
@@ -405,7 +405,7 @@ foo: |-
405
 
406
  EOF;
407
  $expected = array(
408
- 'foo' => "\n\nbar"
409
  );
410
 
411
  $this->assertSame($expected, $this->parser->parse($yaml));
@@ -449,7 +449,7 @@ EOF;
449
  $yamls = array(
450
  iconv("UTF-8", "ISO-8859-1", "foo: 'äöüß'"),
451
  iconv("UTF-8", "ISO-8859-15", "euro: '€'"),
452
- iconv("UTF-8", "CP1252", "cp1252: '©ÉÇáñ'")
453
  );
454
 
455
  foreach ($yamls as $yaml) {
@@ -458,7 +458,7 @@ EOF;
458
 
459
  $this->fail('charsets other than UTF-8 are rejected.');
460
  } catch (\Exception $e) {
461
- $this->assertInstanceOf('Symfony\Component\Yaml\Exception\ParseException', $e, 'charsets other than UTF-8 are rejected.');
462
  }
463
  }
464
  }
@@ -482,6 +482,27 @@ EOF;
482
  $this->parser->parse($yaml);
483
  }
484
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
485
  /**
486
  * @expectedException \Symfony\Component\Yaml\Exception\ParseException
487
  */
@@ -624,7 +645,7 @@ EOF
624
  public function testNestedFoldedStringBlockWithComments()
625
  {
626
  $this->assertEquals(array(array(
627
- 'title' => 'some title',
628
  'content' => <<<EOT
629
  # comment 1
630
  header
@@ -649,6 +670,32 @@ EOT
649
  </body>
650
 
651
  footer # comment3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
652
  EOF
653
  ));
654
  }
405
 
406
  EOF;
407
  $expected = array(
408
+ 'foo' => "\n\nbar",
409
  );
410
 
411
  $this->assertSame($expected, $this->parser->parse($yaml));
449
  $yamls = array(
450
  iconv("UTF-8", "ISO-8859-1", "foo: 'äöüß'"),
451
  iconv("UTF-8", "ISO-8859-15", "euro: '€'"),
452
+ iconv("UTF-8", "CP1252", "cp1252: '©ÉÇáñ'"),
453
  );
454
 
455
  foreach ($yamls as $yaml) {
458
 
459
  $this->fail('charsets other than UTF-8 are rejected.');
460
  } catch (\Exception $e) {
461
+ $this->assertInstanceOf('Symfony\Component\Yaml\Exception\ParseException', $e, 'charsets other than UTF-8 are rejected.');
462
  }
463
  }
464
  }
482
  $this->parser->parse($yaml);
483
  }
484
 
485
+ /**
486
+ * @expectedException \Symfony\Component\Yaml\Exception\ParseException
487
+ * @expectedExceptionMessage Multiple documents are not supported.
488
+ */
489
+ public function testMultipleDocumentsNotSupportedException()
490
+ {
491
+ Yaml::parse(<<<EOL
492
+ # Ranking of 1998 home runs
493
+ ---
494
+ - Mark McGwire
495
+ - Sammy Sosa
496
+ - Ken Griffey
497
+
498
+ # Team ranking
499
+ ---
500
+ - Chicago Cubs
501
+ - St Louis Cardinals
502
+ EOL
503
+ );
504
+ }
505
+
506
  /**
507
  * @expectedException \Symfony\Component\Yaml\Exception\ParseException
508
  */
645
  public function testNestedFoldedStringBlockWithComments()
646
  {
647
  $this->assertEquals(array(array(
648
+ 'title' => 'some title',
649
  'content' => <<<EOT
650
  # comment 1
651
  header
670
  </body>
671
 
672
  footer # comment3
673
+ EOF
674
+ ));
675
+ }
676
+
677
+ public function testReferenceResolvingInInlineStrings()
678
+ {
679
+ $this->assertEquals(array(
680
+ 'var' => 'var-value',
681
+ 'scalar' => 'var-value',
682
+ 'list' => array('var-value'),
683
+ 'list_in_list' => array(array('var-value')),
684
+ 'map_in_list' => array(array('key' => 'var-value')),
685
+ 'embedded_mapping' => array(array('key' => 'var-value')),
686
+ 'map' => array('key' => 'var-value'),
687
+ 'list_in_map' => array('key' => array('var-value')),
688
+ 'map_in_map' => array('foo' => array('bar' => 'var-value')),
689
+ ), Yaml::parse(<<<EOF
690
+ var: &var var-value
691
+ scalar: *var
692
+ list: [ *var ]
693
+ list_in_list: [[ *var ]]
694
+ map_in_list: [ { key: *var } ]
695
+ embedded_mapping: [ key: *var ]
696
+ map: { key: *var }
697
+ list_in_map: { key: [*var] }
698
+ map_in_map: { foo: { bar: *var } }
699
  EOF
700
  ));
701
  }
vendor/symfony/yaml/Symfony/Component/Yaml/Unescaper.php CHANGED
@@ -130,12 +130,12 @@ class Unescaper
130
  return chr($c);
131
  }
132
  if (0x800 > $c) {
133
- return chr(0xC0 | $c>>6).chr(0x80 | $c & 0x3F);
134
  }
135
  if (0x10000 > $c) {
136
- return chr(0xE0 | $c>>12).chr(0x80 | $c>>6 & 0x3F).chr(0x80 | $c & 0x3F);
137
  }
138
 
139
- return chr(0xF0 | $c>>18).chr(0x80 | $c>>12 & 0x3F).chr(0x80 | $c>>6 & 0x3F).chr(0x80 | $c & 0x3F);
140
  }
141
  }
130
  return chr($c);
131
  }
132
  if (0x800 > $c) {
133
+ return chr(0xC0 | $c >> 6).chr(0x80 | $c & 0x3F);
134
  }
135
  if (0x10000 > $c) {
136
+ return chr(0xE0 | $c >> 12).chr(0x80 | $c >> 6 & 0x3F).chr(0x80 | $c & 0x3F);
137
  }
138
 
139
+ return chr(0xF0 | $c >> 18).chr(0x80 | $c >> 12 & 0x3F).chr(0x80 | $c >> 6 & 0x3F).chr(0x80 | $c & 0x3F);
140
  }
141
  }
vendor/symfony/yaml/Symfony/Component/Yaml/Yaml.php CHANGED
@@ -38,9 +38,9 @@ class Yaml
38
  * you must validate the input before calling this method. Passing a file
39
  * as an input is a deprecated feature and will be removed in 3.0.
40
  *
41
- * @param string $input Path to a YAML file or a string containing YAML
42
- * @param bool $exceptionOnInvalidType True if an exception must be thrown on invalid types false otherwise
43
- * @param bool $objectSupport True if object support is enabled, false otherwise
44
  *
45
  * @return array The YAML converted to a PHP array
46
  *
@@ -80,11 +80,11 @@ class Yaml
80
  * The dump method, when supplied with an array, will do its best
81
  * to convert the array into friendly YAML.
82
  *
83
- * @param array $array PHP array
84
- * @param int $inline The level where you switch to inline YAML
85
- * @param int $indent The amount of spaces to use for indentation of nested nodes.
86
- * @param bool $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise
87
- * @param bool $objectSupport true if object support is enabled, false otherwise
88
  *
89
  * @return string A YAML string representing the original PHP array
90
  *
38
  * you must validate the input before calling this method. Passing a file
39
  * as an input is a deprecated feature and will be removed in 3.0.
40
  *
41
+ * @param string $input Path to a YAML file or a string containing YAML
42
+ * @param bool $exceptionOnInvalidType True if an exception must be thrown on invalid types false otherwise
43
+ * @param bool $objectSupport True if object support is enabled, false otherwise
44
  *
45
  * @return array The YAML converted to a PHP array
46
  *
80
  * The dump method, when supplied with an array, will do its best
81
  * to convert the array into friendly YAML.
82
  *
83
+ * @param array $array PHP array
84
+ * @param int $inline The level where you switch to inline YAML
85
+ * @param int $indent The amount of spaces to use for indentation of nested nodes.
86
+ * @param bool $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise
87
+ * @param bool $objectSupport true if object support is enabled, false otherwise
88
  *
89
  * @return string A YAML string representing the original PHP array
90
  *
vendor/symfony/yaml/Symfony/Component/Yaml/composer.json CHANGED
@@ -25,7 +25,7 @@
25
  "minimum-stability": "dev",
26
  "extra": {
27
  "branch-alias": {
28
- "dev-master": "2.5-dev"
29
  }
30
  }
31
  }
25
  "minimum-stability": "dev",
26
  "extra": {
27
  "branch-alias": {
28
+ "dev-master": "2.6-dev"
29
  }
30
  }
31
  }
vendor/symfony/yaml/Symfony/Component/Yaml/phpunit.xml.dist CHANGED
@@ -1,14 +1,9 @@
1
  <?xml version="1.0" encoding="UTF-8"?>
2
 
3
- <phpunit backupGlobals="false"
4
- backupStaticAttributes="false"
 
5
  colors="true"
6
- convertErrorsToExceptions="true"
7
- convertNoticesToExceptions="true"
8
- convertWarningsToExceptions="true"
9
- processIsolation="false"
10
- stopOnFailure="false"
11
- syntaxCheck="false"
12
  bootstrap="vendor/autoload.php"
13
  >
14
  <testsuites>
1
  <?xml version="1.0" encoding="UTF-8"?>
2
 
3
+ <phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
+ xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd"
5
+ backupGlobals="false"
6
  colors="true"
 
 
 
 
 
 
7
  bootstrap="vendor/autoload.php"
8
  >
9
  <testsuites>
vendor/twig/twig/.travis.yml CHANGED
@@ -5,6 +5,7 @@ php:
5
  - 5.3
6
  - 5.4
7
  - 5.5
 
8
  - hhvm
9
 
10
  env:
5
  - 5.3
6
  - 5.4
7
  - 5.5
8
+ - 5.6
9
  - hhvm
10
 
11
  env:
vendor/twig/twig/CHANGELOG CHANGED
@@ -1,4 +1,38 @@
1
- * 1.15.1 (2013-02-13)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
  * fixed the conversion of the special '0000-00-00 00:00' date
4
  * added an error message when trying to import an undefined block from a trait
1
+ * 1.16.3 (2014-12-25)
2
+
3
+ * fixed regression for dynamic parent templates
4
+ * fixed cache management with statcache
5
+ * fixed a regression in the slice filter
6
+
7
+ * 1.16.2 (2014-10-17)
8
+
9
+ * fixed timezone on dates as strings
10
+ * fixed 2-words test names when a custom node class is not used
11
+ * fixed macros when using an argument named like a PHP super global (like GET or POST)
12
+ * fixed date_modify when working with DateTimeImmutable
13
+ * optimized for loops
14
+ * fixed multi-byte characters handling in the split filter
15
+ * fixed a regression in the in operator
16
+ * fixed a regression in the slice filter
17
+
18
+ * 1.16.1 (2014-10-10)
19
+
20
+ * improved error reporting in a sandboxed template
21
+ * fixed missing error file/line information under certain circumstances
22
+ * fixed wrong error line number in some error messages
23
+ * fixed the in operator to use strict comparisons
24
+ * sped up the slice filter
25
+ * fixed for mb function overload mb_substr acting different
26
+ * fixed the attribute() function when passing a variable for the arguments
27
+
28
+ * 1.16.0 (2014-07-05)
29
+
30
+ * changed url_encode to always encode according to RFC 3986
31
+ * fixed inheritance in a 'use'-hierarchy
32
+ * removed the __toString policy check when the sandbox is disabled
33
+ * fixed recursively calling blocks in templates with inheritance
34
+
35
+ * 1.15.1 (2014-02-13)
36
 
37
  * fixed the conversion of the special '0000-00-00 00:00' date
38
  * added an error message when trying to import an undefined block from a trait
vendor/twig/twig/composer.json CHANGED
@@ -14,7 +14,7 @@
14
  },
15
  {
16
  "name": "Twig Team",
17
- "homepage": "https://github.com/fabpot/Twig/graphs/contributors",
18
  "role": "Contributors"
19
  },
20
  {
@@ -36,7 +36,7 @@
36
  },
37
  "extra": {
38
  "branch-alias": {
39
- "dev-master": "1.15-dev"
40
  }
41
  }
42
  }
14
  },
15
  {
16
  "name": "Twig Team",
17
+ "homepage": "http://twig.sensiolabs.org/contributors",
18
  "role": "Contributors"
19
  },
20
  {
36
  },
37
  "extra": {
38
  "branch-alias": {
39
+ "dev-master": "1.16-dev"
40
  }
41
  }
42
  }
vendor/twig/twig/doc/advanced.rst CHANGED
@@ -503,7 +503,7 @@ to host all the specific tags and filters you want to add to Twig.
503
  .. note::
504
 
505
  Before writing your own extensions, have a look at the Twig official
506
- extension repository: http://github.com/fabpot/Twig-extensions.
507
 
508
  An extension is a class that implements the following interface::
509
 
@@ -830,5 +830,5 @@ Testing the node visitors can be complex, so extend your test cases from
830
 
831
  .. _`spl_autoload_register()`: http://www.php.net/spl_autoload_register
832
  .. _`rot13`: http://www.php.net/manual/en/function.str-rot13.php
833
- .. _`tests/Twig/Fixtures`: https://github.com/fabpot/Twig/tree/master/test/Twig/Tests/Fixtures
834
- .. _`tests/Twig/Node`: https://github.com/fabpot/Twig/tree/master/test/Twig/Tests/Node
503
  .. note::
504
 
505
  Before writing your own extensions, have a look at the Twig official
506
+ extension repository: http://github.com/twigphp/Twig-extensions.
507
 
508
  An extension is a class that implements the following interface::
509
 
830
 
831
  .. _`spl_autoload_register()`: http://www.php.net/spl_autoload_register
832
  .. _`rot13`: http://www.php.net/manual/en/function.str-rot13.php
833
+ .. _`tests/Twig/Fixtures`: https://github.com/twigphp/Twig/tree/master/test/Twig/Tests/Fixtures
834
+ .. _`tests/Twig/Node`: https://github.com/twigphp/Twig/tree/master/test/Twig/Tests/Node
vendor/twig/twig/doc/advanced_legacy.rst CHANGED
@@ -529,7 +529,7 @@ to host all the specific tags and filters you want to add to Twig.
529
  .. note::
530
 
531
  Before writing your own extensions, have a look at the Twig official
532
- extension repository: http://github.com/fabpot/Twig-extensions.
533
 
534
  An extension is a class that implements the following interface::
535
 
@@ -883,5 +883,5 @@ Testing the node visitors can be complex, so extend your test cases from
883
 
884
  .. _`spl_autoload_register()`: http://www.php.net/spl_autoload_register
885
  .. _`rot13`: http://www.php.net/manual/en/function.str-rot13.php
886
- .. _`tests/Twig/Fixtures`: https://github.com/fabpot/Twig/tree/master/test/Twig/Tests/Fixtures
887
- .. _`tests/Twig/Node`: https://github.com/fabpot/Twig/tree/master/test/Twig/Tests/Node
529
  .. note::
530
 
531
  Before writing your own extensions, have a look at the Twig official
532
+ extension repository: http://github.com/twigphp/Twig-extensions.
533
 
534
  An extension is a class that implements the following interface::
535
 
883
 
884
  .. _`spl_autoload_register()`: http://www.php.net/spl_autoload_register
885
  .. _`rot13`: http://www.php.net/manual/en/function.str-rot13.php
886
+ .. _`tests/Twig/Fixtures`: https://github.com/twigphp/Twig/tree/master/test/Twig/Tests/Fixtures
887
+ .. _`tests/Twig/Node`: https://github.com/twigphp/Twig/tree/master/test/Twig/Tests/Node
vendor/twig/twig/doc/api.rst CHANGED
@@ -166,21 +166,6 @@ Namespaced templates can be accessed via the special
166
 
167
  $twig->render('@admin/index.html', array());
168
 
169
- ``Twig_Loader_String``
170
- ......................
171
-
172
- ``Twig_Loader_String`` loads templates from strings. It's a dummy loader as
173
- the template reference is the template source code::
174
-
175
- $loader = new Twig_Loader_String();
176
- $twig = new Twig_Environment($loader);
177
-
178
- echo $twig->render('Hello {{ name }}!', array('name' => 'Fabien'));
179
-
180
- This loader should only be used for unit testing as it has severe limitations:
181
- several tags, like ``extends`` or ``include`` do not make sense to use as the
182
- reference to the template is the template source code itself.
183
-
184
  ``Twig_Loader_Array``
185
  .....................
186
 
@@ -214,7 +199,7 @@ projects where storing all templates in a single PHP file might make sense.
214
  'base.html' => '{% block content %}{% endblock %}',
215
  ));
216
  $loader2 = new Twig_Loader_Array(array(
217
- 'index.html' => '{% extends "base.twig" %}{% block content %}Hello {{ name }}{% endblock %}',
218
  'base.html' => 'Will never be loaded',
219
  ));
220
 
@@ -268,26 +253,6 @@ All loaders implement the ``Twig_LoaderInterface``::
268
  function isFresh($name, $time);
269
  }
270
 
271
- As an example, here is how the built-in ``Twig_Loader_String`` reads::
272
-
273
- class Twig_Loader_String implements Twig_LoaderInterface
274
- {
275
- public function getSource($name)
276
- {
277
- return $name;
278
- }
279
-
280
- public function getCacheKey($name)
281
- {
282
- return $name;
283
- }
284
-
285
- public function isFresh($name, $time)
286
- {
287
- return false;
288
- }
289
- }
290
-
291
  The ``isFresh()`` method must return ``true`` if the current cached template
292
  is still fresh, given the last modification time, or ``false`` otherwise.
293
 
166
 
167
  $twig->render('@admin/index.html', array());
168
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
169
  ``Twig_Loader_Array``
170
  .....................
171
 
199
  'base.html' => '{% block content %}{% endblock %}',
200
  ));
201
  $loader2 = new Twig_Loader_Array(array(
202
+ 'index.html' => '{% extends "base.html" %}{% block content %}Hello {{ name }}{% endblock %}',
203
  'base.html' => 'Will never be loaded',
204
  ));
205
 
253
  function isFresh($name, $time);
254
  }
255
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
256
  The ``isFresh()`` method must return ``true`` if the current cached template
257
  is still fresh, given the last modification time, or ``false`` otherwise.
258
 
vendor/twig/twig/doc/deprecated.rst CHANGED
@@ -23,8 +23,8 @@ Extensions
23
  PEAR
24
  ----
25
 
26
- PEAR support will be discontinued in Twig 2.0, and no PEAR packages will be
27
- provided. Use Composer instead.
28
 
29
  Filters
30
  -------
@@ -80,6 +80,12 @@ Tests
80
  * The ``sameas`` and ``divisibleby`` tests are deprecated in favor of ``same
81
  as`` and ``divisible by`` respectively.
82
 
 
 
 
 
 
 
83
  Interfaces
84
  ----------
85
 
23
  PEAR
24
  ----
25
 
26
+ PEAR support has been discontinued in Twig 1.15.1, and no PEAR packages are
27
+ provided anymore. Use Composer instead.
28
 
29
  Filters
30
  -------
80
  * The ``sameas`` and ``divisibleby`` tests are deprecated in favor of ``same
81
  as`` and ``divisible by`` respectively.
82
 
83
+ Nodes
84
+ -----
85
+
86
+ * As of Twig 1.x, ``Node::toXml()`` is deprecated and will be removed in Twig
87
+ 2.0.
88
+
89
  Interfaces
90
  ----------
91
 
vendor/twig/twig/doc/filters/batch.rst CHANGED
@@ -2,7 +2,7 @@
2
  =========
3
 
4
  .. versionadded:: 1.12.3
5
- The batch filter was added in Twig 1.12.3.
6
 
7
  The ``batch`` filter "batches" items by returning a list of lists with the
8
  given number of items. If you provide a second parameter, it is used to fill
2
  =========
3
 
4
  .. versionadded:: 1.12.3
5
+ The ``batch`` filter was added in Twig 1.12.3.
6
 
7
  The ``batch`` filter "batches" items by returning a list of lists with the
8
  given number of items. If you provide a second parameter, it is used to fill
vendor/twig/twig/doc/filters/convert_encoding.rst CHANGED
@@ -21,8 +21,8 @@ is the input charset:
21
  Arguments
22
  ---------
23
 
24
- * ``from``: The input charset
25
  * ``to``: The output charset
 
26
 
27
  .. _`iconv`: http://php.net/iconv
28
  .. _`mbstring`: http://php.net/mbstring
21
  Arguments
22
  ---------
23
 
 
24
  * ``to``: The output charset
25
+ * ``from``: The input charset
26
 
27
  .. _`iconv`: http://php.net/iconv
28
  .. _`mbstring`: http://php.net/mbstring
vendor/twig/twig/doc/filters/first.rst CHANGED
@@ -2,7 +2,7 @@
2
  =========
3
 
4
  .. versionadded:: 1.12.2
5
- The first filter was added in Twig 1.12.2.
6
 
7
  The ``first`` filter returns the first "element" of a sequence, a mapping, or
8
  a string:
2
  =========
3
 
4
  .. versionadded:: 1.12.2
5
+ The ``first`` filter was added in Twig 1.12.2.
6
 
7
  The ``first`` filter returns the first "element" of a sequence, a mapping, or
8
  a string:
vendor/twig/twig/doc/filters/index.rst CHANGED
@@ -20,10 +20,9 @@ Filters
20
  last
21
  length
22
  lower
 
23
  nl2br
24
  number_format
25
- merge
26
- upper
27
  raw
28
  replace
29
  reverse
@@ -34,4 +33,5 @@ Filters
34
  striptags
35
  title
36
  trim
 
37
  url_encode
20
  last
21
  length
22
  lower
23
+ merge
24
  nl2br
25
  number_format
 
 
26
  raw
27
  replace
28
  reverse
33
  striptags
34
  title
35
  trim
36
+ upper
37
  url_encode
vendor/twig/twig/doc/filters/json_encode.rst CHANGED
@@ -1,7 +1,7 @@
1
  ``json_encode``
2
  ===============
3
 
4
- The ``json_encode`` filter returns the JSON representation of a string:
5
 
6
  .. code-block:: jinja
7
 
1
  ``json_encode``
2
  ===============
3
 
4
+ The ``json_encode`` filter returns the JSON representation of a value:
5
 
6
  .. code-block:: jinja
7
 
vendor/twig/twig/doc/filters/last.rst CHANGED
@@ -2,7 +2,7 @@
2
  ========
3
 
4
  .. versionadded:: 1.12.2
5
- The last filter was added in Twig 1.12.2.
6
 
7
  The ``last`` filter returns the last "element" of a sequence, a mapping, or
8
  a string:
2
  ========
3
 
4
  .. versionadded:: 1.12.2
5
+ The ``last`` filter was added in Twig 1.12.2.
6
 
7
  The ``last`` filter returns the last "element" of a sequence, a mapping, or
8
  a string:
vendor/twig/twig/doc/filters/length.rst CHANGED
@@ -1,7 +1,7 @@
1
  ``length``
2
  ==========
3
 
4
- The ``length`` filters returns the number of items of a sequence or mapping, or
5
  the length of a string:
6
 
7
  .. code-block:: jinja
1
  ``length``
2
  ==========
3
 
4
+ The ``length`` filter returns the number of items of a sequence or mapping, or
5
  the length of a string:
6
 
7
  .. code-block:: jinja
vendor/twig/twig/doc/filters/merge.rst CHANGED
@@ -39,3 +39,9 @@ overridden.
39
  {% set items = { 'apple': 'unknown' }|merge(items) %}
40
 
41
  {# items now contains { 'apple': 'fruit', 'orange': 'fruit' } #}
 
 
 
 
 
 
39
  {% set items = { 'apple': 'unknown' }|merge(items) %}
40
 
41
  {# items now contains { 'apple': 'fruit', 'orange': 'fruit' } #}
42
+
43
+ .. note::
44
+
45
+ Internally, Twig uses the PHP `array_merge`_ function.
46
+
47
+ .. _`array_merge`: http://php.net/array_merge
vendor/twig/twig/doc/filters/nl2br.rst CHANGED
@@ -2,7 +2,7 @@
2
  =========
3
 
4
  .. versionadded:: 1.5
5
- The nl2br filter was added in Twig 1.5.
6
 
7
  The ``nl2br`` filter inserts HTML line breaks before all newlines in a string:
8
 
2
  =========
3
 
4
  .. versionadded:: 1.5
5
+ The ``nl2br`` filter was added in Twig 1.5.
6
 
7
  The ``nl2br`` filter inserts HTML line breaks before all newlines in a string:
8
 
vendor/twig/twig/doc/filters/number_format.rst CHANGED
@@ -2,7 +2,7 @@
2
  =================
3
 
4
  .. versionadded:: 1.5
5
- The number_format filter was added in Twig 1.5
6
 
7
  The ``number_format`` filter formats numbers. It is a wrapper around PHP's
8
  `number_format`_ function:
2
  =================
3
 
4
  .. versionadded:: 1.5
5
+ The ``number_format`` filter was added in Twig 1.5
6
 
7
  The ``number_format`` filter formats numbers. It is a wrapper around PHP's
8
  `number_format`_ function:
vendor/twig/twig/doc/filters/raw.rst CHANGED
@@ -10,3 +10,27 @@ if ``raw`` is the last filter applied to it:
10
  {% autoescape %}
11
  {{ var|raw }} {# var won't be escaped #}
12
  {% endautoescape %}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  {% autoescape %}
11
  {{ var|raw }} {# var won't be escaped #}
12
  {% endautoescape %}
13
+
14
+ .. note::
15
+
16
+ Be careful when using the ``raw`` filter inside expressions:
17
+
18
+ .. code-block:: jinja
19
+
20
+ {% autoescape %}
21
+ {% set hello = '<strong>Hello</strong>' %}
22
+ {% set hola = '<strong>Hola</strong>' %}
23
+
24
+ {{ false ? '<strong>Hola</strong>' : hello|raw }}
25
+ does not render the same as
26
+ {{ false ? hola : hello|raw }}
27
+ but renders the same as
28
+ {{ (false ? hola : hello)|raw }}
29
+ {% endautoescape %}
30
+
31
+ The first ternary statement is not escaped: ``hello`` is marked as being
32
+ safe and Twig does not escape static values (see
33
+ :doc:`escape<../tags/autoescape>`). In the second ternary statement, even
34
+ if ``hello`` is marked as safe, ``hola`` remains unsafe and so is the whole
35
+ expression. The third ternary statement is marked as safe and the result is
36
+ not escaped.
vendor/twig/twig/doc/filters/slice.rst CHANGED
@@ -2,7 +2,7 @@
2
  ===========
3
 
4
  .. versionadded:: 1.6
5
- The slice filter was added in Twig 1.6.
6
 
7
  The ``slice`` filter extracts a slice of a sequence, a mapping, or a string:
8
 
@@ -32,7 +32,7 @@ As syntactic sugar, you can also use the ``[]`` notation:
32
  {# ... #}
33
  {% endfor %}
34
 
35
- {{ '12345'[1:2] }}
36
 
37
  {# you can omit the first argument -- which is the same as 0 #}
38
  {{ '12345'[:2] }} {# will display "12" #}
@@ -41,7 +41,7 @@ As syntactic sugar, you can also use the ``[]`` notation:
41
  {{ '12345'[2:] }} {# will display "345" #}
42
 
43
  The ``slice`` filter works as the `array_slice`_ PHP function for arrays and
44
- `substr`_ for strings.
45
 
46
  If the start is non-negative, the sequence will start at that start in the
47
  variable. If start is negative, the sequence will start that far from the end
@@ -67,4 +67,5 @@ Arguments
67
 
68
  .. _`Traversable`: http://php.net/manual/en/class.traversable.php
69
  .. _`array_slice`: http://php.net/array_slice
 
70
  .. _`substr`: http://php.net/substr
2
  ===========
3
 
4
  .. versionadded:: 1.6
5
+ The ``slice`` filter was added in Twig 1.6.
6
 
7
  The ``slice`` filter extracts a slice of a sequence, a mapping, or a string:
8
 
32
  {# ... #}
33
  {% endfor %}
34
 
35
+ {{ '12345'[1:2] }} {# will display "23" #}
36
 
37
  {# you can omit the first argument -- which is the same as 0 #}
38
  {{ '12345'[:2] }} {# will display "12" #}
41
  {{ '12345'[2:] }} {# will display "345" #}
42
 
43
  The ``slice`` filter works as the `array_slice`_ PHP function for arrays and
44
+ `mb_substr`_ for strings with a fallback to `substr`_.
45
 
46
  If the start is non-negative, the sequence will start at that start in the
47
  variable. If start is negative, the sequence will start that far from the end
67
 
68
  .. _`Traversable`: http://php.net/manual/en/class.traversable.php
69
  .. _`array_slice`: http://php.net/array_slice
70
+ .. _`mb_substr` : http://php.net/mb-substr
71
  .. _`substr`: http://php.net/substr
vendor/twig/twig/doc/filters/split.rst CHANGED
@@ -2,15 +2,15 @@
2
  =========
3
 
4
  .. versionadded:: 1.10.3
5
- The split filter was added in Twig 1.10.3.
6
 
7
  The ``split`` filter splits a string by the given delimiter and returns a list
8
  of strings:
9
 
10
  .. code-block:: jinja
11
 
12
- {{ "one,two,three"|split(',') }}
13
- {# returns ['one', 'two', 'three'] #}
14
 
15
  You can also pass a ``limit`` argument:
16
 
@@ -24,19 +24,19 @@ You can also pass a ``limit`` argument:
24
 
25
  .. code-block:: jinja
26
 
27
- {{ "one,two,three,four,five"|split(',', 3) }}
28
- {# returns ['one', 'two', 'three,four,five'] #}
29
 
30
  If the ``delimiter`` is an empty string, then value will be split by equal
31
  chunks. Length is set by the ``limit`` argument (one character by default).
32
 
33
  .. code-block:: jinja
34
 
35
- {{ "123"|split('') }}
36
- {# returns ['1', '2', '3'] #}
37
 
38
- {{ "aabbcc"|split('', 2) }}
39
- {# returns ['aa', 'bb', 'cc'] #}
40
 
41
  .. note::
42
 
2
  =========
3
 
4
  .. versionadded:: 1.10.3
5
+ The ``split`` filter was added in Twig 1.10.3.
6
 
7
  The ``split`` filter splits a string by the given delimiter and returns a list
8
  of strings:
9
 
10
  .. code-block:: jinja
11
 
12
+ {% set foo = "one,two,three"|split(',') %}
13
+ {# foo contains ['one', 'two', 'three'] #}
14
 
15
  You can also pass a ``limit`` argument:
16
 
24
 
25
  .. code-block:: jinja
26
 
27
+ {% set foo = "one,two,three,four,five"|split(',', 3) %}
28
+ {# foo contains ['one', 'two', 'three,four,five'] #}
29
 
30
  If the ``delimiter`` is an empty string, then value will be split by equal
31
  chunks. Length is set by the ``limit`` argument (one character by default).
32
 
33
  .. code-block:: jinja
34
 
35
+ {% set foo = "123"|split('') %}
36
+ {# foo contains ['1', '2', '3'] #}
37
 
38
+ {% set bar = "aabbcc"|split('', 2) %}
39
+ {# bar contains ['aa', 'bb', 'cc'] #}
40
 
41
  .. note::
42
 
vendor/twig/twig/doc/filters/trim.rst CHANGED
@@ -2,7 +2,7 @@
2
  ========
3
 
4
  .. versionadded:: 1.6.2
5
- The trim filter was added in Twig 1.6.2.
6
 
7
  The ``trim`` filter strips whitespace (or other characters) from the beginning
8
  and end of a string:
2
  ========
3
 
4
  .. versionadded:: 1.6.2
5
+ The ``trim`` filter was added in Twig 1.6.2.
6
 
7
  The ``trim`` filter strips whitespace (or other characters) from the beginning
8
  and end of a string:
vendor/twig/twig/doc/filters/url_encode.rst CHANGED
@@ -4,6 +4,10 @@
4
  .. versionadded:: 1.12.3
5
  Support for encoding an array as query string was added in Twig 1.12.3.
6
 
 
 
 
 
7
  The ``url_encode`` filter percent encodes a given string as URL segment
8
  or an array as query string:
9
 
@@ -12,7 +16,7 @@ or an array as query string:
12
  {{ "path-seg*ment"|url_encode }}
13
  {# outputs "path-seg%2Ament" #}
14
 
15
- {{ "string with spaces"|url_encode(true) }}
16
  {# outputs "string%20with%20spaces" #}
17
 
18
  {{ {'param': 'value', 'foo': 'bar'}|url_encode }}
@@ -21,7 +25,9 @@ or an array as query string:
21
  .. note::
22
 
23
  Internally, Twig uses the PHP `urlencode`_ (or `rawurlencode`_ if you pass
24
- ``true`` as the first parameter) or the `http_build_query`_ function.
 
 
25
 
26
  .. _`urlencode`: http://php.net/urlencode
27
  .. _`rawurlencode`: http://php.net/rawurlencode
4
  .. versionadded:: 1.12.3
5
  Support for encoding an array as query string was added in Twig 1.12.3.
6
 
7
+ .. versionadded:: 1.16.0
8
+ The ``raw`` argument was removed in Twig 1.16.0. Twig now always encodes
9
+ according to RFC 3986.
10
+
11
  The ``url_encode`` filter percent encodes a given string as URL segment
12
  or an array as query string:
13
 
16
  {{ "path-seg*ment"|url_encode }}
17
  {# outputs "path-seg%2Ament" #}
18
 
19
+ {{ "string with spaces"|url_encode }}
20
  {# outputs "string%20with%20spaces" #}
21
 
22
  {{ {'param': 'value', 'foo': 'bar'}|url_encode }}
25
  .. note::
26
 
27
  Internally, Twig uses the PHP `urlencode`_ (or `rawurlencode`_ if you pass
28
+ ``true`` as the first parameter) or the `http_build_query`_ function. Note
29
+ that as of Twig 1.16.0, ``urlencode`` **always** uses ``rawurlencode`` (the
30
+ ``raw`` argument was removed.)
31
 
32
  .. _`urlencode`: http://php.net/urlencode
33
  .. _`rawurlencode`: http://php.net/rawurlencode
vendor/twig/twig/doc/functions/date.rst CHANGED
@@ -15,7 +15,7 @@ Converts an argument to a date to allow date comparison:
15
  {# do something #}
16
  {% endif %}
17
 
18
- The argument must be in a format supported by the `date`_ function.
19
 
20
  You can pass a timezone as the second argument:
21
 
@@ -49,4 +49,4 @@ Arguments
49
  * ``date``: The date
50
  * ``timezone``: The timezone
51
 
52
- .. _`date`: http://www.php.net/date
15
  {# do something #}
16
  {% endif %}
17
 
18
+ The argument must be in one of PHP’s supported `date and time formats`_.
19
 
20
  You can pass a timezone as the second argument:
21
 
49
  * ``date``: The date
50
  * ``timezone``: The timezone
51
 
52
+ .. _`date and time formats`: http://php.net/manual/en/datetime.formats.php
vendor/twig/twig/doc/functions/dump.rst CHANGED
@@ -2,7 +2,7 @@
2
  ========
3
 
4
  .. versionadded:: 1.5
5
- The dump function was added in Twig 1.5.
6
 
7
  The ``dump`` function dumps information about a template variable. This is
8
  mostly useful to debug a template that does not behave as expected by
2
  ========
3
 
4
  .. versionadded:: 1.5
5
+ The ``dump`` function was added in Twig 1.5.
6
 
7
  The ``dump`` function dumps information about a template variable. This is
8
  mostly useful to debug a template that does not behave as expected by
vendor/twig/twig/doc/functions/include.rst CHANGED
@@ -2,7 +2,7 @@
2
  ===========
3
 
4
  .. versionadded:: 1.12
5
- The include function was added in Twig 1.12.
6
 
7
  The ``include`` function returns the rendered content of a template:
8
 
2
  ===========
3
 
4
  .. versionadded:: 1.12
5
+ The ``include`` function was added in Twig 1.12.
6
 
7
  The ``include`` function returns the rendered content of a template:
8
 
vendor/twig/twig/doc/functions/max.rst CHANGED
@@ -15,5 +15,6 @@ When called with a mapping, max ignores keys and only compares values:
15
 
16
  .. code-block:: jinja
17
 
18
- {{ max({2: "two", 1: "one", 3: "three", 5: "five", 4: "for"}) }}
19
- {# return "two" #}
 
15
 
16
  .. code-block:: jinja
17
 
18
+ {{ max({2: "e", 1: "a", 3: "b", 5: "d", 4: "c"}) }}
19
+ {# returns "e" #}
20
+
vendor/twig/twig/doc/functions/min.rst CHANGED
@@ -15,5 +15,6 @@ When called with a mapping, min ignores keys and only compares values:
15
 
16
  .. code-block:: jinja
17
 
18
- {{ min({2: "two", 1: "one", 3: "three", 5: "five", 4: "for"}) }}
19
- {# return "five" #}
 
15
 
16
  .. code-block:: jinja
17
 
18
+ {{ min({2: "e", 3: "a", 1: "b", 5: "d", 4: "c"}) }}
19
+ {# returns "a" #}
20
+
vendor/twig/twig/doc/functions/random.rst CHANGED
@@ -2,7 +2,7 @@
2
  ==========
3
 
4
  .. versionadded:: 1.5
5
- The random function was added in Twig 1.5.
6
 
7
  .. versionadded:: 1.6
8
  String and integer handling was added in Twig 1.6.
2
  ==========
3
 
4
  .. versionadded:: 1.5
5
+ The ``random`` function was added in Twig 1.5.
6
 
7
  .. versionadded:: 1.6
8
  String and integer handling was added in Twig 1.6.
vendor/twig/twig/doc/functions/source.rst CHANGED
@@ -2,7 +2,7 @@
2
  ==========
3
 
4
  .. versionadded:: 1.15
5
- The source function was added in Twig 1.15.
6
 
7
  The ``source`` function returns the content of a template without rendering it:
8
 
2
  ==========
3
 
4
  .. versionadded:: 1.15
5
+ The ``source`` function was added in Twig 1.15.
6
 
7
  The ``source`` function returns the content of a template without rendering it:
8
 
vendor/twig/twig/doc/functions/template_from_string.rst CHANGED
@@ -2,7 +2,7 @@
2
  ========================
3
 
4
  .. versionadded:: 1.11
5
- The template_from_string function was added in Twig 1.11.
6
 
7
  The ``template_from_string`` function loads a template from a string:
8
 
2
  ========================
3
 
4
  .. versionadded:: 1.11
5
+ The ``template_from_string`` function was added in Twig 1.11.
6
 
7
  The ``template_from_string`` function loads a template from a string:
8
 
vendor/twig/twig/doc/index.rst CHANGED
@@ -5,15 +5,15 @@ Twig
5
  :maxdepth: 2
6
 
7
  intro
 
8
  templates
9
  api
10
  advanced
11
  internals
 
12
  recipes
13
  coding_standards
14
  tags/index
15
  filters/index
16
  functions/index
17
  tests/index
18
- installation
19
- deprecated
5
  :maxdepth: 2
6
 
7
  intro
8
+ installation
9
  templates
10
  api
11
  advanced
12
  internals
13
+ deprecated
14
  recipes
15
  coding_standards
16
  tags/index
17
  filters/index
18
  functions/index
19
  tests/index
 
 
vendor/twig/twig/doc/installation.rst CHANGED
@@ -9,51 +9,39 @@ Installing the Twig PHP package
9
  Installing via Composer (recommended)
10
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
11
 
12
- 1. Install Composer in your project:
13
 
14
  .. code-block:: bash
15
 
16
- curl -s http://getcomposer.org/installer | php
17
-
18
- 2. Create a ``composer.json`` file in your project root:
19
-
20
- .. code-block:: javascript
21
-
22
- {
23
- "require": {
24
- "twig/twig": "1.*"
25
- }
26
- }
27
-
28
- 3. Install via Composer
29
-
30
- .. code-block:: bash
31
-
32
- php composer.phar install
33
-
34
- .. note::
35
- If you want to learn more about Composer, the ``composer.json`` file syntax
36
- and its usage, you can read the `online documentation`_.
37
 
38
  Installing from the tarball release
39
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
40
 
41
  1. Download the most recent tarball from the `download page`_
42
- 2. Unpack the tarball
43
- 3. Move the files somewhere in your project
 
44
 
45
  Installing the development version
46
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
47
 
48
- 1. Install Git
49
- 2. ``git clone git://github.com/fabpot/Twig.git``
 
50
 
51
  Installing the PEAR package
52
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~
53
 
54
- 1. Install PEAR
55
- 2. ``pear channel-discover pear.twig-project.org``
56
- 3. ``pear install twig/Twig`` (or ``pear install twig/Twig-beta``)
 
 
 
 
 
 
57
 
58
  Installing the C extension
59
  --------------------------
@@ -61,24 +49,31 @@ Installing the C extension
61
  .. versionadded:: 1.4
62
  The C extension was added in Twig 1.4.
63
 
 
 
 
 
64
  Twig comes with a C extension that enhances the performance of the Twig
65
- runtime engine.
66
 
67
- You can install it via PEAR:
68
 
69
- 1. Install PEAR
70
- 2. ``pear channel-discover pear.twig-project.org``
71
- 3. ``pear install twig/CTwig`` (or ``pear install twig/CTwig-beta``)
 
 
72
 
73
- Or manually like any other PHP extension:
74
 
75
- .. code-block:: bash
 
 
 
 
76
 
77
- $ cd ext/twig
78
- $ phpize
79
- $ ./configure
80
- $ make
81
- $ make install
82
 
83
  For Windows:
84
 
@@ -90,15 +85,15 @@ For Windows:
90
 
91
  .. tip::
92
 
93
- For Windows ZendServer, TS is not enabled as mentionned in `Zend Server
94
  FAQ`_.
95
 
96
- You have to use `configure --disable-all --disable-zts --enable-cli
97
- --enable-twig=shared` to be able to build the twig C extension for
98
  ZendServer.
99
 
100
  The built DLL will be available in
101
- C:\\php-sdk\\phpdev\\vcXX\\x86\\php-source-directory\\Release
102
 
103
  Finally, enable the extension in your ``php.ini`` configuration file:
104
 
@@ -112,7 +107,7 @@ advantage of the C extension. Note that this extension does not replace the
112
  PHP code but only provides an optimized version of the
113
  ``Twig_Template::getAttribute()`` method.
114
 
115
- .. _`download page`: https://github.com/fabpot/Twig/tags
116
- .. _`online documentation`: http://getcomposer.org/doc
117
  .. _`PHP documentation`: https://wiki.php.net/internals/windows/stepbystepbuild
118
- .. _`Zend Server FAQ`: http://www.zend.com/en/products/server/faq#faqD6
9
  Installing via Composer (recommended)
10
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
11
 
12
+ Install `Composer`_ and run the following command to get the latest version:
13
 
14
  .. code-block:: bash
15
 
16
+ composer require twig/twig:~1.0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
 
18
  Installing from the tarball release
19
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20
 
21
  1. Download the most recent tarball from the `download page`_
22
+ 2. Verify the integrity of the tarball http://fabien.potencier.org/article/73/signing-project-releases
23
+ 3. Unpack the tarball
24
+ 4. Move the files somewhere in your project
25
 
26
  Installing the development version
27
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
28
 
29
+ .. code-block:: bash
30
+
31
+ git clone git://github.com/twigphp/Twig.git
32
 
33
  Installing the PEAR package
34
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~
35
 
36
+ .. note::
37
+
38
+ Using PEAR for installing Twig is deprecated and Twig 1.15.1 was the last
39
+ version published on the PEAR channel; use Composer instead.
40
+
41
+ .. code-block:: bash
42
+
43
+ pear channel-discover pear.twig-project.org
44
+ pear install twig/Twig
45
 
46
  Installing the C extension
47
  --------------------------
49
  .. versionadded:: 1.4
50
  The C extension was added in Twig 1.4.
51
 
52
+ .. note::
53
+ The C extension is **optional** but as it brings some nice performance
54
+ improvements, you might want to install it in your production environment.
55
+
56
  Twig comes with a C extension that enhances the performance of the Twig
57
+ runtime engine; install it like any other PHP extensions:
58
 
59
+ .. code-block:: bash
60
 
61
+ cd ext/twig
62
+ phpize
63
+ ./configure
64
+ make
65
+ make install
66
 
67
+ .. note::
68
 
69
+ You can also install the C extension via PEAR (note that this method is
70
+ deprecated and newer versions of Twig are not available on the PEAR
71
+ channel):
72
+
73
+ .. code-block:: bash
74
 
75
+ pear channel-discover pear.twig-project.org
76
+ pear install twig/CTwig
 
 
 
77
 
78
  For Windows:
79
 
85
 
86
  .. tip::
87
 
88
+ For Windows ZendServer, ZTS is not enabled as mentioned in `Zend Server
89
  FAQ`_.
90
 
91
+ You have to use ``configure --disable-all --disable-zts --enable-cli
92
+ --enable-twig=shared`` to be able to build the twig C extension for
93
  ZendServer.
94
 
95
  The built DLL will be available in
96
+ ``C:\\php-sdk\\phpdev\\vcXX\\x86\\php-source-directory\\Release``
97
 
98
  Finally, enable the extension in your ``php.ini`` configuration file:
99
 
107
  PHP code but only provides an optimized version of the
108
  ``Twig_Template::getAttribute()`` method.
109
 
110
+ .. _`download page`: https://github.com/twigphp/Twig/tags
111
+ .. _`Composer`: https://getcomposer.org/download/
112
  .. _`PHP documentation`: https://wiki.php.net/internals/windows/stepbystepbuild
113
+ .. _`Zend Server FAQ`: http://www.zend.com/en/products/server/faq#faqD6
vendor/twig/twig/doc/internals.rst CHANGED
@@ -124,7 +124,7 @@ using)::
124
  {
125
  // line 1
126
  echo "Hello ";
127
- echo twig_escape_filter($this->env, $this->getContext($context, "name"), "ndex", null, true);
128
  }
129
 
130
  // some more code
124
  {
125
  // line 1
126
  echo "Hello ";
127
+ echo twig_escape_filter($this->env, $this->getContext($context, "name"), "html", null, true);
128
  }
129
 
130
  // some more code
vendor/twig/twig/doc/intro.rst CHANGED
@@ -33,7 +33,7 @@ The recommended way to install Twig is via Composer:
33
 
34
  .. code-block:: bash
35
 
36
- composer require twig/twig:1.*
37
 
38
  .. note::
39
 
@@ -50,12 +50,14 @@ This section gives you a brief introduction to the PHP API for Twig.
50
 
51
  require_once '/path/to/vendor/autoload.php';
52
 
53
- $loader = new Twig_Loader_String();
 
 
54
  $twig = new Twig_Environment($loader);
55
 
56
- echo $twig->render('Hello {{ name }}!', array('name' => 'Fabien'));
57
 
58
- Twig uses a loader (``Twig_Loader_String``) to locate templates, and an
59
  environment (``Twig_Environment``) to store the configuration.
60
 
61
  The ``render()`` method loads the template passed as a first argument and
33
 
34
  .. code-block:: bash
35
 
36
+ composer require "twig/twig:~1.0"
37
 
38
  .. note::
39
 
50
 
51
  require_once '/path/to/vendor/autoload.php';
52
 
53
+ $loader = new Twig_Loader_Array(array(
54
+ 'index' => 'Hello {{ name }}!',
55
+ ));
56
  $twig = new Twig_Environment($loader);
57
 
58
+ echo $twig->render('index', array('name' => 'Fabien'));
59
 
60
+ Twig uses a loader (``Twig_Loader_Array``) to locate templates, and an
61
  environment (``Twig_Environment``) to store the configuration.
62
 
63
  The ``render()`` method loads the template passed as a first argument and
vendor/twig/twig/doc/recipes.rst CHANGED
@@ -242,7 +242,7 @@ does not return ``false``.
242
  Validating the Template Syntax
243
  ------------------------------
244
 
245
- When template code is providing by a third-party (through a web interface for
246
  instance), it might be interesting to validate the template syntax before
247
  saving it. If the template code is stored in a `$template` variable, here is
248
  how you can do it::
242
  Validating the Template Syntax
243
  ------------------------------
244
 
245
+ When template code is provided by a third-party (through a web interface for
246
  instance), it might be interesting to validate the template syntax before
247
  saving it. If the template code is stored in a `$template` variable, here is
248
  how you can do it::
vendor/twig/twig/doc/tags/autoescape.rst CHANGED
@@ -65,6 +65,18 @@ Functions returning template data (like :doc:`macros<macro>` and
65
  Twig is smart enough to not escape an already escaped value by the
66
  :doc:`escape<../filters/escape>` filter.
67
 
 
 
 
 
 
 
 
 
 
 
 
 
68
  .. note::
69
 
70
  The chapter :doc:`Twig for Developers<../api>` gives more information
65
  Twig is smart enough to not escape an already escaped value by the
66
  :doc:`escape<../filters/escape>` filter.
67
 
68
+ .. note::
69
+
70
+ Twig does not escape static expressions:
71
+
72
+ .. code-block:: jinja
73
+
74
+ {% set hello = "<strong>Hello</strong>" %}
75
+ {{ hello }}
76
+ {{ "<strong>world</strong>" }}
77
+
78
+ Will be rendered "<strong>Hello</strong> **world**".
79
+
80
  .. note::
81
 
82
  The chapter :doc:`Twig for Developers<../api>` gives more information
vendor/twig/twig/doc/tags/do.rst CHANGED
@@ -2,7 +2,7 @@
2
  ======
3
 
4
  .. versionadded:: 1.5
5
- The do tag was added in Twig 1.5.
6
 
7
  The ``do`` tag works exactly like the regular variable expression (``{{ ...
8
  }}``) just that it doesn't print anything:
2
  ======
3
 
4
  .. versionadded:: 1.5
5
+ The ``do`` tag was added in Twig 1.5.
6
 
7
  The ``do`` tag works exactly like the regular variable expression (``{{ ...
8
  }}``) just that it doesn't print anything:
vendor/twig/twig/doc/tags/extends.rst CHANGED
@@ -186,8 +186,8 @@ In this example, the template will extend the "minimum.html" layout template
186
  if the ``standalone`` variable evaluates to ``true``, and "base.html"
187
  otherwise.
188
 
189
- How blocks work?
190
- ----------------
191
 
192
  A block provides a way to change how a certain part of a template is rendered
193
  but it does not interfere in any way with the logic around it.
186
  if the ``standalone`` variable evaluates to ``true``, and "base.html"
187
  otherwise.
188
 
189
+ How do blocks work?
190
+ -------------------
191
 
192
  A block provides a way to change how a certain part of a template is rendered
193
  but it does not interfere in any way with the logic around it.
vendor/twig/twig/doc/tags/if.rst CHANGED
@@ -29,6 +29,14 @@ You can also test if an array is not empty:
29
  If you want to test if the variable is defined, use ``if users is
30
  defined`` instead.
31
 
 
 
 
 
 
 
 
 
32
  For multiple branches ``elseif`` and ``else`` can be used like in PHP. You can use
33
  more complex ``expressions`` there too:
34
 
@@ -41,3 +49,20 @@ more complex ``expressions`` there too:
41
  {% else %}
42
  Kenny looks okay --- so far
43
  {% endif %}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
  If you want to test if the variable is defined, use ``if users is
30
  defined`` instead.
31
 
32
+ You can also use ``not`` to check for values that evaluate to ``false``:
33
+
34
+ .. code-block:: jinja
35
+
36
+ {% if not user.subscribed %}
37
+ <p>You are not subscribed to our mailing list.</p>
38
+ {% endif %}
39
+
40
  For multiple branches ``elseif`` and ``else`` can be used like in PHP. You can use
41
  more complex ``expressions`` there too:
42
 
49
  {% else %}
50
  Kenny looks okay --- so far
51
  {% endif %}
52
+
53
+ .. note::
54
+
55
+ The rules to determine if an expression is ``true`` or ``false`` are the
56
+ same as in PHP; here are the edge cases rules:
57
+
58
+ ====================== ====================
59
+ Value Boolean evaluation
60
+ ====================== ====================
61
+ empty string false
62
+ numeric zero false
63
+ whitespace-only string true
64
+ empty array false
65
+ null false
66
+ non-empty array true
67
+ object true
68
+ ====================== ====================
vendor/twig/twig/doc/tags/index.rst CHANGED
@@ -6,10 +6,10 @@ Tags
6
 
7
  autoescape
8
  block
9
- filter
10
  do
11
  embed
12
  extends
 
13
  flush
14
  for
15
  from
6
 
7
  autoescape
8
  block
 
9
  do
10
  embed
11
  extends
12
+ filter
13
  flush
14
  for
15
  from
vendor/twig/twig/doc/tags/use.rst CHANGED
@@ -39,7 +39,8 @@ The ``use`` statement tells Twig to import the blocks defined in
39
 
40
  .. code-block:: jinja
41
 
42
- # blocks.html
 
43
  {% block sidebar %}{% endblock %}
44
 
45
  In this example, the ``use`` statement imports the ``sidebar`` block into the
39
 
40
  .. code-block:: jinja
41
 
42
+ {# blocks.html #}
43
+
44
  {% block sidebar %}{% endblock %}
45
 
46
  In this example, the ``use`` statement imports the ``sidebar`` block into the
vendor/twig/twig/doc/templates.rst CHANGED
@@ -15,7 +15,7 @@ A template contains **variables** or **expressions**, which get replaced with
15
  values when the template is evaluated, and **tags**, which control the logic
16
  of the template.
17
 
18
- Below is a minimal template that illustrates a few basics. We will cover the
19
  details later on:
20
 
21
  .. code-block:: html+jinja
@@ -58,14 +58,15 @@ Many IDEs support syntax highlighting and auto-completion for Twig:
58
  * *Komodo* and *Komodo Edit* via the Twig highlight/syntax check mode
59
  * *Notepad++* via the `Notepad++ Twig Highlighter`_
60
  * *Emacs* via `web-mode.el`_
 
61
 
62
  Variables
63
  ---------
64
 
65
- The application passes variables to the templates you can mess around in the
66
- template. Variables may have attributes or elements on them you can access
67
- too. How a variable looks like heavily depends on the application providing
68
- those.
69
 
70
  You can use a dot (``.``) to access attributes of a variable (methods or
71
  properties of a PHP object, or items of a PHP array), or the so-called
@@ -88,16 +89,16 @@ access the variable attribute:
88
  .. note::
89
 
90
  It's important to know that the curly braces are *not* part of the
91
- variable but the print statement. If you access variables inside tags
92
- don't put the braces around.
93
 
94
- If a variable or attribute does not exist, you will get back a ``null`` value
95
- when the ``strict_variables`` option is set to ``false``, otherwise Twig will
96
- throw an error (see :ref:`environment options<environment_options>`).
97
 
98
  .. sidebar:: Implementation
99
 
100
- For convenience sake ``foo.bar`` does the following things on the PHP
101
  layer:
102
 
103
  * check if ``foo`` is an array and ``bar`` a valid element;
@@ -115,7 +116,7 @@ throw an error (see :ref:`environment options<environment_options>`).
115
 
116
  .. note::
117
 
118
- If you want to get a dynamic attribute on a variable, use the
119
  :doc:`attribute<functions/attribute>` function instead.
120
 
121
  Global Variables
@@ -161,7 +162,7 @@ example will join a list by commas:
161
 
162
  {{ list|join(', ') }}
163
 
164
- To apply a filter on a section of code, wrap it with the
165
  :doc:`filter<tags/filter>` tag:
166
 
167
  .. code-block:: jinja
@@ -170,7 +171,7 @@ To apply a filter on a section of code, wrap it with the
170
  This text becomes uppercase
171
  {% endfilter %}
172
 
173
- Go to the :doc:`filters<filters/index>` page to learn more about the built-in
174
  filters.
175
 
176
  Functions
@@ -222,7 +223,7 @@ to change the default value:
222
  {# the first argument is the date format, which defaults to the global date format if null is passed #}
223
  {{ "now"|date(null, "Europe/Paris") }}
224
 
225
- {# or skip the format value by using a named argument for the timezone #}
226
  {{ "now"|date(timezone="Europe/Paris") }}
227
 
228
  You can also use both positional and named arguments in one call, in which
@@ -327,7 +328,7 @@ allows you to build a base "skeleton" template that contains all the common
327
  elements of your site and defines **blocks** that child templates can
328
  override.
329
 
330
- Sounds complicated but is very basic. It's easier to understand it by
331
  starting with an example.
332
 
333
  Let's define a base template, ``base.html``, which defines a simple HTML
@@ -692,7 +693,7 @@ string:
692
 
693
  .. code-block:: jinja
694
 
695
- {% if phone matches '{^[\d\.]+$}' %}
696
  {% endif %}
697
 
698
  Containment Operator
@@ -865,9 +866,10 @@ Extension<creating_extensions>` chapter.
865
  .. _`Twig syntax plugin`: http://plugins.netbeans.org/plugin/37069/php-twig
866
  .. _`Twig plugin`: https://github.com/pulse00/Twig-Eclipse-Plugin
867
  .. _`Twig language definition`: https://github.com/gabrielcorpse/gedit-twig-template-language
868
- .. _`extension repository`: http://github.com/fabpot/Twig-extensions
869
  .. _`Twig syntax mode`: https://github.com/bobthecow/Twig-HTML.mode
870
  .. _`other Twig syntax mode`: https://github.com/muxx/Twig-HTML.mode
871
  .. _`Notepad++ Twig Highlighter`: https://github.com/Banane9/notepadplusplus-twig
872
  .. _`web-mode.el`: http://web-mode.org/
873
  .. _`regular expressions`: http://php.net/manual/en/pcre.pattern.php
 
15
  values when the template is evaluated, and **tags**, which control the logic
16
  of the template.
17
 
18
+ Below is a minimal template that illustrates a few basics. We will cover further
19
  details later on:
20
 
21
  .. code-block:: html+jinja
58
  * *Komodo* and *Komodo Edit* via the Twig highlight/syntax check mode
59
  * *Notepad++* via the `Notepad++ Twig Highlighter`_
60
  * *Emacs* via `web-mode.el`_
61
+ * *Atom* via the `PHP-twig for atom`_
62
 
63
  Variables
64
  ---------
65
 
66
+ The application passes variables to the templates for manipulation in the
67
+ template. Variables may have attributes or elements you can access,
68
+ too. The visual representation of a variable depends heavily on the application providing
69
+ it.
70
 
71
  You can use a dot (``.``) to access attributes of a variable (methods or
72
  properties of a PHP object, or items of a PHP array), or the so-called
89
  .. note::
90
 
91
  It's important to know that the curly braces are *not* part of the
92
+ variable but the print statement. When accessing variables inside tags,
93
+ don't put the braces around them.
94
 
95
+ If a variable or attribute does not exist, you will receive a ``null`` value
96
+ when the ``strict_variables`` option is set to ``false``; alternatively, if ``strict_variables``
97
+ is set, Twig will throw an error (see :ref:`environment options<environment_options>`).
98
 
99
  .. sidebar:: Implementation
100
 
101
+ For convenience's sake ``foo.bar`` does the following things on the PHP
102
  layer:
103
 
104
  * check if ``foo`` is an array and ``bar`` a valid element;
116
 
117
  .. note::
118
 
119
+ If you want to access a dynamic attribute of a variable, use the
120
  :doc:`attribute<functions/attribute>` function instead.
121
 
122
  Global Variables
162
 
163
  {{ list|join(', ') }}
164
 
165
+ To apply a filter on a section of code, wrap it in the
166
  :doc:`filter<tags/filter>` tag:
167
 
168
  .. code-block:: jinja
171
  This text becomes uppercase
172
  {% endfilter %}
173
 
174
+ Go to the :doc:`filters<filters/index>` page to learn more about built-in
175
  filters.
176
 
177
  Functions
223
  {# the first argument is the date format, which defaults to the global date format if null is passed #}
224
  {{ "now"|date(null, "Europe/Paris") }}
225
 
226
+ {# or skip the format value by using a named argument for the time zone #}
227
  {{ "now"|date(timezone="Europe/Paris") }}
228
 
229
  You can also use both positional and named arguments in one call, in which
328
  elements of your site and defines **blocks** that child templates can
329
  override.
330
 
331
+ Sounds complicated but it is very basic. It's easier to understand it by
332
  starting with an example.
333
 
334
  Let's define a base template, ``base.html``, which defines a simple HTML
693
 
694
  .. code-block:: jinja
695
 
696
+ {% if phone matches '/^[\\d\\.]+$/' %}
697
  {% endif %}
698
 
699
  Containment Operator
866
  .. _`Twig syntax plugin`: http://plugins.netbeans.org/plugin/37069/php-twig
867
  .. _`Twig plugin`: https://github.com/pulse00/Twig-Eclipse-Plugin
868
  .. _`Twig language definition`: https://github.com/gabrielcorpse/gedit-twig-template-language
869
+ .. _`extension repository`: http://github.com/twigphp/Twig-extensions
870
  .. _`Twig syntax mode`: https://github.com/bobthecow/Twig-HTML.mode
871
  .. _`other Twig syntax mode`: https://github.com/muxx/Twig-HTML.mode
872
  .. _`Notepad++ Twig Highlighter`: https://github.com/Banane9/notepadplusplus-twig
873
  .. _`web-mode.el`: http://web-mode.org/
874
  .. _`regular expressions`: http://php.net/manual/en/pcre.pattern.php
875
+ .. _`PHP-twig for atom`: https://github.com/reesef/php-twig
vendor/twig/twig/doc/tests/sameas.rst CHANGED
@@ -4,8 +4,8 @@
4
  .. versionadded:: 1.14.2
5
  The ``same as`` test was added in Twig 1.14.2 as an alias for ``sameas``.
6
 
7
- ``same as`` checks if a variable points to the same memory address than
8
- another variable:
9
 
10
  .. code-block:: jinja
11
 
4
  .. versionadded:: 1.14.2
5
  The ``same as`` test was added in Twig 1.14.2 as an alias for ``sameas``.
6
 
7
+ ``same as`` checks if a variable is the same as another variable.
8
+ This is the equivalent to ``===`` in PHP:
9
 
10
  .. code-block:: jinja
11
 
vendor/twig/twig/ext/twig/LICENSE DELETED
@@ -1,31 +0,0 @@
1
- Copyright (c) 2009-2013 by the Twig Team, see AUTHORS for more details.
2
-
3
- Some rights reserved.
4
-
5
- Redistribution and use in source and binary forms, with or without
6
- modification, are permitted provided that the following conditions are
7
- met:
8
-
9
- * Redistributions of source code must retain the above copyright
10
- notice, this list of conditions and the following disclaimer.
11
-
12
- * Redistributions in binary form must reproduce the above
13
- copyright notice, this list of conditions and the following
14
- disclaimer in the documentation and/or other materials provided
15
- with the distribution.
16
-
17
- * The names of the contributors may not be used to endorse or
18
- promote products derived from this software without specific
19
- prior written permission.
20
-
21
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22
- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25
- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27
- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.15.1"
19
 
20
  #include "php.h"
21
 
15
  #ifndef PHP_TWIG_H
16
  #define PHP_TWIG_H
17
 
18
+ #define PHP_TWIG_VERSION "1.16.3"
19
 
20
  #include "php.h"
21
 
vendor/twig/twig/ext/twig/twig.c CHANGED
@@ -830,7 +830,11 @@ PHP_FUNCTION(twig_template_get_attributes)
830
  } elseif (is_object($object)) {
831
  $message = sprintf('Impossible to access a key "%s" on an object of class "%s" that does not implement ArrayAccess interface', $item, get_class($object));
832
  } elseif (is_array($object)) {
833
- $message = sprintf('Key "%s" for array with keys "%s" does not exist', $arrayItem, implode(', ', array_keys($object)));
 
 
 
 
834
  } elseif (Twig_Template::ARRAY_CALL === $type) {
835
  $message = sprintf('Impossible to access a key ("%s") on a %s variable ("%s")', $item, gettype($object), $object);
836
  } else {
@@ -845,7 +849,11 @@ PHP_FUNCTION(twig_template_get_attributes)
845
  } else if (Z_TYPE_P(object) == IS_OBJECT) {
846
  TWIG_RUNTIME_ERROR(template TSRMLS_CC, "Impossible to access a key \"%s\" on an object of class \"%s\" that does not implement ArrayAccess interface", item, TWIG_GET_CLASS_NAME(object TSRMLS_CC));
847
  } else if (Z_TYPE_P(object) == IS_ARRAY) {
848
- TWIG_RUNTIME_ERROR(template TSRMLS_CC, "Key \"%s\" for array with keys \"%s\" does not exist", item, TWIG_IMPLODE_ARRAY_KEYS(", ", object TSRMLS_CC));
 
 
 
 
849
  } else {
850
  char *type_name = zend_zval_type_name(object);
851
  Z_ADDREF_P(object);
830
  } elseif (is_object($object)) {
831
  $message = sprintf('Impossible to access a key "%s" on an object of class "%s" that does not implement ArrayAccess interface', $item, get_class($object));
832
  } elseif (is_array($object)) {
833
+ if (empty($object)) {
834
+ $message = sprintf('Key "%s" does not exist as the array is empty', $arrayItem);
835
+ } else {
836
+ $message = sprintf('Key "%s" for array with keys "%s" does not exist', $arrayItem, implode(', ', array_keys($object)));
837
+ }
838
  } elseif (Twig_Template::ARRAY_CALL === $type) {
839
  $message = sprintf('Impossible to access a key ("%s") on a %s variable ("%s")', $item, gettype($object), $object);
840
  } else {
849
  } else if (Z_TYPE_P(object) == IS_OBJECT) {
850
  TWIG_RUNTIME_ERROR(template TSRMLS_CC, "Impossible to access a key \"%s\" on an object of class \"%s\" that does not implement ArrayAccess interface", item, TWIG_GET_CLASS_NAME(object TSRMLS_CC));
851
  } else if (Z_TYPE_P(object) == IS_ARRAY) {
852
+ if (0 == zend_hash_num_elements(Z_ARRVAL_P(object))) {
853
+ TWIG_RUNTIME_ERROR(template TSRMLS_CC, "Key \"%s\" does not exist as the array is empty", item);
854
+ } else {
855
+ TWIG_RUNTIME_ERROR(template TSRMLS_CC, "Key \"%s\" for array with keys \"%s\" does not exist", item, TWIG_IMPLODE_ARRAY_KEYS(", ", object TSRMLS_CC));
856
+ }
857
  } else {
858
  char *type_name = zend_zval_type_name(object);
859
  Z_ADDREF_P(object);
vendor/twig/twig/lib/Twig/Autoloader.php CHANGED
@@ -19,7 +19,7 @@ class Twig_Autoloader
19
  /**
20
  * Registers Twig_Autoloader as an SPL autoloader.
21
  *
22
- * @param Boolean $prepend Whether to prepend the autoloader or not.
23
  */
24
  public static function register($prepend = false)
25
  {
19
  /**
20
  * Registers Twig_Autoloader as an SPL autoloader.
21
  *
22
+ * @param bool $prepend Whether to prepend the autoloader or not.
23
  */
24
  public static function register($prepend = false)
25
  {
vendor/twig/twig/lib/Twig/Compiler.php CHANGED
@@ -66,7 +66,7 @@ class Twig_Compiler implements Twig_CompilerInterface
66
  * Compiles a node.
67
  *
68
  * @param Twig_NodeInterface $node The node to compile
69
- * @param integer $indentation The current indentation
70
  *
71
  * @return Twig_Compiler The current compiler instance
72
  */
@@ -74,6 +74,7 @@ class Twig_Compiler implements Twig_CompilerInterface
74
  {
75
  $this->lastLine = null;
76
  $this->source = '';
 
77
  $this->sourceOffset = 0;
78
  // source code starts at 1 (as we then increment it when we encounter new lines)
79
  $this->sourceLine = 1;
@@ -181,14 +182,14 @@ class Twig_Compiler implements Twig_CompilerInterface
181
  } elseif (is_array($value)) {
182
  $this->raw('array(');
183
  $first = true;
184
- foreach ($value as $key => $value) {
185
  if (!$first) {
186
  $this->raw(', ');
187
  }
188
  $first = false;
189
  $this->repr($key);
190
  $this->raw(' => ');
191
- $this->repr($value);
192
  }
193
  $this->raw(')');
194
  } else {
@@ -236,7 +237,7 @@ class Twig_Compiler implements Twig_CompilerInterface
236
  /**
237
  * Indents the generated code.
238
  *
239
- * @param integer $step The number of indentation to add
240
  *
241
  * @return Twig_Compiler The current compiler instance
242
  */
@@ -250,7 +251,7 @@ class Twig_Compiler implements Twig_CompilerInterface
250
  /**
251
  * Outdents the generated code.
252
  *
253
- * @param integer $step The number of indentation to remove
254
  *
255
  * @return Twig_Compiler The current compiler instance
256
  *
@@ -267,4 +268,9 @@ class Twig_Compiler implements Twig_CompilerInterface
267
 
268
  return $this;
269
  }
 
 
 
 
 
270
  }
66
  * Compiles a node.
67
  *
68
  * @param Twig_NodeInterface $node The node to compile
69
+ * @param int $indentation The current indentation
70
  *
71
  * @return Twig_Compiler The current compiler instance
72
  */
74
  {
75
  $this->lastLine = null;
76
  $this->source = '';
77
+ $this->debugInfo = array();
78
  $this->sourceOffset = 0;
79
  // source code starts at 1 (as we then increment it when we encounter new lines)
80
  $this->sourceLine = 1;
182
  } elseif (is_array($value)) {
183
  $this->raw('array(');
184
  $first = true;
185
+ foreach ($value as $key => $v) {
186
  if (!$first) {
187
  $this->raw(', ');
188
  }
189
  $first = false;
190
  $this->repr($key);
191
  $this->raw(' => ');
192
+ $this->repr($v);
193
  }
194
  $this->raw(')');
195
  } else {
237
  /**
238
  * Indents the generated code.
239
  *
240
+ * @param int $step The number of indentation to add
241
  *
242
  * @return Twig_Compiler The current compiler instance
243
  */
251
  /**
252
  * Outdents the generated code.
253
  *
254
+ * @param int $step The number of indentation to remove
255
  *
256
  * @return Twig_Compiler The current compiler instance
257
  *
268
 
269
  return $this;
270
  }
271
+
272
+ public function getVarName()
273
+ {
274
+ return sprintf('__internal_%s', hash('sha256', uniqid(mt_rand(), true), false));
275
+ }
276
  }
vendor/twig/twig/lib/Twig/CompilerInterface.php CHANGED
@@ -13,7 +13,8 @@
13
  * Interface implemented by compiler classes.
14
  *
15
  * @author Fabien Potencier <fabien@symfony.com>
16
- * @deprecated since 1.12 (to be removed in 2.0)
 
17
  */
18
  interface Twig_CompilerInterface
19
  {
13
  * Interface implemented by compiler classes.
14
  *
15
  * @author Fabien Potencier <fabien@symfony.com>
16
+ *
17
+ * @deprecated since 1.12 (to be removed in 3.0)
18
  */
19
  interface Twig_CompilerInterface
20
  {
vendor/twig/twig/lib/Twig/Environment.php CHANGED
@@ -16,7 +16,7 @@
16
  */
17
  class Twig_Environment
18
  {
19
- const VERSION = '1.15.1';
20
 
21
  protected $charset;
22
  protected $loader;
@@ -154,7 +154,7 @@ class Twig_Environment
154
  /**
155
  * Checks if debug mode is enabled.
156
  *
157
- * @return Boolean true if debug mode is enabled, false otherwise
158
  */
159
  public function isDebug()
160
  {
@@ -180,7 +180,7 @@ class Twig_Environment
180
  /**
181
  * Checks if the auto_reload option is enabled.
182
  *
183
- * @return Boolean true if auto_reload is enabled, false otherwise
184
  */
185
  public function isAutoReload()
186
  {
@@ -206,7 +206,7 @@ class Twig_Environment
206
  /**
207
  * Checks if the strict_variables option is enabled.
208
  *
209
- * @return Boolean true if strict_variables is enabled, false otherwise
210
  */
211
  public function isStrictVariables()
212
  {
@@ -256,7 +256,7 @@ class Twig_Environment
256
  * Gets the template class associated with the given string.
257
  *
258
  * @param string $name The name for which to calculate the template class name
259
- * @param integer $index The index if it is an embedded template
260
  *
261
  * @return string The template class name
262
  */
@@ -311,7 +311,7 @@ class Twig_Environment
311
  * Loads a template by name.
312
  *
313
  * @param string $name The template name
314
- * @param integer $index The index if it is an embedded template
315
  *
316
  * @return Twig_TemplateInterface A template instance representing the given template name
317
  *
@@ -353,9 +353,9 @@ class Twig_Environment
353
  * not changed.
354
  *
355
  * @param string $name The template name
356
- * @param timestamp $time The last modification time of the cached template
357
  *
358
- * @return Boolean true if the template is fresh, false otherwise
359
  */
360
  public function isTemplateFresh($name, $time)
361
  {
@@ -626,7 +626,7 @@ class Twig_Environment
626
  *
627
  * @param string $name The extension name
628
  *
629
- * @return Boolean Whether the extension is registered or not
630
  */
631
  public function hasExtension($name)
632
  {
@@ -1232,8 +1232,11 @@ class Twig_Environment
1232
  {
1233
  $dir = dirname($file);
1234
  if (!is_dir($dir)) {
1235
- if (false === @mkdir($dir, 0777, true) && !is_dir($dir)) {
1236
- throw new RuntimeException(sprintf("Unable to create the cache directory (%s).", $dir));
 
 
 
1237
  }
1238
  } elseif (!is_writable($dir)) {
1239
  throw new RuntimeException(sprintf("Unable to write in the cache directory (%s).", $dir));
16
  */
17
  class Twig_Environment
18
  {
19
+ const VERSION = '1.16.3';
20
 
21
  protected $charset;
22
  protected $loader;
154
  /**
155
  * Checks if debug mode is enabled.
156
  *
157
+ * @return bool true if debug mode is enabled, false otherwise
158
  */
159
  public function isDebug()
160
  {
180
  /**
181
  * Checks if the auto_reload option is enabled.
182
  *
183
+ * @return bool true if auto_reload is enabled, false otherwise
184
  */
185
  public function isAutoReload()
186
  {
206
  /**
207
  * Checks if the strict_variables option is enabled.
208
  *
209
+ * @return bool true if strict_variables is enabled, false otherwise
210
  */
211
  public function isStrictVariables()
212
  {
256
  * Gets the template class associated with the given string.
257
  *
258
  * @param string $name The name for which to calculate the template class name
259
+ * @param int $index The index if it is an embedded template
260
  *
261
  * @return string The template class name
262
  */
311
  * Loads a template by name.
312
  *
313
  * @param string $name The template name
314
+ * @param int $index The index if it is an embedded template
315
  *
316
  * @return Twig_TemplateInterface A template instance representing the given template name
317
  *
353
  * not changed.
354
  *
355
  * @param string $name The template name
356
+ * @param int $time The last modification time of the cached template
357
  *
358
+ * @return bool true if the template is fresh, false otherwise
359
  */
360
  public function isTemplateFresh($name, $time)
361
  {
626
  *
627
  * @param string $name The extension name
628
  *
629
+ * @return bool Whether the extension is registered or not
630
  */
631
  public function hasExtension($name)
632
  {
1232
  {
1233
  $dir = dirname($file);
1234
  if (!is_dir($dir)) {
1235
+ if (false === @mkdir($dir, 0777, true)) {
1236
+ clearstatcache(false, $dir);
1237
+ if (!is_dir($dir)) {
1238
+ throw new RuntimeException(sprintf("Unable to create the cache directory (%s).", $dir));
1239
+ }
1240
  }
1241
  } elseif (!is_writable($dir)) {
1242
  throw new RuntimeException(sprintf("Unable to write in the cache directory (%s).", $dir));
vendor/twig/twig/lib/Twig/Error.php CHANGED
@@ -51,7 +51,7 @@ class Twig_Error extends Exception
51
  * By default, automatic guessing is enabled.
52
  *
53
  * @param string $message The error message
54
- * @param integer $lineno The template line where the error occurred
55
  * @param string $filename The template file name where the error occurred
56
  * @param Exception $previous The previous exception
57
  */
@@ -111,7 +111,7 @@ class Twig_Error extends Exception
111
  /**
112
  * Gets the template line where the error occurred.
113
  *
114
- * @return integer The template line
115
  */
116
  public function getTemplateLine()
117
  {
@@ -121,7 +121,7 @@ class Twig_Error extends Exception
121
  /**
122
  * Sets the template line where the error occurred.
123
  *
124
- * @param integer $lineno The template line
125
  */
126
  public function setTemplateLine($lineno)
127
  {
@@ -229,6 +229,8 @@ class Twig_Error extends Exception
229
 
230
  while ($e = array_pop($exceptions)) {
231
  $traces = $e->getTrace();
 
 
232
  while ($trace = array_shift($traces)) {
233
  if (!isset($trace['file']) || !isset($trace['line']) || $file != $trace['file']) {
234
  continue;
51
  * By default, automatic guessing is enabled.
52
  *
53
  * @param string $message The error message
54
+ * @param int $lineno The template line where the error occurred
55
  * @param string $filename The template file name where the error occurred
56
  * @param Exception $previous The previous exception
57
  */
111
  /**
112
  * Gets the template line where the error occurred.
113
  *
114
+ * @return int The template line
115
  */
116
  public function getTemplateLine()
117
  {
121
  /**
122
  * Sets the template line where the error occurred.
123
  *
124
+ * @param int $lineno The template line
125
  */
126
  public function setTemplateLine($lineno)
127
  {
229
 
230
  while ($e = array_pop($exceptions)) {
231
  $traces = $e->getTrace();
232
+ array_unshift($traces, array('file' => $e->getFile(), 'line' => $e->getLine()));
233
+
234
  while ($trace = array_shift($traces)) {
235
  if (!isset($trace['file']) || !isset($trace['line']) || $file != $trace['file']) {
236
  continue;
vendor/twig/twig/lib/Twig/ExistsLoaderInterface.php CHANGED
@@ -13,7 +13,8 @@
13
  * Adds an exists() method for loaders.
14
  *
15
  * @author Florin Patan <florinpatan@gmail.com>
16
- * @deprecated since 1.12 (to be removed in 2.0)
 
17
  */
18
  interface Twig_ExistsLoaderInterface
19
  {
@@ -22,7 +23,7 @@ interface Twig_ExistsLoaderInterface
22
  *
23
  * @param string $name The name of the template to check if we can load
24
  *
25
- * @return Boolean If the template source code is handled by this loader or not
26
  */
27
  public function exists($name);
28
  }
13
  * Adds an exists() method for loaders.
14
  *
15
  * @author Florin Patan <florinpatan@gmail.com>
16
+ *
17
+ * @deprecated since 1.12 (to be removed in 3.0)
18
  */
19
  interface Twig_ExistsLoaderInterface
20
  {
23
  *
24
  * @param string $name The name of the template to check if we can load
25
  *
26
+ * @return bool If the template source code is handled by this loader or not
27
  */
28
  public function exists($name);
29
  }
vendor/twig/twig/lib/Twig/ExpressionParser.php CHANGED
@@ -164,6 +164,21 @@ class Twig_ExpressionParser
164
  $this->parser->getStream()->next();
165
  $node = new Twig_Node_Expression_Name($token->getValue(), $token->getLine());
166
  break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
167
  }
168
 
169
  default:
@@ -318,7 +333,7 @@ class Twig_ExpressionParser
318
  throw new Twig_Error_Syntax('The "attribute" function takes at least two arguments (the variable and the attributes)', $line, $this->parser->getFilename());
319
  }
320
 
321
- return new Twig_Node_Expression_GetAttr($args->getNode(0), $args->getNode(1), count($args) > 2 ? $args->getNode(2) : new Twig_Node_Expression_Array(array(), $line), Twig_Template::ANY_CALL, $line);
322
  default:
323
  if (null !== $alias = $this->parser->getImportedSymbol('function', $name)) {
324
  $arguments = new Twig_Node_Expression_Array(array(), $line);
@@ -451,8 +466,8 @@ class Twig_ExpressionParser
451
  /**
452
  * Parses arguments.
453
  *
454
- * @param Boolean $namedArguments Whether to allow named arguments or not
455
- * @param Boolean $definition Whether we are parsing arguments for a function definition
456
  */
457
  public function parseArguments($namedArguments = false, $definition = false)
458
  {
@@ -583,7 +598,9 @@ class Twig_ExpressionParser
583
  // checks that the node only contains "constant" elements
584
  protected function checkConstantExpression(Twig_NodeInterface $node)
585
  {
586
- if (!($node instanceof Twig_Node_Expression_Constant || $node instanceof Twig_Node_Expression_Array)) {
 
 
587
  return false;
588
  }
589
 
164
  $this->parser->getStream()->next();
165
  $node = new Twig_Node_Expression_Name($token->getValue(), $token->getLine());
166
  break;
167
+ } elseif (isset($this->unaryOperators[$token->getValue()])) {
168
+ $class = $this->unaryOperators[$token->getValue()]['class'];
169
+
170
+ $ref = new ReflectionClass($class);
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();
178
+ $expr = $this->parsePrimaryExpression();
179
+
180
+ $node = new $class($expr, $token->getLine());
181
+ break;
182
  }
183
 
184
  default:
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);
337
  default:
338
  if (null !== $alias = $this->parser->getImportedSymbol('function', $name)) {
339
  $arguments = new Twig_Node_Expression_Array(array(), $line);
466
  /**
467
  * Parses arguments.
468
  *
469
+ * @param bool $namedArguments Whether to allow named arguments or not
470
+ * @param bool $definition Whether we are parsing arguments for a function definition
471
  */
472
  public function parseArguments($namedArguments = false, $definition = false)
473
  {
598
  // checks that the node only contains "constant" elements
599
  protected function checkConstantExpression(Twig_NodeInterface $node)
600
  {
601
+ if (!($node instanceof Twig_Node_Expression_Constant || $node instanceof Twig_Node_Expression_Array
602
+ || $node instanceof Twig_Node_Expression_Unary_Neg || $node instanceof Twig_Node_Expression_Unary_Pos
603
+ )) {
604
  return false;
605
  }
606
 
vendor/twig/twig/lib/Twig/Extension/Core.php CHANGED
@@ -95,7 +95,7 @@ class Twig_Extension_Core extends Twig_Extension
95
  /**
96
  * Sets the default format to be used by the number_format filter.
97
  *
98
- * @param integer $decimal The number of decimal places to use.
99
  * @param string $decimalPoint The character(s) to use for the decimal point.
100
  * @param string $thousandSep The character(s) to use for the thousands separator.
101
  */
@@ -173,7 +173,7 @@ class Twig_Extension_Core extends Twig_Extension
173
 
174
  // array helpers
175
  new Twig_SimpleFilter('join', 'twig_join_filter'),
176
- new Twig_SimpleFilter('split', 'twig_split_filter'),
177
  new Twig_SimpleFilter('sort', 'twig_sort_filter'),
178
  new Twig_SimpleFilter('merge', 'twig_array_merge'),
179
  new Twig_SimpleFilter('batch', 'twig_array_batch'),
@@ -298,8 +298,8 @@ class Twig_Extension_Core extends Twig_Extension
298
  public function parseTestExpression(Twig_Parser $parser, Twig_NodeInterface $node)
299
  {
300
  $stream = $parser->getStream();
301
- $name = $stream->expect(Twig_Token::NAME_TYPE)->getValue();
302
- $class = $this->getTestNodeClass($parser, $name, $node->getLine());
303
  $arguments = null;
304
  if ($stream->test(Twig_Token::PUNCTUATION_TYPE, '(')) {
305
  $arguments = $parser->getExpressionParser()->parseArguments(true);
@@ -308,33 +308,41 @@ class Twig_Extension_Core extends Twig_Extension
308
  return new $class($node, $name, $arguments, $parser->getCurrentToken()->getLine());
309
  }
310
 
311
- protected function getTestNodeClass(Twig_Parser $parser, $name, $line)
312
  {
 
 
313
  $env = $parser->getEnvironment();
314
  $testMap = $env->getTests();
315
- $testName = null;
316
  if (isset($testMap[$name])) {
317
- $testName = $name;
318
- } elseif ($parser->getStream()->test(Twig_Token::NAME_TYPE)) {
 
 
319
  // try 2-words tests
320
  $name = $name.' '.$parser->getCurrentToken()->getValue();
321
 
322
  if (isset($testMap[$name])) {
323
  $parser->getStream()->next();
324
 
325
- $testName = $name;
326
  }
327
  }
328
 
329
- if (null === $testName) {
330
- $message = sprintf('The test "%s" does not exist', $name);
331
- if ($alternatives = $env->computeAlternatives($name, array_keys($env->getTests()))) {
332
- $message = sprintf('%s. Did you mean "%s"', $message, implode('", "', $alternatives));
333
- }
334
-
335
- throw new Twig_Error_Syntax($message, $line, $parser->getFilename());
336
  }
337
 
 
 
 
 
 
 
 
 
338
  if ($testMap[$name] instanceof Twig_SimpleTest) {
339
  return $testMap[$name]->getNodeClass();
340
  }
@@ -357,7 +365,7 @@ class Twig_Extension_Core extends Twig_Extension
357
  * Cycles over a value.
358
  *
359
  * @param ArrayAccess|array $values An array or an ArrayAccess instance
360
- * @param integer $position The cycle position
361
  *
362
  * @return string The next value in the cycle
363
  */
@@ -377,7 +385,7 @@ function twig_cycle($values, $position)
377
  * - a random integer between 0 and the integer parameter
378
  *
379
  * @param Twig_Environment $env A Twig_Environment instance
380
- * @param Traversable|array|integer|string $values The values to pick a random item from
381
  *
382
  * @throws Twig_Error_Runtime When $values is an empty array (does not apply to an empty string which is returned as is).
383
  *
@@ -436,10 +444,10 @@ function twig_random(Twig_Environment $env, $values = null)
436
  * {{ post.published_at|date("m/d/Y") }}
437
  * </pre>
438
  *
439
- * @param Twig_Environment $env A Twig_Environment instance
440
- * @param DateTime|DateInterval|string $date A date
441
- * @param string $format A format
442
- * @param DateTimeZone|string $timezone A timezone
443
  *
444
  * @return string The formatted date
445
  */
@@ -473,9 +481,12 @@ function twig_date_format_filter(Twig_Environment $env, $date, $format = null, $
473
  function twig_date_modify_filter(Twig_Environment $env, $date, $modifier)
474
  {
475
  $date = twig_date_converter($env, $date, false);
476
- $date->modify($modifier);
477
 
478
- return $date;
 
 
 
479
  }
480
 
481
  /**
@@ -487,32 +498,32 @@ function twig_date_modify_filter(Twig_Environment $env, $date, $modifier)
487
  * {% endif %}
488
  * </pre>
489
  *
490
- * @param Twig_Environment $env A Twig_Environment instance
491
- * @param DateTime|string $date A date
492
- * @param DateTimeZone|string $timezone A timezone
493
  *
494
  * @return DateTime A DateTime instance
495
  */
496
  function twig_date_converter(Twig_Environment $env, $date = null, $timezone = null)
497
  {
498
  // determine the timezone
499
- if (!$timezone) {
500
- $defaultTimezone = $env->getExtension('core')->getTimezone();
501
- } elseif (!$timezone instanceof DateTimeZone) {
502
- $defaultTimezone = new DateTimeZone($timezone);
503
- } else {
504
- $defaultTimezone = $timezone;
505
  }
506
 
507
  // immutable dates
508
  if ($date instanceof DateTimeImmutable) {
509
- return false !== $timezone ? $date->setTimezone($defaultTimezone) : $date;
510
  }
511
 
512
  if ($date instanceof DateTime || $date instanceof DateTimeInterface) {
513
  $date = clone $date;
514
  if (false !== $timezone) {
515
- $date->setTimezone($defaultTimezone);
516
  }
517
 
518
  return $date;
@@ -523,9 +534,9 @@ function twig_date_converter(Twig_Environment $env, $date = null, $timezone = nu
523
  $date = '@'.$date;
524
  }
525
 
526
- $date = new DateTime($date, $defaultTimezone);
527
  if (false !== $timezone) {
528
- $date->setTimezone($defaultTimezone);
529
  }
530
 
531
  return $date;
@@ -534,11 +545,11 @@ function twig_date_converter(Twig_Environment $env, $date = null, $timezone = nu
534
  /**
535
  * Rounds a number.
536
  *
537
- * @param integer|float $value The value to round
538
- * @param integer|float $precision The rounding precision
539
  * @param string $method The method to use for rounding
540
  *
541
- * @return integer|float The rounded number
542
  */
543
  function twig_round($value, $precision = 0, $method = 'common')
544
  {
@@ -562,7 +573,7 @@ function twig_round($value, $precision = 0, $method = 'common')
562
  *
563
  * @param Twig_Environment $env A Twig_Environment instance
564
  * @param mixed $number A float/int/string of the number to format
565
- * @param integer $decimal The number of decimal points to display.
566
  * @param string $decimalPoint The character(s) to use for the decimal point.
567
  * @param string $thousandSep The character(s) to use for the thousands separator.
568
  *
@@ -587,24 +598,23 @@ function twig_number_format_filter(Twig_Environment $env, $number, $decimal = nu
587
  }
588
 
589
  /**
590
- * URL encodes a string as a path segment or an array as a query string.
591
  *
592
  * @param string|array $url A URL or an array of query parameters
593
- * @param Boolean $raw true to use rawurlencode() instead of urlencode
594
  *
595
  * @return string The URL encoded value
596
  */
597
- function twig_urlencode_filter($url, $raw = false)
598
  {
599
  if (is_array($url)) {
600
- return http_build_query($url, '', '&');
601
- }
 
602
 
603
- if ($raw) {
604
- return rawurlencode($url);
605
  }
606
 
607
- return urlencode($url);
608
  }
609
 
610
  if (version_compare(PHP_VERSION, '5.3.0', '<')) {
@@ -612,7 +622,7 @@ if (version_compare(PHP_VERSION, '5.3.0', '<')) {
612
  * JSON encodes a variable.
613
  *
614
  * @param mixed $value The value to encode.
615
- * @param integer $options Not used on PHP 5.2.x
616
  *
617
  * @return mixed The JSON encoded value
618
  */
@@ -631,7 +641,7 @@ if (version_compare(PHP_VERSION, '5.3.0', '<')) {
631
  * JSON encodes a variable.
632
  *
633
  * @param mixed $value The value to encode.
634
- * @param integer $options Bitmask consisting of JSON_HEX_QUOT, JSON_HEX_TAG, JSON_HEX_AMP, JSON_HEX_APOS, JSON_NUMERIC_CHECK, JSON_PRETTY_PRINT, JSON_UNESCAPED_SLASHES, JSON_FORCE_OBJECT
635
  *
636
  * @return mixed The JSON encoded value
637
  */
@@ -673,7 +683,7 @@ function _twig_markup2string(&$value)
673
  function twig_array_merge($arr1, $arr2)
674
  {
675
  if (!is_array($arr1) || !is_array($arr2)) {
676
- throw new Twig_Error_Runtime('The merge filter only works with arrays or hashes.');
677
  }
678
 
679
  return array_merge($arr1, $arr2);
@@ -684,16 +694,28 @@ function twig_array_merge($arr1, $arr2)
684
  *
685
  * @param Twig_Environment $env A Twig_Environment instance
686
  * @param mixed $item A variable
687
- * @param integer $start Start of the slice
688
- * @param integer $length Size of the slice
689
- * @param Boolean $preserveKeys Whether to preserve key or not (when the input is an array)
690
  *
691
  * @return mixed The sliced variable
692
  */
693
  function twig_slice(Twig_Environment $env, $item, $start, $length = null, $preserveKeys = false)
694
  {
695
  if ($item instanceof Traversable) {
696
- $item = iterator_to_array($item, false);
 
 
 
 
 
 
 
 
 
 
 
 
697
  }
698
 
699
  if (is_array($item)) {
@@ -703,10 +725,10 @@ function twig_slice(Twig_Environment $env, $item, $start, $length = null, $prese
703
  $item = (string) $item;
704
 
705
  if (function_exists('mb_get_info') && null !== $charset = $env->getCharset()) {
706
- return mb_substr($item, $start, null === $length ? mb_strlen($item, $charset) - $start : $length, $charset);
707
  }
708
 
709
- return null === $length ? substr($item, $start) : substr($item, $start, $length);
710
  }
711
 
712
  /**
@@ -785,17 +807,35 @@ function twig_join_filter($value, $glue = '')
785
  *
786
  * @param string $value A string
787
  * @param string $delimiter The delimiter
788
- * @param integer $limit The limit
789
  *
790
  * @return array The split string as an array
791
  */
792
- function twig_split_filter($value, $delimiter, $limit = null)
793
  {
794
- if (empty($delimiter)) {
 
 
 
 
795
  return str_split($value, null === $limit ? 1 : $limit);
796
  }
797
 
798
- return null === $limit ? explode($delimiter, $value) : explode($delimiter, $value, $limit);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
799
  }
800
 
801
  // The '_default' filter is used internally to avoid using the ternary operator
@@ -843,7 +883,7 @@ function twig_get_array_keys_filter($array)
843
  *
844
  * @param Twig_Environment $env A Twig_Environment instance
845
  * @param array|Traversable|string $item An array, a Traversable instance, or a string
846
- * @param Boolean $preserveKeys Whether to preserve key or not
847
  *
848
  * @return mixed The reversed input
849
  */
@@ -894,15 +934,11 @@ function twig_sort_filter($array)
894
  function twig_in_filter($value, $compare)
895
  {
896
  if (is_array($compare)) {
897
- return in_array($value, $compare, is_object($value));
898
- } elseif (is_string($compare)) {
899
- if (!strlen($value)) {
900
- return empty($compare);
901
- }
902
-
903
- return false !== strpos($compare, (string) $value);
904
  } elseif ($compare instanceof Traversable) {
905
- return in_array($value, iterator_to_array($compare, false), is_object($value));
906
  }
907
 
908
  return false;
@@ -915,7 +951,7 @@ function twig_in_filter($value, $compare)
915
  * @param string $string The value to be escaped
916
  * @param string $strategy The escaping strategy
917
  * @param string $charset The charset
918
- * @param Boolean $autoescape Whether the function is called by the auto-escaping feature (true) or by the developer (false)
919
  */
920
  function twig_escape_filter(Twig_Environment $env, $string, $strategy = 'html', $charset = null, $autoescape = false)
921
  {
@@ -945,7 +981,7 @@ function twig_escape_filter(Twig_Environment $env, $string, $strategy = 'html',
945
  static $htmlspecialcharsCharsets;
946
 
947
  if (null === $htmlspecialcharsCharsets) {
948
- if ('hiphop' === substr(PHP_VERSION, -6)) {
949
  $htmlspecialcharsCharsets = array('utf-8' => true, 'UTF-8' => true);
950
  } else {
951
  $htmlspecialcharsCharsets = array(
@@ -1192,7 +1228,7 @@ if (function_exists('mb_get_info')) {
1192
  * @param Twig_Environment $env A Twig_Environment instance
1193
  * @param mixed $thing A variable
1194
  *
1195
- * @return integer The length of the value
1196
  */
1197
  function twig_length_filter(Twig_Environment $env, $thing)
1198
  {
@@ -1276,7 +1312,7 @@ else {
1276
  * @param Twig_Environment $env A Twig_Environment instance
1277
  * @param mixed $thing A variable
1278
  *
1279
- * @return integer The length of the value
1280
  */
1281
  function twig_length_filter(Twig_Environment $env, $thing)
1282
  {
@@ -1332,7 +1368,7 @@ function twig_ensure_traversable($seq)
1332
  *
1333
  * @param mixed $value A variable
1334
  *
1335
- * @return Boolean true if the value is empty, false otherwise
1336
  */
1337
  function twig_test_empty($value)
1338
  {
@@ -1355,7 +1391,7 @@ function twig_test_empty($value)
1355
  *
1356
  * @param mixed $value A variable
1357
  *
1358
- * @return Boolean true if the value is traversable
1359
  */
1360
  function twig_test_iterable($value)
1361
  {
@@ -1367,9 +1403,9 @@ function twig_test_iterable($value)
1367
  *
1368
  * @param string|array $template The template to render or an array of templates to try consecutively
1369
  * @param array $variables The variables to pass to the template
1370
- * @param Boolean $with_context Whether to pass the current context variables or not
1371
- * @param Boolean $ignore_missing Whether to ignore missing templates or not
1372
- * @param Boolean $sandboxed Whether to sandbox the template or not
1373
  *
1374
  * @return string The rendered template
1375
  */
@@ -1434,7 +1470,7 @@ function twig_constant($constant, $object = null)
1434
  * Batches item.
1435
  *
1436
  * @param array $items An array of items
1437
- * @param integer $size The size of the batch
1438
  * @param mixed $fill A value used to fill missing items
1439
  *
1440
  * @return array
95
  /**
96
  * Sets the default format to be used by the number_format filter.
97
  *
98
+ * @param int $decimal The number of decimal places to use.
99
  * @param string $decimalPoint The character(s) to use for the decimal point.
100
  * @param string $thousandSep The character(s) to use for the thousands separator.
101
  */
173
 
174
  // array helpers
175
  new Twig_SimpleFilter('join', 'twig_join_filter'),
176
+ new Twig_SimpleFilter('split', 'twig_split_filter', array('needs_environment' => true)),
177
  new Twig_SimpleFilter('sort', 'twig_sort_filter'),
178
  new Twig_SimpleFilter('merge', 'twig_array_merge'),
179
  new Twig_SimpleFilter('batch', 'twig_array_batch'),
298
  public function parseTestExpression(Twig_Parser $parser, Twig_NodeInterface $node)
299
  {
300
  $stream = $parser->getStream();
301
+ $name = $this->getTestName($parser, $node->getLine());
302
+ $class = $this->getTestNodeClass($parser, $name);
303
  $arguments = null;
304
  if ($stream->test(Twig_Token::PUNCTUATION_TYPE, '(')) {
305
  $arguments = $parser->getExpressionParser()->parseArguments(true);
308
  return new $class($node, $name, $arguments, $parser->getCurrentToken()->getLine());
309
  }
310
 
311
+ protected function getTestName(Twig_Parser $parser, $line)
312
  {
313
+ $stream = $parser->getStream();
314
+ $name = $stream->expect(Twig_Token::NAME_TYPE)->getValue();
315
  $env = $parser->getEnvironment();
316
  $testMap = $env->getTests();
317
+
318
  if (isset($testMap[$name])) {
319
+ return $name;
320
+ }
321
+
322
+ if ($stream->test(Twig_Token::NAME_TYPE)) {
323
  // try 2-words tests
324
  $name = $name.' '.$parser->getCurrentToken()->getValue();
325
 
326
  if (isset($testMap[$name])) {
327
  $parser->getStream()->next();
328
 
329
+ return $name;
330
  }
331
  }
332
 
333
+ $message = sprintf('The test "%s" does not exist', $name);
334
+ if ($alternatives = $env->computeAlternatives($name, array_keys($testMap))) {
335
+ $message = sprintf('%s. Did you mean "%s"', $message, implode('", "', $alternatives));
 
 
 
 
336
  }
337
 
338
+ throw new Twig_Error_Syntax($message, $line, $parser->getFilename());
339
+ }
340
+
341
+ protected function getTestNodeClass(Twig_Parser $parser, $name)
342
+ {
343
+ $env = $parser->getEnvironment();
344
+ $testMap = $env->getTests();
345
+
346
  if ($testMap[$name] instanceof Twig_SimpleTest) {
347
  return $testMap[$name]->getNodeClass();
348
  }
365
  * Cycles over a value.
366
  *
367
  * @param ArrayAccess|array $values An array or an ArrayAccess instance
368
+ * @param int $position The cycle position
369
  *
370
  * @return string The next value in the cycle
371
  */
385
  * - a random integer between 0 and the integer parameter
386
  *
387
  * @param Twig_Environment $env A Twig_Environment instance
388
+ * @param Traversable|array|int|string $values The values to pick a random item from
389
  *
390
  * @throws Twig_Error_Runtime When $values is an empty array (does not apply to an empty string which is returned as is).
391
  *
444
  * {{ post.published_at|date("m/d/Y") }}
445
  * </pre>
446
  *
447
+ * @param Twig_Environment $env A Twig_Environment instance
448
+ * @param DateTime|DateTimeInterface|DateInterval|string $date A date
449
+ * @param string|null $format The target format, null to use the default
450
+ * @param DateTimeZone|string|null|false $timezone The target timezone, null to use the default, false to leave unchanged
451
  *
452
  * @return string The formatted date
453
  */
481
  function twig_date_modify_filter(Twig_Environment $env, $date, $modifier)
482
  {
483
  $date = twig_date_converter($env, $date, false);
484
+ $resultDate = $date->modify($modifier);
485
 
486
+ // This is a hack to ensure PHP 5.2 support and support for DateTimeImmutable
487
+ // DateTime::modify does not return the modified DateTime object < 5.3.0
488
+ // and DateTimeImmutable does not modify $date.
489
+ return null === $resultDate ? $date : $resultDate;
490
  }
491
 
492
  /**
498
  * {% endif %}
499
  * </pre>
500
  *
501
+ * @param Twig_Environment $env A Twig_Environment instance
502
+ * @param DateTime|DateTimeInterface|string|null $date A date
503
+ * @param DateTimeZone|string|null|false $timezone The target timezone, null to use the default, false to leave unchanged
504
  *
505
  * @return DateTime A DateTime instance
506
  */
507
  function twig_date_converter(Twig_Environment $env, $date = null, $timezone = null)
508
  {
509
  // determine the timezone
510
+ if (false !== $timezone) {
511
+ if (null === $timezone) {
512
+ $timezone = $env->getExtension('core')->getTimezone();
513
+ } elseif (!$timezone instanceof DateTimeZone) {
514
+ $timezone = new DateTimeZone($timezone);
515
+ }
516
  }
517
 
518
  // immutable dates
519
  if ($date instanceof DateTimeImmutable) {
520
+ return false !== $timezone ? $date->setTimezone($timezone) : $date;
521
  }
522
 
523
  if ($date instanceof DateTime || $date instanceof DateTimeInterface) {
524
  $date = clone $date;
525
  if (false !== $timezone) {
526
+ $date->setTimezone($timezone);
527
  }
528
 
529
  return $date;
534
  $date = '@'.$date;
535
  }
536
 
537
+ $date = new DateTime($date, $env->getExtension('core')->getTimezone());
538
  if (false !== $timezone) {
539
+ $date->setTimezone($timezone);
540
  }
541
 
542
  return $date;
545
  /**
546
  * Rounds a number.
547
  *
548
+ * @param int|float $value The value to round
549
+ * @param int|float $precision The rounding precision
550
  * @param string $method The method to use for rounding
551
  *
552
+ * @return int|float The rounded number
553
  */
554
  function twig_round($value, $precision = 0, $method = 'common')
555
  {
573
  *
574
  * @param Twig_Environment $env A Twig_Environment instance
575
  * @param mixed $number A float/int/string of the number to format
576
+ * @param int $decimal The number of decimal points to display.
577
  * @param string $decimalPoint The character(s) to use for the decimal point.
578
  * @param string $thousandSep The character(s) to use for the thousands separator.
579
  *
598
  }
599
 
600
  /**
601
+ * URL encodes (RFC 3986) a string as a path segment or an array as a query string.
602
  *
603
  * @param string|array $url A URL or an array of query parameters
 
604
  *
605
  * @return string The URL encoded value
606
  */
607
+ function twig_urlencode_filter($url)
608
  {
609
  if (is_array($url)) {
610
+ if (defined('PHP_QUERY_RFC3986')) {
611
+ return http_build_query($url, '', '&', PHP_QUERY_RFC3986);
612
+ }
613
 
614
+ return http_build_query($url, '', '&');
 
615
  }
616
 
617
+ return rawurlencode($url);
618
  }
619
 
620
  if (version_compare(PHP_VERSION, '5.3.0', '<')) {
622
  * JSON encodes a variable.
623
  *
624
  * @param mixed $value The value to encode.
625
+ * @param int $options Not used on PHP 5.2.x
626
  *
627
  * @return mixed The JSON encoded value
628
  */
641
  * JSON encodes a variable.
642
  *
643
  * @param mixed $value The value to encode.
644
+ * @param int $options Bitmask consisting of JSON_HEX_QUOT, JSON_HEX_TAG, JSON_HEX_AMP, JSON_HEX_APOS, JSON_NUMERIC_CHECK, JSON_PRETTY_PRINT, JSON_UNESCAPED_SLASHES, JSON_FORCE_OBJECT
645
  *
646
  * @return mixed The JSON encoded value
647
  */
683
  function twig_array_merge($arr1, $arr2)
684
  {
685
  if (!is_array($arr1) || !is_array($arr2)) {
686
+ throw new Twig_Error_Runtime(sprintf('The merge filter only works with arrays or hashes; %s and %s given.', gettype($arr1), gettype($arr2)));
687
  }
688
 
689
  return array_merge($arr1, $arr2);
694
  *
695
  * @param Twig_Environment $env A Twig_Environment instance
696
  * @param mixed $item A variable
697
+ * @param int $start Start of the slice
698
+ * @param int $length Size of the slice
699
+ * @param bool $preserveKeys Whether to preserve key or not (when the input is an array)
700
  *
701
  * @return mixed The sliced variable
702
  */
703
  function twig_slice(Twig_Environment $env, $item, $start, $length = null, $preserveKeys = false)
704
  {
705
  if ($item instanceof Traversable) {
706
+ if ($item instanceof IteratorAggregate) {
707
+ $item = $item->getIterator();
708
+ }
709
+
710
+ if ($start >= 0 && $length >= 0) {
711
+ try {
712
+ return iterator_to_array(new LimitIterator($item, $start, $length === null ? -1 : $length), $preserveKeys);
713
+ } catch (OutOfBoundsException $exception) {
714
+ return array();
715
+ }
716
+ }
717
+
718
+ $item = iterator_to_array($item, $preserveKeys);
719
  }
720
 
721
  if (is_array($item)) {
725
  $item = (string) $item;
726
 
727
  if (function_exists('mb_get_info') && null !== $charset = $env->getCharset()) {
728
+ return (string) mb_substr($item, $start, null === $length ? mb_strlen($item, $charset) - $start : $length, $charset);
729
  }
730
 
731
+ return (string) (null === $length ? substr($item, $start) : substr($item, $start, $length));
732
  }
733
 
734
  /**
807
  *
808
  * @param string $value A string
809
  * @param string $delimiter The delimiter
810
+ * @param int $limit The limit
811
  *
812
  * @return array The split string as an array
813
  */
814
+ function twig_split_filter(Twig_Environment $env, $value, $delimiter, $limit = null)
815
  {
816
+ if (!empty($delimiter)) {
817
+ return null === $limit ? explode($delimiter, $value) : explode($delimiter, $value, $limit);
818
+ }
819
+
820
+ if (!function_exists('mb_get_info') || null === $charset = $env->getCharset()) {
821
  return str_split($value, null === $limit ? 1 : $limit);
822
  }
823
 
824
+ if ($limit <= 1) {
825
+ return preg_split('/(?<!^)(?!$)/u', $value);
826
+ }
827
+
828
+ $length = mb_strlen($value, $charset);
829
+ if ($length < $limit) {
830
+ return array($value);
831
+ }
832
+
833
+ $r = array();
834
+ for ($i = 0; $i < $length; $i += $limit) {
835
+ $r[] = mb_substr($value, $i, $limit, $charset);
836
+ }
837
+
838
+ return $r;
839
  }
840
 
841
  // The '_default' filter is used internally to avoid using the ternary operator
883
  *
884
  * @param Twig_Environment $env A Twig_Environment instance
885
  * @param array|Traversable|string $item An array, a Traversable instance, or a string
886
+ * @param bool $preserveKeys Whether to preserve key or not
887
  *
888
  * @return mixed The reversed input
889
  */
934
  function twig_in_filter($value, $compare)
935
  {
936
  if (is_array($compare)) {
937
+ return in_array($value, $compare, is_object($value) || is_resource($value));
938
+ } elseif (is_string($compare) && (is_string($value) || is_int($value) || is_float($value))) {
939
+ return '' === $value || false !== strpos($compare, (string) $value);
 
 
 
 
940
  } elseif ($compare instanceof Traversable) {
941
+ return in_array($value, iterator_to_array($compare, false), is_object($value) || is_resource($value));
942
  }
943
 
944
  return false;
951
  * @param string $string The value to be escaped
952
  * @param string $strategy The escaping strategy
953
  * @param string $charset The charset
954
+ * @param bool $autoescape Whether the function is called by the auto-escaping feature (true) or by the developer (false)
955
  */
956
  function twig_escape_filter(Twig_Environment $env, $string, $strategy = 'html', $charset = null, $autoescape = false)
957
  {
981
  static $htmlspecialcharsCharsets;
982
 
983
  if (null === $htmlspecialcharsCharsets) {
984
+ if (defined('HHVM_VERSION')) {
985
  $htmlspecialcharsCharsets = array('utf-8' => true, 'UTF-8' => true);
986
  } else {
987
  $htmlspecialcharsCharsets = array(
1228
  * @param Twig_Environment $env A Twig_Environment instance
1229
  * @param mixed $thing A variable
1230
  *
1231
+ * @return int The length of the value
1232
  */
1233
  function twig_length_filter(Twig_Environment $env, $thing)
1234
  {
1312
  * @param Twig_Environment $env A Twig_Environment instance
1313
  * @param mixed $thing A variable
1314
  *
1315
+ * @return int The length of the value
1316
  */
1317
  function twig_length_filter(Twig_Environment $env, $thing)
1318
  {
1368
  *
1369
  * @param mixed $value A variable
1370
  *
1371
+ * @return bool true if the value is empty, false otherwise
1372
  */
1373
  function twig_test_empty($value)
1374
  {
1391
  *
1392
  * @param mixed $value A variable
1393
  *
1394
+ * @return bool true if the value is traversable
1395
  */
1396
  function twig_test_iterable($value)
1397
  {
1403
  *
1404
  * @param string|array $template The template to render or an array of templates to try consecutively
1405
  * @param array $variables The variables to pass to the template
1406
+ * @param bool $with_context Whether to pass the current context variables or not
1407
+ * @param bool $ignore_missing Whether to ignore missing templates or not
1408
+ * @param bool $sandboxed Whether to sandbox the template or not
1409
  *
1410
  * @return string The rendered template
1411
  */
1470
  * Batches item.
1471
  *
1472
  * @param array $items An array of items
1473
+ * @param int $size The size of the batch
1474
  * @param mixed $fill A value used to fill missing items
1475
  *
1476
  * @return array
vendor/twig/twig/lib/Twig/Extension/Sandbox.php CHANGED
@@ -93,7 +93,7 @@ class Twig_Extension_Sandbox extends Twig_Extension
93
 
94
  public function ensureToStringAllowed($obj)
95
  {
96
- if (is_object($obj)) {
97
  $this->policy->checkMethodAllowed($obj, '__toString');
98
  }
99
 
93
 
94
  public function ensureToStringAllowed($obj)
95
  {
96
+ if ($this->isSandboxed() && is_object($obj)) {
97
  $this->policy->checkMethodAllowed($obj, '__toString');
98
  }
99
 
vendor/twig/twig/lib/Twig/LexerInterface.php CHANGED
@@ -13,7 +13,8 @@
13
  * Interface implemented by lexer classes.
14
  *
15
  * @author Fabien Potencier <fabien@symfony.com>
16
- * @deprecated since 1.12 (to be removed in 2.0)
 
17
  */
18
  interface Twig_LexerInterface
19
  {
13
  * Interface implemented by lexer classes.
14
  *
15
  * @author Fabien Potencier <fabien@symfony.com>
16
+ *
17
+ * @deprecated since 1.12 (to be removed in 3.0)
18
  */
19
  interface Twig_LexerInterface
20
  {
vendor/twig/twig/lib/Twig/Loader/Array.php CHANGED
@@ -17,6 +17,8 @@
17
  * source code of the template). If you don't want to see your cache grows out of
18
  * control, you need to take care of clearing the old cache file by yourself.
19
  *
 
 
20
  * @author Fabien Potencier <fabien@symfony.com>
21
  */
22
  class Twig_Loader_Array implements Twig_LoaderInterface, Twig_ExistsLoaderInterface
17
  * source code of the template). If you don't want to see your cache grows out of
18
  * control, you need to take care of clearing the old cache file by yourself.
19
  *
20
+ * This loader should only be used for unit testing.
21
+ *
22
  * @author Fabien Potencier <fabien@symfony.com>
23
  */
24
  class Twig_Loader_Array implements Twig_LoaderInterface, Twig_ExistsLoaderInterface
vendor/twig/twig/lib/Twig/Loader/Filesystem.php CHANGED
@@ -176,16 +176,7 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface, Twig_ExistsLoaderI
176
 
177
  $this->validateName($name);
178
 
179
- $namespace = self::MAIN_NAMESPACE;
180
- $shortname = $name;
181
- if (isset($name[0]) && '@' == $name[0]) {
182
- if (false === $pos = strpos($name, '/')) {
183
- throw new Twig_Error_Loader(sprintf('Malformed namespaced template name "%s" (expecting "@namespace/template_name").', $name));
184
- }
185
-
186
- $namespace = substr($name, 1, $pos - 1);
187
- $shortname = substr($name, $pos + 1);
188
- }
189
 
190
  if (!isset($this->paths[$namespace])) {
191
  throw new Twig_Error_Loader(sprintf('There are no registered paths for namespace "%s".', $namespace));
@@ -200,6 +191,22 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface, Twig_ExistsLoaderI
200
  throw new Twig_Error_Loader(sprintf('Unable to find template "%s" (looked into: %s).', $name, implode(', ', $this->paths[$namespace])));
201
  }
202
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
203
  protected function normalizeName($name)
204
  {
205
  return preg_replace('#/{2,}#', '/', strtr((string) $name, '\\', '/'));
176
 
177
  $this->validateName($name);
178
 
179
+ list($namespace, $shortname) = $this->parseName($name);
 
 
 
 
 
 
 
 
 
180
 
181
  if (!isset($this->paths[$namespace])) {
182
  throw new Twig_Error_Loader(sprintf('There are no registered paths for namespace "%s".', $namespace));
191
  throw new Twig_Error_Loader(sprintf('Unable to find template "%s" (looked into: %s).', $name, implode(', ', $this->paths[$namespace])));
192
  }
193
 
194
+ protected function parseName($name, $default = self::MAIN_NAMESPACE)
195
+ {
196
+ if (isset($name[0]) && '@' == $name[0]) {
197
+ if (false === $pos = strpos($name, '/')) {
198
+ throw new Twig_Error_Loader(sprintf('Malformed namespaced template name "%s" (expecting "@namespace/template_name").', $name));
199
+ }
200
+
201
+ $namespace = substr($name, 1, $pos - 1);
202
+ $shortname = substr($name, $pos + 1);
203
+
204
+ return array($namespace, $shortname);
205
+ }
206
+
207
+ return array($default, $name);
208
+ }
209
+
210
  protected function normalizeName($name)
211
  {
212
  return preg_replace('#/{2,}#', '/', strtr((string) $name, '\\', '/'));
vendor/twig/twig/lib/Twig/Loader/String.php CHANGED
@@ -12,9 +12,7 @@
12
  /**
13
  * Loads a template from a string.
14
  *
15
- * This loader should only be used for unit testing as it has many limitations
16
- * (for instance, the include or extends tag does not make any sense for a string
17
- * loader).
18
  *
19
  * When using this loader with a cache mechanism, you should know that a new cache
20
  * key is generated each time a template content "changes" (the cache key being the
12
  /**
13
  * Loads a template from a string.
14
  *
15
+ * This loader should NEVER be used. It only exists for Twig internal purposes.
 
 
16
  *
17
  * When using this loader with a cache mechanism, you should know that a new cache
18
  * key is generated each time a template content "changes" (the cache key being the
vendor/twig/twig/lib/Twig/LoaderInterface.php CHANGED
@@ -44,7 +44,7 @@ interface Twig_LoaderInterface
44
  * @param string $name The template name
45
  * @param timestamp $time The last modification time of the cached template
46
  *
47
- * @return Boolean true if the template is fresh, false otherwise
48
  *
49
  * @throws Twig_Error_Loader When $name is not found
50
  */
44
  * @param string $name The template name
45
  * @param timestamp $time The last modification time of the cached template
46
  *
47
+ * @return bool true if the template is fresh, false otherwise
48
  *
49
  * @throws Twig_Error_Loader When $name is not found
50
  */
vendor/twig/twig/lib/Twig/Node.php CHANGED
@@ -30,7 +30,7 @@ class Twig_Node implements Twig_NodeInterface
30
  *
31
  * @param array $nodes An array of named nodes
32
  * @param array $attributes An array of attributes (should not be nodes)
33
- * @param integer $lineno The line number
34
  * @param string $tag The tag name associated with the Node
35
  */
36
  public function __construct(array $nodes = array(), array $attributes = array(), $lineno = 0, $tag = null)
@@ -69,6 +69,9 @@ class Twig_Node implements Twig_NodeInterface
69
  return implode("\n", $repr);
70
  }
71
 
 
 
 
72
  public function toXml($asDom = false)
73
  {
74
  $dom = new DOMDocument('1.0', 'UTF-8');
@@ -121,7 +124,7 @@ class Twig_Node implements Twig_NodeInterface
121
  *
122
  * @param string The attribute name
123
  *
124
- * @return Boolean true if the attribute is defined, false otherwise
125
  */
126
  public function hasAttribute($name)
127
  {
@@ -170,7 +173,7 @@ class Twig_Node implements Twig_NodeInterface
170
  *
171
  * @param string The node name
172
  *
173
- * @return Boolean true if the node with the given name exists, false otherwise
174
  */
175
  public function hasNode($name)
176
  {
30
  *
31
  * @param array $nodes An array of named nodes
32
  * @param array $attributes An array of attributes (should not be nodes)
33
+ * @param int $lineno The line number
34
  * @param string $tag The tag name associated with the Node
35
  */
36
  public function __construct(array $nodes = array(), array $attributes = array(), $lineno = 0, $tag = null)
69
  return implode("\n", $repr);
70
  }
71
 
72
+ /**
73
+ * @deprecated since 1.16.1 (to be removed in 2.0)
74
+ */
75
  public function toXml($asDom = false)
76
  {
77
  $dom = new DOMDocument('1.0', 'UTF-8');
124
  *
125
  * @param string The attribute name
126
  *
127
+ * @return bool true if the attribute is defined, false otherwise
128
  */
129
  public function hasAttribute($name)
130
  {
173
  *
174
  * @param string The node name
175
  *
176
+ * @return bool true if the node with the given name exists, false otherwise
177
  */
178
  public function hasNode($name)
179
  {
vendor/twig/twig/lib/Twig/Node/AutoEscape.php CHANGED
@@ -30,7 +30,7 @@ class Twig_Node_AutoEscape extends Twig_Node
30
  /**
31
  * Compiles the node to PHP.
32
  *
33
- * @param Twig_Compiler A Twig_Compiler instance
34
  */
35
  public function compile(Twig_Compiler $compiler)
36
  {
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
  {
vendor/twig/twig/lib/Twig/Node/Block.php CHANGED
@@ -25,7 +25,7 @@ class Twig_Node_Block extends Twig_Node
25
  /**
26
  * Compiles the node to PHP.
27
  *
28
- * @param Twig_Compiler A Twig_Compiler instance
29
  */
30
  public function compile(Twig_Compiler $compiler)
31
  {
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
  {
vendor/twig/twig/lib/Twig/Node/BlockReference.php CHANGED
@@ -25,7 +25,7 @@ class Twig_Node_BlockReference extends Twig_Node implements Twig_NodeOutputInter
25
  /**
26
  * Compiles the node to PHP.
27
  *
28
- * @param Twig_Compiler A Twig_Compiler instance
29
  */
30
  public function compile(Twig_Compiler $compiler)
31
  {
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
  {
vendor/twig/twig/lib/Twig/Node/Do.php CHANGED
@@ -24,7 +24,7 @@ class Twig_Node_Do extends Twig_Node
24
  /**
25
  * Compiles the node to PHP.
26
  *
27
- * @param Twig_Compiler A Twig_Compiler instance
28
  */
29
  public function compile(Twig_Compiler $compiler)
30
  {
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
  {
vendor/twig/twig/lib/Twig/Node/Expression/Array.php CHANGED
@@ -63,7 +63,7 @@ class Twig_Node_Expression_Array extends Twig_Node_Expression
63
  /**
64
  * Compiles the node to PHP.
65
  *
66
- * @param Twig_Compiler A Twig_Compiler instance
67
  */
68
  public function compile(Twig_Compiler $compiler)
69
  {
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
  {
vendor/twig/twig/lib/Twig/Node/Expression/AssignName.php CHANGED
@@ -15,7 +15,7 @@ class Twig_Node_Expression_AssignName extends Twig_Node_Expression_Name
15
  /**
16
  * Compiles the node to PHP.
17
  *
18
- * @param Twig_Compiler A Twig_Compiler instance
19
  */
20
  public function compile(Twig_Compiler $compiler)
21
  {
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
  {
vendor/twig/twig/lib/Twig/Node/Expression/Binary.php CHANGED
@@ -19,7 +19,7 @@ abstract class Twig_Node_Expression_Binary extends Twig_Node_Expression
19
  /**
20
  * Compiles the node to PHP.
21
  *
22
- * @param Twig_Compiler A Twig_Compiler instance
23
  */
24
  public function compile(Twig_Compiler $compiler)
25
  {
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
  {
vendor/twig/twig/lib/Twig/Node/Expression/Binary/EndsWith.php CHANGED
@@ -12,14 +12,14 @@ class Twig_Node_Expression_Binary_EndsWith extends Twig_Node_Expression_Binary
12
  {
13
  public function compile(Twig_Compiler $compiler)
14
  {
 
 
15
  $compiler
16
- ->raw('(0 === substr_compare(')
17
  ->subcompile($this->getNode('left'))
18
- ->raw(', ')
19
  ->subcompile($this->getNode('right'))
20
- ->raw(', -strlen(')
21
- ->subcompile($this->getNode('right'))
22
- ->raw(')))')
23
  ;
24
  }
25
 
12
  {
13
  public function compile(Twig_Compiler $compiler)
14
  {
15
+ $left = $compiler->getVarName();
16
+ $right = $compiler->getVarName();
17
  $compiler
18
+ ->raw(sprintf('(is_string($%s = ', $left))
19
  ->subcompile($this->getNode('left'))
20
+ ->raw(sprintf(') && is_string($%s = ', $right))
21
  ->subcompile($this->getNode('right'))
22
+ ->raw(sprintf(') && (\'\' === $%2$s || $%2$s === substr($%1$s, -strlen($%2$s))))', $left, $right))
 
 
23
  ;
24
  }
25
 
vendor/twig/twig/lib/Twig/Node/Expression/Binary/FloorDiv.php CHANGED
@@ -13,7 +13,7 @@ class Twig_Node_Expression_Binary_FloorDiv extends Twig_Node_Expression_Binary
13
  /**
14
  * Compiles the node to PHP.
15
  *
16
- * @param Twig_Compiler A Twig_Compiler instance
17
  */
18
  public function compile(Twig_Compiler $compiler)
19
  {
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
  {
vendor/twig/twig/lib/Twig/Node/Expression/Binary/In.php CHANGED
@@ -13,7 +13,7 @@ class Twig_Node_Expression_Binary_In extends Twig_Node_Expression_Binary
13
  /**
14
  * Compiles the node to PHP.
15
  *
16
- * @param Twig_Compiler A Twig_Compiler instance
17
  */
18
  public function compile(Twig_Compiler $compiler)
19
  {
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
  {
vendor/twig/twig/lib/Twig/Node/Expression/Binary/NotIn.php CHANGED
@@ -13,7 +13,7 @@ class Twig_Node_Expression_Binary_NotIn extends Twig_Node_Expression_Binary
13
  /**
14
  * Compiles the node to PHP.
15
  *
16
- * @param Twig_Compiler A Twig_Compiler instance
17
  */
18
  public function compile(Twig_Compiler $compiler)
19
  {
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
  {
vendor/twig/twig/lib/Twig/Node/Expression/Binary/Power.php CHANGED
@@ -13,7 +13,7 @@ class Twig_Node_Expression_Binary_Power extends Twig_Node_Expression_Binary
13
  /**
14
  * Compiles the node to PHP.
15
  *
16
- * @param Twig_Compiler A Twig_Compiler instance
17
  */
18
  public function compile(Twig_Compiler $compiler)
19
  {
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
  {
vendor/twig/twig/lib/Twig/Node/Expression/Binary/Range.php CHANGED
@@ -13,7 +13,7 @@ class Twig_Node_Expression_Binary_Range extends Twig_Node_Expression_Binary
13
  /**
14
  * Compiles the node to PHP.
15
  *
16
- * @param Twig_Compiler A Twig_Compiler instance
17
  */
18
  public function compile(Twig_Compiler $compiler)
19
  {
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
  {
vendor/twig/twig/lib/Twig/Node/Expression/Binary/StartsWith.php CHANGED
@@ -12,12 +12,14 @@ class Twig_Node_Expression_Binary_StartsWith extends Twig_Node_Expression_Binary
12
  {
13
  public function compile(Twig_Compiler $compiler)
14
  {
 
 
15
  $compiler
16
- ->raw('(0 === strpos(')
17
  ->subcompile($this->getNode('left'))
18
- ->raw(', ')
19
  ->subcompile($this->getNode('right'))
20
- ->raw('))')
21
  ;
22
  }
23
 
12
  {
13
  public function compile(Twig_Compiler $compiler)
14
  {
15
+ $left = $compiler->getVarName();
16
+ $right = $compiler->getVarName();
17
  $compiler
18
+ ->raw(sprintf('(is_string($%s = ', $left))
19
  ->subcompile($this->getNode('left'))
20
+ ->raw(sprintf(') && is_string($%s = ', $right))
21
  ->subcompile($this->getNode('right'))
22
+ ->raw(sprintf(') && (\'\' === $%2$s || 0 === strpos($%1$s, $%2$s)))', $left, $right))
23
  ;
24
  }
25
 
vendor/twig/twig/lib/Twig/Node/Expression/BlockReference.php CHANGED
@@ -25,7 +25,7 @@ class Twig_Node_Expression_BlockReference extends Twig_Node_Expression
25
  /**
26
  * Compiles the node to PHP.
27
  *
28
- * @param Twig_Compiler A Twig_Compiler instance
29
  */
30
  public function compile(Twig_Compiler $compiler)
31
  {
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
  {
vendor/twig/twig/lib/Twig/Node/Expression/Call.php CHANGED
@@ -12,10 +12,8 @@ abstract class Twig_Node_Expression_Call extends Twig_Node_Expression
12
  {
13
  protected function compileCallable(Twig_Compiler $compiler)
14
  {
15
- $callable = $this->getAttribute('callable');
16
-
17
  $closingParenthesis = false;
18
- if ($callable) {
19
  if (is_string($callable)) {
20
  $compiler->raw($callable);
21
  } elseif (is_array($callable) && $callable[0] instanceof Twig_ExtensionInterface) {
@@ -140,9 +138,10 @@ abstract class Twig_Node_Expression_Call extends Twig_Node_Expression
140
  }
141
 
142
  $arguments = array();
 
143
  $pos = 0;
144
  foreach ($definition as $param) {
145
- $name = $this->normalizeName($param->name);
146
 
147
  if (array_key_exists($name, $parameters)) {
148
  if (array_key_exists($pos, $parameters)) {
@@ -165,7 +164,10 @@ abstract class Twig_Node_Expression_Call extends Twig_Node_Expression
165
  }
166
 
167
  if (!empty($parameters)) {
168
- throw new Twig_Error_Syntax(sprintf('Unknown argument%s "%s" for %s "%s".', count($parameters) > 1 ? 's' : '', implode('", "', array_keys($parameters)), $this->getAttribute('type'), $this->getAttribute('name')));
 
 
 
169
  }
170
 
171
  return $arguments;
12
  {
13
  protected function compileCallable(Twig_Compiler $compiler)
14
  {
 
 
15
  $closingParenthesis = false;
16
+ if ($this->hasAttribute('callable') && $callable = $this->getAttribute('callable')) {
17
  if (is_string($callable)) {
18
  $compiler->raw($callable);
19
  } elseif (is_array($callable) && $callable[0] instanceof Twig_ExtensionInterface) {
138
  }
139
 
140
  $arguments = array();
141
+ $names = array();
142
  $pos = 0;
143
  foreach ($definition as $param) {
144
+ $names[] = $name = $this->normalizeName($param->name);
145
 
146
  if (array_key_exists($name, $parameters)) {
147
  if (array_key_exists($pos, $parameters)) {
164
  }
165
 
166
  if (!empty($parameters)) {
167
+ throw new Twig_Error_Syntax(sprintf(
168
+ 'Unknown argument%s "%s" for %s "%s(%s)".',
169
+ count($parameters) > 1 ? 's' : '', implode('", "', array_keys($parameters)), $this->getAttribute('type'), $this->getAttribute('name'), implode(', ', $names)
170
+ ));
171
  }
172
 
173
  return $arguments;
vendor/twig/twig/lib/Twig/Node/Expression/ExtensionReference.php CHANGED
@@ -24,7 +24,7 @@ class Twig_Node_Expression_ExtensionReference extends Twig_Node_Expression
24
  /**
25
  * Compiles the node to PHP.
26
  *
27
- * @param Twig_Compiler A Twig_Compiler instance
28
  */
29
  public function compile(Twig_Compiler $compiler)
30
  {
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
  {
vendor/twig/twig/lib/Twig/Node/Expression/GetAttr.php CHANGED
@@ -11,7 +11,7 @@
11
  */
12
  class Twig_Node_Expression_GetAttr extends Twig_Node_Expression
13
  {
14
- public function __construct(Twig_Node_Expression $node, Twig_Node_Expression $attribute, Twig_Node_Expression_Array $arguments, $type, $lineno)
15
  {
16
  parent::__construct(array('node' => $node, 'attribute' => $attribute, 'arguments' => $arguments), array('type' => $type, 'is_defined_test' => false, 'ignore_strict_check' => false, 'disable_c_ext' => false), $lineno);
17
  }
@@ -32,20 +32,30 @@ class Twig_Node_Expression_GetAttr extends Twig_Node_Expression
32
 
33
  $compiler->raw(', ')->subcompile($this->getNode('attribute'));
34
 
35
- if (count($this->getNode('arguments')) || Twig_Template::ANY_CALL !== $this->getAttribute('type') || $this->getAttribute('is_defined_test') || $this->getAttribute('ignore_strict_check')) {
36
- $compiler->raw(', ')->subcompile($this->getNode('arguments'));
37
-
38
- if (Twig_Template::ANY_CALL !== $this->getAttribute('type') || $this->getAttribute('is_defined_test') || $this->getAttribute('ignore_strict_check')) {
39
- $compiler->raw(', ')->repr($this->getAttribute('type'));
 
 
 
 
 
 
40
  }
 
41
 
42
- if ($this->getAttribute('is_defined_test') || $this->getAttribute('ignore_strict_check')) {
43
- $compiler->raw(', '.($this->getAttribute('is_defined_test') ? 'true' : 'false'));
44
- }
45
 
46
- if ($this->getAttribute('ignore_strict_check')) {
47
- $compiler->raw(', '.($this->getAttribute('ignore_strict_check') ? 'true' : 'false'));
48
- }
 
 
 
49
  }
50
 
51
  $compiler->raw(')');
11
  */
12
  class Twig_Node_Expression_GetAttr extends Twig_Node_Expression
13
  {
14
+ public function __construct(Twig_Node_Expression $node, Twig_Node_Expression $attribute, Twig_Node_Expression $arguments = null, $type, $lineno)
15
  {
16
  parent::__construct(array('node' => $node, 'attribute' => $attribute, 'arguments' => $arguments), array('type' => $type, 'is_defined_test' => false, 'ignore_strict_check' => false, 'disable_c_ext' => false), $lineno);
17
  }
32
 
33
  $compiler->raw(', ')->subcompile($this->getNode('attribute'));
34
 
35
+ // only generate optional arguments when needed (to make generated code more readable)
36
+ $needFourth = $this->getAttribute('ignore_strict_check');
37
+ $needThird = $needFourth || $this->getAttribute('is_defined_test');
38
+ $needSecond = $needThird || Twig_Template::ANY_CALL !== $this->getAttribute('type');
39
+ $needFirst = $needSecond || null !== $this->getNode('arguments');
40
+
41
+ if ($needFirst) {
42
+ if (null !== $this->getNode('arguments')) {
43
+ $compiler->raw(', ')->subcompile($this->getNode('arguments'));
44
+ } else {
45
+ $compiler->raw(', array()');
46
  }
47
+ }
48
 
49
+ if ($needSecond) {
50
+ $compiler->raw(', ')->repr($this->getAttribute('type'));
51
+ }
52
 
53
+ if ($needThird) {
54
+ $compiler->raw(', ')->repr($this->getAttribute('is_defined_test'));
55
+ }
56
+
57
+ if ($needFourth) {
58
+ $compiler->raw(', ')->repr($this->getAttribute('ignore_strict_check'));
59
  }
60
 
61
  $compiler->raw(')');
vendor/twig/twig/lib/Twig/Node/Expression/Parent.php CHANGED
@@ -25,7 +25,7 @@ class Twig_Node_Expression_Parent extends Twig_Node_Expression
25
  /**
26
  * Compiles the node to PHP.
27
  *
28
- * @param Twig_Compiler A Twig_Compiler instance
29
  */
30
  public function compile(Twig_Compiler $compiler)
31
  {
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
  {
vendor/twig/twig/lib/Twig/Node/Expression/Test/Divisibleby.php CHANGED
@@ -13,7 +13,7 @@
13
  * Checks if a variable is divisible by a number.
14
  *
15
  * <pre>
16
- * {% if loop.index is divisibleby(3) %}
17
  * </pre>
18
  *
19
  * @author Fabien Potencier <fabien@symfony.com>
13
  * Checks if a variable is divisible by a number.
14
  *
15
  * <pre>
16
+ * {% if loop.index is divisible by(3) %}
17
  * </pre>
18
  *
19
  * @author Fabien Potencier <fabien@symfony.com>
vendor/twig/twig/lib/Twig/Node/Expression/Unary.php CHANGED
@@ -18,12 +18,9 @@ abstract class Twig_Node_Expression_Unary extends Twig_Node_Expression
18
 
19
  public function compile(Twig_Compiler $compiler)
20
  {
21
- $compiler->raw('(');
22
  $this->operator($compiler);
23
- $compiler
24
- ->subcompile($this->getNode('node'))
25
- ->raw(')')
26
- ;
27
  }
28
 
29
  abstract public function operator(Twig_Compiler $compiler);
18
 
19
  public function compile(Twig_Compiler $compiler)
20
  {
21
+ $compiler->raw(' ');
22
  $this->operator($compiler);
23
+ $compiler->subcompile($this->getNode('node'));
 
 
 
24
  }
25
 
26
  abstract public function operator(Twig_Compiler $compiler);
vendor/twig/twig/lib/Twig/Node/Flush.php CHANGED
@@ -24,7 +24,7 @@ class Twig_Node_Flush extends Twig_Node
24
  /**
25
  * Compiles the node to PHP.
26
  *
27
- * @param Twig_Compiler A Twig_Compiler instance
28
  */
29
  public function compile(Twig_Compiler $compiler)
30
  {
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
  {
vendor/twig/twig/lib/Twig/Node/For.php CHANGED
@@ -33,7 +33,7 @@ class Twig_Node_For extends Twig_Node
33
  /**
34
  * Compiles the node to PHP.
35
  *
36
- * @param Twig_Compiler A Twig_Compiler instance
37
  */
38
  public function compile(Twig_Compiler $compiler)
39
  {
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
  {
vendor/twig/twig/lib/Twig/Node/ForLoop.php CHANGED
@@ -24,7 +24,7 @@ class Twig_Node_ForLoop extends Twig_Node
24
  /**
25
  * Compiles the node to PHP.
26
  *
27
- * @param Twig_Compiler A Twig_Compiler instance
28
  */
29
  public function compile(Twig_Compiler $compiler)
30
  {
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
  {
vendor/twig/twig/lib/Twig/Node/If.php CHANGED
@@ -25,7 +25,7 @@ class Twig_Node_If extends Twig_Node
25
  /**
26
  * Compiles the node to PHP.
27
  *
28
- * @param Twig_Compiler A Twig_Compiler instance
29
  */
30
  public function compile(Twig_Compiler $compiler)
31
  {
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
  {
vendor/twig/twig/lib/Twig/Node/Import.php CHANGED
@@ -24,7 +24,7 @@ class Twig_Node_Import extends Twig_Node
24
  /**
25
  * Compiles the node to PHP.
26
  *
27
- * @param Twig_Compiler A Twig_Compiler instance
28
  */
29
  public function compile(Twig_Compiler $compiler)
30
  {
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
  {
vendor/twig/twig/lib/Twig/Node/Include.php CHANGED
@@ -19,13 +19,13 @@ class Twig_Node_Include extends Twig_Node implements Twig_NodeOutputInterface
19
  {
20
  public function __construct(Twig_Node_Expression $expr, Twig_Node_Expression $variables = null, $only = false, $ignoreMissing = false, $lineno, $tag = null)
21
  {
22
- parent::__construct(array('expr' => $expr, 'variables' => $variables), array('only' => (Boolean) $only, 'ignore_missing' => (Boolean) $ignoreMissing), $lineno, $tag);
23
  }
24
 
25
  /**
26
  * Compiles the node to PHP.
27
  *
28
- * @param Twig_Compiler A Twig_Compiler instance
29
  */
30
  public function compile(Twig_Compiler $compiler)
31
  {
@@ -60,40 +60,26 @@ class Twig_Node_Include extends Twig_Node implements Twig_NodeOutputInterface
60
 
61
  protected function addGetTemplate(Twig_Compiler $compiler)
62
  {
63
- if ($this->getNode('expr') instanceof Twig_Node_Expression_Constant) {
64
- $compiler
65
- ->write("\$this->env->loadTemplate(")
66
- ->subcompile($this->getNode('expr'))
67
- ->raw(")")
68
- ;
69
- } else {
70
- $compiler
71
- ->write("\$template = \$this->env->resolveTemplate(")
72
- ->subcompile($this->getNode('expr'))
73
- ->raw(");\n")
74
- ->write('$template')
75
- ;
76
- }
77
  }
78
 
79
  protected function addTemplateArguments(Twig_Compiler $compiler)
80
  {
81
- if (false === $this->getAttribute('only')) {
82
- if (null === $this->getNode('variables')) {
83
- $compiler->raw('$context');
84
- } else {
85
- $compiler
86
- ->raw('array_merge($context, ')
87
- ->subcompile($this->getNode('variables'))
88
- ->raw(')')
89
- ;
90
- }
91
  } else {
92
- if (null === $this->getNode('variables')) {
93
- $compiler->raw('array()');
94
- } else {
95
- $compiler->subcompile($this->getNode('variables'));
96
- }
97
  }
98
  }
99
  }
19
  {
20
  public function __construct(Twig_Node_Expression $expr, Twig_Node_Expression $variables = null, $only = false, $ignoreMissing = false, $lineno, $tag = null)
21
  {
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
  {
60
 
61
  protected function addGetTemplate(Twig_Compiler $compiler)
62
  {
63
+ $method = $this->getNode('expr') instanceof Twig_Node_Expression_Constant ? 'loadTemplate' : 'resolveTemplate';
64
+ $compiler
65
+ ->write(sprintf('$this->env->%s(', $method))
66
+ ->subcompile($this->getNode('expr'))
67
+ ->raw(')')
68
+ ;
 
 
 
 
 
 
 
 
69
  }
70
 
71
  protected function addTemplateArguments(Twig_Compiler $compiler)
72
  {
73
+ if (null === $this->getNode('variables')) {
74
+ $compiler->raw(false === $this->getAttribute('only') ? '$context' : 'array()');
75
+ } elseif (false === $this->getAttribute('only')) {
76
+ $compiler
77
+ ->raw('array_merge($context, ')
78
+ ->subcompile($this->getNode('variables'))
79
+ ->raw(')')
80
+ ;
 
 
81
  } else {
82
+ $compiler->subcompile($this->getNode('variables'));
 
 
 
 
83
  }
84
  }
85
  }
vendor/twig/twig/lib/Twig/Node/Macro.php CHANGED
@@ -24,7 +24,7 @@ class Twig_Node_Macro extends Twig_Node
24
  /**
25
  * Compiles the node to PHP.
26
  *
27
- * @param Twig_Compiler A Twig_Compiler instance
28
  */
29
  public function compile(Twig_Compiler $compiler)
30
  {
@@ -37,7 +37,7 @@ class Twig_Node_Macro extends Twig_Node
37
  $pos = 0;
38
  foreach ($this->getNode('arguments') as $name => $default) {
39
  $compiler
40
- ->raw('$_'.$name.' = ')
41
  ->subcompile($default)
42
  ;
43
 
@@ -64,7 +64,7 @@ class Twig_Node_Macro extends Twig_Node
64
  $compiler
65
  ->write('')
66
  ->string($name)
67
- ->raw(' => $_'.$name)
68
  ->raw(",\n")
69
  ;
70
  }
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
  {
37
  $pos = 0;
38
  foreach ($this->getNode('arguments') as $name => $default) {
39
  $compiler
40
+ ->raw('$__'.$name.'__ = ')
41
  ->subcompile($default)
42
  ;
43
 
64
  $compiler
65
  ->write('')
66
  ->string($name)
67
+ ->raw(' => $__'.$name.'__')
68
  ->raw(",\n")
69
  ;
70
  }
vendor/twig/twig/lib/Twig/Node/Module.php CHANGED
@@ -31,7 +31,7 @@ class Twig_Node_Module extends Twig_Node
31
  /**
32
  * Compiles the node to PHP.
33
  *
34
- * @param Twig_Compiler A Twig_Compiler instance
35
  */
36
  public function compile(Twig_Compiler $compiler)
37
  {
@@ -77,17 +77,18 @@ class Twig_Node_Module extends Twig_Node
77
 
78
  protected function compileGetParent(Twig_Compiler $compiler)
79
  {
80
- if (null === $this->getNode('parent')) {
81
  return;
82
  }
83
 
84
  $compiler
85
  ->write("protected function doGetParent(array \$context)\n", "{\n")
86
  ->indent()
 
87
  ->write("return ")
88
  ;
89
 
90
- if ($this->getNode('parent') instanceof Twig_Node_Expression_Constant) {
91
  $compiler->subcompile($this->getNode('parent'));
92
  } else {
93
  $compiler
@@ -108,8 +109,9 @@ class Twig_Node_Module extends Twig_Node
108
  {
109
  $compiler->subcompile($this->getNode('body'));
110
 
111
- if (null !== $this->getNode('parent')) {
112
- if ($this->getNode('parent') instanceof Twig_Node_Expression_Constant) {
 
113
  $compiler->write("\$this->parent");
114
  } else {
115
  $compiler->write("\$this->getParent(\$context)");
@@ -140,13 +142,24 @@ class Twig_Node_Module extends Twig_Node
140
  ;
141
 
142
  // parent
143
- if (null === $this->getNode('parent')) {
144
  $compiler->write("\$this->parent = false;\n\n");
145
- } elseif ($this->getNode('parent') instanceof Twig_Node_Expression_Constant) {
146
  $compiler
 
 
 
147
  ->write("\$this->parent = \$this->env->loadTemplate(")
148
  ->subcompile($this->getNode('parent'))
149
- ->raw(");\n\n")
 
 
 
 
 
 
 
 
150
  ;
151
  }
152
 
@@ -249,7 +262,7 @@ class Twig_Node_Module extends Twig_Node
249
  ->outdent()
250
  ->write(");\n")
251
  ->outdent()
252
- ->write("}\n\n");
253
  ;
254
  }
255
 
31
  /**
32
  * Compiles the node to PHP.
33
  *
34
+ * @param Twig_Compiler $compiler A Twig_Compiler instance
35
  */
36
  public function compile(Twig_Compiler $compiler)
37
  {
77
 
78
  protected function compileGetParent(Twig_Compiler $compiler)
79
  {
80
+ if (null === $parent = $this->getNode('parent')) {
81
  return;
82
  }
83
 
84
  $compiler
85
  ->write("protected function doGetParent(array \$context)\n", "{\n")
86
  ->indent()
87
+ ->addDebugInfo($parent)
88
  ->write("return ")
89
  ;
90
 
91
+ if ($parent instanceof Twig_Node_Expression_Constant) {
92
  $compiler->subcompile($this->getNode('parent'));
93
  } else {
94
  $compiler
109
  {
110
  $compiler->subcompile($this->getNode('body'));
111
 
112
+ if (null !== $parent = $this->getNode('parent')) {
113
+ $compiler->addDebugInfo($parent);
114
+ if ($parent instanceof Twig_Node_Expression_Constant) {
115
  $compiler->write("\$this->parent");
116
  } else {
117
  $compiler->write("\$this->getParent(\$context)");
142
  ;
143
 
144
  // parent
145
+ if (null === $parent = $this->getNode('parent')) {
146
  $compiler->write("\$this->parent = false;\n\n");
147
+ } elseif ($parent instanceof Twig_Node_Expression_Constant) {
148
  $compiler
149
+ ->addDebugInfo($parent)
150
+ ->write("try {\n")
151
+ ->indent()
152
  ->write("\$this->parent = \$this->env->loadTemplate(")
153
  ->subcompile($this->getNode('parent'))
154
+ ->raw(");\n")
155
+ ->outdent()
156
+ ->write("} catch (Twig_Error_Loader \$e) {\n")
157
+ ->indent()
158
+ ->write("\$e->setTemplateFile(\$this->getTemplateName());\n")
159
+ ->write(sprintf("\$e->setTemplateLine(%d);\n\n", $parent->getLine()))
160
+ ->write("throw \$e;\n")
161
+ ->outdent()
162
+ ->write("}\n\n")
163
  ;
164
  }
165
 
262
  ->outdent()
263
  ->write(");\n")
264
  ->outdent()
265
+ ->write("}\n\n")
266
  ;
267
  }
268
 
vendor/twig/twig/lib/Twig/Node/Print.php CHANGED
@@ -25,7 +25,7 @@ class Twig_Node_Print extends Twig_Node implements Twig_NodeOutputInterface
25
  /**
26
  * Compiles the node to PHP.
27
  *
28
- * @param Twig_Compiler A Twig_Compiler instance
29
  */
30
  public function compile(Twig_Compiler $compiler)
31
  {
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
  {
vendor/twig/twig/lib/Twig/Node/Sandbox.php CHANGED
@@ -24,7 +24,7 @@ class Twig_Node_Sandbox extends Twig_Node
24
  /**
25
  * Compiles the node to PHP.
26
  *
27
- * @param Twig_Compiler A Twig_Compiler instance
28
  */
29
  public function compile(Twig_Compiler $compiler)
30
  {
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
  {
vendor/twig/twig/lib/Twig/Node/SandboxedModule.php CHANGED
@@ -23,7 +23,7 @@ class Twig_Node_SandboxedModule extends Twig_Node_Module
23
 
24
  public function __construct(Twig_Node_Module $node, array $usedFilters, array $usedTags, array $usedFunctions)
25
  {
26
- parent::__construct($node->getNode('body'), $node->getNode('parent'), $node->getNode('blocks'), $node->getNode('macros'), $node->getNode('traits'), $node->getAttribute('embedded_templates'), $node->getAttribute('filename'), $node->getLine(), $node->getNodeTag());
27
 
28
  $this->setAttribute('index', $node->getAttribute('index'));
29
 
@@ -43,17 +43,53 @@ class Twig_Node_SandboxedModule extends Twig_Node_Module
43
  {
44
  parent::compileDisplayFooter($compiler);
45
 
 
 
 
 
 
 
 
 
 
 
 
46
  $compiler
47
  ->write("protected function checkSecurity()\n", "{\n")
48
  ->indent()
 
 
 
 
 
49
  ->write("\$this->env->getExtension('sandbox')->checkSecurity(\n")
50
  ->indent()
51
- ->write(!$this->usedTags ? "array(),\n" : "array('".implode('\', \'', $this->usedTags)."'),\n")
52
- ->write(!$this->usedFilters ? "array(),\n" : "array('".implode('\', \'', $this->usedFilters)."'),\n")
53
- ->write(!$this->usedFunctions ? "array()\n" : "array('".implode('\', \'', $this->usedFunctions)."')\n")
54
  ->outdent()
55
  ->write(");\n")
56
  ->outdent()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
  ->write("}\n\n")
58
  ;
59
  }
23
 
24
  public function __construct(Twig_Node_Module $node, array $usedFilters, array $usedTags, array $usedFunctions)
25
  {
26
+ parent::__construct($node->getNode('body'), $node->getNode('parent'), $node->getNode('blocks'), $node->getNode('macros'), $node->getNode('traits'), $node->getAttribute('embedded_templates'), $node->getAttribute('filename'));
27
 
28
  $this->setAttribute('index', $node->getAttribute('index'));
29
 
43
  {
44
  parent::compileDisplayFooter($compiler);
45
 
46
+ $tags = $filters = $functions = array();
47
+ foreach (array('tags', 'filters', 'functions') as $type) {
48
+ foreach ($this->{'used'.ucfirst($type)} as $name => $node) {
49
+ if ($node instanceof Twig_Node) {
50
+ ${$type}[$name] = $node->getLine();
51
+ } else {
52
+ ${$type}[$node] = null;
53
+ }
54
+ }
55
+ }
56
+
57
  $compiler
58
  ->write("protected function checkSecurity()\n", "{\n")
59
  ->indent()
60
+ ->write("\$tags = ")->repr(array_filter($tags))->raw(";\n")
61
+ ->write("\$filters = ")->repr(array_filter($filters))->raw(";\n")
62
+ ->write("\$functions = ")->repr(array_filter($functions))->raw(";\n\n")
63
+ ->write("try {\n")
64
+ ->indent()
65
  ->write("\$this->env->getExtension('sandbox')->checkSecurity(\n")
66
  ->indent()
67
+ ->write(!$tags ? "array(),\n" : "array('".implode("', '", array_keys($tags))."'),\n")
68
+ ->write(!$filters ? "array(),\n" : "array('".implode("', '", array_keys($filters))."'),\n")
69
+ ->write(!$functions ? "array()\n" : "array('".implode("', '", array_keys($functions))."')\n")
70
  ->outdent()
71
  ->write(");\n")
72
  ->outdent()
73
+ ->write("} catch (Twig_Sandbox_SecurityError \$e) {\n")
74
+ ->indent()
75
+ ->write("\$e->setTemplateFile(\$this->getTemplateName());\n\n")
76
+ ->write("if (\$e instanceof Twig_Sandbox_SecurityNotAllowedTagError && isset(\$tags[\$e->getTagName()])) {\n")
77
+ ->indent()
78
+ ->write("\$e->setTemplateLine(\$tags[\$e->getTagName()]);\n")
79
+ ->outdent()
80
+ ->write("} elseif (\$e instanceof Twig_Sandbox_SecurityNotAllowedFilterError && isset(\$filters[\$e->getFilterName()])) {\n")
81
+ ->indent()
82
+ ->write("\$e->setTemplateLine(\$filters[\$e->getFilterName()]);\n")
83
+ ->outdent()
84
+ ->write("} elseif (\$e instanceof Twig_Sandbox_SecurityNotAllowedFunctionError && isset(\$functions[\$e->getFunctionName()])) {\n")
85
+ ->indent()
86
+ ->write("\$e->setTemplateLine(\$functions[\$e->getFunctionName()]);\n")
87
+ ->outdent()
88
+ ->write("}\n\n")
89
+ ->write("throw \$e;\n")
90
+ ->outdent()
91
+ ->write("}\n")
92
+ ->outdent()
93
  ->write("}\n\n")
94
  ;
95
  }
vendor/twig/twig/lib/Twig/Node/SandboxedPrint.php CHANGED
@@ -29,7 +29,7 @@ class Twig_Node_SandboxedPrint extends Twig_Node_Print
29
  /**
30
  * Compiles the node to PHP.
31
  *
32
- * @param Twig_Compiler A Twig_Compiler instance
33
  */
34
  public function compile(Twig_Compiler $compiler)
35
  {
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
  {
vendor/twig/twig/lib/Twig/Node/Set.php CHANGED
@@ -39,7 +39,7 @@ class Twig_Node_Set extends Twig_Node
39
  /**
40
  * Compiles the node to PHP.
41
  *
42
- * @param Twig_Compiler A Twig_Compiler instance
43
  */
44
  public function compile(Twig_Compiler $compiler)
45
  {
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
  {
vendor/twig/twig/lib/Twig/Node/Spaceless.php CHANGED
@@ -26,7 +26,7 @@ class Twig_Node_Spaceless extends Twig_Node
26
  /**
27
  * Compiles the node to PHP.
28
  *
29
- * @param Twig_Compiler A Twig_Compiler instance
30
  */
31
  public function compile(Twig_Compiler $compiler)
32
  {
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
  {
vendor/twig/twig/lib/Twig/Node/Text.php CHANGED
@@ -25,7 +25,7 @@ class Twig_Node_Text extends Twig_Node implements Twig_NodeOutputInterface
25
  /**
26
  * Compiles the node to PHP.
27
  *
28
- * @param Twig_Compiler A Twig_Compiler instance
29
  */
30
  public function compile(Twig_Compiler $compiler)
31
  {
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
  {
vendor/twig/twig/lib/Twig/NodeInterface.php CHANGED
@@ -13,14 +13,15 @@
13
  * Represents a node in the AST.
14
  *
15
  * @author Fabien Potencier <fabien@symfony.com>
16
- * @deprecated since 1.12 (to be removed in 2.0)
 
17
  */
18
  interface Twig_NodeInterface extends Countable, IteratorAggregate
19
  {
20
  /**
21
  * Compiles the node to PHP.
22
  *
23
- * @param Twig_Compiler A Twig_Compiler instance
24
  */
25
  public function compile(Twig_Compiler $compiler);
26
 
13
  * Represents a node in the AST.
14
  *
15
  * @author Fabien Potencier <fabien@symfony.com>
16
+ *
17
+ * @deprecated since 1.12 (to be removed in 3.0)
18
  */
19
  interface Twig_NodeInterface extends Countable, IteratorAggregate
20
  {
21
  /**
22
  * Compiles the node to PHP.
23
  *
24
+ * @param Twig_Compiler $compiler A Twig_Compiler instance
25
  */
26
  public function compile(Twig_Compiler $compiler);
27
 
vendor/twig/twig/lib/Twig/NodeTraverser.php CHANGED
@@ -70,7 +70,7 @@ class Twig_NodeTraverser
70
  protected function traverseForVisitor(Twig_NodeVisitorInterface $visitor, Twig_NodeInterface $node = null)
71
  {
72
  if (null === $node) {
73
- return null;
74
  }
75
 
76
  $node = $visitor->enterNode($node, $this->env);
70
  protected function traverseForVisitor(Twig_NodeVisitorInterface $visitor, Twig_NodeInterface $node = null)
71
  {
72
  if (null === $node) {
73
+ return;
74
  }
75
 
76
  $node = $visitor->enterNode($node, $this->env);
vendor/twig/twig/lib/Twig/NodeVisitor/Optimizer.php CHANGED
@@ -28,6 +28,7 @@ class Twig_NodeVisitor_Optimizer implements Twig_NodeVisitorInterface
28
  const OPTIMIZE_VAR_ACCESS = 8;
29
 
30
  protected $loops = array();
 
31
  protected $optimizers;
32
  protected $prependedNodes = array();
33
  protected $inABody = false;
@@ -35,7 +36,7 @@ class Twig_NodeVisitor_Optimizer implements Twig_NodeVisitorInterface
35
  /**
36
  * Constructor.
37
  *
38
- * @param integer $optimizers The optimizer mode
39
  */
40
  public function __construct($optimizers = -1)
41
  {
@@ -174,6 +175,8 @@ class Twig_NodeVisitor_Optimizer implements Twig_NodeVisitorInterface
174
  // disable the loop variable by default
175
  $node->setAttribute('with_loop', false);
176
  array_unshift($this->loops, $node);
 
 
177
  } elseif (!$this->loops) {
178
  // we are outside a loop
179
  return;
@@ -183,9 +186,15 @@ class Twig_NodeVisitor_Optimizer implements Twig_NodeVisitorInterface
183
 
184
  // the loop variable is referenced for the current loop
185
  elseif ($node instanceof Twig_Node_Expression_Name && 'loop' === $node->getAttribute('name')) {
 
186
  $this->addLoopToCurrent();
187
  }
188
 
 
 
 
 
 
189
  // block reference
190
  elseif ($node instanceof Twig_Node_BlockReference || $node instanceof Twig_Node_Expression_BlockReference) {
191
  $this->addLoopToCurrent();
@@ -196,6 +205,16 @@ class Twig_NodeVisitor_Optimizer implements Twig_NodeVisitorInterface
196
  $this->addLoopToAll();
197
  }
198
 
 
 
 
 
 
 
 
 
 
 
199
  // the loop variable is referenced via an attribute
200
  elseif ($node instanceof Twig_Node_Expression_GetAttr
201
  && (!$node->getNode('attribute') instanceof Twig_Node_Expression_Constant
@@ -221,6 +240,8 @@ class Twig_NodeVisitor_Optimizer implements Twig_NodeVisitorInterface
221
  {
222
  if ($node instanceof Twig_Node_For) {
223
  array_shift($this->loops);
 
 
224
  }
225
  }
226
 
28
  const OPTIMIZE_VAR_ACCESS = 8;
29
 
30
  protected $loops = array();
31
+ protected $loopsTargets = array();
32
  protected $optimizers;
33
  protected $prependedNodes = array();
34
  protected $inABody = false;
36
  /**
37
  * Constructor.
38
  *
39
+ * @param int $optimizers The optimizer mode
40
  */
41
  public function __construct($optimizers = -1)
42
  {
175
  // disable the loop variable by default
176
  $node->setAttribute('with_loop', false);
177
  array_unshift($this->loops, $node);
178
+ array_unshift($this->loopsTargets, $node->getNode('value_target')->getAttribute('name'));
179
+ array_unshift($this->loopsTargets, $node->getNode('key_target')->getAttribute('name'));
180
  } elseif (!$this->loops) {
181
  // we are outside a loop
182
  return;
186
 
187
  // the loop variable is referenced for the current loop
188
  elseif ($node instanceof Twig_Node_Expression_Name && 'loop' === $node->getAttribute('name')) {
189
+ $node->setAttribute('always_defined', true);
190
  $this->addLoopToCurrent();
191
  }
192
 
193
+ // optimize access to loop targets
194
+ elseif ($node instanceof Twig_Node_Expression_Name && in_array($node->getAttribute('name'), $this->loopsTargets)) {
195
+ $node->setAttribute('always_defined', true);
196
+ }
197
+
198
  // block reference
199
  elseif ($node instanceof Twig_Node_BlockReference || $node instanceof Twig_Node_Expression_BlockReference) {
200
  $this->addLoopToCurrent();
205
  $this->addLoopToAll();
206
  }
207
 
208
+ // include function without the with_context=false parameter
209
+ elseif ($node instanceof Twig_Node_Expression_Function
210
+ && 'include' === $node->getAttribute('name')
211
+ && (!$node->getNode('arguments')->hasNode('with_context')
212
+ || false !== $node->getNode('arguments')->getNode('with_context')->getAttribute('value')
213
+ )
214
+ ) {
215
+ $this->addLoopToAll();
216
+ }
217
+
218
  // the loop variable is referenced via an attribute
219
  elseif ($node instanceof Twig_Node_Expression_GetAttr
220
  && (!$node->getNode('attribute') instanceof Twig_Node_Expression_Constant
240
  {
241
  if ($node instanceof Twig_Node_For) {
242
  array_shift($this->loops);
243
+ array_shift($this->loopsTargets);
244
+ array_shift($this->loopsTargets);
245
  }
246
  }
247
 
vendor/twig/twig/lib/Twig/NodeVisitor/Sandbox.php CHANGED
@@ -40,18 +40,18 @@ class Twig_NodeVisitor_Sandbox implements Twig_NodeVisitorInterface
40
  return $node;
41
  } elseif ($this->inAModule) {
42
  // look for tags
43
- if ($node->getNodeTag()) {
44
- $this->tags[] = $node->getNodeTag();
45
  }
46
 
47
  // look for filters
48
- if ($node instanceof Twig_Node_Expression_Filter) {
49
- $this->filters[] = $node->getNode('filter')->getAttribute('value');
50
  }
51
 
52
  // look for functions
53
- if ($node instanceof Twig_Node_Expression_Function) {
54
- $this->functions[] = $node->getAttribute('name');
55
  }
56
 
57
  // wrap print to check __toString() calls
@@ -76,7 +76,7 @@ class Twig_NodeVisitor_Sandbox implements Twig_NodeVisitorInterface
76
  if ($node instanceof Twig_Node_Module) {
77
  $this->inAModule = false;
78
 
79
- return new Twig_Node_SandboxedModule($node, array_unique($this->filters), array_unique($this->tags), array_unique($this->functions));
80
  }
81
 
82
  return $node;
40
  return $node;
41
  } elseif ($this->inAModule) {
42
  // look for tags
43
+ if ($node->getNodeTag() && !isset($this->tags[$node->getNodeTag()])) {
44
+ $this->tags[$node->getNodeTag()] = $node;
45
  }
46
 
47
  // look for filters
48
+ if ($node instanceof Twig_Node_Expression_Filter && !isset($this->filters[$node->getNode('filter')->getAttribute('value')])) {
49
+ $this->filters[$node->getNode('filter')->getAttribute('value')] = $node;
50
  }
51
 
52
  // look for functions
53
+ if ($node instanceof Twig_Node_Expression_Function && !isset($this->functions[$node->getAttribute('name')])) {
54
+ $this->functions[$node->getAttribute('name')] = $node;
55
  }
56
 
57
  // wrap print to check __toString() calls
76
  if ($node instanceof Twig_Node_Module) {
77
  $this->inAModule = false;
78
 
79
+ return new Twig_Node_SandboxedModule($node, $this->filters, $this->tags, $this->functions);
80
  }
81
 
82
  return $node;
vendor/twig/twig/lib/Twig/NodeVisitorInterface.php CHANGED
@@ -41,7 +41,7 @@ interface Twig_NodeVisitorInterface
41
  *
42
  * Priority should be between -10 and 10 (0 is the default).
43
  *
44
- * @return integer The priority level
45
  */
46
  public function getPriority();
47
  }
41
  *
42
  * Priority should be between -10 and 10 (0 is the default).
43
  *
44
+ * @return int The priority level
45
  */
46
  public function getPriority();
47
  }
vendor/twig/twig/lib/Twig/ParserInterface.php CHANGED
@@ -13,7 +13,8 @@
13
  * Interface implemented by parser classes.
14
  *
15
  * @author Fabien Potencier <fabien@symfony.com>
16
- * @deprecated since 1.12 (to be removed in 2.0)
 
17
  */
18
  interface Twig_ParserInterface
19
  {
13
  * Interface implemented by parser classes.
14
  *
15
  * @author Fabien Potencier <fabien@symfony.com>
16
+ *
17
+ * @deprecated since 1.12 (to be removed in 3.0)
18
  */
19
  interface Twig_ParserInterface
20
  {
vendor/twig/twig/lib/Twig/Sandbox/SecurityNotAllowedFilterError.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of Twig.
5
+ *
6
+ * (c) 2009 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
+ * Exception thrown when a not allowed filter is used in a template.
14
+ *
15
+ * @author Martin Hasoň <martin.hason@gmail.com>
16
+ */
17
+ class Twig_Sandbox_SecurityNotAllowedFilterError extends Twig_Sandbox_SecurityError
18
+ {
19
+ private $filterName;
20
+
21
+ public function __construct($message, $functionName, $lineno = -1, $filename = null, Exception $previous = null)
22
+ {
23
+ parent::__construct($message, $lineno, $filename, $previous);
24
+ $this->filterName = $functionName;
25
+ }
26
+
27
+ public function getFilterName()
28
+ {
29
+ return $this->filterName;
30
+ }
31
+ }
vendor/twig/twig/lib/Twig/Sandbox/SecurityNotAllowedFunctionError.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of Twig.
5
+ *
6
+ * (c) 2009 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
+ * Exception thrown when a not allowed function is used in a template.
14
+ *
15
+ * @author Martin Hasoň <martin.hason@gmail.com>
16
+ */
17
+ class Twig_Sandbox_SecurityNotAllowedFunctionError extends Twig_Sandbox_SecurityError
18
+ {
19
+ private $functionName;
20
+
21
+ public function __construct($message, $functionName, $lineno = -1, $filename = null, Exception $previous = null)
22
+ {
23
+ parent::__construct($message, $lineno, $filename, $previous);
24
+ $this->functionName = $functionName;
25
+ }
26
+
27
+ public function getFunctionName()
28
+ {
29
+ return $this->functionName;
30
+ }
31
+ }
vendor/twig/twig/lib/Twig/Sandbox/SecurityNotAllowedTagError.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of Twig.
5
+ *
6
+ * (c) 2009 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
+ * Exception thrown when a not allowed tag is used in a template.
14
+ *
15
+ * @author Martin Hasoň <martin.hason@gmail.com>
16
+ */
17
+ class Twig_Sandbox_SecurityNotAllowedTagError extends Twig_Sandbox_SecurityError
18
+ {
19
+ private $tagName;
20
+
21
+ public function __construct($message, $tagName, $lineno = -1, $filename = null, Exception $previous = null)
22
+ {
23
+ parent::__construct($message, $lineno, $filename, $previous);
24
+ $this->tagName = $tagName;
25
+ }
26
+
27
+ public function getTagName()
28
+ {
29
+ return $this->tagName;
30
+ }
31
+ }
vendor/twig/twig/lib/Twig/Sandbox/SecurityPolicy.php CHANGED
@@ -63,19 +63,19 @@ class Twig_Sandbox_SecurityPolicy implements Twig_Sandbox_SecurityPolicyInterfac
63
  {
64
  foreach ($tags as $tag) {
65
  if (!in_array($tag, $this->allowedTags)) {
66
- throw new Twig_Sandbox_SecurityError(sprintf('Tag "%s" is not allowed.', $tag));
67
  }
68
  }
69
 
70
  foreach ($filters as $filter) {
71
  if (!in_array($filter, $this->allowedFilters)) {
72
- throw new Twig_Sandbox_SecurityError(sprintf('Filter "%s" is not allowed.', $filter));
73
  }
74
  }
75
 
76
  foreach ($functions as $function) {
77
  if (!in_array($function, $this->allowedFunctions)) {
78
- throw new Twig_Sandbox_SecurityError(sprintf('Function "%s" is not allowed.', $function));
79
  }
80
  }
81
  }
63
  {
64
  foreach ($tags as $tag) {
65
  if (!in_array($tag, $this->allowedTags)) {
66
+ throw new Twig_Sandbox_SecurityNotAllowedTagError(sprintf('Tag "%s" is not allowed.', $tag), $tag);
67
  }
68
  }
69
 
70
  foreach ($filters as $filter) {
71
  if (!in_array($filter, $this->allowedFilters)) {
72
+ throw new Twig_Sandbox_SecurityNotAllowedFilterError(sprintf('Filter "%s" is not allowed.', $filter), $filter);
73
  }
74
  }
75
 
76
  foreach ($functions as $function) {
77
  if (!in_array($function, $this->allowedFunctions)) {
78
+ throw new Twig_Sandbox_SecurityNotAllowedFunctionError(sprintf('Function "%s" is not allowed.', $function), $function);
79
  }
80
  }
81
  }
vendor/twig/twig/lib/Twig/Template.php CHANGED
@@ -20,7 +20,7 @@ abstract class Twig_Template implements Twig_TemplateInterface
20
  protected static $cache = array();
21
 
22
  protected $parent;
23
- protected $parents;
24
  protected $env;
25
  protected $blocks;
26
  protected $traits;
@@ -66,15 +66,25 @@ abstract class Twig_Template implements Twig_TemplateInterface
66
  return $this->parent;
67
  }
68
 
69
- $parent = $this->doGetParent($context);
70
- if (false === $parent) {
71
- return false;
72
- } elseif ($parent instanceof Twig_Template) {
73
- $name = $parent->getTemplateName();
74
- $this->parents[$name] = $parent;
75
- $parent = $name;
76
- } elseif (!isset($this->parents[$parent])) {
77
- $this->parents[$parent] = $this->env->loadTemplate($parent);
 
 
 
 
 
 
 
 
 
 
78
  }
79
 
80
  return $this->parents[$parent];
@@ -105,9 +115,9 @@ abstract class Twig_Template implements Twig_TemplateInterface
105
  $name = (string) $name;
106
 
107
  if (isset($this->traits[$name])) {
108
- $this->traits[$name][0]->displayBlock($name, $context, $blocks);
109
  } elseif (false !== $parent = $this->getParent($context)) {
110
- $parent->displayBlock($name, $context, $blocks);
111
  } else {
112
  throw new Twig_Error_Runtime(sprintf('The template has no parent and no traits defining the "%s" block', $name), -1, $this->getTemplateName());
113
  }
@@ -119,18 +129,18 @@ abstract class Twig_Template implements Twig_TemplateInterface
119
  * This method is for internal use only and should never be called
120
  * directly.
121
  *
122
- * @param string $name The block name to display
123
- * @param array $context The context
124
- * @param array $blocks The current set of blocks
 
125
  */
126
- public function displayBlock($name, array $context, array $blocks = array())
127
  {
128
  $name = (string) $name;
129
 
130
- if (isset($blocks[$name])) {
131
  $template = $blocks[$name][0];
132
  $block = $blocks[$name][1];
133
- unset($blocks[$name]);
134
  } elseif (isset($this->blocks[$name])) {
135
  $template = $this->blocks[$name][0];
136
  $block = $this->blocks[$name][1];
@@ -148,7 +158,7 @@ abstract class Twig_Template implements Twig_TemplateInterface
148
  throw new Twig_Error_Runtime(sprintf('An exception has been thrown during the rendering of a template ("%s").', $e->getMessage()), -1, $template->getTemplateName(), $e);
149
  }
150
  } elseif (false !== $parent = $this->getParent($context)) {
151
- $parent->displayBlock($name, $context, array_merge($this->blocks, $blocks));
152
  }
153
  }
154
 
@@ -178,16 +188,17 @@ abstract class Twig_Template implements Twig_TemplateInterface
178
  * This method is for internal use only and should never be called
179
  * directly.
180
  *
181
- * @param string $name The block name to render
182
- * @param array $context The context
183
- * @param array $blocks The current set of blocks
 
184
  *
185
  * @return string The rendered block
186
  */
187
- public function renderBlock($name, array $context, array $blocks = array())
188
  {
189
  ob_start();
190
- $this->displayBlock($name, $context, $blocks);
191
 
192
  return ob_get_clean();
193
  }
@@ -207,7 +218,7 @@ abstract class Twig_Template implements Twig_TemplateInterface
207
  *
208
  * @param string $name The block name
209
  *
210
- * @return Boolean true if the block exists, false otherwise
211
  */
212
  public function hasBlock($name)
213
  {
@@ -249,7 +260,7 @@ abstract class Twig_Template implements Twig_TemplateInterface
249
  */
250
  public function display(array $context, array $blocks = array())
251
  {
252
- $this->displayWithErrorHandling($this->env->mergeGlobals($context), $blocks);
253
  }
254
 
255
  /**
@@ -315,7 +326,7 @@ abstract class Twig_Template implements Twig_TemplateInterface
315
  *
316
  * @param array $context The context
317
  * @param string $item The variable to return from the context
318
- * @param Boolean $ignoreStrictCheck Whether to ignore the strict variable check or not
319
  *
320
  * @return The content of the context variable
321
  *
@@ -325,7 +336,7 @@ abstract class Twig_Template implements Twig_TemplateInterface
325
  {
326
  if (!array_key_exists($item, $context)) {
327
  if ($ignoreStrictCheck || !$this->env->isStrictVariables()) {
328
- return null;
329
  }
330
 
331
  throw new Twig_Error_Runtime(sprintf('Variable "%s" does not exist', $item), -1, $this->getTemplateName());
@@ -341,8 +352,8 @@ abstract class Twig_Template implements Twig_TemplateInterface
341
  * @param mixed $item The item to get from the array or object
342
  * @param array $arguments An array of arguments to pass if the item is an object method
343
  * @param string $type The type of attribute (@see Twig_Template constants)
344
- * @param Boolean $isDefinedTest Whether this is only a defined check
345
- * @param Boolean $ignoreStrictCheck Whether to ignore the strict attribute check or not
346
  *
347
  * @return mixed The attribute value, or a Boolean when $isDefinedTest is true, or null when the attribute is not set and $ignoreStrictCheck is true
348
  *
@@ -370,7 +381,7 @@ abstract class Twig_Template implements Twig_TemplateInterface
370
  }
371
 
372
  if ($ignoreStrictCheck || !$this->env->isStrictVariables()) {
373
- return null;
374
  }
375
 
376
  if ($object instanceof ArrayAccess) {
@@ -378,7 +389,11 @@ abstract class Twig_Template implements Twig_TemplateInterface
378
  } elseif (is_object($object)) {
379
  $message = sprintf('Impossible to access a key "%s" on an object of class "%s" that does not implement ArrayAccess interface', $item, get_class($object));
380
  } elseif (is_array($object)) {
381
- $message = sprintf('Key "%s" for array with keys "%s" does not exist', $arrayItem, implode(', ', array_keys($object)));
 
 
 
 
382
  } elseif (Twig_Template::ARRAY_CALL === $type) {
383
  $message = sprintf('Impossible to access a key ("%s") on a %s variable ("%s")', $item, gettype($object), $object);
384
  } else {
@@ -395,14 +410,12 @@ abstract class Twig_Template implements Twig_TemplateInterface
395
  }
396
 
397
  if ($ignoreStrictCheck || !$this->env->isStrictVariables()) {
398
- return null;
399
  }
400
 
401
  throw new Twig_Error_Runtime(sprintf('Impossible to invoke a method ("%s") on a %s variable ("%s")', $item, gettype($object), $object), -1, $this->getTemplateName());
402
  }
403
 
404
- $class = get_class($object);
405
-
406
  // object property
407
  if (Twig_Template::METHOD_CALL !== $type) {
408
  if (isset($object->$item) || array_key_exists((string) $item, $object)) {
@@ -418,6 +431,8 @@ abstract class Twig_Template implements Twig_TemplateInterface
418
  }
419
  }
420
 
 
 
421
  // object method
422
  if (!isset(self::$cache[$class]['methods'])) {
423
  self::$cache[$class]['methods'] = array_change_key_case(array_flip(get_class_methods($object)));
@@ -440,7 +455,7 @@ abstract class Twig_Template implements Twig_TemplateInterface
440
  }
441
 
442
  if ($ignoreStrictCheck || !$this->env->isStrictVariables()) {
443
- return null;
444
  }
445
 
446
  throw new Twig_Error_Runtime(sprintf('Method "%s" for object "%s" does not exist', $item, get_class($object)), -1, $this->getTemplateName());
@@ -460,7 +475,7 @@ abstract class Twig_Template implements Twig_TemplateInterface
460
  $ret = call_user_func_array(array($object, $method), $arguments);
461
  } catch (BadMethodCallException $e) {
462
  if ($call && ($ignoreStrictCheck || !$this->env->isStrictVariables())) {
463
- return null;
464
  }
465
  throw $e;
466
  }
20
  protected static $cache = array();
21
 
22
  protected $parent;
23
+ protected $parents = array();
24
  protected $env;
25
  protected $blocks;
26
  protected $traits;
66
  return $this->parent;
67
  }
68
 
69
+ try {
70
+ $parent = $this->doGetParent($context);
71
+
72
+ if (false === $parent) {
73
+ return false;
74
+ }
75
+
76
+ if ($parent instanceof Twig_Template) {
77
+ return $this->parents[$parent->getTemplateName()] = $parent;
78
+ }
79
+
80
+ if (!isset($this->parents[$parent])) {
81
+ $this->parents[$parent] = $this->env->loadTemplate($parent);
82
+ }
83
+ } catch (Twig_Error_Loader $e) {
84
+ $e->setTemplateFile(null);
85
+ $e->guess();
86
+
87
+ throw $e;
88
  }
89
 
90
  return $this->parents[$parent];
115
  $name = (string) $name;
116
 
117
  if (isset($this->traits[$name])) {
118
+ $this->traits[$name][0]->displayBlock($name, $context, $blocks, false);
119
  } elseif (false !== $parent = $this->getParent($context)) {
120
+ $parent->displayBlock($name, $context, $blocks, false);
121
  } else {
122
  throw new Twig_Error_Runtime(sprintf('The template has no parent and no traits defining the "%s" block', $name), -1, $this->getTemplateName());
123
  }
129
  * This method is for internal use only and should never be called
130
  * directly.
131
  *
132
+ * @param string $name The block name to display
133
+ * @param array $context The context
134
+ * @param array $blocks The current set of blocks
135
+ * @param bool $useBlocks Whether to use the current set of blocks
136
  */
137
+ public function displayBlock($name, array $context, array $blocks = array(), $useBlocks = true)
138
  {
139
  $name = (string) $name;
140
 
141
+ if ($useBlocks && isset($blocks[$name])) {
142
  $template = $blocks[$name][0];
143
  $block = $blocks[$name][1];
 
144
  } elseif (isset($this->blocks[$name])) {
145
  $template = $this->blocks[$name][0];
146
  $block = $this->blocks[$name][1];
158
  throw new Twig_Error_Runtime(sprintf('An exception has been thrown during the rendering of a template ("%s").', $e->getMessage()), -1, $template->getTemplateName(), $e);
159
  }
160
  } elseif (false !== $parent = $this->getParent($context)) {
161
+ $parent->displayBlock($name, $context, array_merge($this->blocks, $blocks), false);
162
  }
163
  }
164
 
188
  * This method is for internal use only and should never be called
189
  * directly.
190
  *
191
+ * @param string $name The block name to render
192
+ * @param array $context The context
193
+ * @param array $blocks The current set of blocks
194
+ * @param bool $useBlocks Whether to use the current set of blocks
195
  *
196
  * @return string The rendered block
197
  */
198
+ public function renderBlock($name, array $context, array $blocks = array(), $useBlocks = true)
199
  {
200
  ob_start();
201
+ $this->displayBlock($name, $context, $blocks, $useBlocks);
202
 
203
  return ob_get_clean();
204
  }
218
  *
219
  * @param string $name The block name
220
  *
221
+ * @return bool true if the block exists, false otherwise
222
  */
223
  public function hasBlock($name)
224
  {
260
  */
261
  public function display(array $context, array $blocks = array())
262
  {
263
+ $this->displayWithErrorHandling($this->env->mergeGlobals($context), array_merge($this->blocks, $blocks));
264
  }
265
 
266
  /**
326
  *
327
  * @param array $context The context
328
  * @param string $item The variable to return from the context
329
+ * @param bool $ignoreStrictCheck Whether to ignore the strict variable check or not
330
  *
331
  * @return The content of the context variable
332
  *
336
  {
337
  if (!array_key_exists($item, $context)) {
338
  if ($ignoreStrictCheck || !$this->env->isStrictVariables()) {
339
+ return;
340
  }
341
 
342
  throw new Twig_Error_Runtime(sprintf('Variable "%s" does not exist', $item), -1, $this->getTemplateName());
352
  * @param mixed $item The item to get from the array or object
353
  * @param array $arguments An array of arguments to pass if the item is an object method
354
  * @param string $type The type of attribute (@see Twig_Template constants)
355
+ * @param bool $isDefinedTest Whether this is only a defined check
356
+ * @param bool $ignoreStrictCheck Whether to ignore the strict attribute check or not
357
  *
358
  * @return mixed The attribute value, or a Boolean when $isDefinedTest is true, or null when the attribute is not set and $ignoreStrictCheck is true
359
  *
381
  }
382
 
383
  if ($ignoreStrictCheck || !$this->env->isStrictVariables()) {
384
+ return;
385
  }
386
 
387
  if ($object instanceof ArrayAccess) {
389
  } elseif (is_object($object)) {
390
  $message = sprintf('Impossible to access a key "%s" on an object of class "%s" that does not implement ArrayAccess interface', $item, get_class($object));
391
  } elseif (is_array($object)) {
392
+ if (empty($object)) {
393
+ $message = sprintf('Key "%s" does not exist as the array is empty', $arrayItem);
394
+ } else {
395
+ $message = sprintf('Key "%s" for array with keys "%s" does not exist', $arrayItem, implode(', ', array_keys($object)));
396
+ }
397
  } elseif (Twig_Template::ARRAY_CALL === $type) {
398
  $message = sprintf('Impossible to access a key ("%s") on a %s variable ("%s")', $item, gettype($object), $object);
399
  } else {
410
  }
411
 
412
  if ($ignoreStrictCheck || !$this->env->isStrictVariables()) {
413
+ return;
414
  }
415
 
416
  throw new Twig_Error_Runtime(sprintf('Impossible to invoke a method ("%s") on a %s variable ("%s")', $item, gettype($object), $object), -1, $this->getTemplateName());
417
  }
418
 
 
 
419
  // object property
420
  if (Twig_Template::METHOD_CALL !== $type) {
421
  if (isset($object->$item) || array_key_exists((string) $item, $object)) {
431
  }
432
  }
433
 
434
+ $class = get_class($object);
435
+
436
  // object method
437
  if (!isset(self::$cache[$class]['methods'])) {
438
  self::$cache[$class]['methods'] = array_change_key_case(array_flip(get_class_methods($object)));
455
  }
456
 
457
  if ($ignoreStrictCheck || !$this->env->isStrictVariables()) {
458
+ return;
459
  }
460
 
461
  throw new Twig_Error_Runtime(sprintf('Method "%s" for object "%s" does not exist', $item, get_class($object)), -1, $this->getTemplateName());
475
  $ret = call_user_func_array(array($object, $method), $arguments);
476
  } catch (BadMethodCallException $e) {
477
  if ($call && ($ignoreStrictCheck || !$this->env->isStrictVariables())) {
478
+ return;
479
  }
480
  throw $e;
481
  }
vendor/twig/twig/lib/Twig/TemplateInterface.php CHANGED
@@ -13,7 +13,8 @@
13
  * Interface implemented by all compiled templates.
14
  *
15
  * @author Fabien Potencier <fabien@symfony.com>
16
- * @deprecated since 1.12 (to be removed in 2.0)
 
17
  */
18
  interface Twig_TemplateInterface
19
  {
13
  * Interface implemented by all compiled templates.
14
  *
15
  * @author Fabien Potencier <fabien@symfony.com>
16
+ *
17
+ * @deprecated since 1.12 (to be removed in 3.0)
18
  */
19
  interface Twig_TemplateInterface
20
  {
vendor/twig/twig/lib/Twig/Token.php CHANGED
@@ -38,9 +38,9 @@ class Twig_Token
38
  /**
39
  * Constructor.
40
  *
41
- * @param integer $type The type of the token
42
  * @param string $value The token value
43
- * @param integer $lineno The line position in the source
44
  */
45
  public function __construct($type, $value, $lineno)
46
  {
@@ -67,10 +67,10 @@ class Twig_Token
67
  * * type and value (or array of possible values)
68
  * * just value (or array of possible values) (NAME_TYPE is used as type)
69
  *
70
- * @param array|integer $type The type to test
71
  * @param array|string|null $values The token value
72
  *
73
- * @return Boolean
74
  */
75
  public function test($type, $values = null)
76
  {
@@ -89,7 +89,7 @@ class Twig_Token
89
  /**
90
  * Gets the line.
91
  *
92
- * @return integer The source line
93
  */
94
  public function getLine()
95
  {
@@ -99,7 +99,7 @@ class Twig_Token
99
  /**
100
  * Gets the token type.
101
  *
102
- * @return integer The token type
103
  */
104
  public function getType()
105
  {
@@ -119,8 +119,8 @@ class Twig_Token
119
  /**
120
  * Returns the constant representation (internal) of a given type.
121
  *
122
- * @param integer $type The type as an integer
123
- * @param Boolean $short Whether to return a short representation or not
124
  *
125
  * @return string The string representation
126
  */
@@ -176,7 +176,7 @@ class Twig_Token
176
  /**
177
  * Returns the english representation of a given type.
178
  *
179
- * @param integer $type The type as an integer
180
  *
181
  * @return string The string representation
182
  */
38
  /**
39
  * Constructor.
40
  *
41
+ * @param int $type The type of the token
42
  * @param string $value The token value
43
+ * @param int $lineno The line position in the source
44
  */
45
  public function __construct($type, $value, $lineno)
46
  {
67
  * * type and value (or array of possible values)
68
  * * just value (or array of possible values) (NAME_TYPE is used as type)
69
  *
70
+ * @param array|int $type The type to test
71
  * @param array|string|null $values The token value
72
  *
73
+ * @return bool
74
  */
75
  public function test($type, $values = null)
76
  {
89
  /**
90
  * Gets the line.
91
  *
92
+ * @return int The source line
93
  */
94
  public function getLine()
95
  {
99
  /**
100
  * Gets the token type.
101
  *
102
+ * @return int The token type
103
  */
104
  public function getType()
105
  {
119
  /**
120
  * Returns the constant representation (internal) of a given type.
121
  *
122
+ * @param int $type The type as an integer
123
+ * @param bool $short Whether to return a short representation or not
124
  *
125
  * @return string The string representation
126
  */
176
  /**
177
  * Returns the english representation of a given type.
178
  *
179
+ * @param int $type The type as an integer
180
  *
181
  * @return string The string representation
182
  */
vendor/twig/twig/lib/Twig/TokenStream.php CHANGED
@@ -101,7 +101,7 @@ class Twig_TokenStream
101
  /**
102
  * Looks at the next token.
103
  *
104
- * @param integer $number
105
  *
106
  * @return Twig_Token
107
  */
@@ -117,7 +117,7 @@ class Twig_TokenStream
117
  /**
118
  * Tests the current token
119
  *
120
- * @return Boolean
121
  */
122
  public function test($primary, $secondary = null)
123
  {
@@ -127,7 +127,7 @@ class Twig_TokenStream
127
  /**
128
  * Checks if end of stream was reached
129
  *
130
- * @return Boolean
131
  */
132
  public function isEOF()
133
  {
101
  /**
102
  * Looks at the next token.
103
  *
104
+ * @param int $number
105
  *
106
  * @return Twig_Token
107
  */
117
  /**
118
  * Tests the current token
119
  *
120
+ * @return bool
121
  */
122
  public function test($primary, $secondary = null)
123
  {
127
  /**
128
  * Checks if end of stream was reached
129
  *
130
+ * @return bool
131
  */
132
  public function isEOF()
133
  {
vendor/twig/twig/test/Twig/Tests/EnvironmentTest.php CHANGED
@@ -48,7 +48,7 @@ class Twig_Tests_EnvironmentTest extends PHPUnit_Framework_TestCase
48
  // globals can be added after calling getGlobals
49
  $twig = new Twig_Environment(new Twig_Loader_String());
50
  $twig->addGlobal('foo', 'foo');
51
- $globals = $twig->getGlobals();
52
  $twig->addGlobal('foo', 'bar');
53
  $globals = $twig->getGlobals();
54
  $this->assertEquals('bar', $globals['foo']);
@@ -65,7 +65,7 @@ class Twig_Tests_EnvironmentTest extends PHPUnit_Framework_TestCase
65
  // globals can be modified after extensions init
66
  $twig = new Twig_Environment(new Twig_Loader_String());
67
  $twig->addGlobal('foo', 'foo');
68
- $globals = $twig->getGlobals();
69
  $twig->getFunctions();
70
  $twig->addGlobal('foo', 'bar');
71
  $globals = $twig->getGlobals();
@@ -74,7 +74,7 @@ class Twig_Tests_EnvironmentTest extends PHPUnit_Framework_TestCase
74
  // globals can be modified after extensions and runtime init
75
  $twig = new Twig_Environment(new Twig_Loader_String());
76
  $twig->addGlobal('foo', 'foo');
77
- $globals = $twig->getGlobals();
78
  $twig->getFunctions();
79
  $twig->initRuntime();
80
  $twig->addGlobal('foo', 'bar');
48
  // globals can be added after calling getGlobals
49
  $twig = new Twig_Environment(new Twig_Loader_String());
50
  $twig->addGlobal('foo', 'foo');
51
+ $twig->getGlobals();
52
  $twig->addGlobal('foo', 'bar');
53
  $globals = $twig->getGlobals();
54
  $this->assertEquals('bar', $globals['foo']);
65
  // globals can be modified after extensions init
66
  $twig = new Twig_Environment(new Twig_Loader_String());
67
  $twig->addGlobal('foo', 'foo');
68
+ $twig->getGlobals();
69
  $twig->getFunctions();
70
  $twig->addGlobal('foo', 'bar');
71
  $globals = $twig->getGlobals();
74
  // globals can be modified after extensions and runtime init
75
  $twig = new Twig_Environment(new Twig_Loader_String());
76
  $twig->addGlobal('foo', 'foo');
77
+ $twig->getGlobals();
78
  $twig->getFunctions();
79
  $twig->initRuntime();
80
  $twig->addGlobal('foo', 'bar');
vendor/twig/twig/test/Twig/Tests/Extension/CoreTest.php CHANGED
@@ -130,6 +130,24 @@ class Twig_Tests_Extension_CoreTest extends PHPUnit_Framework_TestCase
130
  {
131
  twig_escape_filter(new Twig_Environment(), 'foo', 'bar');
132
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
133
  }
134
 
135
  function foo_escaper_for_test(Twig_Environment $env, $string, $charset)
130
  {
131
  twig_escape_filter(new Twig_Environment(), 'foo', 'bar');
132
  }
133
+
134
+ public function testTwigFirst()
135
+ {
136
+ $twig = new Twig_Environment();
137
+ $this->assertEquals('a', twig_first($twig, 'abc'));
138
+ $this->assertEquals(1, twig_first($twig, array(1, 2, 3)));
139
+ $this->assertSame('', twig_first($twig, null));
140
+ $this->assertSame('', twig_first($twig, ''));
141
+ }
142
+
143
+ public function testTwigLast()
144
+ {
145
+ $twig = new Twig_Environment();
146
+ $this->assertEquals('c', twig_last($twig, 'abc'));
147
+ $this->assertEquals(3, twig_last($twig, array(1, 2, 3)));
148
+ $this->assertSame('', twig_last($twig, null));
149
+ $this->assertSame('', twig_last($twig, ''));
150
+ }
151
  }
152
 
153
  function foo_escaper_for_test(Twig_Environment $env, $string, $charset)
vendor/twig/twig/test/Twig/Tests/Extension/SandboxTest.php CHANGED
@@ -33,13 +33,13 @@ class Twig_Tests_Extension_SandboxTest extends PHPUnit_Framework_TestCase
33
  '1_basic9' => '{{ obj.foobar }}{{ obj.fooBar }}',
34
  '1_basic' => '{% if obj.foo %}{{ obj.foo|upper }}{% endif %}',
35
  '1_layout' => '{% block content %}{% endblock %}',
36
- '1_child' => '{% extends "1_layout" %}{% block content %}{{ "a"|json_encode }}{% endblock %}',
37
  );
38
  }
39
 
40
  /**
41
  * @expectedException Twig_Sandbox_SecurityError
42
- * @expectedExceptionMessage Filter "json_encode" is not allowed in "1_child".
43
  */
44
  public function testSandboxWithInheritance()
45
  {
@@ -111,6 +111,11 @@ class Twig_Tests_Extension_SandboxTest extends PHPUnit_Framework_TestCase
111
  $this->assertEquals('foo', $twig->loadTemplate('1_basic5')->render(self::$params), 'Sandbox allow some methods');
112
  $this->assertEquals(1, FooObject::$called['__toString'], 'Sandbox only calls method once');
113
 
 
 
 
 
 
114
  $twig = $this->getEnvironment(true, array(), self::$templates, array(), array('upper'));
115
  $this->assertEquals('FABIEN', $twig->loadTemplate('1_basic2')->render(self::$params), 'Sandbox allow some filters');
116
 
33
  '1_basic9' => '{{ obj.foobar }}{{ obj.fooBar }}',
34
  '1_basic' => '{% if obj.foo %}{{ obj.foo|upper }}{% endif %}',
35
  '1_layout' => '{% block content %}{% endblock %}',
36
+ '1_child' => "{% extends \"1_layout\" %}\n{% block content %}\n{{ \"a\"|json_encode }}\n{% endblock %}",
37
  );
38
  }
39
 
40
  /**
41
  * @expectedException Twig_Sandbox_SecurityError
42
+ * @expectedExceptionMessage Filter "json_encode" is not allowed in "1_child" at line 3.
43
  */
44
  public function testSandboxWithInheritance()
45
  {
111
  $this->assertEquals('foo', $twig->loadTemplate('1_basic5')->render(self::$params), 'Sandbox allow some methods');
112
  $this->assertEquals(1, FooObject::$called['__toString'], 'Sandbox only calls method once');
113
 
114
+ $twig = $this->getEnvironment(false, array(), self::$templates);
115
+ FooObject::reset();
116
+ $this->assertEquals('foo', $twig->loadTemplate('1_basic5')->render(self::$params), 'Sandbox allows __toString when sandbox disabled');
117
+ $this->assertEquals(1, FooObject::$called['__toString'], 'Sandbox only calls method once');
118
+
119
  $twig = $this->getEnvironment(true, array(), self::$templates, array(), array('upper'));
120
  $this->assertEquals('FABIEN', $twig->loadTemplate('1_basic2')->render(self::$params), 'Sandbox allow some filters');
121
 
vendor/twig/twig/test/Twig/Tests/FileCachingTest.php CHANGED
@@ -32,7 +32,7 @@ class Twig_Tests_FileCachingTest extends PHPUnit_Framework_TestCase
32
  public function testWritingCacheFiles()
33
  {
34
  $name = 'This is just text.';
35
- $template = $this->env->loadTemplate($name);
36
  $cacheFileName = $this->env->getCacheFilename($name);
37
 
38
  $this->assertTrue(file_exists($cacheFileName), 'Cache file does not exist.');
@@ -42,7 +42,7 @@ class Twig_Tests_FileCachingTest extends PHPUnit_Framework_TestCase
42
  public function testClearingCacheFiles()
43
  {
44
  $name = 'I will be deleted.';
45
- $template = $this->env->loadTemplate($name);
46
  $cacheFileName = $this->env->getCacheFilename($name);
47
 
48
  $this->assertTrue(file_exists($cacheFileName), 'Cache file does not exist.');
32
  public function testWritingCacheFiles()
33
  {
34
  $name = 'This is just text.';
35
+ $this->env->loadTemplate($name);
36
  $cacheFileName = $this->env->getCacheFilename($name);
37
 
38
  $this->assertTrue(file_exists($cacheFileName), 'Cache file does not exist.');
42
  public function testClearingCacheFiles()
43
  {
44
  $name = 'I will be deleted.';
45
+ $this->env->loadTemplate($name);
46
  $cacheFileName = $this->env->getCacheFilename($name);
47
 
48
  $this->assertTrue(file_exists($cacheFileName), 'Cache file does not exist.');
vendor/twig/twig/test/Twig/Tests/Fixtures/exceptions/undefined_parent.test ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ --TEST--
2
+ Exception for an undefined parent
3
+ --TEMPLATE--
4
+ {% extends 'foo.html' %}
5
+
6
+ {% set foo = "foo" %}
7
+ --EXCEPTION--
8
+ Twig_Error_Loader: Template "foo.html" is not defined in "index.twig" at line 2.
vendor/twig/twig/test/Twig/Tests/Fixtures/exceptions/undefined_trait.test CHANGED
@@ -6,4 +6,4 @@ Exception for an undefined trait
6
  {% block bar %}
7
  {% endblock %}
8
  --EXCEPTION--
9
- Twig_Error_Runtime: Block "foobar" is not defined in trait "foo" in "index.twig".
6
  {% block bar %}
7
  {% endblock %}
8
  --EXCEPTION--
9
+ Twig_Error_Runtime: Block "foobar" is not defined in trait "foo" in "index.twig" at line 2.
vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/bitwise.test CHANGED
@@ -4,7 +4,7 @@ Twig supports bitwise operations
4
  {{ 1 b-and 5 }}
5
  {{ 1 b-or 5 }}
6
  {{ 1 b-xor 5 }}
7
- {{ (1 and 0 b-or 0) is sameas(1 and (0 b-or 0)) ? 'ok' : 'ko' }}
8
  --DATA--
9
  return array()
10
  --EXPECT--
4
  {{ 1 b-and 5 }}
5
  {{ 1 b-or 5 }}
6
  {{ 1 b-xor 5 }}
7
+ {{ (1 and 0 b-or 0) is same as(1 and (0 b-or 0)) ? 'ok' : 'ko' }}
8
  --DATA--
9
  return array()
10
  --EXPECT--
vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/divisibleby.test CHANGED
@@ -1,8 +1,6 @@
1
  --TEST--
2
  Twig supports the "divisible by" operator
3
  --TEMPLATE--
4
- {{ 8 is divisibleby(2) ? 'OK' }}
5
- {{ 8 is not divisibleby(3) ? 'OK' }}
6
  {{ 8 is divisible by(2) ? 'OK' }}
7
  {{ 8 is not divisible by(3) ? 'OK' }}
8
  {{ 8 is divisible by (2) ? 'OK' }}
@@ -17,5 +15,3 @@ OK
17
  OK
18
  OK
19
  OK
20
- OK
21
- OK
1
  --TEST--
2
  Twig supports the "divisible by" operator
3
  --TEMPLATE--
 
 
4
  {{ 8 is divisible by(2) ? 'OK' }}
5
  {{ 8 is not divisible by(3) ? 'OK' }}
6
  {{ 8 is divisible by (2) ? 'OK' }}
15
  OK
16
  OK
17
  OK
 
 
vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/ends_with.test CHANGED
@@ -4,9 +4,23 @@ Twig supports the "ends with" operator
4
  {{ 'foo' ends with 'o' ? 'OK' : 'KO' }}
5
  {{ not ('foo' ends with 'f') ? 'OK' : 'KO' }}
6
  {{ not ('foo' ends with 'foowaytoolong') ? 'OK' : 'KO' }}
 
 
 
 
 
 
 
7
  --DATA--
8
  return array()
9
  --EXPECT--
10
  OK
11
  OK
12
  OK
 
 
 
 
 
 
 
4
  {{ 'foo' ends with 'o' ? 'OK' : 'KO' }}
5
  {{ not ('foo' ends with 'f') ? 'OK' : 'KO' }}
6
  {{ not ('foo' ends with 'foowaytoolong') ? 'OK' : 'KO' }}
7
+ {{ 'foo' ends with '' ? 'OK' : 'KO' }}
8
+ {{ '1' ends with true ? 'OK' : 'KO' }}
9
+ {{ 1 ends with true ? 'OK' : 'KO' }}
10
+ {{ 0 ends with false ? 'OK' : 'KO' }}
11
+ {{ '' ends with false ? 'OK' : 'KO' }}
12
+ {{ false ends with false ? 'OK' : 'KO' }}
13
+ {{ false ends with '' ? 'OK' : 'KO' }}
14
  --DATA--
15
  return array()
16
  --EXPECT--
17
  OK
18
  OK
19
  OK
20
+ OK
21
+ KO
22
+ KO
23
+ KO
24
+ KO
25
+ KO
26
+ KO
vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/negative_numbers.test ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ --TEST--
2
+ Twig manages negative numbers correctly
3
+ --TEMPLATE--
4
+ {{ -1 }}
5
+ {{ - 1 }}
6
+ {{ 5 - 1 }}
7
+ {{ 5-1 }}
8
+ {{ 5 + -1 }}
9
+ {{ 5 + - 1 }}
10
+ --DATA--
11
+ return array()
12
+ --EXPECT--
13
+ -1
14
+ -1
15
+ 4
16
+ 4
17
+ 4
18
+ 4
vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/sameas.test CHANGED
@@ -1,8 +1,8 @@
1
  --TEST--
2
  Twig supports the "same as" operator
3
  --TEMPLATE--
4
- {{ 1 is sameas(1) ? 'OK' }}
5
- {{ 1 is not sameas(true) ? 'OK' }}
6
  {{ 1 is same as(1) ? 'OK' }}
7
  {{ 1 is not same as(true) ? 'OK' }}
8
  {{ 1 is same as (1) ? 'OK' }}
1
  --TEST--
2
  Twig supports the "same as" operator
3
  --TEMPLATE--
4
+ {{ 1 is same as(1) ? 'OK' }}
5
+ {{ 1 is not same as(true) ? 'OK' }}
6
  {{ 1 is same as(1) ? 'OK' }}
7
  {{ 1 is not same as(true) ? 'OK' }}
8
  {{ 1 is same as (1) ? 'OK' }}
vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/starts_with.test CHANGED
@@ -7,6 +7,11 @@ Twig supports the "starts with" operator
7
  {{ 'foo' starts with 'f' ? 'OK' : 'KO' }}
8
  {{ 'foo' starts
9
  with 'f' ? 'OK' : 'KO' }}
 
 
 
 
 
10
  --DATA--
11
  return array()
12
  --EXPECT--
@@ -15,3 +20,8 @@ OK
15
  OK
16
  OK
17
  OK
 
 
 
 
 
7
  {{ 'foo' starts with 'f' ? 'OK' : 'KO' }}
8
  {{ 'foo' starts
9
  with 'f' ? 'OK' : 'KO' }}
10
+ {{ 'foo' starts with '' ? 'OK' : 'KO' }}
11
+ {{ '1' starts with true ? 'OK' : 'KO' }}
12
+ {{ '' starts with false ? 'OK' : 'KO' }}
13
+ {{ 'a' starts with false ? 'OK' : 'KO' }}
14
+ {{ false starts with '' ? 'OK' : 'KO' }}
15
  --DATA--
16
  return array()
17
  --EXPECT--
20
  OK
21
  OK
22
  OK
23
+ OK
24
+ KO
25
+ KO
26
+ KO
27
+ KO
vendor/twig/twig/test/Twig/Tests/Fixtures/expressions/unary_macro_arguments.test ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ --TEST--
2
+ Twig manages negative numbers as default parameters
3
+ --TEMPLATE--
4
+ {% import _self as macros %}
5
+ {{ macros.negative_number1() }}
6
+ {{ macros.negative_number2() }}
7
+ {{ macros.negative_number3() }}
8
+ {{ macros.positive_number1() }}
9
+ {{ macros.positive_number2() }}
10
+ {% macro negative_number1(nb=-1) %}{{ nb }}{% endmacro %}
11
+ {% macro negative_number2(nb = --1) %}{{ nb }}{% endmacro %}
12
+ {% macro negative_number3(nb = - 1) %}{{ nb }}{% endmacro %}
13
+ {% macro positive_number1(nb = +1) %}{{ nb }}{% endmacro %}
14
+ {% macro positive_number2(nb = ++1) %}{{ nb }}{% endmacro %}
15
+ --DATA--
16
+ return array()
17
+ --EXPECT--
18
+ -1
19
+ 1
20
+ -1
21
+ 1
22
+ 1
vendor/twig/twig/test/Twig/Tests/Fixtures/filters/{batch_float.php → batch_float.test} RENAMED
@@ -15,17 +15,15 @@ return array('items' => array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'))
15
  <div class=item>a</div>
16
  <div class=item>b</div>
17
  <div class=item>c</div>
 
18
  </div>
19
  <div class=row>
20
- <div class=item>d</div>
21
  <div class=item>e</div>
22
  <div class=item>f</div>
23
- </div>
24
- <div class=row>
25
  <div class=item>g</div>
26
  <div class=item>h</div>
27
- <div class=item>i</div>
28
  </div>
29
  <div class=row>
 
30
  <div class=item>j</div>
31
  </div>
15
  <div class=item>a</div>
16
  <div class=item>b</div>
17
  <div class=item>c</div>
18
+ <div class=item>d</div>
19
  </div>
20
  <div class=row>
 
21
  <div class=item>e</div>
22
  <div class=item>f</div>
 
 
23
  <div class=item>g</div>
24
  <div class=item>h</div>
 
25
  </div>
26
  <div class=row>
27
+ <div class=item>i</div>
28
  <div class=item>j</div>
29
  </div>
vendor/twig/twig/test/Twig/Tests/Fixtures/filters/date.test CHANGED
@@ -31,6 +31,13 @@
31
  {{ date6|date('e', false) }}
32
 
33
  {{ date7|date }}
 
 
 
 
 
 
 
34
  --DATA--
35
  date_default_timezone_set('Europe/Paris');
36
  return array(
@@ -40,7 +47,7 @@ return array(
40
  'date4' => 1286199900, // DateTime::createFromFormat('Y-m-d H:i', '2010-10-04 13:45', new DateTimeZone('UTC'))->getTimestamp() -- A unixtimestamp is always GMT
41
  'date5' => -189291360, // DateTime::createFromFormat('Y-m-d H:i', '1964-01-02 03:04', new DateTimeZone('UTC'))->getTimestamp(),
42
  'date6' => new DateTime('2010-10-04 13:45', new DateTimeZone('America/New_York')),
43
- 'date7' => '2010-01-28T15:00:00+05:00',
44
  'timezone1' => new DateTimeZone('America/New_York'),
45
  )
46
  --EXPECT--
@@ -73,4 +80,11 @@ January 2, 1964 04:04
73
  Europe/Paris
74
  America/New_York
75
 
76
- January 28, 2010 11:00
 
 
 
 
 
 
 
31
  {{ date6|date('e', false) }}
32
 
33
  {{ date7|date }}
34
+ {{ date7|date(timezone='Europe/Paris') }}
35
+ {{ date7|date(timezone='Asia/Hong_Kong') }}
36
+ {{ date7|date(timezone=false) }}
37
+ {{ date7|date(timezone='Indian/Mauritius') }}
38
+
39
+ {{ '2010-01-28 15:00:00'|date(timezone="Europe/Paris") }}
40
+ {{ '2010-01-28 15:00:00'|date(timezone="Asia/Hong_Kong") }}
41
  --DATA--
42
  date_default_timezone_set('Europe/Paris');
43
  return array(
47
  'date4' => 1286199900, // DateTime::createFromFormat('Y-m-d H:i', '2010-10-04 13:45', new DateTimeZone('UTC'))->getTimestamp() -- A unixtimestamp is always GMT
48
  'date5' => -189291360, // DateTime::createFromFormat('Y-m-d H:i', '1964-01-02 03:04', new DateTimeZone('UTC'))->getTimestamp(),
49
  'date6' => new DateTime('2010-10-04 13:45', new DateTimeZone('America/New_York')),
50
+ 'date7' => '2010-01-28T15:00:00+04:00',
51
  'timezone1' => new DateTimeZone('America/New_York'),
52
  )
53
  --EXPECT--
80
  Europe/Paris
81
  America/New_York
82
 
83
+ January 28, 2010 12:00
84
+ January 28, 2010 12:00
85
+ January 28, 2010 19:00
86
+ January 28, 2010 15:00
87
+ January 28, 2010 15:00
88
+
89
+ January 28, 2010 15:00
90
+ January 28, 2010 22:00
vendor/twig/twig/test/Twig/Tests/Fixtures/filters/date_immutable.test CHANGED
@@ -8,6 +8,7 @@ version_compare(phpversion(), '5.5.0', '>=')
8
  {{ date1|date('d/m/Y H:i:s', 'Asia/Hong_Kong') }}
9
  {{ date1|date('d/m/Y H:i:s', timezone1) }}
10
  {{ date1|date('d/m/Y H:i:s') }}
 
11
 
12
  {{ date2|date('d/m/Y H:i:s P', 'Europe/Paris') }}
13
  {{ date2|date('d/m/Y H:i:s P', 'Asia/Hong_Kong') }}
@@ -27,6 +28,7 @@ October 4, 2010 13:45
27
  04/10/2010 19:45:00
28
  04/10/2010 07:45:00
29
  04/10/2010 13:45:00
 
30
 
31
  04/10/2010 19:45:00 +02:00
32
  05/10/2010 01:45:00 +08:00
8
  {{ date1|date('d/m/Y H:i:s', 'Asia/Hong_Kong') }}
9
  {{ date1|date('d/m/Y H:i:s', timezone1) }}
10
  {{ date1|date('d/m/Y H:i:s') }}
11
+ {{ date1|date_modify('+1 hour')|date('d/m/Y H:i:s') }}
12
 
13
  {{ date2|date('d/m/Y H:i:s P', 'Europe/Paris') }}
14
  {{ date2|date('d/m/Y H:i:s P', 'Asia/Hong_Kong') }}
28
  04/10/2010 19:45:00
29
  04/10/2010 07:45:00
30
  04/10/2010 13:45:00
31
+ 04/10/2010 14:45:00
32
 
33
  04/10/2010 19:45:00 +02:00
34
  05/10/2010 01:45:00 +08:00
vendor/twig/twig/test/Twig/Tests/Fixtures/filters/default.test CHANGED
@@ -2,42 +2,42 @@
2
  "default" filter
3
  --TEMPLATE--
4
  Variable:
5
- {{ definedVar |default('default') is sameas('default') ? 'ko' : 'ok' }}
6
- {{ zeroVar |default('default') is sameas('default') ? 'ko' : 'ok' }}
7
- {{ emptyVar |default('default') is sameas('default') ? 'ok' : 'ko' }}
8
- {{ nullVar |default('default') is sameas('default') ? 'ok' : 'ko' }}
9
- {{ undefinedVar |default('default') is sameas('default') ? 'ok' : 'ko' }}
10
  Array access:
11
- {{ nested.definedVar |default('default') is sameas('default') ? 'ko' : 'ok' }}
12
- {{ nested['definedVar'] |default('default') is sameas('default') ? 'ko' : 'ok' }}
13
- {{ nested.zeroVar |default('default') is sameas('default') ? 'ko' : 'ok' }}
14
- {{ nested.emptyVar |default('default') is sameas('default') ? 'ok' : 'ko' }}
15
- {{ nested.nullVar |default('default') is sameas('default') ? 'ok' : 'ko' }}
16
- {{ nested.undefinedVar |default('default') is sameas('default') ? 'ok' : 'ko' }}
17
- {{ nested['undefinedVar'] |default('default') is sameas('default') ? 'ok' : 'ko' }}
18
- {{ undefinedVar.foo |default('default') is sameas('default') ? 'ok' : 'ko' }}
19
  Plain values:
20
- {{ 'defined' |default('default') is sameas('default') ? 'ko' : 'ok' }}
21
- {{ 0 |default('default') is sameas('default') ? 'ko' : 'ok' }}
22
- {{ '' |default('default') is sameas('default') ? 'ok' : 'ko' }}
23
- {{ null |default('default') is sameas('default') ? 'ok' : 'ko' }}
24
  Precedence:
25
  {{ 'o' ~ nullVar |default('k') }}
26
  {{ 'o' ~ nested.nullVar |default('k') }}
27
  Object methods:
28
- {{ object.foo |default('default') is sameas('default') ? 'ko' : 'ok' }}
29
- {{ object.undefinedMethod |default('default') is sameas('default') ? 'ok' : 'ko' }}
30
- {{ object.getFoo() |default('default') is sameas('default') ? 'ko' : 'ok' }}
31
- {{ object.getFoo('a') |default('default') is sameas('default') ? 'ko' : 'ok' }}
32
- {{ object.undefinedMethod() |default('default') is sameas('default') ? 'ok' : 'ko' }}
33
- {{ object.undefinedMethod('a') |default('default') is sameas('default') ? 'ok' : 'ko' }}
34
  Deep nested:
35
- {{ nested.undefinedVar.foo.bar |default('default') is sameas('default') ? 'ok' : 'ko' }}
36
- {{ nested.definedArray.0 |default('default') is sameas('default') ? 'ko' : 'ok' }}
37
- {{ nested['definedArray'][0] |default('default') is sameas('default') ? 'ko' : 'ok' }}
38
- {{ object.self.foo |default('default') is sameas('default') ? 'ko' : 'ok' }}
39
- {{ object.self.undefinedMethod |default('default') is sameas('default') ? 'ok' : 'ko' }}
40
- {{ object.undefinedMethod.self |default('default') is sameas('default') ? 'ok' : 'ko' }}
41
  --DATA--
42
  return array(
43
  'definedVar' => 'defined',
2
  "default" filter
3
  --TEMPLATE--
4
  Variable:
5
+ {{ definedVar |default('default') is same as('default') ? 'ko' : 'ok' }}
6
+ {{ zeroVar |default('default') is same as('default') ? 'ko' : 'ok' }}
7
+ {{ emptyVar |default('default') is same as('default') ? 'ok' : 'ko' }}
8
+ {{ nullVar |default('default') is same as('default') ? 'ok' : 'ko' }}
9
+ {{ undefinedVar |default('default') is same as('default') ? 'ok' : 'ko' }}
10
  Array access:
11
+ {{ nested.definedVar |default('default') is same as('default') ? 'ko' : 'ok' }}
12
+ {{ nested['definedVar'] |default('default') is same as('default') ? 'ko' : 'ok' }}
13
+ {{ nested.zeroVar |default('default') is same as('default') ? 'ko' : 'ok' }}
14
+ {{ nested.emptyVar |default('default') is same as('default') ? 'ok' : 'ko' }}
15
+ {{ nested.nullVar |default('default') is same as('default') ? 'ok' : 'ko' }}
16
+ {{ nested.undefinedVar |default('default') is same as('default') ? 'ok' : 'ko' }}
17
+ {{ nested['undefinedVar'] |default('default') is same as('default') ? 'ok' : 'ko' }}
18
+ {{ undefinedVar.foo |default('default') is same as('default') ? 'ok' : 'ko' }}
19
  Plain values:
20
+ {{ 'defined' |default('default') is same as('default') ? 'ko' : 'ok' }}
21
+ {{ 0 |default('default') is same as('default') ? 'ko' : 'ok' }}
22
+ {{ '' |default('default') is same as('default') ? 'ok' : 'ko' }}
23
+ {{ null |default('default') is same as('default') ? 'ok' : 'ko' }}
24
  Precedence:
25
  {{ 'o' ~ nullVar |default('k') }}
26
  {{ 'o' ~ nested.nullVar |default('k') }}
27
  Object methods:
28
+ {{ object.foo |default('default') is same as('default') ? 'ko' : 'ok' }}
29
+ {{ object.undefinedMethod |default('default') is same as('default') ? 'ok' : 'ko' }}
30
+ {{ object.getFoo() |default('default') is same as('default') ? 'ko' : 'ok' }}
31
+ {{ object.getFoo('a') |default('default') is same as('default') ? 'ko' : 'ok' }}
32
+ {{ object.undefinedMethod() |default('default') is same as('default') ? 'ok' : 'ko' }}
33
+ {{ object.undefinedMethod('a') |default('default') is same as('default') ? 'ok' : 'ko' }}
34
  Deep nested:
35
+ {{ nested.undefinedVar.foo.bar |default('default') is same as('default') ? 'ok' : 'ko' }}
36
+ {{ nested.definedArray.0 |default('default') is same as('default') ? 'ko' : 'ok' }}
37
+ {{ nested['definedArray'][0] |default('default') is same as('default') ? 'ko' : 'ok' }}
38
+ {{ object.self.foo |default('default') is same as('default') ? 'ko' : 'ok' }}
39
+ {{ object.self.undefinedMethod |default('default') is same as('default') ? 'ok' : 'ko' }}
40
+ {{ object.undefinedMethod.self |default('default') is same as('default') ? 'ok' : 'ko' }}
41
  --DATA--
42
  return array(
43
  'definedVar' => 'defined',
vendor/twig/twig/test/Twig/Tests/Fixtures/filters/first.test CHANGED
@@ -6,6 +6,7 @@
6
  {{ '1234'|first }}
7
  {{ arr|first }}
8
  {{ 'Ä€é'|first }}
 
9
  --DATA--
10
  return array('arr' => new ArrayObject(array(1, 2, 3, 4)))
11
  --EXPECT--
6
  {{ '1234'|first }}
7
  {{ arr|first }}
8
  {{ 'Ä€é'|first }}
9
+ {{ ''|first }}
10
  --DATA--
11
  return array('arr' => new ArrayObject(array(1, 2, 3, 4)))
12
  --EXPECT--
vendor/twig/twig/test/Twig/Tests/Fixtures/filters/last.test CHANGED
@@ -6,6 +6,7 @@
6
  {{ '1234'|last }}
7
  {{ arr|last }}
8
  {{ 'Ä€é'|last }}
 
9
  --DATA--
10
  return array('arr' => new ArrayObject(array(1, 2, 3, 4)))
11
  --EXPECT--
6
  {{ '1234'|last }}
7
  {{ arr|last }}
8
  {{ 'Ä€é'|last }}
9
+ {{ ''|last }}
10
  --DATA--
11
  return array('arr' => new ArrayObject(array(1, 2, 3, 4)))
12
  --EXPECT--
vendor/twig/twig/test/Twig/Tests/Fixtures/filters/slice.test CHANGED
@@ -13,12 +13,17 @@
13
  {{ '1234'[1:2] }}
14
  {{ arr|slice(1, 2)|join('') }}
15
  {{ arr[1:2]|join('') }}
 
 
16
 
17
  {{ [1, 2, 3, 4]|slice(1)|join('') }}
18
  {{ [1, 2, 3, 4][1:]|join('') }}
19
  {{ '1234'|slice(1) }}
20
  {{ '1234'[1:] }}
21
  {{ '1234'[:1] }}
 
 
 
22
  --DATA--
23
  return array('start' => 1, 'length' => 2, 'arr' => new ArrayObject(array(1, 2, 3, 4)))
24
  --EXPECT--
@@ -35,8 +40,13 @@ bc
35
  23
36
  23
37
 
 
 
38
  234
39
  234
40
  234
41
  234
42
  1
 
 
 
13
  {{ '1234'[1:2] }}
14
  {{ arr|slice(1, 2)|join('') }}
15
  {{ arr[1:2]|join('') }}
16
+ {{ arr[4:1]|join('') }}
17
+ {{ arr[3:2]|join('') }}
18
 
19
  {{ [1, 2, 3, 4]|slice(1)|join('') }}
20
  {{ [1, 2, 3, 4][1:]|join('') }}
21
  {{ '1234'|slice(1) }}
22
  {{ '1234'[1:] }}
23
  {{ '1234'[:1] }}
24
+
25
+ {{ arr|slice(3)|join('') }}
26
+ {{ arr[2:]|join('') }}
27
  --DATA--
28
  return array('start' => 1, 'length' => 2, 'arr' => new ArrayObject(array(1, 2, 3, 4)))
29
  --EXPECT--
40
  23
41
  23
42
 
43
+ 4
44
+
45
  234
46
  234
47
  234
48
  234
49
  1
50
+
51
+ 4
52
+ 34
vendor/twig/twig/test/Twig/Tests/Fixtures/filters/split.test CHANGED
@@ -5,6 +5,7 @@
5
  {{ foo|split(',')|join('-') }}
6
  {{ foo|split(',', 3)|join('-') }}
7
  {{ baz|split('')|join('-') }}
 
8
  {{ baz|split('', 2)|join('-') }}
9
  {{ foo|split(',', -2)|join('-') }}
10
  --DATA--
@@ -14,5 +15,6 @@ one-two-three-four-five
14
  one-two-three-four-five
15
  one-two-three,four,five
16
  1-2-3-4-5
 
17
  12-34-5
18
  one-two-three
5
  {{ foo|split(',')|join('-') }}
6
  {{ foo|split(',', 3)|join('-') }}
7
  {{ baz|split('')|join('-') }}
8
+ {{ baz|split('', 1)|join('-') }}
9
  {{ baz|split('', 2)|join('-') }}
10
  {{ foo|split(',', -2)|join('-') }}
11
  --DATA--
15
  one-two-three-four-five
16
  one-two-three,four,five
17
  1-2-3-4-5
18
+ 1-2-3-4-5
19
  12-34-5
20
  one-two-three
vendor/twig/twig/test/Twig/Tests/Fixtures/filters/split_utf8.test ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ --TEST--
2
+ "split" filter
3
+ --CONDITION--
4
+ function_exists('mb_get_info')
5
+ --TEMPLATE--
6
+ {{ "é"|split('', 10)|join('-') }}
7
+ {{ foo|split(',')|join('-') }}
8
+ {{ foo|split(',', 1)|join('-') }}
9
+ {{ foo|split(',', 2)|join('-') }}
10
+ {{ foo|split(',', 3)|join('-') }}
11
+ {{ baz|split('')|join('-') }}
12
+ {{ baz|split('', 1)|join('-') }}
13
+ {{ baz|split('', 2)|join('-') }}
14
+ --DATA--
15
+ return array('foo' => 'Ä,é,Äほ', 'baz' => 'éÄßごa',)
16
+ --EXPECT--
17
+ é
18
+ Ä-é-Äほ
19
+ Ä,é,Äほ
20
+ Ä-é,Äほ
21
+ Ä-é-Äほ
22
+ é-Ä-ß-ご-a
23
+ é-Ä-ß-ご-a
24
+ éÄ-ßご-a
vendor/twig/twig/test/Twig/Tests/Fixtures/filters/urlencode.test CHANGED
@@ -1,12 +1,16 @@
1
  --TEST--
2
  "url_encode" filter
 
 
3
  --TEMPLATE--
4
  {{ {foo: "bar", number: 3, "spéßi%l": "e%c0d@d", "spa ce": ""}|url_encode }}
5
  {{ {foo: "bar", number: 3, "spéßi%l": "e%c0d@d", "spa ce": ""}|url_encode|raw }}
6
  {{ {}|url_encode|default("default") }}
 
7
  --DATA--
8
  return array()
9
  --EXPECT--
10
- foo=bar&amp;number=3&amp;sp%C3%A9%C3%9Fi%25l=e%25c0d%40d&amp;spa+ce=
11
- foo=bar&number=3&sp%C3%A9%C3%9Fi%25l=e%25c0d%40d&spa+ce=
12
  default
 
1
  --TEST--
2
  "url_encode" filter
3
+ --CONDITION--
4
+ defined('PHP_QUERY_RFC3986')
5
  --TEMPLATE--
6
  {{ {foo: "bar", number: 3, "spéßi%l": "e%c0d@d", "spa ce": ""}|url_encode }}
7
  {{ {foo: "bar", number: 3, "spéßi%l": "e%c0d@d", "spa ce": ""}|url_encode|raw }}
8
  {{ {}|url_encode|default("default") }}
9
+ {{ 'spéßi%le%c0d@dspa ce'|url_encode }}
10
  --DATA--
11
  return array()
12
  --EXPECT--
13
+ foo=bar&amp;number=3&amp;sp%C3%A9%C3%9Fi%25l=e%25c0d%40d&amp;spa%20ce=
14
+ foo=bar&number=3&sp%C3%A9%C3%9Fi%25l=e%25c0d%40d&spa%20ce=
15
  default
16
+ sp%C3%A9%C3%9Fi%25le%25c0d%40dspa%20ce
vendor/{vendor/twig/twig/test/Twig/Tests/Fixtures/filters/urlencode.test → twig/twig/test/Twig/Tests/Fixtures/filters/urlencode_deprecated.test} RENAMED
@@ -1,12 +1,16 @@
1
  --TEST--
2
- "url_encode" filter
 
 
3
  --TEMPLATE--
4
  {{ {foo: "bar", number: 3, "spéßi%l": "e%c0d@d", "spa ce": ""}|url_encode }}
5
  {{ {foo: "bar", number: 3, "spéßi%l": "e%c0d@d", "spa ce": ""}|url_encode|raw }}
6
  {{ {}|url_encode|default("default") }}
 
7
  --DATA--
8
  return array()
9
  --EXPECT--
10
- foo=bar&amp;number=3&amp;sp%C3%A9%C3%9Fi%25l=e%25c0d%40d&amp;spa+ce=
11
- foo=bar&number=3&sp%C3%A9%C3%9Fi%25l=e%25c0d%40d&spa+ce=
12
  default
 
1
  --TEST--
2
+ "url_encode" filter for PHP < 5.4 and HHVM
3
+ --CONDITION--
4
+ defined('PHP_QUERY_RFC3986')
5
  --TEMPLATE--
6
  {{ {foo: "bar", number: 3, "spéßi%l": "e%c0d@d", "spa ce": ""}|url_encode }}
7
  {{ {foo: "bar", number: 3, "spéßi%l": "e%c0d@d", "spa ce": ""}|url_encode|raw }}
8
  {{ {}|url_encode|default("default") }}
9
+ {{ 'spéßi%le%c0d@dspa ce'|url_encode }}
10
  --DATA--
11
  return array()
12
  --EXPECT--
13
+ foo=bar&amp;number=3&amp;sp%C3%A9%C3%9Fi%25l=e%25c0d%40d&amp;spa%20ce=
14
+ foo=bar&number=3&sp%C3%A9%C3%9Fi%25l=e%25c0d%40d&spa%20ce=
15
  default
16
+ sp%C3%A9%C3%9Fi%25le%25c0d%40dspa%20ce
vendor/twig/twig/test/Twig/Tests/Fixtures/functions/attribute.test CHANGED
@@ -4,13 +4,15 @@
4
  {{ attribute(obj, method) }}
5
  {{ attribute(array, item) }}
6
  {{ attribute(obj, "bar", ["a", "b"]) }}
 
7
  {{ attribute(obj, method) is defined ? 'ok' : 'ko' }}
8
  {{ attribute(obj, nonmethod) is defined ? 'ok' : 'ko' }}
9
  --DATA--
10
- return array('obj' => new TwigTestFoo(), 'method' => 'foo', 'array' => array('foo' => 'bar'), 'item' => 'foo', 'nonmethod' => 'xxx')
11
  --EXPECT--
12
  foo
13
  bar
14
  bar_a-b
 
15
  ok
16
  ko
4
  {{ attribute(obj, method) }}
5
  {{ attribute(array, item) }}
6
  {{ attribute(obj, "bar", ["a", "b"]) }}
7
+ {{ attribute(obj, "bar", arguments) }}
8
  {{ attribute(obj, method) is defined ? 'ok' : 'ko' }}
9
  {{ attribute(obj, nonmethod) is defined ? 'ok' : 'ko' }}
10
  --DATA--
11
+ return array('obj' => new TwigTestFoo(), 'method' => 'foo', 'array' => array('foo' => 'bar'), 'item' => 'foo', 'nonmethod' => 'xxx', 'arguments' => array('a', 'b'))
12
  --EXPECT--
13
  foo
14
  bar
15
  bar_a-b
16
+ bar_a-b
17
  ok
18
  ko
vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/sandbox.test CHANGED
@@ -3,8 +3,11 @@
3
  --TEMPLATE--
4
  {{ include("foo.twig", sandboxed = true) }}
5
  --TEMPLATE(foo.twig)--
 
 
 
6
  {{ foo|e }}
7
  --DATA--
8
  return array()
9
  --EXCEPTION--
10
- Twig_Sandbox_SecurityError: Filter "e" is not allowed in "index.twig" at line 2.
3
  --TEMPLATE--
4
  {{ include("foo.twig", sandboxed = true) }}
5
  --TEMPLATE(foo.twig)--
6
+
7
+
8
+ {{ foo|e }}
9
  {{ foo|e }}
10
  --DATA--
11
  return array()
12
  --EXCEPTION--
13
+ Twig_Sandbox_SecurityNotAllowedFilterError: Filter "e" is not allowed in "foo.twig" at line 4.
vendor/twig/twig/test/Twig/Tests/Fixtures/functions/recursive_block_with_inheritance.test ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ --TEST--
2
+ "block" function recursively called in a parent template
3
+ --TEMPLATE--
4
+ {% extends "ordered_menu.twig" %}
5
+ {% block label %}"{{ parent() }}"{% endblock %}
6
+ {% block list %}{% set class = 'b' %}{{ parent() }}{% endblock %}
7
+ --TEMPLATE(ordered_menu.twig)--
8
+ {% extends "menu.twig" %}
9
+ {% block list %}{% set class = class|default('a') %}<ol class="{{ class }}">{{ block('children') }}</ol>{% endblock %}
10
+ --TEMPLATE(menu.twig)--
11
+ {% extends "base.twig" %}
12
+ {% block list %}<ul>{{ block('children') }}</ul>{% endblock %}
13
+ {% block children %}{% set currentItem = item %}{% for item in currentItem %}{{ block('item') }}{% endfor %}{% set item = currentItem %}{% endblock %}
14
+ {% block item %}<li>{% if item is not iterable %}{{ block('label') }}{% else %}{{ block('list') }}{% endif %}</li>{% endblock %}
15
+ {% block label %}{{ item }}{{ block('unknown') }}{% endblock %}
16
+ --TEMPLATE(base.twig)--
17
+ {{ block('list') }}
18
+ --DATA--
19
+ return array('item' => array('1', '2', array('3.1', array('3.2.1', '3.2.2'), '3.4')))
20
+ --EXPECT--
21
+ <ol class="b"><li>"1"</li><li>"2"</li><li><ol class="b"><li>"3.1"</li><li><ol class="b"><li>"3.2.1"</li><li>"3.2.2"</li></ol></li><li>"3.4"</li></ol></li></ol>
vendor/twig/twig/test/Twig/Tests/Fixtures/regression/combined_debug_info.test ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ --TEST--
2
+ Exception with bad line number
3
+ --TEMPLATE--
4
+ {% block content %}
5
+ {{ foo }}
6
+ {{ include("foo") }}
7
+ {% endblock %}
8
+ index
9
+ --TEMPLATE(foo)--
10
+ foo
11
+ {{ foo.bar }}
12
+ --DATA--
13
+ return array('foo' => 'foo');
14
+ --EXCEPTION--
15
+ Twig_Error_Runtime: Impossible to access an attribute ("bar") on a string variable ("foo") in "foo" at line 3
vendor/twig/twig/test/Twig/Tests/Fixtures/regression/multi_word_tests.test ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ --TEST--
2
+ Twig allows multi-word tests without a custom node class
3
+ --TEMPLATE--
4
+ {{ 'foo' is multi word ? 'yes' : 'no' }}
5
+ {{ 'foo bar' is multi word ? 'yes' : 'no' }}
6
+ --DATA--
7
+ return array()
8
+ --EXPECT--
9
+ no
10
+ yes
vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/block_expr.test ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ --TEST--
2
+ block_expr
3
+ --TEMPLATE--
4
+ {% extends "base.twig" %}
5
+
6
+ {% block element -%}
7
+ Element:
8
+ {{- parent() -}}
9
+ {% endblock %}
10
+ --TEMPLATE(base.twig)--
11
+ {% spaceless %}
12
+ {% block element -%}
13
+ <div>
14
+ {%- if item.children is defined %}
15
+ {%- for item in item.children %}
16
+ {{- block('element') -}}
17
+ {% endfor %}
18
+ {%- endif -%}
19
+ </div>
20
+ {%- endblock %}
21
+ {% endspaceless %}
22
+ --DATA--
23
+ return array(
24
+ 'item' => array(
25
+ 'children' => array(
26
+ null,
27
+ null,
28
+ )
29
+ )
30
+ )
31
+ --EXPECT--
32
+ Element:<div>Element:<div></div>Element:<div></div></div>
vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/block_expr2.test ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ --TEST--
2
+ block_expr2
3
+ --TEMPLATE--
4
+ {% extends "base2.twig" %}
5
+
6
+ {% block element -%}
7
+ Element:
8
+ {{- parent() -}}
9
+ {% endblock %}
10
+ --TEMPLATE(base2.twig)--
11
+ {% extends "base.twig" %}
12
+ --TEMPLATE(base.twig)--
13
+ {% spaceless %}
14
+ {% block element -%}
15
+ <div>
16
+ {%- if item.children is defined %}
17
+ {%- for item in item.children %}
18
+ {{- block('element') -}}
19
+ {% endfor %}
20
+ {%- endif -%}
21
+ </div>
22
+ {%- endblock %}
23
+ {% endspaceless %}
24
+ --DATA--
25
+ return array(
26
+ 'item' => array(
27
+ 'children' => array(
28
+ null,
29
+ null,
30
+ )
31
+ )
32
+ )
33
+ --EXPECT--
34
+ Element:<div>Element:<div></div>Element:<div></div></div>
vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/multiple_dynamic.test ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ --TEST--
2
+ "extends" tag
3
+ --TEMPLATE--
4
+ {% set foo = 1 %}
5
+ {{ include('parent.twig') }}
6
+ {{ include('parent.twig') }}
7
+ {% set foo = 2 %}
8
+ {{ include('parent.twig') }}
9
+ --TEMPLATE(parent.twig)--
10
+ {% extends foo~'_parent.twig' %}{% block content %}{{ parent() }} parent{% endblock %}
11
+ --TEMPLATE(1_parent.twig)--
12
+ {% block content %}1{% endblock %}
13
+ --TEMPLATE(2_parent.twig)--
14
+ {% block content %}2{% endblock %}
15
+ --DATA--
16
+ return array()
17
+ --EXPECT--
18
+ 1 parent
19
+
20
+ 1 parent
21
+
22
+ 2 parent
vendor/{vendor/twig/twig/test/Twig/Tests/Fixtures/tags/macro/special_chars.test → twig/twig/test/Twig/Tests/Fixtures/tags/macro/super_globals.test} RENAMED
@@ -1,14 +1,14 @@
1
  --TEST--
2
- "§" as a macro name
3
  --TEMPLATE--
4
  {% import _self as macros %}
5
 
6
- {{ macros('foo') }}
7
 
8
- {% macro §(foo) %}
9
- §{{ foo }}§
10
  {% endmacro %}
11
  --DATA--
12
  return array()
13
  --EXPECT--
14
- §foo§
1
  --TEST--
2
+ Super globals as macro arguments
3
  --TEMPLATE--
4
  {% import _self as macros %}
5
 
6
+ {{ macros.foo('foo') }}
7
 
8
+ {% macro foo(GET) %}
9
+ {{ GET }}
10
  {% endmacro %}
11
  --DATA--
12
  return array()
13
  --EXPECT--
14
+ foo
vendor/twig/twig/test/Twig/Tests/Fixtures/tags/use/inheritance.test ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ --TEST--
2
+ "use" tag
3
+ --TEMPLATE--
4
+ {% use "parent.twig" %}
5
+
6
+ {{ block('container') }}
7
+ --TEMPLATE(parent.twig)--
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 %}
15
+ <div class="container">{{ block('sub_container') }}</div>
16
+ {% endblock %}
17
+
18
+ {% block sub_container %}
19
+ <div class="sub_container">sub_container</div>
20
+ {% endblock %}
21
+ --DATA--
22
+ return array()
23
+ --EXPECT--
24
+ <div class="container"> <div class="overriden_sub_container">overriden sub_container</div>
25
+ </div>
vendor/twig/twig/test/Twig/Tests/Fixtures/tags/use/inheritance2.test ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ --TEST--
2
+ "use" tag
3
+ --TEMPLATE--
4
+ {% use "ancestor.twig" %}
5
+ {% use "parent.twig" %}
6
+
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 %}
14
+ <div class="container">{{ block('sub_container') }}</div>
15
+ {% endblock %}
16
+
17
+ {% block sub_container %}
18
+ <div class="sub_container">sub_container</div>
19
+ {% endblock %}
20
+ --DATA--
21
+ return array()
22
+ --EXPECT--
23
+ <div class="container"> <div class="overriden_sub_container">overriden sub_container</div>
24
+ </div>
vendor/twig/twig/test/Twig/Tests/Fixtures/tags/use/parent_block.test ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ --TEST--
2
+ "use" tag
3
+ --TEMPLATE--
4
+ {% use 'file2.html.twig' with foobar as base_base_foobar %}
5
+ {% block foobar %}
6
+ {{- block('base_base_foobar') -}}
7
+ Content of block (second override)
8
+ {% endblock foobar %}
9
+ --TEMPLATE(file2.html.twig)--
10
+ {% use 'file1.html.twig' with foobar as base_foobar %}
11
+ {% block foobar %}
12
+ {{- block('base_foobar') -}}
13
+ Content of block (first override)
14
+ {% endblock foobar %}
15
+ --TEMPLATE(file1.html.twig)--
16
+ {% block foobar -%}
17
+ Content of block
18
+ {% endblock foobar %}
19
+ --DATA--
20
+ return array()
21
+ --EXPECT--
22
+ Content of block
23
+ Content of block (first override)
24
+ Content of block (second override)
vendor/twig/twig/test/Twig/Tests/Fixtures/tags/use/parent_block2.test ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ --TEST--
2
+ "use" tag
3
+ --TEMPLATE--
4
+ {% use 'file2.html.twig'%}
5
+ {% block foobar %}
6
+ {{- parent() -}}
7
+ Content of block (second override)
8
+ {% endblock foobar %}
9
+ --TEMPLATE(file2.html.twig)--
10
+ {% use 'file1.html.twig' %}
11
+ {% block foobar %}
12
+ {{- parent() -}}
13
+ Content of block (first override)
14
+ {% endblock foobar %}
15
+ --TEMPLATE(file1.html.twig)--
16
+ {% block foobar -%}
17
+ Content of block
18
+ {% endblock foobar %}
19
+ --DATA--
20
+ return array()
21
+ --EXPECT--
22
+ Content of block
23
+ Content of block (first override)
24
+ Content of block (second override)
vendor/twig/twig/test/Twig/Tests/Fixtures/tags/use/parent_block3.test ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ --TEST--
2
+ "use" tag
3
+ --TEMPLATE--
4
+ {% use 'file2.html.twig' %}
5
+ {% use 'file1.html.twig' with foo %}
6
+ {% block foo %}
7
+ {{- parent() -}}
8
+ Content of foo (second override)
9
+ {% endblock foo %}
10
+ {% block bar %}
11
+ {{- parent() -}}
12
+ Content of bar (second override)
13
+ {% endblock bar %}
14
+ --TEMPLATE(file2.html.twig)--
15
+ {% use 'file1.html.twig' %}
16
+ {% block foo %}
17
+ {{- parent() -}}
18
+ Content of foo (first override)
19
+ {% endblock foo %}
20
+ {% block bar %}
21
+ {{- parent() -}}
22
+ Content of bar (first override)
23
+ {% endblock bar %}
24
+ --TEMPLATE(file1.html.twig)--
25
+ {% block foo -%}
26
+ Content of foo
27
+ {% endblock foo %}
28
+ {% block bar -%}
29
+ Content of bar
30
+ {% endblock bar %}
31
+ --DATA--
32
+ return array()
33
+ --EXPECT--
34
+ Content of foo
35
+ Content of foo (first override)
36
+ Content of foo (second override)
37
+ Content of bar
38
+ Content of bar (second override)
vendor/twig/twig/test/Twig/Tests/Fixtures/tests/in.test CHANGED
@@ -18,7 +18,7 @@ TRUE
18
  {% if 'c' not in bar %}
19
  TRUE
20
  {% endif %}
21
- {% if '' not in bar %}
22
  TRUE
23
  {% endif %}
24
  {% if '' in '' %}
@@ -33,8 +33,47 @@ TRUE
33
  {% if '0' in '0' %}
34
  TRUE
35
  {% endif %}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  --DATA--
37
- return array('bar' => 'bar', 'foo' => array('bar' => 'bar'))
38
  --EXPECT--
39
  TRUE
40
  TRUE
@@ -46,3 +85,42 @@ TRUE
46
  TRUE
47
  TRUE
48
  TRUE
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  {% if 'c' not in bar %}
19
  TRUE
20
  {% endif %}
21
+ {% if '' in bar %}
22
  TRUE
23
  {% endif %}
24
  {% if '' in '' %}
33
  {% if '0' in '0' %}
34
  TRUE
35
  {% endif %}
36
+
37
+ {{ false in [0, 1] ? 'TRUE' : 'FALSE' }}
38
+ {{ true in [0, 1] ? 'TRUE' : 'FALSE' }}
39
+ {{ '0' in [0, 1] ? 'TRUE' : 'FALSE' }}
40
+ {{ '' in [0, 1] ? 'TRUE' : 'FALSE' }}
41
+ {{ 0 in ['', 1] ? 'TRUE' : 'FALSE' }}
42
+
43
+ {{ '' in 'foo' ? 'TRUE' : 'FALSE' }}
44
+ {{ 0 in 'foo' ? 'TRUE' : 'FALSE' }}
45
+ {{ false in 'foo' ? 'TRUE' : 'FALSE' }}
46
+ {{ false in '100' ? 'TRUE' : 'FALSE' }}
47
+ {{ true in '100' ? 'TRUE' : 'FALSE' }}
48
+
49
+ {{ [] in [true, false] ? 'TRUE' : 'FALSE' }}
50
+ {{ [] in [true, ''] ? 'TRUE' : 'FALSE' }}
51
+ {{ [] in [true, []] ? 'TRUE' : 'FALSE' }}
52
+
53
+ {{ resource in 'foo'~resource ? 'TRUE' : 'FALSE' }}
54
+ {{ object in 'stdClass' ? 'TRUE' : 'FALSE' }}
55
+ {{ [] in 'Array' ? 'TRUE' : 'FALSE' }}
56
+ {{ dir_object in 'foo'~dir_object ? 'TRUE' : 'FALSE' }}
57
+
58
+ {{ ''~resource in resource ? 'TRUE' : 'FALSE' }}
59
+ {{ 'stdClass' in object ? 'TRUE' : 'FALSE' }}
60
+ {{ 'Array' in [] ? 'TRUE' : 'FALSE' }}
61
+ {{ ''~dir_object in dir_object ? 'TRUE' : 'FALSE' }}
62
+
63
+ {{ resource in [''~resource] ? 'TRUE' : 'FALSE' }}
64
+ {{ resource in [resource + 1 - 1] ? 'TRUE' : 'FALSE' }}
65
+ {{ dir_object in [''~dir_object] ? 'TRUE' : 'FALSE' }}
66
+
67
+ {{ 5 in 125 ? 'TRUE' : 'FALSE' }}
68
+ {{ 5 in '125' ? 'TRUE' : 'FALSE' }}
69
+ {{ '5' in 125 ? 'TRUE' : 'FALSE' }}
70
+ {{ '5' in '125' ? 'TRUE' : 'FALSE' }}
71
+
72
+ {{ 5.5 in 125.5 ? 'TRUE' : 'FALSE' }}
73
+ {{ 5.5 in '125.5' ? 'TRUE' : 'FALSE' }}
74
+ {{ '5.5' in 125.5 ? 'TRUE' : 'FALSE' }}
75
  --DATA--
76
+ return array('bar' => 'bar', 'foo' => array('bar' => 'bar'), 'dir_object' => new SplFileInfo(dirname(__FILE__)), 'object' => new stdClass(), 'resource' => fopen(dirname(__FILE__), 'r'))
77
  --EXPECT--
78
  TRUE
79
  TRUE
85
  TRUE
86
  TRUE
87
  TRUE
88
+
89
+ TRUE
90
+ TRUE
91
+ TRUE
92
+ TRUE
93
+ TRUE
94
+
95
+ TRUE
96
+ FALSE
97
+ FALSE
98
+ FALSE
99
+ FALSE
100
+
101
+ TRUE
102
+ FALSE
103
+ TRUE
104
+
105
+ FALSE
106
+ FALSE
107
+ FALSE
108
+ FALSE
109
+
110
+ FALSE
111
+ FALSE
112
+ FALSE
113
+ FALSE
114
+
115
+ FALSE
116
+ FALSE
117
+ FALSE
118
+
119
+ FALSE
120
+ TRUE
121
+ FALSE
122
+ TRUE
123
+
124
+ FALSE
125
+ TRUE
126
+ FALSE
vendor/twig/twig/test/Twig/Tests/IntegrationTest.php CHANGED
@@ -157,6 +157,13 @@ class TwigTestExtension extends Twig_Extension
157
  );
158
  }
159
 
 
 
 
 
 
 
 
160
  public function §Filter($value)
161
  {
162
  return "§{$value}§";
@@ -210,6 +217,11 @@ class TwigTestExtension extends Twig_Extension
210
  return '<br />';
211
  }
212
 
 
 
 
 
 
213
  public function getName()
214
  {
215
  return 'integration_test';
157
  );
158
  }
159
 
160
+ public function getTests()
161
+ {
162
+ return array(
163
+ new Twig_SimpleTest('multi word', array($this, 'is_multi_word')),
164
+ );
165
+ }
166
+
167
  public function §Filter($value)
168
  {
169
  return "§{$value}§";
217
  return '<br />';
218
  }
219
 
220
+ public function is_multi_word($value)
221
+ {
222
+ return false !== strpos($value, ' ');
223
+ }
224
+
225
  public function getName()
226
  {
227
  return 'integration_test';
vendor/twig/twig/test/Twig/Tests/LexerTest.php CHANGED
@@ -46,7 +46,6 @@ class Twig_Tests_LexerTest extends PHPUnit_Framework_TestCase
46
  $stream = $lexer->tokenize($template);
47
 
48
  $count = 0;
49
- $tokens = array();
50
  while (!$stream->isEOF()) {
51
  $token = $stream->next();
52
  if ($type === $token->getType()) {
@@ -114,7 +113,7 @@ class Twig_Tests_LexerTest extends PHPUnit_Framework_TestCase
114
  $template = '{% raw %}'.str_repeat('*', 100000).'{% endraw %}';
115
 
116
  $lexer = new Twig_Lexer(new Twig_Environment());
117
- $stream = $lexer->tokenize($template);
118
 
119
  // should not throw an exception
120
  }
@@ -124,7 +123,7 @@ class Twig_Tests_LexerTest extends PHPUnit_Framework_TestCase
124
  $template = '{{ '.str_repeat('x', 100000).' }}';
125
 
126
  $lexer = new Twig_Lexer(new Twig_Environment());
127
- $stream = $lexer->tokenize($template);
128
 
129
  // should not throw an exception
130
  }
@@ -134,17 +133,13 @@ class Twig_Tests_LexerTest extends PHPUnit_Framework_TestCase
134
  $template = '{% '.str_repeat('x', 100000).' %}';
135
 
136
  $lexer = new Twig_Lexer(new Twig_Environment());
137
- $stream = $lexer->tokenize($template);
138
 
139
  // should not throw an exception
140
  }
141
 
142
  public function testBigNumbers()
143
  {
144
- if ('hiphop' === substr(PHP_VERSION, -6)) {
145
- $this->markTestSkipped('hhvm thinks that the number is actually a T_CONSTANT_ENCAPSED_STRING!');
146
- }
147
-
148
  $template = '{{ 922337203685477580700 }}';
149
 
150
  $lexer = new Twig_Lexer(new Twig_Environment());
@@ -216,7 +211,7 @@ class Twig_Tests_LexerTest extends PHPUnit_Framework_TestCase
216
  $template = '{{ "bar #{x" }}';
217
 
218
  $lexer = new Twig_Lexer(new Twig_Environment());
219
- $stream = $lexer->tokenize($template);
220
  }
221
 
222
  public function testStringWithNestedInterpolations()
@@ -281,7 +276,7 @@ bar
281
  ';
282
 
283
  $lexer = new Twig_Lexer(new Twig_Environment());
284
- $stream = $lexer->tokenize($template);
285
  }
286
 
287
  /**
@@ -300,6 +295,6 @@ bar
300
  ';
301
 
302
  $lexer = new Twig_Lexer(new Twig_Environment());
303
- $stream = $lexer->tokenize($template);
304
  }
305
  }
46
  $stream = $lexer->tokenize($template);
47
 
48
  $count = 0;
 
49
  while (!$stream->isEOF()) {
50
  $token = $stream->next();
51
  if ($type === $token->getType()) {
113
  $template = '{% raw %}'.str_repeat('*', 100000).'{% endraw %}';
114
 
115
  $lexer = new Twig_Lexer(new Twig_Environment());
116
+ $lexer->tokenize($template);
117
 
118
  // should not throw an exception
119
  }
123
  $template = '{{ '.str_repeat('x', 100000).' }}';
124
 
125
  $lexer = new Twig_Lexer(new Twig_Environment());
126
+ $lexer->tokenize($template);
127
 
128
  // should not throw an exception
129
  }
133
  $template = '{% '.str_repeat('x', 100000).' %}';
134
 
135
  $lexer = new Twig_Lexer(new Twig_Environment());
136
+ $lexer->tokenize($template);
137
 
138
  // should not throw an exception
139
  }
140
 
141
  public function testBigNumbers()
142
  {
 
 
 
 
143
  $template = '{{ 922337203685477580700 }}';
144
 
145
  $lexer = new Twig_Lexer(new Twig_Environment());
211
  $template = '{{ "bar #{x" }}';
212
 
213
  $lexer = new Twig_Lexer(new Twig_Environment());
214
+ $lexer->tokenize($template);
215
  }
216
 
217
  public function testStringWithNestedInterpolations()
276
  ';
277
 
278
  $lexer = new Twig_Lexer(new Twig_Environment());
279
+ $lexer->tokenize($template);
280
  }
281
 
282
  /**
295
  ';
296
 
297
  $lexer = new Twig_Lexer(new Twig_Environment());
298
+ $lexer->tokenize($template);
299
  }
300
  }
vendor/twig/twig/test/Twig/Tests/NativeExtensionTest.php CHANGED
@@ -13,6 +13,10 @@ class Twig_Tests_NativeExtensionTest extends PHPUnit_Framework_TestCase
13
  {
14
  public function testGetProperties()
15
  {
 
 
 
 
16
  $twig = new Twig_Environment(new Twig_Loader_String(), array(
17
  'debug' => true,
18
  'cache' => false,
@@ -23,10 +27,6 @@ class Twig_Tests_NativeExtensionTest extends PHPUnit_Framework_TestCase
23
  $d2 = new DateTime();
24
  $output = $twig->render('{{ d1.date }}{{ d2.date }}', compact('d1', 'd2'));
25
 
26
- if ('hiphop' === substr(PHP_VERSION, -6)) {
27
- $this->markTestSkipped('Skip under HHVM as the behavior is not the same as plain PHP (which is an edge case anyway)');
28
- }
29
-
30
  // If it fails, PHP will crash.
31
  $this->assertEquals($output, $d1->date.$d2->date);
32
  }
13
  {
14
  public function testGetProperties()
15
  {
16
+ if (defined('HHVM_VERSION')) {
17
+ $this->markTestSkipped('Skip under HHVM as the behavior is not the same as plain PHP (which is an edge case anyway)');
18
+ }
19
+
20
  $twig = new Twig_Environment(new Twig_Loader_String(), array(
21
  'debug' => true,
22
  'cache' => false,
27
  $d2 = new DateTime();
28
  $output = $twig->render('{{ d1.date }}{{ d2.date }}', compact('d1', 'd2'));
29
 
 
 
 
 
30
  // If it fails, PHP will crash.
31
  $this->assertEquals($output, $d1->date.$d2->date);
32
  }
vendor/twig/twig/test/Twig/Tests/Node/AutoEscapeTest.php CHANGED
@@ -11,9 +11,6 @@
11
 
12
  class Twig_Tests_Node_AutoEscapeTest extends Twig_Test_NodeTestCase
13
  {
14
- /**
15
- * @covers Twig_Node_AutoEscape::__construct
16
- */
17
  public function testConstructor()
18
  {
19
  $body = new Twig_Node(array(new Twig_Node_Text('foo', 1)));
@@ -23,15 +20,6 @@ class Twig_Tests_Node_AutoEscapeTest extends Twig_Test_NodeTestCase
23
  $this->assertTrue($node->getAttribute('value'));
24
  }
25
 
26
- /**
27
- * @covers Twig_Node_AutoEscape::compile
28
- * @dataProvider getTests
29
- */
30
- public function testCompile($node, $source, $environment = null)
31
- {
32
- parent::testCompile($node, $source, $environment);
33
- }
34
-
35
  public function getTests()
36
  {
37
  $body = new Twig_Node(array(new Twig_Node_Text('foo', 1)));
11
 
12
  class Twig_Tests_Node_AutoEscapeTest extends Twig_Test_NodeTestCase
13
  {
 
 
 
14
  public function testConstructor()
15
  {
16
  $body = new Twig_Node(array(new Twig_Node_Text('foo', 1)));
20
  $this->assertTrue($node->getAttribute('value'));
21
  }
22
 
 
 
 
 
 
 
 
 
 
23
  public function getTests()
24
  {
25
  $body = new Twig_Node(array(new Twig_Node_Text('foo', 1)));
vendor/twig/twig/test/Twig/Tests/Node/BlockReferenceTest.php CHANGED
@@ -11,9 +11,6 @@
11
 
12
  class Twig_Tests_Node_BlockReferenceTest extends Twig_Test_NodeTestCase
13
  {
14
- /**
15
- * @covers Twig_Node_BlockReference::__construct
16
- */
17
  public function testConstructor()
18
  {
19
  $node = new Twig_Node_BlockReference('foo', 1);
@@ -21,15 +18,6 @@ class Twig_Tests_Node_BlockReferenceTest extends Twig_Test_NodeTestCase
21
  $this->assertEquals('foo', $node->getAttribute('name'));
22
  }
23
 
24
- /**
25
- * @covers Twig_Node_BlockReference::compile
26
- * @dataProvider getTests
27
- */
28
- public function testCompile($node, $source, $environment = null)
29
- {
30
- parent::testCompile($node, $source, $environment);
31
- }
32
-
33
  public function getTests()
34
  {
35
  return array(
11
 
12
  class Twig_Tests_Node_BlockReferenceTest extends Twig_Test_NodeTestCase
13
  {
 
 
 
14
  public function testConstructor()
15
  {
16
  $node = new Twig_Node_BlockReference('foo', 1);
18
  $this->assertEquals('foo', $node->getAttribute('name'));
19
  }
20
 
 
 
 
 
 
 
 
 
 
21
  public function getTests()
22
  {
23
  return array(
vendor/twig/twig/test/Twig/Tests/Node/BlockTest.php CHANGED
@@ -11,9 +11,6 @@
11
 
12
  class Twig_Tests_Node_BlockTest extends Twig_Test_NodeTestCase
13
  {
14
- /**
15
- * @covers Twig_Node_Block::__construct
16
- */
17
  public function testConstructor()
18
  {
19
  $body = new Twig_Node_Text('foo', 1);
@@ -23,15 +20,6 @@ class Twig_Tests_Node_BlockTest extends Twig_Test_NodeTestCase
23
  $this->assertEquals('foo', $node->getAttribute('name'));
24
  }
25
 
26
- /**
27
- * @covers Twig_Node_Block::compile
28
- * @dataProvider getTests
29
- */
30
- public function testCompile($node, $source, $environment = null)
31
- {
32
- parent::testCompile($node, $source, $environment);
33
- }
34
-
35
  public function getTests()
36
  {
37
  $body = new Twig_Node_Text('foo', 1);
11
 
12
  class Twig_Tests_Node_BlockTest extends Twig_Test_NodeTestCase
13
  {
 
 
 
14
  public function testConstructor()
15
  {
16
  $body = new Twig_Node_Text('foo', 1);
20
  $this->assertEquals('foo', $node->getAttribute('name'));
21
  }
22
 
 
 
 
 
 
 
 
 
 
23
  public function getTests()
24
  {
25
  $body = new Twig_Node_Text('foo', 1);
vendor/twig/twig/test/Twig/Tests/Node/DoTest.php CHANGED
@@ -11,9 +11,6 @@
11
 
12
  class Twig_Tests_Node_DoTest extends Twig_Test_NodeTestCase
13
  {
14
- /**
15
- * @covers Twig_Node_Do::__construct
16
- */
17
  public function testConstructor()
18
  {
19
  $expr = new Twig_Node_Expression_Constant('foo', 1);
@@ -22,15 +19,6 @@ class Twig_Tests_Node_DoTest extends Twig_Test_NodeTestCase
22
  $this->assertEquals($expr, $node->getNode('expr'));
23
  }
24
 
25
- /**
26
- * @covers Twig_Node_Do::compile
27
- * @dataProvider getTests
28
- */
29
- public function testCompile($node, $source, $environment = null)
30
- {
31
- parent::testCompile($node, $source, $environment);
32
- }
33
-
34
  public function getTests()
35
  {
36
  $tests = array();
11
 
12
  class Twig_Tests_Node_DoTest extends Twig_Test_NodeTestCase
13
  {
 
 
 
14
  public function testConstructor()
15
  {
16
  $expr = new Twig_Node_Expression_Constant('foo', 1);
19
  $this->assertEquals($expr, $node->getNode('expr'));
20
  }
21
 
 
 
 
 
 
 
 
 
 
22
  public function getTests()
23
  {
24
  $tests = array();
vendor/twig/twig/test/Twig/Tests/Node/Expression/ArrayTest.php CHANGED
@@ -11,9 +11,6 @@
11
 
12
  class Twig_Tests_Node_Expression_ArrayTest extends Twig_Test_NodeTestCase
13
  {
14
- /**
15
- * @covers Twig_Node_Expression_Array::__construct
16
- */
17
  public function testConstructor()
18
  {
19
  $elements = array(new Twig_Node_Expression_Constant('foo', 1), $foo = new Twig_Node_Expression_Constant('bar', 1));
@@ -22,15 +19,6 @@ class Twig_Tests_Node_Expression_ArrayTest extends Twig_Test_NodeTestCase
22
  $this->assertEquals($foo, $node->getNode(1));
23
  }
24
 
25
- /**
26
- * @covers Twig_Node_Expression_Array::compile
27
- * @dataProvider getTests
28
- */
29
- public function testCompile($node, $source, $environment = null)
30
- {
31
- parent::testCompile($node, $source, $environment);
32
- }
33
-
34
  public function getTests()
35
  {
36
  $elements = array(
11
 
12
  class Twig_Tests_Node_Expression_ArrayTest extends Twig_Test_NodeTestCase
13
  {
 
 
 
14
  public function testConstructor()
15
  {
16
  $elements = array(new Twig_Node_Expression_Constant('foo', 1), $foo = new Twig_Node_Expression_Constant('bar', 1));
19
  $this->assertEquals($foo, $node->getNode(1));
20
  }
21
 
 
 
 
 
 
 
 
 
 
22
  public function getTests()
23
  {
24
  $elements = array(
vendor/twig/twig/test/Twig/Tests/Node/Expression/AssignNameTest.php CHANGED
@@ -11,9 +11,6 @@
11
 
12
  class Twig_Tests_Node_Expression_AssignNameTest extends Twig_Test_NodeTestCase
13
  {
14
- /**
15
- * @covers Twig_Node_Expression_AssignName::__construct
16
- */
17
  public function testConstructor()
18
  {
19
  $node = new Twig_Node_Expression_AssignName('foo', 1);
@@ -21,15 +18,6 @@ class Twig_Tests_Node_Expression_AssignNameTest extends Twig_Test_NodeTestCase
21
  $this->assertEquals('foo', $node->getAttribute('name'));
22
  }
23
 
24
- /**
25
- * @covers Twig_Node_Expression_AssignName::compile
26
- * @dataProvider getTests
27
- */
28
- public function testCompile($node, $source, $environment = null)
29
- {
30
- parent::testCompile($node, $source, $environment);
31
- }
32
-
33
  public function getTests()
34
  {
35
  $node = new Twig_Node_Expression_AssignName('foo', 1);
11
 
12
  class Twig_Tests_Node_Expression_AssignNameTest extends Twig_Test_NodeTestCase
13
  {
 
 
 
14
  public function testConstructor()
15
  {
16
  $node = new Twig_Node_Expression_AssignName('foo', 1);
18
  $this->assertEquals('foo', $node->getAttribute('name'));
19
  }
20
 
 
 
 
 
 
 
 
 
 
21
  public function getTests()
22
  {
23
  $node = new Twig_Node_Expression_AssignName('foo', 1);
vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/AddTest.php CHANGED
@@ -11,9 +11,6 @@
11
 
12
  class Twig_Tests_Node_Expression_Binary_AddTest extends Twig_Test_NodeTestCase
13
  {
14
- /**
15
- * @covers Twig_Node_Expression_Binary_Add::__construct
16
- */
17
  public function testConstructor()
18
  {
19
  $left = new Twig_Node_Expression_Constant(1, 1);
@@ -24,16 +21,6 @@ class Twig_Tests_Node_Expression_Binary_AddTest extends Twig_Test_NodeTestCase
24
  $this->assertEquals($right, $node->getNode('right'));
25
  }
26
 
27
- /**
28
- * @covers Twig_Node_Expression_Binary_Add::compile
29
- * @covers Twig_Node_Expression_Binary_Add::operator
30
- * @dataProvider getTests
31
- */
32
- public function testCompile($node, $source, $environment = null)
33
- {
34
- parent::testCompile($node, $source, $environment);
35
- }
36
-
37
  public function getTests()
38
  {
39
  $left = new Twig_Node_Expression_Constant(1, 1);
11
 
12
  class Twig_Tests_Node_Expression_Binary_AddTest extends Twig_Test_NodeTestCase
13
  {
 
 
 
14
  public function testConstructor()
15
  {
16
  $left = new Twig_Node_Expression_Constant(1, 1);
21
  $this->assertEquals($right, $node->getNode('right'));
22
  }
23
 
 
 
 
 
 
 
 
 
 
 
24
  public function getTests()
25
  {
26
  $left = new Twig_Node_Expression_Constant(1, 1);
vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/AndTest.php CHANGED
@@ -11,9 +11,6 @@
11
 
12
  class Twig_Tests_Node_Expression_Binary_AndTest extends Twig_Test_NodeTestCase
13
  {
14
- /**
15
- * @covers Twig_Node_Expression_Binary_And::__construct
16
- */
17
  public function testConstructor()
18
  {
19
  $left = new Twig_Node_Expression_Constant(1, 1);
@@ -24,16 +21,6 @@ class Twig_Tests_Node_Expression_Binary_AndTest extends Twig_Test_NodeTestCase
24
  $this->assertEquals($right, $node->getNode('right'));
25
  }
26
 
27
- /**
28
- * @covers Twig_Node_Expression_Binary_And::compile
29
- * @covers Twig_Node_Expression_Binary_And::operator
30
- * @dataProvider getTests
31
- */
32
- public function testCompile($node, $source, $environment = null)
33
- {
34
- parent::testCompile($node, $source, $environment);
35
- }
36
-
37
  public function getTests()
38
  {
39
  $left = new Twig_Node_Expression_Constant(1, 1);
11
 
12
  class Twig_Tests_Node_Expression_Binary_AndTest extends Twig_Test_NodeTestCase
13
  {
 
 
 
14
  public function testConstructor()
15
  {
16
  $left = new Twig_Node_Expression_Constant(1, 1);
21
  $this->assertEquals($right, $node->getNode('right'));
22
  }
23
 
 
 
 
 
 
 
 
 
 
 
24
  public function getTests()
25
  {
26
  $left = new Twig_Node_Expression_Constant(1, 1);
vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/ConcatTest.php CHANGED
@@ -11,9 +11,6 @@
11
 
12
  class Twig_Tests_Node_Expression_Binary_ConcatTest extends Twig_Test_NodeTestCase
13
  {
14
- /**
15
- * @covers Twig_Node_Expression_Binary_Concat::__construct
16
- */
17
  public function testConstructor()
18
  {
19
  $left = new Twig_Node_Expression_Constant(1, 1);
@@ -24,16 +21,6 @@ class Twig_Tests_Node_Expression_Binary_ConcatTest extends Twig_Test_NodeTestCas
24
  $this->assertEquals($right, $node->getNode('right'));
25
  }
26
 
27
- /**
28
- * @covers Twig_Node_Expression_Binary_Concat::compile
29
- * @covers Twig_Node_Expression_Binary_Concat::operator
30
- * @dataProvider getTests
31
- */
32
- public function testCompile($node, $source, $environment = null)
33
- {
34
- parent::testCompile($node, $source, $environment);
35
- }
36
-
37
  public function getTests()
38
  {
39
  $left = new Twig_Node_Expression_Constant(1, 1);
11
 
12
  class Twig_Tests_Node_Expression_Binary_ConcatTest extends Twig_Test_NodeTestCase
13
  {
 
 
 
14
  public function testConstructor()
15
  {
16
  $left = new Twig_Node_Expression_Constant(1, 1);
21
  $this->assertEquals($right, $node->getNode('right'));
22
  }
23
 
 
 
 
 
 
 
 
 
 
 
24
  public function getTests()
25
  {
26
  $left = new Twig_Node_Expression_Constant(1, 1);
vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/DivTest.php CHANGED
@@ -11,9 +11,6 @@
11
 
12
  class Twig_Tests_Node_Expression_Binary_DivTest extends Twig_Test_NodeTestCase
13
  {
14
- /**
15
- * @covers Twig_Node_Expression_Binary_Div::__construct
16
- */
17
  public function testConstructor()
18
  {
19
  $left = new Twig_Node_Expression_Constant(1, 1);
@@ -24,16 +21,6 @@ class Twig_Tests_Node_Expression_Binary_DivTest extends Twig_Test_NodeTestCase
24
  $this->assertEquals($right, $node->getNode('right'));
25
  }
26
 
27
- /**
28
- * @covers Twig_Node_Expression_Binary_Div::compile
29
- * @covers Twig_Node_Expression_Binary_Div::operator
30
- * @dataProvider getTests
31
- */
32
- public function testCompile($node, $source, $environment = null)
33
- {
34
- parent::testCompile($node, $source, $environment);
35
- }
36
-
37
  public function getTests()
38
  {
39
  $left = new Twig_Node_Expression_Constant(1, 1);
11
 
12
  class Twig_Tests_Node_Expression_Binary_DivTest extends Twig_Test_NodeTestCase
13
  {
 
 
 
14
  public function testConstructor()
15
  {
16
  $left = new Twig_Node_Expression_Constant(1, 1);
21
  $this->assertEquals($right, $node->getNode('right'));
22
  }
23
 
 
 
 
 
 
 
 
 
 
 
24
  public function getTests()
25
  {
26
  $left = new Twig_Node_Expression_Constant(1, 1);
vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/FloorDivTest.php CHANGED
@@ -11,9 +11,6 @@
11
 
12
  class Twig_Tests_Node_Expression_Binary_FloorDivTest extends Twig_Test_NodeTestCase
13
  {
14
- /**
15
- * @covers Twig_Node_Expression_Binary_FloorDiv::__construct
16
- */
17
  public function testConstructor()
18
  {
19
  $left = new Twig_Node_Expression_Constant(1, 1);
@@ -24,16 +21,6 @@ class Twig_Tests_Node_Expression_Binary_FloorDivTest extends Twig_Test_NodeTestC
24
  $this->assertEquals($right, $node->getNode('right'));
25
  }
26
 
27
- /**
28
- * @covers Twig_Node_Expression_Binary_FloorDiv::compile
29
- * @covers Twig_Node_Expression_Binary_FloorDiv::operator
30
- * @dataProvider getTests
31
- */
32
- public function testCompile($node, $source, $environment = null)
33
- {
34
- parent::testCompile($node, $source, $environment);
35
- }
36
-
37
  public function getTests()
38
  {
39
  $left = new Twig_Node_Expression_Constant(1, 1);
11
 
12
  class Twig_Tests_Node_Expression_Binary_FloorDivTest extends Twig_Test_NodeTestCase
13
  {
 
 
 
14
  public function testConstructor()
15
  {
16
  $left = new Twig_Node_Expression_Constant(1, 1);
21
  $this->assertEquals($right, $node->getNode('right'));
22
  }
23
 
 
 
 
 
 
 
 
 
 
 
24
  public function getTests()
25
  {
26
  $left = new Twig_Node_Expression_Constant(1, 1);
vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/ModTest.php CHANGED
@@ -11,9 +11,6 @@
11
 
12
  class Twig_Tests_Node_Expression_Binary_ModTest extends Twig_Test_NodeTestCase
13
  {
14
- /**
15
- * @covers Twig_Node_Expression_Binary_Mod::__construct
16
- */
17
  public function testConstructor()
18
  {
19
  $left = new Twig_Node_Expression_Constant(1, 1);
@@ -24,16 +21,6 @@ class Twig_Tests_Node_Expression_Binary_ModTest extends Twig_Test_NodeTestCase
24
  $this->assertEquals($right, $node->getNode('right'));
25
  }
26
 
27
- /**
28
- * @covers Twig_Node_Expression_Binary_Mod::compile
29
- * @covers Twig_Node_Expression_Binary_Mod::operator
30
- * @dataProvider getTests
31
- */
32
- public function testCompile($node, $source, $environment = null)
33
- {
34
- parent::testCompile($node, $source, $environment);
35
- }
36
-
37
  public function getTests()
38
  {
39
  $left = new Twig_Node_Expression_Constant(1, 1);
11
 
12
  class Twig_Tests_Node_Expression_Binary_ModTest extends Twig_Test_NodeTestCase
13
  {
 
 
 
14
  public function testConstructor()
15
  {
16
  $left = new Twig_Node_Expression_Constant(1, 1);
21
  $this->assertEquals($right, $node->getNode('right'));
22
  }
23
 
 
 
 
 
 
 
 
 
 
 
24
  public function getTests()
25
  {
26
  $left = new Twig_Node_Expression_Constant(1, 1);
vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/MulTest.php CHANGED
@@ -11,9 +11,6 @@
11
 
12
  class Twig_Tests_Node_Expression_Binary_MulTest extends Twig_Test_NodeTestCase
13
  {
14
- /**
15
- * @covers Twig_Node_Expression_Binary_Mul::__construct
16
- */
17
  public function testConstructor()
18
  {
19
  $left = new Twig_Node_Expression_Constant(1, 1);
@@ -24,16 +21,6 @@ class Twig_Tests_Node_Expression_Binary_MulTest extends Twig_Test_NodeTestCase
24
  $this->assertEquals($right, $node->getNode('right'));
25
  }
26
 
27
- /**
28
- * @covers Twig_Node_Expression_Binary_Mul::compile
29
- * @covers Twig_Node_Expression_Binary_Mul::operator
30
- * @dataProvider getTests
31
- */
32
- public function testCompile($node, $source, $environment = null)
33
- {
34
- parent::testCompile($node, $source, $environment);
35
- }
36
-
37
  public function getTests()
38
  {
39
  $left = new Twig_Node_Expression_Constant(1, 1);
11
 
12
  class Twig_Tests_Node_Expression_Binary_MulTest extends Twig_Test_NodeTestCase
13
  {
 
 
 
14
  public function testConstructor()
15
  {
16
  $left = new Twig_Node_Expression_Constant(1, 1);
21
  $this->assertEquals($right, $node->getNode('right'));
22
  }
23
 
 
 
 
 
 
 
 
 
 
 
24
  public function getTests()
25
  {
26
  $left = new Twig_Node_Expression_Constant(1, 1);
vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/OrTest.php CHANGED
@@ -11,9 +11,6 @@
11
 
12
  class Twig_Tests_Node_Expression_Binary_OrTest extends Twig_Test_NodeTestCase
13
  {
14
- /**
15
- * @covers Twig_Node_Expression_Binary_Or::__construct
16
- */
17
  public function testConstructor()
18
  {
19
  $left = new Twig_Node_Expression_Constant(1, 1);
@@ -24,16 +21,6 @@ class Twig_Tests_Node_Expression_Binary_OrTest extends Twig_Test_NodeTestCase
24
  $this->assertEquals($right, $node->getNode('right'));
25
  }
26
 
27
- /**
28
- * @covers Twig_Node_Expression_Binary_Or::compile
29
- * @covers Twig_Node_Expression_Binary_Or::operator
30
- * @dataProvider getTests
31
- */
32
- public function testCompile($node, $source, $environment = null)
33
- {
34
- parent::testCompile($node, $source, $environment);
35
- }
36
-
37
  public function getTests()
38
  {
39
  $left = new Twig_Node_Expression_Constant(1, 1);
11
 
12
  class Twig_Tests_Node_Expression_Binary_OrTest extends Twig_Test_NodeTestCase
13
  {
 
 
 
14
  public function testConstructor()
15
  {
16
  $left = new Twig_Node_Expression_Constant(1, 1);
21
  $this->assertEquals($right, $node->getNode('right'));
22
  }
23
 
 
 
 
 
 
 
 
 
 
 
24
  public function getTests()
25
  {
26
  $left = new Twig_Node_Expression_Constant(1, 1);
vendor/twig/twig/test/Twig/Tests/Node/Expression/Binary/SubTest.php CHANGED
@@ -11,9 +11,6 @@
11
 
12
  class Twig_Tests_Node_Expression_Binary_SubTest extends Twig_Test_NodeTestCase
13
  {
14
- /**
15
- * @covers Twig_Node_Expression_Binary_Sub::__construct
16
- */
17
  public function testConstructor()
18
  {
19
  $left = new Twig_Node_Expression_Constant(1, 1);
@@ -24,16 +21,6 @@ class Twig_Tests_Node_Expression_Binary_SubTest extends Twig_Test_NodeTestCase
24
  $this->assertEquals($right, $node->getNode('right'));
25
  }
26
 
27
- /**
28
- * @covers Twig_Node_Expression_Binary_Sub::compile
29
- * @covers Twig_Node_Expression_Binary_Sub::operator
30
- * @dataProvider getTests
31
- */
32
- public function testCompile($node, $source, $environment = null)
33
- {
34
- parent::testCompile($node, $source, $environment);
35
- }
36
-
37
  public function getTests()
38
  {
39
  $left = new Twig_Node_Expression_Constant(1, 1);
11
 
12
  class Twig_Tests_Node_Expression_Binary_SubTest extends Twig_Test_NodeTestCase
13
  {
 
 
 
14
  public function testConstructor()
15
  {
16
  $left = new Twig_Node_Expression_Constant(1, 1);
21
  $this->assertEquals($right, $node->getNode('right'));
22
  }
23
 
 
 
 
 
 
 
 
 
 
 
24
  public function getTests()
25
  {
26
  $left = new Twig_Node_Expression_Constant(1, 1);
vendor/twig/twig/test/Twig/Tests/Node/Expression/CallTest.php CHANGED
@@ -39,7 +39,7 @@ class Twig_Tests_Node_Expression_CallTest extends PHPUnit_Framework_TestCase
39
 
40
  /**
41
  * @expectedException Twig_Error_Syntax
42
- * @expectedExceptionMessage Unknown argument "unknown" for function "date".
43
  */
44
  public function testGetArgumentsWithWrongNamedArgumentName()
45
  {
@@ -49,7 +49,7 @@ class Twig_Tests_Node_Expression_CallTest extends PHPUnit_Framework_TestCase
49
 
50
  /**
51
  * @expectedException Twig_Error_Syntax
52
- * @expectedExceptionMessage Unknown arguments "unknown1", "unknown2" for function "date".
53
  */
54
  public function testGetArgumentsWithWrongNamedArgumentNames()
55
  {
39
 
40
  /**
41
  * @expectedException Twig_Error_Syntax
42
+ * @expectedExceptionMessage Unknown argument "unknown" for function "date(format, timestamp)".
43
  */
44
  public function testGetArgumentsWithWrongNamedArgumentName()
45
  {
49
 
50
  /**
51
  * @expectedException Twig_Error_Syntax
52
+ * @expectedExceptionMessage Unknown arguments "unknown1", "unknown2" for function "date(format, timestamp)".
53
  */
54
  public function testGetArgumentsWithWrongNamedArgumentNames()
55
  {
vendor/twig/twig/test/Twig/Tests/Node/Expression/ConditionalTest.php CHANGED
@@ -11,9 +11,6 @@
11
 
12
  class Twig_Tests_Node_Expression_ConditionalTest extends Twig_Test_NodeTestCase
13
  {
14
- /**
15
- * @covers Twig_Node_Expression_Conditional::__construct
16
- */
17
  public function testConstructor()
18
  {
19
  $expr1 = new Twig_Node_Expression_Constant(1, 1);
@@ -26,15 +23,6 @@ class Twig_Tests_Node_Expression_ConditionalTest extends Twig_Test_NodeTestCase
26
  $this->assertEquals($expr3, $node->getNode('expr3'));
27
  }
28
 
29
- /**
30
- * @covers Twig_Node_Expression_Conditional::compile
31
- * @dataProvider getTests
32
- */
33
- public function testCompile($node, $source, $environment = null)
34
- {
35
- parent::testCompile($node, $source, $environment);
36
- }
37
-
38
  public function getTests()
39
  {
40
  $tests = array();
11
 
12
  class Twig_Tests_Node_Expression_ConditionalTest extends Twig_Test_NodeTestCase
13
  {
 
 
 
14
  public function testConstructor()
15
  {
16
  $expr1 = new Twig_Node_Expression_Constant(1, 1);
23
  $this->assertEquals($expr3, $node->getNode('expr3'));
24
  }
25
 
 
 
 
 
 
 
 
 
 
26
  public function getTests()
27
  {
28
  $tests = array();
vendor/twig/twig/test/Twig/Tests/Node/Expression/ConstantTest.php CHANGED
@@ -11,9 +11,6 @@
11
 
12
  class Twig_Tests_Node_Expression_ConstantTest extends Twig_Test_NodeTestCase
13
  {
14
- /**
15
- * @covers Twig_Node_Expression_Constant::__construct
16
- */
17
  public function testConstructor()
18
  {
19
  $node = new Twig_Node_Expression_Constant('foo', 1);
@@ -21,15 +18,6 @@ class Twig_Tests_Node_Expression_ConstantTest extends Twig_Test_NodeTestCase
21
  $this->assertEquals('foo', $node->getAttribute('value'));
22
  }
23
 
24
- /**
25
- * @covers Twig_Node_Expression_Constant::compile
26
- * @dataProvider getTests
27
- */
28
- public function testCompile($node, $source, $environment = null)
29
- {
30
- parent::testCompile($node, $source, $environment);
31
- }
32
-
33
  public function getTests()
34
  {
35
  $tests = array();
11
 
12
  class Twig_Tests_Node_Expression_ConstantTest extends Twig_Test_NodeTestCase
13
  {
 
 
 
14
  public function testConstructor()
15
  {
16
  $node = new Twig_Node_Expression_Constant('foo', 1);
18
  $this->assertEquals('foo', $node->getAttribute('value'));
19
  }
20
 
 
 
 
 
 
 
 
 
 
21
  public function getTests()
22
  {
23
  $tests = array();
vendor/twig/twig/test/Twig/Tests/Node/Expression/FilterTest.php CHANGED
@@ -11,9 +11,6 @@
11
 
12
  class Twig_Tests_Node_Expression_FilterTest extends Twig_Test_NodeTestCase
13
  {
14
- /**
15
- * @covers Twig_Node_Expression_Filter::__construct
16
- */
17
  public function testConstructor()
18
  {
19
  $expr = new Twig_Node_Expression_Constant('foo', 1);
@@ -26,15 +23,6 @@ class Twig_Tests_Node_Expression_FilterTest extends Twig_Test_NodeTestCase
26
  $this->assertEquals($args, $node->getNode('arguments'));
27
  }
28
 
29
- /**
30
- * @covers Twig_Node_Expression_Filter::compile
31
- * @dataProvider getTests
32
- */
33
- public function testCompile($node, $source, $environment = null)
34
- {
35
- parent::testCompile($node, $source, $environment);
36
- }
37
-
38
  public function getTests()
39
  {
40
  $tests = array();
@@ -86,7 +74,7 @@ class Twig_Tests_Node_Expression_FilterTest extends Twig_Test_NodeTestCase
86
 
87
  /**
88
  * @expectedException Twig_Error_Syntax
89
- * @expectedExceptionMessage Unknown argument "foobar" for filter "date".
90
  */
91
  public function testCompileWithWrongNamedArgumentName()
92
  {
11
 
12
  class Twig_Tests_Node_Expression_FilterTest extends Twig_Test_NodeTestCase
13
  {
 
 
 
14
  public function testConstructor()
15
  {
16
  $expr = new Twig_Node_Expression_Constant('foo', 1);
23
  $this->assertEquals($args, $node->getNode('arguments'));
24
  }
25
 
 
 
 
 
 
 
 
 
 
26
  public function getTests()
27
  {
28
  $tests = array();
74
 
75
  /**
76
  * @expectedException Twig_Error_Syntax
77
+ * @expectedExceptionMessage Unknown argument "foobar" for filter "date(format, timezone)".
78
  */
79
  public function testCompileWithWrongNamedArgumentName()
80
  {
vendor/twig/twig/test/Twig/Tests/Node/Expression/FunctionTest.php CHANGED
@@ -11,9 +11,6 @@
11
 
12
  class Twig_Tests_Node_Expression_FunctionTest extends Twig_Test_NodeTestCase
13
  {
14
- /**
15
- * @covers Twig_Node_Expression_Function::__construct
16
- */
17
  public function testConstructor()
18
  {
19
  $name = 'function';
@@ -24,15 +21,6 @@ class Twig_Tests_Node_Expression_FunctionTest extends Twig_Test_NodeTestCase
24
  $this->assertEquals($args, $node->getNode('arguments'));
25
  }
26
 
27
- /**
28
- * @covers Twig_Node_Expression_Function::compile
29
- * @dataProvider getTests
30
- */
31
- public function testCompile($node, $source, $environment = null)
32
- {
33
- parent::testCompile($node, $source, $environment);
34
- }
35
-
36
  public function getTests()
37
  {
38
  $environment = new Twig_Environment();
11
 
12
  class Twig_Tests_Node_Expression_FunctionTest extends Twig_Test_NodeTestCase
13
  {
 
 
 
14
  public function testConstructor()
15
  {
16
  $name = 'function';
21
  $this->assertEquals($args, $node->getNode('arguments'));
22
  }
23
 
 
 
 
 
 
 
 
 
 
24
  public function getTests()
25
  {
26
  $environment = new Twig_Environment();
vendor/twig/twig/test/Twig/Tests/Node/Expression/GetAttrTest.php CHANGED
@@ -11,9 +11,6 @@
11
 
12
  class Twig_Tests_Node_Expression_GetAttrTest extends Twig_Test_NodeTestCase
13
  {
14
- /**
15
- * @covers Twig_Node_Expression_GetAttr::__construct
16
- */
17
  public function testConstructor()
18
  {
19
  $expr = new Twig_Node_Expression_Name('foo', 1);
@@ -29,15 +26,6 @@ class Twig_Tests_Node_Expression_GetAttrTest extends Twig_Test_NodeTestCase
29
  $this->assertEquals(Twig_Template::ARRAY_CALL, $node->getAttribute('type'));
30
  }
31
 
32
- /**
33
- * @covers Twig_Node_Expression_GetAttr::compile
34
- * @dataProvider getTests
35
- */
36
- public function testCompile($node, $source, $environment = null)
37
- {
38
- parent::testCompile($node, $source, $environment);
39
- }
40
-
41
  public function getTests()
42
  {
43
  $tests = array();
@@ -46,7 +34,7 @@ class Twig_Tests_Node_Expression_GetAttrTest extends Twig_Test_NodeTestCase
46
  $attr = new Twig_Node_Expression_Constant('bar', 1);
47
  $args = new Twig_Node_Expression_Array(array(), 1);
48
  $node = new Twig_Node_Expression_GetAttr($expr, $attr, $args, Twig_Template::ANY_CALL, 1);
49
- $tests[] = array($node, sprintf('%s%s, "bar")', $this->getAttributeGetter(), $this->getVariableGetter('foo')));
50
 
51
  $node = new Twig_Node_Expression_GetAttr($expr, $attr, $args, Twig_Template::ARRAY_CALL, 1);
52
  $tests[] = array($node, sprintf('%s%s, "bar", array(), "array")', $this->getAttributeGetter(), $this->getVariableGetter('foo')));
11
 
12
  class Twig_Tests_Node_Expression_GetAttrTest extends Twig_Test_NodeTestCase
13
  {
 
 
 
14
  public function testConstructor()
15
  {
16
  $expr = new Twig_Node_Expression_Name('foo', 1);
26
  $this->assertEquals(Twig_Template::ARRAY_CALL, $node->getAttribute('type'));
27
  }
28
 
 
 
 
 
 
 
 
 
 
29
  public function getTests()
30
  {
31
  $tests = array();
34
  $attr = new Twig_Node_Expression_Constant('bar', 1);
35
  $args = new Twig_Node_Expression_Array(array(), 1);
36
  $node = new Twig_Node_Expression_GetAttr($expr, $attr, $args, Twig_Template::ANY_CALL, 1);
37
+ $tests[] = array($node, sprintf('%s%s, "bar", array())', $this->getAttributeGetter(), $this->getVariableGetter('foo')));
38
 
39
  $node = new Twig_Node_Expression_GetAttr($expr, $attr, $args, Twig_Template::ARRAY_CALL, 1);
40
  $tests[] = array($node, sprintf('%s%s, "bar", array(), "array")', $this->getAttributeGetter(), $this->getVariableGetter('foo')));
vendor/twig/twig/test/Twig/Tests/Node/Expression/NameTest.php CHANGED
@@ -11,9 +11,6 @@
11
 
12
  class Twig_Tests_Node_Expression_NameTest extends Twig_Test_NodeTestCase
13
  {
14
- /**
15
- * @covers Twig_Node_Expression_Name::__construct
16
- */
17
  public function testConstructor()
18
  {
19
  $node = new Twig_Node_Expression_Name('foo', 1);
@@ -21,15 +18,6 @@ class Twig_Tests_Node_Expression_NameTest extends Twig_Test_NodeTestCase
21
  $this->assertEquals('foo', $node->getAttribute('name'));
22
  }
23
 
24
- /**
25
- * @covers Twig_Node_Expression_Name::compile
26
- * @dataProvider getTests
27
- */
28
- public function testCompile($node, $source, $environment = null)
29
- {
30
- parent::testCompile($node, $source, $environment);
31
- }
32
-
33
  public function getTests()
34
  {
35
  $node = new Twig_Node_Expression_Name('foo', 1);
11
 
12
  class Twig_Tests_Node_Expression_NameTest extends Twig_Test_NodeTestCase
13
  {
 
 
 
14
  public function testConstructor()
15
  {
16
  $node = new Twig_Node_Expression_Name('foo', 1);
18
  $this->assertEquals('foo', $node->getAttribute('name'));
19
  }
20
 
 
 
 
 
 
 
 
 
 
21
  public function getTests()
22
  {
23
  $node = new Twig_Node_Expression_Name('foo', 1);
vendor/twig/twig/test/Twig/Tests/Node/Expression/ParentTest.php CHANGED
@@ -11,9 +11,6 @@
11
 
12
  class Twig_Tests_Node_Expression_ParentTest extends Twig_Test_NodeTestCase
13
  {
14
- /**
15
- * @covers Twig_Node_Expression_Parent::__construct
16
- */
17
  public function testConstructor()
18
  {
19
  $node = new Twig_Node_Expression_Parent('foo', 1);
@@ -21,15 +18,6 @@ class Twig_Tests_Node_Expression_ParentTest extends Twig_Test_NodeTestCase
21
  $this->assertEquals('foo', $node->getAttribute('name'));
22
  }
23
 
24
- /**
25
- * @covers Twig_Node_Expression_Parent::compile
26
- * @dataProvider getTests
27
- */
28
- public function testCompile($node, $source, $environment = null)
29
- {
30
- parent::testCompile($node, $source, $environment);
31
- }
32
-
33
  public function getTests()
34
  {
35
  $tests = array();
11
 
12
  class Twig_Tests_Node_Expression_ParentTest extends Twig_Test_NodeTestCase
13
  {
 
 
 
14
  public function testConstructor()
15
  {
16
  $node = new Twig_Node_Expression_Parent('foo', 1);
18
  $this->assertEquals('foo', $node->getAttribute('name'));
19
  }
20
 
 
 
 
 
 
 
 
 
 
21
  public function getTests()
22
  {
23
  $tests = array();
vendor/twig/twig/test/Twig/Tests/Node/Expression/TestTest.php CHANGED
@@ -11,9 +11,6 @@
11
 
12
  class Twig_Tests_Node_Expression_TestTest extends Twig_Test_NodeTestCase
13
  {
14
- /**
15
- * @covers Twig_Node_Expression_Test::__construct
16
- */
17
  public function testConstructor()
18
  {
19
  $expr = new Twig_Node_Expression_Constant('foo', 1);
@@ -26,15 +23,6 @@ class Twig_Tests_Node_Expression_TestTest extends Twig_Test_NodeTestCase
26
  $this->assertEquals($name, $node->getAttribute('name'));
27
  }
28
 
29
- /**
30
- * @covers Twig_Node_Expression_Test::compile
31
- * @dataProvider getTests
32
- */
33
- public function testCompile($node, $source, $environment = null)
34
- {
35
- parent::testCompile($node, $source, $environment);
36
- }
37
-
38
  public function getTests()
39
  {
40
  $tests = array();
11
 
12
  class Twig_Tests_Node_Expression_TestTest extends Twig_Test_NodeTestCase
13
  {
 
 
 
14
  public function testConstructor()
15
  {
16
  $expr = new Twig_Node_Expression_Constant('foo', 1);
23
  $this->assertEquals($name, $node->getAttribute('name'));
24
  }
25
 
 
 
 
 
 
 
 
 
 
26
  public function getTests()
27
  {
28
  $tests = array();
vendor/twig/twig/test/Twig/Tests/Node/Expression/Unary/NegTest.php CHANGED
@@ -11,9 +11,6 @@
11
 
12
  class Twig_Tests_Node_Expression_Unary_NegTest extends Twig_Test_NodeTestCase
13
  {
14
- /**
15
- * @covers Twig_Node_Expression_Unary_Neg::__construct
16
- */
17
  public function testConstructor()
18
  {
19
  $expr = new Twig_Node_Expression_Constant(1, 1);
@@ -22,23 +19,14 @@ class Twig_Tests_Node_Expression_Unary_NegTest extends Twig_Test_NodeTestCase
22
  $this->assertEquals($expr, $node->getNode('node'));
23
  }
24
 
25
- /**
26
- * @covers Twig_Node_Expression_Unary_Neg::compile
27
- * @covers Twig_Node_Expression_Unary_Neg::operator
28
- * @dataProvider getTests
29
- */
30
- public function testCompile($node, $source, $environment = null)
31
- {
32
- parent::testCompile($node, $source, $environment);
33
- }
34
-
35
  public function getTests()
36
  {
37
  $node = new Twig_Node_Expression_Constant(1, 1);
38
  $node = new Twig_Node_Expression_Unary_Neg($node, 1);
39
 
40
  return array(
41
- array($node, '(-1)'),
 
42
  );
43
  }
44
  }
11
 
12
  class Twig_Tests_Node_Expression_Unary_NegTest extends Twig_Test_NodeTestCase
13
  {
 
 
 
14
  public function testConstructor()
15
  {
16
  $expr = new Twig_Node_Expression_Constant(1, 1);
19
  $this->assertEquals($expr, $node->getNode('node'));
20
  }
21
 
 
 
 
 
 
 
 
 
 
 
22
  public function getTests()
23
  {
24
  $node = new Twig_Node_Expression_Constant(1, 1);
25
  $node = new Twig_Node_Expression_Unary_Neg($node, 1);
26
 
27
  return array(
28
+ array($node, '-1'),
29
+ array(new Twig_Node_Expression_Unary_Neg($node, 1), '- -1'),
30
  );
31
  }
32
  }
vendor/twig/twig/test/Twig/Tests/Node/Expression/Unary/NotTest.php CHANGED
@@ -11,9 +11,6 @@
11
 
12
  class Twig_Tests_Node_Expression_Unary_NotTest extends Twig_Test_NodeTestCase
13
  {
14
- /**
15
- * @covers Twig_Node_Expression_Unary_Not::__construct
16
- */
17
  public function testConstructor()
18
  {
19
  $expr = new Twig_Node_Expression_Constant(1, 1);
@@ -22,23 +19,13 @@ class Twig_Tests_Node_Expression_Unary_NotTest extends Twig_Test_NodeTestCase
22
  $this->assertEquals($expr, $node->getNode('node'));
23
  }
24
 
25
- /**
26
- * @covers Twig_Node_Expression_Unary_Not::compile
27
- * @covers Twig_Node_Expression_Unary_Not::operator
28
- * @dataProvider getTests
29
- */
30
- public function testCompile($node, $source, $environment = null)
31
- {
32
- parent::testCompile($node, $source, $environment);
33
- }
34
-
35
  public function getTests()
36
  {
37
  $node = new Twig_Node_Expression_Constant(1, 1);
38
  $node = new Twig_Node_Expression_Unary_Not($node, 1);
39
 
40
  return array(
41
- array($node, '(!1)'),
42
  );
43
  }
44
  }
11
 
12
  class Twig_Tests_Node_Expression_Unary_NotTest extends Twig_Test_NodeTestCase
13
  {
 
 
 
14
  public function testConstructor()
15
  {
16
  $expr = new Twig_Node_Expression_Constant(1, 1);
19
  $this->assertEquals($expr, $node->getNode('node'));
20
  }
21
 
 
 
 
 
 
 
 
 
 
 
22
  public function getTests()
23
  {
24
  $node = new Twig_Node_Expression_Constant(1, 1);
25
  $node = new Twig_Node_Expression_Unary_Not($node, 1);
26
 
27
  return array(
28
+ array($node, '!1'),
29
  );
30
  }
31
  }
vendor/twig/twig/test/Twig/Tests/Node/Expression/Unary/PosTest.php CHANGED
@@ -11,9 +11,6 @@
11
 
12
  class Twig_Tests_Node_Expression_Unary_PosTest extends Twig_Test_NodeTestCase
13
  {
14
- /**
15
- * @covers Twig_Node_Expression_Unary_Pos::__construct
16
- */
17
  public function testConstructor()
18
  {
19
  $expr = new Twig_Node_Expression_Constant(1, 1);
@@ -22,23 +19,13 @@ class Twig_Tests_Node_Expression_Unary_PosTest extends Twig_Test_NodeTestCase
22
  $this->assertEquals($expr, $node->getNode('node'));
23
  }
24
 
25
- /**
26
- * @covers Twig_Node_Expression_Unary_Pos::compile
27
- * @covers Twig_Node_Expression_Unary_Pos::operator
28
- * @dataProvider getTests
29
- */
30
- public function testCompile($node, $source, $environment = null)
31
- {
32
- parent::testCompile($node, $source, $environment);
33
- }
34
-
35
  public function getTests()
36
  {
37
  $node = new Twig_Node_Expression_Constant(1, 1);
38
  $node = new Twig_Node_Expression_Unary_Pos($node, 1);
39
 
40
  return array(
41
- array($node, '(+1)'),
42
  );
43
  }
44
  }
11
 
12
  class Twig_Tests_Node_Expression_Unary_PosTest extends Twig_Test_NodeTestCase
13
  {
 
 
 
14
  public function testConstructor()
15
  {
16
  $expr = new Twig_Node_Expression_Constant(1, 1);
19
  $this->assertEquals($expr, $node->getNode('node'));
20
  }
21
 
 
 
 
 
 
 
 
 
 
 
22
  public function getTests()
23
  {
24
  $node = new Twig_Node_Expression_Constant(1, 1);
25
  $node = new Twig_Node_Expression_Unary_Pos($node, 1);
26
 
27
  return array(
28
+ array($node, '+1'),
29
  );
30
  }
31
  }
vendor/twig/twig/test/Twig/Tests/Node/ForTest.php CHANGED
@@ -11,9 +11,6 @@
11
 
12
  class Twig_Tests_Node_ForTest extends Twig_Test_NodeTestCase
13
  {
14
- /**
15
- * @covers Twig_Node_For::__construct
16
- */
17
  public function testConstructor()
18
  {
19
  $keyTarget = new Twig_Node_Expression_AssignName('key', 1);
@@ -39,15 +36,6 @@ class Twig_Tests_Node_ForTest extends Twig_Test_NodeTestCase
39
  $this->assertEquals($else, $node->getNode('else'));
40
  }
41
 
42
- /**
43
- * @covers Twig_Node_For::compile
44
- * @dataProvider getTests
45
- */
46
- public function testCompile($node, $source, $environment = null)
47
- {
48
- parent::testCompile($node, $source, $environment);
49
- }
50
-
51
  public function getTests()
52
  {
53
  $tests = array();
11
 
12
  class Twig_Tests_Node_ForTest extends Twig_Test_NodeTestCase
13
  {
 
 
 
14
  public function testConstructor()
15
  {
16
  $keyTarget = new Twig_Node_Expression_AssignName('key', 1);
36
  $this->assertEquals($else, $node->getNode('else'));
37
  }
38
 
 
 
 
 
 
 
 
 
 
39
  public function getTests()
40
  {
41
  $tests = array();
vendor/twig/twig/test/Twig/Tests/Node/IfTest.php CHANGED
@@ -11,9 +11,6 @@
11
 
12
  class Twig_Tests_Node_IfTest extends Twig_Test_NodeTestCase
13
  {
14
- /**
15
- * @covers Twig_Node_If::__construct
16
- */
17
  public function testConstructor()
18
  {
19
  $t = new Twig_Node(array(
@@ -31,15 +28,6 @@ class Twig_Tests_Node_IfTest extends Twig_Test_NodeTestCase
31
  $this->assertEquals($else, $node->getNode('else'));
32
  }
33
 
34
- /**
35
- * @covers Twig_Node_If::compile
36
- * @dataProvider getTests
37
- */
38
- public function testCompile($node, $source, $environment = null)
39
- {
40
- parent::testCompile($node, $source, $environment);
41
- }
42
-
43
  public function getTests()
44
  {
45
  $tests = array();
11
 
12
  class Twig_Tests_Node_IfTest extends Twig_Test_NodeTestCase
13
  {
 
 
 
14
  public function testConstructor()
15
  {
16
  $t = new Twig_Node(array(
28
  $this->assertEquals($else, $node->getNode('else'));
29
  }
30
 
 
 
 
 
 
 
 
 
 
31
  public function getTests()
32
  {
33
  $tests = array();
vendor/twig/twig/test/Twig/Tests/Node/ImportTest.php CHANGED
@@ -11,9 +11,6 @@
11
 
12
  class Twig_Tests_Node_ImportTest extends Twig_Test_NodeTestCase
13
  {
14
- /**
15
- * @covers Twig_Node_Import::__construct
16
- */
17
  public function testConstructor()
18
  {
19
  $macro = new Twig_Node_Expression_Constant('foo.twig', 1);
@@ -24,15 +21,6 @@ class Twig_Tests_Node_ImportTest extends Twig_Test_NodeTestCase
24
  $this->assertEquals($var, $node->getNode('var'));
25
  }
26
 
27
- /**
28
- * @covers Twig_Node_Import::compile
29
- * @dataProvider getTests
30
- */
31
- public function testCompile($node, $source, $environment = null)
32
- {
33
- parent::testCompile($node, $source, $environment);
34
- }
35
-
36
  public function getTests()
37
  {
38
  $tests = array();
11
 
12
  class Twig_Tests_Node_ImportTest extends Twig_Test_NodeTestCase
13
  {
 
 
 
14
  public function testConstructor()
15
  {
16
  $macro = new Twig_Node_Expression_Constant('foo.twig', 1);
21
  $this->assertEquals($var, $node->getNode('var'));
22
  }
23
 
 
 
 
 
 
 
 
 
 
24
  public function getTests()
25
  {
26
  $tests = array();
vendor/twig/twig/test/Twig/Tests/Node/IncludeTest.php CHANGED
@@ -11,9 +11,6 @@
11
 
12
  class Twig_Tests_Node_IncludeTest extends Twig_Test_NodeTestCase
13
  {
14
- /**
15
- * @covers Twig_Node_Include::__construct
16
- */
17
  public function testConstructor()
18
  {
19
  $expr = new Twig_Node_Expression_Constant('foo.twig', 1);
@@ -29,15 +26,6 @@ class Twig_Tests_Node_IncludeTest extends Twig_Test_NodeTestCase
29
  $this->assertTrue($node->getAttribute('only'));
30
  }
31
 
32
- /**
33
- * @covers Twig_Node_Include::compile
34
- * @dataProvider getTests
35
- */
36
- public function testCompile($node, $source, $environment = null)
37
- {
38
- parent::testCompile($node, $source, $environment);
39
- }
40
-
41
  public function getTests()
42
  {
43
  $tests = array();
@@ -59,8 +47,7 @@ EOF
59
  $node = new Twig_Node_Include($expr, null, false, false, 1);
60
  $tests[] = array($node, <<<EOF
61
  // line 1
62
- \$template = \$this->env->resolveTemplate(((true) ? ("foo") : ("foo")));
63
- \$template->display(\$context);
64
  EOF
65
  );
66
 
11
 
12
  class Twig_Tests_Node_IncludeTest extends Twig_Test_NodeTestCase
13
  {
 
 
 
14
  public function testConstructor()
15
  {
16
  $expr = new Twig_Node_Expression_Constant('foo.twig', 1);
26
  $this->assertTrue($node->getAttribute('only'));
27
  }
28
 
 
 
 
 
 
 
 
 
 
29
  public function getTests()
30
  {
31
  $tests = array();
47
  $node = new Twig_Node_Include($expr, null, false, false, 1);
48
  $tests[] = array($node, <<<EOF
49
  // line 1
50
+ \$this->env->resolveTemplate(((true) ? ("foo") : ("foo")))->display(\$context);
 
51
  EOF
52
  );
53
 
vendor/twig/twig/test/Twig/Tests/Node/MacroTest.php CHANGED
@@ -11,9 +11,6 @@
11
 
12
  class Twig_Tests_Node_MacroTest extends Twig_Test_NodeTestCase
13
  {
14
- /**
15
- * @covers Twig_Node_Macro::__construct
16
- */
17
  public function testConstructor()
18
  {
19
  $body = new Twig_Node_Text('foo', 1);
@@ -25,15 +22,6 @@ class Twig_Tests_Node_MacroTest extends Twig_Test_NodeTestCase
25
  $this->assertEquals('foo', $node->getAttribute('name'));
26
  }
27
 
28
- /**
29
- * @covers Twig_Node_Macro::compile
30
- * @dataProvider getTests
31
- */
32
- public function testCompile($node, $source, $environment = null)
33
- {
34
- parent::testCompile($node, $source, $environment);
35
- }
36
-
37
  public function getTests()
38
  {
39
  $body = new Twig_Node_Text('foo', 1);
@@ -46,11 +34,11 @@ class Twig_Tests_Node_MacroTest extends Twig_Test_NodeTestCase
46
  return array(
47
  array($node, <<<EOF
48
  // line 1
49
- public function getfoo(\$_foo = null, \$_bar = "Foo")
50
  {
51
  \$context = \$this->env->mergeGlobals(array(
52
- "foo" => \$_foo,
53
- "bar" => \$_bar,
54
  ));
55
 
56
  \$blocks = array();
11
 
12
  class Twig_Tests_Node_MacroTest extends Twig_Test_NodeTestCase
13
  {
 
 
 
14
  public function testConstructor()
15
  {
16
  $body = new Twig_Node_Text('foo', 1);
22
  $this->assertEquals('foo', $node->getAttribute('name'));
23
  }
24
 
 
 
 
 
 
 
 
 
 
25
  public function getTests()
26
  {
27
  $body = new Twig_Node_Text('foo', 1);
34
  return array(
35
  array($node, <<<EOF
36
  // line 1
37
+ public function getfoo(\$__foo__ = null, \$__bar__ = "Foo")
38
  {
39
  \$context = \$this->env->mergeGlobals(array(
40
+ "foo" => \$__foo__,
41
+ "bar" => \$__bar__,
42
  ));
43
 
44
  \$blocks = array();
vendor/twig/twig/test/Twig/Tests/Node/ModuleTest.php CHANGED
@@ -11,9 +11,6 @@
11
 
12
  class Twig_Tests_Node_ModuleTest extends Twig_Test_NodeTestCase
13
  {
14
- /**
15
- * @covers Twig_Node_Module::__construct
16
- */
17
  public function testConstructor()
18
  {
19
  $body = new Twig_Node_Text('foo', 1);
@@ -31,22 +28,6 @@ class Twig_Tests_Node_ModuleTest extends Twig_Test_NodeTestCase
31
  $this->assertEquals($filename, $node->getAttribute('filename'));
32
  }
33
 
34
- /**
35
- * @covers Twig_Node_Module::compile
36
- * @covers Twig_Node_Module::compileTemplate
37
- * @covers Twig_Node_Module::compileMacros
38
- * @covers Twig_Node_Module::compileClassHeader
39
- * @covers Twig_Node_Module::compileDisplayHeader
40
- * @covers Twig_Node_Module::compileDisplayBody
41
- * @covers Twig_Node_Module::compileDisplayFooter
42
- * @covers Twig_Node_Module::compileClassFooter
43
- * @dataProvider getTests
44
- */
45
- public function testCompile($node, $source, $environment = null)
46
- {
47
- parent::testCompile($node, $source, $environment);
48
- }
49
-
50
  public function getTests()
51
  {
52
  $twig = new Twig_Environment(new Twig_Loader_String());
@@ -96,7 +77,7 @@ class __TwigTemplate_a2bfbf7dd6ab85666684fe9297f69363a3fc2046d90f22a317d380c1863
96
  EOF
97
  , $twig);
98
 
99
- $import = new Twig_Node_Import(new Twig_Node_Expression_Constant('foo.twig', 1), new Twig_Node_Expression_AssignName('macro', 1), 1);
100
 
101
  $body = new Twig_Node(array($import));
102
  $extends = new Twig_Node_Expression_Constant('layout.twig', 1);
@@ -112,7 +93,15 @@ class __TwigTemplate_a2bfbf7dd6ab85666684fe9297f69363a3fc2046d90f22a317d380c1863
112
  {
113
  parent::__construct(\$env);
114
 
115
- \$this->parent = \$this->env->loadTemplate("layout.twig");
 
 
 
 
 
 
 
 
116
 
117
  \$this->blocks = array(
118
  );
@@ -125,8 +114,9 @@ class __TwigTemplate_a2bfbf7dd6ab85666684fe9297f69363a3fc2046d90f22a317d380c1863
125
 
126
  protected function doDisplay(array \$context, array \$blocks = array())
127
  {
128
- // line 1
129
  \$context["macro"] = \$this->env->loadTemplate("foo.twig");
 
130
  \$this->parent->display(\$context, array_merge(\$this->blocks, \$blocks));
131
  }
132
 
@@ -142,18 +132,19 @@ class __TwigTemplate_a2bfbf7dd6ab85666684fe9297f69363a3fc2046d90f22a317d380c1863
142
 
143
  public function getDebugInfo()
144
  {
145
- return array ( 24 => 1,);
146
  }
147
  }
148
  EOF
149
  , $twig);
150
 
151
- $body = new Twig_Node();
 
152
  $extends = new Twig_Node_Expression_Conditional(
153
- new Twig_Node_Expression_Constant(true, 1),
154
- new Twig_Node_Expression_Constant('foo', 1),
155
- new Twig_Node_Expression_Constant('foo', 1),
156
- 0
157
  );
158
 
159
  $node = new Twig_Node_Module($body, $extends, $blocks, $macros, $traits, new Twig_Node(array()), $filename);
@@ -165,11 +156,15 @@ class __TwigTemplate_a2bfbf7dd6ab85666684fe9297f69363a3fc2046d90f22a317d380c1863
165
  {
166
  protected function doGetParent(array \$context)
167
  {
 
168
  return \$this->env->resolveTemplate(((true) ? ("foo") : ("foo")));
169
  }
170
 
171
  protected function doDisplay(array \$context, array \$blocks = array())
172
  {
 
 
 
173
  \$this->getParent(\$context)->display(\$context, array_merge(\$this->blocks, \$blocks));
174
  }
175
 
@@ -185,7 +180,7 @@ class __TwigTemplate_a2bfbf7dd6ab85666684fe9297f69363a3fc2046d90f22a317d380c1863
185
 
186
  public function getDebugInfo()
187
  {
188
- return array ();
189
  }
190
  }
191
  EOF
11
 
12
  class Twig_Tests_Node_ModuleTest extends Twig_Test_NodeTestCase
13
  {
 
 
 
14
  public function testConstructor()
15
  {
16
  $body = new Twig_Node_Text('foo', 1);
28
  $this->assertEquals($filename, $node->getAttribute('filename'));
29
  }
30
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  public function getTests()
32
  {
33
  $twig = new Twig_Environment(new Twig_Loader_String());
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
 
82
  $body = new Twig_Node(array($import));
83
  $extends = new Twig_Node_Expression_Constant('layout.twig', 1);
93
  {
94
  parent::__construct(\$env);
95
 
96
+ // line 1
97
+ try {
98
+ \$this->parent = \$this->env->loadTemplate("layout.twig");
99
+ } catch (Twig_Error_Loader \$e) {
100
+ \$e->setTemplateFile(\$this->getTemplateName());
101
+ \$e->setTemplateLine(1);
102
+
103
+ throw \$e;
104
+ }
105
 
106
  \$this->blocks = array(
107
  );
114
 
115
  protected function doDisplay(array \$context, array \$blocks = array())
116
  {
117
+ // line 2
118
  \$context["macro"] = \$this->env->loadTemplate("foo.twig");
119
+ // line 1
120
  \$this->parent->display(\$context, array_merge(\$this->blocks, \$blocks));
121
  }
122
 
132
 
133
  public function getDebugInfo()
134
  {
135
+ return array ( 34 => 1, 32 => 2, 11 => 1,);
136
  }
137
  }
138
  EOF
139
  , $twig);
140
 
141
+ $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);
142
+ $body = new Twig_Node(array($set));
143
  $extends = new Twig_Node_Expression_Conditional(
144
+ new Twig_Node_Expression_Constant(true, 2),
145
+ new Twig_Node_Expression_Constant('foo', 2),
146
+ new Twig_Node_Expression_Constant('foo', 2),
147
+ 2
148
  );
149
 
150
  $node = new Twig_Node_Module($body, $extends, $blocks, $macros, $traits, new Twig_Node(array()), $filename);
156
  {
157
  protected function doGetParent(array \$context)
158
  {
159
+ // line 2
160
  return \$this->env->resolveTemplate(((true) ? ("foo") : ("foo")));
161
  }
162
 
163
  protected function doDisplay(array \$context, array \$blocks = array())
164
  {
165
+ // line 4
166
+ \$context["foo"] = "foo";
167
+ // line 2
168
  \$this->getParent(\$context)->display(\$context, array_merge(\$this->blocks, \$blocks));
169
  }
170
 
180
 
181
  public function getDebugInfo()
182
  {
183
+ return array ( 17 => 2, 15 => 4, 9 => 2,);
184
  }
185
  }
186
  EOF
vendor/twig/twig/test/Twig/Tests/Node/PrintTest.php CHANGED
@@ -11,9 +11,6 @@
11
 
12
  class Twig_Tests_Node_PrintTest extends Twig_Test_NodeTestCase
13
  {
14
- /**
15
- * @covers Twig_Node_Print::__construct
16
- */
17
  public function testConstructor()
18
  {
19
  $expr = new Twig_Node_Expression_Constant('foo', 1);
@@ -22,15 +19,6 @@ class Twig_Tests_Node_PrintTest extends Twig_Test_NodeTestCase
22
  $this->assertEquals($expr, $node->getNode('expr'));
23
  }
24
 
25
- /**
26
- * @covers Twig_Node_Print::compile
27
- * @dataProvider getTests
28
- */
29
- public function testCompile($node, $source, $environment = null)
30
- {
31
- parent::testCompile($node, $source, $environment);
32
- }
33
-
34
  public function getTests()
35
  {
36
  $tests = array();
11
 
12
  class Twig_Tests_Node_PrintTest extends Twig_Test_NodeTestCase
13
  {
 
 
 
14
  public function testConstructor()
15
  {
16
  $expr = new Twig_Node_Expression_Constant('foo', 1);
19
  $this->assertEquals($expr, $node->getNode('expr'));
20
  }
21
 
 
 
 
 
 
 
 
 
 
22
  public function getTests()
23
  {
24
  $tests = array();
vendor/twig/twig/test/Twig/Tests/Node/SandboxTest.php CHANGED
@@ -11,9 +11,6 @@
11
 
12
  class Twig_Tests_Node_SandboxTest extends Twig_Test_NodeTestCase
13
  {
14
- /**
15
- * @covers Twig_Node_Sandbox::__construct
16
- */
17
  public function testConstructor()
18
  {
19
  $body = new Twig_Node_Text('foo', 1);
@@ -22,15 +19,6 @@ class Twig_Tests_Node_SandboxTest extends Twig_Test_NodeTestCase
22
  $this->assertEquals($body, $node->getNode('body'));
23
  }
24
 
25
- /**
26
- * @covers Twig_Node_Sandbox::compile
27
- * @dataProvider getTests
28
- */
29
- public function testCompile($node, $source, $environment = null)
30
- {
31
- parent::testCompile($node, $source, $environment);
32
- }
33
-
34
  public function getTests()
35
  {
36
  $tests = array();
11
 
12
  class Twig_Tests_Node_SandboxTest extends Twig_Test_NodeTestCase
13
  {
 
 
 
14
  public function testConstructor()
15
  {
16
  $body = new Twig_Node_Text('foo', 1);
19
  $this->assertEquals($body, $node->getNode('body'));
20
  }
21
 
 
 
 
 
 
 
 
 
 
22
  public function getTests()
23
  {
24
  $tests = array();
vendor/twig/twig/test/Twig/Tests/Node/SandboxedModuleTest.php CHANGED
@@ -11,9 +11,6 @@
11
 
12
  class Twig_Tests_Node_SandboxedModuleTest extends Twig_Test_NodeTestCase
13
  {
14
- /**
15
- * @covers Twig_Node_SandboxedModule::__construct
16
- */
17
  public function testConstructor()
18
  {
19
  $body = new Twig_Node_Text('foo', 1);
@@ -32,17 +29,6 @@ class Twig_Tests_Node_SandboxedModuleTest extends Twig_Test_NodeTestCase
32
  $this->assertEquals($filename, $node->getAttribute('filename'));
33
  }
34
 
35
- /**
36
- * @covers Twig_Node_SandboxedModule::compile
37
- * @covers Twig_Node_SandboxedModule::compileDisplayBody
38
- * @covers Twig_Node_SandboxedModule::compileDisplayFooter
39
- * @dataProvider getTests
40
- */
41
- public function testCompile($node, $source, $environment = null)
42
- {
43
- parent::testCompile($node, $source, $environment);
44
- }
45
-
46
  public function getTests()
47
  {
48
  $twig = new Twig_Environment(new Twig_Loader_String());
@@ -84,11 +70,29 @@ class __TwigTemplate_a2bfbf7dd6ab85666684fe9297f69363a3fc2046d90f22a317d380c1863
84
 
85
  protected function checkSecurity()
86
  {
87
- \$this->env->getExtension('sandbox')->checkSecurity(
88
- array('upper'),
89
- array('for'),
90
- array('cycle')
91
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92
  }
93
 
94
  public function getTemplateName()
@@ -124,7 +128,15 @@ class __TwigTemplate_a2bfbf7dd6ab85666684fe9297f69363a3fc2046d90f22a317d380c1863
124
  {
125
  parent::__construct(\$env);
126
 
127
- \$this->parent = \$this->env->loadTemplate("layout.twig");
 
 
 
 
 
 
 
 
128
 
129
  \$this->blocks = array(
130
  );
@@ -143,11 +155,29 @@ class __TwigTemplate_a2bfbf7dd6ab85666684fe9297f69363a3fc2046d90f22a317d380c1863
143
 
144
  protected function checkSecurity()
145
  {
146
- \$this->env->getExtension('sandbox')->checkSecurity(
147
- array('upper'),
148
- array('for'),
149
- array('cycle')
150
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
151
  }
152
 
153
  public function getTemplateName()
@@ -162,7 +192,7 @@ class __TwigTemplate_a2bfbf7dd6ab85666684fe9297f69363a3fc2046d90f22a317d380c1863
162
 
163
  public function getDebugInfo()
164
  {
165
- return array ();
166
  }
167
  }
168
  EOF
11
 
12
  class Twig_Tests_Node_SandboxedModuleTest extends Twig_Test_NodeTestCase
13
  {
 
 
 
14
  public function testConstructor()
15
  {
16
  $body = new Twig_Node_Text('foo', 1);
29
  $this->assertEquals($filename, $node->getAttribute('filename'));
30
  }
31
 
 
 
 
 
 
 
 
 
 
 
 
32
  public function getTests()
33
  {
34
  $twig = new Twig_Environment(new Twig_Loader_String());
70
 
71
  protected function checkSecurity()
72
  {
73
+ \$tags = array();
74
+ \$filters = array();
75
+ \$functions = array();
76
+
77
+ try {
78
+ \$this->env->getExtension('sandbox')->checkSecurity(
79
+ array('upper'),
80
+ array('for'),
81
+ array('cycle')
82
+ );
83
+ } catch (Twig_Sandbox_SecurityError \$e) {
84
+ \$e->setTemplateFile(\$this->getTemplateName());
85
+
86
+ if (\$e instanceof Twig_Sandbox_SecurityNotAllowedTagError && isset(\$tags[\$e->getTagName()])) {
87
+ \$e->setTemplateLine(\$tags[\$e->getTagName()]);
88
+ } elseif (\$e instanceof Twig_Sandbox_SecurityNotAllowedFilterError && isset(\$filters[\$e->getFilterName()])) {
89
+ \$e->setTemplateLine(\$filters[\$e->getFilterName()]);
90
+ } elseif (\$e instanceof Twig_Sandbox_SecurityNotAllowedFunctionError && isset(\$functions[\$e->getFunctionName()])) {
91
+ \$e->setTemplateLine(\$functions[\$e->getFunctionName()]);
92
+ }
93
+
94
+ throw \$e;
95
+ }
96
  }
97
 
98
  public function getTemplateName()
128
  {
129
  parent::__construct(\$env);
130
 
131
+ // line 1
132
+ try {
133
+ \$this->parent = \$this->env->loadTemplate("layout.twig");
134
+ } catch (Twig_Error_Loader \$e) {
135
+ \$e->setTemplateFile(\$this->getTemplateName());
136
+ \$e->setTemplateLine(1);
137
+
138
+ throw \$e;
139
+ }
140
 
141
  \$this->blocks = array(
142
  );
155
 
156
  protected function checkSecurity()
157
  {
158
+ \$tags = array();
159
+ \$filters = array();
160
+ \$functions = array();
161
+
162
+ try {
163
+ \$this->env->getExtension('sandbox')->checkSecurity(
164
+ array('upper'),
165
+ array('for'),
166
+ array('cycle')
167
+ );
168
+ } catch (Twig_Sandbox_SecurityError \$e) {
169
+ \$e->setTemplateFile(\$this->getTemplateName());
170
+
171
+ if (\$e instanceof Twig_Sandbox_SecurityNotAllowedTagError && isset(\$tags[\$e->getTagName()])) {
172
+ \$e->setTemplateLine(\$tags[\$e->getTagName()]);
173
+ } elseif (\$e instanceof Twig_Sandbox_SecurityNotAllowedFilterError && isset(\$filters[\$e->getFilterName()])) {
174
+ \$e->setTemplateLine(\$filters[\$e->getFilterName()]);
175
+ } elseif (\$e instanceof Twig_Sandbox_SecurityNotAllowedFunctionError && isset(\$functions[\$e->getFunctionName()])) {
176
+ \$e->setTemplateLine(\$functions[\$e->getFunctionName()]);
177
+ }
178
+
179
+ throw \$e;
180
+ }
181
  }
182
 
183
  public function getTemplateName()
192
 
193
  public function getDebugInfo()
194
  {
195
+ return array ( 11 => 1,);
196
  }
197
  }
198
  EOF
vendor/twig/twig/test/Twig/Tests/Node/SandboxedPrintTest.php CHANGED
@@ -11,9 +11,6 @@
11
 
12
  class Twig_Tests_Node_SandboxedPrintTest extends Twig_Test_NodeTestCase
13
  {
14
- /**
15
- * @covers Twig_Node_SandboxedPrint::__construct
16
- */
17
  public function testConstructor()
18
  {
19
  $node = new Twig_Node_SandboxedPrint($expr = new Twig_Node_Expression_Constant('foo', 1), 1);
@@ -21,15 +18,6 @@ class Twig_Tests_Node_SandboxedPrintTest extends Twig_Test_NodeTestCase
21
  $this->assertEquals($expr, $node->getNode('expr'));
22
  }
23
 
24
- /**
25
- * @covers Twig_Node_SandboxedPrint::compile
26
- * @dataProvider getTests
27
- */
28
- public function testCompile($node, $source, $environment = null)
29
- {
30
- parent::testCompile($node, $source, $environment);
31
- }
32
-
33
  public function getTests()
34
  {
35
  $tests = array();
11
 
12
  class Twig_Tests_Node_SandboxedPrintTest extends Twig_Test_NodeTestCase
13
  {
 
 
 
14
  public function testConstructor()
15
  {
16
  $node = new Twig_Node_SandboxedPrint($expr = new Twig_Node_Expression_Constant('foo', 1), 1);
18
  $this->assertEquals($expr, $node->getNode('expr'));
19
  }
20
 
 
 
 
 
 
 
 
 
 
21
  public function getTests()
22
  {
23
  $tests = array();
vendor/twig/twig/test/Twig/Tests/Node/SetTest.php CHANGED
@@ -11,9 +11,6 @@
11
 
12
  class Twig_Tests_Node_SetTest extends Twig_Test_NodeTestCase
13
  {
14
- /**
15
- * @covers Twig_Node_Set::__construct
16
- */
17
  public function testConstructor()
18
  {
19
  $names = new Twig_Node(array(new Twig_Node_Expression_AssignName('foo', 1)), array(), 1);
@@ -25,15 +22,6 @@ class Twig_Tests_Node_SetTest extends Twig_Test_NodeTestCase
25
  $this->assertFalse($node->getAttribute('capture'));
26
  }
27
 
28
- /**
29
- * @covers Twig_Node_Set::compile
30
- * @dataProvider getTests
31
- */
32
- public function testCompile($node, $source, $environment = null)
33
- {
34
- parent::testCompile($node, $source, $environment);
35
- }
36
-
37
  public function getTests()
38
  {
39
  $tests = array();
11
 
12
  class Twig_Tests_Node_SetTest extends Twig_Test_NodeTestCase
13
  {
 
 
 
14
  public function testConstructor()
15
  {
16
  $names = new Twig_Node(array(new Twig_Node_Expression_AssignName('foo', 1)), array(), 1);
22
  $this->assertFalse($node->getAttribute('capture'));
23
  }
24
 
 
 
 
 
 
 
 
 
 
25
  public function getTests()
26
  {
27
  $tests = array();
vendor/twig/twig/test/Twig/Tests/Node/SpacelessTest.php CHANGED
@@ -11,9 +11,6 @@
11
 
12
  class Twig_Tests_Node_SpacelessTest extends Twig_Test_NodeTestCase
13
  {
14
- /**
15
- * @covers Twig_Node_Spaceless::__construct
16
- */
17
  public function testConstructor()
18
  {
19
  $body = new Twig_Node(array(new Twig_Node_Text('<div> <div> foo </div> </div>', 1)));
@@ -22,15 +19,6 @@ class Twig_Tests_Node_SpacelessTest extends Twig_Test_NodeTestCase
22
  $this->assertEquals($body, $node->getNode('body'));
23
  }
24
 
25
- /**
26
- * @covers Twig_Node_Spaceless::compile
27
- * @dataProvider getTests
28
- */
29
- public function testCompile($node, $source, $environment = null)
30
- {
31
- parent::testCompile($node, $source, $environment);
32
- }
33
-
34
  public function getTests()
35
  {
36
  $body = new Twig_Node(array(new Twig_Node_Text('<div> <div> foo </div> </div>', 1)));
11
 
12
  class Twig_Tests_Node_SpacelessTest extends Twig_Test_NodeTestCase
13
  {
 
 
 
14
  public function testConstructor()
15
  {
16
  $body = new Twig_Node(array(new Twig_Node_Text('<div> <div> foo </div> </div>', 1)));
19
  $this->assertEquals($body, $node->getNode('body'));
20
  }
21
 
 
 
 
 
 
 
 
 
 
22
  public function getTests()
23
  {
24
  $body = new Twig_Node(array(new Twig_Node_Text('<div> <div> foo </div> </div>', 1)));
vendor/twig/twig/test/Twig/Tests/Node/TextTest.php CHANGED
@@ -11,9 +11,6 @@
11
 
12
  class Twig_Tests_Node_TextTest extends Twig_Test_NodeTestCase
13
  {
14
- /**
15
- * @covers Twig_Node_Text::__construct
16
- */
17
  public function testConstructor()
18
  {
19
  $node = new Twig_Node_Text('foo', 1);
@@ -21,15 +18,6 @@ class Twig_Tests_Node_TextTest extends Twig_Test_NodeTestCase
21
  $this->assertEquals('foo', $node->getAttribute('data'));
22
  }
23
 
24
- /**
25
- * @covers Twig_Node_Text::compile
26
- * @dataProvider getTests
27
- */
28
- public function testCompile($node, $source, $environment = null)
29
- {
30
- parent::testCompile($node, $source, $environment);
31
- }
32
-
33
  public function getTests()
34
  {
35
  $tests = array();
11
 
12
  class Twig_Tests_Node_TextTest extends Twig_Test_NodeTestCase
13
  {
 
 
 
14
  public function testConstructor()
15
  {
16
  $node = new Twig_Node_Text('foo', 1);
18
  $this->assertEquals('foo', $node->getAttribute('data'));
19
  }
20
 
 
 
 
 
 
 
 
 
 
21
  public function getTests()
22
  {
23
  $tests = array();
vendor/twig/twig/test/Twig/Tests/NodeVisitor/OptimizerTest.php CHANGED
@@ -89,6 +89,16 @@ class Twig_Tests_NodeVisitor_OptimizerTest extends PHPUnit_Framework_TestCase
89
  array('{% for i in foo %}{% for j in foo %}{{ foo.parent.loop.index }}{% endfor %}{% endfor %}', array('i' => false, 'j' => false)),
90
 
91
  array('{% for i in foo %}{% for j in foo %}{{ loop["parent"].loop.index }}{% endfor %}{% endfor %}', array('i' => true, 'j' => true)),
 
 
 
 
 
 
 
 
 
 
92
  );
93
  }
94
 
89
  array('{% for i in foo %}{% for j in foo %}{{ foo.parent.loop.index }}{% endfor %}{% endfor %}', array('i' => false, 'j' => false)),
90
 
91
  array('{% for i in foo %}{% for j in foo %}{{ loop["parent"].loop.index }}{% endfor %}{% endfor %}', array('i' => true, 'j' => true)),
92
+
93
+ array('{% for i in foo %}{{ include("foo") }}{% endfor %}', array('i' => true)),
94
+
95
+ array('{% for i in foo %}{{ include("foo", with_context = false) }}{% endfor %}', array('i' => false)),
96
+
97
+ array('{% for i in foo %}{{ include("foo", with_context = true) }}{% endfor %}', array('i' => true)),
98
+
99
+ array('{% for i in foo %}{{ include("foo", { "foo": "bar" }, with_context = false) }}{% endfor %}', array('i' => false)),
100
+
101
+ array('{% for i in foo %}{{ include("foo", { "foo": loop.index }, with_context = false) }}{% endfor %}', array('i' => true)),
102
  );
103
  }
104
 
vendor/twig/twig/test/Twig/Tests/TemplateTest.php CHANGED
@@ -28,6 +28,7 @@ class Twig_Tests_TemplateTest extends PHPUnit_Framework_TestCase
28
 
29
  $context = array(
30
  'string' => 'foo',
 
31
  'array' => array('foo' => 'foo'),
32
  'array_access' => new Twig_TemplateArrayAccessObject(),
33
  'magic_exception' => new Twig_TemplateMagicPropertyObjectWithException(),
@@ -46,10 +47,12 @@ class Twig_Tests_TemplateTest extends PHPUnit_Framework_TestCase
46
  {
47
  $tests = array(
48
  array('{{ string["a"] }}', 'Impossible to access a key ("a") on a string variable ("foo") in "%s" at line 1', false),
 
49
  array('{{ array["a"] }}', 'Key "a" for array with keys "foo" does not exist in "%s" at line 1', false),
50
  array('{{ array_access["a"] }}', 'Key "a" in object with ArrayAccess of class "Twig_TemplateArrayAccessObject" does not exist in "%s" at line 1', false),
51
  array('{{ string.a }}', 'Impossible to access an attribute ("a") on a string variable ("foo") in "%s" at line 1', false),
52
  array('{{ string.a() }}', 'Impossible to invoke a method ("a") on a string variable ("foo") in "%s" at line 1', false),
 
53
  array('{{ array.a }}', 'Key "a" for array with keys "foo" does not exist in "%s" at line 1', false),
54
  array('{{ attribute(array, -10) }}', 'Key "-10" for array with keys "foo" does not exist in "%s" at line 1', false),
55
  array('{{ array_access.a }}', 'Method "a" for object "Twig_TemplateArrayAccessObject" does not exist in "%s" at line 1', false),
@@ -368,7 +371,7 @@ class Twig_Tests_TemplateTest extends PHPUnit_Framework_TestCase
368
  $tests = array_merge($tests, array(
369
  array(false, null, 42, 'a', array(), $anyType, false, 'Impossible to access an attribute ("a") on a integer variable ("42")'),
370
  array(false, null, "string", 'a', array(), $anyType, false, 'Impossible to access an attribute ("a") on a string variable ("string")'),
371
- array(false, null, array(), 'a', array(), $anyType, false, 'Key "a" for array with keys "" does not exist'),
372
  ));
373
 
374
  // add twig_template_get_attributes tests
@@ -585,7 +588,6 @@ class Twig_TemplateMethodObject
585
 
586
  public function getNull()
587
  {
588
- return null;
589
  }
590
 
591
  public function isBar()
28
 
29
  $context = array(
30
  'string' => 'foo',
31
+ 'empty_array' => array(),
32
  'array' => array('foo' => 'foo'),
33
  'array_access' => new Twig_TemplateArrayAccessObject(),
34
  'magic_exception' => new Twig_TemplateMagicPropertyObjectWithException(),
47
  {
48
  $tests = array(
49
  array('{{ string["a"] }}', 'Impossible to access a key ("a") on a string variable ("foo") in "%s" at line 1', false),
50
+ array('{{ empty_array["a"] }}', 'Key "a" does not exist as the array is empty in "%s" at line 1', false),
51
  array('{{ array["a"] }}', 'Key "a" for array with keys "foo" does not exist in "%s" at line 1', false),
52
  array('{{ array_access["a"] }}', 'Key "a" in object with ArrayAccess of class "Twig_TemplateArrayAccessObject" does not exist in "%s" at line 1', false),
53
  array('{{ string.a }}', 'Impossible to access an attribute ("a") on a string variable ("foo") in "%s" at line 1', false),
54
  array('{{ string.a() }}', 'Impossible to invoke a method ("a") on a string variable ("foo") in "%s" at line 1', false),
55
+ array('{{ empty_array.a }}', 'Key "a" does not exist as the array is empty in "%s" at line 1', false),
56
  array('{{ array.a }}', 'Key "a" for array with keys "foo" does not exist in "%s" at line 1', false),
57
  array('{{ attribute(array, -10) }}', 'Key "-10" for array with keys "foo" does not exist in "%s" at line 1', false),
58
  array('{{ array_access.a }}', 'Method "a" for object "Twig_TemplateArrayAccessObject" does not exist in "%s" at line 1', false),
371
  $tests = array_merge($tests, array(
372
  array(false, null, 42, 'a', array(), $anyType, false, 'Impossible to access an attribute ("a") on a integer variable ("42")'),
373
  array(false, null, "string", 'a', array(), $anyType, false, 'Impossible to access an attribute ("a") on a string variable ("string")'),
374
+ array(false, null, array(), 'a', array(), $anyType, false, 'Key "a" does not exist as the array is empty'),
375
  ));
376
 
377
  // add twig_template_get_attributes tests
588
 
589
  public function getNull()
590
  {
 
591
  }
592
 
593
  public function isBar()
vendor/twig/twig/test/Twig/Tests/escapingTest.php CHANGED
@@ -227,7 +227,7 @@ class Twig_Test_EscapingTest extends PHPUnit_Framework_TestCase
227
  /**
228
  * Convert a Unicode Codepoint to a literal UTF-8 character.
229
  *
230
- * @param int Unicode codepoint in hex notation
231
  * @return string UTF-8 literal string
232
  */
233
  protected function codepointToUtf8($codepoint)
@@ -301,7 +301,7 @@ class Twig_Test_EscapingTest extends PHPUnit_Framework_TestCase
301
 
302
  public function testCssEscapingEscapesOwaspRecommendedRanges()
303
  {
304
- $immune = array(); // CSS has no exceptions to escaping ranges
305
  for ($chr=0; $chr < 0xFF; $chr++) {
306
  if ($chr >= 0x30 && $chr <= 0x39
307
  || $chr >= 0x41 && $chr <= 0x5A
227
  /**
228
  * Convert a Unicode Codepoint to a literal UTF-8 character.
229
  *
230
+ * @param int $codepoint Unicode codepoint in hex notation
231
  * @return string UTF-8 literal string
232
  */
233
  protected function codepointToUtf8($codepoint)
301
 
302
  public function testCssEscapingEscapesOwaspRecommendedRanges()
303
  {
304
+ // CSS has no exceptions to escaping ranges
305
  for ($chr=0; $chr < 0xFF; $chr++) {
306
  if ($chr >= 0x30 && $chr <= 0x39
307
  || $chr >= 0x41 && $chr <= 0x5A
vendor/vendor/asm89/twig-cache-extension/.gitignore DELETED
@@ -1,4 +0,0 @@
1
- phpunit.xml
2
- composer.lock
3
- composer.phar
4
- /vendor/
 
 
 
 
vendor/vendor/asm89/twig-cache-extension/.travis.yml DELETED
@@ -1,14 +0,0 @@
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
-
14
- script: phpunit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/asm89/twig-cache-extension/LICENSE DELETED
@@ -1,19 +0,0 @@
1
- Copyright (c) 2013 Alexander <iam.asm89@gmail.com>
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining a copy
4
- of this software and associated documentation files (the "Software"), to deal
5
- in the Software without restriction, including without limitation the rights
6
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- copies of the Software, and to permit persons to whom the Software is furnished
8
- to do so, subject to the following conditions:
9
-
10
- The above copyright notice and this permission notice shall be included in all
11
- copies or substantial portions of the Software.
12
-
13
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
- THE SOFTWARE.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/asm89/twig-cache-extension/README.md DELETED
@@ -1,195 +0,0 @@
1
- Twig cache extension
2
- ====================
3
-
4
- The missing cache extension for Twig. The extension allows for caching rendered parts of
5
- templates using several cache strategies.
6
-
7
- [![Build Status](https://secure.travis-ci.org/asm89/twig-cache-extension.png?branch=master)](http://travis-ci.org/asm89/twig-cache-extension)
8
-
9
- ## Installation
10
-
11
- The extension is installable via composer:
12
-
13
- ```js
14
- {
15
- "require": {
16
- "asm89/twig-cache-extension": "*"
17
- }
18
- }
19
- ```
20
-
21
- ## Quick start
22
-
23
- ### Setup
24
-
25
- A minimal setup for adding the extension with the `LifeTimeCacheStrategy` and
26
- doctrine array cache is as following:
27
-
28
- ```php
29
- <?php
30
-
31
- use Doctrine\Common\Cache\ArrayCache;
32
- use Asm89\Twig\CacheExtension\CacheProvider\DoctrineCacheAdapter;
33
- use Asm89\Twig\CacheExtension\CacheStrategy\LifetimeCacheStrategy;
34
- use Asm89\Twig\CacheExtension\Extension as CacheExtension;
35
-
36
- $cacheProvider = new DoctrineCacheAdapter(new ArrayCache());
37
- $cacheStrategy = new LifetimeCacheStrategy($cacheProvider);
38
- $cacheExtension = new CacheExtension($cacheStrategy);
39
-
40
- $twig->addExtension($cacheExtension);
41
- ```
42
-
43
- ### Usage
44
-
45
- To cache a part of a template in Twig surround the code with a `cache` block.
46
- The cache block takes two parameters, first an "annotation" part, second the
47
- "value" the cache strategy can work with. Example:
48
-
49
- ```jinja
50
- {% cache 'v1/summary' 900 %}
51
- {# heavy lifting template stuff here, include/render other partials etc #}
52
- {% endcache %}
53
- ```
54
-
55
- Cache blocks can be nested:
56
-
57
- ```jinja
58
- {% cache 'v1' 900 %}
59
- {% for item in items %}
60
- {% cache 'v1' item %}
61
- {# ... #}
62
- {% endcache %}
63
- {% endfor %}
64
- {% endcache %}
65
-
66
- ```
67
-
68
- ## Cache strategies
69
-
70
- The extension ships with a few cache strategies out of the box. Setup and usage
71
- of all of them is described below.
72
-
73
- ### Lifetime
74
-
75
- See the "Quick start" for usage information of the `LifetimeCacheStrategy`.
76
-
77
- ### Generational
78
-
79
- Strategy for generational caching.
80
-
81
- In theory the strategy only saves fragments to the cache with infinite
82
- lifetime. The key of the strategy lies in the fact that the keys for blocks
83
- will change as the value for which the key is generated changes.
84
-
85
- For example: entities containing a last update time, would include a timestamp
86
- in the key. For an interesting blog post about this type of caching see:
87
- http://37signals.com/svn/posts/3113-how-key-based-cache-expiration-works
88
-
89
- #### Setup
90
-
91
- In order to use the strategy you need to setup a `KeyGenerator` class that is
92
- able to generate a cache key for a given value.
93
-
94
- The following naive example always assumes the value is an object with the methods
95
- `getId()` and `getUpdatedAt()` method. The key then composed from the class
96
- name, the id and the updated time of the object:
97
-
98
- ```php
99
- <?php
100
-
101
- use Asm89\Twig\CacheExtension\CacheStrategy\KeyGeneratorInterface;
102
-
103
- class MyKeyGenerator implements KeyGeneratorInterface
104
- {
105
- public function generateKey($value)
106
- {
107
- return get_class($value) . '_' . $value->getId() . '_' . $value->getUpdatedAt();
108
- }
109
-
110
- }
111
- ```
112
-
113
- Next the `GenerationalCacheStrategy` needs to be setup with the keygenerator.
114
-
115
- ```php
116
- <?php
117
-
118
- use Asm89\Twig\CacheExtension\CacheStrategy\GenerationalCacheStrategy;
119
- use Asm89\Twig\CacheExtension\Extension as CacheExtension;
120
-
121
- $keyGenerator = new MyKeyGenerator();
122
- $cacheProvider = /* see Quick start */;
123
- $cacheStrategy = new GenerationalCacheStrategy($cacheProvider, $keyGenerator, 0 /* = infinite lifetime */);
124
- $cacheExtension = new CacheExtension($cacheStrategy);
125
-
126
- $twig->addExtension($cacheExtension);
127
- ```
128
-
129
- #### Usage
130
-
131
- The strategy expects an object as value for determining the cache key of the
132
- block:
133
-
134
- ```jinja
135
- {% cache 'v1/summary' item %}
136
- {# heavy lifting template stuff here, include/render other partials etc #}
137
- {% endcache %}
138
- ```
139
-
140
- ### Using multiple strategies
141
-
142
- Different cache strategies are useful for different usecases. It is possible to
143
- mix multiple strategies in an application with the
144
- `IndexedChainingCacheStrategy`. The strategy takes an array of `'name' =>
145
- $strategy` and delegates the caching to the appropriate strategy.
146
-
147
- #### Setup
148
-
149
- ```php
150
- <?php
151
-
152
- use Asm89\Twig\CacheExtension\CacheStrategy\IndexedChainingCacheStrategy;
153
- use Asm89\Twig\CacheExtension\Extension as CacheExtension;
154
-
155
- $cacheStrategy = new IndexedChainingCacheStrategy(array(
156
- 'time' => $lifetimeCacheStrategy,
157
- 'gen' => $generationalCacheStrategy,
158
- ));
159
- $cacheExtension = new CacheExtension($cacheStrategy);
160
-
161
- $twig->addExtension($cacheExtension);
162
- ```
163
-
164
- #### Usage
165
-
166
- The strategy expects an array with as key the name of the strategy which it
167
- needs to delegate to and as value the appropriate value for the delegated
168
- strategy.
169
-
170
- ```jinja
171
- {# delegate to lifetime strategy #}
172
- {% cache 'v1/summary' {time: 300} %}
173
- {# heavy lifting template stuff here, include/render other partials etc #}
174
- {% endcache %}
175
-
176
- {# delegate to generational strategy #}
177
- {% cache 'v1/summary' {gen: item} %}
178
- {# heavy lifting template stuff here, include/render other partials etc #}
179
- {% endcache %}
180
- ```
181
-
182
- ## Implementing a cache strategy
183
-
184
- Creating separate caches for different access levels, languages or other
185
- usecases can be done by implementing a custom cache strategy. In order to do so
186
- implement the `CacheProviderInterface`. It is recommended to use composition
187
- and wrap a custom strategy around an existing one.
188
-
189
- ## Authors
190
-
191
- Alexander <iam.asm89@gmail.com>
192
-
193
- ## License
194
-
195
- twig-cache-extension is licensed under the MIT License - see the LICENSE file for details
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/asm89/twig-cache-extension/composer.json DELETED
@@ -1,29 +0,0 @@
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",
7
- "license": "MIT",
8
- "authors": [
9
- {
10
- "name": "Alexander",
11
- "email": "iam.asm89@gmail.com"
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": {
26
- "dev-master": "0.1-dev"
27
- }
28
- }
29
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/asm89/twig-cache-extension/lib/Asm89/Twig/CacheExtension/CacheProvider/DoctrineCacheAdapter.php DELETED
@@ -1,49 +0,0 @@
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\CacheProvider;
13
-
14
- use Asm89\Twig\CacheExtension\CacheProviderInterface;
15
- use Doctrine\Common\Cache\Cache;
16
-
17
- /**
18
- * Adapter class to use the cache classes provider by Doctrine.
19
- *
20
- * @author Alexander <iam.asm89@gmail.com>
21
- */
22
- class DoctrineCacheAdapter implements CacheProviderInterface
23
- {
24
- private $cache;
25
-
26
- /**
27
- * @param Cache $cache
28
- */
29
- public function __construct(Cache $cache)
30
- {
31
- $this->cache = $cache;
32
- }
33
-
34
- /**
35
- * {@inheritDoc}
36
- */
37
- public function fetch($key)
38
- {
39
- return $this->cache->fetch($key);
40
- }
41
-
42
- /**
43
- * {@inheritDoc}
44
- */
45
- public function save($key, $value, $lifetime = 0)
46
- {
47
- return $this->cache->save($key, $value, $lifetime);
48
- }
49
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/asm89/twig-cache-extension/lib/Asm89/Twig/CacheExtension/CacheProviderInterface.php DELETED
@@ -1,34 +0,0 @@
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;
13
-
14
- /**
15
- * Cache provider interface.
16
- *
17
- * @author Alexander <iam.asm89@gmail.com>
18
- */
19
- interface CacheProviderInterface
20
- {
21
- /**
22
- * @param string $key
23
- *
24
- * @return mixed False, if there was no value to be fetched. Null or a string otherwise.
25
- */
26
- public function fetch($key);
27
-
28
- /**
29
- * @param string $key
30
- * @param string $value
31
- * @param integer $lifetime
32
- */
33
- public function save($key, $value, $lifetime = 0);
34
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/asm89/twig-cache-extension/lib/Asm89/Twig/CacheExtension/CacheStrategy/GenerationalCacheStrategy.php DELETED
@@ -1,79 +0,0 @@
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\CacheProviderInterface;
15
- use Asm89\Twig\CacheExtension\CacheStrategyInterface;
16
-
17
- /**
18
- * Strategy for generational caching.
19
- *
20
- * In theory the strategy only saves fragments to the cache with infinite
21
- * lifetime. The key of the strategy lies in the fact that the keys for blocks
22
- * will change as the value for which the key is generated changes.
23
- *
24
- * For example: entities containing a last update time, would include a
25
- * timestamp in the key.
26
- *
27
- * @see http://37signals.com/svn/posts/3113-how-key-based-cache-expiration-works
28
- *
29
- * @author Alexander <iam.asm89@gmail.com>
30
- */
31
- class GenerationalCacheStrategy implements CacheStrategyInterface
32
- {
33
- private $keyGenerator;
34
- private $cache;
35
- private $lifetime;
36
-
37
- /**
38
- * @param CacheProviderInterface $cache
39
- * @param KeyGeneratorInterface $keyGenerator
40
- * @param integer $lifetime
41
- */
42
- public function __construct(CacheProviderInterface $cache, KeyGeneratorInterface $keyGenerator, $lifetime = 0)
43
- {
44
- $this->keyGenerator = $keyGenerator;
45
- $this->cache = $cache;
46
- $this->lifetime = $lifetime;
47
- }
48
-
49
- /**
50
- * {@inheritDoc}
51
- */
52
- public function fetchBlock($key)
53
- {
54
- return $this->cache->fetch($key);
55
- }
56
-
57
- /**
58
- * {@inheritDoc}
59
- */
60
- public function generateKey($annotation, $value)
61
- {
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;
70
- }
71
-
72
- /**
73
- * {@inheritDoc}
74
- */
75
- public function saveBlock($key, $block)
76
- {
77
- return $this->cache->save($key, $block, $this->lifetime);
78
- }
79
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/asm89/twig-cache-extension/lib/Asm89/Twig/CacheExtension/CacheStrategy/IndexedChainingCacheStrategy.php DELETED
@@ -1,75 +0,0 @@
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
- * Combines several configured cache strategies.
18
- *
19
- * Useful for combining for example generational cache strategy with a lifetime
20
- * cache strategy, but also useful when combining several generational cache
21
- * strategies which differ on cache lifetime (infinite, 1hr, 5m).
22
- *
23
- * @author Alexander <iam.asm89@gmail.com>
24
- */
25
- class IndexedChainingCacheStrategy implements CacheStrategyInterface
26
- {
27
- private $strategies;
28
-
29
- /**
30
- * @param array $strategies
31
- */
32
- public function __construct(array $strategies)
33
- {
34
- $this->strategies = $strategies;
35
- }
36
-
37
- /**
38
- * {@inheritDoc}
39
- */
40
- public function fetchBlock($key)
41
- {
42
- return $this->strategies[$key['strategyKey']]->fetchBlock($key['key']);
43
- }
44
-
45
- /**
46
- * {@inheritDoc}
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
-
68
- /**
69
- * {@inheritDoc}
70
- */
71
- public function saveBlock($key, $block)
72
- {
73
- return $this->strategies[$key['strategyKey']]->saveBlock($key['key'], $block);
74
- }
75
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/asm89/twig-cache-extension/lib/Asm89/Twig/CacheExtension/CacheStrategy/KeyGeneratorInterface.php DELETED
@@ -1,29 +0,0 @@
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
- /**
15
- * Generates a key for a given value.
16
- *
17
- * @author Alexander <iam.asm89@gmail.com>
18
- */
19
- interface KeyGeneratorInterface
20
- {
21
- /**
22
- * Generate a cache key for a given value.
23
- *
24
- * @param mixed $value
25
- *
26
- * @return string
27
- */
28
- public function generateKey($value);
29
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/asm89/twig-cache-extension/lib/Asm89/Twig/CacheExtension/CacheStrategy/LifetimeCacheStrategy.php DELETED
@@ -1,68 +0,0 @@
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\CacheProviderInterface;
15
- use Asm89\Twig\CacheExtension\CacheStrategyInterface;
16
-
17
- /**
18
- * Strategy for caching with a pre-defined lifetime.
19
- *
20
- * The value passed to the strategy is the lifetime of the cache block in
21
- * seconds.
22
- *
23
- * @author Alexander <iam.asm89@gmail.com>
24
- */
25
- class LifetimeCacheStrategy implements CacheStrategyInterface
26
- {
27
- private $cache;
28
-
29
- /**
30
- * @param CacheProviderInterface $cache
31
- */
32
- public function __construct(CacheProviderInterface $cache)
33
- {
34
- $this->cache = $cache;
35
- }
36
-
37
- /**
38
- * {@inheritDoc}
39
- */
40
- public function fetchBlock($key)
41
- {
42
- return $this->cache->fetch($key['key']);
43
- }
44
-
45
- /**
46
- * {@inheritDoc}
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
-
61
- /**
62
- * {@inheritDoc}
63
- */
64
- public function saveBlock($key, $block)
65
- {
66
- return $this->cache->save($key['key'], $block, $key['lifetime']);
67
- }
68
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/asm89/twig-cache-extension/lib/Asm89/Twig/CacheExtension/CacheStrategyInterface.php DELETED
@@ -1,47 +0,0 @@
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;
13
-
14
- /**
15
- * Cache strategy interface.
16
- *
17
- * @author Alexander <iam.asm89@gmail.com>
18
- */
19
- interface CacheStrategyInterface
20
- {
21
- /**
22
- * Fetch the block for a given key.
23
- *
24
- * @param mixed $key
25
- *
26
- * @return string
27
- */
28
- public function fetchBlock($key);
29
-
30
- /**
31
- * Generate a key for the value.
32
- *
33
- * @param string $annotation
34
- * @param mixed $value
35
- *
36
- * @return mixed
37
- */
38
- public function generateKey($annotation, $value);
39
-
40
- /**
41
- * Save the contents of a rendered block.
42
- *
43
- * @param mixed $key
44
- * @param string $block
45
- */
46
- public function saveBlock($key, $block);
47
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/asm89/twig-cache-extension/lib/Asm89/Twig/CacheExtension/Extension.php DELETED
@@ -1,56 +0,0 @@
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;
13
-
14
- /**
15
- * Extension for caching template blocks with twig.
16
- *
17
- * @author Alexander <iam.asm89@gmail.com>
18
- */
19
- class Extension extends \Twig_Extension
20
- {
21
- private $cacheStrategy;
22
-
23
- /**
24
- * @param CacheStrategyInterface $cacheStrategy
25
- */
26
- public function __construct(CacheStrategyInterface $cacheStrategy)
27
- {
28
- $this->cacheStrategy = $cacheStrategy;
29
- }
30
-
31
- /**
32
- * @return CacheStrategyInterface
33
- */
34
- public function getCacheStrategy()
35
- {
36
- return $this->cacheStrategy;
37
- }
38
-
39
- /**
40
- * {@inheritDoc}
41
- */
42
- public function getName()
43
- {
44
- return 'asm89_cache';
45
- }
46
-
47
- /**
48
- * {@inheritDoc}
49
- */
50
- public function getTokenParsers()
51
- {
52
- return array(
53
- new TokenParser\Cache(),
54
- );
55
- }
56
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/asm89/twig-cache-extension/lib/Asm89/Twig/CacheExtension/Node/CacheNode.php DELETED
@@ -1,63 +0,0 @@
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\Node;
13
-
14
- /**
15
- * Cache twig node.
16
- *
17
- * @author Alexander <iam.asm89@gmail.com>
18
- */
19
- class CacheNode extends \Twig_Node
20
- {
21
- private static $cacheCount = 1;
22
-
23
- /**
24
- * @param string $annotation
25
- * @param \Twig_Node_Expression $keyInfo
26
- * @param \Twig_NodeInterface $body
27
- * @param integer $lineno
28
- * @param string $tag
29
- */
30
- public function __construct($annotation, \Twig_Node_Expression $keyInfo, \Twig_NodeInterface $body, $lineno, $tag = null)
31
- {
32
- parent::__construct(array('key_info' => $keyInfo, 'body' => $body), array('annotation' => $annotation), $lineno, $tag);
33
- }
34
-
35
- /**
36
- * {@inheritDoc}
37
- */
38
- public function compile(\Twig_Compiler $compiler)
39
- {
40
- $i = self::$cacheCount++;
41
-
42
- $compiler
43
- ->addDebugInfo($this)
44
- ->write("\$asm89CacheStrategy".$i." = \$this->getEnvironment()->getExtension('asm89_cache')->getCacheStrategy();\n")
45
- ->write("\$asm89Key".$i." = \$asm89CacheStrategy".$i."->generateKey('".$this->getAttribute('annotation')."', ")
46
- ->subcompile($this->getNode('key_info'))
47
- ->write(");\n")
48
- ->write("\$asm89CacheBody".$i." = \$asm89CacheStrategy".$i."->fetchBlock(\$asm89Key".$i.");\n")
49
- ->write("if (\$asm89CacheBody".$i." === false) {\n")
50
- ->indent()
51
- ->write("ob_start();\n")
52
- ->indent()
53
- ->subcompile($this->getNode('body'))
54
- ->outdent()
55
- ->write("\n")
56
- ->write("\$asm89CacheBody".$i." = ob_get_clean();\n")
57
- ->write("\$asm89CacheStrategy".$i."->saveBlock(\$asm89Key".$i.", \$asm89CacheBody".$i.");\n")
58
- ->outdent()
59
- ->write("}\n")
60
- ->write("echo \$asm89CacheBody".$i.";\n")
61
- ;
62
- }
63
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/asm89/twig-cache-extension/lib/Asm89/Twig/CacheExtension/TokenParser/Cache.php DELETED
@@ -1,56 +0,0 @@
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\TokenParser;
13
-
14
- use \Twig_Token;
15
-
16
- /**
17
- * Parser for cache/endcache blocks.
18
- *
19
- * @author Alexander <iam.asm89@gmail.com>
20
- */
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
- }
30
-
31
- /**
32
- * {@inheritDoc}
33
- */
34
- public function getTag()
35
- {
36
- return 'cache';
37
- }
38
-
39
- /**
40
- * {@inheritDoc}
41
- */
42
- public function parse(Twig_Token $token)
43
- {
44
- $lineno = $token->getLine();
45
- $stream = $this->parser->getStream();
46
-
47
- $annotation = $stream->expect(Twig_Token::STRING_TYPE)->getValue();
48
- $key = $this->parser->getExpressionParser()->parseExpression();
49
-
50
- $stream->expect(Twig_Token::BLOCK_END_TYPE);
51
- $body = $this->parser->subparse(array($this, 'decideCacheEnd'), true);
52
- $stream->expect(Twig_Token::BLOCK_END_TYPE);
53
-
54
- return new \Asm89\Twig\CacheExtension\Node\CacheNode($annotation, $key, $body, $lineno, $this->getTag());
55
- }
56
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/asm89/twig-cache-extension/phpunit.xml.dist DELETED
@@ -1,25 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
-
3
- <phpunit backupGlobals="false"
4
- backupStaticAttributes="false"
5
- colors="true"
6
- convertErrorsToExceptions="true"
7
- convertNoticesToExceptions="true"
8
- convertWarningsToExceptions="true"
9
- processIsolation="false"
10
- stopOnFailure="false"
11
- syntaxCheck="false"
12
- bootstrap="test/bootstrap.php"
13
- >
14
- <testsuites>
15
- <testsuite name="Twig Cache Extension Test Suite">
16
- <directory>./test/Asm89/</directory>
17
- </testsuite>
18
- </testsuites>
19
-
20
- <filter>
21
- <whitelist>
22
- <directory suffix=".php">./lib/</directory>
23
- </whitelist>
24
- </filter>
25
- </phpunit>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/asm89/twig-cache-extension/test/Asm89/Twig/CacheExtension/Tests/CacheProvider/DoctrineCacheAdapterTest.php DELETED
@@ -1,46 +0,0 @@
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\Tests\CacheProvider;
13
-
14
- use Asm89\Twig\CacheExtension\CacheProvider\DoctrineCacheAdapter;
15
-
16
- class DoctrineCacheAdapterTest extends \PHPUnit_Framework_TestCase
17
- {
18
- public function testFetch()
19
- {
20
- $cacheMock = $this->createCacheMock();
21
- $cacheMock->expects($this->any())
22
- ->method('fetch')
23
- ->will($this->returnValue('fromcache'));
24
-
25
- $cache = new DoctrineCacheAdapter($cacheMock);
26
-
27
- $this->assertEquals('fromcache', $cache->fetch('test'));
28
- }
29
-
30
- public function testSave()
31
- {
32
- $cacheMock = $this->createCacheMock();
33
- $cacheMock->expects($this->once())
34
- ->method('save')
35
- ->with('key', 'value', 42);
36
-
37
- $cache = new DoctrineCacheAdapter($cacheMock);
38
-
39
- $cache->save('key', 'value', 42);
40
- }
41
-
42
- public function createCacheMock()
43
- {
44
- return $this->getMock('Doctrine\Common\Cache\Cache');
45
- }
46
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/asm89/twig-cache-extension/test/Asm89/Twig/CacheExtension/Tests/CacheStrategy/GenerationCacheStrategyTest.php DELETED
@@ -1,80 +0,0 @@
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\Tests\CacheStrategy;
13
-
14
- use Asm89\Twig\CacheExtension\CacheStrategy\GenerationalCacheStrategy;
15
-
16
- class GenerationalCacheStrategyTest extends \PHPUnit_Framework_TestCase
17
- {
18
- private $keyGeneratorMock;
19
- private $cacheProviderMock;
20
-
21
- public function createCacheStrategy($lifetime = 0)
22
- {
23
- $this->keyGeneratorMock = $this->createKeyGeneratorMock();
24
- $this->cacheProviderMock = $this->createCacheProviderMock();
25
-
26
- return new GenerationalCacheStrategy($this->cacheProviderMock, $this->keyGeneratorMock, $lifetime);
27
- }
28
-
29
- public function testGenerateKeyContainsAnnotation()
30
- {
31
- $strategy = $this->createCacheStrategy();
32
- $this->keyGeneratorMock->expects($this->any())
33
- ->method('generateKey')
34
- ->will($this->returnValue('foo'));
35
-
36
- $this->assertEquals('v42__GCS__foo', $strategy->generateKey('v42', 'value'));
37
- }
38
-
39
- /**
40
- * @expectedException RuntimeException
41
- */
42
- public function testGenerationKeyThrowsExceptionWhenKeyGeneratorReturnsNull()
43
- {
44
- $strategy = $this->createCacheStrategy();
45
-
46
- $strategy->generateKey('v42', 'value');
47
- }
48
-
49
- /**
50
- * @dataProvider getLifeTimes
51
- */
52
- public function testSaveBlockUsesConfiguredLifetime($lifetime)
53
- {
54
- $strategy = $this->createCacheStrategy($lifetime);
55
- $this->cacheProviderMock->expects($this->any())
56
- ->method('save')
57
- ->with('key', 'value', $lifetime)
58
- ->will($this->returnValue('foo'));
59
-
60
- $strategy->saveBlock('key', 'value');
61
- }
62
-
63
- public function getLifetimes()
64
- {
65
- return array(
66
- array(0),
67
- array(60),
68
- );
69
- }
70
-
71
- public function createKeyGeneratorMock()
72
- {
73
- return $this->getMock('Asm89\Twig\CacheExtension\CacheStrategy\KeyGeneratorInterface');
74
- }
75
-
76
- public function createCacheProviderMock()
77
- {
78
- return $this->getMock('Asm89\Twig\CacheExtension\CacheProviderInterface');
79
- }
80
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/asm89/twig-cache-extension/test/Asm89/Twig/CacheExtension/Tests/CacheStrategy/IndexedChainingCacheStrategyTest.php DELETED
@@ -1,72 +0,0 @@
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\Tests\CacheStrategy;
13
-
14
- use Asm89\Twig\CacheExtension\CacheStrategy\IndexedChainingCacheStrategy;
15
-
16
- class IndexedChainingCacheStrategyTest extends \PHPUnit_Framework_TestCase
17
- {
18
- private $cacheStrategyMocks = array();
19
-
20
- public function createCacheStrategy()
21
- {
22
- foreach($this->getStrategies() as $config) {
23
- list($key, $return) = $config;
24
-
25
- $cacheStrategyMock = $this->createCacheStrategyMock();
26
- $cacheStrategyMock->expects($this->any())
27
- ->method('generateKey')
28
- ->will($this->returnValue($return));
29
-
30
- $this->cacheStrategyMocks[$key] = $cacheStrategyMock;
31
- }
32
-
33
- return new IndexedChainingCacheStrategy($this->cacheStrategyMocks);
34
- }
35
-
36
- /**
37
- * @dataProvider getStrategies
38
- */
39
- public function testGenerateKeyProxiesToAppropriateStrategy($key, $return)
40
- {
41
- $strategy = $this->createCacheStrategy();
42
-
43
- $generatedKey = $strategy->generateKey('v42', array($key => 'proxied_value'));
44
-
45
- $this->assertEquals($return, $generatedKey['key']);
46
- $this->assertEquals($key, $generatedKey['strategyKey']);
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
-
60
- public function getStrategies()
61
- {
62
- return array(
63
- array('foo', 'foo_key'),
64
- array('bar', 'bar_key'),
65
- );
66
- }
67
-
68
- public function createCacheStrategyMock()
69
- {
70
- return $this->getMock('Asm89\Twig\CacheExtension\CacheStrategyInterface');
71
- }
72
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/asm89/twig-cache-extension/test/Asm89/Twig/CacheExtension/Tests/CacheStrategy/LifetimeCacheStrategyTest.php DELETED
@@ -1,68 +0,0 @@
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\Tests\CacheStrategy;
13
-
14
- use Asm89\Twig\CacheExtension\CacheStrategy\LifetimeCacheStrategy;
15
-
16
- class LifetimeCacheStrategyTest extends \PHPUnit_Framework_TestCase
17
- {
18
- private $cacheProviderMock;
19
-
20
- public function createCacheStrategy()
21
- {
22
- $this->cacheProviderMock = $this->createCacheProviderMock();
23
-
24
- return new LifetimeCacheStrategy($this->cacheProviderMock);
25
- }
26
-
27
- public function testGenerateKeyUsesGivenLifetime()
28
- {
29
- $strategy = $this->createCacheStrategy();
30
-
31
- $key = $strategy->generateKey('v42', 42);
32
-
33
- $this->assertEquals(42, $key['lifetime']);
34
- }
35
-
36
- public function testGenerateKeyAnnotatesKey()
37
- {
38
- $strategy = $this->createCacheStrategy();
39
-
40
- $key = $strategy->generateKey('the_annotation', 42);
41
-
42
- $this->assertContains('the_annotation', $key['key']);
43
- }
44
-
45
- /**
46
- * @dataProvider getInvalidLifetimeValues
47
- * @expectedException RuntimeException
48
- */
49
- public function testGenerateKeyThrowsExceptionWhenNoLifetimeProvided($value)
50
- {
51
- $strategy = $this->createCacheStrategy();
52
-
53
- $strategy->generateKey('v42', $value);
54
- }
55
-
56
- public function getInvalidLifetimeValues()
57
- {
58
- return array(
59
- array('foo'),
60
- array(array('foo')),
61
- );
62
- }
63
-
64
- public function createCacheProviderMock()
65
- {
66
- return $this->getMock('Asm89\Twig\CacheExtension\CacheProviderInterface');
67
- }
68
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/asm89/twig-cache-extension/test/Asm89/Twig/CacheExtension/Tests/FunctionalExtensionTest.php DELETED
@@ -1,185 +0,0 @@
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\Tests;
13
-
14
- use Asm89\Twig\CacheExtension\CacheProvider\DoctrineCacheAdapter;
15
- use Asm89\Twig\CacheExtension\CacheStrategy\KeyGeneratorInterface;
16
- use Asm89\Twig\CacheExtension\CacheStrategy\GenerationalCacheStrategy;
17
- use Asm89\Twig\CacheExtension\CacheStrategy\IndexedChainingCacheStrategy;
18
- use Asm89\Twig\CacheExtension\CacheStrategy\LifetimeCacheStrategy;
19
- use Asm89\Twig\CacheExtension\Extension;
20
- use Doctrine\Common\Cache\ArrayCache;
21
- use Twig_Loader_Filesystem;
22
- use Twig_Environment;
23
-
24
- class FunctionalExtensionTest extends \PHPUnit_Framework_TestCase
25
- {
26
- private $cache;
27
-
28
- protected function createCacheProvider()
29
- {
30
- $this->cache = new ArrayCache();
31
-
32
- return new DoctrineCacheAdapter($this->cache);
33
- }
34
-
35
- protected function createCacheStrategy($name = null)
36
- {
37
- $cacheProvider = $this->createCacheProvider();
38
- $keyGenerator = $this->createKeyGenerator();
39
- $lifetime = 0;
40
-
41
- switch ($name) {
42
- case 'time':
43
- return new LifetimeCacheStrategy($cacheProvider);
44
- case 'indexed':
45
- return new IndexedChainingCacheStrategy(array(
46
- 'gcs' => new GenerationalCacheStrategy($cacheProvider, $keyGenerator, $lifetime),
47
- 'time' => new LifetimeCacheStrategy($cacheProvider),
48
- ));
49
- default:
50
- return new GenerationalCacheStrategy($cacheProvider, $keyGenerator, $lifetime);
51
- }
52
- }
53
-
54
- protected function createKeyGenerator()
55
- {
56
- return new KeyGenerator();
57
- }
58
-
59
- protected function createTwig($cacheStrategyName = null)
60
- {
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);
68
-
69
- return $twig;
70
- }
71
-
72
- protected function getValue($value, $updatedAt)
73
- {
74
- return new Value($value, $updatedAt);
75
- }
76
-
77
- public function testCachesWithSameCacheKey()
78
- {
79
- $twig = $this->createTwig();
80
-
81
- $rendered = $twig->render('gcs_value.twig', array('value' => $this->getValue('asm89', 1)));
82
- $this->assertEquals('Hello asm89!', $rendered);
83
-
84
- $rendered2 = $twig->render('gcs_value.twig', array('value' => $this->getValue('fabpot', 1)));
85
- $this->assertEquals('Hello asm89!', $rendered2);
86
- }
87
-
88
- public function testDifferentCacheOnDifferentAnnotation()
89
- {
90
- $twig = $this->createTwig();
91
-
92
- $rendered = $twig->render('gcs_value.twig', array('value' => $this->getValue('asm89', 1)));
93
- $this->assertEquals('Hello asm89!', $rendered);
94
-
95
- $rendered2 = $twig->render('gcs_value.twig', array('value' => $this->getValue('fabpot', 1)));
96
- $this->assertEquals('Hello asm89!', $rendered2);
97
-
98
- $rendered3 = $twig->render('gcs_value_v2.twig', array('value' => $this->getValue('fabpot', 1)));
99
- $this->assertEquals('Hello fabpot!', $rendered3);
100
- }
101
-
102
- public function testLifetimeCacheStrategy()
103
- {
104
- $twig = $this->createTwig('time');
105
-
106
- $rendered = $twig->render('lcs_value.twig', array('value' => $this->getValue('asm89', 1)));
107
- $this->assertEquals('Hello asm89!', $rendered);
108
-
109
- $rendered2 = $twig->render('lcs_value.twig', array('value' => $this->getValue('fabpot', 1)));
110
- $this->assertEquals('Hello asm89!', $rendered2);
111
-
112
- $this->cache->flushAll();
113
-
114
- $rendered3 = $twig->render('lcs_value.twig', array('value' => $this->getValue('fabpot', 1)));
115
- $this->assertEquals('Hello fabpot!', $rendered3);
116
- }
117
-
118
- public function testIndexedChainingStrategy()
119
- {
120
- $twig = $this->createTwig('indexed');
121
-
122
- $rendered = $twig->render('ics_value.twig', array('value' => $this->getValue('asm89', 1)));
123
- $this->assertEquals('Hello asm89!', $rendered);
124
-
125
- $rendered2 = $twig->render('ics_value.twig', array('value' => $this->getValue('fabpot', 1)));
126
- $this->assertEquals('Hello asm89!', $rendered2);
127
-
128
- $this->cache->flushAll();
129
-
130
- $rendered3 = $twig->render('ics_value.twig', array('value' => $this->getValue('fabpot', 1)));
131
- $this->assertEquals('Hello fabpot!', $rendered3);
132
- }
133
-
134
- /**
135
- * @expectedException Twig_Error_Runtime
136
- * @expectedExceptionMessage An exception has been thrown during the rendering of a template ("No strategy key found in value.") in "ics_no_key.twig" at line 1.
137
- */
138
- public function testIndexedChainingStrategyNeedsKey()
139
- {
140
- $twig = $this->createTwig('indexed');
141
-
142
- $rendered = $twig->render('ics_no_key.twig', array('value' => $this->getValue('asm89', 1)));
143
- }
144
-
145
- /**
146
- * @expectedException Twig_Error_Syntax
147
- * @expectedExceptionMessage Unexpected token "name" of value "annotation" ("string" expected) in "annotation_not_string.twig"
148
- */
149
- public function testAnnotationMustBeString()
150
- {
151
- $twig = $this->createTwig();
152
-
153
- $rendered = $twig->render('annotation_not_string.twig', array('value' => $this->getValue('asm89', 1)));
154
- }
155
- }
156
-
157
- class KeyGenerator implements KeyGeneratorInterface
158
- {
159
- public function generateKey($value)
160
- {
161
- return get_class($value) . '_' . $value->getUpdatedAt();
162
- }
163
-
164
- }
165
-
166
- class Value
167
- {
168
- private $updatedAt;
169
-
170
- public function __construct($value, $updatedAt)
171
- {
172
- $this->value = $value;
173
- $this->updatedAt = $updatedAt;
174
- }
175
-
176
- public function getUpdatedAt()
177
- {
178
- return $this->updatedAt;
179
- }
180
-
181
- public function __toString()
182
- {
183
- return $this->value;
184
- }
185
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/asm89/twig-cache-extension/test/Asm89/Twig/CacheExtension/Tests/fixtures/annotation_not_string.twig DELETED
@@ -1,2 +0,0 @@
1
- {% set annotation = 'v1' %}
2
- {% cache annotation value %}Hello {{ value }}!{% endcache %}
 
 
vendor/vendor/asm89/twig-cache-extension/test/Asm89/Twig/CacheExtension/Tests/fixtures/gcs_value.twig DELETED
@@ -1 +0,0 @@
1
- {% cache 'v1' value %}Hello {{ value }}!{% endcache %}
 
vendor/vendor/asm89/twig-cache-extension/test/Asm89/Twig/CacheExtension/Tests/fixtures/gcs_value_v2.twig DELETED
@@ -1 +0,0 @@
1
- {% cache 'v2' value %}Hello {{ value }}!{% endcache %}
 
vendor/vendor/asm89/twig-cache-extension/test/Asm89/Twig/CacheExtension/Tests/fixtures/ics_no_key.twig DELETED
@@ -1 +0,0 @@
1
- {% cache 'v1' 10 %}Hello {{ value }}!{% endcache %}
 
vendor/vendor/asm89/twig-cache-extension/test/Asm89/Twig/CacheExtension/Tests/fixtures/ics_value.twig DELETED
@@ -1 +0,0 @@
1
- {% cache 'v1' {time: 10} %}Hello {{ value }}!{% endcache %}
 
vendor/vendor/asm89/twig-cache-extension/test/Asm89/Twig/CacheExtension/Tests/fixtures/lcs_value.twig DELETED
@@ -1 +0,0 @@
1
- {% cache 'v1' 10 %}Hello {{ value }}!{% endcache %}
 
vendor/vendor/asm89/twig-cache-extension/test/bootstrap.php DELETED
@@ -1,16 +0,0 @@
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
- if (file_exists($file = __DIR__.'/../vendor/autoload.php')) {
13
- $autoload = require_once $file;
14
- } else {
15
- throw new RuntimeException('Install dependencies to run test suite.');
16
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/autoload.php DELETED
@@ -1,7 +0,0 @@
1
- <?php
2
-
3
- // autoload.php @generated by Composer
4
-
5
- require_once __DIR__ . '/composer' . '/autoload_real.php';
6
-
7
- return ComposerAutoloaderInita70107d44215103d417eb8d0d8675954::getLoader();
 
 
 
 
 
 
 
vendor/vendor/composer/ClassLoader.php DELETED
@@ -1,378 +0,0 @@
1
- <?php
2
-
3
- /*
4
- * This file is part of Composer.
5
- *
6
- * (c) Nils Adermann <naderman@naderman.de>
7
- * Jordi Boggiano <j.boggiano@seld.be>
8
- *
9
- * For the full copyright and license information, please view the LICENSE
10
- * file that was distributed with this source code.
11
- */
12
-
13
- namespace Composer\Autoload;
14
-
15
- /**
16
- * ClassLoader implements a PSR-0 class loader
17
- *
18
- * See https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md
19
- *
20
- * $loader = new \Composer\Autoload\ClassLoader();
21
- *
22
- * // register classes with namespaces
23
- * $loader->add('Symfony\Component', __DIR__.'/component');
24
- * $loader->add('Symfony', __DIR__.'/framework');
25
- *
26
- * // activate the autoloader
27
- * $loader->register();
28
- *
29
- * // to enable searching the include path (eg. for PEAR packages)
30
- * $loader->setUseIncludePath(true);
31
- *
32
- * In this example, if you try to use a class in the Symfony\Component
33
- * namespace or one of its children (Symfony\Component\Console for instance),
34
- * the autoloader will first look for the class under the component/
35
- * directory, and it will then fallback to the framework/ directory if not
36
- * found before giving up.
37
- *
38
- * This class is loosely based on the Symfony UniversalClassLoader.
39
- *
40
- * @author Fabien Potencier <fabien@symfony.com>
41
- * @author Jordi Boggiano <j.boggiano@seld.be>
42
- */
43
- class ClassLoader
44
- {
45
- // PSR-4
46
- private $prefixLengthsPsr4 = array();
47
- private $prefixDirsPsr4 = array();
48
- private $fallbackDirsPsr4 = array();
49
-
50
- // PSR-0
51
- private $prefixesPsr0 = array();
52
- private $fallbackDirsPsr0 = array();
53
-
54
- private $useIncludePath = false;
55
- private $classMap = array();
56
-
57
- public function getPrefixes()
58
- {
59
- return call_user_func_array('array_merge', $this->prefixesPsr0);
60
- }
61
-
62
- public function getPrefixesPsr4()
63
- {
64
- return $this->prefixDirsPsr4;
65
- }
66
-
67
- public function getFallbackDirs()
68
- {
69
- return $this->fallbackDirsPsr0;
70
- }
71
-
72
- public function getFallbackDirsPsr4()
73
- {
74
- return $this->fallbackDirsPsr4;
75
- }
76
-
77
- public function getClassMap()
78
- {
79
- return $this->classMap;
80
- }
81
-
82
- /**
83
- * @param array $classMap Class to filename map
84
- */
85
- public function addClassMap(array $classMap)
86
- {
87
- if ($this->classMap) {
88
- $this->classMap = array_merge($this->classMap, $classMap);
89
- } else {
90
- $this->classMap = $classMap;
91
- }
92
- }
93
-
94
- /**
95
- * Registers a set of PSR-0 directories for a given prefix, either
96
- * appending or prepending to the ones previously set for this prefix.
97
- *
98
- * @param string $prefix The prefix
99
- * @param array|string $paths The PSR-0 root directories
100
- * @param bool $prepend Whether to prepend the directories
101
- */
102
- public function add($prefix, $paths, $prepend = false)
103
- {
104
- if (!$prefix) {
105
- if ($prepend) {
106
- $this->fallbackDirsPsr0 = array_merge(
107
- (array) $paths,
108
- $this->fallbackDirsPsr0
109
- );
110
- } else {
111
- $this->fallbackDirsPsr0 = array_merge(
112
- $this->fallbackDirsPsr0,
113
- (array) $paths
114
- );
115
- }
116
-
117
- return;
118
- }
119
-
120
- $first = $prefix[0];
121
- if (!isset($this->prefixesPsr0[$first][$prefix])) {
122
- $this->prefixesPsr0[$first][$prefix] = (array) $paths;
123
-
124
- return;
125
- }
126
- if ($prepend) {
127
- $this->prefixesPsr0[$first][$prefix] = array_merge(
128
- (array) $paths,
129
- $this->prefixesPsr0[$first][$prefix]
130
- );
131
- } else {
132
- $this->prefixesPsr0[$first][$prefix] = array_merge(
133
- $this->prefixesPsr0[$first][$prefix],
134
- (array) $paths
135
- );
136
- }
137
- }
138
-
139
- /**
140
- * Registers a set of PSR-4 directories for a given namespace, either
141
- * appending or prepending to the ones previously set for this namespace.
142
- *
143
- * @param string $prefix The prefix/namespace, with trailing '\\'
144
- * @param array|string $paths The PSR-0 base directories
145
- * @param bool $prepend Whether to prepend the directories
146
- */
147
- public function addPsr4($prefix, $paths, $prepend = false)
148
- {
149
- if (!$prefix) {
150
- // Register directories for the root namespace.
151
- if ($prepend) {
152
- $this->fallbackDirsPsr4 = array_merge(
153
- (array) $paths,
154
- $this->fallbackDirsPsr4
155
- );
156
- } else {
157
- $this->fallbackDirsPsr4 = array_merge(
158
- $this->fallbackDirsPsr4,
159
- (array) $paths
160
- );
161
- }
162
- } elseif (!isset($this->prefixDirsPsr4[$prefix])) {
163
- // Register directories for a new namespace.
164
- $length = strlen($prefix);
165
- if ('\\' !== $prefix[$length - 1]) {
166
- throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
167
- }
168
- $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
169
- $this->prefixDirsPsr4[$prefix] = (array) $paths;
170
- } elseif ($prepend) {
171
- // Prepend directories for an already registered namespace.
172
- $this->prefixDirsPsr4[$prefix] = array_merge(
173
- (array) $paths,
174
- $this->prefixDirsPsr4[$prefix]
175
- );
176
- } else {
177
- // Append directories for an already registered namespace.
178
- $this->prefixDirsPsr4[$prefix] = array_merge(
179
- $this->prefixDirsPsr4[$prefix],
180
- (array) $paths
181
- );
182
- }
183
- }
184
-
185
- /**
186
- * Registers a set of PSR-0 directories for a given prefix,
187
- * replacing any others previously set for this prefix.
188
- *
189
- * @param string $prefix The prefix
190
- * @param array|string $paths The PSR-0 base directories
191
- */
192
- public function set($prefix, $paths)
193
- {
194
- if (!$prefix) {
195
- $this->fallbackDirsPsr0 = (array) $paths;
196
- } else {
197
- $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
198
- }
199
- }
200
-
201
- /**
202
- * Registers a set of PSR-4 directories for a given namespace,
203
- * replacing any others previously set for this namespace.
204
- *
205
- * @param string $prefix The prefix/namespace, with trailing '\\'
206
- * @param array|string $paths The PSR-4 base directories
207
- */
208
- public function setPsr4($prefix, $paths) {
209
- if (!$prefix) {
210
- $this->fallbackDirsPsr4 = (array) $paths;
211
- } else {
212
- $length = strlen($prefix);
213
- if ('\\' !== $prefix[$length - 1]) {
214
- throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
215
- }
216
- $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
217
- $this->prefixDirsPsr4[$prefix] = (array) $paths;
218
- }
219
- }
220
-
221
- /**
222
- * Turns on searching the include path for class files.
223
- *
224
- * @param bool $useIncludePath
225
- */
226
- public function setUseIncludePath($useIncludePath)
227
- {
228
- $this->useIncludePath = $useIncludePath;
229
- }
230
-
231
- /**
232
- * Can be used to check if the autoloader uses the include path to check
233
- * for classes.
234
- *
235
- * @return bool
236
- */
237
- public function getUseIncludePath()
238
- {
239
- return $this->useIncludePath;
240
- }
241
-
242
- /**
243
- * Registers this instance as an autoloader.
244
- *
245
- * @param bool $prepend Whether to prepend the autoloader or not
246
- */
247
- public function register($prepend = false)
248
- {
249
- spl_autoload_register(array($this, 'loadClass'), true, $prepend);
250
- }
251
-
252
- /**
253
- * Unregisters this instance as an autoloader.
254
- */
255
- public function unregister()
256
- {
257
- spl_autoload_unregister(array($this, 'loadClass'));
258
- }
259
-
260
- /**
261
- * Loads the given class or interface.
262
- *
263
- * @param string $class The name of the class
264
- * @return bool|null True if loaded, null otherwise
265
- */
266
- public function loadClass($class)
267
- {
268
- if ($file = $this->findFile($class)) {
269
- includeFile($file);
270
-
271
- return true;
272
- }
273
- }
274
-
275
- /**
276
- * Finds the path to the file where the class is defined.
277
- *
278
- * @param string $class The name of the class
279
- *
280
- * @return string|false The path if found, false otherwise
281
- */
282
- public function findFile($class)
283
- {
284
- // work around for PHP 5.3.0 - 5.3.2 https://bugs.php.net/50731
285
- if ('\\' == $class[0]) {
286
- $class = substr($class, 1);
287
- }
288
-
289
- // class map lookup
290
- if (isset($this->classMap[$class])) {
291
- return $this->classMap[$class];
292
- }
293
-
294
- $file = $this->findFileWithExtension($class, '.php');
295
-
296
- // Search for Hack files if we are running on HHVM
297
- if ($file === null && defined('HHVM_VERSION')) {
298
- $file = $this->findFileWithExtension($class, '.hh');
299
- }
300
-
301
- if ($file === null) {
302
- // Remember that this class does not exist.
303
- return $this->classMap[$class] = false;
304
- }
305
-
306
- return $file;
307
- }
308
-
309
- private function findFileWithExtension($class, $ext)
310
- {
311
- // PSR-4 lookup
312
- $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
313
-
314
- $first = $class[0];
315
- if (isset($this->prefixLengthsPsr4[$first])) {
316
- foreach ($this->prefixLengthsPsr4[$first] as $prefix => $length) {
317
- if (0 === strpos($class, $prefix)) {
318
- foreach ($this->prefixDirsPsr4[$prefix] as $dir) {
319
- if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) {
320
- return $file;
321
- }
322
- }
323
- }
324
- }
325
- }
326
-
327
- // PSR-4 fallback dirs
328
- foreach ($this->fallbackDirsPsr4 as $dir) {
329
- if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
330
- return $file;
331
- }
332
- }
333
-
334
- // PSR-0 lookup
335
- if (false !== $pos = strrpos($class, '\\')) {
336
- // namespaced class name
337
- $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
338
- . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
339
- } else {
340
- // PEAR-like class name
341
- $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
342
- }
343
-
344
- if (isset($this->prefixesPsr0[$first])) {
345
- foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
346
- if (0 === strpos($class, $prefix)) {
347
- foreach ($dirs as $dir) {
348
- if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
349
- return $file;
350
- }
351
- }
352
- }
353
- }
354
- }
355
-
356
- // PSR-0 fallback dirs
357
- foreach ($this->fallbackDirsPsr0 as $dir) {
358
- if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
359
- return $file;
360
- }
361
- }
362
-
363
- // PSR-0 include paths.
364
- if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
365
- return $file;
366
- }
367
- }
368
- }
369
-
370
- /**
371
- * Scope isolated include.
372
- *
373
- * Prevents access to $this/self from included files.
374
- */
375
- function includeFile($file)
376
- {
377
- include $file;
378
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/composer/autoload_classmap.php DELETED
@@ -1,9 +0,0 @@
1
- <?php
2
-
3
- // autoload_classmap.php @generated by Composer
4
-
5
- $vendorDir = dirname(dirname(__FILE__));
6
- $baseDir = dirname($vendorDir);
7
-
8
- return array(
9
- );
 
 
 
 
 
 
 
 
 
vendor/vendor/composer/autoload_namespaces.php DELETED
@@ -1,14 +0,0 @@
1
- <?php
2
-
3
- // autoload_namespaces.php @generated by Composer
4
-
5
- $vendorDir = dirname(dirname(__FILE__));
6
- $baseDir = dirname($vendorDir);
7
-
8
- return array(
9
- 'Twig_' => array($vendorDir . '/twig/twig/lib'),
10
- 'Symfony\\Component\\Yaml\\' => array($vendorDir . '/symfony/yaml'),
11
- 'PHPRouter' => array($vendorDir . '/dannyvankooten/php-router/src'),
12
- 'Composer\\Installers\\' => array($vendorDir . '/composer/installers/src'),
13
- 'Asm89\\Twig\\CacheExtension\\' => array($vendorDir . '/asm89/twig-cache-extension/lib'),
14
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/composer/autoload_psr4.php DELETED
@@ -1,9 +0,0 @@
1
- <?php
2
-
3
- // autoload_psr4.php @generated by Composer
4
-
5
- $vendorDir = dirname(dirname(__FILE__));
6
- $baseDir = dirname($vendorDir);
7
-
8
- return array(
9
- );
 
 
 
 
 
 
 
 
 
vendor/vendor/composer/autoload_real.php DELETED
@@ -1,53 +0,0 @@
1
- <?php
2
-
3
- // autoload_real.php @generated by Composer
4
-
5
- class ComposerAutoloaderInita70107d44215103d417eb8d0d8675954
6
- {
7
- private static $loader;
8
-
9
- public static function loadClassLoader($class)
10
- {
11
- if ('Composer\Autoload\ClassLoader' === $class) {
12
- require __DIR__ . '/ClassLoader.php';
13
- }
14
- }
15
-
16
- public static function getLoader()
17
- {
18
- if (null !== self::$loader) {
19
- return self::$loader;
20
- }
21
-
22
- spl_autoload_register(array('ComposerAutoloaderInita70107d44215103d417eb8d0d8675954', 'loadClassLoader'), true, true);
23
- self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
- spl_autoload_unregister(array('ComposerAutoloaderInita70107d44215103d417eb8d0d8675954', 'loadClassLoader'));
25
-
26
- $vendorDir = dirname(__DIR__);
27
- $baseDir = dirname($vendorDir);
28
-
29
- $map = require __DIR__ . '/autoload_namespaces.php';
30
- foreach ($map as $namespace => $path) {
31
- $loader->set($namespace, $path);
32
- }
33
-
34
- $map = require __DIR__ . '/autoload_psr4.php';
35
- foreach ($map as $namespace => $path) {
36
- $loader->setPsr4($namespace, $path);
37
- }
38
-
39
- $classMap = require __DIR__ . '/autoload_classmap.php';
40
- if ($classMap) {
41
- $loader->addClassMap($classMap);
42
- }
43
-
44
- $loader->register(true);
45
-
46
- return $loader;
47
- }
48
- }
49
-
50
- function composerRequirea70107d44215103d417eb8d0d8675954($file)
51
- {
52
- require $file;
53
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/composer/installed.json DELETED
@@ -1,311 +0,0 @@
1
- [
2
- {
3
- "name": "composer/installers",
4
- "version": "v1.0.15",
5
- "version_normalized": "1.0.15.0",
6
- "source": {
7
- "type": "git",
8
- "url": "https://github.com/composer/installers.git",
9
- "reference": "8e6a72a78f6cfd537fde3350720dfdc9ae3c5621"
10
- },
11
- "dist": {
12
- "type": "zip",
13
- "url": "https://api.github.com/repos/composer/installers/zipball/8e6a72a78f6cfd537fde3350720dfdc9ae3c5621",
14
- "reference": "8e6a72a78f6cfd537fde3350720dfdc9ae3c5621",
15
- "shasum": ""
16
- },
17
- "replace": {
18
- "roundcube/plugin-installer": "*",
19
- "shama/baton": "*"
20
- },
21
- "require-dev": {
22
- "composer/composer": "1.0.*@dev",
23
- "phpunit/phpunit": "4.1.*"
24
- },
25
- "time": "2014-06-23 16:25:28",
26
- "type": "composer-installer",
27
- "extra": {
28
- "class": "Composer\\Installers\\Installer",
29
- "branch-alias": {
30
- "dev-master": "1.0-dev"
31
- }
32
- },
33
- "installation-source": "dist",
34
- "autoload": {
35
- "psr-0": {
36
- "Composer\\Installers\\": "src/"
37
- }
38
- },
39
- "notification-url": "https://packagist.org/downloads/",
40
- "license": [
41
- "MIT"
42
- ],
43
- "authors": [
44
- {
45
- "name": "Kyle Robinson Young",
46
- "email": "kyle@dontkry.com",
47
- "homepage": "https://github.com/shama",
48
- "role": "Developer"
49
- }
50
- ],
51
- "description": "A multi-framework Composer library installer",
52
- "homepage": "http://composer.github.com/installers/",
53
- "keywords": [
54
- "Craft",
55
- "Dolibarr",
56
- "Hurad",
57
- "MODX Evo",
58
- "OXID",
59
- "WolfCMS",
60
- "agl",
61
- "annotatecms",
62
- "bitrix",
63
- "cakephp",
64
- "codeigniter",
65
- "concrete5",
66
- "croogo",
67
- "drupal",
68
- "elgg",
69
- "fuelphp",
70
- "installer",
71
- "joomla",
72
- "kohana",
73
- "laravel",
74
- "lithium",
75
- "magento",
76
- "mako",
77
- "mediawiki",
78
- "modulework",
79
- "moodle",
80
- "phpbb",
81
- "piwik",
82
- "ppi",
83
- "roundcube",
84
- "shopware",
85
- "silverstripe",
86
- "symfony",
87
- "typo3",
88
- "wordpress",
89
- "zend",
90
- "zikula"
91
- ]
92
- },
93
- {
94
- "name": "twig/twig",
95
- "version": "v1.15.1",
96
- "version_normalized": "1.15.1.0",
97
- "source": {
98
- "type": "git",
99
- "url": "https://github.com/fabpot/Twig.git",
100
- "reference": "1fb5784662f438d7d96a541e305e28b812e2eeed"
101
- },
102
- "dist": {
103
- "type": "zip",
104
- "url": "https://api.github.com/repos/fabpot/Twig/zipball/1fb5784662f438d7d96a541e305e28b812e2eeed",
105
- "reference": "1fb5784662f438d7d96a541e305e28b812e2eeed",
106
- "shasum": ""
107
- },
108
- "require": {
109
- "php": ">=5.2.4"
110
- },
111
- "time": "2014-02-13 10:19:29",
112
- "type": "library",
113
- "extra": {
114
- "branch-alias": {
115
- "dev-master": "1.15-dev"
116
- }
117
- },
118
- "installation-source": "dist",
119
- "autoload": {
120
- "psr-0": {
121
- "Twig_": "lib/"
122
- }
123
- },
124
- "notification-url": "https://packagist.org/downloads/",
125
- "license": [
126
- "BSD-3-Clause"
127
- ],
128
- "authors": [
129
- {
130
- "name": "Fabien Potencier",
131
- "email": "fabien@symfony.com",
132
- "homepage": "http://fabien.potencier.org",
133
- "role": "Lead Developer"
134
- },
135
- {
136
- "name": "Armin Ronacher2",
137
- "email": "armin.ronacher@active-4.com",
138
- "role": "Project Founder"
139
- },
140
- {
141
- "name": "Twig Team",
142
- "homepage": "https://github.com/fabpot/Twig/graphs/contributors",
143
- "role": "Contributors"
144
- }
145
- ],
146
- "description": "Twig, the flexible, fast, and secure template language for PHP",
147
- "homepage": "http://twig.sensiolabs.org",
148
- "keywords": [
149
- "templating"
150
- ]
151
- },
152
- {
153
- "name": "asm89/twig-cache-extension",
154
- "version": "0.1.0",
155
- "version_normalized": "0.1.0.0",
156
- "source": {
157
- "type": "git",
158
- "url": "https://github.com/asm89/twig-cache-extension.git",
159
- "reference": "35da9579dc0648e5bb52d02530ff81352f7e1247"
160
- },
161
- "dist": {
162
- "type": "zip",
163
- "url": "https://api.github.com/repos/asm89/twig-cache-extension/zipball/35da9579dc0648e5bb52d02530ff81352f7e1247",
164
- "reference": "35da9579dc0648e5bb52d02530ff81352f7e1247",
165
- "shasum": ""
166
- },
167
- "require": {
168
- "php": ">=5.3.2",
169
- "twig/twig": "1.*"
170
- },
171
- "require-dev": {
172
- "doctrine/cache": "1.*"
173
- },
174
- "time": "2013-11-13 20:03:36",
175
- "type": "library",
176
- "extra": {
177
- "branch-alias": {
178
- "dev-master": "0.1-dev"
179
- }
180
- },
181
- "installation-source": "dist",
182
- "autoload": {
183
- "psr-0": {
184
- "Asm89\\Twig\\CacheExtension\\": "lib/"
185
- }
186
- },
187
- "notification-url": "https://packagist.org/downloads/",
188
- "license": [
189
- "MIT"
190
- ],
191
- "authors": [
192
- {
193
- "name": "Alexander",
194
- "email": "iam.asm89@gmail.com",
195
- "homepage": "http://asm89.github.io/"
196
- }
197
- ],
198
- "description": "Caching template fragments with Twig.",
199
- "homepage": "https://github.com/asm89/twig-cache-extension",
200
- "keywords": [
201
- "cache",
202
- "extension",
203
- "twig"
204
- ]
205
- },
206
- {
207
- "name": "symfony/yaml",
208
- "version": "v2.5.0",
209
- "version_normalized": "2.5.0.0",
210
- "target-dir": "Symfony/Component/Yaml",
211
- "source": {
212
- "type": "git",
213
- "url": "https://github.com/symfony/Yaml.git",
214
- "reference": "b4b09c68ec2f2727574544ef0173684281a5033c"
215
- },
216
- "dist": {
217
- "type": "zip",
218
- "url": "https://api.github.com/repos/symfony/Yaml/zipball/b4b09c68ec2f2727574544ef0173684281a5033c",
219
- "reference": "b4b09c68ec2f2727574544ef0173684281a5033c",
220
- "shasum": ""
221
- },
222
- "require": {
223
- "php": ">=5.3.3"
224
- },
225
- "time": "2014-05-16 14:25:18",
226
- "type": "library",
227
- "extra": {
228
- "branch-alias": {
229
- "dev-master": "2.5-dev"
230
- }
231
- },
232
- "installation-source": "dist",
233
- "autoload": {
234
- "psr-0": {
235
- "Symfony\\Component\\Yaml\\": ""
236
- }
237
- },
238
- "notification-url": "https://packagist.org/downloads/",
239
- "license": [
240
- "MIT"
241
- ],
242
- "authors": [
243
- {
244
- "name": "Fabien Potencier",
245
- "email": "fabien@symfony.com",
246
- "homepage": "http://fabien.potencier.org",
247
- "role": "Lead Developer"
248
- },
249
- {
250
- "name": "Symfony Community",
251
- "homepage": "http://symfony.com/contributors"
252
- }
253
- ],
254
- "description": "Symfony Yaml Component",
255
- "homepage": "http://symfony.com"
256
- },
257
- {
258
- "name": "dannyvankooten/php-router",
259
- "version": "dev-master",
260
- "version_normalized": "9999999-dev",
261
- "source": {
262
- "type": "git",
263
- "url": "https://github.com/dannyvankooten/PHP-Router.git",
264
- "reference": "e9a479820b871ae4493fec30d5e433456767a505"
265
- },
266
- "dist": {
267
- "type": "zip",
268
- "url": "https://api.github.com/repos/dannyvankooten/PHP-Router/zipball/896472302cd1c0d0b6269b3837e7ca636a5b9b3a",
269
- "reference": "e9a479820b871ae4493fec30d5e433456767a505",
270
- "shasum": ""
271
- },
272
- "require": {
273
- "php": ">=5.3.3",
274
- "symfony/yaml": "@dev"
275
- },
276
- "require-dev": {
277
- "phpunit/phpunit": "3.7.*"
278
- },
279
- "time": "2014-02-12 12:10:38",
280
- "type": "library",
281
- "installation-source": "source",
282
- "autoload": {
283
- "psr-0": {
284
- "PHPRouter": "src/"
285
- }
286
- },
287
- "notification-url": "https://packagist.org/downloads/",
288
- "license": [
289
- "MIT"
290
- ],
291
- "authors": [
292
- {
293
- "name": "Danny van Kooten",
294
- "email": "dannyvankooten@gmail.com",
295
- "homepage": "http://dannyvankooten.com/"
296
- },
297
- {
298
- "name": "Jefersson Nathan",
299
- "email": "malukenho@phpse.net"
300
- }
301
- ],
302
- "description": "Simple PHP Router, supports REST and reverse routing.",
303
- "homepage": "https://github.com/dannyvankooten/PHP-Router",
304
- "keywords": [
305
- "php",
306
- "rest",
307
- "router",
308
- "routing"
309
- ]
310
- }
311
- ]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/composer/installers/.editorconfig DELETED
@@ -1,10 +0,0 @@
1
- ; top-most EditorConfig file
2
- root = true
3
-
4
- ; Unix-style newlines
5
- [*]
6
- end_of_line = LF
7
-
8
- [*.php]
9
- indent_style = space
10
- indent_size = 4
 
 
 
 
 
 
 
 
 
 
vendor/vendor/composer/installers/.gitignore DELETED
@@ -1,3 +0,0 @@
1
- vendor/
2
- composer.lock
3
- .idea/
 
 
 
vendor/vendor/composer/installers/.travis.yml DELETED
@@ -1,11 +0,0 @@
1
- language: php
2
-
3
- php:
4
- - 5.3
5
- - 5.4
6
-
7
- before_script:
8
- - curl -s http://getcomposer.org/installer | php -- --quiet
9
- - php composer.phar install --dev
10
-
11
- script: phpunit
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/composer/installers/LICENSE DELETED
@@ -1,19 +0,0 @@
1
- Copyright (c) 2012 Kyle Robinson Young
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining a copy
4
- of this software and associated documentation files (the "Software"), to deal
5
- in the Software without restriction, including without limitation the rights
6
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- copies of the Software, and to permit persons to whom the Software is furnished
8
- to do so, subject to the following conditions:
9
-
10
- The above copyright notice and this permission notice shall be included in all
11
- copies or substantial portions of the Software.
12
-
13
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
- THE SOFTWARE.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/composer/installers/README.md DELETED
@@ -1,180 +0,0 @@
1
- # A Multi-Framework [Composer](http://getcomposer.org) Library Installer
2
-
3
- [![Build Status](https://secure.travis-ci.org/composer/installers.png)](http://travis-ci.org/composer/installers)
4
-
5
- This is for PHP package authors to require in their `composer.json`. It will
6
- install their package to the correct location based on the specified package
7
- type.
8
-
9
- The goal of `installers` is to be a simple package type to install path map.
10
- Users can also customize the install path per package and package authors can
11
- modify the package name upon installing.
12
-
13
- `installers` isn't intended on replacing all custom installers. If your
14
- package requires special installation handling then by all means, create a
15
- custom installer to handle it.
16
-
17
- **Natively Supported Frameworks**:
18
-
19
- The following frameworks natively work with Composer and will be
20
- installed to the default `vendor` directory. `composer/installers`
21
- is not needed to install packages with these frameworks:
22
-
23
- * Aura
24
- * Symfony2
25
- * Yii
26
- * Yii2
27
-
28
- **Current Supported Package Types**:
29
-
30
- > Stable types are marked as **bold**, this means that installation paths
31
- > for those type will not be changed. Any adjustment for those types would
32
- > require creation of brand new type that will cover required changes.
33
-
34
- | Framework | Types
35
- | --------- | -----
36
- | AGL | `agl-module`
37
- | AnnotateCms | `annotatecms-module`<br>`annotatecms-component`<br>`annotatecms-service`
38
- | Bitrix | `bitrix-module`<br>`bitrix-component`
39
- | CakePHP 2+ | **`cakephp-plugin`**
40
- | CodeIgniter | `codeigniter-library`<br>`codeigniter-third-party`<br>`codeigniter-module`
41
- | concrete5 | `concrete5-block`<br>`concrete5-package`<br>`concrete5-theme`<br>`concrete5-update`
42
- | Craft | `craft-plugin`
43
- | Croogo | `croogo-plugin`<br>`croogo-theme`
44
- | Dolibarr | `dolibarr-module`
45
- | Drupal | <b>`drupal-module`<br>`drupal-theme`</b><br>`drupal-library`<br>`drupal-profile`<br>`drupal-drush`
46
- | Elgg | `elgg-plugin`
47
- | FuelPHP v1.x | `fuel-module`<br>`fuel-package`<br/>`fuel-theme`
48
- | Hurad | `hurad-plugin`<br>`hurad-theme`
49
- | Joomla | `joomla-component`<br>`joomla-module`<br>`joomla-template`<br>`joomla-plugin`<br>`joomla-library`
50
- | Kirby | **`kirby-plugin`**
51
- | Kohana | **`kohana-module`**
52
- | Laravel | `laravel-library`
53
- | Lithium | **`lithium-library`<br>`lithium-source`**
54
- | Magento | `magento-library`<br>`magento-skin`<br>`magento-theme`
55
- | Mako | `mako-package`
56
- | MODX Evo | `modxevo-snippet`<br>`modxevo-plugin`<br>`modxevo-module`<br>`modxevo-template`<br>`modxevo-lib`
57
- | MediaWiki | `mediawiki-extension`
58
- | October | **`october-module`<br>`october-plugin`**
59
- | OXID | `oxid-module`<br>`oxid-theme`<br>`oxid-out`
60
- | MODULEWork | `modulework-module`
61
- | Moodle | `moodle-*` (Please [check source](https://raw.githubusercontent.com/composer/installers/master/src/Composer/Installers/MoodleInstaller.php) for all supported types)
62
- | Piwik | `piwik-plugin`
63
- | phpBB | `phpbb-extension`<br>`phpbb-style`<br>`phpbb-language`
64
- | Pimcore | `pimcore-plugin`
65
- | PPI | **`ppi-module`**
66
- | Roundcube | `roundcube-plugin`
67
- | shopware | `shopware-backend-plugin`<br/>`shopware-core-plugin`<br/>`shopware-frontend-plugin`<br/>`shopware-theme`
68
- | SilverStripe | `silverstripe-module`<br>`silverstripe-theme`
69
- | symfony1 | **`symfony1-plugin`**
70
- | Tusk | `tusk-task`<br>`tusk-command`<br>`tusk-asset`
71
- | TYPO3 Flow | `typo3-flow-package`<br>`typo3-flow-framework`<br>`typo3-flow-plugin`<br>`typo3-flow-site`<br>`typo3-flow-boilerplate`<br>`typo3-flow-build`
72
- | TYPO3 CMS | `typo3-cms-extension`
73
- | Wolf CMS | `wolfcms-plugin`
74
- | WordPress | <b>`wordpress-plugin`<br>`wordpress-theme`</b><br>`wordpress-muplugin`
75
- | Zend | `zend-library`<br>`zend-extra`<br>`zend-module`
76
- | Zikula | `zikula-module`<br>`zikula-theme`
77
-
78
- ## Example `composer.json` File
79
-
80
- This is an example for a CakePHP plugin. The only important parts to set in your
81
- composer.json file are `"type": "cakephp-plugin"` which describes what your
82
- package is and `"require": { "composer/installers": "~1.0" }` which tells composer
83
- to load the custom installers.
84
-
85
- ```json
86
- {
87
- "name": "you/ftp",
88
- "type": "cakephp-plugin",
89
- "require": {
90
- "composer/installers": "~1.0"
91
- }
92
- }
93
- ```
94
-
95
- This would install your package to the `Plugin/Ftp/` folder of a CakePHP app
96
- when a user runs `php composer.phar install`.
97
-
98
- So submit your packages to [packagist.org](http://packagist.org)!
99
-
100
- ## Custom Install Paths
101
-
102
- If you are consuming a package that uses the `composer/installers` you can
103
- override the install path with the following extra in your `composer.json`:
104
-
105
- ```json
106
- {
107
- "extra": {
108
- "installer-paths": {
109
- "your/custom/path/{$name}/": ["shama/ftp", "vendor/package"]
110
- }
111
- }
112
- }
113
- ```
114
-
115
- A package type can have a custom installation path with a `type:` prefix.
116
-
117
- ``` json
118
- {
119
- "extra": {
120
- "installer-paths": {
121
- "your/custom/path/{$name}/": ["type:wordpress-plugin"]
122
- }
123
- }
124
- }
125
- ```
126
-
127
- This would use your custom path for each of the listed packages. The available
128
- variables to use in your paths are: `{$name}`, `{$vendor}`, `{$type}`.
129
-
130
- ## Custom Install Names
131
-
132
- If you're a package author and need your package to be named differently when
133
- installed consider using the `installer-name` extra.
134
-
135
- For example you have a package named `shama/cakephp-ftp` with the type
136
- `cakephp-plugin`. Installing with `composer/installers` would install to the
137
- path `Plugin/CakephpFtp`. Due to the strict naming conventions, you as a
138
- package author actually need the package to be named and installed to
139
- `Plugin/Ftp`. Using the following config within your **package** `composer.json`
140
- will allow this:
141
-
142
- ```json
143
- {
144
- "name": "shama/cakephp-ftp",
145
- "type": "cakephp-plugin",
146
- "extra": {
147
- "installer-name": "Ftp"
148
- }
149
- }
150
- ```
151
-
152
- Please note the name entered into `installer-name` will be the final and will
153
- not be inflected.
154
-
155
- ## Contribute!
156
-
157
- * [Fork and clone](https://help.github.com/articles/fork-a-repo).
158
- * Run the command `php composer.phar install --dev` to install the dev
159
- dependencies. See [Composer](https://github.com/composer/composer#installation--usage).
160
- * Use the command `phpunit` to run the tests. See [PHPUnit](http://phpunit.de).
161
- * Create a branch, commit, push and send us a
162
- [pull request](https://help.github.com/articles/using-pull-requests).
163
-
164
- To ensure a consistent code base, you should make sure the code follows the
165
- [Coding Standards](http://symfony.com/doc/2.0/contributing/code/standards.html)
166
- which we borrowed from Symfony.
167
-
168
- If you would like to help, please take a look at the list of
169
- [issues](https://github.com/composer/installers/issues).
170
-
171
- ### Should we allow dynamic package types or paths? No.
172
- What are they? The ability for a package author to determine where a package
173
- will be installed either through setting the path directly in their
174
- `composer.json` or through a dynamic package type: `"type":
175
- "framework-install-here"`.
176
-
177
- It has been proposed many times. Even implemented once early on and then
178
- removed. `installers` won't do this because it would allow a single package
179
- author to wipe out entire folders without the user's consent. That user would
180
- then come here to yell at us.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/composer/installers/composer.json DELETED
@@ -1,70 +0,0 @@
1
- {
2
- "name": "composer/installers",
3
- "type": "composer-installer",
4
- "license": "MIT",
5
- "description": "A multi-framework Composer library installer",
6
- "keywords": [
7
- "installer",
8
- "AGL",
9
- "AnnotateCms",
10
- "Bitrix",
11
- "CakePHP",
12
- "CodeIgniter",
13
- "concrete5",
14
- "Craft",
15
- "Croogo",
16
- "Dolibarr",
17
- "Drupal",
18
- "Elgg",
19
- "FuelPHP",
20
- "Hurad",
21
- "Joomla",
22
- "Kohana",
23
- "Laravel",
24
- "Lithium",
25
- "Magento",
26
- "Mako",
27
- "MODX Evo",
28
- "MediaWiki",
29
- "OXID",
30
- "MODULEWork",
31
- "Moodle",
32
- "Piwik",
33
- "phpBB",
34
- "PPI",
35
- "Roundcube",
36
- "shopware",
37
- "SilverStripe",
38
- "symfony",
39
- "TYPO3",
40
- "WolfCMS",
41
- "WordPress",
42
- "Zend",
43
- "Zikula"
44
- ],
45
- "homepage": "http://composer.github.com/installers/",
46
- "authors": [
47
- {
48
- "name": "Kyle Robinson Young",
49
- "email": "kyle@dontkry.com",
50
- "homepage": "https://github.com/shama"
51
- }
52
- ],
53
- "autoload": {
54
- "psr-0": { "Composer\\Installers\\": "src/" }
55
- },
56
- "extra": {
57
- "class": "Composer\\Installers\\Installer",
58
- "branch-alias": {
59
- "dev-master": "1.0-dev"
60
- }
61
- },
62
- "replace": {
63
- "shama/baton": "*",
64
- "roundcube/plugin-installer": "*"
65
- },
66
- "require-dev": {
67
- "composer/composer": "1.0.*@dev",
68
- "phpunit/phpunit": "4.1.*"
69
- }
70
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/composer/installers/phpunit.xml.dist DELETED
@@ -1,25 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
-
3
- <phpunit backupGlobals="false"
4
- backupStaticAttributes="false"
5
- colors="true"
6
- convertErrorsToExceptions="true"
7
- convertNoticesToExceptions="true"
8
- convertWarningsToExceptions="true"
9
- processIsolation="false"
10
- stopOnFailure="false"
11
- syntaxCheck="false"
12
- bootstrap="tests/bootstrap.php"
13
- >
14
- <testsuites>
15
- <testsuite name="Installers Test Suite">
16
- <directory>tests/Composer/Installers</directory>
17
- </testsuite>
18
- </testsuites>
19
-
20
- <filter>
21
- <whitelist>
22
- <directory>src/Composer/Installers</directory>
23
- </whitelist>
24
- </filter>
25
- </phpunit>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/composer/installers/src/Composer/Installers/AglInstaller.php DELETED
@@ -1,21 +0,0 @@
1
- <?php
2
- namespace Composer\Installers;
3
-
4
- class AglInstaller extends BaseInstaller
5
- {
6
- protected $locations = array(
7
- 'module' => 'More/{$name}/',
8
- );
9
-
10
- /**
11
- * Format package name to CamelCase
12
- */
13
- public function inflectPackageVars($vars)
14
- {
15
- $vars['name'] = preg_replace_callback('/(?:^|_|-)(.?)/', function ($matches) {
16
- return strtoupper($matches[1]);
17
- }, $vars['name']);
18
-
19
- return $vars;
20
- }
21
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/composer/installers/src/Composer/Installers/AnnotateCmsInstaller.php DELETED
@@ -1,11 +0,0 @@
1
- <?php
2
- namespace Composer\Installers;
3
-
4
- class AnnotateCmsInstaller extends BaseInstaller
5
- {
6
- protected $locations = array(
7
- 'module' => 'addons/modules/{$name}/',
8
- 'component' => 'addons/components/{$name}/',
9
- 'service' => 'addons/services/{$name}/',
10
- );
11
- }
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/composer/installers/src/Composer/Installers/BaseInstaller.php DELETED
@@ -1,131 +0,0 @@
1
- <?php
2
- namespace Composer\Installers;
3
-
4
- use Composer\Composer;
5
- use Composer\Package\PackageInterface;
6
-
7
- abstract class BaseInstaller
8
- {
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
- /**
26
- * Return the install path based on package type.
27
- *
28
- * @param PackageInterface $package
29
- * @param string $frameworkType
30
- * @return string
31
- */
32
- public function getInstallPath(PackageInterface $package, $frameworkType = '')
33
- {
34
- $type = $this->package->getType();
35
-
36
- $prettyName = $this->package->getPrettyName();
37
- if (strpos($prettyName, '/') !== false) {
38
- list($vendor, $name) = explode('/', $prettyName);
39
- } else {
40
- $vendor = '';
41
- $name = $prettyName;
42
- }
43
-
44
- $availableVars = $this->inflectPackageVars(compact('name', 'vendor', 'type'));
45
-
46
- $extra = $package->getExtra();
47
- if (!empty($extra['installer-name'])) {
48
- $availableVars['name'] = $extra['installer-name'];
49
- }
50
-
51
- if ($this->composer->getPackage()) {
52
- $extra = $this->composer->getPackage()->getExtra();
53
- if (!empty($extra['installer-paths'])) {
54
- $customPath = $this->mapCustomInstallPaths($extra['installer-paths'], $prettyName, $type);
55
- if ($customPath !== false) {
56
- return $this->templatePath($customPath, $availableVars);
57
- }
58
- }
59
- }
60
-
61
- $packageType = substr($type, strlen($frameworkType) + 1);
62
- $locations = $this->getLocations();
63
- if (!isset($locations[$packageType])) {
64
- throw new \InvalidArgumentException(sprintf('Package type "%s" is not supported', $type));
65
- }
66
-
67
- return $this->templatePath($locations[$packageType], $availableVars);
68
- }
69
-
70
- /**
71
- * For an installer to override to modify the vars per installer.
72
- *
73
- * @param array $vars
74
- * @return array
75
- */
76
- public function inflectPackageVars($vars)
77
- {
78
- return $vars;
79
- }
80
-
81
- /**
82
- * Gets the installer's locations
83
- *
84
- * @return array
85
- */
86
- public function getLocations()
87
- {
88
- return $this->locations;
89
- }
90
-
91
- /**
92
- * Replace vars in a path
93
- *
94
- * @param string $path
95
- * @param array $vars
96
- * @return string
97
- */
98
- protected function templatePath($path, array $vars = array())
99
- {
100
- if (strpos($path, '{') !== false) {
101
- extract($vars);
102
- preg_match_all('@\{\$([A-Za-z0-9_]*)\}@i', $path, $matches);
103
- if (!empty($matches[1])) {
104
- foreach ($matches[1] as $var) {
105
- $path = str_replace('{$' . $var . '}', $$var, $path);
106
- }
107
- }
108
- }
109
-
110
- return $path;
111
- }
112
-
113
- /**
114
- * Search through a passed paths array for a custom install path.
115
- *
116
- * @param array $paths
117
- * @param string $name
118
- * @param string $type
119
- * @return string
120
- */
121
- protected function mapCustomInstallPaths(array $paths, $name, $type)
122
- {
123
- foreach ($paths as $path => $names) {
124
- if (in_array($name, $names) || in_array('type:' . $type, $names)) {
125
- return $path;
126
- }
127
- }
128
-
129
- return false;
130
- }
131
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/composer/installers/src/Composer/Installers/BitrixInstaller.php DELETED
@@ -1,10 +0,0 @@
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
- );
10
- }
 
 
 
 
 
 
 
 
 
 
vendor/vendor/composer/installers/src/Composer/Installers/CakePHPInstaller.php DELETED
@@ -1,58 +0,0 @@
1
- <?php
2
- 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
- {
11
- protected $locations = array(
12
- 'plugin' => 'Plugin/{$name}/',
13
- );
14
-
15
- /**
16
- * Format package name to CamelCase
17
- */
18
- public function inflectPackageVars($vars)
19
- {
20
- $nameParts = explode('/', $vars['name']);
21
- foreach ($nameParts as &$value) {
22
- $value = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $value));
23
- $value = str_replace(array('-', '_'), ' ', $value);
24
- $value = str_replace(' ', '', ucwords($value));
25
- }
26
- $vars['name'] = implode('/', $nameParts);
27
-
28
- return $vars;
29
- }
30
-
31
- /**
32
- * Change the default plugin location when cakephp >= 3.0
33
- */
34
- public function getLocations() {
35
- $repositoryManager = $this->composer->getRepositoryManager();
36
- if ($repositoryManager) {
37
- $repos = $repositoryManager->getLocalRepository();
38
- if (!$repos) {
39
- return $this->locations;
40
- }
41
- $cake3 = new MultiConstraint(array(
42
- new VersionConstraint('>=', '3.0.0'),
43
- new VersionConstraint('!=', '9999999-dev'),
44
- ));
45
- $pool = new Pool('dev');
46
- $pool->addRepository($repos);
47
- $packages = $pool->whatProvides('cakephp/cakephp');
48
- foreach ($packages as $package) {
49
- $installed = new VersionConstraint('=', $package->getVersion());
50
- if ($cake3->matches($installed)) {
51
- $this->locations['plugin'] = 'plugins/{$name}/';
52
- break;
53
- }
54
- }
55
- }
56
- return $this->locations;
57
- }
58
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/composer/installers/src/Composer/Installers/CodeIgniterInstaller.php DELETED
@@ -1,11 +0,0 @@
1
- <?php
2
- namespace Composer\Installers;
3
-
4
- class CodeIgniterInstaller extends BaseInstaller
5
- {
6
- protected $locations = array(
7
- 'library' => 'application/libraries/{$name}/',
8
- 'third-party' => 'application/third_party/{$name}/',
9
- 'module' => 'application/modules/{$name}/',
10
- );
11
- }
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/composer/installers/src/Composer/Installers/Concrete5Installer.php DELETED
@@ -1,12 +0,0 @@
1
- <?php
2
- namespace Composer\Installers;
3
-
4
- class Concrete5Installer extends BaseInstaller
5
- {
6
- protected $locations = array(
7
- 'block' => 'blocks/{$name}/',
8
- 'package' => 'packages/{$name}/',
9
- 'theme' => 'themes/{$name}/',
10
- 'update' => 'updates/{$name}/',
11
- );
12
- }
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/composer/installers/src/Composer/Installers/CraftInstaller.php DELETED
@@ -1,9 +0,0 @@
1
- <?php
2
- namespace Composer\Installers;
3
-
4
- class CraftInstaller extends BaseInstaller
5
- {
6
- protected $locations = array(
7
- 'plugin' => 'craft/plugins/{$name}/',
8
- );
9
- }
 
 
 
 
 
 
 
 
 
vendor/vendor/composer/installers/src/Composer/Installers/CroogoInstaller.php DELETED
@@ -1,21 +0,0 @@
1
- <?php
2
- namespace Composer\Installers;
3
-
4
- class CroogoInstaller extends BaseInstaller
5
- {
6
- protected $locations = array(
7
- 'plugin' => 'Plugin/{$name}/',
8
- 'theme' => 'View/Themed/{$name}/',
9
- );
10
-
11
- /**
12
- * Format package name to CamelCase
13
- */
14
- public function inflectPackageVars($vars)
15
- {
16
- $vars['name'] = strtolower(str_replace(array('-', '_'), ' ', $vars['name']));
17
- $vars['name'] = str_replace(' ', '', ucwords($vars['name']));
18
-
19
- return $vars;
20
- }
21
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/composer/installers/src/Composer/Installers/DolibarrInstaller.php DELETED
@@ -1,16 +0,0 @@
1
- <?php
2
- namespace Composer\Installers;
3
-
4
- /**
5
- * Class DolibarrInstaller
6
- *
7
- * @package Composer\Installers
8
- * @author Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
9
- */
10
- class DolibarrInstaller extends BaseInstaller
11
- {
12
- //TODO: Add support for scripts and themes
13
- protected $locations = array(
14
- 'module' => 'htdocs/custom/{$name}/',
15
- );
16
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/composer/installers/src/Composer/Installers/DrupalInstaller.php DELETED
@@ -1,13 +0,0 @@
1
- <?php
2
- namespace Composer\Installers;
3
-
4
- class DrupalInstaller extends BaseInstaller
5
- {
6
- protected $locations = array(
7
- 'module' => 'modules/{$name}/',
8
- 'theme' => 'themes/{$name}/',
9
- 'library' => 'libraries/{$name}/',
10
- 'profile' => 'profiles/{$name}/',
11
- 'drush' => 'drush/{$name}/',
12
- );
13
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/composer/installers/src/Composer/Installers/ElggInstaller.php DELETED
@@ -1,9 +0,0 @@
1
- <?php
2
- namespace Composer\Installers;
3
-
4
- class ElggInstaller extends BaseInstaller
5
- {
6
- protected $locations = array(
7
- 'plugin' => 'mod/{$name}/',
8
- );
9
- }
 
 
 
 
 
 
 
 
 
vendor/vendor/composer/installers/src/Composer/Installers/FuelInstaller.php DELETED
@@ -1,11 +0,0 @@
1
- <?php
2
- namespace Composer\Installers;
3
-
4
- class FuelInstaller extends BaseInstaller
5
- {
6
- protected $locations = array(
7
- 'module' => 'fuel/app/modules/{$name}/',
8
- 'package' => 'fuel/packages/{$name}/',
9
- 'theme' => 'fuel/themes/{$name}/',
10
- );
11
- }
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/composer/installers/src/Composer/Installers/HuradInstaller.php DELETED
@@ -1,21 +0,0 @@
1
- <?php
2
- namespace Composer\Installers;
3
-
4
- class HuradInstaller extends BaseInstaller
5
- {
6
- protected $locations = array(
7
- 'plugin' => 'Plugin/{$name}/',
8
- 'theme' => 'View/Themed/{$name}/',
9
- );
10
-
11
- /**
12
- * Format package name to CamelCase
13
- */
14
- public function inflectPackageVars($vars)
15
- {
16
- $vars['name'] = strtolower(str_replace(array('-', '_'), ' ', $vars['name']));
17
- $vars['name'] = str_replace(' ', '', ucwords($vars['name']));
18
-
19
- return $vars;
20
- }
21
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/composer/installers/src/Composer/Installers/Installer.php DELETED
@@ -1,149 +0,0 @@
1
- <?php
2
- namespace Composer\Installers;
3
-
4
- use Composer\Installer\LibraryInstaller;
5
- use Composer\Package\PackageInterface;
6
- use Composer\Repository\InstalledRepositoryInterface;
7
-
8
- class Installer extends LibraryInstaller
9
- {
10
- /**
11
- * Package types to installer class map
12
- *
13
- * @var array
14
- */
15
- private $supportedTypes = array(
16
- 'agl' => 'AglInstaller',
17
- 'annotatecms' => 'AnnotateCmsInstaller',
18
- 'bitrix' => 'BitrixInstaller',
19
- 'cakephp' => 'CakePHPInstaller',
20
- 'codeigniter' => 'CodeIgniterInstaller',
21
- 'concrete5' => 'Concrete5Installer',
22
- 'craft' => 'CraftInstaller',
23
- 'croogo' => 'CroogoInstaller',
24
- 'drupal' => 'DrupalInstaller',
25
- 'dolibarr' => 'DolibarrInstaller',
26
- 'elgg' => 'ElggInstaller',
27
- 'piwik' => 'PiwikInstaller',
28
- 'fuel' => 'FuelInstaller',
29
- 'hurad' => 'HuradInstaller',
30
- 'joomla' => 'JoomlaInstaller',
31
- 'kirby' => 'KirbyInstaller',
32
- 'kohana' => 'KohanaInstaller',
33
- 'laravel' => 'LaravelInstaller',
34
- 'lithium' => 'LithiumInstaller',
35
- 'magento' => 'MagentoInstaller',
36
- 'mako' => 'MakoInstaller',
37
- 'modxevo' => 'MODXEvoInstaller',
38
- 'mediawiki' => 'MediaWikiInstaller',
39
- 'microweber' => 'MicroweberInstaller',
40
- 'modulework' => 'MODULEWorkInstaller',
41
- 'moodle' => 'MoodleInstaller',
42
- 'october' => 'OctoberInstaller',
43
- 'oxid' => 'OxidInstaller',
44
- 'phpbb' => 'PhpBBInstaller',
45
- 'piwik' => 'PiwikInstaller',
46
- 'pimcore' => 'PimcoreInstaller',
47
- 'ppi' => 'PPIInstaller',
48
- 'roundcube' => 'RoundcubeInstaller',
49
- 'shopware' => 'ShopwareInstaller',
50
- 'silverstripe' => 'SilverStripeInstaller',
51
- 'symfony1' => 'Symfony1Installer',
52
- 'wolfcms' => 'WolfCMSInstaller',
53
- 'wordpress' => 'WordPressInstaller',
54
- 'zend' => 'ZendInstaller',
55
- 'zikula' => 'ZikulaInstaller',
56
- 'typo3-flow' => 'TYPO3FlowInstaller',
57
- 'typo3-cms' => 'TYPO3CmsInstaller',
58
- 'tusk' => 'TuskInstaller',
59
- );
60
-
61
- /**
62
- * {@inheritDoc}
63
- */
64
- public function getInstallPath(PackageInterface $package)
65
- {
66
- $type = $package->getType();
67
- $frameworkType = $this->findFrameworkType($type);
68
-
69
- if ($frameworkType === false) {
70
- throw new \InvalidArgumentException(
71
- 'Sorry the package type of this package is not yet supported.'
72
- );
73
- }
74
-
75
- $class = 'Composer\\Installers\\' . $this->supportedTypes[$frameworkType];
76
- $installer = new $class($package, $this->composer);
77
-
78
- return $installer->getInstallPath($package, $frameworkType);
79
- }
80
-
81
- public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)
82
- {
83
- if (!$repo->hasPackage($package)) {
84
- throw new \InvalidArgumentException('Package is not installed: '.$package);
85
- }
86
-
87
- $repo->removePackage($package);
88
-
89
- $installPath = $this->getInstallPath($package);
90
- $this->io->write(sprintf('Deleting %s - %s', $installPath, $this->filesystem->removeDirectory($installPath) ? '<comment>deleted</comment>' : '<error>not deleted</error>'));
91
- }
92
-
93
- /**
94
- * {@inheritDoc}
95
- */
96
- public function supports($packageType)
97
- {
98
- $frameworkType = $this->findFrameworkType($packageType);
99
-
100
- if ($frameworkType === false) {
101
- return false;
102
- }
103
-
104
- $locationPattern = $this->getLocationPattern($frameworkType);
105
-
106
- return preg_match('#' . $frameworkType . '-' . $locationPattern . '#', $packageType, $matches) === 1;
107
- }
108
-
109
- /**
110
- * Finds a supported framework type if it exists and returns it
111
- *
112
- * @param string $type
113
- * @return string
114
- */
115
- protected function findFrameworkType($type)
116
- {
117
- $frameworkType = false;
118
-
119
- foreach ($this->supportedTypes as $key => $val) {
120
- if ($key === substr($type, 0, strlen($key))) {
121
- $frameworkType = substr($type, 0, strlen($key));
122
- break;
123
- }
124
- }
125
-
126
- return $frameworkType;
127
- }
128
-
129
- /**
130
- * Get the second part of the regular expression to check for support of a
131
- * package type
132
- *
133
- * @param string $frameworkType
134
- * @return string
135
- */
136
- protected function getLocationPattern($frameworkType)
137
- {
138
- $pattern = false;
139
- if (!empty($this->supportedTypes[$frameworkType])) {
140
- $frameworkClass = 'Composer\\Installers\\' . $this->supportedTypes[$frameworkType];
141
- /** @var BaseInstaller $framework */
142
- $framework = new $frameworkClass(null, $this->composer);
143
- $locations = array_keys($framework->getLocations());
144
- $pattern = $locations ? '(' . implode('|', $locations) . ')' : false;
145
- }
146
-
147
- return $pattern ? : '(\w+)';
148
- }
149
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/composer/installers/src/Composer/Installers/JoomlaInstaller.php DELETED
@@ -1,15 +0,0 @@
1
- <?php
2
- namespace Composer\Installers;
3
-
4
- class JoomlaInstaller extends BaseInstaller
5
- {
6
- protected $locations = array(
7
- 'component' => 'components/{$name}/',
8
- 'module' => 'modules/{$name}/',
9
- 'template' => 'templates/{$name}/',
10
- 'plugin' => 'plugins/{$name}/',
11
- 'library' => 'libraries/{$name}/',
12
- );
13
-
14
- // TODO: Add inflector for mod_ and com_ names
15
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/composer/installers/src/Composer/Installers/KirbyInstaller.php DELETED
@@ -1,9 +0,0 @@
1
- <?php
2
- namespace Composer\Installers;
3
-
4
- class KirbyInstaller extends BaseInstaller
5
- {
6
- protected $locations = array(
7
- 'plugin' => 'site/plugins/{$name}/',
8
- );
9
- }
 
 
 
 
 
 
 
 
 
vendor/vendor/composer/installers/src/Composer/Installers/KohanaInstaller.php DELETED
@@ -1,9 +0,0 @@
1
- <?php
2
- namespace Composer\Installers;
3
-
4
- class KohanaInstaller extends BaseInstaller
5
- {
6
- protected $locations = array(
7
- 'module' => 'modules/{$name}/',
8
- );
9
- }
 
 
 
 
 
 
 
 
 
vendor/vendor/composer/installers/src/Composer/Installers/LaravelInstaller.php DELETED
@@ -1,9 +0,0 @@
1
- <?php
2
- namespace Composer\Installers;
3
-
4
- class LaravelInstaller extends BaseInstaller
5
- {
6
- protected $locations = array(
7
- 'library' => 'libraries/{$name}/',
8
- );
9
- }
 
 
 
 
 
 
 
 
 
vendor/vendor/composer/installers/src/Composer/Installers/LithiumInstaller.php DELETED
@@ -1,10 +0,0 @@
1
- <?php
2
- namespace Composer\Installers;
3
-
4
- class LithiumInstaller extends BaseInstaller
5
- {
6
- protected $locations = array(
7
- 'library' => 'libraries/{$name}/',
8
- 'source' => 'libraries/_source/{$name}/',
9
- );
10
- }
 
 
 
 
 
 
 
 
 
 
vendor/vendor/composer/installers/src/Composer/Installers/MODULEWorkInstaller.php DELETED
@@ -1,9 +0,0 @@
1
- <?php
2
- namespace Composer\Installers;
3
-
4
- class MODULEWorkInstaller extends BaseInstaller
5
- {
6
- protected $locations = array(
7
- 'module' => 'modules/{$name}/',
8
- );
9
- }
 
 
 
 
 
 
 
 
 
vendor/vendor/composer/installers/src/Composer/Installers/MODXEvoInstaller.php DELETED
@@ -1,16 +0,0 @@
1
- <?php
2
- namespace Composer\Installers;
3
-
4
- /**
5
- * An installer to handle MODX Evolution specifics when installing packages.
6
- */
7
- class MODXEvoInstaller extends BaseInstaller
8
- {
9
- protected $locations = array(
10
- 'snippet' => 'assets/snippets/{$name}/',
11
- 'plugin' => 'assets/plugins/{$name}/',
12
- 'module' => 'assets/modules/{$name}/',
13
- 'template' => 'assets/templates/{$name}/',
14
- 'lib' => 'assets/lib/{$name}/'
15
- );
16
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/composer/installers/src/Composer/Installers/MagentoInstaller.php DELETED
@@ -1,11 +0,0 @@
1
- <?php
2
- namespace Composer\Installers;
3
-
4
- class MagentoInstaller extends BaseInstaller
5
- {
6
- protected $locations = array(
7
- 'theme' => 'app/design/frontend/{$name}/',
8
- 'skin' => 'skin/frontend/default/{$name}/',
9
- 'library' => 'lib/{$name}/',
10
- );
11
- }
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/composer/installers/src/Composer/Installers/MakoInstaller.php DELETED
@@ -1,9 +0,0 @@
1
- <?php
2
- namespace Composer\Installers;
3
-
4
- class MakoInstaller extends BaseInstaller
5
- {
6
- protected $locations = array(
7
- 'package' => 'app/packages/{$name}/',
8
- );
9
- }
 
 
 
 
 
 
 
 
 
vendor/vendor/composer/installers/src/Composer/Installers/MediaWikiInstaller.php DELETED
@@ -1,50 +0,0 @@
1
- <?php
2
- namespace Composer\Installers;
3
-
4
- class MediaWikiInstaller extends BaseInstaller
5
- {
6
- protected $locations = array(
7
- 'extension' => 'extensions/{$name}/',
8
- 'skin' => 'skins/{$name}/',
9
- );
10
-
11
- /**
12
- * Format package name.
13
- *
14
- * For package type mediawiki-extension, cut off a trailing '-extension' if present and transform
15
- * to CamelCase keeping existing uppercase chars.
16
- *
17
- * For package type mediawiki-skin, cut off a trailing '-skin' if present.
18
- *
19
- */
20
- public function inflectPackageVars($vars)
21
- {
22
-
23
- if ($vars['type'] === 'mediawiki-extension') {
24
- return $this->inflectExtensionVars($vars);
25
- }
26
-
27
- if ($vars['type'] === 'mediawiki-skin') {
28
- return $this->inflectSkinVars($vars);
29
- }
30
-
31
- return $vars;
32
- }
33
-
34
- protected function inflectExtensionVars($vars)
35
- {
36
- $vars['name'] = preg_replace('/-extension$/', '', $vars['name']);
37
- $vars['name'] = str_replace('-', ' ', $vars['name']);
38
- $vars['name'] = str_replace(' ', '', ucwords($vars['name']));
39
-
40
- return $vars;
41
- }
42
-
43
- protected function inflectSkinVars($vars)
44
- {
45
- $vars['name'] = preg_replace('/-skin$/', '', $vars['name']);
46
-
47
- return $vars;
48
- }
49
-
50
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/composer/installers/src/Composer/Installers/MicroweberInstaller.php DELETED
@@ -1,111 +0,0 @@
1
- <?php
2
- namespace Composer\Installers;
3
-
4
- class MicroweberInstaller extends BaseInstaller
5
- {
6
- protected $locations = array(
7
- 'module' => 'userfiles/modules/{$name}/',
8
- 'module-skin' => 'userfiles/modules/{$name}/templates/',
9
- 'template' => 'userfiles/templates/{$name}/',
10
- 'element' => 'userfiles/elements/{$name}/',
11
- 'vendor' => 'vendor/{$name}/',
12
- 'components' => 'components/{$name}/'
13
- );
14
-
15
- /**
16
- * Format package name.
17
- *
18
- * For package type microweber-module, cut off a trailing '-module' if present
19
- *
20
- * For package type microweber-template, cut off a trailing '-template' if present.
21
- *
22
- */
23
- public function inflectPackageVars($vars)
24
- {
25
- if ($vars['type'] === 'microweber-template') {
26
- return $this->inflectTemplateVars($vars);
27
- }
28
- if ($vars['type'] === 'microweber-templates') {
29
- return $this->inflectTemplatesVars($vars);
30
- }
31
- if ($vars['type'] === 'microweber-core') {
32
- return $this->inflectCoreVars($vars);
33
- }
34
- if ($vars['type'] === 'microweber-adapter') {
35
- return $this->inflectCoreVars($vars);
36
- }
37
- if ($vars['type'] === 'microweber-module') {
38
- return $this->inflectModuleVars($vars);
39
- }
40
- if ($vars['type'] === 'microweber-modules') {
41
- return $this->inflectModulesVars($vars);
42
- }
43
- if ($vars['type'] === 'microweber-skin') {
44
- return $this->inflectSkinVars($vars);
45
- }
46
- if ($vars['type'] === 'microweber-element' or $vars['type'] === 'microweber-elements') {
47
- return $this->inflectElementVars($vars);
48
- }
49
-
50
- return $vars;
51
- }
52
-
53
- protected function inflectTemplateVars($vars)
54
- {
55
- $vars['name'] = preg_replace('/-template$/', '', $vars['name']);
56
- $vars['name'] = preg_replace('/template-$/', '', $vars['name']);
57
-
58
- return $vars;
59
- }
60
-
61
- protected function inflectTemplatesVars($vars)
62
- {
63
- $vars['name'] = preg_replace('/-templates$/', '', $vars['name']);
64
- $vars['name'] = preg_replace('/templates-$/', '', $vars['name']);
65
-
66
- return $vars;
67
- }
68
-
69
- protected function inflectCoreVars($vars)
70
- {
71
- $vars['name'] = preg_replace('/-providers$/', '', $vars['name']);
72
- $vars['name'] = preg_replace('/-provider$/', '', $vars['name']);
73
- $vars['name'] = preg_replace('/-adapter$/', '', $vars['name']);
74
-
75
- return $vars;
76
- }
77
-
78
- protected function inflectModuleVars($vars)
79
- {
80
- $vars['name'] = preg_replace('/-module$/', '', $vars['name']);
81
- $vars['name'] = preg_replace('/module-$/', '', $vars['name']);
82
-
83
- return $vars;
84
- }
85
-
86
- protected function inflectModulesVars($vars)
87
- {
88
- $vars['name'] = preg_replace('/-modules$/', '', $vars['name']);
89
- $vars['name'] = preg_replace('/modules-$/', '', $vars['name']);
90
-
91
- return $vars;
92
- }
93
-
94
- protected function inflectSkinVars($vars)
95
- {
96
- $vars['name'] = preg_replace('/-skin$/', '', $vars['name']);
97
- $vars['name'] = preg_replace('/skin-$/', '', $vars['name']);
98
-
99
- return $vars;
100
- }
101
-
102
- protected function inflectElementVars($vars)
103
- {
104
- $vars['name'] = preg_replace('/-elements$/', '', $vars['name']);
105
- $vars['name'] = preg_replace('/elements-$/', '', $vars['name']);
106
- $vars['name'] = preg_replace('/-element$/', '', $vars['name']);
107
- $vars['name'] = preg_replace('/element-$/', '', $vars['name']);
108
-
109
- return $vars;
110
- }
111
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/composer/installers/src/Composer/Installers/MoodleInstaller.php DELETED
@@ -1,47 +0,0 @@
1
- <?php
2
- namespace Composer\Installers;
3
-
4
- class MoodleInstaller extends BaseInstaller
5
- {
6
- protected $locations = array(
7
- 'mod' => 'mod/{$name}/',
8
- 'report' => 'admin/report/{$name}/',
9
- 'tool' => 'admin/tool/{$name}/',
10
- 'assignment' => 'mod/assignment/type/{$name}/',
11
- 'assignsubmission' => 'mod/assign/submission/{$name}/',
12
- 'assignfeedback' => 'mod/assign/feedback/{$name}/',
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}/',
19
- 'datafield' => 'mod/data/field/{$name}/',
20
- 'datapreset' => 'mod/data/preset/{$name}/',
21
- 'editor' => 'lib/editor/{$name}/',
22
- 'enrol' => 'enrol/{$name}/',
23
- 'filter' => 'filter/{$name}/',
24
- 'gradeexport' => 'grade/export/{$name}/',
25
- 'gradeimport' => 'grade/import/{$name}/',
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}/',
33
- 'qformat' => 'question/format/{$name}/',
34
- 'qtype' => 'question/type/{$name}/',
35
- 'quizaccess' => 'mod/quiz/accessrule/{$name}/',
36
- 'quiz' => 'mod/quiz/report/{$name}/',
37
- 'report' => 'report/{$name}/',
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}/',
44
- 'workshopeval' => 'mod/workshop/eval/{$name}/',
45
- 'workshopform' => 'mod/workshop/form/{$name}/'
46
- );
47
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/composer/installers/src/Composer/Installers/OctoberInstaller.php DELETED
@@ -1,10 +0,0 @@
1
- <?php
2
- namespace Composer\Installers;
3
-
4
- class OctoberInstaller extends BaseInstaller
5
- {
6
- protected $locations = array(
7
- 'module' => 'modules/{$name}/',
8
- 'plugin' => 'plugins/{$vendor}/{$name}/',
9
- );
10
- }
 
 
 
 
 
 
 
 
 
 
vendor/vendor/composer/installers/src/Composer/Installers/OxidInstaller.php DELETED
@@ -1,11 +0,0 @@
1
- <?php
2
- namespace Composer\Installers;
3
-
4
- class OxidInstaller extends BaseInstaller
5
- {
6
- protected $locations = array(
7
- 'module' => 'modules/{$name}/',
8
- 'theme' => 'application/views/{$name}/',
9
- 'out' => 'out/{$name}/',
10
- );
11
- }
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/composer/installers/src/Composer/Installers/PhpBBInstaller.php DELETED
@@ -1,11 +0,0 @@
1
- <?php
2
- namespace Composer\Installers;
3
-
4
- class PhpBBInstaller extends BaseInstaller
5
- {
6
- protected $locations = array(
7
- 'extension' => 'ext/{$vendor}/{$name}/',
8
- 'language' => 'language/{$name}/',
9
- 'style' => 'styles/{$name}/',
10
- );
11
- }
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/composer/installers/src/Composer/Installers/PimcoreInstaller.php DELETED
@@ -1,21 +0,0 @@
1
- <?php
2
- namespace Composer\Installers;
3
-
4
- class PimcoreInstaller extends BaseInstaller
5
- {
6
- protected $locations = array(
7
- 'plugin' => 'plugins/{$name}/',
8
- );
9
-
10
- /**
11
- * Format package name to CamelCase
12
- */
13
- public function inflectPackageVars($vars)
14
- {
15
- $vars['name'] = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $vars['name']));
16
- $vars['name'] = str_replace(array('-', '_'), ' ', $vars['name']);
17
- $vars['name'] = str_replace(' ', '', ucwords($vars['name']));
18
-
19
- return $vars;
20
- }
21
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/composer/installers/src/Composer/Installers/PiwikInstaller.php DELETED
@@ -1,32 +0,0 @@
1
- <?php
2
- namespace Composer\Installers;
3
-
4
- /**
5
- * Class PiwikInstaller
6
- *
7
- * @package Composer\Installers
8
- */
9
- class PiwikInstaller extends BaseInstaller
10
- {
11
- /**
12
- * @var array
13
- */
14
- protected $locations = array(
15
- 'plugin' => 'plugins/{$name}/',
16
- );
17
-
18
- /**
19
- * Format package name to CamelCase
20
- * @param array $vars
21
- *
22
- * @return array
23
- */
24
- public function inflectPackageVars($vars)
25
- {
26
- $vars['name'] = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $vars['name']));
27
- $vars['name'] = str_replace(array('-', '_'), ' ', $vars['name']);
28
- $vars['name'] = str_replace(' ', '', ucwords($vars['name']));
29
-
30
- return $vars;
31
- }
32
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/composer/installers/src/Composer/Installers/RoundcubeInstaller.php DELETED
@@ -1,22 +0,0 @@
1
- <?php
2
- namespace Composer\Installers;
3
-
4
- class RoundcubeInstaller extends BaseInstaller
5
- {
6
- protected $locations = array(
7
- 'plugin' => 'plugins/{$name}/',
8
- );
9
-
10
- /**
11
- * Lowercase name and changes the name to a underscores
12
- *
13
- * @param array $vars
14
- * @return array
15
- */
16
- public function inflectPackageVars($vars)
17
- {
18
- $vars['name'] = strtolower(str_replace('-', '_', $vars['name']));
19
-
20
- return $vars;
21
- }
22
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/composer/installers/src/Composer/Installers/ShopwareInstaller.php DELETED
@@ -1,58 +0,0 @@
1
- <?php
2
- namespace Composer\Installers;
3
-
4
- /**
5
- * Plugin/theme installer for shopware
6
- * @author Benjamin Boit
7
- */
8
- class ShopwareInstaller extends BaseInstaller
9
- {
10
- protected $locations = array(
11
- 'backend-plugin' => 'engine/Shopware/Plugins/Local/Backend/{$name}/',
12
- 'core-plugin' => 'engine/Shopware/Plugins/Local/Core/{$name}/',
13
- 'frontend-plugin' => 'engine/Shopware/Plugins/Local/Frontend/{$name}/',
14
- 'theme' => 'templates/{$name}/'
15
- );
16
-
17
- /**
18
- * Transforms the names
19
- * @param array $vars
20
- * @return array
21
- */
22
- public function inflectPackageVars($vars)
23
- {
24
- if ($vars['type'] === 'shopware-theme') {
25
- return $this->correctThemeName($vars);
26
- } else {
27
- return $this->correctPluginName($vars);
28
- }
29
- }
30
-
31
- /**
32
- * Changes the name to a camelcased combination of vendor and name
33
- * @param array $vars
34
- * @return array
35
- */
36
- private function correctPluginName($vars)
37
- {
38
- $camelCasedName = preg_replace_callback('/(-[a-z])/', function ($matches) {
39
- return strtoupper($matches[0][1]);
40
- }, $vars['name']);
41
-
42
- $vars['name'] = ucfirst($vars['vendor']) . ucfirst($camelCasedName);
43
-
44
- return $vars;
45
- }
46
-
47
- /**
48
- * Changes the name to a underscore separated name
49
- * @param array $vars
50
- * @return array
51
- */
52
- private function correctThemeName($vars)
53
- {
54
- $vars['name'] = str_replace('-', '_', $vars['name']);
55
-
56
- return $vars;
57
- }
58
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/composer/installers/src/Composer/Installers/SilverStripeInstaller.php DELETED
@@ -1,36 +0,0 @@
1
- <?php
2
- namespace Composer\Installers;
3
-
4
- use Composer\Package\PackageInterface;
5
-
6
- class SilverStripeInstaller extends BaseInstaller
7
- {
8
- protected $locations = array(
9
- 'module' => '{$name}/',
10
- 'theme' => 'themes/{$name}/',
11
- );
12
-
13
- /**
14
- * Return the install path based on package type.
15
- *
16
- * Relies on built-in BaseInstaller behaviour with one exception: silverstripe/framework
17
- * must be installed to 'sapphire' and not 'framework' if the version is <3.0.0
18
- *
19
- * @param PackageInterface $package
20
- * @param string $frameworkType
21
- * @return string
22
- */
23
- public function getInstallPath(PackageInterface $package, $frameworkType = '')
24
- {
25
- if (
26
- $package->getName() == 'silverstripe/framework'
27
- && preg_match('/^\d+\.\d+\.\d+/', $package->getVersion())
28
- && version_compare($package->getVersion(), '2.999.999') < 0
29
- ) {
30
- return $this->templatePath($this->locations['module'], array('name' => 'sapphire'));
31
- } else {
32
- return parent::getInstallPath($package, $frameworkType);
33
- }
34
-
35
- }
36
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/composer/installers/src/Composer/Installers/Symfony1Installer.php DELETED
@@ -1,26 +0,0 @@
1
- <?php
2
- namespace Composer\Installers;
3
-
4
- /**
5
- * Plugin installer for symfony 1.x
6
- *
7
- * @author Jérôme Tamarelle <jerome@tamarelle.net>
8
- */
9
- class Symfony1Installer extends BaseInstaller
10
- {
11
- protected $locations = array(
12
- 'plugin' => 'plugins/{$name}/',
13
- );
14
-
15
- /**
16
- * Format package name to CamelCase
17
- */
18
- public function inflectPackageVars($vars)
19
- {
20
- $vars['name'] = preg_replace_callback('/(-[a-z])/', function ($matches) {
21
- return strtoupper($matches[0][1]);
22
- }, $vars['name']);
23
-
24
- return $vars;
25
- }
26
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/composer/installers/src/Composer/Installers/TYPO3CmsInstaller.php DELETED
@@ -1,14 +0,0 @@
1
- <?php
2
- namespace Composer\Installers;
3
-
4
- /**
5
- * Extension installer for TYPO3 CMS
6
- *
7
- * @author Sascha Egerer <sascha.egerer@dkd.de>
8
- */
9
- class TYPO3CmsInstaller extends BaseInstaller
10
- {
11
- protected $locations = array(
12
- 'extension' => 'typo3conf/ext/{$name}/',
13
- );
14
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/composer/installers/src/Composer/Installers/TYPO3FlowInstaller.php DELETED
@@ -1,38 +0,0 @@
1
- <?php
2
- namespace Composer\Installers;
3
-
4
- /**
5
- * An installer to handle TYPO3 Flow specifics when installing packages.
6
- */
7
- class TYPO3FlowInstaller extends BaseInstaller
8
- {
9
- protected $locations = array(
10
- 'package' => 'Packages/Application/{$name}/',
11
- 'framework' => 'Packages/Framework/{$name}/',
12
- 'plugin' => 'Packages/Plugins/{$name}/',
13
- 'site' => 'Packages/Sites/{$name}/',
14
- 'boilerplate' => 'Packages/Boilerplates/{$name}/',
15
- 'build' => 'Build/{$name}/',
16
- );
17
-
18
- /**
19
- * Modify the package name to be a TYPO3 Flow style key.
20
- *
21
- * @param array $vars
22
- * @return array
23
- */
24
- public function inflectPackageVars($vars)
25
- {
26
- $autoload = $this->package->getAutoload();
27
- if (isset($autoload['psr-0']) && is_array($autoload['psr-0'])) {
28
- $namespace = key($autoload['psr-0']);
29
- $vars['name'] = str_replace('\\', '.', $namespace);
30
- }
31
- if (isset($autoload['psr-4']) && is_array($autoload['psr-4'])) {
32
- $namespace = key($autoload['psr-4']);
33
- $vars['name'] = rtrim(str_replace('\\', '.', $namespace), '.');
34
- }
35
-
36
- return $vars;
37
- }
38
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/composer/installers/src/Composer/Installers/TuskInstaller.php DELETED
@@ -1,14 +0,0 @@
1
- <?php
2
- namespace Composer\Installers;
3
- /**
4
- * Composer installer for 3rd party Tusk utilities
5
- * @author Drew Ewing <drew@phenocode.com>
6
- */
7
- class TuskInstaller extends BaseInstaller
8
- {
9
- protected $locations = array(
10
- 'task' => '.tusk/tasks/{$name}/',
11
- 'command' => '.tusk/commands/{$name}/',
12
- 'asset' => 'assets/tusk/{$name}/',
13
- );
14
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/composer/installers/src/Composer/Installers/WolfCMSInstaller.php DELETED
@@ -1,9 +0,0 @@
1
- <?php
2
- namespace Composer\Installers;
3
-
4
- class WolfCMSInstaller extends BaseInstaller
5
- {
6
- protected $locations = array(
7
- 'plugin' => 'wolf/plugins/{$name}/',
8
- );
9
- }
 
 
 
 
 
 
 
 
 
vendor/vendor/composer/installers/src/Composer/Installers/WordPressInstaller.php DELETED
@@ -1,11 +0,0 @@
1
- <?php
2
- namespace Composer\Installers;
3
-
4
- class WordPressInstaller extends BaseInstaller
5
- {
6
- protected $locations = array(
7
- 'plugin' => 'wp-content/plugins/{$name}/',
8
- 'theme' => 'wp-content/themes/{$name}/',
9
- 'muplugin' => 'wp-content/mu-plugins/{$name}/',
10
- );
11
- }
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/composer/installers/src/Composer/Installers/ZendInstaller.php DELETED
@@ -1,11 +0,0 @@
1
- <?php
2
- namespace Composer\Installers;
3
-
4
- class ZendInstaller extends BaseInstaller
5
- {
6
- protected $locations = array(
7
- 'library' => 'library/{$name}/',
8
- 'extra' => 'extras/library/{$name}/',
9
- 'module' => 'module/{$name}/',
10
- );
11
- }
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/composer/installers/src/Composer/Installers/ZikulaInstaller.php DELETED
@@ -1,10 +0,0 @@
1
- <?php
2
- namespace Composer\Installers;
3
-
4
- class ZikulaInstaller extends BaseInstaller
5
- {
6
- protected $locations = array(
7
- 'module' => 'modules/{$vendor}-{$name}/',
8
- 'theme' => 'themes/{$vendor}-{$name}/'
9
- );
10
- }
 
 
 
 
 
 
 
 
 
 
vendor/vendor/composer/installers/src/bootstrap.php DELETED
@@ -1,13 +0,0 @@
1
- <?php
2
- function includeIfExists($file)
3
- {
4
- if (file_exists($file)) {
5
- return include $file;
6
- }
7
- }
8
- if ((!$loader = includeIfExists(__DIR__ . '/../vendor/autoload.php')) && (!$loader = includeIfExists(__DIR__ . '/../../../autoload.php'))) {
9
- die('You must set up the project dependencies, run the following commands:'.PHP_EOL.
10
- 'curl -s http://getcomposer.org/installer | php'.PHP_EOL.
11
- 'php composer.phar install'.PHP_EOL);
12
- }
13
- return $loader;
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/composer/installers/tests/Composer/Installers/Test/CakePHPInstallerTest.php DELETED
@@ -1,113 +0,0 @@
1
- <?php
2
- namespace Composer\Installers\Test;
3
-
4
- use Composer\Installers\CakePHPInstaller;
5
- use Composer\Repository\RepositoryManager;
6
- use Composer\Repository\InstalledArrayRepository;
7
- use Composer\Package\Package;
8
- use Composer\Package\RootPackage;
9
- use Composer\Package\Link;
10
- use Composer\Package\Version\VersionParser;
11
- use Composer\Composer;
12
-
13
- class CakePHPInstallerTest extends TestCase
14
- {
15
- private $composer;
16
- private $io;
17
-
18
- /**
19
- * setUp
20
- *
21
- * @return void
22
- */
23
- public function setUp()
24
- {
25
- $this->package = new Package('CamelCased', '1.0', '1.0');
26
- $this->io = $this->getMock('Composer\IO\PackageInterface');
27
- $this->composer = new Composer();
28
- }
29
-
30
- /**
31
- * testInflectPackageVars
32
- *
33
- * @return void
34
- */
35
- public function testInflectPackageVars()
36
- {
37
- $installer = new CakePHPInstaller($this->package, $this->composer);
38
- $result = $installer->inflectPackageVars(array('name' => 'CamelCased'));
39
- $this->assertEquals($result, array('name' => 'CamelCased'));
40
-
41
- $installer = new CakePHPInstaller($this->package, $this->composer);
42
- $result = $installer->inflectPackageVars(array('name' => 'with-dash'));
43
- $this->assertEquals($result, array('name' => 'WithDash'));
44
-
45
- $installer = new CakePHPInstaller($this->package, $this->composer);
46
- $result = $installer->inflectPackageVars(array('name' => 'with_underscore'));
47
- $this->assertEquals($result, array('name' => 'WithUnderscore'));
48
-
49
- $installer = new CakePHPInstaller($this->package, $this->composer);
50
- $result = $installer->inflectPackageVars(array('name' => 'cake/acl'));
51
- $this->assertEquals($result, array('name' => 'Cake/Acl'));
52
-
53
- $installer = new CakePHPInstaller($this->package, $this->composer);
54
- $result = $installer->inflectPackageVars(array('name' => 'cake/debug-kit'));
55
- $this->assertEquals($result, array('name' => 'Cake/DebugKit'));
56
- }
57
-
58
- /**
59
- * Test getLocations returning appropriate values based on CakePHP version
60
- *
61
- */
62
- public function testGetLocations() {
63
- $package = new RootPackage('CamelCased', '1.0', '1.0');
64
- $composer = new Composer();
65
- $rm = new RepositoryManager(
66
- $this->getMock('Composer\IO\IOInterface'),
67
- $this->getMock('Composer\Config')
68
- );
69
- $composer->setRepositoryManager($rm);
70
- $installer = new CakePHPInstaller($package, $composer);
71
-
72
- // 2.0 < cakephp < 3.0
73
- $this->setCakephpVersion($rm, '2.0.0');
74
- $result = $installer->getLocations();
75
- $this->assertContains('Plugin/', $result['plugin']);
76
-
77
- $this->setCakephpVersion($rm, '2.5.9');
78
- $result = $installer->getLocations();
79
- $this->assertContains('Plugin/', $result['plugin']);
80
-
81
- $this->setCakephpVersion($rm, '~2.5');
82
- $result = $installer->getLocations();
83
- $this->assertContains('Plugin/', $result['plugin']);
84
-
85
- // special handling for 2.x versions when 3.x is still in development
86
- $this->setCakephpVersion($rm, 'dev-master');
87
- $result = $installer->getLocations();
88
- $this->assertContains('Plugin/', $result['plugin']);
89
-
90
- $this->setCakephpVersion($rm, '>=2.5');
91
- $result = $installer->getLocations();
92
- $this->assertContains('Plugin/', $result['plugin']);
93
-
94
- // cakephp >= 3.0
95
- $this->setCakephpVersion($rm, '3.0.*-dev');
96
- $result = $installer->getLocations();
97
- $this->assertContains('plugins/', $result['plugin']);
98
-
99
- $this->setCakephpVersion($rm, '~8.8');
100
- $result = $installer->getLocations();
101
- $this->assertContains('plugins/', $result['plugin']);
102
- }
103
-
104
- protected function setCakephpVersion($rm, $version) {
105
- $parser = new VersionParser();
106
- list(, $version) = explode(' ', $parser->parseConstraints($version));
107
- $installed = new InstalledArrayRepository();
108
- $package = new Package('cakephp/cakephp', $version, $version);
109
- $installed->addPackage($package);
110
- $rm->setLocalRepository($installed);
111
- }
112
-
113
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/composer/installers/tests/Composer/Installers/Test/InstallerTest.php DELETED
@@ -1,381 +0,0 @@
1
- <?php
2
- namespace Composer\Installers\Test;
3
-
4
- use Composer\Installers\Installer;
5
- use Composer\Util\Filesystem;
6
- use Composer\Package\Package;
7
- use Composer\Package\RootPackage;
8
- use Composer\Composer;
9
- use Composer\Config;
10
-
11
- class InstallerTest extends TestCase
12
- {
13
- private $composer;
14
- private $config;
15
- private $vendorDir;
16
- private $binDir;
17
- private $dm;
18
- private $repository;
19
- private $io;
20
- private $fs;
21
-
22
- /**
23
- * setUp
24
- *
25
- * @return void
26
- */
27
- public function setUp()
28
- {
29
- $this->fs = new Filesystem;
30
-
31
- $this->composer = new Composer();
32
- $this->config = new Config();
33
- $this->composer->setConfig($this->config);
34
-
35
- $this->vendorDir = realpath(sys_get_temp_dir()) . DIRECTORY_SEPARATOR . 'baton-test-vendor';
36
- $this->ensureDirectoryExistsAndClear($this->vendorDir);
37
-
38
- $this->binDir = realpath(sys_get_temp_dir()) . DIRECTORY_SEPARATOR . 'baton-test-bin';
39
- $this->ensureDirectoryExistsAndClear($this->binDir);
40
-
41
- $this->config->merge(array(
42
- 'config' => array(
43
- 'vendor-dir' => $this->vendorDir,
44
- 'bin-dir' => $this->binDir,
45
- ),
46
- ));
47
-
48
- $this->dm = $this->getMockBuilder('Composer\Downloader\DownloadManager')
49
- ->disableOriginalConstructor()
50
- ->getMock();
51
- $this->composer->setDownloadManager($this->dm);
52
-
53
- $this->repository = $this->getMock('Composer\Repository\InstalledRepositoryInterface');
54
- $this->io = $this->getMock('Composer\IO\IOInterface');
55
- }
56
-
57
- /**
58
- * tearDown
59
- *
60
- * @return void
61
- */
62
- public function tearDown()
63
- {
64
- $this->fs->removeDirectory($this->vendorDir);
65
- $this->fs->removeDirectory($this->binDir);
66
- }
67
-
68
- /**
69
- * testSupports
70
- *
71
- * @return void
72
- *
73
- * @dataProvider dataForTestSupport
74
- */
75
- public function testSupports($type, $expected)
76
- {
77
- $installer = new Installer($this->io, $this->composer);
78
- $this->assertSame($expected, $installer->supports($type), sprintf('Failed to show support for %s', $type));
79
- }
80
-
81
- /**
82
- * dataForTestSupport
83
- */
84
- public function dataForTestSupport()
85
- {
86
- return array(
87
- array('agl-module', true),
88
- array('annotatecms-module', true),
89
- array('annotatecms-component', true),
90
- array('annotatecms-service', true),
91
- array('bitrix-module', true),
92
- array('bitrix-component', true),
93
- array('cakephp', false),
94
- array('cakephp-', false),
95
- array('cakephp-app', false),
96
- array('cakephp-plugin', true),
97
- array('codeigniter-app', false),
98
- array('codeigniter-library', true),
99
- array('codeigniter-third-party', true),
100
- array('codeigniter-module', true),
101
- array('concrete5-block', true),
102
- array('concrete5-package', true),
103
- array('concrete5-theme', true),
104
- array('concrete5-update', true),
105
- array('craft-plugin', true),
106
- array('croogo-plugin', true),
107
- array('croogo-theme', true),
108
- array('drupal-module', true),
109
- array('dolibarr-module', true),
110
- array('elgg-plugin', true),
111
- array('fuel-module', true),
112
- array('fuel-package', true),
113
- array('hurad-plugin', true),
114
- array('hurad-theme', true),
115
- array('joomla-library', true),
116
- array('kirby-plugin', true),
117
- array('kohana-module', true),
118
- array('laravel-library', true),
119
- array('lithium-library', true),
120
- array('magento-library', true),
121
- array('mako-package', true),
122
- array('modxevo-snippet', true),
123
- array('modxevo-plugin', true),
124
- array('modxevo-module', true),
125
- array('modxevo-template', true),
126
- array('modxevo-lib', true),
127
- array('mediawiki-extension', true),
128
- array('mediawiki-skin', true),
129
- array('microweber-module', true),
130
- array('modulework-module', true),
131
- array('moodle-mod', true),
132
- array('october-module', true),
133
- array('october-plugin', true),
134
- array('piwik-plugin', true),
135
- array('phpbb-extension', true),
136
- array('pimcore-plugin', true),
137
- array('ppi-module', true),
138
- array('roundcube-plugin', true),
139
- array('shopware-backend-plugin', true),
140
- array('shopware-core-plugin', true),
141
- array('shopware-frontend-plugin', true),
142
- array('shopware-theme', true),
143
- array('silverstripe-module', true),
144
- array('silverstripe-theme', true),
145
- array('symfony1-plugin', true),
146
- array('tusk-task', true),
147
- array('tusk-asset', true),
148
- array('typo3-flow-plugin', true),
149
- array('typo3-cms-extension', true),
150
- array('wolfcms-plugin', true),
151
- array('wordpress-plugin', true),
152
- array('wordpress-core', false),
153
- array('zend-library', true),
154
- array('zikula-module', true),
155
- array('zikula-theme', true),
156
- );
157
- }
158
-
159
- /**
160
- * testInstallPath
161
- *
162
- * @dataProvider dataForTestInstallPath
163
- */
164
- public function testInstallPath($type, $path, $name, $version = '1.0.0')
165
- {
166
- $installer = new Installer($this->io, $this->composer);
167
- $package = new Package($name, $version, $version);
168
-
169
- $package->setType($type);
170
- $result = $installer->getInstallPath($package);
171
- $this->assertEquals($path, $result);
172
- }
173
-
174
- /**
175
- * dataFormTestInstallPath
176
- */
177
- public function dataForTestInstallPath()
178
- {
179
- return array(
180
- array('agl-module', 'More/MyTestPackage/', 'agl/my_test-package'),
181
- array('annotatecms-module', 'addons/modules/my_module/', 'vysinsky/my_module'),
182
- array('annotatecms-component', 'addons/components/my_component/', 'vysinsky/my_component'),
183
- array('annotatecms-service', 'addons/services/my_service/', 'vysinsky/my_service'),
184
- array('bitrix-module', 'local/modules/my_module/', 'author/my_module'),
185
- array('bitrix-component', 'local/components/my_component/', 'author/my_component'),
186
- array('cakephp-plugin', 'Plugin/Ftp/', 'shama/ftp'),
187
- array('codeigniter-library', 'application/libraries/my_package/', 'shama/my_package'),
188
- array('codeigniter-module', 'application/modules/my_package/', 'shama/my_package'),
189
- array('concrete5-block', 'blocks/concrete5_block/', 'remo/concrete5_block'),
190
- array('concrete5-package', 'packages/concrete5_package/', 'remo/concrete5_package'),
191
- array('concrete5-theme', 'themes/concrete5_theme/', 'remo/concrete5_theme'),
192
- array('concrete5-update', 'updates/concrete5/', 'concrete5/concrete5'),
193
- array('craft-plugin', 'craft/plugins/my_plugin/', 'mdcpepper/my_plugin'),
194
- array('croogo-plugin', 'Plugin/Sitemaps/', 'fahad19/sitemaps'),
195
- array('croogo-theme', 'View/Themed/Readable/', 'rchavik/readable'),
196
- array('dolibarr-module', 'htdocs/custom/my_module/', 'shama/my_module'),
197
- array('drupal-module', 'modules/my_module/', 'shama/my_module'),
198
- array('drupal-theme', 'themes/my_module/', 'shama/my_module'),
199
- array('drupal-profile', 'profiles/my_module/', 'shama/my_module'),
200
- array('drupal-drush', 'drush/my_module/', 'shama/my_module'),
201
- array('elgg-plugin', 'mod/sample_plugin/', 'test/sample_plugin'),
202
- array('fuel-module', 'fuel/app/modules/module/', 'fuel/module'),
203
- array('fuel-package', 'fuel/packages/orm/', 'fuel/orm'),
204
- array('hurad-plugin', 'Plugin/Akismet/', 'atkrad/akismet'),
205
- array('hurad-theme', 'View/Themed/Hurad2013/', 'atkrad/Hurad2013'),
206
- array('joomla-plugin', 'plugins/my_plugin/', 'shama/my_plugin'),
207
- array('kirby-plugin', 'site/plugins/my_plugin/', 'shama/my_plugin'),
208
- array('kohana-module', 'modules/my_package/', 'shama/my_package'),
209
- array('laravel-library', 'libraries/my_package/', 'shama/my_package'),
210
- array('lithium-library', 'libraries/li3_test/', 'user/li3_test'),
211
- array('magento-library', 'lib/foo/', 'test/foo'),
212
- array('modxevo-snippet', 'assets/snippets/my_snippet/', 'shama/my_snippet'),
213
- array('modxevo-plugin', 'assets/plugins/my_plugin/', 'shama/my_plugin'),
214
- array('modxevo-module', 'assets/modules/my_module/', 'shama/my_module'),
215
- array('modxevo-template', 'assets/templates/my_template/', 'shama/my_template'),
216
- array('modxevo-lib', 'assets/lib/my_lib/', 'shama/my_lib'),
217
- array('mako-package', 'app/packages/my_package/', 'shama/my_package'),
218
- array('mediawiki-extension', 'extensions/APC/', 'author/APC'),
219
- array('mediawiki-extension', 'extensions/APC/', 'author/APC-extension'),
220
- array('mediawiki-extension', 'extensions/UploadWizard/', 'author/upload-wizard'),
221
- array('mediawiki-extension', 'extensions/SyntaxHighlight_GeSHi/', 'author/syntax-highlight_GeSHi'),
222
- array('mediawiki-skin', 'skins/someskin/', 'author/someskin-skin'),
223
- array('mediawiki-skin', 'skins/someskin/', 'author/someskin'),
224
- array('microweber-module', 'userfiles/modules/my-thing/', 'author/my-thing-module'),
225
- array('modulework-module', 'modules/my_package/', 'shama/my_package'),
226
- array('moodle-mod', 'mod/my_package/', 'shama/my_package'),
227
- array('october-module', 'modules/my_plugin/', 'shama/my_plugin'),
228
- array('october-plugin', 'plugins/shama/my_plugin/', 'shama/my_plugin'),
229
- array('piwik-plugin', 'plugins/VisitSummary/', 'shama/visit-summary'),
230
- array('phpbb-extension', 'ext/test/foo/', 'test/foo'),
231
- array('phpbb-style', 'styles/foo/', 'test/foo'),
232
- array('phpbb-language', 'language/foo/', 'test/foo'),
233
- array('pimcore-plugin', 'plugins/MyPlugin/', 'ubikz/my_plugin'),
234
- array('ppi-module', 'modules/foo/', 'test/foo'),
235
- array('roundcube-plugin', 'plugins/base/', 'test/base'),
236
- array('roundcube-plugin', 'plugins/replace_dash/', 'test/replace-dash'),
237
- array('shopware-backend-plugin', 'engine/Shopware/Plugins/Local/Backend/ShamaMyBackendPlugin/', 'shama/my-backend-plugin'),
238
- array('shopware-core-plugin', 'engine/Shopware/Plugins/Local/Core/ShamaMyCorePlugin/', 'shama/my-core-plugin'),
239
- array('shopware-frontend-plugin', 'engine/Shopware/Plugins/Local/Frontend/ShamaMyFrontendPlugin/', 'shama/my-frontend-plugin'),
240
- array('shopware-theme', 'templates/my_theme/', 'shama/my-theme'),
241
- array('silverstripe-module', 'my_module/', 'shama/my_module'),
242
- array('silverstripe-module', 'sapphire/', 'silverstripe/framework', '2.4.0'),
243
- array('silverstripe-module', 'framework/', 'silverstripe/framework', '3.0.0'),
244
- array('silverstripe-module', 'framework/', 'silverstripe/framework', '3.0.0-rc1'),
245
- array('silverstripe-module', 'framework/', 'silverstripe/framework', 'my/branch'),
246
- array('silverstripe-theme', 'themes/my_theme/', 'shama/my_theme'),
247
- array('symfony1-plugin', 'plugins/sfShamaPlugin/', 'shama/sfShamaPlugin'),
248
- array('symfony1-plugin', 'plugins/sfShamaPlugin/', 'shama/sf-shama-plugin'),
249
- array('tusk-task', '.tusk/tasks/my_task/', 'shama/my_task'),
250
- array('typo3-flow-package', 'Packages/Application/my_package/', 'shama/my_package'),
251
- array('typo3-flow-build', 'Build/my_package/', 'shama/my_package'),
252
- array('typo3-cms-extension', 'typo3conf/ext/my_extension/', 'shama/my_extension'),
253
- array('wolfcms-plugin', 'wolf/plugins/my_plugin/', 'shama/my_plugin'),
254
- array('wordpress-plugin', 'wp-content/plugins/my_plugin/', 'shama/my_plugin'),
255
- array('wordpress-muplugin', 'wp-content/mu-plugins/my_plugin/', 'shama/my_plugin'),
256
- array('zend-extra', 'extras/library/zend_test/', 'shama/zend_test'),
257
- array('zikula-module', 'modules/my-test_module/', 'my/test_module'),
258
- array('zikula-theme', 'themes/my-test_theme/', 'my/test_theme'),
259
- );
260
- }
261
-
262
- /**
263
- * testGetCakePHPInstallPathException
264
- *
265
- * @return void
266
- *
267
- * @expectedException \InvalidArgumentException
268
- */
269
- public function testGetCakePHPInstallPathException()
270
- {
271
- $installer = new Installer($this->io, $this->composer);
272
- $package = new Package('shama/ftp', '1.0.0', '1.0.0');
273
-
274
- $package->setType('cakephp-whoops');
275
- $result = $installer->getInstallPath($package);
276
- }
277
-
278
- /**
279
- * testCustomInstallPath
280
- */
281
- public function testCustomInstallPath()
282
- {
283
- $installer = new Installer($this->io, $this->composer);
284
- $package = new Package('shama/ftp', '1.0.0', '1.0.0');
285
- $package->setType('cakephp-plugin');
286
- $consumerPackage = new RootPackage('foo/bar', '1.0.0', '1.0.0');
287
- $this->composer->setPackage($consumerPackage);
288
- $consumerPackage->setExtra(array(
289
- 'installer-paths' => array(
290
- 'my/custom/path/{$name}/' => array(
291
- 'shama/ftp',
292
- 'foo/bar',
293
- ),
294
- ),
295
- ));
296
- $result = $installer->getInstallPath($package);
297
- $this->assertEquals('my/custom/path/Ftp/', $result);
298
- }
299
-
300
- /**
301
- * testCustomInstallerName
302
- */
303
- public function testCustomInstallerName()
304
- {
305
- $installer = new Installer($this->io, $this->composer);
306
- $package = new Package('shama/cakephp-ftp-plugin', '1.0.0', '1.0.0');
307
- $package->setType('cakephp-plugin');
308
- $package->setExtra(array(
309
- 'installer-name' => 'FTP',
310
- ));
311
- $result = $installer->getInstallPath($package);
312
- $this->assertEquals('Plugin/FTP/', $result);
313
- }
314
-
315
- /**
316
- * testCustomTypePath
317
- */
318
- public function testCustomTypePath()
319
- {
320
- $installer = new Installer($this->io, $this->composer);
321
- $package = new Package('slbmeh/my_plugin', '1.0.0', '1.0.0');
322
- $package->setType('wordpress-plugin');
323
- $consumerPackage = new RootPackage('foo/bar', '1.0.0', '1.0.0');
324
- $this->composer->setPackage($consumerPackage);
325
- $consumerPackage->setExtra(array(
326
- 'installer-paths' => array(
327
- 'my/custom/path/{$name}/' => array(
328
- 'type:wordpress-plugin'
329
- ),
330
- ),
331
- ));
332
- $result = $installer->getInstallPath($package);
333
- $this->assertEquals('my/custom/path/my_plugin/', $result);
334
- }
335
-
336
- /**
337
- * testNoVendorName
338
- */
339
- public function testNoVendorName()
340
- {
341
- $installer = new Installer($this->io, $this->composer);
342
- $package = new Package('sfPhpunitPlugin', '1.0.0', '1.0.0');
343
-
344
- $package->setType('symfony1-plugin');
345
- $result = $installer->getInstallPath($package);
346
- $this->assertEquals('plugins/sfPhpunitPlugin/', $result);
347
- }
348
-
349
- /**
350
- * testTypo3Inflection
351
- */
352
- public function testTypo3Inflection()
353
- {
354
- $installer = new Installer($this->io, $this->composer);
355
- $package = new Package('typo3/fluid', '1.0.0', '1.0.0');
356
-
357
- $package->setAutoload(array(
358
- 'psr-0' => array(
359
- 'TYPO3\\Fluid' => 'Classes',
360
- ),
361
- ));
362
-
363
- $package->setType('typo3-flow-package');
364
- $result = $installer->getInstallPath($package);
365
- $this->assertEquals('Packages/Application/TYPO3.Fluid/', $result);
366
- }
367
-
368
- public function testUninstallAndDeletePackageFromLocalRepo()
369
- {
370
- $package = new Package('foo', '1.0.0', '1.0.0');
371
-
372
- $installer = $this->getMock('Composer\Installers\Installer', array('getInstallPath'), array($this->io, $this->composer));
373
- $installer->expects($this->once())->method('getInstallPath')->with($package)->will($this->returnValue(sys_get_temp_dir().'/foo'));
374
-
375
- $repo = $this->getMock('Composer\Repository\InstalledRepositoryInterface');
376
- $repo->expects($this->once())->method('hasPackage')->with($package)->will($this->returnValue(true));
377
- $repo->expects($this->once())->method('removePackage')->with($package);
378
-
379
- $installer->uninstall($repo, $package);
380
- }
381
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/composer/installers/tests/Composer/Installers/Test/MediaWikiInstallerTest.php DELETED
@@ -1,66 +0,0 @@
1
- <?php
2
- namespace Composer\Installers\Test;
3
-
4
- use Composer\Installers\MediaWikiInstaller;
5
- use Composer\Package\Package;
6
- use Composer\Composer;
7
-
8
- class MediaWikiInstallerTest extends \PHPUnit_Framework_TestCase
9
- {
10
- /**
11
- * @var MediaWikiInstaller
12
- */
13
- private $installer;
14
-
15
- public function setUp()
16
- {
17
- $this->installer = new MediaWikiInstaller(
18
- new Package('NyanCat', '4.2', '4.2'),
19
- new Composer()
20
- );
21
- }
22
-
23
- /**
24
- * @dataProvider packageNameInflectionProvider
25
- */
26
- public function testInflectPackageVars($type, $name, $expected)
27
- {
28
- $this->assertEquals(
29
- $this->installer->inflectPackageVars(array('name' => $name, 'type'=>$type)),
30
- array('name' => $expected, 'type'=>$type)
31
- );
32
- }
33
-
34
- public function packageNameInflectionProvider()
35
- {
36
- return array(
37
- array(
38
- 'mediawiki-extension',
39
- 'sub-page-list',
40
- 'SubPageList',
41
- ),
42
- array(
43
- 'mediawiki-extension',
44
- 'sub-page-list-extension',
45
- 'SubPageList',
46
- ),
47
- array(
48
- 'mediawiki-extension',
49
- 'semantic-mediawiki',
50
- 'SemanticMediawiki',
51
- ),
52
- // tests that exactly one '-skin' is cut off, and that skins do not get ucwords treatment like extensions
53
- array(
54
- 'mediawiki-skin',
55
- 'some-skin-skin',
56
- 'some-skin',
57
- ),
58
- // tests that names without '-skin' suffix stay valid
59
- array(
60
- 'mediawiki-skin',
61
- 'someotherskin',
62
- 'someotherskin',
63
- ),
64
- );
65
- }
66
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/composer/installers/tests/Composer/Installers/Test/PimcoreInstallerTest.php DELETED
@@ -1,44 +0,0 @@
1
- <?php
2
- namespace Composer\Installers\Test;
3
-
4
- use Composer\Installers\PimcoreInstaller;
5
- use Composer\Package\Package;
6
- use Composer\Composer;
7
-
8
- class PimcoreInstallerTest extends TestCase
9
- {
10
- private $composer;
11
- private $io;
12
-
13
- /**
14
- * setUp
15
- *
16
- * @return void
17
- */
18
- public function setUp()
19
- {
20
- $this->package = new Package('CamelCased', '1.0', '1.0');
21
- $this->io = $this->getMock('Composer\IO\PackageInterface');
22
- $this->composer = new Composer();
23
- }
24
-
25
- /**
26
- * testInflectPackageVars
27
- *
28
- * @return void
29
- */
30
- public function testInflectPackageVars()
31
- {
32
- $installer = new PimcoreInstaller($this->package, $this->composer);
33
- $result = $installer->inflectPackageVars(array('name' => 'CamelCased'));
34
- $this->assertEquals($result, array('name' => 'CamelCased'));
35
-
36
- $installer = new PimcoreInstaller($this->package, $this->composer);
37
- $result = $installer->inflectPackageVars(array('name' => 'with-dash'));
38
- $this->assertEquals($result, array('name' => 'WithDash'));
39
-
40
- $installer = new PimcoreInstaller($this->package, $this->composer);
41
- $result = $installer->inflectPackageVars(array('name' => 'with_underscore'));
42
- $this->assertEquals($result, array('name' => 'WithUnderscore'));
43
- }
44
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/composer/installers/tests/Composer/Installers/Test/PiwikInstallerTest.php DELETED
@@ -1,63 +0,0 @@
1
- <?php
2
- namespace Composer\Installers\Test;
3
-
4
- use Composer\Composer;
5
- use Composer\Installers\PiwikInstaller;
6
- use Composer\Package\Package;
7
- use Composer\Package\PackageInterface;
8
-
9
- /**
10
- * Class PiwikInstallerTest
11
- *
12
- * @package Composer\Installers\Test
13
- */
14
- class PiwikInstallerTest extends TestCase
15
- {
16
- /**
17
- * @varComposer
18
- */
19
- private $composer;
20
-
21
- /**
22
- * @var PackageInterface
23
- */
24
- private $io;
25
-
26
- /**
27
- * @var Package
28
- */
29
- private $package;
30
-
31
- /**
32
- * setUp
33
- *
34
- * @return void
35
- */
36
- public function setUp()
37
- {
38
- $this->package = new Package('VisitSummary', '1.0', '1.0');
39
- $this->io = $this->getMock('Composer\IO\PackageInterface');
40
- $this->composer = new Composer();
41
- }
42
-
43
- /**
44
- * testInflectPackageVars
45
- *
46
- * @return void
47
- */
48
- public function testInflectPackageVars()
49
- {
50
- $installer = new PiwikInstaller($this->package, $this->composer);
51
- $result = $installer->inflectPackageVars(array('name' => 'VisitSummary'));
52
- $this->assertEquals($result, array('name' => 'VisitSummary'));
53
-
54
- $installer = new PiwikInstaller($this->package, $this->composer);
55
- $result = $installer->inflectPackageVars(array('name' => 'visit-summary'));
56
- $this->assertEquals($result, array('name' => 'VisitSummary'));
57
-
58
- $installer = new PiwikInstaller($this->package, $this->composer);
59
- $result = $installer->inflectPackageVars(array('name' => 'visit_summary'));
60
- $this->assertEquals($result, array('name' => 'VisitSummary'));
61
- }
62
-
63
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/composer/installers/tests/Composer/Installers/Test/TestCase.php DELETED
@@ -1,64 +0,0 @@
1
- <?php
2
-
3
- /*
4
- * This file is part of Composer.
5
- *
6
- * (c) Nils Adermann <naderman@naderman.de>
7
- * Jordi Boggiano <j.boggiano@seld.be>
8
- *
9
- * For the full copyright and license information, please view the LICENSE
10
- * file that was distributed with this source code.
11
- */
12
-
13
- namespace Composer\Installers\Test;
14
-
15
- use Composer\Package\Version\VersionParser;
16
- use Composer\Package\Package;
17
- use Composer\Package\AliasPackage;
18
- use Composer\Package\LinkConstraint\VersionConstraint;
19
- use Composer\Util\Filesystem;
20
-
21
- abstract class TestCase extends \PHPUnit_Framework_TestCase
22
- {
23
- private static $parser;
24
-
25
- protected static function getVersionParser()
26
- {
27
- if (!self::$parser) {
28
- self::$parser = new VersionParser();
29
- }
30
-
31
- return self::$parser;
32
- }
33
-
34
- protected function getVersionConstraint($operator, $version)
35
- {
36
- return new VersionConstraint(
37
- $operator,
38
- self::getVersionParser()->normalize($version)
39
- );
40
- }
41
-
42
- protected function getPackage($name, $version)
43
- {
44
- $normVersion = self::getVersionParser()->normalize($version);
45
-
46
- return new Package($name, $normVersion, $version);
47
- }
48
-
49
- protected function getAliasPackage($package, $version)
50
- {
51
- $normVersion = self::getVersionParser()->normalize($version);
52
-
53
- return new AliasPackage($package, $normVersion, $version);
54
- }
55
-
56
- protected function ensureDirectoryExistsAndClear($directory)
57
- {
58
- $fs = new Filesystem();
59
- if (is_dir($directory)) {
60
- $fs->removeDirectory($directory);
61
- }
62
- mkdir($directory, 0777, true);
63
- }
64
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/composer/installers/tests/bootstrap.php DELETED
@@ -1,4 +0,0 @@
1
- <?php
2
-
3
- $loader = require __DIR__ . '/../src/bootstrap.php';
4
- $loader->add('Composer\Installers\Test', __DIR__);
 
 
 
 
vendor/vendor/dannyvankooten/php-router/.gitignore DELETED
@@ -1,36 +0,0 @@
1
- # Compiled source #
2
- ###################
3
- *.com
4
- *.class
5
- *.dll
6
- *.exe
7
- *.o
8
- *.so
9
- *.sublime-project
10
- *.sublime-workspace
11
-
12
- # Packages #
13
- ############
14
- # it's better to unpack these files and commit the raw source
15
- # git has its own built in compression methods
16
- *.7z
17
- *.dmg
18
- *.gz
19
- *.iso
20
- *.jar
21
- *.rar
22
- *.tar
23
- *.zip
24
-
25
- # Logs and databases #
26
- ######################
27
- *.log
28
- *.sql
29
- *.sqlite
30
-
31
- # OS generated files #
32
- ######################
33
- .DS_Store*
34
- ehthumbs.db
35
- Icon?
36
- Thumbs.db
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/dannyvankooten/php-router/.htaccess DELETED
@@ -1,3 +0,0 @@
1
- Options +FollowSymLinks
2
- RewriteEngine On
3
- RewriteRule ^(.*)$ example.php [NC,L]
 
 
 
vendor/vendor/dannyvankooten/php-router/LICENSE DELETED
@@ -1,7 +0,0 @@
1
- Copyright (c) 2012 Danny van Kooten
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
-
5
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
-
7
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 
 
 
 
 
 
vendor/vendor/dannyvankooten/php-router/README.md DELETED
@@ -1,43 +0,0 @@
1
- # PHP Router class
2
-
3
- A simple Rails inspired PHP router class.
4
-
5
- * Usage of different HTTP Methods
6
- * REST / Resourceful routing
7
- * Reversed routing using named routes
8
- * Dynamic URL's: use URL segments as parameters.
9
-
10
- ## Usage
11
- ```php
12
- <?php
13
- require 'Router.php';
14
- require 'Route.php';
15
-
16
- $router = new Router();
17
-
18
- $router->setBasePath('/PHP-Router');
19
-
20
- // defining routes can be as simple as this
21
- $router->map('/', 'users#index');
22
-
23
- // or somewhat more complicated
24
- $router->map('/users/:id/edit/', array('controller' => 'SomeController', 'action' => 'someAction'), array('methods' => 'GET,PUT', 'name' => 'users_edit', 'filters' => array('id' => '(\d+)')));
25
-
26
- // You can even specify closures as the Route's target
27
- $router->map('/hello/:name', function($name) { echo "Hello $name."; });
28
-
29
- // match current request URL & http method
30
- $target = $router->matchCurrentRequest();
31
- var_dump($target);
32
-
33
- // generate an URL
34
- $router->generate('users_edit', array('id' => 5));
35
- ```
36
-
37
- ## More information
38
- Have a look at the example.php file or read trough the class' documentation for a better understanding on how to use this class.
39
-
40
- If you like PHP Router you might also like [AltoRouter](//github.com/dannyvankooten/AltoRouter).
41
-
42
- ## License
43
- MIT Licensed, http://www.opensource.org/licenses/MIT
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/dannyvankooten/php-router/composer.json DELETED
@@ -1,26 +0,0 @@
1
- {
2
- "name": "dannyvankooten/php-router",
3
- "description": "Simple PHP Router, supports REST and reverse routing.",
4
- "keywords": ["router", "routing", "php", "rest"],
5
- "homepage": "https://github.com/dannyvankooten/PHP-Router",
6
- "license": "MIT",
7
- "authors": [
8
- {
9
- "name": "Danny van Kooten",
10
- "email": "dannyvankooten@gmail.com",
11
- "homepage": "http://dannyvankooten.com/"
12
- },
13
- {
14
- "name": "Jefersson Nathan",
15
- "email": "malukenho@phpse.net"
16
- }
17
- ],
18
- "require": {
19
- "php": ">=5.3.0"
20
- },
21
- "autoload": {
22
- "psr-0": {
23
- "PHProuter": "src/"
24
- }
25
- }
26
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/dannyvankooten/php-router/example.php DELETED
@@ -1,37 +0,0 @@
1
- <?php
2
- require 'Router.php';
3
- require 'Route.php';
4
-
5
- $router = new Router();
6
-
7
- $router->setBasePath('/PHP-Router');
8
-
9
- $router->map('/', 'someController:indexAction', array('methods' => 'GET'));
10
- $router->map('/users/','users#create', array('methods' => 'POST', 'name' => 'users_create'));
11
- $router->map('/users/:id/edit/', 'users#edit', array('methods' => 'GET', 'name' => 'users_edit', 'filters' => array('id' => '(\d+)')));
12
- $router->map('/contact/',array('controller' => 'someController', 'action' => 'contactAction'), array('name' => 'contact'));
13
-
14
- $router->map('/blog/:slug', array('c' => 'BlogController', 'a' => 'showAction'));
15
-
16
- // capture rest of URL in "path" parameter (including forward slashes)
17
- $router->map('/site-section/:path','some#target',array( 'filters' => array( 'path' => '(.*)') ) );
18
-
19
- $route = $router->matchCurrentRequest();
20
-
21
- ?><h3>Current URL & HTTP method would route to: </h3>
22
- <?php if($route) { ?>
23
- <strong>Target:</strong>
24
- <pre><?php var_dump($route->getTarget()); ?></pre>
25
-
26
- <strong>Parameters:</strong>
27
- <pre><?php var_dump($route->getParameters()); ?></pre>
28
- <?php } else { ?>
29
- <pre>No route matched.</pre>
30
- <?php } ?>
31
-
32
- <h3>Try out these URL's.</h3>
33
- <p><a href="<?php echo $router->generate('users_edit', array('id' => 5)); ?>"><?php echo $router->generate('users_edit', array('id' => 5)); ?></a></p>
34
- <p><a href="<?php echo $router->generate('contact'); ?>"><?php echo $router->generate('contact'); ?></a></p>
35
- <p><form action="" method="POST"><input type="submit" value="Post request to current URL" /></form></p>
36
- <p><form action="<?php echo $router->generate('users_create'); ?>" method="POST"><input type="submit" value="POST request to <?php echo $router->generate('users_create'); ?>" /></form></p>
37
- <p><a href="<?php echo $router->generate('users_list'); ?>">GET request to <?php echo $router->generate('users_list'); ?></p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/dannyvankooten/php-router/src/PHPRouter/Route.php DELETED
@@ -1,115 +0,0 @@
1
- <?php
2
- namespace PHPRouter;
3
-
4
- class Route
5
- {
6
- /**
7
- * URL of this Route
8
- * @var string
9
- */
10
- private $_url;
11
-
12
- /**
13
- * Accepted HTTP methods for this route
14
- * @var array
15
- */
16
- private $_methods = array('GET','POST','PUT','DELETE');
17
-
18
- /**
19
- * Target for this route, can be anything.
20
- * @var mixed
21
- */
22
- private $_target;
23
-
24
- /**
25
- * The name of this route, used for reversed routing
26
- * @var string
27
- */
28
- private $_name;
29
-
30
- /**
31
- * Custom parameter filters for this route
32
- * @var array
33
- */
34
- private $_filters = array();
35
-
36
- /**
37
- * Array containing parameters passed through request URL
38
- * @var array
39
- */
40
- private $_parameters = array();
41
-
42
- public function getUrl()
43
- {
44
- return $this->_url;
45
- }
46
-
47
- public function setUrl($url)
48
- {
49
- $url = (string) $url;
50
-
51
- // make sure that the URL is suffixed with a forward slash
52
- if(substr($url,-1) !== '/') $url .= '/';
53
-
54
- $this->_url = $url;
55
- }
56
-
57
- public function getTarget()
58
- {
59
- return $this->_target;
60
- }
61
-
62
- public function setTarget($target)
63
- {
64
- $this->_target = $target;
65
- }
66
-
67
- public function getMethods()
68
- {
69
- return $this->_methods;
70
- }
71
-
72
- public function setMethods(array $methods)
73
- {
74
- $this->_methods = $methods;
75
- }
76
-
77
- public function getName()
78
- {
79
- return $this->_name;
80
- }
81
-
82
- public function setName($name)
83
- {
84
- $this->_name = (string) $name;
85
- }
86
-
87
- public function setFilters(array $filters)
88
- {
89
- $this->_filters = $filters;
90
- }
91
-
92
- public function getRegex()
93
- {
94
- return preg_replace_callback("/:(\w+)/", array(&$this, 'substituteFilter'), $this->_url);
95
- }
96
-
97
- private function substituteFilter($matches)
98
- {
99
- if (isset($matches[1]) && isset($this->_filters[$matches[1]])) {
100
- return $this->_filters[$matches[1]];
101
- }
102
-
103
- return "([\w-]+)";
104
- }
105
-
106
- public function getParameters()
107
- {
108
- return $this->_parameters;
109
- }
110
-
111
- public function setParameters(array $parameters)
112
- {
113
- $this->_parameters = $parameters;
114
- }
115
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/dannyvankooten/php-router/src/PHPRouter/Router.php DELETED
@@ -1,164 +0,0 @@
1
- <?php
2
- namespace PHPRouter;
3
-
4
- /**
5
- * Routing class to match request URL's against given routes and map them to a controller action.
6
- */
7
- class Router
8
- {
9
- /**
10
- * Array that holds all Route objects
11
- * @var array
12
- */
13
- private $_routes = array();
14
-
15
- /**
16
- * Array to store named routes in, used for reverse routing.
17
- * @var array
18
- */
19
- private $_namedRoutes = array();
20
-
21
- /**
22
- * The base REQUEST_URI. Gets prepended to all route _url's.
23
- * @var string
24
- */
25
- private $_basePath = '';
26
-
27
- /**
28
- * Set the base _url - gets prepended to all route _url's.
29
- * @param string $base_url
30
- */
31
- public function setBasePath($basePath)
32
- {
33
- $this->_basePath = (string) $basePath;
34
- }
35
-
36
- /**
37
- * Route factory method
38
- *
39
- * Maps the given URL to the given target.
40
- * @param string $routeUrl string
41
- * @param mixed $target The target of this route. Can be anything. You'll have to provide your own method to turn * this into a filename, controller / action pair, etc..
42
- * @param array $args Array of optional arguments.
43
- */
44
- public function map($routeUrl, $target = '', array $args = array())
45
- {
46
- $route = new Route();
47
-
48
- $route->setUrl($this->_basePath . $routeUrl);
49
-
50
- $route->setTarget($target);
51
-
52
- if(isset($args['methods'])) {
53
- $methods = explode(',', $args['methods']);
54
- $route->setMethods($methods);
55
- }
56
-
57
- if(isset($args['filters'])) {
58
- $route->setFilters($args['filters']);
59
- }
60
-
61
- if(isset($args['name'])) {
62
- $route->setName($args['name']);
63
- if (!isset($this->_namedRoutes[$route->getName()])) {
64
- $this->_namedRoutes[$route->getName()] = $route;
65
- }
66
- }
67
-
68
- $this->_routes[] = $route;
69
- }
70
-
71
- /**
72
- * Matches the current request against mapped routes
73
- */
74
- public function matchCurrentRequest()
75
- {
76
- $requestMethod = (isset($_POST['_method']) && ($_method = strtoupper($_POST['_method'])) && in_array($_method,array('PUT','DELETE'))) ? $_method : $_SERVER['REQUEST_METHOD'];
77
- $requestUrl = $_SERVER['REQUEST_URI'];
78
-
79
- // strip GET variables from URL
80
- if(($pos = strpos($requestUrl, '?')) !== false) {
81
- $requestUrl = substr($requestUrl, 0, $pos);
82
- }
83
-
84
- return $this->match($requestUrl, $requestMethod);
85
- }
86
-
87
- /**
88
- * Match given request _url and request method and see if a route has been defined for it
89
- * If so, return route's target
90
- * If called multiple times
91
- */
92
- public function match($requestUrl, $requestMethod = 'GET')
93
- {
94
-
95
- foreach ($this->_routes as $route) {
96
-
97
- // compare server request method with route's allowed http methods
98
- if (! in_array($requestMethod, $route->getMethods())) {
99
- continue;
100
- }
101
-
102
- // check if request _url matches route regex. if not, return false.
103
- if (! preg_match("@^".$route->getRegex()."*$@i", $requestUrl, $matches)) {
104
- continue;
105
- }
106
-
107
- $params = array();
108
-
109
- if (preg_match_all("/:([\w-]+)/", $route->getUrl(), $argument_keys)) {
110
-
111
- // grab array with matches
112
- $argument_keys = $argument_keys[1];
113
-
114
- // loop trough parameter names, store matching value in $params array
115
- foreach ($argument_keys as $key => $name) {
116
- if (isset($matches[$key + 1])) {
117
- $params[$name] = $matches[$key + 1];
118
- }
119
- }
120
-
121
- }
122
-
123
- $route->setParameters($params);
124
-
125
- return $route;
126
- }
127
- return false;
128
- }
129
-
130
-
131
-
132
- /**
133
- * Reverse route a named route
134
- *
135
- * @param string $route_name The name of the route to reverse route.
136
- * @param array $params Optional array of parameters to use in URL
137
- * @return string The url to the route
138
- */
139
- public function generate($routeName, array $params = array())
140
- {
141
- // Check if route exists
142
- if (! isset($this->_namedRoutes[$routeName])) {
143
- throw new Exception("No route with the name $routeName has been found.");
144
- }
145
-
146
- $route = $this->_namedRoutes[$routeName];
147
- $url = $route->getUrl();
148
-
149
- // replace route url with given parameters
150
- if ($params && preg_match_all("/:(\w+)/", $url, $param_keys))
151
- {
152
-
153
- // grab array with matches
154
- $param_keys = $param_keys[1];
155
-
156
- // loop trough parameter names, store matching value in $params array
157
- foreach ($param_keys as $key) {
158
- if (isset($params[$key]))
159
- $url = preg_replace("/:(\w+)/", $params[$key], $url, 1);
160
- }
161
- }
162
- return $url;
163
- }
164
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/symfony/yaml/Symfony/Component/Yaml/.gitignore DELETED
@@ -1,3 +0,0 @@
1
- vendor/
2
- composer.lock
3
- phpunit.xml
 
 
 
vendor/vendor/symfony/yaml/Symfony/Component/Yaml/CHANGELOG.md DELETED
@@ -1,8 +0,0 @@
1
- CHANGELOG
2
- =========
3
-
4
- 2.1.0
5
- -----
6
-
7
- * Yaml::parse() does not evaluate loaded files as PHP files by default
8
- anymore (call Yaml::enablePhpParsing() to get back the old behavior)
 
 
 
 
 
 
 
 
vendor/vendor/symfony/yaml/Symfony/Component/Yaml/Dumper.php DELETED
@@ -1,73 +0,0 @@
1
- <?php
2
-
3
- /*
4
- * This file is part of the Symfony package.
5
- *
6
- * (c) Fabien Potencier <fabien@symfony.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 Symfony\Component\Yaml;
13
-
14
- /**
15
- * Dumper dumps PHP variables to YAML strings.
16
- *
17
- * @author Fabien Potencier <fabien@symfony.com>
18
- */
19
- class Dumper
20
- {
21
- /**
22
- * The amount of spaces to use for indentation of nested nodes.
23
- *
24
- * @var int
25
- */
26
- protected $indentation = 4;
27
-
28
- /**
29
- * Sets the indentation.
30
- *
31
- * @param int $num The amount of spaces to use for indentation of nested nodes.
32
- */
33
- public function setIndentation($num)
34
- {
35
- $this->indentation = (int) $num;
36
- }
37
-
38
- /**
39
- * Dumps a PHP value to YAML.
40
- *
41
- * @param mixed $input The PHP value
42
- * @param int $inline The level where you switch to inline YAML
43
- * @param int $indent The level of indentation (used internally)
44
- * @param bool $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise
45
- * @param bool $objectSupport true if object support is enabled, false otherwise
46
- *
47
- * @return string The YAML representation of the PHP value
48
- */
49
- public function dump($input, $inline = 0, $indent = 0, $exceptionOnInvalidType = false, $objectSupport = false)
50
- {
51
- $output = '';
52
- $prefix = $indent ? str_repeat(' ', $indent) : '';
53
-
54
- if ($inline <= 0 || !is_array($input) || empty($input)) {
55
- $output .= $prefix.Inline::dump($input, $exceptionOnInvalidType, $objectSupport);
56
- } else {
57
- $isAHash = array_keys($input) !== range(0, count($input) - 1);
58
-
59
- foreach ($input as $key => $value) {
60
- $willBeInlined = $inline - 1 <= 0 || !is_array($value) || empty($value);
61
-
62
- $output .= sprintf('%s%s%s%s',
63
- $prefix,
64
- $isAHash ? Inline::dump($key, $exceptionOnInvalidType, $objectSupport).':' : '-',
65
- $willBeInlined ? ' ' : "\n",
66
- $this->dump($value, $inline - 1, $willBeInlined ? 0 : $indent + $this->indentation, $exceptionOnInvalidType, $objectSupport)
67
- ).($willBeInlined ? "\n" : '');
68
- }
69
- }
70
-
71
- return $output;
72
- }
73
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/symfony/yaml/Symfony/Component/Yaml/Escaper.php DELETED
@@ -1,89 +0,0 @@
1
- <?php
2
-
3
- /*
4
- * This file is part of the Symfony package.
5
- *
6
- * (c) Fabien Potencier <fabien@symfony.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 Symfony\Component\Yaml;
13
-
14
- /**
15
- * Escaper encapsulates escaping rules for single and double-quoted
16
- * YAML strings.
17
- *
18
- * @author Matthew Lewinski <matthew@lewinski.org>
19
- */
20
- class Escaper
21
- {
22
- // Characters that would cause a dumped string to require double quoting.
23
- const REGEX_CHARACTER_TO_ESCAPE = "[\\x00-\\x1f]|\xc2\x85|\xc2\xa0|\xe2\x80\xa8|\xe2\x80\xa9";
24
-
25
- // Mapping arrays for escaping a double quoted string. The backslash is
26
- // first to ensure proper escaping because str_replace operates iteratively
27
- // on the input arrays. This ordering of the characters avoids the use of strtr,
28
- // which performs more slowly.
29
- private static $escapees = array('\\\\', '\\"', '"',
30
- "\x00", "\x01", "\x02", "\x03", "\x04", "\x05", "\x06", "\x07",
31
- "\x08", "\x09", "\x0a", "\x0b", "\x0c", "\x0d", "\x0e", "\x0f",
32
- "\x10", "\x11", "\x12", "\x13", "\x14", "\x15", "\x16", "\x17",
33
- "\x18", "\x19", "\x1a", "\x1b", "\x1c", "\x1d", "\x1e", "\x1f",
34
- "\xc2\x85", "\xc2\xa0", "\xe2\x80\xa8", "\xe2\x80\xa9");
35
- private static $escaped = array('\\"', '\\\\', '\\"',
36
- "\\0", "\\x01", "\\x02", "\\x03", "\\x04", "\\x05", "\\x06", "\\a",
37
- "\\b", "\\t", "\\n", "\\v", "\\f", "\\r", "\\x0e", "\\x0f",
38
- "\\x10", "\\x11", "\\x12", "\\x13", "\\x14", "\\x15", "\\x16", "\\x17",
39
- "\\x18", "\\x19", "\\x1a", "\\e", "\\x1c", "\\x1d", "\\x1e", "\\x1f",
40
- "\\N", "\\_", "\\L", "\\P");
41
-
42
- /**
43
- * Determines if a PHP value would require double quoting in YAML.
44
- *
45
- * @param string $value A PHP value
46
- *
47
- * @return bool True if the value would require double quotes.
48
- */
49
- public static function requiresDoubleQuoting($value)
50
- {
51
- return preg_match('/'.self::REGEX_CHARACTER_TO_ESCAPE.'/u', $value);
52
- }
53
-
54
- /**
55
- * Escapes and surrounds a PHP value with double quotes.
56
- *
57
- * @param string $value A PHP value
58
- *
59
- * @return string The quoted, escaped string
60
- */
61
- public static function escapeWithDoubleQuotes($value)
62
- {
63
- return sprintf('"%s"', str_replace(self::$escapees, self::$escaped, $value));
64
- }
65
-
66
- /**
67
- * Determines if a PHP value would require single quoting in YAML.
68
- *
69
- * @param string $value A PHP value
70
- *
71
- * @return bool True if the value would require single quotes.
72
- */
73
- public static function requiresSingleQuoting($value)
74
- {
75
- return preg_match('/[ \s \' " \: \{ \} \[ \] , & \* \# \?] | \A[ \- ? | < > = ! % @ ` ]/x', $value);
76
- }
77
-
78
- /**
79
- * Escapes and surrounds a PHP value with single quotes.
80
- *
81
- * @param string $value A PHP value
82
- *
83
- * @return string The quoted, escaped string
84
- */
85
- public static function escapeWithSingleQuotes($value)
86
- {
87
- return sprintf("'%s'", str_replace('\'', '\'\'', $value));
88
- }
89
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/symfony/yaml/Symfony/Component/Yaml/Exception/DumpException.php DELETED
@@ -1,23 +0,0 @@
1
- <?php
2
-
3
- /*
4
- * This file is part of the Symfony package.
5
- *
6
- * (c) Fabien Potencier <fabien@symfony.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 Symfony\Component\Yaml\Exception;
13
-
14
- /**
15
- * Exception class thrown when an error occurs during dumping.
16
- *
17
- * @author Fabien Potencier <fabien@symfony.com>
18
- *
19
- * @api
20
- */
21
- class DumpException extends RuntimeException
22
- {
23
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/symfony/yaml/Symfony/Component/Yaml/Exception/ExceptionInterface.php DELETED
@@ -1,23 +0,0 @@
1
- <?php
2
-
3
- /*
4
- * This file is part of the Symfony package.
5
- *
6
- * (c) Fabien Potencier <fabien@symfony.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 Symfony\Component\Yaml\Exception;
13
-
14
- /**
15
- * Exception interface for all exceptions thrown by the component.
16
- *
17
- * @author Fabien Potencier <fabien@symfony.com>
18
- *
19
- * @api
20
- */
21
- interface ExceptionInterface
22
- {
23
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/symfony/yaml/Symfony/Component/Yaml/Exception/ParseException.php DELETED
@@ -1,148 +0,0 @@
1
- <?php
2
-
3
- /*
4
- * This file is part of the Symfony package.
5
- *
6
- * (c) Fabien Potencier <fabien@symfony.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 Symfony\Component\Yaml\Exception;
13
-
14
- if (!defined('JSON_UNESCAPED_UNICODE')) {
15
- define('JSON_UNESCAPED_SLASHES', 64);
16
- define('JSON_UNESCAPED_UNICODE', 256);
17
- }
18
-
19
- /**
20
- * Exception class thrown when an error occurs during parsing.
21
- *
22
- * @author Fabien Potencier <fabien@symfony.com>
23
- *
24
- * @api
25
- */
26
- class ParseException extends RuntimeException
27
- {
28
- private $parsedFile;
29
- private $parsedLine;
30
- private $snippet;
31
- private $rawMessage;
32
-
33
- /**
34
- * Constructor.
35
- *
36
- * @param string $message The error message
37
- * @param int $parsedLine The line where the error occurred
38
- * @param int $snippet The snippet of code near the problem
39
- * @param string $parsedFile The file name where the error occurred
40
- * @param \Exception $previous The previous exception
41
- */
42
- public function __construct($message, $parsedLine = -1, $snippet = null, $parsedFile = null, \Exception $previous = null)
43
- {
44
- $this->parsedFile = $parsedFile;
45
- $this->parsedLine = $parsedLine;
46
- $this->snippet = $snippet;
47
- $this->rawMessage = $message;
48
-
49
- $this->updateRepr();
50
-
51
- parent::__construct($this->message, 0, $previous);
52
- }
53
-
54
- /**
55
- * Gets the snippet of code near the error.
56
- *
57
- * @return string The snippet of code
58
- */
59
- public function getSnippet()
60
- {
61
- return $this->snippet;
62
- }
63
-
64
- /**
65
- * Sets the snippet of code near the error.
66
- *
67
- * @param string $snippet The code snippet
68
- */
69
- public function setSnippet($snippet)
70
- {
71
- $this->snippet = $snippet;
72
-
73
- $this->updateRepr();
74
- }
75
-
76
- /**
77
- * Gets the filename where the error occurred.
78
- *
79
- * This method returns null if a string is parsed.
80
- *
81
- * @return string The filename
82
- */
83
- public function getParsedFile()
84
- {
85
- return $this->parsedFile;
86
- }
87
-
88
- /**
89
- * Sets the filename where the error occurred.
90
- *
91
- * @param string $parsedFile The filename
92
- */
93
- public function setParsedFile($parsedFile)
94
- {
95
- $this->parsedFile = $parsedFile;
96
-
97
- $this->updateRepr();
98
- }
99
-
100
- /**
101
- * Gets the line where the error occurred.
102
- *
103
- * @return int The file line
104
- */
105
- public function getParsedLine()
106
- {
107
- return $this->parsedLine;
108
- }
109
-
110
- /**
111
- * Sets the line where the error occurred.
112
- *
113
- * @param int $parsedLine The file line
114
- */
115
- public function setParsedLine($parsedLine)
116
- {
117
- $this->parsedLine = $parsedLine;
118
-
119
- $this->updateRepr();
120
- }
121
-
122
- private function updateRepr()
123
- {
124
- $this->message = $this->rawMessage;
125
-
126
- $dot = false;
127
- if ('.' === substr($this->message, -1)) {
128
- $this->message = substr($this->message, 0, -1);
129
- $dot = true;
130
- }
131
-
132
- if (null !== $this->parsedFile) {
133
- $this->message .= sprintf(' in %s', json_encode($this->parsedFile, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
134
- }
135
-
136
- if ($this->parsedLine >= 0) {
137
- $this->message .= sprintf(' at line %d', $this->parsedLine);
138
- }
139
-
140
- if ($this->snippet) {
141
- $this->message .= sprintf(' (near "%s")', $this->snippet);
142
- }
143
-
144
- if ($dot) {
145
- $this->message .= '.';
146
- }
147
- }
148
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/symfony/yaml/Symfony/Component/Yaml/Exception/RuntimeException.php DELETED
@@ -1,23 +0,0 @@
1
- <?php
2
-
3
- /*
4
- * This file is part of the Symfony package.
5
- *
6
- * (c) Fabien Potencier <fabien@symfony.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 Symfony\Component\Yaml\Exception;
13
-
14
- /**
15
- * Exception class thrown when an error occurs during parsing.
16
- *
17
- * @author Romain Neutron <imprec@gmail.com>
18
- *
19
- * @api
20
- */
21
- class RuntimeException extends \RuntimeException implements ExceptionInterface
22
- {
23
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/symfony/yaml/Symfony/Component/Yaml/Inline.php DELETED
@@ -1,487 +0,0 @@
1
- <?php
2
-
3
- /*
4
- * This file is part of the Symfony package.
5
- *
6
- * (c) Fabien Potencier <fabien@symfony.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 Symfony\Component\Yaml;
13
-
14
- use Symfony\Component\Yaml\Exception\ParseException;
15
- use Symfony\Component\Yaml\Exception\DumpException;
16
-
17
- /**
18
- * Inline implements a YAML parser/dumper for the YAML inline syntax.
19
- *
20
- * @author Fabien Potencier <fabien@symfony.com>
21
- */
22
- class Inline
23
- {
24
- const REGEX_QUOTED_STRING = '(?:"([^"\\\\]*(?:\\\\.[^"\\\\]*)*)"|\'([^\']*(?:\'\'[^\']*)*)\')';
25
-
26
- private static $exceptionOnInvalidType = false;
27
- private static $objectSupport = false;
28
-
29
- /**
30
- * Converts a YAML string to a PHP array.
31
- *
32
- * @param string $value A YAML string
33
- * @param bool $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise
34
- * @param bool $objectSupport true if object support is enabled, false otherwise
35
- *
36
- * @return array A PHP array representing the YAML string
37
- *
38
- * @throws ParseException
39
- */
40
- public static function parse($value, $exceptionOnInvalidType = false, $objectSupport = false)
41
- {
42
- self::$exceptionOnInvalidType = $exceptionOnInvalidType;
43
- self::$objectSupport = $objectSupport;
44
-
45
- $value = trim($value);
46
-
47
- if (0 == strlen($value)) {
48
- return '';
49
- }
50
-
51
- if (function_exists('mb_internal_encoding') && ((int) ini_get('mbstring.func_overload')) & 2) {
52
- $mbEncoding = mb_internal_encoding();
53
- mb_internal_encoding('ASCII');
54
- }
55
-
56
- $i = 0;
57
- switch ($value[0]) {
58
- case '[':
59
- $result = self::parseSequence($value, $i);
60
- ++$i;
61
- break;
62
- case '{':
63
- $result = self::parseMapping($value, $i);
64
- ++$i;
65
- break;
66
- default:
67
- $result = self::parseScalar($value, null, array('"', "'"), $i);
68
- }
69
-
70
- // some comments are allowed at the end
71
- if (preg_replace('/\s+#.*$/A', '', substr($value, $i))) {
72
- throw new ParseException(sprintf('Unexpected characters near "%s".', substr($value, $i)));
73
- }
74
-
75
- if (isset($mbEncoding)) {
76
- mb_internal_encoding($mbEncoding);
77
- }
78
-
79
- return $result;
80
- }
81
-
82
- /**
83
- * Dumps a given PHP variable to a YAML string.
84
- *
85
- * @param mixed $value The PHP variable to convert
86
- * @param bool $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise
87
- * @param bool $objectSupport true if object support is enabled, false otherwise
88
- *
89
- * @return string The YAML string representing the PHP array
90
- *
91
- * @throws DumpException When trying to dump PHP resource
92
- */
93
- public static function dump($value, $exceptionOnInvalidType = false, $objectSupport = false)
94
- {
95
- switch (true) {
96
- case is_resource($value):
97
- if ($exceptionOnInvalidType) {
98
- throw new DumpException(sprintf('Unable to dump PHP resources in a YAML file ("%s").', get_resource_type($value)));
99
- }
100
-
101
- return 'null';
102
- case is_object($value):
103
- if ($objectSupport) {
104
- return '!!php/object:'.serialize($value);
105
- }
106
-
107
- if ($exceptionOnInvalidType) {
108
- throw new DumpException('Object support when dumping a YAML file has been disabled.');
109
- }
110
-
111
- return 'null';
112
- case is_array($value):
113
- return self::dumpArray($value, $exceptionOnInvalidType, $objectSupport);
114
- case null === $value:
115
- return 'null';
116
- case true === $value:
117
- return 'true';
118
- case false === $value:
119
- return 'false';
120
- case ctype_digit($value):
121
- return is_string($value) ? "'$value'" : (int) $value;
122
- case is_numeric($value):
123
- $locale = setlocale(LC_NUMERIC, 0);
124
- if (false !== $locale) {
125
- setlocale(LC_NUMERIC, 'C');
126
- }
127
- $repr = is_string($value) ? "'$value'" : (is_infinite($value) ? str_ireplace('INF', '.Inf', strval($value)) : strval($value));
128
-
129
- if (false !== $locale) {
130
- setlocale(LC_NUMERIC, $locale);
131
- }
132
-
133
- return $repr;
134
- case Escaper::requiresDoubleQuoting($value):
135
- return Escaper::escapeWithDoubleQuotes($value);
136
- case Escaper::requiresSingleQuoting($value):
137
- return Escaper::escapeWithSingleQuotes($value);
138
- case '' == $value:
139
- return "''";
140
- case preg_match(self::getTimestampRegex(), $value):
141
- case in_array(strtolower($value), array('null', '~', 'true', 'false')):
142
- return "'$value'";
143
- default:
144
- return $value;
145
- }
146
- }
147
-
148
- /**
149
- * Dumps a PHP array to a YAML string.
150
- *
151
- * @param array $value The PHP array to dump
152
- * @param bool $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise
153
- * @param bool $objectSupport true if object support is enabled, false otherwise
154
- *
155
- * @return string The YAML string representing the PHP array
156
- */
157
- private static function dumpArray($value, $exceptionOnInvalidType, $objectSupport)
158
- {
159
- // array
160
- $keys = array_keys($value);
161
- if ((1 == count($keys) && '0' == $keys[0])
162
- || (count($keys) > 1 && array_reduce($keys, function ($v, $w) { return (int) $v + $w; }, 0) == count($keys) * (count($keys) - 1) / 2)
163
- ) {
164
- $output = array();
165
- foreach ($value as $val) {
166
- $output[] = self::dump($val, $exceptionOnInvalidType, $objectSupport);
167
- }
168
-
169
- return sprintf('[%s]', implode(', ', $output));
170
- }
171
-
172
- // mapping
173
- $output = array();
174
- foreach ($value as $key => $val) {
175
- $output[] = sprintf('%s: %s', self::dump($key, $exceptionOnInvalidType, $objectSupport), self::dump($val, $exceptionOnInvalidType, $objectSupport));
176
- }
177
-
178
- return sprintf('{ %s }', implode(', ', $output));
179
- }
180
-
181
- /**
182
- * Parses a scalar to a YAML string.
183
- *
184
- * @param scalar $scalar
185
- * @param string $delimiters
186
- * @param array $stringDelimiters
187
- * @param int &$i
188
- * @param bool $evaluate
189
- *
190
- * @return string A YAML string
191
- *
192
- * @throws ParseException When malformed inline YAML string is parsed
193
- */
194
- public static function parseScalar($scalar, $delimiters = null, $stringDelimiters = array('"', "'"), &$i = 0, $evaluate = true)
195
- {
196
- if (in_array($scalar[$i], $stringDelimiters)) {
197
- // quoted scalar
198
- $output = self::parseQuotedScalar($scalar, $i);
199
-
200
- if (null !== $delimiters) {
201
- $tmp = ltrim(substr($scalar, $i), ' ');
202
- if (!in_array($tmp[0], $delimiters)) {
203
- throw new ParseException(sprintf('Unexpected characters (%s).', substr($scalar, $i)));
204
- }
205
- }
206
- } else {
207
- // "normal" string
208
- if (!$delimiters) {
209
- $output = substr($scalar, $i);
210
- $i += strlen($output);
211
-
212
- // remove comments
213
- if (false !== $strpos = strpos($output, ' #')) {
214
- $output = rtrim(substr($output, 0, $strpos));
215
- }
216
- } elseif (preg_match('/^(.+?)('.implode('|', $delimiters).')/', substr($scalar, $i), $match)) {
217
- $output = $match[1];
218
- $i += strlen($output);
219
- } else {
220
- throw new ParseException(sprintf('Malformed inline YAML string (%s).', $scalar));
221
- }
222
-
223
- if ($evaluate) {
224
- $output = self::evaluateScalar($output);
225
- }
226
- }
227
-
228
- return $output;
229
- }
230
-
231
- /**
232
- * Parses a quoted scalar to YAML.
233
- *
234
- * @param string $scalar
235
- * @param int &$i
236
- *
237
- * @return string A YAML string
238
- *
239
- * @throws ParseException When malformed inline YAML string is parsed
240
- */
241
- private static function parseQuotedScalar($scalar, &$i)
242
- {
243
- if (!preg_match('/'.self::REGEX_QUOTED_STRING.'/Au', substr($scalar, $i), $match)) {
244
- throw new ParseException(sprintf('Malformed inline YAML string (%s).', substr($scalar, $i)));
245
- }
246
-
247
- $output = substr($match[0], 1, strlen($match[0]) - 2);
248
-
249
- $unescaper = new Unescaper();
250
- if ('"' == $scalar[$i]) {
251
- $output = $unescaper->unescapeDoubleQuotedString($output);
252
- } else {
253
- $output = $unescaper->unescapeSingleQuotedString($output);
254
- }
255
-
256
- $i += strlen($match[0]);
257
-
258
- return $output;
259
- }
260
-
261
- /**
262
- * Parses a sequence to a YAML string.
263
- *
264
- * @param string $sequence
265
- * @param int &$i
266
- *
267
- * @return string A YAML string
268
- *
269
- * @throws ParseException When malformed inline YAML string is parsed
270
- */
271
- private static function parseSequence($sequence, &$i = 0)
272
- {
273
- $output = array();
274
- $len = strlen($sequence);
275
- $i += 1;
276
-
277
- // [foo, bar, ...]
278
- while ($i < $len) {
279
- switch ($sequence[$i]) {
280
- case '[':
281
- // nested sequence
282
- $output[] = self::parseSequence($sequence, $i);
283
- break;
284
- case '{':
285
- // nested mapping
286
- $output[] = self::parseMapping($sequence, $i);
287
- break;
288
- case ']':
289
- return $output;
290
- case ',':
291
- case ' ':
292
- break;
293
- default:
294
- $isQuoted = in_array($sequence[$i], array('"', "'"));
295
- $value = self::parseScalar($sequence, array(',', ']'), array('"', "'"), $i);
296
-
297
- if (!$isQuoted && false !== strpos($value, ': ')) {
298
- // embedded mapping?
299
- try {
300
- $value = self::parseMapping('{'.$value.'}');
301
- } catch (\InvalidArgumentException $e) {
302
- // no, it's not
303
- }
304
- }
305
-
306
- $output[] = $value;
307
-
308
- --$i;
309
- }
310
-
311
- ++$i;
312
- }
313
-
314
- throw new ParseException(sprintf('Malformed inline YAML string %s', $sequence));
315
- }
316
-
317
- /**
318
- * Parses a mapping to a YAML string.
319
- *
320
- * @param string $mapping
321
- * @param int &$i
322
- *
323
- * @return string A YAML string
324
- *
325
- * @throws ParseException When malformed inline YAML string is parsed
326
- */
327
- private static function parseMapping($mapping, &$i = 0)
328
- {
329
- $output = array();
330
- $len = strlen($mapping);
331
- $i += 1;
332
-
333
- // {foo: bar, bar:foo, ...}
334
- while ($i < $len) {
335
- switch ($mapping[$i]) {
336
- case ' ':
337
- case ',':
338
- ++$i;
339
- continue 2;
340
- case '}':
341
- return $output;
342
- }
343
-
344
- // key
345
- $key = self::parseScalar($mapping, array(':', ' '), array('"', "'"), $i, false);
346
-
347
- // value
348
- $done = false;
349
- while ($i < $len) {
350
- switch ($mapping[$i]) {
351
- case '[':
352
- // nested sequence
353
- $value = self::parseSequence($mapping, $i);
354
- // Spec: Keys MUST be unique; first one wins.
355
- // Parser cannot abort this mapping earlier, since lines
356
- // are processed sequentially.
357
- if (!isset($output[$key])) {
358
- $output[$key] = $value;
359
- }
360
- $done = true;
361
- break;
362
- case '{':
363
- // nested mapping
364
- $value = self::parseMapping($mapping, $i);
365
- // Spec: Keys MUST be unique; first one wins.
366
- // Parser cannot abort this mapping earlier, since lines
367
- // are processed sequentially.
368
- if (!isset($output[$key])) {
369
- $output[$key] = $value;
370
- }
371
- $done = true;
372
- break;
373
- case ':':
374
- case ' ':
375
- break;
376
- default:
377
- $value = self::parseScalar($mapping, array(',', '}'), array('"', "'"), $i);
378
- // Spec: Keys MUST be unique; first one wins.
379
- // Parser cannot abort this mapping earlier, since lines
380
- // are processed sequentially.
381
- if (!isset($output[$key])) {
382
- $output[$key] = $value;
383
- }
384
- $done = true;
385
- --$i;
386
- }
387
-
388
- ++$i;
389
-
390
- if ($done) {
391
- continue 2;
392
- }
393
- }
394
- }
395
-
396
- throw new ParseException(sprintf('Malformed inline YAML string %s', $mapping));
397
- }
398
-
399
- /**
400
- * Evaluates scalars and replaces magic values.
401
- *
402
- * @param string $scalar
403
- *
404
- * @return string A YAML string
405
- */
406
- private static function evaluateScalar($scalar)
407
- {
408
- $scalar = trim($scalar);
409
- $scalarLower = strtolower($scalar);
410
- switch (true) {
411
- case 'null' === $scalarLower:
412
- case '' === $scalar:
413
- case '~' === $scalar:
414
- return;
415
- case 'true' === $scalarLower:
416
- return true;
417
- case 'false' === $scalarLower:
418
- return false;
419
- // Optimise for returning strings.
420
- case $scalar[0] === '+' || $scalar[0] === '-' || $scalar[0] === '.' || $scalar[0] === '!' || is_numeric($scalar[0]):
421
- switch (true) {
422
- case 0 === strpos($scalar, '!str'):
423
- return (string) substr($scalar, 5);
424
- case 0 === strpos($scalar, '! '):
425
- return intval(self::parseScalar(substr($scalar, 2)));
426
- case 0 === strpos($scalar, '!!php/object:'):
427
- if (self::$objectSupport) {
428
- return unserialize(substr($scalar, 13));
429
- }
430
-
431
- if (self::$exceptionOnInvalidType) {
432
- throw new ParseException('Object support when parsing a YAML file has been disabled.');
433
- }
434
-
435
- return;
436
- case ctype_digit($scalar):
437
- $raw = $scalar;
438
- $cast = intval($scalar);
439
-
440
- return '0' == $scalar[0] ? octdec($scalar) : (((string) $raw == (string) $cast) ? $cast : $raw);
441
- case '-' === $scalar[0] && ctype_digit(substr($scalar, 1)):
442
- $raw = $scalar;
443
- $cast = intval($scalar);
444
-
445
- return '0' == $scalar[1] ? octdec($scalar) : (((string) $raw == (string) $cast) ? $cast : $raw);
446
- case is_numeric($scalar):
447
- return '0x' == $scalar[0].$scalar[1] ? hexdec($scalar) : floatval($scalar);
448
- case '.inf' === $scalarLower:
449
- case '.nan' === $scalarLower:
450
- return -log(0);
451
- case '-.inf' === $scalarLower:
452
- return log(0);
453
- case preg_match('/^(-|\+)?[0-9,]+(\.[0-9]+)?$/', $scalar):
454
- return floatval(str_replace(',', '', $scalar));
455
- case preg_match(self::getTimestampRegex(), $scalar):
456
- return strtotime($scalar);
457
- }
458
- default:
459
- return (string) $scalar;
460
- }
461
- }
462
-
463
- /**
464
- * Gets a regex that matches a YAML date.
465
- *
466
- * @return string The regular expression
467
- *
468
- * @see http://www.yaml.org/spec/1.2/spec.html#id2761573
469
- */
470
- private static function getTimestampRegex()
471
- {
472
- return <<<EOF
473
- ~^
474
- (?P<year>[0-9][0-9][0-9][0-9])
475
- -(?P<month>[0-9][0-9]?)
476
- -(?P<day>[0-9][0-9]?)
477
- (?:(?:[Tt]|[ \t]+)
478
- (?P<hour>[0-9][0-9]?)
479
- :(?P<minute>[0-9][0-9])
480
- :(?P<second>[0-9][0-9])
481
- (?:\.(?P<fraction>[0-9]*))?
482
- (?:[ \t]*(?P<tz>Z|(?P<tz_sign>[-+])(?P<tz_hour>[0-9][0-9]?)
483
- (?::(?P<tz_minute>[0-9][0-9]))?))?)?
484
- $~x
485
- EOF;
486
- }
487
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/symfony/yaml/Symfony/Component/Yaml/LICENSE DELETED
@@ -1,19 +0,0 @@
1
- Copyright (c) 2004-2014 Fabien Potencier
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining a copy
4
- of this software and associated documentation files (the "Software"), to deal
5
- in the Software without restriction, including without limitation the rights
6
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- copies of the Software, and to permit persons to whom the Software is furnished
8
- to do so, subject to the following conditions:
9
-
10
- The above copyright notice and this permission notice shall be included in all
11
- copies or substantial portions of the Software.
12
-
13
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
- THE SOFTWARE.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/symfony/yaml/Symfony/Component/Yaml/Parser.php DELETED
@@ -1,655 +0,0 @@
1
- <?php
2
-
3
- /*
4
- * This file is part of the Symfony package.
5
- *
6
- * (c) Fabien Potencier <fabien@symfony.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 Symfony\Component\Yaml;
13
-
14
- use Symfony\Component\Yaml\Exception\ParseException;
15
-
16
- /**
17
- * Parser parses YAML strings to convert them to PHP arrays.
18
- *
19
- * @author Fabien Potencier <fabien@symfony.com>
20
- */
21
- class Parser
22
- {
23
- const FOLDED_SCALAR_PATTERN = '(?P<separator>\||>)(?P<modifiers>\+|\-|\d+|\+\d+|\-\d+|\d+\+|\d+\-)?(?P<comments> +#.*)?';
24
-
25
- private $offset = 0;
26
- private $lines = array();
27
- private $currentLineNb = -1;
28
- private $currentLine = '';
29
- private $refs = array();
30
-
31
- /**
32
- * Constructor
33
- *
34
- * @param int $offset The offset of YAML document (used for line numbers in error messages)
35
- */
36
- public function __construct($offset = 0)
37
- {
38
- $this->offset = $offset;
39
- }
40
-
41
- /**
42
- * Parses a YAML string to a PHP value.
43
- *
44
- * @param string $value A YAML string
45
- * @param bool $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise
46
- * @param bool $objectSupport true if object support is enabled, false otherwise
47
- *
48
- * @return mixed A PHP value
49
- *
50
- * @throws ParseException If the YAML is not valid
51
- */
52
- public function parse($value, $exceptionOnInvalidType = false, $objectSupport = false)
53
- {
54
- $this->currentLineNb = -1;
55
- $this->currentLine = '';
56
- $this->lines = explode("\n", $this->cleanup($value));
57
-
58
- if (!preg_match('//u', $value)) {
59
- throw new ParseException('The YAML value does not appear to be valid UTF-8.');
60
- }
61
-
62
- if (function_exists('mb_internal_encoding') && ((int) ini_get('mbstring.func_overload')) & 2) {
63
- $mbEncoding = mb_internal_encoding();
64
- mb_internal_encoding('UTF-8');
65
- }
66
-
67
- $data = array();
68
- $context = null;
69
- while ($this->moveToNextLine()) {
70
- if ($this->isCurrentLineEmpty()) {
71
- continue;
72
- }
73
-
74
- // tab?
75
- if ("\t" === $this->currentLine[0]) {
76
- throw new ParseException('A YAML file cannot contain tabs as indentation.', $this->getRealCurrentLineNb() + 1, $this->currentLine);
77
- }
78
-
79
- $isRef = $isInPlace = $isProcessed = false;
80
- if (preg_match('#^\-((?P<leadspaces>\s+)(?P<value>.+?))?\s*$#u', $this->currentLine, $values)) {
81
- if ($context && 'mapping' == $context) {
82
- throw new ParseException('You cannot define a sequence item when in a mapping');
83
- }
84
- $context = 'sequence';
85
-
86
- if (isset($values['value']) && preg_match('#^&(?P<ref>[^ ]+) *(?P<value>.*)#u', $values['value'], $matches)) {
87
- $isRef = $matches['ref'];
88
- $values['value'] = $matches['value'];
89
- }
90
-
91
- // array
92
- if (!isset($values['value']) || '' == trim($values['value'], ' ') || 0 === strpos(ltrim($values['value'], ' '), '#')) {
93
- $c = $this->getRealCurrentLineNb() + 1;
94
- $parser = new Parser($c);
95
- $parser->refs =& $this->refs;
96
- $data[] = $parser->parse($this->getNextEmbedBlock(), $exceptionOnInvalidType, $objectSupport);
97
- } else {
98
- if (isset($values['leadspaces'])
99
- && ' ' == $values['leadspaces']
100
- && preg_match('#^(?P<key>'.Inline::REGEX_QUOTED_STRING.'|[^ \'"\{\[].*?) *\:(\s+(?P<value>.+?))?\s*$#u', $values['value'], $matches)
101
- ) {
102
- // this is a compact notation element, add to next block and parse
103
- $c = $this->getRealCurrentLineNb();
104
- $parser = new Parser($c);
105
- $parser->refs =& $this->refs;
106
-
107
- $block = $values['value'];
108
- if ($this->isNextLineIndented()) {
109
- $block .= "\n".$this->getNextEmbedBlock($this->getCurrentLineIndentation() + 2);
110
- }
111
-
112
- $data[] = $parser->parse($block, $exceptionOnInvalidType, $objectSupport);
113
- } else {
114
- $data[] = $this->parseValue($values['value'], $exceptionOnInvalidType, $objectSupport);
115
- }
116
- }
117
- } elseif (preg_match('#^(?P<key>'.Inline::REGEX_QUOTED_STRING.'|[^ \'"\[\{].*?) *\:(\s+(?P<value>.+?))?\s*$#u', $this->currentLine, $values) && false === strpos($values['key'],' #')) {
118
- if ($context && 'sequence' == $context) {
119
- throw new ParseException('You cannot define a mapping item when in a sequence');
120
- }
121
- $context = 'mapping';
122
-
123
- // force correct settings
124
- Inline::parse(null, $exceptionOnInvalidType, $objectSupport);
125
- try {
126
- $key = Inline::parseScalar($values['key']);
127
- } catch (ParseException $e) {
128
- $e->setParsedLine($this->getRealCurrentLineNb() + 1);
129
- $e->setSnippet($this->currentLine);
130
-
131
- throw $e;
132
- }
133
-
134
- if ('<<' === $key) {
135
- if (isset($values['value']) && 0 === strpos($values['value'], '*')) {
136
- $isInPlace = substr($values['value'], 1);
137
- if (!array_key_exists($isInPlace, $this->refs)) {
138
- throw new ParseException(sprintf('Reference "%s" does not exist.', $isInPlace), $this->getRealCurrentLineNb() + 1, $this->currentLine);
139
- }
140
- } else {
141
- if (isset($values['value']) && $values['value'] !== '') {
142
- $value = $values['value'];
143
- } else {
144
- $value = $this->getNextEmbedBlock();
145
- }
146
- $c = $this->getRealCurrentLineNb() + 1;
147
- $parser = new Parser($c);
148
- $parser->refs =& $this->refs;
149
- $parsed = $parser->parse($value, $exceptionOnInvalidType, $objectSupport);
150
-
151
- $merged = array();
152
- if (!is_array($parsed)) {
153
- throw new ParseException('YAML merge keys used with a scalar value instead of an array.', $this->getRealCurrentLineNb() + 1, $this->currentLine);
154
- } elseif (isset($parsed[0])) {
155
- // Numeric array, merge individual elements
156
- foreach (array_reverse($parsed) as $parsedItem) {
157
- if (!is_array($parsedItem)) {
158
- throw new ParseException('Merge items must be arrays.', $this->getRealCurrentLineNb() + 1, $parsedItem);
159
- }
160
- $merged = array_merge($parsedItem, $merged);
161
- }
162
- } else {
163
- // Associative array, merge
164
- $merged = array_merge($merged, $parsed);
165
- }
166
-
167
- $isProcessed = $merged;
168
- }
169
- } elseif (isset($values['value']) && preg_match('#^&(?P<ref>[^ ]+) *(?P<value>.*)#u', $values['value'], $matches)) {
170
- $isRef = $matches['ref'];
171
- $values['value'] = $matches['value'];
172
- }
173
-
174
- if ($isProcessed) {
175
- // Merge keys
176
- $data = $isProcessed;
177
- // hash
178
- } elseif (!isset($values['value']) || '' == trim($values['value'], ' ') || 0 === strpos(ltrim($values['value'], ' '), '#')) {
179
- // if next line is less indented or equal, then it means that the current value is null
180
- if (!$this->isNextLineIndented() && !$this->isNextLineUnIndentedCollection()) {
181
- // Spec: Keys MUST be unique; first one wins.
182
- // Parser cannot abort this mapping earlier, since lines
183
- // are processed sequentially.
184
- if (!isset($data[$key])) {
185
- $data[$key] = null;
186
- }
187
- } else {
188
- $c = $this->getRealCurrentLineNb() + 1;
189
- $parser = new Parser($c);
190
- $parser->refs =& $this->refs;
191
- $value = $parser->parse($this->getNextEmbedBlock(), $exceptionOnInvalidType, $objectSupport);
192
- // Spec: Keys MUST be unique; first one wins.
193
- // Parser cannot abort this mapping earlier, since lines
194
- // are processed sequentially.
195
- if (!isset($data[$key])) {
196
- $data[$key] = $value;
197
- }
198
- }
199
- } else {
200
- if ($isInPlace) {
201
- $data = $this->refs[$isInPlace];
202
- } else {
203
- $value = $this->parseValue($values['value'], $exceptionOnInvalidType, $objectSupport);;
204
- // Spec: Keys MUST be unique; first one wins.
205
- // Parser cannot abort this mapping earlier, since lines
206
- // are processed sequentially.
207
- if (!isset($data[$key])) {
208
- $data[$key] = $value;
209
- }
210
- }
211
- }
212
- } else {
213
- // 1-liner optionally followed by newline
214
- $lineCount = count($this->lines);
215
- if (1 === $lineCount || (2 === $lineCount && empty($this->lines[1]))) {
216
- try {
217
- $value = Inline::parse($this->lines[0], $exceptionOnInvalidType, $objectSupport);
218
- } catch (ParseException $e) {
219
- $e->setParsedLine($this->getRealCurrentLineNb() + 1);
220
- $e->setSnippet($this->currentLine);
221
-
222
- throw $e;
223
- }
224
-
225
- if (is_array($value)) {
226
- $first = reset($value);
227
- if (is_string($first) && 0 === strpos($first, '*')) {
228
- $data = array();
229
- foreach ($value as $alias) {
230
- $data[] = $this->refs[substr($alias, 1)];
231
- }
232
- $value = $data;
233
- }
234
- }
235
-
236
- if (isset($mbEncoding)) {
237
- mb_internal_encoding($mbEncoding);
238
- }
239
-
240
- return $value;
241
- }
242
-
243
- switch (preg_last_error()) {
244
- case PREG_INTERNAL_ERROR:
245
- $error = 'Internal PCRE error.';
246
- break;
247
- case PREG_BACKTRACK_LIMIT_ERROR:
248
- $error = 'pcre.backtrack_limit reached.';
249
- break;
250
- case PREG_RECURSION_LIMIT_ERROR:
251
- $error = 'pcre.recursion_limit reached.';
252
- break;
253
- case PREG_BAD_UTF8_ERROR:
254
- $error = 'Malformed UTF-8 data.';
255
- break;
256
- case PREG_BAD_UTF8_OFFSET_ERROR:
257
- $error = 'Offset doesn\'t correspond to the begin of a valid UTF-8 code point.';
258
- break;
259
- default:
260
- $error = 'Unable to parse.';
261
- }
262
-
263
- throw new ParseException($error, $this->getRealCurrentLineNb() + 1, $this->currentLine);
264
- }
265
-
266
- if ($isRef) {
267
- $this->refs[$isRef] = end($data);
268
- }
269
- }
270
-
271
- if (isset($mbEncoding)) {
272
- mb_internal_encoding($mbEncoding);
273
- }
274
-
275
- return empty($data) ? null : $data;
276
- }
277
-
278
- /**
279
- * Returns the current line number (takes the offset into account).
280
- *
281
- * @return int The current line number
282
- */
283
- private function getRealCurrentLineNb()
284
- {
285
- return $this->currentLineNb + $this->offset;
286
- }
287
-
288
- /**
289
- * Returns the current line indentation.
290
- *
291
- * @return int The current line indentation
292
- */
293
- private function getCurrentLineIndentation()
294
- {
295
- return strlen($this->currentLine) - strlen(ltrim($this->currentLine, ' '));
296
- }
297
-
298
- /**
299
- * Returns the next embed block of YAML.
300
- *
301
- * @param int $indentation The indent level at which the block is to be read, or null for default
302
- *
303
- * @return string A YAML string
304
- *
305
- * @throws ParseException When indentation problem are detected
306
- */
307
- private function getNextEmbedBlock($indentation = null)
308
- {
309
- $this->moveToNextLine();
310
-
311
- if (null === $indentation) {
312
- $newIndent = $this->getCurrentLineIndentation();
313
-
314
- $unindentedEmbedBlock = $this->isStringUnIndentedCollectionItem($this->currentLine);
315
-
316
- if (!$this->isCurrentLineEmpty() && 0 === $newIndent && !$unindentedEmbedBlock) {
317
- throw new ParseException('Indentation problem.', $this->getRealCurrentLineNb() + 1, $this->currentLine);
318
- }
319
- } else {
320
- $newIndent = $indentation;
321
- }
322
-
323
- $data = array(substr($this->currentLine, $newIndent));
324
-
325
- $isItUnindentedCollection = $this->isStringUnIndentedCollectionItem($this->currentLine);
326
-
327
- // Comments must not be removed inside a string block (ie. after a line ending with "|")
328
- $removeCommentsPattern = '~'.self::FOLDED_SCALAR_PATTERN.'$~';
329
- $removeComments = !preg_match($removeCommentsPattern, $this->currentLine);
330
-
331
- while ($this->moveToNextLine()) {
332
- $indent = $this->getCurrentLineIndentation();
333
-
334
- if ($indent === $newIndent) {
335
- $removeComments = !preg_match($removeCommentsPattern, $this->currentLine);
336
- }
337
-
338
- if ($isItUnindentedCollection && !$this->isStringUnIndentedCollectionItem($this->currentLine)) {
339
- $this->moveToPreviousLine();
340
- break;
341
- }
342
-
343
- if ($this->isCurrentLineBlank()) {
344
- $data[] = substr($this->currentLine, $newIndent);
345
- continue;
346
- }
347
-
348
- if ($removeComments && $this->isCurrentLineComment()) {
349
- continue;
350
- }
351
-
352
- if ($indent >= $newIndent) {
353
- $data[] = substr($this->currentLine, $newIndent);
354
- } elseif (0 == $indent) {
355
- $this->moveToPreviousLine();
356
-
357
- break;
358
- } else {
359
- throw new ParseException('Indentation problem.', $this->getRealCurrentLineNb() + 1, $this->currentLine);
360
- }
361
- }
362
-
363
- return implode("\n", $data);
364
- }
365
-
366
- /**
367
- * Moves the parser to the next line.
368
- *
369
- * @return bool
370
- */
371
- private function moveToNextLine()
372
- {
373
- if ($this->currentLineNb >= count($this->lines) - 1) {
374
- return false;
375
- }
376
-
377
- $this->currentLine = $this->lines[++$this->currentLineNb];
378
-
379
- return true;
380
- }
381
-
382
- /**
383
- * Moves the parser to the previous line.
384
- */
385
- private function moveToPreviousLine()
386
- {
387
- $this->currentLine = $this->lines[--$this->currentLineNb];
388
- }
389
-
390
- /**
391
- * Parses a YAML value.
392
- *
393
- * @param string $value A YAML value
394
- * @param bool $exceptionOnInvalidType True if an exception must be thrown on invalid types false otherwise
395
- * @param bool $objectSupport True if object support is enabled, false otherwise
396
- *
397
- * @return mixed A PHP value
398
- *
399
- * @throws ParseException When reference does not exist
400
- */
401
- private function parseValue($value, $exceptionOnInvalidType, $objectSupport)
402
- {
403
- if (0 === strpos($value, '*')) {
404
- if (false !== $pos = strpos($value, '#')) {
405
- $value = substr($value, 1, $pos - 2);
406
- } else {
407
- $value = substr($value, 1);
408
- }
409
-
410
- if (!array_key_exists($value, $this->refs)) {
411
- throw new ParseException(sprintf('Reference "%s" does not exist.', $value), $this->currentLine);
412
- }
413
-
414
- return $this->refs[$value];
415
- }
416
-
417
- if (preg_match('/^'.self::FOLDED_SCALAR_PATTERN.'$/', $value, $matches)) {
418
- $modifiers = isset($matches['modifiers']) ? $matches['modifiers'] : '';
419
-
420
- return $this->parseFoldedScalar($matches['separator'], preg_replace('#\d+#', '', $modifiers), intval(abs($modifiers)));
421
- }
422
-
423
- try {
424
- return Inline::parse($value, $exceptionOnInvalidType, $objectSupport);
425
- } catch (ParseException $e) {
426
- $e->setParsedLine($this->getRealCurrentLineNb() + 1);
427
- $e->setSnippet($this->currentLine);
428
-
429
- throw $e;
430
- }
431
- }
432
-
433
- /**
434
- * Parses a folded scalar.
435
- *
436
- * @param string $separator The separator that was used to begin this folded scalar (| or >)
437
- * @param string $indicator The indicator that was used to begin this folded scalar (+ or -)
438
- * @param int $indentation The indentation that was used to begin this folded scalar
439
- *
440
- * @return string The text value
441
- */
442
- private function parseFoldedScalar($separator, $indicator = '', $indentation = 0)
443
- {
444
- $notEOF = $this->moveToNextLine();
445
- if (!$notEOF) {
446
- return '';
447
- }
448
-
449
- $isCurrentLineBlank = $this->isCurrentLineBlank();
450
- $text = '';
451
-
452
- // leading blank lines are consumed before determining indentation
453
- while ($notEOF && $isCurrentLineBlank) {
454
- // newline only if not EOF
455
- if ($notEOF = $this->moveToNextLine()) {
456
- $text .= "\n";
457
- $isCurrentLineBlank = $this->isCurrentLineBlank();
458
- }
459
- }
460
-
461
- // determine indentation if not specified
462
- if (0 === $indentation) {
463
- if (preg_match('/^ +/', $this->currentLine, $matches)) {
464
- $indentation = strlen($matches[0]);
465
- }
466
- }
467
-
468
- if ($indentation > 0) {
469
- $pattern = sprintf('/^ {%d}(.*)$/', $indentation);
470
-
471
- while (
472
- $notEOF && (
473
- $isCurrentLineBlank ||
474
- preg_match($pattern, $this->currentLine, $matches)
475
- )
476
- ) {
477
- if ($isCurrentLineBlank) {
478
- $text .= substr($this->currentLine, $indentation);
479
- } else {
480
- $text .= $matches[1];
481
- }
482
-
483
- // newline only if not EOF
484
- if ($notEOF = $this->moveToNextLine()) {
485
- $text .= "\n";
486
- $isCurrentLineBlank = $this->isCurrentLineBlank();
487
- }
488
- }
489
- } elseif ($notEOF) {
490
- $text .= "\n";
491
- }
492
-
493
- if ($notEOF) {
494
- $this->moveToPreviousLine();
495
- }
496
-
497
- // replace all non-trailing single newlines with spaces in folded blocks
498
- if ('>' === $separator) {
499
- preg_match('/(\n*)$/', $text, $matches);
500
- $text = preg_replace('/(?<!\n)\n(?!\n)/', ' ', rtrim($text, "\n"));
501
- $text .= $matches[1];
502
- }
503
-
504
- // deal with trailing newlines as indicated
505
- if ('' === $indicator) {
506
- $text = preg_replace('/\n+$/s', "\n", $text);
507
- } elseif ('-' === $indicator) {
508
- $text = preg_replace('/\n+$/s', '', $text);
509
- }
510
-
511
- return $text;
512
- }
513
-
514
- /**
515
- * Returns true if the next line is indented.
516
- *
517
- * @return bool Returns true if the next line is indented, false otherwise
518
- */
519
- private function isNextLineIndented()
520
- {
521
- $currentIndentation = $this->getCurrentLineIndentation();
522
- $EOF = !$this->moveToNextLine();
523
-
524
- while (!$EOF && $this->isCurrentLineEmpty()) {
525
- $EOF = !$this->moveToNextLine();
526
- }
527
-
528
- if ($EOF) {
529
- return false;
530
- }
531
-
532
- $ret = false;
533
- if ($this->getCurrentLineIndentation() > $currentIndentation) {
534
- $ret = true;
535
- }
536
-
537
- $this->moveToPreviousLine();
538
-
539
- return $ret;
540
- }
541
-
542
- /**
543
- * Returns true if the current line is blank or if it is a comment line.
544
- *
545
- * @return bool Returns true if the current line is empty or if it is a comment line, false otherwise
546
- */
547
- private function isCurrentLineEmpty()
548
- {
549
- return $this->isCurrentLineBlank() || $this->isCurrentLineComment();
550
- }
551
-
552
- /**
553
- * Returns true if the current line is blank.
554
- *
555
- * @return bool Returns true if the current line is blank, false otherwise
556
- */
557
- private function isCurrentLineBlank()
558
- {
559
- return '' == trim($this->currentLine, ' ');
560
- }
561
-
562
- /**
563
- * Returns true if the current line is a comment line.
564
- *
565
- * @return bool Returns true if the current line is a comment line, false otherwise
566
- */
567
- private function isCurrentLineComment()
568
- {
569
- //checking explicitly the first char of the trim is faster than loops or strpos
570
- $ltrimmedLine = ltrim($this->currentLine, ' ');
571
-
572
- return $ltrimmedLine[0] === '#';
573
- }
574
-
575
- /**
576
- * Cleanups a YAML string to be parsed.
577
- *
578
- * @param string $value The input YAML string
579
- *
580
- * @return string A cleaned up YAML string
581
- */
582
- private function cleanup($value)
583
- {
584
- $value = str_replace(array("\r\n", "\r"), "\n", $value);
585
-
586
- // strip YAML header
587
- $count = 0;
588
- $value = preg_replace('#^\%YAML[: ][\d\.]+.*\n#su', '', $value, -1, $count);
589
- $this->offset += $count;
590
-
591
- // remove leading comments
592
- $trimmedValue = preg_replace('#^(\#.*?\n)+#s', '', $value, -1, $count);
593
- if ($count == 1) {
594
- // items have been removed, update the offset
595
- $this->offset += substr_count($value, "\n") - substr_count($trimmedValue, "\n");
596
- $value = $trimmedValue;
597
- }
598
-
599
- // remove start of the document marker (---)
600
- $trimmedValue = preg_replace('#^\-\-\-.*?\n#s', '', $value, -1, $count);
601
- if ($count == 1) {
602
- // items have been removed, update the offset
603
- $this->offset += substr_count($value, "\n") - substr_count($trimmedValue, "\n");
604
- $value = $trimmedValue;
605
-
606
- // remove end of the document marker (...)
607
- $value = preg_replace('#\.\.\.\s*$#s', '', $value);
608
- }
609
-
610
- return $value;
611
- }
612
-
613
- /**
614
- * Returns true if the next line starts unindented collection
615
- *
616
- * @return bool Returns true if the next line starts unindented collection, false otherwise
617
- */
618
- private function isNextLineUnIndentedCollection()
619
- {
620
- $currentIndentation = $this->getCurrentLineIndentation();
621
- $notEOF = $this->moveToNextLine();
622
-
623
- while ($notEOF && $this->isCurrentLineEmpty()) {
624
- $notEOF = $this->moveToNextLine();
625
- }
626
-
627
- if (false === $notEOF) {
628
- return false;
629
- }
630
-
631
- $ret = false;
632
- if (
633
- $this->getCurrentLineIndentation() == $currentIndentation
634
- &&
635
- $this->isStringUnIndentedCollectionItem($this->currentLine)
636
- ) {
637
- $ret = true;
638
- }
639
-
640
- $this->moveToPreviousLine();
641
-
642
- return $ret;
643
- }
644
-
645
- /**
646
- * Returns true if the string is un-indented collection item
647
- *
648
- * @return bool Returns true if the string is un-indented collection item, false otherwise
649
- */
650
- private function isStringUnIndentedCollectionItem()
651
- {
652
- return (0 === strpos($this->currentLine, '- '));
653
- }
654
-
655
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/symfony/yaml/Symfony/Component/Yaml/README.md DELETED
@@ -1,19 +0,0 @@
1
- Yaml Component
2
- ==============
3
-
4
- YAML implements most of the YAML 1.2 specification.
5
-
6
- use Symfony\Component\Yaml\Yaml;
7
-
8
- $array = Yaml::parse($file);
9
-
10
- print Yaml::dump($array);
11
-
12
- Resources
13
- ---------
14
-
15
- You can run the unit tests with the following command:
16
-
17
- $ cd path/to/Symfony/Component/Yaml/
18
- $ composer.phar install
19
- $ phpunit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/DumperTest.php DELETED
@@ -1,207 +0,0 @@
1
- <?php
2
-
3
- /*
4
- * This file is part of the Symfony package.
5
- *
6
- * (c) Fabien Potencier <fabien@symfony.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 Symfony\Component\Yaml\Tests;
13
-
14
- use Symfony\Component\Yaml\Yaml;
15
- use Symfony\Component\Yaml\Parser;
16
- use Symfony\Component\Yaml\Dumper;
17
-
18
- class DumperTest extends \PHPUnit_Framework_TestCase
19
- {
20
- protected $parser;
21
- protected $dumper;
22
- protected $path;
23
-
24
- protected $array = array(
25
- '' => 'bar',
26
- 'foo' => '#bar',
27
- 'foo\'bar' => array(),
28
- 'bar' => array(1, 'foo'),
29
- 'foobar' => array(
30
- 'foo' => 'bar',
31
- 'bar' => array(1, 'foo'),
32
- 'foobar' => array(
33
- 'foo' => 'bar',
34
- 'bar' => array(1, 'foo'),
35
- ),
36
- ),
37
- );
38
-
39
- protected function setUp()
40
- {
41
- $this->parser = new Parser();
42
- $this->dumper = new Dumper();
43
- $this->path = __DIR__.'/Fixtures';
44
- }
45
-
46
- protected function tearDown()
47
- {
48
- $this->parser = null;
49
- $this->dumper = null;
50
- $this->path = null;
51
- $this->array = null;
52
- }
53
-
54
- public function testSetIndentation()
55
- {
56
- $this->dumper->setIndentation(7);
57
-
58
- $expected = <<<EOF
59
- '': bar
60
- foo: '#bar'
61
- 'foo''bar': { }
62
- bar:
63
- - 1
64
- - foo
65
- foobar:
66
- foo: bar
67
- bar:
68
- - 1
69
- - foo
70
- foobar:
71
- foo: bar
72
- bar:
73
- - 1
74
- - foo
75
-
76
- EOF;
77
- $this->assertEquals($expected, $this->dumper->dump($this->array, 4, 0));
78
- }
79
-
80
- public function testSpecifications()
81
- {
82
- $files = $this->parser->parse(file_get_contents($this->path.'/index.yml'));
83
- foreach ($files as $file) {
84
- $yamls = file_get_contents($this->path.'/'.$file.'.yml');
85
-
86
- // split YAMLs documents
87
- foreach (preg_split('/^---( %YAML\:1\.0)?/m', $yamls) as $yaml) {
88
- if (!$yaml) {
89
- continue;
90
- }
91
-
92
- $test = $this->parser->parse($yaml);
93
- if (isset($test['dump_skip']) && $test['dump_skip']) {
94
- continue;
95
- } elseif (isset($test['todo']) && $test['todo']) {
96
- // TODO
97
- } else {
98
- eval('$expected = '.trim($test['php']).';');
99
-
100
- $this->assertEquals($expected, $this->parser->parse($this->dumper->dump($expected, 10)), $test['test']);
101
- }
102
- }
103
- }
104
- }
105
-
106
- public function testInlineLevel()
107
- {
108
- $expected = <<<EOF
109
- { '': bar, foo: '#bar', 'foo''bar': { }, bar: [1, foo], foobar: { foo: bar, bar: [1, foo], foobar: { foo: bar, bar: [1, foo] } } }
110
- EOF;
111
- $this->assertEquals($expected, $this->dumper->dump($this->array, -10), '->dump() takes an inline level argument');
112
- $this->assertEquals($expected, $this->dumper->dump($this->array, 0), '->dump() takes an inline level argument');
113
-
114
- $expected = <<<EOF
115
- '': bar
116
- foo: '#bar'
117
- 'foo''bar': { }
118
- bar: [1, foo]
119
- foobar: { foo: bar, bar: [1, foo], foobar: { foo: bar, bar: [1, foo] } }
120
-
121
- EOF;
122
- $this->assertEquals($expected, $this->dumper->dump($this->array, 1), '->dump() takes an inline level argument');
123
-
124
- $expected = <<<EOF
125
- '': bar
126
- foo: '#bar'
127
- 'foo''bar': { }
128
- bar:
129
- - 1
130
- - foo
131
- foobar:
132
- foo: bar
133
- bar: [1, foo]
134
- foobar: { foo: bar, bar: [1, foo] }
135
-
136
- EOF;
137
- $this->assertEquals($expected, $this->dumper->dump($this->array, 2), '->dump() takes an inline level argument');
138
-
139
- $expected = <<<EOF
140
- '': bar
141
- foo: '#bar'
142
- 'foo''bar': { }
143
- bar:
144
- - 1
145
- - foo
146
- foobar:
147
- foo: bar
148
- bar:
149
- - 1
150
- - foo
151
- foobar:
152
- foo: bar
153
- bar: [1, foo]
154
-
155
- EOF;
156
- $this->assertEquals($expected, $this->dumper->dump($this->array, 3), '->dump() takes an inline level argument');
157
-
158
- $expected = <<<EOF
159
- '': bar
160
- foo: '#bar'
161
- 'foo''bar': { }
162
- bar:
163
- - 1
164
- - foo
165
- foobar:
166
- foo: bar
167
- bar:
168
- - 1
169
- - foo
170
- foobar:
171
- foo: bar
172
- bar:
173
- - 1
174
- - foo
175
-
176
- EOF;
177
- $this->assertEquals($expected, $this->dumper->dump($this->array, 4), '->dump() takes an inline level argument');
178
- $this->assertEquals($expected, $this->dumper->dump($this->array, 10), '->dump() takes an inline level argument');
179
- }
180
-
181
- public function testObjectSupportEnabled()
182
- {
183
- $dump = $this->dumper->dump(array('foo' => new A(), 'bar' => 1), 0, 0, false, true);
184
-
185
- $this->assertEquals('{ foo: !!php/object:O:30:"Symfony\Component\Yaml\Tests\A":1:{s:1:"a";s:3:"foo";}, bar: 1 }', $dump, '->dump() is able to dump objects');
186
- }
187
-
188
- public function testObjectSupportDisabledButNoExceptions()
189
- {
190
- $dump = $this->dumper->dump(array('foo' => new A(), 'bar' => 1));
191
-
192
- $this->assertEquals('{ foo: null, bar: 1 }', $dump, '->dump() does not dump objects when disabled');
193
- }
194
-
195
- /**
196
- * @expectedException \Symfony\Component\Yaml\Exception\DumpException
197
- */
198
- public function testObjectSupportDisabledWithExceptions()
199
- {
200
- $this->dumper->dump(array('foo' => new A(), 'bar' => 1), 0, 0, true, false);
201
- }
202
- }
203
-
204
- class A
205
- {
206
- public $a = 'foo';
207
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/YtsAnchorAlias.yml DELETED
@@ -1,31 +0,0 @@
1
- --- %YAML:1.0
2
- test: Simple Alias Example
3
- brief: >
4
- If you need to refer to the same item of data twice,
5
- you can give that item an alias. The alias is a plain
6
- string, starting with an ampersand. The item may then
7
- be referred to by the alias throughout your document
8
- by using an asterisk before the name of the alias.
9
- This is called an anchor.
10
- yaml: |
11
- - &showell Steve
12
- - Clark
13
- - Brian
14
- - Oren
15
- - *showell
16
- php: |
17
- array('Steve', 'Clark', 'Brian', 'Oren', 'Steve')
18
-
19
- ---
20
- test: Alias of a Mapping
21
- brief: >
22
- An alias can be used on any item of data, including
23
- sequences, mappings, and other complex data types.
24
- yaml: |
25
- - &hello
26
- Meat: pork
27
- Starch: potato
28
- - banana
29
- - *hello
30
- php: |
31
- array(array('Meat'=>'pork', 'Starch'=>'potato'), 'banana', array('Meat'=>'pork', 'Starch'=>'potato'))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/YtsBasicTests.yml DELETED
@@ -1,178 +0,0 @@
1
- --- %YAML:1.0
2
- test: Simple Sequence
3
- brief: |
4
- You can specify a list in YAML by placing each
5
- member of the list on a new line with an opening
6
- dash. These lists are called sequences.
7
- yaml: |
8
- - apple
9
- - banana
10
- - carrot
11
- php: |
12
- array('apple', 'banana', 'carrot')
13
- ---
14
- test: Nested Sequences
15
- brief: |
16
- You can include a sequence within another
17
- sequence by giving the sequence an empty
18
- dash, followed by an indented list.
19
- yaml: |
20
- -
21
- - foo
22
- - bar
23
- - baz
24
- php: |
25
- array(array('foo', 'bar', 'baz'))
26
- ---
27
- test: Mixed Sequences
28
- brief: |
29
- Sequences can contain any YAML data,
30
- including strings and other sequences.
31
- yaml: |
32
- - apple
33
- -
34
- - foo
35
- - bar
36
- - x123
37
- - banana
38
- - carrot
39
- php: |
40
- array('apple', array('foo', 'bar', 'x123'), 'banana', 'carrot')
41
- ---
42
- test: Deeply Nested Sequences
43
- brief: |
44
- Sequences can be nested even deeper, with each
45
- level of indentation representing a level of
46
- depth.
47
- yaml: |
48
- -
49
- -
50
- - uno
51
- - dos
52
- php: |
53
- array(array(array('uno', 'dos')))
54
- ---
55
- test: Simple Mapping
56
- brief: |
57
- You can add a keyed list (also known as a dictionary or
58
- hash) to your document by placing each member of the
59
- list on a new line, with a colon separating the key
60
- from its value. In YAML, this type of list is called
61
- a mapping.
62
- yaml: |
63
- foo: whatever
64
- bar: stuff
65
- php: |
66
- array('foo' => 'whatever', 'bar' => 'stuff')
67
- ---
68
- test: Sequence in a Mapping
69
- brief: |
70
- A value in a mapping can be a sequence.
71
- yaml: |
72
- foo: whatever
73
- bar:
74
- - uno
75
- - dos
76
- php: |
77
- array('foo' => 'whatever', 'bar' => array('uno', 'dos'))
78
- ---
79
- test: Nested Mappings
80
- brief: |
81
- A value in a mapping can be another mapping.
82
- yaml: |
83
- foo: whatever
84
- bar:
85
- fruit: apple
86
- name: steve
87
- sport: baseball
88
- php: |
89
- array(
90
- 'foo' => 'whatever',
91
- 'bar' => array(
92
- 'fruit' => 'apple',
93
- 'name' => 'steve',
94
- 'sport' => 'baseball'
95
- )
96
- )
97
- ---
98
- test: Mixed Mapping
99
- brief: |
100
- A mapping can contain any assortment
101
- of mappings and sequences as values.
102
- yaml: |
103
- foo: whatever
104
- bar:
105
- -
106
- fruit: apple
107
- name: steve
108
- sport: baseball
109
- - more
110
- -
111
- python: rocks
112
- perl: papers
113
- ruby: scissorses
114
- php: |
115
- array(
116
- 'foo' => 'whatever',
117
- 'bar' => array(
118
- array(
119
- 'fruit' => 'apple',
120
- 'name' => 'steve',
121
- 'sport' => 'baseball'
122
- ),
123
- 'more',
124
- array(
125
- 'python' => 'rocks',
126
- 'perl' => 'papers',
127
- 'ruby' => 'scissorses'
128
- )
129
- )
130
- )
131
- ---
132
- test: Mapping-in-Sequence Shortcut
133
- todo: true
134
- brief: |
135
- If you are adding a mapping to a sequence, you
136
- can place the mapping on the same line as the
137
- dash as a shortcut.
138
- yaml: |
139
- - work on YAML.py:
140
- - work on Store
141
- php: |
142
- array(array('work on YAML.py' => array('work on Store')))
143
- ---
144
- test: Sequence-in-Mapping Shortcut
145
- todo: true
146
- brief: |
147
- The dash in a sequence counts as indentation, so
148
- you can add a sequence inside of a mapping without
149
- needing spaces as indentation.
150
- yaml: |
151
- allow:
152
- - 'localhost'
153
- - '%.sourceforge.net'
154
- - '%.freepan.org'
155
- php: |
156
- array('allow' => array('localhost', '%.sourceforge.net', '%.freepan.org'))
157
- ---
158
- todo: true
159
- test: Merge key
160
- brief: |
161
- A merge key ('<<') can be used in a mapping to insert other mappings. If
162
- the value associated with the merge key is a mapping, each of its key/value
163
- pairs is inserted into the current mapping.
164
- yaml: |
165
- mapping:
166
- name: Joe
167
- job: Accountant
168
- <<:
169
- age: 38
170
- php: |
171
- array(
172
- 'mapping' =>
173
- array(
174
- 'name' => 'Joe',
175
- 'job' => 'Accountant',
176
- 'age' => 38
177
- )
178
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/YtsBlockMapping.yml DELETED
@@ -1,51 +0,0 @@
1
- ---
2
- test: One Element Mapping
3
- brief: |
4
- A mapping with one key/value pair
5
- yaml: |
6
- foo: bar
7
- php: |
8
- array('foo' => 'bar')
9
- ---
10
- test: Multi Element Mapping
11
- brief: |
12
- More than one key/value pair
13
- yaml: |
14
- red: baron
15
- white: walls
16
- blue: berries
17
- php: |
18
- array(
19
- 'red' => 'baron',
20
- 'white' => 'walls',
21
- 'blue' => 'berries',
22
- )
23
- ---
24
- test: Values aligned
25
- brief: |
26
- Often times human editors of documents will align the values even
27
- though YAML emitters generally don't.
28
- yaml: |
29
- red: baron
30
- white: walls
31
- blue: berries
32
- php: |
33
- array(
34
- 'red' => 'baron',
35
- 'white' => 'walls',
36
- 'blue' => 'berries',
37
- )
38
- ---
39
- test: Colons aligned
40
- brief: |
41
- Spaces can come before the ': ' key/value separator.
42
- yaml: |
43
- red : baron
44
- white : walls
45
- blue : berries
46
- php: |
47
- array(
48
- 'red' => 'baron',
49
- 'white' => 'walls',
50
- 'blue' => 'berries',
51
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/YtsDocumentSeparator.yml DELETED
@@ -1,85 +0,0 @@
1
- --- %YAML:1.0
2
- test: Trailing Document Separator
3
- todo: true
4
- brief: >
5
- You can separate YAML documents
6
- with a string of three dashes.
7
- yaml: |
8
- - foo: 1
9
- bar: 2
10
- ---
11
- more: stuff
12
- python: |
13
- [
14
- [ { 'foo': 1, 'bar': 2 } ],
15
- { 'more': 'stuff' }
16
- ]
17
- ruby: |
18
- [ { 'foo' => 1, 'bar' => 2 } ]
19
-
20
- ---
21
- test: Leading Document Separator
22
- todo: true
23
- brief: >
24
- You can explicity give an opening
25
- document separator to your YAML stream.
26
- yaml: |
27
- ---
28
- - foo: 1
29
- bar: 2
30
- ---
31
- more: stuff
32
- python: |
33
- [
34
- [ {'foo': 1, 'bar': 2}],
35
- {'more': 'stuff'}
36
- ]
37
- ruby: |
38
- [ { 'foo' => 1, 'bar' => 2 } ]
39
-
40
- ---
41
- test: YAML Header
42
- todo: true
43
- brief: >
44
- The opening separator can contain directives
45
- to the YAML parser, such as the version
46
- number.
47
- yaml: |
48
- --- %YAML:1.0
49
- foo: 1
50
- bar: 2
51
- php: |
52
- array('foo' => 1, 'bar' => 2)
53
- documents: 1
54
-
55
- ---
56
- test: Red Herring Document Separator
57
- brief: >
58
- Separators included in blocks or strings
59
- are treated as blocks or strings, as the
60
- document separator should have no indentation
61
- preceding it.
62
- yaml: |
63
- foo: |
64
- ---
65
- php: |
66
- array('foo' => "---\n")
67
-
68
- ---
69
- test: Multiple Document Separators in Block
70
- brief: >
71
- This technique allows you to embed other YAML
72
- documents within literal blocks.
73
- yaml: |
74
- foo: |
75
- ---
76
- foo: bar
77
- ---
78
- yo: baz
79
- bar: |
80
- fooness
81
- php: |
82
- array(
83
- 'foo' => "---\nfoo: bar\n---\nyo: baz\n",
84
- 'bar' => "fooness\n"
85
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/YtsErrorTests.yml DELETED
@@ -1,25 +0,0 @@
1
- ---
2
- test: Missing value for hash item
3
- todo: true
4
- brief: |
5
- Third item in this hash doesn't have a value
6
- yaml: |
7
- okay: value
8
- also okay: ~
9
- causes error because no value specified
10
- last key: value okay here too
11
- python-error: causes error because no value specified
12
-
13
- ---
14
- test: Not indenting enough
15
- brief: |
16
- There was a bug in PyYaml where it was off by one
17
- in the indentation check. It was allowing the YAML
18
- below.
19
- # This is actually valid YAML now. Someone should tell showell.
20
- yaml: |
21
- foo:
22
- firstline: 1
23
- secondline: 2
24
- php: |
25
- array('foo' => null, 'firstline' => 1, 'secondline' => 2)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/YtsFlowCollections.yml DELETED
@@ -1,60 +0,0 @@
1
- ---
2
- test: Simple Inline Array
3
- brief: >
4
- Sequences can be contained on a
5
- single line, using the inline syntax.
6
- Separate each entry with commas and
7
- enclose in square brackets.
8
- yaml: |
9
- seq: [ a, b, c ]
10
- php: |
11
- array('seq' => array('a', 'b', 'c'))
12
- ---
13
- test: Simple Inline Hash
14
- brief: >
15
- Mapping can also be contained on
16
- a single line, using the inline
17
- syntax. Each key-value pair is
18
- separated by a colon, with a comma
19
- between each entry in the mapping.
20
- Enclose with curly braces.
21
- yaml: |
22
- hash: { name: Steve, foo: bar }
23
- php: |
24
- array('hash' => array('name' => 'Steve', 'foo' => 'bar'))
25
- ---
26
- test: Multi-line Inline Collections
27
- todo: true
28
- brief: >
29
- Both inline sequences and inline mappings
30
- can span multiple lines, provided that you
31
- indent the additional lines.
32
- yaml: |
33
- languages: [ Ruby,
34
- Perl,
35
- Python ]
36
- websites: { YAML: yaml.org,
37
- Ruby: ruby-lang.org,
38
- Python: python.org,
39
- Perl: use.perl.org }
40
- php: |
41
- array(
42
- 'languages' => array('Ruby', 'Perl', 'Python'),
43
- 'websites' => array(
44
- 'YAML' => 'yaml.org',
45
- 'Ruby' => 'ruby-lang.org',
46
- 'Python' => 'python.org',
47
- 'Perl' => 'use.perl.org'
48
- )
49
- )
50
- ---
51
- test: Commas in Values (not in the spec!)
52
- todo: true
53
- brief: >
54
- List items in collections are delimited by commas, but
55
- there must be a space after each comma. This allows you
56
- to add numbers without quoting.
57
- yaml: |
58
- attendances: [ 45,123, 70,000, 17,222 ]
59
- php: |
60
- array('attendances' => array(45123, 70000, 17222))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/YtsFoldedScalars.yml DELETED
@@ -1,176 +0,0 @@
1
- --- %YAML:1.0
2
- test: Single ending newline
3
- brief: >
4
- A pipe character, followed by an indented
5
- block of text is treated as a literal
6
- block, in which newlines are preserved
7
- throughout the block, including the final
8
- newline.
9
- yaml: |
10
- ---
11
- this: |
12
- Foo
13
- Bar
14
- php: |
15
- array('this' => "Foo\nBar\n")
16
- ---
17
- test: The '+' indicator
18
- brief: >
19
- The '+' indicator says to keep newlines at the end of text
20
- blocks.
21
- yaml: |
22
- normal: |
23
- extra new lines not kept
24
-
25
- preserving: |+
26
- extra new lines are kept
27
-
28
-
29
- dummy: value
30
- php: |
31
- array(
32
- 'normal' => "extra new lines not kept\n",
33
- 'preserving' => "extra new lines are kept\n\n\n",
34
- 'dummy' => 'value'
35
- )
36
- ---
37
- test: Three trailing newlines in literals
38
- brief: >
39
- To give you more control over how space
40
- is preserved in text blocks, YAML has
41
- the keep '+' and chomp '-' indicators.
42
- The keep indicator will preserve all
43
- ending newlines, while the chomp indicator
44
- will strip all ending newlines.
45
- yaml: |
46
- clipped: |
47
- This has one newline.
48
-
49
-
50
-
51
- same as "clipped" above: "This has one newline.\n"
52
-
53
- stripped: |-
54
- This has no newline.
55
-
56
-
57
-
58
- same as "stripped" above: "This has no newline."
59
-
60
- kept: |+
61
- This has four newlines.
62
-
63
-
64
-
65
- same as "kept" above: "This has four newlines.\n\n\n\n"
66
- php: |
67
- array(
68
- 'clipped' => "This has one newline.\n",
69
- 'same as "clipped" above' => "This has one newline.\n",
70
- 'stripped' => 'This has no newline.',
71
- 'same as "stripped" above' => 'This has no newline.',
72
- 'kept' => "This has four newlines.\n\n\n\n",
73
- 'same as "kept" above' => "This has four newlines.\n\n\n\n"
74
- )
75
- ---
76
- test: Extra trailing newlines with spaces
77
- todo: true
78
- brief: >
79
- Normally, only a single newline is kept
80
- from the end of a literal block, unless the
81
- keep '+' character is used in combination
82
- with the pipe. The following example
83
- will preserve all ending whitespace
84
- since the last line of both literal blocks
85
- contains spaces which extend past the indentation
86
- level.
87
- yaml: |
88
- ---
89
- this: |
90
- Foo
91
-
92
-
93
- kept: |+
94
- Foo
95
-
96
-
97
- php: |
98
- array('this' => "Foo\n\n \n",
99
- 'kept' => "Foo\n\n \n" )
100
-
101
- ---
102
- test: Folded Block in a Sequence
103
- brief: >
104
- A greater-then character, followed by an indented
105
- block of text is treated as a folded block, in
106
- which lines of text separated by a single newline
107
- are concatenated as a single line.
108
- yaml: |
109
- ---
110
- - apple
111
- - banana
112
- - >
113
- can't you see
114
- the beauty of yaml?
115
- hmm
116
- - dog
117
- php: |
118
- array(
119
- 'apple',
120
- 'banana',
121
- "can't you see the beauty of yaml? hmm\n",
122
- 'dog'
123
- )
124
- ---
125
- test: Folded Block as a Mapping Value
126
- brief: >
127
- Both literal and folded blocks can be
128
- used in collections, as values in a
129
- sequence or a mapping.
130
- yaml: |
131
- ---
132
- quote: >
133
- Mark McGwire's
134
- year was crippled
135
- by a knee injury.
136
- source: espn
137
- php: |
138
- array(
139
- 'quote' => "Mark McGwire's year was crippled by a knee injury.\n",
140
- 'source' => 'espn'
141
- )
142
- ---
143
- test: Three trailing newlines in folded blocks
144
- brief: >
145
- The keep and chomp indicators can also
146
- be applied to folded blocks.
147
- yaml: |
148
- clipped: >
149
- This has one newline.
150
-
151
-
152
-
153
- same as "clipped" above: "This has one newline.\n"
154
-
155
- stripped: >-
156
- This has no newline.
157
-
158
-
159
-
160
- same as "stripped" above: "This has no newline."
161
-
162
- kept: >+
163
- This has four newlines.
164
-
165
-
166
-
167
- same as "kept" above: "This has four newlines.\n\n\n\n"
168
- php: |
169
- array(
170
- 'clipped' => "This has one newline.\n",
171
- 'same as "clipped" above' => "This has one newline.\n",
172
- 'stripped' => 'This has no newline.',
173
- 'same as "stripped" above' => 'This has no newline.',
174
- 'kept' => "This has four newlines.\n\n\n\n",
175
- 'same as "kept" above' => "This has four newlines.\n\n\n\n"
176
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/YtsNullsAndEmpties.yml DELETED
@@ -1,45 +0,0 @@
1
- --- %YAML:1.0
2
- test: Empty Sequence
3
- brief: >
4
- You can represent the empty sequence
5
- with an empty inline sequence.
6
- yaml: |
7
- empty: []
8
- php: |
9
- array('empty' => array())
10
- ---
11
- test: Empty Mapping
12
- brief: >
13
- You can represent the empty mapping
14
- with an empty inline mapping.
15
- yaml: |
16
- empty: {}
17
- php: |
18
- array('empty' => array())
19
- ---
20
- test: Empty Sequence as Entire Document
21
- yaml: |
22
- []
23
- php: |
24
- array()
25
- ---
26
- test: Empty Mapping as Entire Document
27
- yaml: |
28
- {}
29
- php: |
30
- array()
31
- ---
32
- test: Null as Document
33
- yaml: |
34
- ~
35
- php: |
36
- null
37
- ---
38
- test: Empty String
39
- brief: >
40
- You can represent an empty string
41
- with a pair of quotes.
42
- yaml: |
43
- ''
44
- php: |
45
- ''
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/YtsSpecificationExamples.yml DELETED
@@ -1,1695 +0,0 @@
1
- --- %YAML:1.0
2
- test: Sequence of scalars
3
- spec: 2.1
4
- yaml: |
5
- - Mark McGwire
6
- - Sammy Sosa
7
- - Ken Griffey
8
- php: |
9
- array('Mark McGwire', 'Sammy Sosa', 'Ken Griffey')
10
- ---
11
- test: Mapping of scalars to scalars
12
- spec: 2.2
13
- yaml: |
14
- hr: 65
15
- avg: 0.278
16
- rbi: 147
17
- php: |
18
- array('hr' => 65, 'avg' => 0.278, 'rbi' => 147)
19
- ---
20
- test: Mapping of scalars to sequences
21
- spec: 2.3
22
- yaml: |
23
- american:
24
- - Boston Red Sox
25
- - Detroit Tigers
26
- - New York Yankees
27
- national:
28
- - New York Mets
29
- - Chicago Cubs
30
- - Atlanta Braves
31
- php: |
32
- array('american' =>
33
- array( 'Boston Red Sox', 'Detroit Tigers',
34
- 'New York Yankees' ),
35
- 'national' =>
36
- array( 'New York Mets', 'Chicago Cubs',
37
- 'Atlanta Braves' )
38
- )
39
- ---
40
- test: Sequence of mappings
41
- spec: 2.4
42
- yaml: |
43
- -
44
- name: Mark McGwire
45
- hr: 65
46
- avg: 0.278
47
- -
48
- name: Sammy Sosa
49
- hr: 63
50
- avg: 0.288
51
- php: |
52
- array(
53
- array('name' => 'Mark McGwire', 'hr' => 65, 'avg' => 0.278),
54
- array('name' => 'Sammy Sosa', 'hr' => 63, 'avg' => 0.288)
55
- )
56
- ---
57
- test: Legacy A5
58
- todo: true
59
- spec: legacy_A5
60
- yaml: |
61
- ?
62
- - New York Yankees
63
- - Atlanta Braves
64
- :
65
- - 2001-07-02
66
- - 2001-08-12
67
- - 2001-08-14
68
- ?
69
- - Detroit Tigers
70
- - Chicago Cubs
71
- :
72
- - 2001-07-23
73
- perl-busted: >
74
- YAML.pm will be able to emulate this behavior soon. In this regard
75
- it may be somewhat more correct than Python's native behaviour which
76
- can only use tuples as mapping keys. PyYAML will also need to figure
77
- out some clever way to roundtrip structured keys.
78
- python: |
79
- [
80
- {
81
- ('New York Yankees', 'Atlanta Braves'):
82
- [yaml.timestamp('2001-07-02'),
83
- yaml.timestamp('2001-08-12'),
84
- yaml.timestamp('2001-08-14')],
85
- ('Detroit Tigers', 'Chicago Cubs'):
86
- [yaml.timestamp('2001-07-23')]
87
- }
88
- ]
89
- ruby: |
90
- {
91
- [ 'New York Yankees', 'Atlanta Braves' ] =>
92
- [ Date.new( 2001, 7, 2 ), Date.new( 2001, 8, 12 ), Date.new( 2001, 8, 14 ) ],
93
- [ 'Detroit Tigers', 'Chicago Cubs' ] =>
94
- [ Date.new( 2001, 7, 23 ) ]
95
- }
96
- syck: |
97
- struct test_node seq1[] = {
98
- { T_STR, 0, "New York Yankees" },
99
- { T_STR, 0, "Atlanta Braves" },
100
- end_node
101
- };
102
- struct test_node seq2[] = {
103
- { T_STR, 0, "2001-07-02" },
104
- { T_STR, 0, "2001-08-12" },
105
- { T_STR, 0, "2001-08-14" },
106
- end_node
107
- };
108
- struct test_node seq3[] = {
109
- { T_STR, 0, "Detroit Tigers" },
110
- { T_STR, 0, "Chicago Cubs" },
111
- end_node
112
- };
113
- struct test_node seq4[] = {
114
- { T_STR, 0, "2001-07-23" },
115
- end_node
116
- };
117
- struct test_node map[] = {
118
- { T_SEQ, 0, 0, seq1 },
119
- { T_SEQ, 0, 0, seq2 },
120
- { T_SEQ, 0, 0, seq3 },
121
- { T_SEQ, 0, 0, seq4 },
122
- end_node
123
- };
124
- struct test_node stream[] = {
125
- { T_MAP, 0, 0, map },
126
- end_node
127
- };
128
-
129
- ---
130
- test: Sequence of sequences
131
- spec: 2.5
132
- yaml: |
133
- - [ name , hr , avg ]
134
- - [ Mark McGwire , 65 , 0.278 ]
135
- - [ Sammy Sosa , 63 , 0.288 ]
136
- php: |
137
- array(
138
- array( 'name', 'hr', 'avg' ),
139
- array( 'Mark McGwire', 65, 0.278 ),
140
- array( 'Sammy Sosa', 63, 0.288 )
141
- )
142
- ---
143
- test: Mapping of mappings
144
- todo: true
145
- spec: 2.6
146
- yaml: |
147
- Mark McGwire: {hr: 65, avg: 0.278}
148
- Sammy Sosa: {
149
- hr: 63,
150
- avg: 0.288
151
- }
152
- php: |
153
- array(
154
- 'Mark McGwire' =>
155
- array( 'hr' => 65, 'avg' => 0.278 ),
156
- 'Sammy Sosa' =>
157
- array( 'hr' => 63, 'avg' => 0.288 )
158
- )
159
- ---
160
- test: Two documents in a stream each with a leading comment
161
- todo: true
162
- spec: 2.7
163
- yaml: |
164
- # Ranking of 1998 home runs
165
- ---
166
- - Mark McGwire
167
- - Sammy Sosa
168
- - Ken Griffey
169
-
170
- # Team ranking
171
- ---
172
- - Chicago Cubs
173
- - St Louis Cardinals
174
- ruby: |
175
- y = YAML::Stream.new
176
- y.add( [ 'Mark McGwire', 'Sammy Sosa', 'Ken Griffey' ] )
177
- y.add( [ 'Chicago Cubs', 'St Louis Cardinals' ] )
178
- documents: 2
179
-
180
- ---
181
- test: Play by play feed from a game
182
- todo: true
183
- spec: 2.8
184
- yaml: |
185
- ---
186
- time: 20:03:20
187
- player: Sammy Sosa
188
- action: strike (miss)
189
- ...
190
- ---
191
- time: 20:03:47
192
- player: Sammy Sosa
193
- action: grand slam
194
- ...
195
- perl: |
196
- [ 'Mark McGwire', 'Sammy Sosa', 'Ken Griffey' ]
197
- documents: 2
198
-
199
- ---
200
- test: Single document with two comments
201
- spec: 2.9
202
- yaml: |
203
- hr: # 1998 hr ranking
204
- - Mark McGwire
205
- - Sammy Sosa
206
- rbi:
207
- # 1998 rbi ranking
208
- - Sammy Sosa
209
- - Ken Griffey
210
- php: |
211
- array(
212
- 'hr' => array( 'Mark McGwire', 'Sammy Sosa' ),
213
- 'rbi' => array( 'Sammy Sosa', 'Ken Griffey' )
214
- )
215
- ---
216
- test: Node for Sammy Sosa appears twice in this document
217
- spec: 2.10
218
- yaml: |
219
- ---
220
- hr:
221
- - Mark McGwire
222
- # Following node labeled SS
223
- - &SS Sammy Sosa
224
- rbi:
225
- - *SS # Subsequent occurrence
226
- - Ken Griffey
227
- php: |
228
- array(
229
- 'hr' =>
230
- array('Mark McGwire', 'Sammy Sosa'),
231
- 'rbi' =>
232
- array('Sammy Sosa', 'Ken Griffey')
233
- )
234
- ---
235
- test: Mapping between sequences
236
- todo: true
237
- spec: 2.11
238
- yaml: |
239
- ? # PLAY SCHEDULE
240
- - Detroit Tigers
241
- - Chicago Cubs
242
- :
243
- - 2001-07-23
244
-
245
- ? [ New York Yankees,
246
- Atlanta Braves ]
247
- : [ 2001-07-02, 2001-08-12,
248
- 2001-08-14 ]
249
- ruby: |
250
- {
251
- [ 'Detroit Tigers', 'Chicago Cubs' ] => [ Date.new( 2001, 7, 23 ) ],
252
- [ 'New York Yankees', 'Atlanta Braves' ] => [ Date.new( 2001, 7, 2 ), Date.new( 2001, 8, 12 ), Date.new( 2001, 8, 14 ) ]
253
- }
254
- syck: |
255
- struct test_node seq1[] = {
256
- { T_STR, 0, "New York Yankees" },
257
- { T_STR, 0, "Atlanta Braves" },
258
- end_node
259
- };
260
- struct test_node seq2[] = {
261
- { T_STR, 0, "2001-07-02" },
262
- { T_STR, 0, "2001-08-12" },
263
- { T_STR, 0, "2001-08-14" },
264
- end_node
265
- };
266
- struct test_node seq3[] = {
267
- { T_STR, 0, "Detroit Tigers" },
268
- { T_STR, 0, "Chicago Cubs" },
269
- end_node
270
- };
271
- struct test_node seq4[] = {
272
- { T_STR, 0, "2001-07-23" },
273
- end_node
274
- };
275
- struct test_node map[] = {
276
- { T_SEQ, 0, 0, seq3 },
277
- { T_SEQ, 0, 0, seq4 },
278
- { T_SEQ, 0, 0, seq1 },
279
- { T_SEQ, 0, 0, seq2 },
280
- end_node
281
- };
282
- struct test_node stream[] = {
283
- { T_MAP, 0, 0, map },
284
- end_node
285
- };
286
-
287
- ---
288
- test: Sequence key shortcut
289
- spec: 2.12
290
- yaml: |
291
- ---
292
- # products purchased
293
- - item : Super Hoop
294
- quantity: 1
295
- - item : Basketball
296
- quantity: 4
297
- - item : Big Shoes
298
- quantity: 1
299
- php: |
300
- array (
301
- array (
302
- 'item' => 'Super Hoop',
303
- 'quantity' => 1,
304
- ),
305
- array (
306
- 'item' => 'Basketball',
307
- 'quantity' => 4,
308
- ),
309
- array (
310
- 'item' => 'Big Shoes',
311
- 'quantity' => 1,
312
- )
313
- )
314
- perl: |
315
- [
316
- { item => 'Super Hoop', quantity => 1 },
317
- { item => 'Basketball', quantity => 4 },
318
- { item => 'Big Shoes', quantity => 1 }
319
- ]
320
-
321
- ruby: |
322
- [
323
- { 'item' => 'Super Hoop', 'quantity' => 1 },
324
- { 'item' => 'Basketball', 'quantity' => 4 },
325
- { 'item' => 'Big Shoes', 'quantity' => 1 }
326
- ]
327
- python: |
328
- [
329
- { 'item': 'Super Hoop', 'quantity': 1 },
330
- { 'item': 'Basketball', 'quantity': 4 },
331
- { 'item': 'Big Shoes', 'quantity': 1 }
332
- ]
333
- syck: |
334
- struct test_node map1[] = {
335
- { T_STR, 0, "item" },
336
- { T_STR, 0, "Super Hoop" },
337
- { T_STR, 0, "quantity" },
338
- { T_STR, 0, "1" },
339
- end_node
340
- };
341
- struct test_node map2[] = {
342
- { T_STR, 0, "item" },
343
- { T_STR, 0, "Basketball" },
344
- { T_STR, 0, "quantity" },
345
- { T_STR, 0, "4" },
346
- end_node
347
- };
348
- struct test_node map3[] = {
349
- { T_STR, 0, "item" },
350
- { T_STR, 0, "Big Shoes" },
351
- { T_STR, 0, "quantity" },
352
- { T_STR, 0, "1" },
353
- end_node
354
- };
355
- struct test_node seq[] = {
356
- { T_MAP, 0, 0, map1 },
357
- { T_MAP, 0, 0, map2 },
358
- { T_MAP, 0, 0, map3 },
359
- end_node
360
- };
361
- struct test_node stream[] = {
362
- { T_SEQ, 0, 0, seq },
363
- end_node
364
- };
365
-
366
-
367
- ---
368
- test: Literal perserves newlines
369
- todo: true
370
- spec: 2.13
371
- yaml: |
372
- # ASCII Art
373
- --- |
374
- \//||\/||
375
- // || ||_
376
- perl: |
377
- "\\//||\\/||\n// || ||_\n"
378
- ruby: |
379
- "\\//||\\/||\n// || ||_\n"
380
- python: |
381
- [
382
- flushLeft(
383
- """
384
- \//||\/||
385
- // || ||_
386
- """
387
- )
388
- ]
389
- syck: |
390
- struct test_node stream[] = {
391
- { T_STR, 0, "\\//||\\/||\n// || ||_\n" },
392
- end_node
393
- };
394
-
395
- ---
396
- test: Folded treats newlines as a space
397
- todo: true
398
- spec: 2.14
399
- yaml: |
400
- ---
401
- Mark McGwire's
402
- year was crippled
403
- by a knee injury.
404
- perl: |
405
- "Mark McGwire's year was crippled by a knee injury."
406
- ruby: |
407
- "Mark McGwire's year was crippled by a knee injury."
408
- python: |
409
- [ "Mark McGwire's year was crippled by a knee injury." ]
410
- syck: |
411
- struct test_node stream[] = {
412
- { T_STR, 0, "Mark McGwire's year was crippled by a knee injury." },
413
- end_node
414
- };
415
-
416
- ---
417
- test: Newlines preserved for indented and blank lines
418
- todo: true
419
- spec: 2.15
420
- yaml: |
421
- --- >
422
- Sammy Sosa completed another
423
- fine season with great stats.
424
-
425
- 63 Home Runs
426
- 0.288 Batting Average
427
-
428
- What a year!
429
- perl: |
430
- "Sammy Sosa completed another fine season with great stats.\n\n 63 Home Runs\n 0.288 Batting Average\n\nWhat a year!\n"
431
- ruby: |
432
- "Sammy Sosa completed another fine season with great stats.\n\n 63 Home Runs\n 0.288 Batting Average\n\nWhat a year!\n"
433
- python: |
434
- [
435
- flushLeft(
436
- """
437
- Sammy Sosa completed another fine season with great stats.
438
-
439
- 63 Home Runs
440
- 0.288 Batting Average
441
-
442
- What a year!
443
- """
444
- )
445
- ]
446
- syck: |
447
- struct test_node stream[] = {
448
- { T_STR, 0, "Sammy Sosa completed another fine season with great stats.\n\n 63 Home Runs\n 0.288 Batting Average\n\nWhat a year!\n" },
449
- end_node
450
- };
451
-
452
-
453
- ---
454
- test: Indentation determines scope
455
- spec: 2.16
456
- yaml: |
457
- name: Mark McGwire
458
- accomplishment: >
459
- Mark set a major league
460
- home run record in 1998.
461
- stats: |
462
- 65 Home Runs
463
- 0.278 Batting Average
464
- php: |
465
- array(
466
- 'name' => 'Mark McGwire',
467
- 'accomplishment' => "Mark set a major league home run record in 1998.\n",
468
- 'stats' => "65 Home Runs\n0.278 Batting Average\n"
469
- )
470
- ---
471
- test: Quoted scalars
472
- todo: true
473
- spec: 2.17
474
- yaml: |
475
- unicode: "Sosa did fine.\u263A"
476
- control: "\b1998\t1999\t2000\n"
477
- hexesc: "\x0D\x0A is \r\n"
478
-
479
- single: '"Howdy!" he cried.'
480
- quoted: ' # not a ''comment''.'
481
- tie-fighter: '|\-*-/|'
482
- ruby: |
483
- {
484
- "tie-fighter" => "|\\-*-/|",
485
- "control"=>"\0101998\t1999\t2000\n",
486
- "unicode"=>"Sosa did fine." + ["263A".hex ].pack('U*'),
487
- "quoted"=>" # not a 'comment'.",
488
- "single"=>"\"Howdy!\" he cried.",
489
- "hexesc"=>"\r\n is \r\n"
490
- }
491
- ---
492
- test: Multiline flow scalars
493
- todo: true
494
- spec: 2.18
495
- yaml: |
496
- plain:
497
- This unquoted scalar
498
- spans many lines.
499
-
500
- quoted: "So does this
501
- quoted scalar.\n"
502
- ruby: |
503
- {
504
- 'plain' => 'This unquoted scalar spans many lines.',
505
- 'quoted' => "So does this quoted scalar.\n"
506
- }
507
- ---
508
- test: Integers
509
- spec: 2.19
510
- yaml: |
511
- canonical: 12345
512
- decimal: +12,345
513
- octal: 014
514
- hexadecimal: 0xC
515
- php: |
516
- array(
517
- 'canonical' => 12345,
518
- 'decimal' => 12345,
519
- 'octal' => 014,
520
- 'hexadecimal' => 0xC
521
- )
522
- ---
523
- # FIX: spec shows parens around -inf and NaN
524
- test: Floating point
525
- spec: 2.20
526
- yaml: |
527
- canonical: 1.23015e+3
528
- exponential: 12.3015e+02
529
- fixed: 1,230.15
530
- negative infinity: -.inf
531
- not a number: .NaN
532
- php: |
533
- array(
534
- 'canonical' => 1230.15,
535
- 'exponential' => 1230.15,
536
- 'fixed' => 1230.15,
537
- 'negative infinity' => log(0),
538
- 'not a number' => -log(0),
539
- )
540
- ---
541
- test: Miscellaneous
542
- spec: 2.21
543
- yaml: |
544
- null: ~
545
- true: true
546
- false: false
547
- string: '12345'
548
- php: |
549
- array(
550
- '' => null,
551
- 1 => true,
552
- 0 => false,
553
- 'string' => '12345'
554
- )
555
- ---
556
- test: Timestamps
557
- todo: true
558
- spec: 2.22
559
- yaml: |
560
- canonical: 2001-12-15T02:59:43.1Z
561
- iso8601: 2001-12-14t21:59:43.10-05:00
562
- spaced: 2001-12-14 21:59:43.10 -05:00
563
- date: 2002-12-14 # Time is noon UTC
564
- php: |
565
- array(
566
- 'canonical' => YAML::mktime( 2001, 12, 15, 2, 59, 43, 0.10 ),
567
- 'iso8601' => YAML::mktime( 2001, 12, 14, 21, 59, 43, 0.10, "-05:00" ),
568
- 'spaced' => YAML::mktime( 2001, 12, 14, 21, 59, 43, 0.10, "-05:00" ),
569
- 'date' => Date.new( 2002, 12, 14 )
570
- )
571
- ---
572
- test: legacy Timestamps test
573
- todo: true
574
- spec: legacy D4
575
- yaml: |
576
- canonical: 2001-12-15T02:59:43.00Z
577
- iso8601: 2001-02-28t21:59:43.00-05:00
578
- spaced: 2001-12-14 21:59:43.00 -05:00
579
- date: 2002-12-14
580
- php: |
581
- array(
582
- 'canonical' => Time::utc( 2001, 12, 15, 2, 59, 43, 0 ),
583
- 'iso8601' => YAML::mktime( 2001, 2, 28, 21, 59, 43, 0, "-05:00" ),
584
- 'spaced' => YAML::mktime( 2001, 12, 14, 21, 59, 43, 0, "-05:00" ),
585
- 'date' => Date.new( 2002, 12, 14 )
586
- )
587
- ---
588
- test: Various explicit families
589
- todo: true
590
- spec: 2.23
591
- yaml: |
592
- not-date: !str 2002-04-28
593
- picture: !binary |
594
- R0lGODlhDAAMAIQAAP//9/X
595
- 17unp5WZmZgAAAOfn515eXv
596
- Pz7Y6OjuDg4J+fn5OTk6enp
597
- 56enmleECcgggoBADs=
598
-
599
- application specific tag: !!something |
600
- The semantics of the tag
601
- above may be different for
602
- different documents.
603
-
604
- ruby-setup: |
605
- YAML.add_private_type( "something" ) do |type, val|
606
- "SOMETHING: #{val}"
607
- end
608
- ruby: |
609
- {
610
- 'not-date' => '2002-04-28',
611
- 'picture' => "GIF89a\f\000\f\000\204\000\000\377\377\367\365\365\356\351\351\345fff\000\000\000\347\347\347^^^\363\363\355\216\216\216\340\340\340\237\237\237\223\223\223\247\247\247\236\236\236i^\020' \202\n\001\000;",
612
- 'application specific tag' => "SOMETHING: The semantics of the tag\nabove may be different for\ndifferent documents.\n"
613
- }
614
- ---
615
- test: Application specific family
616
- todo: true
617
- spec: 2.24
618
- yaml: |
619
- # Establish a tag prefix
620
- --- !clarkevans.com,2002/graph/^shape
621
- # Use the prefix: shorthand for
622
- # !clarkevans.com,2002/graph/circle
623
- - !^circle
624
- center: &ORIGIN {x: 73, 'y': 129}
625
- radius: 7
626
- - !^line # !clarkevans.com,2002/graph/line
627
- start: *ORIGIN
628
- finish: { x: 89, 'y': 102 }
629
- - !^label
630
- start: *ORIGIN
631
- color: 0xFFEEBB
632
- value: Pretty vector drawing.
633
- ruby-setup: |
634
- YAML.add_domain_type( "clarkevans.com,2002", 'graph/shape' ) { |type, val|
635
- if Array === val
636
- val << "Shape Container"
637
- val
638
- else
639
- raise YAML::Error, "Invalid graph of class #{ val.class }: " + val.inspect
640
- end
641
- }
642
- one_shape_proc = Proc.new { |type, val|
643
- scheme, domain, type = type.split( /:/, 3 )
644
- if val.is_a? ::Hash
645
- val['TYPE'] = "Shape: #{type}"
646
- val
647
- else
648
- raise YAML::Error, "Invalid graph of class #{ val.class }: " + val.inspect
649
- end
650
- }
651
- YAML.add_domain_type( "clarkevans.com,2002", 'graph/circle', &one_shape_proc )
652
- YAML.add_domain_type( "clarkevans.com,2002", 'graph/line', &one_shape_proc )
653
- YAML.add_domain_type( "clarkevans.com,2002", 'graph/label', &one_shape_proc )
654
- ruby: |
655
- [
656
- {
657
- "radius" => 7,
658
- "center"=>
659
- {
660
- "x" => 73,
661
- "y" => 129
662
- },
663
- "TYPE" => "Shape: graph/circle"
664
- }, {
665
- "finish" =>
666
- {
667
- "x" => 89,
668
- "y" => 102
669
- },
670
- "TYPE" => "Shape: graph/line",
671
- "start" =>
672
- {
673
- "x" => 73,
674
- "y" => 129
675
- }
676
- }, {
677
- "TYPE" => "Shape: graph/label",
678
- "value" => "Pretty vector drawing.",
679
- "start" =>
680
- {
681
- "x" => 73,
682
- "y" => 129
683
- },
684
- "color" => 16772795
685
- },
686
- "Shape Container"
687
- ]
688
- # ---
689
- # test: Unordered set
690
- # spec: 2.25
691
- # yaml: |
692
- # # sets are represented as a
693
- # # mapping where each key is
694
- # # associated with the empty string
695
- # --- !set
696
- # ? Mark McGwire
697
- # ? Sammy Sosa
698
- # ? Ken Griff
699
- ---
700
- test: Ordered mappings
701
- todo: true
702
- spec: 2.26
703
- yaml: |
704
- # ordered maps are represented as
705
- # a sequence of mappings, with
706
- # each mapping having one key
707
- --- !omap
708
- - Mark McGwire: 65
709
- - Sammy Sosa: 63
710
- - Ken Griffy: 58
711
- ruby: |
712
- YAML::Omap[
713
- 'Mark McGwire', 65,
714
- 'Sammy Sosa', 63,
715
- 'Ken Griffy', 58
716
- ]
717
- ---
718
- test: Invoice
719
- dump_skip: true
720
- spec: 2.27
721
- yaml: |
722
- --- !clarkevans.com,2002/^invoice
723
- invoice: 34843
724
- date : 2001-01-23
725
- bill-to: &id001
726
- given : Chris
727
- family : Dumars
728
- address:
729
- lines: |
730
- 458 Walkman Dr.
731
- Suite #292
732
- city : Royal Oak
733
- state : MI
734
- postal : 48046
735
- ship-to: *id001
736
- product:
737
- -
738
- sku : BL394D
739
- quantity : 4
740
- description : Basketball
741
- price : 450.00
742
- -
743
- sku : BL4438H
744
- quantity : 1
745
- description : Super Hoop
746
- price : 2392.00
747
- tax : 251.42
748
- total: 4443.52
749
- comments: >
750
- Late afternoon is best.
751
- Backup contact is Nancy
752
- Billsmer @ 338-4338.
753
- php: |
754
- array(
755
- 'invoice' => 34843, 'date' => mktime(0, 0, 0, 1, 23, 2001),
756
- 'bill-to' =>
757
- array( 'given' => 'Chris', 'family' => 'Dumars', 'address' => array( 'lines' => "458 Walkman Dr.\nSuite #292\n", 'city' => 'Royal Oak', 'state' => 'MI', 'postal' => 48046 ) )
758
- , 'ship-to' =>
759
- array( 'given' => 'Chris', 'family' => 'Dumars', 'address' => array( 'lines' => "458 Walkman Dr.\nSuite #292\n", 'city' => 'Royal Oak', 'state' => 'MI', 'postal' => 48046 ) )
760
- , 'product' =>
761
- array(
762
- array( 'sku' => 'BL394D', 'quantity' => 4, 'description' => 'Basketball', 'price' => 450.00 ),
763
- array( 'sku' => 'BL4438H', 'quantity' => 1, 'description' => 'Super Hoop', 'price' => 2392.00 )
764
- ),
765
- 'tax' => 251.42, 'total' => 4443.52,
766
- 'comments' => "Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338.\n"
767
- )
768
- ---
769
- test: Log file
770
- todo: true
771
- spec: 2.28
772
- yaml: |
773
- ---
774
- Time: 2001-11-23 15:01:42 -05:00
775
- User: ed
776
- Warning: >
777
- This is an error message
778
- for the log file
779
- ---
780
- Time: 2001-11-23 15:02:31 -05:00
781
- User: ed
782
- Warning: >
783
- A slightly different error
784
- message.
785
- ---
786
- Date: 2001-11-23 15:03:17 -05:00
787
- User: ed
788
- Fatal: >
789
- Unknown variable "bar"
790
- Stack:
791
- - file: TopClass.py
792
- line: 23
793
- code: |
794
- x = MoreObject("345\n")
795
- - file: MoreClass.py
796
- line: 58
797
- code: |-
798
- foo = bar
799
- ruby: |
800
- y = YAML::Stream.new
801
- y.add( { 'Time' => YAML::mktime( 2001, 11, 23, 15, 01, 42, 00, "-05:00" ),
802
- 'User' => 'ed', 'Warning' => "This is an error message for the log file\n" } )
803
- y.add( { 'Time' => YAML::mktime( 2001, 11, 23, 15, 02, 31, 00, "-05:00" ),
804
- 'User' => 'ed', 'Warning' => "A slightly different error message.\n" } )
805
- y.add( { 'Date' => YAML::mktime( 2001, 11, 23, 15, 03, 17, 00, "-05:00" ),
806
- 'User' => 'ed', 'Fatal' => "Unknown variable \"bar\"\n",
807
- 'Stack' => [
808
- { 'file' => 'TopClass.py', 'line' => 23, 'code' => "x = MoreObject(\"345\\n\")\n" },
809
- { 'file' => 'MoreClass.py', 'line' => 58, 'code' => "foo = bar" } ] } )
810
- documents: 3
811
-
812
- ---
813
- test: Throwaway comments
814
- yaml: |
815
- ### These are four throwaway comment ###
816
-
817
- ### lines (the second line is empty). ###
818
- this: | # Comments may trail lines.
819
- contains three lines of text.
820
- The third one starts with a
821
- # character. This isn't a comment.
822
-
823
- # These are three throwaway comment
824
- # lines (the first line is empty).
825
- php: |
826
- array(
827
- 'this' => "contains three lines of text.\nThe third one starts with a\n# character. This isn't a comment.\n"
828
- )
829
- ---
830
- test: Document with a single value
831
- todo: true
832
- yaml: |
833
- --- >
834
- This YAML stream contains a single text value.
835
- The next stream is a log file - a sequence of
836
- log entries. Adding an entry to the log is a
837
- simple matter of appending it at the end.
838
- ruby: |
839
- "This YAML stream contains a single text value. The next stream is a log file - a sequence of log entries. Adding an entry to the log is a simple matter of appending it at the end.\n"
840
- ---
841
- test: Document stream
842
- todo: true
843
- yaml: |
844
- ---
845
- at: 2001-08-12 09:25:00.00 Z
846
- type: GET
847
- HTTP: '1.0'
848
- url: '/index.html'
849
- ---
850
- at: 2001-08-12 09:25:10.00 Z
851
- type: GET
852
- HTTP: '1.0'
853
- url: '/toc.html'
854
- ruby: |
855
- y = YAML::Stream.new
856
- y.add( {
857
- 'at' => Time::utc( 2001, 8, 12, 9, 25, 00 ),
858
- 'type' => 'GET',
859
- 'HTTP' => '1.0',
860
- 'url' => '/index.html'
861
- } )
862
- y.add( {
863
- 'at' => Time::utc( 2001, 8, 12, 9, 25, 10 ),
864
- 'type' => 'GET',
865
- 'HTTP' => '1.0',
866
- 'url' => '/toc.html'
867
- } )
868
- documents: 2
869
-
870
- ---
871
- test: Top level mapping
872
- yaml: |
873
- # This stream is an example of a top-level mapping.
874
- invoice : 34843
875
- date : 2001-01-23
876
- total : 4443.52
877
- php: |
878
- array(
879
- 'invoice' => 34843,
880
- 'date' => mktime(0, 0, 0, 1, 23, 2001),
881
- 'total' => 4443.52
882
- )
883
- ---
884
- test: Single-line documents
885
- todo: true
886
- yaml: |
887
- # The following is a sequence of three documents.
888
- # The first contains an empty mapping, the second
889
- # an empty sequence, and the last an empty string.
890
- --- {}
891
- --- [ ]
892
- --- ''
893
- ruby: |
894
- y = YAML::Stream.new
895
- y.add( {} )
896
- y.add( [] )
897
- y.add( '' )
898
- documents: 3
899
-
900
- ---
901
- test: Document with pause
902
- todo: true
903
- yaml: |
904
- # A communication channel based on a YAML stream.
905
- ---
906
- sent at: 2002-06-06 11:46:25.10 Z
907
- payload: Whatever
908
- # Receiver can process this as soon as the following is sent:
909
- ...
910
- # Even if the next message is sent long after:
911
- ---
912
- sent at: 2002-06-06 12:05:53.47 Z
913
- payload: Whatever
914
- ...
915
- ruby: |
916
- y = YAML::Stream.new
917
- y.add(
918
- { 'sent at' => YAML::mktime( 2002, 6, 6, 11, 46, 25, 0.10 ),
919
- 'payload' => 'Whatever' }
920
- )
921
- y.add(
922
- { "payload" => "Whatever", "sent at" => YAML::mktime( 2002, 6, 6, 12, 5, 53, 0.47 ) }
923
- )
924
- documents: 2
925
-
926
- ---
927
- test: Explicit typing
928
- yaml: |
929
- integer: 12
930
- also int: ! "12"
931
- string: !str 12
932
- php: |
933
- array( 'integer' => 12, 'also int' => 12, 'string' => '12' )
934
- ---
935
- test: Private types
936
- todo: true
937
- yaml: |
938
- # Both examples below make use of the 'x-private:ball'
939
- # type family URI, but with different semantics.
940
- ---
941
- pool: !!ball
942
- number: 8
943
- color: black
944
- ---
945
- bearing: !!ball
946
- material: steel
947
- ruby: |
948
- y = YAML::Stream.new
949
- y.add( { 'pool' =>
950
- YAML::PrivateType.new( 'ball',
951
- { 'number' => 8, 'color' => 'black' } ) }
952
- )
953
- y.add( { 'bearing' =>
954
- YAML::PrivateType.new( 'ball',
955
- { 'material' => 'steel' } ) }
956
- )
957
- documents: 2
958
-
959
- ---
960
- test: Type family under yaml.org
961
- yaml: |
962
- # The URI is 'tag:yaml.org,2002:str'
963
- - !str a Unicode string
964
- php: |
965
- array( 'a Unicode string' )
966
- ---
967
- test: Type family under perl.yaml.org
968
- todo: true
969
- yaml: |
970
- # The URI is 'tag:perl.yaml.org,2002:Text::Tabs'
971
- - !perl/Text::Tabs {}
972
- ruby: |
973
- [ YAML::DomainType.new( 'perl.yaml.org,2002', 'Text::Tabs', {} ) ]
974
- ---
975
- test: Type family under clarkevans.com
976
- todo: true
977
- yaml: |
978
- # The URI is 'tag:clarkevans.com,2003-02:timesheet'
979
- - !clarkevans.com,2003-02/timesheet {}
980
- ruby: |
981
- [ YAML::DomainType.new( 'clarkevans.com,2003-02', 'timesheet', {} ) ]
982
- ---
983
- test: URI Escaping
984
- todo: true
985
- yaml: |
986
- same:
987
- - !domain.tld,2002/type\x30 value
988
- - !domain.tld,2002/type0 value
989
- different: # As far as the YAML parser is concerned
990
- - !domain.tld,2002/type%30 value
991
- - !domain.tld,2002/type0 value
992
- ruby-setup: |
993
- YAML.add_domain_type( "domain.tld,2002", "type0" ) { |type, val|
994
- "ONE: #{val}"
995
- }
996
- YAML.add_domain_type( "domain.tld,2002", "type%30" ) { |type, val|
997
- "TWO: #{val}"
998
- }
999
- ruby: |
1000
- { 'same' => [ 'ONE: value', 'ONE: value' ], 'different' => [ 'TWO: value', 'ONE: value' ] }
1001
- ---
1002
- test: URI Prefixing
1003
- todo: true
1004
- yaml: |
1005
- # 'tag:domain.tld,2002:invoice' is some type family.
1006
- invoice: !domain.tld,2002/^invoice
1007
- # 'seq' is shorthand for 'tag:yaml.org,2002:seq'.
1008
- # This does not effect '^customer' below
1009
- # because it is does not specify a prefix.
1010
- customers: !seq
1011
- # '^customer' is shorthand for the full
1012
- # notation 'tag:domain.tld,2002:customer'.
1013
- - !^customer
1014
- given : Chris
1015
- family : Dumars
1016
- ruby-setup: |
1017
- YAML.add_domain_type( "domain.tld,2002", /(invoice|customer)/ ) { |type, val|
1018
- if val.is_a? ::Hash
1019
- scheme, domain, type = type.split( /:/, 3 )
1020
- val['type'] = "domain #{type}"
1021
- val
1022
- else
1023
- raise YAML::Error, "Not a Hash in domain.tld/invoice: " + val.inspect
1024
- end
1025
- }
1026
- ruby: |
1027
- { "invoice"=> { "customers"=> [ { "given"=>"Chris", "type"=>"domain customer", "family"=>"Dumars" } ], "type"=>"domain invoice" } }
1028
-
1029
- ---
1030
- test: Overriding anchors
1031
- yaml: |
1032
- anchor : &A001 This scalar has an anchor.
1033
- override : &A001 >
1034
- The alias node below is a
1035
- repeated use of this value.
1036
- alias : *A001
1037
- php: |
1038
- array( 'anchor' => 'This scalar has an anchor.',
1039
- 'override' => "The alias node below is a repeated use of this value.\n",
1040
- 'alias' => "The alias node below is a repeated use of this value.\n" )
1041
- ---
1042
- test: Flow and block formatting
1043
- todo: true
1044
- yaml: |
1045
- empty: []
1046
- flow: [ one, two, three # May span lines,
1047
- , four, # indentation is
1048
- five ] # mostly ignored.
1049
- block:
1050
- - First item in top sequence
1051
- -
1052
- - Subordinate sequence entry
1053
- - >
1054
- A folded sequence entry
1055
- - Sixth item in top sequence
1056
- ruby: |
1057
- { 'empty' => [], 'flow' => [ 'one', 'two', 'three', 'four', 'five' ],
1058
- 'block' => [ 'First item in top sequence', [ 'Subordinate sequence entry' ],
1059
- "A folded sequence entry\n", 'Sixth item in top sequence' ] }
1060
- ---
1061
- test: Complete mapping test
1062
- todo: true
1063
- yaml: |
1064
- empty: {}
1065
- flow: { one: 1, two: 2 }
1066
- spanning: { one: 1,
1067
- two: 2 }
1068
- block:
1069
- first : First entry
1070
- second:
1071
- key: Subordinate mapping
1072
- third:
1073
- - Subordinate sequence
1074
- - { }
1075
- - Previous mapping is empty.
1076
- - A key: value pair in a sequence.
1077
- A second: key:value pair.
1078
- - The previous entry is equal to the following one.
1079
- -
1080
- A key: value pair in a sequence.
1081
- A second: key:value pair.
1082
- !float 12 : This key is a float.
1083
- ? >
1084
- ?
1085
- : This key had to be protected.
1086
- "\a" : This key had to be escaped.
1087
- ? >
1088
- This is a
1089
- multi-line
1090
- folded key
1091
- : Whose value is
1092
- also multi-line.
1093
- ? this also works as a key
1094
- : with a value at the next line.
1095
- ?
1096
- - This key
1097
- - is a sequence
1098
- :
1099
- - With a sequence value.
1100
- ?
1101
- This: key
1102
- is a: mapping
1103
- :
1104
- with a: mapping value.
1105
- ruby: |
1106
- { 'empty' => {}, 'flow' => { 'one' => 1, 'two' => 2 },
1107
- 'spanning' => { 'one' => 1, 'two' => 2 },
1108
- 'block' => { 'first' => 'First entry', 'second' =>
1109
- { 'key' => 'Subordinate mapping' }, 'third' =>
1110
- [ 'Subordinate sequence', {}, 'Previous mapping is empty.',
1111
- { 'A key' => 'value pair in a sequence.', 'A second' => 'key:value pair.' },
1112
- 'The previous entry is equal to the following one.',
1113
- { 'A key' => 'value pair in a sequence.', 'A second' => 'key:value pair.' } ],
1114
- 12.0 => 'This key is a float.', "?\n" => 'This key had to be protected.',
1115
- "\a" => 'This key had to be escaped.',
1116
- "This is a multi-line folded key\n" => "Whose value is also multi-line.",
1117
- 'this also works as a key' => 'with a value at the next line.',
1118
- [ 'This key', 'is a sequence' ] => [ 'With a sequence value.' ] } }
1119
- # Couldn't recreate map exactly, so we'll do a detailed check to be sure it's entact
1120
- obj_y['block'].keys.each { |k|
1121
- if Hash === k
1122
- v = obj_y['block'][k]
1123
- if k['This'] == 'key' and k['is a'] == 'mapping' and v['with a'] == 'mapping value.'
1124
- obj_r['block'][k] = v
1125
- end
1126
- end
1127
- }
1128
- ---
1129
- test: Literal explicit indentation
1130
- yaml: |
1131
- # Explicit indentation must
1132
- # be given in all the three
1133
- # following cases.
1134
- leading spaces: |2
1135
- This value starts with four spaces.
1136
-
1137
- leading line break: |2
1138
-
1139
- This value starts with a line break.
1140
-
1141
- leading comment indicator: |2
1142
- # first line starts with a
1143
- # character.
1144
-
1145
- # Explicit indentation may
1146
- # also be given when it is
1147
- # not required.
1148
- redundant: |2
1149
- This value is indented 2 spaces.
1150
- php: |
1151
- array(
1152
- 'leading spaces' => " This value starts with four spaces.\n",
1153
- 'leading line break' => "\nThis value starts with a line break.\n",
1154
- 'leading comment indicator' => "# first line starts with a\n# character.\n",
1155
- 'redundant' => "This value is indented 2 spaces.\n"
1156
- )
1157
- ---
1158
- test: Chomping and keep modifiers
1159
- yaml: |
1160
- clipped: |
1161
- This has one newline.
1162
-
1163
- same as "clipped" above: "This has one newline.\n"
1164
-
1165
- stripped: |-
1166
- This has no newline.
1167
-
1168
- same as "stripped" above: "This has no newline."
1169
-
1170
- kept: |+
1171
- This has two newlines.
1172
-
1173
- same as "kept" above: "This has two newlines.\n\n"
1174
- php: |
1175
- array(
1176
- 'clipped' => "This has one newline.\n",
1177
- 'same as "clipped" above' => "This has one newline.\n",
1178
- 'stripped' => 'This has no newline.',
1179
- 'same as "stripped" above' => 'This has no newline.',
1180
- 'kept' => "This has two newlines.\n\n",
1181
- 'same as "kept" above' => "This has two newlines.\n\n"
1182
- )
1183
- ---
1184
- test: Literal combinations
1185
- todo: true
1186
- yaml: |
1187
- empty: |
1188
-
1189
- literal: |
1190
- The \ ' " characters may be
1191
- freely used. Leading white
1192
- space is significant.
1193
-
1194
- Line breaks are significant.
1195
- Thus this value contains one
1196
- empty line and ends with a
1197
- single line break, but does
1198
- not start with one.
1199
-
1200
- is equal to: "The \\ ' \" characters may \
1201
- be\nfreely used. Leading white\n space \
1202
- is significant.\n\nLine breaks are \
1203
- significant.\nThus this value contains \
1204
- one\nempty line and ends with a\nsingle \
1205
- line break, but does\nnot start with one.\n"
1206
-
1207
- # Comments may follow a block
1208
- # scalar value. They must be
1209
- # less indented.
1210
-
1211
- # Modifiers may be combined in any order.
1212
- indented and chomped: |2-
1213
- This has no newline.
1214
-
1215
- also written as: |-2
1216
- This has no newline.
1217
-
1218
- both are equal to: " This has no newline."
1219
- php: |
1220
- array(
1221
- 'empty' => '',
1222
- 'literal' => "The \\ ' \" characters may be\nfreely used. Leading white\n space " +
1223
- "is significant.\n\nLine breaks are significant.\nThus this value contains one\n" +
1224
- "empty line and ends with a\nsingle line break, but does\nnot start with one.\n",
1225
- 'is equal to' => "The \\ ' \" characters may be\nfreely used. Leading white\n space " +
1226
- "is significant.\n\nLine breaks are significant.\nThus this value contains one\n" +
1227
- "empty line and ends with a\nsingle line break, but does\nnot start with one.\n",
1228
- 'indented and chomped' => ' This has no newline.',
1229
- 'also written as' => ' This has no newline.',
1230
- 'both are equal to' => ' This has no newline.'
1231
- )
1232
- ---
1233
- test: Folded combinations
1234
- todo: true
1235
- yaml: |
1236
- empty: >
1237
-
1238
- one paragraph: >
1239
- Line feeds are converted
1240
- to spaces, so this value
1241
- contains no line breaks
1242
- except for the final one.
1243
-
1244
- multiple paragraphs: >2
1245
-
1246
- An empty line, either
1247
- at the start or in
1248
- the value:
1249
-
1250
- Is interpreted as a
1251
- line break. Thus this
1252
- value contains three
1253
- line breaks.
1254
-
1255
- indented text: >
1256
- This is a folded
1257
- paragraph followed
1258
- by a list:
1259
- * first entry
1260
- * second entry
1261
- Followed by another
1262
- folded paragraph,
1263
- another list:
1264
-
1265
- * first entry
1266
-
1267
- * second entry
1268
-
1269
- And a final folded
1270
- paragraph.
1271
-
1272
- above is equal to: |
1273
- This is a folded paragraph followed by a list:
1274
- * first entry
1275
- * second entry
1276
- Followed by another folded paragraph, another list:
1277
-
1278
- * first entry
1279
-
1280
- * second entry
1281
-
1282
- And a final folded paragraph.
1283
-
1284
- # Explicit comments may follow
1285
- # but must be less indented.
1286
- php: |
1287
- array(
1288
- 'empty' => '',
1289
- 'one paragraph' => 'Line feeds are converted to spaces, so this value'.
1290
- " contains no line breaks except for the final one.\n",
1291
- 'multiple paragraphs' => "\nAn empty line, either at the start or in the value:\n".
1292
- "Is interpreted as a line break. Thus this value contains three line breaks.\n",
1293
- 'indented text' => "This is a folded paragraph followed by a list:\n".
1294
- " * first entry\n * second entry\nFollowed by another folded paragraph, ".
1295
- "another list:\n\n * first entry\n\n * second entry\n\nAnd a final folded paragraph.\n",
1296
- 'above is equal to' => "This is a folded paragraph followed by a list:\n".
1297
- " * first entry\n * second entry\nFollowed by another folded paragraph, ".
1298
- "another list:\n\n * first entry\n\n * second entry\n\nAnd a final folded paragraph.\n"
1299
- )
1300
- ---
1301
- test: Single quotes
1302
- todo: true
1303
- yaml: |
1304
- empty: ''
1305
- second: '! : \ etc. can be used freely.'
1306
- third: 'a single quote '' must be escaped.'
1307
- span: 'this contains
1308
- six spaces
1309
-
1310
- and one
1311
- line break'
1312
- is same as: "this contains six spaces\nand one line break"
1313
- php: |
1314
- array(
1315
- 'empty' => '',
1316
- 'second' => '! : \\ etc. can be used freely.',
1317
- 'third' => "a single quote ' must be escaped.",
1318
- 'span' => "this contains six spaces\nand one line break",
1319
- 'is same as' => "this contains six spaces\nand one line break"
1320
- )
1321
- ---
1322
- test: Double quotes
1323
- todo: true
1324
- yaml: |
1325
- empty: ""
1326
- second: "! : etc. can be used freely."
1327
- third: "a \" or a \\ must be escaped."
1328
- fourth: "this value ends with an LF.\n"
1329
- span: "this contains
1330
- four \
1331
- spaces"
1332
- is equal to: "this contains four spaces"
1333
- php: |
1334
- array(
1335
- 'empty' => '',
1336
- 'second' => '! : etc. can be used freely.',
1337
- 'third' => 'a " or a \\ must be escaped.',
1338
- 'fourth' => "this value ends with an LF.\n",
1339
- 'span' => "this contains four spaces",
1340
- 'is equal to' => "this contains four spaces"
1341
- )
1342
- ---
1343
- test: Unquoted strings
1344
- todo: true
1345
- yaml: |
1346
- first: There is no unquoted empty string.
1347
-
1348
- second: 12 ## This is an integer.
1349
-
1350
- third: !str 12 ## This is a string.
1351
-
1352
- span: this contains
1353
- six spaces
1354
-
1355
- and one
1356
- line break
1357
-
1358
- indicators: this has no comments.
1359
- #:foo and bar# are
1360
- both text.
1361
-
1362
- flow: [ can span
1363
- lines, # comment
1364
- like
1365
- this ]
1366
-
1367
- note: { one-line keys: but multi-line values }
1368
-
1369
- php: |
1370
- array(
1371
- 'first' => 'There is no unquoted empty string.',
1372
- 'second' => 12,
1373
- 'third' => '12',
1374
- 'span' => "this contains six spaces\nand one line break",
1375
- 'indicators' => "this has no comments. #:foo and bar# are both text.",
1376
- 'flow' => [ 'can span lines', 'like this' ],
1377
- 'note' => { 'one-line keys' => 'but multi-line values' }
1378
- )
1379
- ---
1380
- test: Spanning sequences
1381
- todo: true
1382
- yaml: |
1383
- # The following are equal seqs
1384
- # with different identities.
1385
- flow: [ one, two ]
1386
- spanning: [ one,
1387
- two ]
1388
- block:
1389
- - one
1390
- - two
1391
- php: |
1392
- array(
1393
- 'flow' => [ 'one', 'two' ],
1394
- 'spanning' => [ 'one', 'two' ],
1395
- 'block' => [ 'one', 'two' ]
1396
- )
1397
- ---
1398
- test: Flow mappings
1399
- yaml: |
1400
- # The following are equal maps
1401
- # with different identities.
1402
- flow: { one: 1, two: 2 }
1403
- block:
1404
- one: 1
1405
- two: 2
1406
- php: |
1407
- array(
1408
- 'flow' => array( 'one' => 1, 'two' => 2 ),
1409
- 'block' => array( 'one' => 1, 'two' => 2 )
1410
- )
1411
- ---
1412
- test: Representations of 12
1413
- todo: true
1414
- yaml: |
1415
- - 12 # An integer
1416
- # The following scalars
1417
- # are loaded to the
1418
- # string value '1' '2'.
1419
- - !str 12
1420
- - '12'
1421
- - "12"
1422
- - "\
1423
- 1\
1424
- 2\
1425
- "
1426
- # Strings containing paths and regexps can be unquoted:
1427
- - /foo/bar
1428
- - d:/foo/bar
1429
- - foo/bar
1430
- - /a.*b/
1431
- php: |
1432
- array( 12, '12', '12', '12', '12', '/foo/bar', 'd:/foo/bar', 'foo/bar', '/a.*b/' )
1433
- ---
1434
- test: "Null"
1435
- todo: true
1436
- yaml: |
1437
- canonical: ~
1438
-
1439
- english: null
1440
-
1441
- # This sequence has five
1442
- # entries, two with values.
1443
- sparse:
1444
- - ~
1445
- - 2nd entry
1446
- - Null
1447
- - 4th entry
1448
- -
1449
-
1450
- four: This mapping has five keys,
1451
- only two with values.
1452
-
1453
- php: |
1454
- array (
1455
- 'canonical' => null,
1456
- 'english' => null,
1457
- 'sparse' => array( null, '2nd entry', null, '4th entry', null ]),
1458
- 'four' => 'This mapping has five keys, only two with values.'
1459
- )
1460
- ---
1461
- test: Omap
1462
- todo: true
1463
- yaml: |
1464
- # Explicitly typed dictionary.
1465
- Bestiary: !omap
1466
- - aardvark: African pig-like ant eater. Ugly.
1467
- - anteater: South-American ant eater. Two species.
1468
- - anaconda: South-American constrictor snake. Scary.
1469
- # Etc.
1470
- ruby: |
1471
- {
1472
- 'Bestiary' => YAML::Omap[
1473
- 'aardvark', 'African pig-like ant eater. Ugly.',
1474
- 'anteater', 'South-American ant eater. Two species.',
1475
- 'anaconda', 'South-American constrictor snake. Scary.'
1476
- ]
1477
- }
1478
-
1479
- ---
1480
- test: Pairs
1481
- todo: true
1482
- yaml: |
1483
- # Explicitly typed pairs.
1484
- tasks: !pairs
1485
- - meeting: with team.
1486
- - meeting: with boss.
1487
- - break: lunch.
1488
- - meeting: with client.
1489
- ruby: |
1490
- {
1491
- 'tasks' => YAML::Pairs[
1492
- 'meeting', 'with team.',
1493
- 'meeting', 'with boss.',
1494
- 'break', 'lunch.',
1495
- 'meeting', 'with client.'
1496
- ]
1497
- }
1498
-
1499
- ---
1500
- test: Set
1501
- todo: true
1502
- yaml: |
1503
- # Explicitly typed set.
1504
- baseball players: !set
1505
- Mark McGwire:
1506
- Sammy Sosa:
1507
- Ken Griffey:
1508
- ruby: |
1509
- {
1510
- 'baseball players' => YAML::Set[
1511
- 'Mark McGwire', nil,
1512
- 'Sammy Sosa', nil,
1513
- 'Ken Griffey', nil
1514
- ]
1515
- }
1516
-
1517
- ---
1518
- test: Boolean
1519
- yaml: |
1520
- false: used as key
1521
- logical: true
1522
- answer: false
1523
- php: |
1524
- array(
1525
- false => 'used as key',
1526
- 'logical' => true,
1527
- 'answer' => false
1528
- )
1529
- ---
1530
- test: Integer
1531
- yaml: |
1532
- canonical: 12345
1533
- decimal: +12,345
1534
- octal: 014
1535
- hexadecimal: 0xC
1536
- php: |
1537
- array(
1538
- 'canonical' => 12345,
1539
- 'decimal' => 12345,
1540
- 'octal' => 12,
1541
- 'hexadecimal' => 12
1542
- )
1543
- ---
1544
- test: Float
1545
- yaml: |
1546
- canonical: 1.23015e+3
1547
- exponential: 12.3015e+02
1548
- fixed: 1,230.15
1549
- negative infinity: -.inf
1550
- not a number: .NaN
1551
- php: |
1552
- array(
1553
- 'canonical' => 1230.15,
1554
- 'exponential' => 1230.15,
1555
- 'fixed' => 1230.15,
1556
- 'negative infinity' => log(0),
1557
- 'not a number' => -log(0)
1558
- )
1559
- ---
1560
- test: Timestamp
1561
- todo: true
1562
- yaml: |
1563
- canonical: 2001-12-15T02:59:43.1Z
1564
- valid iso8601: 2001-12-14t21:59:43.10-05:00
1565
- space separated: 2001-12-14 21:59:43.10 -05:00
1566
- date (noon UTC): 2002-12-14
1567
- ruby: |
1568
- array(
1569
- 'canonical' => YAML::mktime( 2001, 12, 15, 2, 59, 43, 0.10 ),
1570
- 'valid iso8601' => YAML::mktime( 2001, 12, 14, 21, 59, 43, 0.10, "-05:00" ),
1571
- 'space separated' => YAML::mktime( 2001, 12, 14, 21, 59, 43, 0.10, "-05:00" ),
1572
- 'date (noon UTC)' => Date.new( 2002, 12, 14 )
1573
- )
1574
- ---
1575
- test: Binary
1576
- todo: true
1577
- yaml: |
1578
- canonical: !binary "\
1579
- R0lGODlhDAAMAIQAAP//9/X17unp5WZmZgAAAOfn515eXvPz7Y6OjuDg4J+fn5\
1580
- OTk6enp56enmlpaWNjY6Ojo4SEhP/++f/++f/++f/++f/++f/++f/++f/++f/+\
1581
- +f/++f/++f/++f/++f/++SH+Dk1hZGUgd2l0aCBHSU1QACwAAAAADAAMAAAFLC\
1582
- AgjoEwnuNAFOhpEMTRiggcz4BNJHrv/zCFcLiwMWYNG84BwwEeECcgggoBADs="
1583
- base64: !binary |
1584
- R0lGODlhDAAMAIQAAP//9/X17unp5WZmZgAAAOfn515eXvPz7Y6OjuDg4J+fn5
1585
- OTk6enp56enmlpaWNjY6Ojo4SEhP/++f/++f/++f/++f/++f/++f/++f/++f/+
1586
- +f/++f/++f/++f/++f/++SH+Dk1hZGUgd2l0aCBHSU1QACwAAAAADAAMAAAFLC
1587
- AgjoEwnuNAFOhpEMTRiggcz4BNJHrv/zCFcLiwMWYNG84BwwEeECcgggoBADs=
1588
- description: >
1589
- The binary value above is a tiny arrow
1590
- encoded as a gif image.
1591
- ruby-setup: |
1592
- arrow_gif = "GIF89a\f\000\f\000\204\000\000\377\377\367\365\365\356\351\351\345fff\000\000\000\347\347\347^^^\363\363\355\216\216\216\340\340\340\237\237\237\223\223\223\247\247\247\236\236\236iiiccc\243\243\243\204\204\204\377\376\371\377\376\371\377\376\371\377\376\371\377\376\371\377\376\371\377\376\371\377\376\371\377\376\371\377\376\371\377\376\371\377\376\371\377\376\371\377\376\371!\376\016Made with GIMP\000,\000\000\000\000\f\000\f\000\000\005, \216\2010\236\343@\024\350i\020\304\321\212\010\034\317\200M$z\357\3770\205p\270\2601f\r\e\316\001\303\001\036\020' \202\n\001\000;"
1593
- ruby: |
1594
- {
1595
- 'canonical' => arrow_gif,
1596
- 'base64' => arrow_gif,
1597
- 'description' => "The binary value above is a tiny arrow encoded as a gif image.\n"
1598
- }
1599
-
1600
- ---
1601
- test: Merge key
1602
- todo: true
1603
- yaml: |
1604
- ---
1605
- - &CENTER { x: 1, y: 2 }
1606
- - &LEFT { x: 0, y: 2 }
1607
- - &BIG { r: 10 }
1608
- - &SMALL { r: 1 }
1609
-
1610
- # All the following maps are equal:
1611
-
1612
- - # Explicit keys
1613
- x: 1
1614
- y: 2
1615
- r: 10
1616
- label: center/big
1617
-
1618
- - # Merge one map
1619
- << : *CENTER
1620
- r: 10
1621
- label: center/big
1622
-
1623
- - # Merge multiple maps
1624
- << : [ *CENTER, *BIG ]
1625
- label: center/big
1626
-
1627
- - # Override
1628
- << : [ *BIG, *LEFT, *SMALL ]
1629
- x: 1
1630
- label: center/big
1631
-
1632
- ruby-setup: |
1633
- center = { 'x' => 1, 'y' => 2 }
1634
- left = { 'x' => 0, 'y' => 2 }
1635
- big = { 'r' => 10 }
1636
- small = { 'r' => 1 }
1637
- node1 = { 'x' => 1, 'y' => 2, 'r' => 10, 'label' => 'center/big' }
1638
- node2 = center.dup
1639
- node2.update( { 'r' => 10, 'label' => 'center/big' } )
1640
- node3 = big.dup
1641
- node3.update( center )
1642
- node3.update( { 'label' => 'center/big' } )
1643
- node4 = small.dup
1644
- node4.update( left )
1645
- node4.update( big )
1646
- node4.update( { 'x' => 1, 'label' => 'center/big' } )
1647
-
1648
- ruby: |
1649
- [
1650
- center, left, big, small, node1, node2, node3, node4
1651
- ]
1652
-
1653
- ---
1654
- test: Default key
1655
- todo: true
1656
- yaml: |
1657
- --- # Old schema
1658
- link with:
1659
- - library1.dll
1660
- - library2.dll
1661
- --- # New schema
1662
- link with:
1663
- - = : library1.dll
1664
- version: 1.2
1665
- - = : library2.dll
1666
- version: 2.3
1667
- ruby: |
1668
- y = YAML::Stream.new
1669
- y.add( { 'link with' => [ 'library1.dll', 'library2.dll' ] } )
1670
- obj_h = Hash[ 'version' => 1.2 ]
1671
- obj_h.default = 'library1.dll'
1672
- obj_h2 = Hash[ 'version' => 2.3 ]
1673
- obj_h2.default = 'library2.dll'
1674
- y.add( { 'link with' => [ obj_h, obj_h2 ] } )
1675
- documents: 2
1676
-
1677
- ---
1678
- test: Special keys
1679
- todo: true
1680
- yaml: |
1681
- "!": These three keys
1682
- "&": had to be quoted
1683
- "=": and are normal strings.
1684
- # NOTE: the following node should NOT be serialized this way.
1685
- encoded node :
1686
- !special '!' : '!type'
1687
- !special|canonical '&' : 12
1688
- = : value
1689
- # The proper way to serialize the above node is as follows:
1690
- node : !!type &12 value
1691
- ruby: |
1692
- { '!' => 'These three keys', '&' => 'had to be quoted',
1693
- '=' => 'and are normal strings.',
1694
- 'encoded node' => YAML::PrivateType.new( 'type', 'value' ),
1695
- 'node' => YAML::PrivateType.new( 'type', 'value' ) }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/YtsTypeTransfers.yml DELETED
@@ -1,244 +0,0 @@
1
- --- %YAML:1.0
2
- test: Strings
3
- brief: >
4
- Any group of characters beginning with an
5
- alphabetic or numeric character is a string,
6
- unless it belongs to one of the groups below
7
- (such as an Integer or Time).
8
- yaml: |
9
- String
10
- php: |
11
- 'String'
12
- ---
13
- test: String characters
14
- brief: >
15
- A string can contain any alphabetic or
16
- numeric character, along with many
17
- punctuation characters, including the
18
- period, dash, space, quotes, exclamation, and
19
- question mark.
20
- yaml: |
21
- - What's Yaml?
22
- - It's for writing data structures in plain text.
23
- - And?
24
- - And what? That's not good enough for you?
25
- - No, I mean, "And what about Yaml?"
26
- - Oh, oh yeah. Uh.. Yaml for Ruby.
27
- php: |
28
- array(
29
- "What's Yaml?",
30
- "It's for writing data structures in plain text.",
31
- "And?",
32
- "And what? That's not good enough for you?",
33
- "No, I mean, \"And what about Yaml?\"",
34
- "Oh, oh yeah. Uh.. Yaml for Ruby."
35
- )
36
- ---
37
- test: Indicators in Strings
38
- brief: >
39
- Be careful using indicators in strings. In particular,
40
- the comma, colon, and pound sign must be used carefully.
41
- yaml: |
42
- the colon followed by space is an indicator: but is a string:right here
43
- same for the pound sign: here we have it#in a string
44
- the comma can, honestly, be used in most cases: [ but not in, inline collections ]
45
- php: |
46
- array(
47
- 'the colon followed by space is an indicator' => 'but is a string:right here',
48
- 'same for the pound sign' => 'here we have it#in a string',
49
- 'the comma can, honestly, be used in most cases' => array('but not in', 'inline collections')
50
- )
51
- ---
52
- test: Forcing Strings
53
- brief: >
54
- Any YAML type can be forced into a string using the
55
- explicit !str method.
56
- yaml: |
57
- date string: !str 2001-08-01
58
- number string: !str 192
59
- php: |
60
- array(
61
- 'date string' => '2001-08-01',
62
- 'number string' => '192'
63
- )
64
- ---
65
- test: Single-quoted Strings
66
- brief: >
67
- You can also enclose your strings within single quotes,
68
- which allows use of slashes, colons, and other indicators
69
- freely. Inside single quotes, you can represent a single
70
- quote in your string by using two single quotes next to
71
- each other.
72
- yaml: |
73
- all my favorite symbols: '#:!/%.)'
74
- a few i hate: '&(*'
75
- why do i hate them?: 'it''s very hard to explain'
76
- entities: '&pound; me'
77
- php: |
78
- array(
79
- 'all my favorite symbols' => '#:!/%.)',
80
- 'a few i hate' => '&(*',
81
- 'why do i hate them?' => 'it\'s very hard to explain',
82
- 'entities' => '&pound; me'
83
- )
84
- ---
85
- test: Double-quoted Strings
86
- brief: >
87
- Enclosing strings in double quotes allows you
88
- to use escapings to represent ASCII and
89
- Unicode characters.
90
- yaml: |
91
- i know where i want my line breaks: "one here\nand another here\n"
92
- php: |
93
- array(
94
- 'i know where i want my line breaks' => "one here\nand another here\n"
95
- )
96
- ---
97
- test: Multi-line Quoted Strings
98
- todo: true
99
- brief: >
100
- Both single- and double-quoted strings may be
101
- carried on to new lines in your YAML document.
102
- They must be indented a step and indentation
103
- is interpreted as a single space.
104
- yaml: |
105
- i want a long string: "so i'm going to
106
- let it go on and on to other lines
107
- until i end it with a quote."
108
- php: |
109
- array('i want a long string' => "so i'm going to ".
110
- "let it go on and on to other lines ".
111
- "until i end it with a quote."
112
- )
113
-
114
- ---
115
- test: Plain scalars
116
- todo: true
117
- brief: >
118
- Unquoted strings may also span multiple lines, if they
119
- are free of YAML space indicators and indented.
120
- yaml: |
121
- - My little toe is broken in two places;
122
- - I'm crazy to have skied this way;
123
- - I'm not the craziest he's seen, since there was always the German guy
124
- who skied for 3 hours on a broken shin bone (just below the kneecap);
125
- - Nevertheless, second place is respectable, and he doesn't
126
- recommend going for the record;
127
- - He's going to put my foot in plaster for a month;
128
- - This would impair my skiing ability somewhat for the
129
- duration, as can be imagined.
130
- php: |
131
- array(
132
- "My little toe is broken in two places;",
133
- "I'm crazy to have skied this way;",
134
- "I'm not the craziest he's seen, since there was always ".
135
- "the German guy who skied for 3 hours on a broken shin ".
136
- "bone (just below the kneecap);",
137
- "Nevertheless, second place is respectable, and he doesn't ".
138
- "recommend going for the record;",
139
- "He's going to put my foot in plaster for a month;",
140
- "This would impair my skiing ability somewhat for the duration, ".
141
- "as can be imagined."
142
- )
143
- ---
144
- test: 'Null'
145
- brief: >
146
- You can use the tilde '~' character for a null value.
147
- yaml: |
148
- name: Mr. Show
149
- hosted by: Bob and David
150
- date of next season: ~
151
- php: |
152
- array(
153
- 'name' => 'Mr. Show',
154
- 'hosted by' => 'Bob and David',
155
- 'date of next season' => null
156
- )
157
- ---
158
- test: Boolean
159
- brief: >
160
- You can use 'true' and 'false' for Boolean values.
161
- yaml: |
162
- Is Gus a Liar?: true
163
- Do I rely on Gus for Sustenance?: false
164
- php: |
165
- array(
166
- 'Is Gus a Liar?' => true,
167
- 'Do I rely on Gus for Sustenance?' => false
168
- )
169
- ---
170
- test: Integers
171
- dump_skip: true
172
- brief: >
173
- An integer is a series of numbers, optionally
174
- starting with a positive or negative sign. Integers
175
- may also contain commas for readability.
176
- yaml: |
177
- zero: 0
178
- simple: 12
179
- one-thousand: 1,000
180
- negative one-thousand: -1,000
181
- php: |
182
- array(
183
- 'zero' => 0,
184
- 'simple' => 12,
185
- 'one-thousand' => 1000,
186
- 'negative one-thousand' => -1000
187
- )
188
- ---
189
- test: Integers as Map Keys
190
- brief: >
191
- An integer can be used a dictionary key.
192
- yaml: |
193
- 1: one
194
- 2: two
195
- 3: three
196
- php: |
197
- array(
198
- 1 => 'one',
199
- 2 => 'two',
200
- 3 => 'three'
201
- )
202
- ---
203
- test: Floats
204
- dump_skip: true
205
- brief: >
206
- Floats are represented by numbers with decimals,
207
- allowing for scientific notation, as well as
208
- positive and negative infinity and "not a number."
209
- yaml: |
210
- a simple float: 2.00
211
- larger float: 1,000.09
212
- scientific notation: 1.00009e+3
213
- php: |
214
- array(
215
- 'a simple float' => 2.0,
216
- 'larger float' => 1000.09,
217
- 'scientific notation' => 1000.09
218
- )
219
- ---
220
- test: Time
221
- todo: true
222
- brief: >
223
- You can represent timestamps by using
224
- ISO8601 format, or a variation which
225
- allows spaces between the date, time and
226
- time zone.
227
- yaml: |
228
- iso8601: 2001-12-14t21:59:43.10-05:00
229
- space separated: 2001-12-14 21:59:43.10 -05:00
230
- php: |
231
- array(
232
- 'iso8601' => mktime( 2001, 12, 14, 21, 59, 43, 0.10, "-05:00" ),
233
- 'space separated' => mktime( 2001, 12, 14, 21, 59, 43, 0.10, "-05:00" )
234
- )
235
- ---
236
- test: Date
237
- todo: true
238
- brief: >
239
- A date can be represented by its year,
240
- month and day in ISO8601 order.
241
- yaml: |
242
- 1976-07-31
243
- php: |
244
- date( 1976, 7, 31 )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/embededPhp.yml DELETED
@@ -1 +0,0 @@
1
- value: <?php echo 1 + 2 + 3 ?>
 
vendor/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/escapedCharacters.yml DELETED
@@ -1,147 +0,0 @@
1
- test: outside double quotes
2
- yaml: |
3
- \0 \ \a \b \n
4
- php: |
5
- "\\0 \\ \\a \\b \\n"
6
- ---
7
- test: null
8
- yaml: |
9
- "\0"
10
- php: |
11
- "\x00"
12
- ---
13
- test: bell
14
- yaml: |
15
- "\a"
16
- php: |
17
- "\x07"
18
- ---
19
- test: backspace
20
- yaml: |
21
- "\b"
22
- php: |
23
- "\x08"
24
- ---
25
- test: horizontal tab (1)
26
- yaml: |
27
- "\t"
28
- php: |
29
- "\x09"
30
- ---
31
- test: horizontal tab (2)
32
- yaml: |
33
- "\ "
34
- php: |
35
- "\x09"
36
- ---
37
- test: line feed
38
- yaml: |
39
- "\n"
40
- php: |
41
- "\x0a"
42
- ---
43
- test: vertical tab
44
- yaml: |
45
- "\v"
46
- php: |
47
- "\x0b"
48
- ---
49
- test: form feed
50
- yaml: |
51
- "\f"
52
- php: |
53
- "\x0c"
54
- ---
55
- test: carriage return
56
- yaml: |
57
- "\r"
58
- php: |
59
- "\x0d"
60
- ---
61
- test: escape
62
- yaml: |
63
- "\e"
64
- php: |
65
- "\x1b"
66
- ---
67
- test: space
68
- yaml: |
69
- "\ "
70
- php: |
71
- "\x20"
72
- ---
73
- test: slash
74
- yaml: |
75
- "\/"
76
- php: |
77
- "\x2f"
78
- ---
79
- test: backslash
80
- yaml: |
81
- "\\"
82
- php: |
83
- "\\"
84
- ---
85
- test: Unicode next line
86
- yaml: |
87
- "\N"
88
- php: |
89
- "\xc2\x85"
90
- ---
91
- test: Unicode non-breaking space
92
- yaml: |
93
- "\_"
94
- php: |
95
- "\xc2\xa0"
96
- ---
97
- test: Unicode line separator
98
- yaml: |
99
- "\L"
100
- php: |
101
- "\xe2\x80\xa8"
102
- ---
103
- test: Unicode paragraph separator
104
- yaml: |
105
- "\P"
106
- php: |
107
- "\xe2\x80\xa9"
108
- ---
109
- test: Escaped 8-bit Unicode
110
- yaml: |
111
- "\x42"
112
- php: |
113
- "B"
114
- ---
115
- test: Escaped 16-bit Unicode
116
- yaml: |
117
- "\u20ac"
118
- php: |
119
- "\xe2\x82\xac"
120
- ---
121
- test: Escaped 32-bit Unicode
122
- yaml: |
123
- "\U00000043"
124
- php: |
125
- "C"
126
- ---
127
- test: Example 5.13 Escaped Characters
128
- note: |
129
- Currently throws an error parsing first line. Maybe Symfony Yaml doesn't support
130
- continuation of string across multiple lines? Keeping test here but disabled.
131
- todo: true
132
- yaml: |
133
- "Fun with \\
134
- \" \a \b \e \f \
135
- \n \r \t \v \0 \
136
- \ \_ \N \L \P \
137
- \x41 \u0041 \U00000041"
138
- php: |
139
- "Fun with \x5C\n\x22 \x07 \x08 \x1B \x0C\n\x0A \x0D \x09 \x0B \x00\n\x20 \xA0 \x85 \xe2\x80\xa8 \xe2\x80\xa9\nA A A"
140
- ---
141
- test: Double quotes with a line feed
142
- yaml: |
143
- { double: "some value\n \"some quoted string\" and 'some single quotes one'" }
144
- php: |
145
- array(
146
- 'double' => "some value\n \"some quoted string\" and 'some single quotes one'"
147
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/index.yml DELETED
@@ -1,18 +0,0 @@
1
- - escapedCharacters
2
- - sfComments
3
- - sfCompact
4
- - sfTests
5
- - sfObjects
6
- - sfMergeKey
7
- - sfQuotes
8
- - YtsAnchorAlias
9
- - YtsBasicTests
10
- - YtsBlockMapping
11
- - YtsDocumentSeparator
12
- - YtsErrorTests
13
- - YtsFlowCollections
14
- - YtsFoldedScalars
15
- - YtsNullsAndEmpties
16
- - YtsSpecificationExamples
17
- - YtsTypeTransfers
18
- - unindentedCollections
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/sfComments.yml DELETED
@@ -1,65 +0,0 @@
1
- --- %YAML:1.0
2
- test: Comments at the end of a line
3
- brief: >
4
- Comments at the end of a line
5
- yaml: |
6
- ex1: "foo # bar"
7
- ex2: "foo # bar" # comment
8
- ex3: 'foo # bar' # comment
9
- ex4: foo # comment
10
- php: |
11
- array('ex1' => 'foo # bar', 'ex2' => 'foo # bar', 'ex3' => 'foo # bar', 'ex4' => 'foo')
12
- ---
13
- test: Comments in the middle
14
- brief: >
15
- Comments in the middle
16
- yaml: |
17
- foo:
18
- # some comment
19
- # some comment
20
- bar: foo
21
- # some comment
22
- # some comment
23
- php: |
24
- array('foo' => array('bar' => 'foo'))
25
- ---
26
- test: Comments on a hash line
27
- brief: >
28
- Comments on a hash line
29
- yaml: |
30
- foo: # a comment
31
- foo: bar # a comment
32
- php: |
33
- array('foo' => array('foo' => 'bar'))
34
- ---
35
- test: 'Value starting with a #'
36
- brief: >
37
- 'Value starting with a #'
38
- yaml: |
39
- foo: '#bar'
40
- php: |
41
- array('foo' => '#bar')
42
- ---
43
- test: Document starting with a comment and a separator
44
- brief: >
45
- Commenting before document start is allowed
46
- yaml: |
47
- # document comment
48
- ---
49
- foo: bar # a comment
50
- php: |
51
- array('foo' => 'bar')
52
- ---
53
- test: Comment containing a colon on a hash line
54
- brief: >
55
- Comment containing a colon on a scalar line
56
- yaml: 'foo # comment: this is also part of the comment'
57
- php: |
58
- 'foo'
59
- ---
60
- test: 'Hash key containing a #'
61
- brief: >
62
- 'Hash key containing a #'
63
- yaml: 'foo#bar: baz'
64
- php: |
65
- array('foo#bar' => 'baz')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/sfCompact.yml DELETED
@@ -1,159 +0,0 @@
1
- --- %YAML:1.0
2
- test: Compact notation
3
- brief: |
4
- Compact notation for sets of mappings with single element
5
- yaml: |
6
- ---
7
- # products purchased
8
- - item : Super Hoop
9
- - item : Basketball
10
- quantity: 1
11
- - item:
12
- name: Big Shoes
13
- nick: Biggies
14
- quantity: 1
15
- php: |
16
- array (
17
- array (
18
- 'item' => 'Super Hoop',
19
- ),
20
- array (
21
- 'item' => 'Basketball',
22
- 'quantity' => 1,
23
- ),
24
- array (
25
- 'item' => array(
26
- 'name' => 'Big Shoes',
27
- 'nick' => 'Biggies'
28
- ),
29
- 'quantity' => 1
30
- )
31
- )
32
- ---
33
- test: Compact notation combined with inline notation
34
- brief: |
35
- Combinations of compact and inline notation are allowed
36
- yaml: |
37
- ---
38
- items:
39
- - { item: Super Hoop, quantity: 1 }
40
- - [ Basketball, Big Shoes ]
41
- php: |
42
- array (
43
- 'items' => array (
44
- array (
45
- 'item' => 'Super Hoop',
46
- 'quantity' => 1,
47
- ),
48
- array (
49
- 'Basketball',
50
- 'Big Shoes'
51
- )
52
- )
53
- )
54
- --- %YAML:1.0
55
- test: Compact notation
56
- brief: |
57
- Compact notation for sets of mappings with single element
58
- yaml: |
59
- ---
60
- # products purchased
61
- - item : Super Hoop
62
- - item : Basketball
63
- quantity: 1
64
- - item:
65
- name: Big Shoes
66
- nick: Biggies
67
- quantity: 1
68
- php: |
69
- array (
70
- array (
71
- 'item' => 'Super Hoop',
72
- ),
73
- array (
74
- 'item' => 'Basketball',
75
- 'quantity' => 1,
76
- ),
77
- array (
78
- 'item' => array(
79
- 'name' => 'Big Shoes',
80
- 'nick' => 'Biggies'
81
- ),
82
- 'quantity' => 1
83
- )
84
- )
85
- ---
86
- test: Compact notation combined with inline notation
87
- brief: |
88
- Combinations of compact and inline notation are allowed
89
- yaml: |
90
- ---
91
- items:
92
- - { item: Super Hoop, quantity: 1 }
93
- - [ Basketball, Big Shoes ]
94
- php: |
95
- array (
96
- 'items' => array (
97
- array (
98
- 'item' => 'Super Hoop',
99
- 'quantity' => 1,
100
- ),
101
- array (
102
- 'Basketball',
103
- 'Big Shoes'
104
- )
105
- )
106
- )
107
- --- %YAML:1.0
108
- test: Compact notation
109
- brief: |
110
- Compact notation for sets of mappings with single element
111
- yaml: |
112
- ---
113
- # products purchased
114
- - item : Super Hoop
115
- - item : Basketball
116
- quantity: 1
117
- - item:
118
- name: Big Shoes
119
- nick: Biggies
120
- quantity: 1
121
- php: |
122
- array (
123
- array (
124
- 'item' => 'Super Hoop',
125
- ),
126
- array (
127
- 'item' => 'Basketball',
128
- 'quantity' => 1,
129
- ),
130
- array (
131
- 'item' => array(
132
- 'name' => 'Big Shoes',
133
- 'nick' => 'Biggies'
134
- ),
135
- 'quantity' => 1
136
- )
137
- )
138
- ---
139
- test: Compact notation combined with inline notation
140
- brief: |
141
- Combinations of compact and inline notation are allowed
142
- yaml: |
143
- ---
144
- items:
145
- - { item: Super Hoop, quantity: 1 }
146
- - [ Basketball, Big Shoes ]
147
- php: |
148
- array (
149
- 'items' => array (
150
- array (
151
- 'item' => 'Super Hoop',
152
- 'quantity' => 1,
153
- ),
154
- array (
155
- 'Basketball',
156
- 'Big Shoes'
157
- )
158
- )
159
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/sfMergeKey.yml DELETED
@@ -1,27 +0,0 @@
1
- --- %YAML:1.0
2
- test: Simple In Place Substitution
3
- brief: >
4
- If you want to reuse an entire alias, only overwriting what is different
5
- you can use a << in place substitution. This is not part of the official
6
- YAML spec, but a widely implemented extension. See the following URL for
7
- details: http://yaml.org/type/merge.html
8
- yaml: |
9
- foo: &foo
10
- a: Steve
11
- b: Clark
12
- c: Brian
13
- bar: &bar
14
- <<: *foo
15
- x: Oren
16
- foo2: &foo2
17
- a: Ballmer
18
- ding: &dong [ fi, fei, fo, fam]
19
- check:
20
- <<:
21
- - *foo
22
- - *dong
23
- isit: tested
24
- head:
25
- <<: [ *foo , *dong , *foo2 ]
26
- php: |
27
- array('foo' => array('a' => 'Steve', 'b' => 'Clark', 'c' => 'Brian'), 'bar' => array('a' => 'Steve', 'b' => 'Clark', 'c' => 'Brian', 'x' => 'Oren'), 'foo2' => array('a' => 'Ballmer'), 'ding' => array('fi', 'fei', 'fo', 'fam'), 'check' => array('a' => 'Steve', 'b' => 'Clark', 'c' => 'Brian', 'fi', 'fei', 'fo', 'fam', 'isit' => 'tested'), 'head' => array('a' => 'Ballmer', 'b' => 'Clark', 'c' => 'Brian', 'fi', 'fei', 'fo', 'fam'))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/sfObjects.yml DELETED
@@ -1,11 +0,0 @@
1
- --- %YAML:1.0
2
- test: Objects
3
- brief: >
4
- Comments at the end of a line
5
- yaml: |
6
- ex1: "foo # bar"
7
- ex2: "foo # bar" # comment
8
- ex3: 'foo # bar' # comment
9
- ex4: foo # comment
10
- php: |
11
- array('ex1' => 'foo # bar', 'ex2' => 'foo # bar', 'ex3' => 'foo # bar', 'ex4' => 'foo')
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/sfQuotes.yml DELETED
@@ -1,33 +0,0 @@
1
- --- %YAML:1.0
2
- test: Some characters at the beginning of a string must be escaped
3
- brief: >
4
- Some characters at the beginning of a string must be escaped
5
- yaml: |
6
- foo: | bar
7
- php: |
8
- array('foo' => '| bar')
9
- ---
10
- test: A key can be a quoted string
11
- brief: >
12
- A key can be a quoted string
13
- yaml: |
14
- "foo1": bar
15
- 'foo2': bar
16
- "foo \" bar": bar
17
- 'foo '' bar': bar
18
- 'foo3: ': bar
19
- "foo4: ": bar
20
- foo5: { "foo \" bar: ": bar, 'foo '' bar: ': bar }
21
- php: |
22
- array(
23
- 'foo1' => 'bar',
24
- 'foo2' => 'bar',
25
- 'foo " bar' => 'bar',
26
- 'foo \' bar' => 'bar',
27
- 'foo3: ' => 'bar',
28
- 'foo4: ' => 'bar',
29
- 'foo5' => array(
30
- 'foo " bar: ' => 'bar',
31
- 'foo \' bar: ' => 'bar',
32
- ),
33
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/sfTests.yml DELETED
@@ -1,135 +0,0 @@
1
- --- %YAML:1.0
2
- test: Multiple quoted string on one line
3
- brief: >
4
- Multiple quoted string on one line
5
- yaml: |
6
- stripped_title: { name: "foo bar", help: "bar foo" }
7
- php: |
8
- array('stripped_title' => array('name' => 'foo bar', 'help' => 'bar foo'))
9
- ---
10
- test: Empty sequence
11
- yaml: |
12
- foo: [ ]
13
- php: |
14
- array('foo' => array())
15
- ---
16
- test: Empty value
17
- yaml: |
18
- foo:
19
- php: |
20
- array('foo' => null)
21
- ---
22
- test: Inline string parsing
23
- brief: >
24
- Inline string parsing
25
- yaml: |
26
- test: ['complex: string', 'another [string]']
27
- php: |
28
- array('test' => array('complex: string', 'another [string]'))
29
- ---
30
- test: Boolean
31
- brief: >
32
- Boolean
33
- yaml: |
34
- - false
35
- - true
36
- - null
37
- - ~
38
- - 'false'
39
- - 'true'
40
- - 'null'
41
- - '~'
42
- php: |
43
- array(
44
- false,
45
- true,
46
- null,
47
- null,
48
- 'false',
49
- 'true',
50
- 'null',
51
- '~',
52
- )
53
- ---
54
- test: Empty lines in folded blocks
55
- brief: >
56
- Empty lines in folded blocks
57
- yaml: |
58
- foo:
59
- bar: |
60
- foo
61
-
62
-
63
-
64
- bar
65
- php: |
66
- array('foo' => array('bar' => "foo\n\n\n \nbar\n"))
67
- ---
68
- test: IP addresses
69
- brief: >
70
- IP addresses
71
- yaml: |
72
- foo: 10.0.0.2
73
- php: |
74
- array('foo' => '10.0.0.2')
75
- ---
76
- test: A sequence with an embedded mapping
77
- brief: >
78
- A sequence with an embedded mapping
79
- yaml: |
80
- - foo
81
- - bar: { bar: foo }
82
- php: |
83
- array('foo', array('bar' => array('bar' => 'foo')))
84
- ---
85
- test: A sequence with an unordered array
86
- brief: >
87
- A sequence with an unordered array
88
- yaml: |
89
- 1: foo
90
- 0: bar
91
- php: |
92
- array(1 => 'foo', 0 => 'bar')
93
- ---
94
- test: Octal
95
- brief: as in spec example 2.19, octal value is converted
96
- yaml: |
97
- foo: 0123
98
- php: |
99
- array('foo' => 83)
100
- ---
101
- test: Octal strings
102
- brief: Octal notation in a string must remain a string
103
- yaml: |
104
- foo: "0123"
105
- php: |
106
- array('foo' => '0123')
107
- ---
108
- test: Octal strings
109
- brief: Octal notation in a string must remain a string
110
- yaml: |
111
- foo: '0123'
112
- php: |
113
- array('foo' => '0123')
114
- ---
115
- test: Octal strings
116
- brief: Octal notation in a string must remain a string
117
- yaml: |
118
- foo: |
119
- 0123
120
- php: |
121
- array('foo' => "0123\n")
122
- ---
123
- test: Document as a simple hash
124
- brief: Document as a simple hash
125
- yaml: |
126
- { foo: bar }
127
- php: |
128
- array('foo' => 'bar')
129
- ---
130
- test: Document as a simple array
131
- brief: Document as a simple array
132
- yaml: |
133
- [ foo, bar ]
134
- php: |
135
- array('foo', 'bar')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/unindentedCollections.yml DELETED
@@ -1,62 +0,0 @@
1
- --- %YAML:1.0
2
- test: Unindented collection
3
- brief: >
4
- Unindented collection
5
- yaml: |
6
- collection:
7
- - item1
8
- - item2
9
- - item3
10
- php: |
11
- array('collection' => array('item1', 'item2', 'item3'))
12
- ---
13
- test: Nested unindented collection (two levels)
14
- brief: >
15
- Nested unindented collection
16
- yaml: |
17
- collection:
18
- key:
19
- - a
20
- - b
21
- - c
22
- php: |
23
- array('collection' => array('key' => array('a', 'b', 'c')))
24
- ---
25
- test: Nested unindented collection (three levels)
26
- brief: >
27
- Nested unindented collection
28
- yaml: |
29
- collection:
30
- key:
31
- subkey:
32
- - one
33
- - two
34
- - three
35
- php: |
36
- array('collection' => array('key' => array('subkey' => array('one', 'two', 'three'))))
37
- ---
38
- test: Key/value after unindented collection (1)
39
- brief: >
40
- Key/value after unindented collection (1)
41
- yaml: |
42
- collection:
43
- key:
44
- - a
45
- - b
46
- - c
47
- foo: bar
48
- php: |
49
- array('collection' => array('key' => array('a', 'b', 'c')), 'foo' => 'bar')
50
- ---
51
- test: Key/value after unindented collection (at the same level)
52
- brief: >
53
- Key/value after unindented collection
54
- yaml: |
55
- collection:
56
- key:
57
- - a
58
- - b
59
- - c
60
- foo: bar
61
- php: |
62
- array('collection' => array('key' => array('a', 'b', 'c'), 'foo' => 'bar'))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/InlineTest.php DELETED
@@ -1,231 +0,0 @@
1
- <?php
2
-
3
- /*
4
- * This file is part of the Symfony package.
5
- *
6
- * (c) Fabien Potencier <fabien@symfony.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 Symfony\Component\Yaml\Tests;
13
-
14
- use Symfony\Component\Yaml\Inline;
15
-
16
- class InlineTest extends \PHPUnit_Framework_TestCase
17
- {
18
- public function testParse()
19
- {
20
- foreach ($this->getTestsForParse() as $yaml => $value) {
21
- $this->assertSame($value, Inline::parse($yaml), sprintf('::parse() converts an inline YAML to a PHP structure (%s)', $yaml));
22
- }
23
- }
24
-
25
- public function testDump()
26
- {
27
- $testsForDump = $this->getTestsForDump();
28
-
29
- foreach ($testsForDump as $yaml => $value) {
30
- $this->assertEquals($yaml, Inline::dump($value), sprintf('::dump() converts a PHP structure to an inline YAML (%s)', $yaml));
31
- }
32
-
33
- foreach ($this->getTestsForParse() as $value) {
34
- $this->assertEquals($value, Inline::parse(Inline::dump($value)), 'check consistency');
35
- }
36
-
37
- foreach ($testsForDump as $value) {
38
- $this->assertEquals($value, Inline::parse(Inline::dump($value)), 'check consistency');
39
- }
40
- }
41
-
42
- public function testDumpNumericValueWithLocale()
43
- {
44
- $locale = setlocale(LC_NUMERIC, 0);
45
- if (false === $locale) {
46
- $this->markTestSkipped('Your platform does not support locales.');
47
- }
48
-
49
- $required_locales = array('fr_FR.UTF-8', 'fr_FR.UTF8', 'fr_FR.utf-8', 'fr_FR.utf8', 'French_France.1252');
50
- if (false === setlocale(LC_ALL, $required_locales)) {
51
- $this->markTestSkipped('Could not set any of required locales: '.implode(", ", $required_locales));
52
- }
53
-
54
- $this->assertEquals('1.2', Inline::dump(1.2));
55
- $this->assertContains('fr', strtolower(setlocale(LC_NUMERIC, 0)));
56
-
57
- setlocale(LC_ALL, $locale);
58
- }
59
-
60
- public function testHashStringsResemblingExponentialNumericsShouldNotBeChangedToINF()
61
- {
62
- $value = '686e444';
63
-
64
- $this->assertSame($value, Inline::parse(Inline::dump($value)));
65
- }
66
-
67
- /**
68
- * @expectedException \Symfony\Component\Yaml\Exception\ParseException
69
- */
70
- public function testParseScalarWithIncorrectlyQuotedStringShouldThrowException()
71
- {
72
- $value = "'don't do somthin' like that'";
73
- Inline::parse($value);
74
- }
75
-
76
- /**
77
- * @expectedException \Symfony\Component\Yaml\Exception\ParseException
78
- */
79
- public function testParseScalarWithIncorrectlyDoubleQuotedStringShouldThrowException()
80
- {
81
- $value = '"don"t do somthin" like that"';
82
- Inline::parse($value);
83
- }
84
-
85
- /**
86
- * @expectedException \Symfony\Component\Yaml\Exception\ParseException
87
- */
88
- public function testParseInvalidMappingKeyShouldThrowException()
89
- {
90
- $value = '{ "foo " bar": "bar" }';
91
- Inline::parse($value);
92
- }
93
-
94
- /**
95
- * @expectedException \Symfony\Component\Yaml\Exception\ParseException
96
- */
97
- public function testParseInvalidMappingShouldThrowException()
98
- {
99
- Inline::parse('[foo] bar');
100
- }
101
-
102
- /**
103
- * @expectedException \Symfony\Component\Yaml\Exception\ParseException
104
- */
105
- public function testParseInvalidSequenceShouldThrowException()
106
- {
107
- Inline::parse('{ foo: bar } bar');
108
- }
109
-
110
- public function testParseScalarWithCorrectlyQuotedStringShouldReturnString()
111
- {
112
- $value = "'don''t do somthin'' like that'";
113
- $expect = "don't do somthin' like that";
114
-
115
- $this->assertSame($expect, Inline::parseScalar($value));
116
- }
117
-
118
- protected function getTestsForParse()
119
- {
120
- return array(
121
- '' => '',
122
- 'null' => null,
123
- 'false' => false,
124
- 'true' => true,
125
- '12' => 12,
126
- '-12' => -12,
127
- '"quoted string"' => 'quoted string',
128
- "'quoted string'" => 'quoted string',
129
- '12.30e+02' => 12.30e+02,
130
- '0x4D2' => 0x4D2,
131
- '02333' => 02333,
132
- '.Inf' => -log(0),
133
- '-.Inf' => log(0),
134
- "'686e444'" => '686e444',
135
- '686e444' => 646e444,
136
- '123456789123456789123456789123456789' => '123456789123456789123456789123456789',
137
- '"foo\r\nbar"' => "foo\r\nbar",
138
- "'foo#bar'" => 'foo#bar',
139
- "'foo # bar'" => 'foo # bar',
140
- "'#cfcfcf'" => '#cfcfcf',
141
- '::form_base.html.twig' => '::form_base.html.twig',
142
-
143
- '2007-10-30' => mktime(0, 0, 0, 10, 30, 2007),
144
- '2007-10-30T02:59:43Z' => gmmktime(2, 59, 43, 10, 30, 2007),
145
- '2007-10-30 02:59:43 Z' => gmmktime(2, 59, 43, 10, 30, 2007),
146
- '1960-10-30 02:59:43 Z' => gmmktime(2, 59, 43, 10, 30, 1960),
147
- '1730-10-30T02:59:43Z' => gmmktime(2, 59, 43, 10, 30, 1730),
148
-
149
- '"a \\"string\\" with \'quoted strings inside\'"' => 'a "string" with \'quoted strings inside\'',
150
- "'a \"string\" with ''quoted strings inside'''" => 'a "string" with \'quoted strings inside\'',
151
-
152
- // sequences
153
- // urls are no key value mapping. see #3609. Valid yaml "key: value" mappings require a space after the colon
154
- '[foo, http://urls.are/no/mappings, false, null, 12]' => array('foo', 'http://urls.are/no/mappings', false, null, 12),
155
- '[ foo , bar , false , null , 12 ]' => array('foo', 'bar', false, null, 12),
156
- '[\'foo,bar\', \'foo bar\']' => array('foo,bar', 'foo bar'),
157
-
158
- // mappings
159
- '{foo:bar,bar:foo,false:false,null:null,integer:12}' => array('foo' => 'bar', 'bar' => 'foo', 'false' => false, 'null' => null, 'integer' => 12),
160
- '{ foo : bar, bar : foo, false : false, null : null, integer : 12 }' => array('foo' => 'bar', 'bar' => 'foo', 'false' => false, 'null' => null, 'integer' => 12),
161
- '{foo: \'bar\', bar: \'foo: bar\'}' => array('foo' => 'bar', 'bar' => 'foo: bar'),
162
- '{\'foo\': \'bar\', "bar": \'foo: bar\'}' => array('foo' => 'bar', 'bar' => 'foo: bar'),
163
- '{\'foo\'\'\': \'bar\', "bar\"": \'foo: bar\'}' => array('foo\'' => 'bar', "bar\"" => 'foo: bar'),
164
- '{\'foo: \': \'bar\', "bar: ": \'foo: bar\'}' => array('foo: ' => 'bar', "bar: " => 'foo: bar'),
165
-
166
- // nested sequences and mappings
167
- '[foo, [bar, foo]]' => array('foo', array('bar', 'foo')),
168
- '[foo, {bar: foo}]' => array('foo', array('bar' => 'foo')),
169
- '{ foo: {bar: foo} }' => array('foo' => array('bar' => 'foo')),
170
- '{ foo: [bar, foo] }' => array('foo' => array('bar', 'foo')),
171
-
172
- '[ foo, [ bar, foo ] ]' => array('foo', array('bar', 'foo')),
173
-
174
- '[{ foo: {bar: foo} }]' => array(array('foo' => array('bar' => 'foo'))),
175
-
176
- '[foo, [bar, [foo, [bar, foo]], foo]]' => array('foo', array('bar', array('foo', array('bar', 'foo')), 'foo')),
177
-
178
- '[foo, {bar: foo, foo: [foo, {bar: foo}]}, [foo, {bar: foo}]]' => array('foo', array('bar' => 'foo', 'foo' => array('foo', array('bar' => 'foo'))), array('foo', array('bar' => 'foo'))),
179
-
180
- '[foo, bar: { foo: bar }]' => array('foo', '1' => array('bar' => array('foo' => 'bar'))),
181
- '[foo, \'@foo.baz\', { \'%foo%\': \'foo is %foo%\', bar: \'%foo%\' }, true, \'@service_container\']' => array('foo', '@foo.baz', array('%foo%' => 'foo is %foo%', 'bar' => '%foo%',), true, '@service_container',),
182
- );
183
- }
184
-
185
- protected function getTestsForDump()
186
- {
187
- return array(
188
- 'null' => null,
189
- 'false' => false,
190
- 'true' => true,
191
- '12' => 12,
192
- "'quoted string'" => 'quoted string',
193
- '12.30e+02' => 12.30e+02,
194
- '1234' => 0x4D2,
195
- '1243' => 02333,
196
- '.Inf' => -log(0),
197
- '-.Inf' => log(0),
198
- "'686e444'" => '686e444',
199
- '"foo\r\nbar"' => "foo\r\nbar",
200
- "'foo#bar'" => 'foo#bar',
201
- "'foo # bar'" => 'foo # bar',
202
- "'#cfcfcf'" => '#cfcfcf',
203
-
204
- "'a \"string\" with ''quoted strings inside'''" => 'a "string" with \'quoted strings inside\'',
205
-
206
- "'-dash'" => '-dash',
207
- "'-'" => '-',
208
-
209
- // sequences
210
- '[foo, bar, false, null, 12]' => array('foo', 'bar', false, null, 12),
211
- '[\'foo,bar\', \'foo bar\']' => array('foo,bar', 'foo bar'),
212
-
213
- // mappings
214
- '{ foo: bar, bar: foo, \'false\': false, \'null\': null, integer: 12 }' => array('foo' => 'bar', 'bar' => 'foo', 'false' => false, 'null' => null, 'integer' => 12),
215
- '{ foo: bar, bar: \'foo: bar\' }' => array('foo' => 'bar', 'bar' => 'foo: bar'),
216
-
217
- // nested sequences and mappings
218
- '[foo, [bar, foo]]' => array('foo', array('bar', 'foo')),
219
-
220
- '[foo, [bar, [foo, [bar, foo]], foo]]' => array('foo', array('bar', array('foo', array('bar', 'foo')), 'foo')),
221
-
222
- '{ foo: { bar: foo } }' => array('foo' => array('bar' => 'foo')),
223
-
224
- '[foo, { bar: foo }]' => array('foo', array('bar' => 'foo')),
225
-
226
- '[foo, { bar: foo, foo: [foo, { bar: foo }] }, [foo, { bar: foo }]]' => array('foo', array('bar' => 'foo', 'foo' => array('foo', array('bar' => 'foo'))), array('foo', array('bar' => 'foo'))),
227
-
228
- '[foo, \'@foo.baz\', { \'%foo%\': \'foo is %foo%\', bar: \'%foo%\' }, true, \'@service_container\']' => array('foo', '@foo.baz', array('%foo%' => 'foo is %foo%', 'bar' => '%foo%',), true, '@service_container',),
229
- );
230
- }
231
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/ParseExceptionTest.php DELETED
@@ -1,30 +0,0 @@
1
- <?php
2
-
3
- /*
4
- * This file is part of the Symfony package.
5
- *
6
- * (c) Fabien Potencier <fabien@symfony.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 Symfony\Component\Yaml\Tests;
13
-
14
- use Symfony\Component\Yaml\Exception\ParseException;
15
- use Symfony\Component\Yaml\Yaml;
16
-
17
- class ParseExceptionTest extends \PHPUnit_Framework_TestCase
18
- {
19
- public function testGetMessage()
20
- {
21
- $exception = new ParseException('Error message', 42, 'foo: bar', '/var/www/app/config.yml');
22
- if (version_compare(PHP_VERSION, '5.4.0', '>=')) {
23
- $message = 'Error message in "/var/www/app/config.yml" at line 42 (near "foo: bar")';
24
- } else {
25
- $message = 'Error message in "\\/var\\/www\\/app\\/config.yml" at line 42 (near "foo: bar")';
26
- }
27
-
28
- $this->assertEquals($message, $exception->getMessage());
29
- }
30
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/ParserTest.php DELETED
@@ -1,660 +0,0 @@
1
- <?php
2
-
3
- /*
4
- * This file is part of the Symfony package.
5
- *
6
- * (c) Fabien Potencier <fabien@symfony.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 Symfony\Component\Yaml\Tests;
13
-
14
- use Symfony\Component\Yaml\Yaml;
15
- use Symfony\Component\Yaml\Parser;
16
-
17
- class ParserTest extends \PHPUnit_Framework_TestCase
18
- {
19
- protected $parser;
20
-
21
- protected function setUp()
22
- {
23
- $this->parser = new Parser();
24
- }
25
-
26
- protected function tearDown()
27
- {
28
- $this->parser = null;
29
- }
30
-
31
- /**
32
- * @dataProvider getDataFormSpecifications
33
- */
34
- public function testSpecifications($file, $expected, $yaml, $comment)
35
- {
36
- $this->assertEquals($expected, var_export($this->parser->parse($yaml), true), $comment);
37
- }
38
-
39
- public function getDataFormSpecifications()
40
- {
41
- $parser = new Parser();
42
- $path = __DIR__.'/Fixtures';
43
-
44
- $tests = array();
45
- $files = $parser->parse(file_get_contents($path.'/index.yml'));
46
- foreach ($files as $file) {
47
- $yamls = file_get_contents($path.'/'.$file.'.yml');
48
-
49
- // split YAMLs documents
50
- foreach (preg_split('/^---( %YAML\:1\.0)?/m', $yamls) as $yaml) {
51
- if (!$yaml) {
52
- continue;
53
- }
54
-
55
- $test = $parser->parse($yaml);
56
- if (isset($test['todo']) && $test['todo']) {
57
- // TODO
58
- } else {
59
- eval('$expected = '.trim($test['php']).';');
60
-
61
- $tests[] = array($file, var_export($expected, true), $test['yaml'], $test['test']);
62
- }
63
- }
64
- }
65
-
66
- return $tests;
67
- }
68
-
69
- public function testTabsInYaml()
70
- {
71
- // test tabs in YAML
72
- $yamls = array(
73
- "foo:\n bar",
74
- "foo:\n bar",
75
- "foo:\n bar",
76
- "foo:\n bar",
77
- );
78
-
79
- foreach ($yamls as $yaml) {
80
- try {
81
- $content = $this->parser->parse($yaml);
82
-
83
- $this->fail('YAML files must not contain tabs');
84
- } catch (\Exception $e) {
85
- $this->assertInstanceOf('\Exception', $e, 'YAML files must not contain tabs');
86
- $this->assertEquals('A YAML file cannot contain tabs as indentation at line 2 (near "'.strpbrk($yaml, "\t").'").', $e->getMessage(), 'YAML files must not contain tabs');
87
- }
88
- }
89
- }
90
-
91
- public function testEndOfTheDocumentMarker()
92
- {
93
- $yaml = <<<EOF
94
- --- %YAML:1.0
95
- foo
96
- ...
97
- EOF;
98
-
99
- $this->assertEquals('foo', $this->parser->parse($yaml));
100
- }
101
-
102
- public function getBlockChompingTests()
103
- {
104
- $tests = array();
105
-
106
- $yaml = <<<'EOF'
107
- foo: |-
108
- one
109
- two
110
- bar: |-
111
- one
112
- two
113
-
114
- EOF;
115
- $expected = array(
116
- 'foo' => "one\ntwo",
117
- 'bar' => "one\ntwo",
118
- );
119
- $tests['Literal block chomping strip with single trailing newline'] = array($expected, $yaml);
120
-
121
- $yaml = <<<'EOF'
122
- foo: |-
123
- one
124
- two
125
-
126
- bar: |-
127
- one
128
- two
129
-
130
-
131
- EOF;
132
- $expected = array(
133
- 'foo' => "one\ntwo",
134
- 'bar' => "one\ntwo",
135
- );
136
- $tests['Literal block chomping strip with multiple trailing newlines'] = array($expected, $yaml);
137
-
138
- $yaml = <<<'EOF'
139
- foo: |-
140
- one
141
- two
142
- bar: |-
143
- one
144
- two
145
- EOF;
146
- $expected = array(
147
- 'foo' => "one\ntwo",
148
- 'bar' => "one\ntwo",
149
- );
150
- $tests['Literal block chomping strip without trailing newline'] = array($expected, $yaml);
151
-
152
- $yaml = <<<'EOF'
153
- foo: |
154
- one
155
- two
156
- bar: |
157
- one
158
- two
159
-
160
- EOF;
161
- $expected = array(
162
- 'foo' => "one\ntwo\n",
163
- 'bar' => "one\ntwo\n",
164
- );
165
- $tests['Literal block chomping clip with single trailing newline'] = array($expected, $yaml);
166
-
167
- $yaml = <<<'EOF'
168
- foo: |
169
- one
170
- two
171
-
172
- bar: |
173
- one
174
- two
175
-
176
-
177
- EOF;
178
- $expected = array(
179
- 'foo' => "one\ntwo\n",
180
- 'bar' => "one\ntwo\n",
181
- );
182
- $tests['Literal block chomping clip with multiple trailing newlines'] = array($expected, $yaml);
183
-
184
- $yaml = <<<'EOF'
185
- foo: |
186
- one
187
- two
188
- bar: |
189
- one
190
- two
191
- EOF;
192
- $expected = array(
193
- 'foo' => "one\ntwo\n",
194
- 'bar' => "one\ntwo",
195
- );
196
- $tests['Literal block chomping clip without trailing newline'] = array($expected, $yaml);
197
-
198
- $yaml = <<<'EOF'
199
- foo: |+
200
- one
201
- two
202
- bar: |+
203
- one
204
- two
205
-
206
- EOF;
207
- $expected = array(
208
- 'foo' => "one\ntwo\n",
209
- 'bar' => "one\ntwo\n",
210
- );
211
- $tests['Literal block chomping keep with single trailing newline'] = array($expected, $yaml);
212
-
213
- $yaml = <<<'EOF'
214
- foo: |+
215
- one
216
- two
217
-
218
- bar: |+
219
- one
220
- two
221
-
222
-
223
- EOF;
224
- $expected = array(
225
- 'foo' => "one\ntwo\n\n",
226
- 'bar' => "one\ntwo\n\n",
227
- );
228
- $tests['Literal block chomping keep with multiple trailing newlines'] = array($expected, $yaml);
229
-
230
- $yaml = <<<'EOF'
231
- foo: |+
232
- one
233
- two
234
- bar: |+
235
- one
236
- two
237
- EOF;
238
- $expected = array(
239
- 'foo' => "one\ntwo\n",
240
- 'bar' => "one\ntwo",
241
- );
242
- $tests['Literal block chomping keep without trailing newline'] = array($expected, $yaml);
243
-
244
- $yaml = <<<'EOF'
245
- foo: >-
246
- one
247
- two
248
- bar: >-
249
- one
250
- two
251
-
252
- EOF;
253
- $expected = array(
254
- 'foo' => "one two",
255
- 'bar' => "one two",
256
- );
257
- $tests['Folded block chomping strip with single trailing newline'] = array($expected, $yaml);
258
-
259
- $yaml = <<<'EOF'
260
- foo: >-
261
- one
262
- two
263
-
264
- bar: >-
265
- one
266
- two
267
-
268
-
269
- EOF;
270
- $expected = array(
271
- 'foo' => "one two",
272
- 'bar' => "one two",
273
- );
274
- $tests['Folded block chomping strip with multiple trailing newlines'] = array($expected, $yaml);
275
-
276
- $yaml = <<<'EOF'
277
- foo: >-
278
- one
279
- two
280
- bar: >-
281
- one
282
- two
283
- EOF;
284
- $expected = array(
285
- 'foo' => "one two",
286
- 'bar' => "one two",
287
- );
288
- $tests['Folded block chomping strip without trailing newline'] = array($expected, $yaml);
289
-
290
- $yaml = <<<'EOF'
291
- foo: >
292
- one
293
- two
294
- bar: >
295
- one
296
- two
297
-
298
- EOF;
299
- $expected = array(
300
- 'foo' => "one two\n",
301
- 'bar' => "one two\n",
302
- );
303
- $tests['Folded block chomping clip with single trailing newline'] = array($expected, $yaml);
304
-
305
- $yaml = <<<'EOF'
306
- foo: >
307
- one
308
- two
309
-
310
- bar: >
311
- one
312
- two
313
-
314
-
315
- EOF;
316
- $expected = array(
317
- 'foo' => "one two\n",
318
- 'bar' => "one two\n",
319
- );
320
- $tests['Folded block chomping clip with multiple trailing newlines'] = array($expected, $yaml);
321
-
322
- $yaml = <<<'EOF'
323
- foo: >
324
- one
325
- two
326
- bar: >
327
- one
328
- two
329
- EOF;
330
- $expected = array(
331
- 'foo' => "one two\n",
332
- 'bar' => "one two",
333
- );
334
- $tests['Folded block chomping clip without trailing newline'] = array($expected, $yaml);
335
-
336
- $yaml = <<<'EOF'
337
- foo: >+
338
- one
339
- two
340
- bar: >+
341
- one
342
- two
343
-
344
- EOF;
345
- $expected = array(
346
- 'foo' => "one two\n",
347
- 'bar' => "one two\n",
348
- );
349
- $tests['Folded block chomping keep with single trailing newline'] = array($expected, $yaml);
350
-
351
- $yaml = <<<'EOF'
352
- foo: >+
353
- one
354
- two
355
-
356
- bar: >+
357
- one
358
- two
359
-
360
-
361
- EOF;
362
- $expected = array(
363
- 'foo' => "one two\n\n",
364
- 'bar' => "one two\n\n",
365
- );
366
- $tests['Folded block chomping keep with multiple trailing newlines'] = array($expected, $yaml);
367
-
368
- $yaml = <<<'EOF'
369
- foo: >+
370
- one
371
- two
372
- bar: >+
373
- one
374
- two
375
- EOF;
376
- $expected = array(
377
- 'foo' => "one two\n",
378
- 'bar' => "one two",
379
- );
380
- $tests['Folded block chomping keep without trailing newline'] = array($expected, $yaml);
381
-
382
- return $tests;
383
- }
384
-
385
- /**
386
- * @dataProvider getBlockChompingTests
387
- */
388
- public function testBlockChomping($expected, $yaml)
389
- {
390
- $this->assertSame($expected, $this->parser->parse($yaml));
391
- }
392
-
393
- /**
394
- * Regression test for issue #7989.
395
- *
396
- * @see https://github.com/symfony/symfony/issues/7989
397
- */
398
- public function testBlockLiteralWithLeadingNewlines()
399
- {
400
- $yaml = <<<'EOF'
401
- foo: |-
402
-
403
-
404
- bar
405
-
406
- EOF;
407
- $expected = array(
408
- 'foo' => "\n\nbar"
409
- );
410
-
411
- $this->assertSame($expected, $this->parser->parse($yaml));
412
- }
413
-
414
- public function testObjectSupportEnabled()
415
- {
416
- $input = <<<EOF
417
- foo: !!php/object:O:30:"Symfony\Component\Yaml\Tests\B":1:{s:1:"b";s:3:"foo";}
418
- bar: 1
419
- EOF;
420
- $this->assertEquals(array('foo' => new B(), 'bar' => 1), $this->parser->parse($input, false, true), '->parse() is able to parse objects');
421
- }
422
-
423
- public function testObjectSupportDisabledButNoExceptions()
424
- {
425
- $input = <<<EOF
426
- foo: !!php/object:O:30:"Symfony\Tests\Component\Yaml\B":1:{s:1:"b";s:3:"foo";}
427
- bar: 1
428
- EOF;
429
-
430
- $this->assertEquals(array('foo' => null, 'bar' => 1), $this->parser->parse($input), '->parse() does not parse objects');
431
- }
432
-
433
- /**
434
- * @expectedException \Symfony\Component\Yaml\Exception\ParseException
435
- */
436
- public function testObjectsSupportDisabledWithExceptions()
437
- {
438
- $this->parser->parse('foo: !!php/object:O:30:"Symfony\Tests\Component\Yaml\B":1:{s:1:"b";s:3:"foo";}', true, false);
439
- }
440
-
441
- public function testNonUtf8Exception()
442
- {
443
- if (!function_exists('iconv')) {
444
- $this->markTestSkipped('Exceptions for non-utf8 charsets require the iconv() function.');
445
-
446
- return;
447
- }
448
-
449
- $yamls = array(
450
- iconv("UTF-8", "ISO-8859-1", "foo: 'äöüß'"),
451
- iconv("UTF-8", "ISO-8859-15", "euro: '€'"),
452
- iconv("UTF-8", "CP1252", "cp1252: '©ÉÇáñ'")
453
- );
454
-
455
- foreach ($yamls as $yaml) {
456
- try {
457
- $this->parser->parse($yaml);
458
-
459
- $this->fail('charsets other than UTF-8 are rejected.');
460
- } catch (\Exception $e) {
461
- $this->assertInstanceOf('Symfony\Component\Yaml\Exception\ParseException', $e, 'charsets other than UTF-8 are rejected.');
462
- }
463
- }
464
- }
465
-
466
- /**
467
- *
468
- * @expectedException \Symfony\Component\Yaml\Exception\ParseException
469
- *
470
- */
471
- public function testUnindentedCollectionException()
472
- {
473
- $yaml = <<<EOF
474
-
475
- collection:
476
- -item1
477
- -item2
478
- -item3
479
-
480
- EOF;
481
-
482
- $this->parser->parse($yaml);
483
- }
484
-
485
- /**
486
- * @expectedException \Symfony\Component\Yaml\Exception\ParseException
487
- */
488
- public function testSequenceInAMapping()
489
- {
490
- Yaml::parse(<<<EOF
491
- yaml:
492
- hash: me
493
- - array stuff
494
- EOF
495
- );
496
- }
497
-
498
- /**
499
- * @expectedException \Symfony\Component\Yaml\Exception\ParseException
500
- */
501
- public function testMappingInASequence()
502
- {
503
- Yaml::parse(<<<EOF
504
- yaml:
505
- - array stuff
506
- hash: me
507
- EOF
508
- );
509
- }
510
-
511
- /**
512
- * > It is an error for two equal keys to appear in the same mapping node.
513
- * > In such a case the YAML processor may continue, ignoring the second
514
- * > `key: value` pair and issuing an appropriate warning. This strategy
515
- * > preserves a consistent information model for one-pass and random access
516
- * > applications.
517
- *
518
- * @see http://yaml.org/spec/1.2/spec.html#id2759572
519
- * @see http://yaml.org/spec/1.1/#id932806
520
- *
521
- * @covers \Symfony\Component\Yaml\Parser::parse
522
- */
523
- public function testMappingDuplicateKeyBlock()
524
- {
525
- $input = <<<EOD
526
- parent:
527
- child: first
528
- child: duplicate
529
- parent:
530
- child: duplicate
531
- child: duplicate
532
- EOD;
533
- $expected = array(
534
- 'parent' => array(
535
- 'child' => 'first',
536
- ),
537
- );
538
- $this->assertSame($expected, Yaml::parse($input));
539
- }
540
-
541
- /**
542
- * @covers \Symfony\Component\Yaml\Inline::parseMapping
543
- */
544
- public function testMappingDuplicateKeyFlow()
545
- {
546
- $input = <<<EOD
547
- parent: { child: first, child: duplicate }
548
- parent: { child: duplicate, child: duplicate }
549
- EOD;
550
- $expected = array(
551
- 'parent' => array(
552
- 'child' => 'first',
553
- ),
554
- );
555
- $this->assertSame($expected, Yaml::parse($input));
556
- }
557
-
558
- public function testEmptyValue()
559
- {
560
- $input = <<<EOF
561
- hash:
562
- EOF;
563
-
564
- $this->assertEquals(array('hash' => null), Yaml::parse($input));
565
- }
566
-
567
- public function testStringBlockWithComments()
568
- {
569
- $this->assertEquals(array('content' => <<<EOT
570
- # comment 1
571
- header
572
-
573
- # comment 2
574
- <body>
575
- <h1>title</h1>
576
- </body>
577
-
578
- footer # comment3
579
- EOT
580
- ), Yaml::parse(<<<EOF
581
- content: |
582
- # comment 1
583
- header
584
-
585
- # comment 2
586
- <body>
587
- <h1>title</h1>
588
- </body>
589
-
590
- footer # comment3
591
- EOF
592
- ));
593
- }
594
-
595
- public function testFoldedStringBlockWithComments()
596
- {
597
- $this->assertEquals(array(array('content' => <<<EOT
598
- # comment 1
599
- header
600
-
601
- # comment 2
602
- <body>
603
- <h1>title</h1>
604
- </body>
605
-
606
- footer # comment3
607
- EOT
608
- )), Yaml::parse(<<<EOF
609
- -
610
- content: |
611
- # comment 1
612
- header
613
-
614
- # comment 2
615
- <body>
616
- <h1>title</h1>
617
- </body>
618
-
619
- footer # comment3
620
- EOF
621
- ));
622
- }
623
-
624
- public function testNestedFoldedStringBlockWithComments()
625
- {
626
- $this->assertEquals(array(array(
627
- 'title' => 'some title',
628
- 'content' => <<<EOT
629
- # comment 1
630
- header
631
-
632
- # comment 2
633
- <body>
634
- <h1>title</h1>
635
- </body>
636
-
637
- footer # comment3
638
- EOT
639
- )), Yaml::parse(<<<EOF
640
- -
641
- title: some title
642
- content: |
643
- # comment 1
644
- header
645
-
646
- # comment 2
647
- <body>
648
- <h1>title</h1>
649
- </body>
650
-
651
- footer # comment3
652
- EOF
653
- ));
654
- }
655
- }
656
-
657
- class B
658
- {
659
- public $b = 'foo';
660
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/YamlTest.php DELETED
@@ -1,31 +0,0 @@
1
- <?php
2
-
3
- /*
4
- * This file is part of the Symfony package.
5
- *
6
- * (c) Fabien Potencier <fabien@symfony.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 Symfony\Component\Yaml\Tests;
13
-
14
- use Symfony\Component\Yaml\Yaml;
15
-
16
- class YamlTest extends \PHPUnit_Framework_TestCase
17
- {
18
- public function testParseAndDump()
19
- {
20
- $data = array('lorem' => 'ipsum', 'dolor' => 'sit');
21
- $yml = Yaml::dump($data);
22
- $parsed = Yaml::parse($yml);
23
- $this->assertEquals($data, $parsed);
24
-
25
- $filename = __DIR__.'/Fixtures/index.yml';
26
- $contents = file_get_contents($filename);
27
- $parsedByFilename = Yaml::parse($filename);
28
- $parsedByContents = Yaml::parse($contents);
29
- $this->assertEquals($parsedByFilename, $parsedByContents);
30
- }
31
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/symfony/yaml/Symfony/Component/Yaml/Unescaper.php DELETED
@@ -1,141 +0,0 @@
1
- <?php
2
-
3
- /*
4
- * This file is part of the Symfony package.
5
- *
6
- * (c) Fabien Potencier <fabien@symfony.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 Symfony\Component\Yaml;
13
-
14
- /**
15
- * Unescaper encapsulates unescaping rules for single and double-quoted
16
- * YAML strings.
17
- *
18
- * @author Matthew Lewinski <matthew@lewinski.org>
19
- */
20
- class Unescaper
21
- {
22
- // Parser and Inline assume UTF-8 encoding, so escaped Unicode characters
23
- // must be converted to that encoding.
24
- // @deprecated since 2.5, to be removed in 3.0
25
- const ENCODING = 'UTF-8';
26
-
27
- // Regex fragment that matches an escaped character in a double quoted
28
- // string.
29
- const REGEX_ESCAPED_CHARACTER = "\\\\([0abt\tnvfre \\\"\\/\\\\N_LP]|x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|U[0-9a-fA-F]{8})";
30
-
31
- /**
32
- * Unescapes a single quoted string.
33
- *
34
- * @param string $value A single quoted string.
35
- *
36
- * @return string The unescaped string.
37
- */
38
- public function unescapeSingleQuotedString($value)
39
- {
40
- return str_replace('\'\'', '\'', $value);
41
- }
42
-
43
- /**
44
- * Unescapes a double quoted string.
45
- *
46
- * @param string $value A double quoted string.
47
- *
48
- * @return string The unescaped string.
49
- */
50
- public function unescapeDoubleQuotedString($value)
51
- {
52
- $self = $this;
53
- $callback = function ($match) use ($self) {
54
- return $self->unescapeCharacter($match[0]);
55
- };
56
-
57
- // evaluate the string
58
- return preg_replace_callback('/'.self::REGEX_ESCAPED_CHARACTER.'/u', $callback, $value);
59
- }
60
-
61
- /**
62
- * Unescapes a character that was found in a double-quoted string
63
- *
64
- * @param string $value An escaped character
65
- *
66
- * @return string The unescaped character
67
- */
68
- public function unescapeCharacter($value)
69
- {
70
- switch ($value{1}) {
71
- case '0':
72
- return "\x0";
73
- case 'a':
74
- return "\x7";
75
- case 'b':
76
- return "\x8";
77
- case 't':
78
- return "\t";
79
- case "\t":
80
- return "\t";
81
- case 'n':
82
- return "\n";
83
- case 'v':
84
- return "\xB";
85
- case 'f':
86
- return "\xC";
87
- case 'r':
88
- return "\r";
89
- case 'e':
90
- return "\x1B";
91
- case ' ':
92
- return ' ';
93
- case '"':
94
- return '"';
95
- case '/':
96
- return '/';
97
- case '\\':
98
- return '\\';
99
- case 'N':
100
- // U+0085 NEXT LINE
101
- return "\xC2\x85";
102
- case '_':
103
- // U+00A0 NO-BREAK SPACE
104
- return "\xC2\xA0";
105
- case 'L':
106
- // U+2028 LINE SEPARATOR
107
- return "\xE2\x80\xA8";
108
- case 'P':
109
- // U+2029 PARAGRAPH SEPARATOR
110
- return "\xE2\x80\xA9";
111
- case 'x':
112
- return self::utf8chr(hexdec(substr($value, 2, 2)));
113
- case 'u':
114
- return self::utf8chr(hexdec(substr($value, 2, 4)));
115
- case 'U':
116
- return self::utf8chr(hexdec(substr($value, 2, 8)));
117
- }
118
- }
119
-
120
- /**
121
- * Get the UTF-8 character for the given code point.
122
- *
123
- * @param int $c The unicode code point
124
- *
125
- * @return string The corresponding UTF-8 character
126
- */
127
- private static function utf8chr($c)
128
- {
129
- if (0x80 > $c %= 0x200000) {
130
- return chr($c);
131
- }
132
- if (0x800 > $c) {
133
- return chr(0xC0 | $c>>6).chr(0x80 | $c & 0x3F);
134
- }
135
- if (0x10000 > $c) {
136
- return chr(0xE0 | $c>>12).chr(0x80 | $c>>6 & 0x3F).chr(0x80 | $c & 0x3F);
137
- }
138
-
139
- return chr(0xF0 | $c>>18).chr(0x80 | $c>>12 & 0x3F).chr(0x80 | $c>>6 & 0x3F).chr(0x80 | $c & 0x3F);
140
- }
141
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/symfony/yaml/Symfony/Component/Yaml/Yaml.php DELETED
@@ -1,100 +0,0 @@
1
- <?php
2
-
3
- /*
4
- * This file is part of the Symfony package.
5
- *
6
- * (c) Fabien Potencier <fabien@symfony.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 Symfony\Component\Yaml;
13
-
14
- use Symfony\Component\Yaml\Exception\ParseException;
15
-
16
- /**
17
- * Yaml offers convenience methods to load and dump YAML.
18
- *
19
- * @author Fabien Potencier <fabien@symfony.com>
20
- *
21
- * @api
22
- */
23
- class Yaml
24
- {
25
- /**
26
- * Parses YAML into a PHP array.
27
- *
28
- * The parse method, when supplied with a YAML stream (string or file),
29
- * will do its best to convert YAML in a file into a PHP array.
30
- *
31
- * Usage:
32
- * <code>
33
- * $array = Yaml::parse('config.yml');
34
- * print_r($array);
35
- * </code>
36
- *
37
- * As this method accepts both plain strings and file names as an input,
38
- * you must validate the input before calling this method. Passing a file
39
- * as an input is a deprecated feature and will be removed in 3.0.
40
- *
41
- * @param string $input Path to a YAML file or a string containing YAML
42
- * @param bool $exceptionOnInvalidType True if an exception must be thrown on invalid types false otherwise
43
- * @param bool $objectSupport True if object support is enabled, false otherwise
44
- *
45
- * @return array The YAML converted to a PHP array
46
- *
47
- * @throws ParseException If the YAML is not valid
48
- *
49
- * @api
50
- */
51
- public static function parse($input, $exceptionOnInvalidType = false, $objectSupport = false)
52
- {
53
- // if input is a file, process it
54
- $file = '';
55
- if (strpos($input, "\n") === false && is_file($input)) {
56
- if (false === is_readable($input)) {
57
- throw new ParseException(sprintf('Unable to parse "%s" as the file is not readable.', $input));
58
- }
59
-
60
- $file = $input;
61
- $input = file_get_contents($file);
62
- }
63
-
64
- $yaml = new Parser();
65
-
66
- try {
67
- return $yaml->parse($input, $exceptionOnInvalidType, $objectSupport);
68
- } catch (ParseException $e) {
69
- if ($file) {
70
- $e->setParsedFile($file);
71
- }
72
-
73
- throw $e;
74
- }
75
- }
76
-
77
- /**
78
- * Dumps a PHP array to a YAML string.
79
- *
80
- * The dump method, when supplied with an array, will do its best
81
- * to convert the array into friendly YAML.
82
- *
83
- * @param array $array PHP array
84
- * @param int $inline The level where you switch to inline YAML
85
- * @param int $indent The amount of spaces to use for indentation of nested nodes.
86
- * @param bool $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise
87
- * @param bool $objectSupport true if object support is enabled, false otherwise
88
- *
89
- * @return string A YAML string representing the original PHP array
90
- *
91
- * @api
92
- */
93
- public static function dump($array, $inline = 2, $indent = 4, $exceptionOnInvalidType = false, $objectSupport = false)
94
- {
95
- $yaml = new Dumper();
96
- $yaml->setIndentation($indent);
97
-
98
- return $yaml->dump($array, $inline, 0, $exceptionOnInvalidType, $objectSupport);
99
- }
100
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/symfony/yaml/Symfony/Component/Yaml/composer.json DELETED
@@ -1,31 +0,0 @@
1
- {
2
- "name": "symfony/yaml",
3
- "type": "library",
4
- "description": "Symfony Yaml Component",
5
- "keywords": [],
6
- "homepage": "http://symfony.com",
7
- "license": "MIT",
8
- "authors": [
9
- {
10
- "name": "Fabien Potencier",
11
- "email": "fabien@symfony.com"
12
- },
13
- {
14
- "name": "Symfony Community",
15
- "homepage": "http://symfony.com/contributors"
16
- }
17
- ],
18
- "require": {
19
- "php": ">=5.3.3"
20
- },
21
- "autoload": {
22
- "psr-0": { "Symfony\\Component\\Yaml\\": "" }
23
- },
24
- "target-dir": "Symfony/Component/Yaml",
25
- "minimum-stability": "dev",
26
- "extra": {
27
- "branch-alias": {
28
- "dev-master": "2.5-dev"
29
- }
30
- }
31
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/symfony/yaml/Symfony/Component/Yaml/phpunit.xml.dist DELETED
@@ -1,29 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
-
3
- <phpunit backupGlobals="false"
4
- backupStaticAttributes="false"
5
- colors="true"
6
- convertErrorsToExceptions="true"
7
- convertNoticesToExceptions="true"
8
- convertWarningsToExceptions="true"
9
- processIsolation="false"
10
- stopOnFailure="false"
11
- syntaxCheck="false"
12
- bootstrap="vendor/autoload.php"
13
- >
14
- <testsuites>
15
- <testsuite name="Symfony Yaml Component Test Suite">
16
- <directory>./Tests/</directory>
17
- </testsuite>
18
- </testsuites>
19
-
20
- <filter>
21
- <whitelist>
22
- <directory>./</directory>
23
- <exclude>
24
- <directory>./vendor</directory>
25
- <directory>./Tests</directory>
26
- </exclude>
27
- </whitelist>
28
- </filter>
29
- </phpunit>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/twig/twig/.editorconfig DELETED
@@ -1,18 +0,0 @@
1
- ; top-most EditorConfig file
2
- root = true
3
-
4
- ; Unix-style newlines
5
- [*]
6
- end_of_line = LF
7
-
8
- [*.php]
9
- indent_style = space
10
- indent_size = 4
11
-
12
- [*.test]
13
- indent_style = space
14
- indent_size = 4
15
-
16
- [*.rst]
17
- indent_style = space
18
- indent_size = 4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/twig/twig/.gitignore DELETED
@@ -1,2 +0,0 @@
1
- /ext/twig/autom4te.cache/
2
-
 
 
vendor/vendor/twig/twig/.travis.yml DELETED
@@ -1,21 +0,0 @@
1
- language: php
2
-
3
- php:
4
- - 5.2
5
- - 5.3
6
- - 5.4
7
- - 5.5
8
- - hhvm
9
-
10
- env:
11
- - TWIG_EXT=no
12
- - TWIG_EXT=yes
13
-
14
- before_script:
15
- - if [ "$TWIG_EXT" == "yes" ]; then sh -c "cd ext/twig && phpize && ./configure --enable-twig && make && sudo make install"; fi
16
- - if [ "$TWIG_EXT" == "yes" ]; then echo "extension=twig.so" >> `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"`; fi
17
-
18
- matrix:
19
- exclude:
20
- - php: hhvm
21
- env: TWIG_EXT=yes
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/twig/twig/CHANGELOG DELETED
@@ -1,677 +0,0 @@
1
- * 1.15.1 (2013-02-13)
2
-
3
- * fixed the conversion of the special '0000-00-00 00:00' date
4
- * added an error message when trying to import an undefined block from a trait
5
- * fixed a C extension crash when accessing defined but uninitialized property.
6
-
7
- * 1.15.0 (2013-12-06)
8
-
9
- * made ignoreStrictCheck in Template::getAttribute() works with __call() methods throwing BadMethodCallException
10
- * added min and max functions
11
- * added the round filter
12
- * fixed a bug that prevented the optimizers to be enabled/disabled selectively
13
- * fixed first and last filters for UTF-8 strings
14
- * added a source function to include the content of a template without rendering it
15
- * fixed the C extension sandbox behavior when get or set is prepend to method name
16
-
17
- * 1.14.2 (2013-10-30)
18
-
19
- * fixed error filename/line when an error occurs in an included file
20
- * allowed operators that contain whitespaces to have more than one whitespace
21
- * allowed tests to be made of 1 or 2 words (like "same as" or "divisible by")
22
-
23
- * 1.14.1 (2013-10-15)
24
-
25
- * made it possible to use named operators as variables
26
- * fixed the possibility to have a variable named 'matches'
27
- * added support for PHP 5.5 DateTimeInterface
28
-
29
- * 1.14.0 (2013-10-03)
30
-
31
- * fixed usage of the html_attr escaping strategy to avoid double-escaping with the html strategy
32
- * added new operators: ends with, starts with, and matches
33
- * fixed some compatibility issues with HHVM
34
- * added a way to add custom escaping strategies
35
- * fixed the C extension compilation on Windows
36
- * fixed the batch filter when using a fill argument with an exact match of elements to batch
37
- * fixed the filesystem loader cache when a template name exists in several namespaces
38
- * fixed template_from_string when the template includes or extends other ones
39
- * fixed a crash of the C extension on an edge case
40
-
41
- * 1.13.2 (2013-08-03)
42
-
43
- * fixed the error line number for an error occurs in and embedded template
44
- * fixed crashes of the C extension on some edge cases
45
-
46
- * 1.13.1 (2013-06-06)
47
-
48
- * added the possibility to ignore the filesystem constructor argument in Twig_Loader_Filesystem
49
- * fixed Twig_Loader_Chain::exists() for a loader which implements Twig_ExistsLoaderInterface
50
- * adjusted backtrace call to reduce memory usage when an error occurs
51
- * added support for object instances as the second argument of the constant test
52
- * fixed the include function when used in an assignment
53
-
54
- * 1.13.0 (2013-05-10)
55
-
56
- * fixed getting a numeric-like item on a variable ('09' for instance)
57
- * fixed getting a boolean or float key on an array, so it is consistent with PHP's array access:
58
- `{{ array[false] }}` behaves the same as `echo $array[false];` (equals `$array[0]`)
59
- * made the escape filter 20% faster for happy path (escaping string for html with UTF-8)
60
- * changed ☃ to § in tests
61
- * enforced usage of named arguments after positional ones
62
-
63
- * 1.12.3 (2013-04-08)
64
-
65
- * fixed a security issue in the filesystem loader where it was possible to include a template one
66
- level above the configured path
67
- * fixed fatal error that should be an exception when adding a filter/function/test too late
68
- * added a batch filter
69
- * added support for encoding an array as query string in the url_encode filter
70
-
71
- * 1.12.2 (2013-02-09)
72
-
73
- * fixed the timezone used by the date filter and function when the given date contains a timezone (like 2010-01-28T15:00:00+02:00)
74
- * fixed globals when getGlobals is called early on
75
- * added the first and last filter
76
-
77
- * 1.12.1 (2013-01-15)
78
-
79
- * added support for object instances as the second argument of the constant function
80
- * relaxed globals management to avoid a BC break
81
- * added support for {{ some_string[:2] }}
82
-
83
- * 1.12.0 (2013-01-08)
84
-
85
- * added verbatim as an alias for the raw tag to avoid confusion with the raw filter
86
- * fixed registration of tests and functions as anonymous functions
87
- * fixed globals management
88
-
89
- * 1.12.0-RC1 (2012-12-29)
90
-
91
- * added an include function (does the same as the include tag but in a more flexible way)
92
- * added the ability to use any PHP callable to define filters, functions, and tests
93
- * added a syntax error when using a loop variable that is not defined
94
- * added the ability to set default values for macro arguments
95
- * added support for named arguments for filters, tests, and functions
96
- * moved filters/functions/tests syntax errors to the parser
97
- * added support for extended ternary operator syntaxes
98
-
99
- * 1.11.1 (2012-11-11)
100
-
101
- * fixed debug info line numbering (was off by 2)
102
- * fixed escaping when calling a macro inside another one (regression introduced in 1.9.1)
103
- * optimized variable access on PHP 5.4
104
- * fixed a crash of the C extension when an exception was thrown from a macro called without being imported (using _self.XXX)
105
-
106
- * 1.11.0 (2012-11-07)
107
-
108
- * fixed macro compilation when a variable name is a PHP reserved keyword
109
- * changed the date filter behavior to always apply the default timezone, except if false is passed as the timezone
110
- * fixed bitwise operator precedences
111
- * added the template_from_string function
112
- * fixed default timezone usage for the date function
113
- * optimized the way Twig exceptions are managed (to make them faster)
114
- * added Twig_ExistsLoaderInterface (implementing this interface in your loader make the chain loader much faster)
115
-
116
- * 1.10.3 (2012-10-19)
117
-
118
- * fixed wrong template location in some error messages
119
- * reverted a BC break introduced in 1.10.2
120
- * added a split filter
121
-
122
- * 1.10.2 (2012-10-15)
123
-
124
- * fixed macro calls on PHP 5.4
125
-
126
- * 1.10.1 (2012-10-15)
127
-
128
- * made a speed optimization to macro calls when imported via the "import" tag
129
- * fixed C extension compilation on Windows
130
- * fixed a segfault in the C extension when using DateTime objects
131
-
132
- * 1.10.0 (2012-09-28)
133
-
134
- * extracted functional tests framework to make it reusable for third-party extensions
135
- * added namespaced templates support in Twig_Loader_Filesystem
136
- * added Twig_Loader_Filesystem::prependPath()
137
- * fixed an error when a token parser pass a closure as a test to the subparse() method
138
-
139
- * 1.9.2 (2012-08-25)
140
-
141
- * fixed the in operator for objects that contain circular references
142
- * fixed the C extension when accessing a public property of an object implementing the \ArrayAccess interface
143
-
144
- * 1.9.1 (2012-07-22)
145
-
146
- * optimized macro calls when auto-escaping is on
147
- * fixed wrong parent class for Twig_Function_Node
148
- * made Twig_Loader_Chain more explicit about problems
149
-
150
- * 1.9.0 (2012-07-13)
151
-
152
- * made the parsing independent of the template loaders
153
- * fixed exception trace when an error occurs when rendering a child template
154
- * added escaping strategies for CSS, URL, and HTML attributes
155
- * fixed nested embed tag calls
156
- * added the date_modify filter
157
-
158
- * 1.8.3 (2012-06-17)
159
-
160
- * fixed paths in the filesystem loader when passing a path that ends with a slash or a backslash
161
- * fixed escaping when a project defines a function named html or js
162
- * fixed chmod mode to apply the umask correctly
163
-
164
- * 1.8.2 (2012-05-30)
165
-
166
- * added the abs filter
167
- * fixed a regression when using a number in template attributes
168
- * fixed compiler when mbstring.func_overload is set to 2
169
- * fixed DateTimeZone support in date filter
170
-
171
- * 1.8.1 (2012-05-17)
172
-
173
- * fixed a regression when dealing with SimpleXMLElement instances in templates
174
- * fixed "is_safe" value for the "dump" function when "html_errors" is not defined in php.ini
175
- * switched to use mbstring whenever possible instead of iconv (you might need to update your encoding as mbstring and iconv encoding names sometimes differ)
176
-
177
- * 1.8.0 (2012-05-08)
178
-
179
- * enforced interface when adding tests, filters, functions, and node visitors from extensions
180
- * fixed a side-effect of the date filter where the timezone might be changed
181
- * simplified usage of the autoescape tag; the only (optional) argument is now the escaping strategy or false (with a BC layer)
182
- * added a way to dynamically change the auto-escaping strategy according to the template "filename"
183
- * changed the autoescape option to also accept a supported escaping strategy (for BC, true is equivalent to html)
184
- * added an embed tag
185
-
186
- * 1.7.0 (2012-04-24)
187
-
188
- * fixed a PHP warning when using CIFS
189
- * fixed template line number in some exceptions
190
- * added an iterable test
191
- * added an error when defining two blocks with the same name in a template
192
- * added the preserves_safety option for filters
193
- * fixed a PHP notice when trying to access a key on a non-object/array variable
194
- * enhanced error reporting when the template file is an instance of SplFileInfo
195
- * added Twig_Environment::mergeGlobals()
196
- * added compilation checks to avoid misuses of the sandbox tag
197
- * fixed filesystem loader freshness logic for high traffic websites
198
- * fixed random function when charset is null
199
-
200
- * 1.6.5 (2012-04-11)
201
-
202
- * fixed a regression when a template only extends another one without defining any blocks
203
-
204
- * 1.6.4 (2012-04-02)
205
-
206
- * fixed PHP notice in Twig_Error::guessTemplateLine() introduced in 1.6.3
207
- * fixed performance when compiling large files
208
- * optimized parent template creation when the template does not use dynamic inheritance
209
-
210
- * 1.6.3 (2012-03-22)
211
-
212
- * fixed usage of Z_ADDREF_P for PHP 5.2 in the C extension
213
- * fixed compilation of numeric values used in templates when using a locale where the decimal separator is not a dot
214
- * made the strategy used to guess the real template file name and line number in exception messages much faster and more accurate
215
-
216
- * 1.6.2 (2012-03-18)
217
-
218
- * fixed sandbox mode when used with inheritance
219
- * added preserveKeys support for the slice filter
220
- * fixed the date filter when a DateTime instance is passed with a specific timezone
221
- * added a trim filter
222
-
223
- * 1.6.1 (2012-02-29)
224
-
225
- * fixed Twig C extension
226
- * removed the creation of Twig_Markup instances when not needed
227
- * added a way to set the default global timezone for dates
228
- * fixed the slice filter on strings when the length is not specified
229
- * fixed the creation of the cache directory in case of a race condition
230
-
231
- * 1.6.0 (2012-02-04)
232
-
233
- * fixed raw blocks when used with the whitespace trim option
234
- * made a speed optimization to macro calls when imported via the "from" tag
235
- * fixed globals, parsers, visitors, filters, tests, and functions management in Twig_Environment when a new one or new extension is added
236
- * fixed the attribute function when passing arguments
237
- * added slice notation support for the [] operator (syntactic sugar for the slice operator)
238
- * added a slice filter
239
- * added string support for the reverse filter
240
- * fixed the empty test and the length filter for Twig_Markup instances
241
- * added a date function to ease date comparison
242
- * fixed unary operators precedence
243
- * added recursive parsing support in the parser
244
- * added string and integer handling for the random function
245
-
246
- * 1.5.1 (2012-01-05)
247
-
248
- * fixed a regression when parsing strings
249
-
250
- * 1.5.0 (2012-01-04)
251
-
252
- * added Traversable objects support for the join filter
253
-
254
- * 1.5.0-RC2 (2011-12-30)
255
-
256
- * added a way to set the default global date interval format
257
- * fixed the date filter for DateInterval instances (setTimezone() does not exist for them)
258
- * refactored Twig_Template::display() to ease its extension
259
- * added a number_format filter
260
-
261
- * 1.5.0-RC1 (2011-12-26)
262
-
263
- * removed the need to quote hash keys
264
- * allowed hash keys to be any expression
265
- * added a do tag
266
- * added a flush tag
267
- * added support for dynamically named filters and functions
268
- * added a dump function to help debugging templates
269
- * added a nl2br filter
270
- * added a random function
271
- * added a way to change the default format for the date filter
272
- * fixed the lexer when an operator ending with a letter ends a line
273
- * added string interpolation support
274
- * enhanced exceptions for unknown filters, functions, tests, and tags
275
-
276
- * 1.4.0 (2011-12-07)
277
-
278
- * fixed lexer when using big numbers (> PHP_INT_MAX)
279
- * added missing preserveKeys argument to the reverse filter
280
- * fixed macros containing filter tag calls
281
-
282
- * 1.4.0-RC2 (2011-11-27)
283
-
284
- * removed usage of Reflection in Twig_Template::getAttribute()
285
- * added a C extension that can optionally replace Twig_Template::getAttribute()
286
- * added negative timestamp support to the date filter
287
-
288
- * 1.4.0-RC1 (2011-11-20)
289
-
290
- * optimized variable access when using PHP 5.4
291
- * changed the precedence of the .. operator to be more consistent with languages that implements such a feature like Ruby
292
- * added an Exception to Twig_Loader_Array::isFresh() method when the template does not exist to be consistent with other loaders
293
- * added Twig_Function_Node to allow more complex functions to have their own Node class
294
- * added Twig_Filter_Node to allow more complex filters to have their own Node class
295
- * added Twig_Test_Node to allow more complex tests to have their own Node class
296
- * added a better error message when a template is empty but contain a BOM
297
- * fixed "in" operator for empty strings
298
- * fixed the "defined" test and the "default" filter (now works with more than one call (foo.bar.foo) and for both values of the strict_variables option)
299
- * changed the way extensions are loaded (addFilter/addFunction/addGlobal/addTest/addNodeVisitor/addTokenParser/addExtension can now be called in any order)
300
- * added Twig_Environment::display()
301
- * made the escape filter smarter when the encoding is not supported by PHP
302
- * added a convert_encoding filter
303
- * moved all node manipulations outside the compile() Node method
304
- * made several speed optimizations
305
-
306
- * 1.3.0 (2011-10-08)
307
-
308
- no changes
309
-
310
- * 1.3.0-RC1 (2011-10-04)
311
-
312
- * added an optimization for the parent() function
313
- * added cache reloading when auto_reload is true and an extension has been modified
314
- * added the possibility to force the escaping of a string already marked as safe (instance of Twig_Markup)
315
- * allowed empty templates to be used as traits
316
- * added traits support for the "parent" function
317
-
318
- * 1.2.0 (2011-09-13)
319
-
320
- no changes
321
-
322
- * 1.2.0-RC1 (2011-09-10)
323
-
324
- * enhanced the exception when a tag remains unclosed
325
- * added support for empty Countable objects for the "empty" test
326
- * fixed algorithm that determines if a template using inheritance is valid (no output between block definitions)
327
- * added better support for encoding problems when escaping a string (available as of PHP 5.4)
328
- * added a way to ignore a missing template when using the "include" tag ({% include "foo" ignore missing %})
329
- * added support for an array of templates to the "include" and "extends" tags ({% include ['foo', 'bar'] %})
330
- * added support for bitwise operators in expressions
331
- * added the "attribute" function to allow getting dynamic attributes on variables
332
- * added Twig_Loader_Chain
333
- * added Twig_Loader_Array::setTemplate()
334
- * added an optimization for the set tag when used to capture a large chunk of static text
335
- * changed name regex to match PHP one "[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*" (works for blocks, tags, functions, filters, and macros)
336
- * removed the possibility to use the "extends" tag from a block
337
- * added "if" modifier support to "for" loops
338
-
339
- * 1.1.2 (2011-07-30)
340
-
341
- * fixed json_encode filter on PHP 5.2
342
- * fixed regression introduced in 1.1.1 ({{ block(foo|lower) }})
343
- * fixed inheritance when using conditional parents
344
- * fixed compilation of templates when the body of a child template is not empty
345
- * fixed output when a macro throws an exception
346
- * fixed a parsing problem when a large chunk of text is enclosed in a comment tag
347
- * added PHPDoc for all Token parsers and Core extension functions
348
-
349
- * 1.1.1 (2011-07-17)
350
-
351
- * added a performance optimization in the Optimizer (also helps to lower the number of nested level calls)
352
- * made some performance improvement for some edge cases
353
-
354
- * 1.1.0 (2011-06-28)
355
-
356
- * fixed json_encode filter
357
-
358
- * 1.1.0-RC3 (2011-06-24)
359
-
360
- * fixed method case-sensitivity when using the sandbox mode
361
- * added timezone support for the date filter
362
- * fixed possible security problems with NUL bytes
363
-
364
- * 1.1.0-RC2 (2011-06-16)
365
-
366
- * added an exception when the template passed to "use" is not a string
367
- * made 'a.b is defined' not throw an exception if a is not defined (in strict mode)
368
- * added {% line \d+ %} directive
369
-
370
- * 1.1.0-RC1 (2011-05-28)
371
-
372
- Flush your cache after upgrading.
373
-
374
- * fixed date filter when using a timestamp
375
- * fixed the defined test for some cases
376
- * fixed a parsing problem when a large chunk of text is enclosed in a raw tag
377
- * added support for horizontal reuse of template blocks (see docs for more information)
378
- * added whitespace control modifier to all tags (see docs for more information)
379
- * added null as an alias for none (the null test is also an alias for the none test now)
380
- * made TRUE, FALSE, NONE equivalent to their lowercase counterparts
381
- * wrapped all compilation and runtime exceptions with Twig_Error_Runtime and added logic to guess the template name and line
382
- * moved display() method to Twig_Template (generated templates should now use doDisplay() instead)
383
-
384
- * 1.0.0 (2011-03-27)
385
-
386
- * fixed output when using mbstring
387
- * fixed duplicate call of methods when using the sandbox
388
- * made the charset configurable for the escape filter
389
-
390
- * 1.0.0-RC2 (2011-02-21)
391
-
392
- * changed the way {% set %} works when capturing (the content is now marked as safe)
393
- * added support for macro name in the endmacro tag
394
- * make Twig_Error compatible with PHP 5.3.0 >
395
- * fixed an infinite loop on some Windows configurations
396
- * fixed the "length" filter for numbers
397
- * fixed Template::getAttribute() as properties in PHP are case sensitive
398
- * removed coupling between Twig_Node and Twig_Template
399
- * fixed the ternary operator precedence rule
400
-
401
- * 1.0.0-RC1 (2011-01-09)
402
-
403
- Backward incompatibilities:
404
-
405
- * the "items" filter, which has been deprecated for quite a long time now, has been removed
406
- * the "range" filter has been converted to a function: 0|range(10) -> range(0, 10)
407
- * the "constant" filter has been converted to a function: {{ some_date|date('DATE_W3C'|constant) }} -> {{ some_date|date(constant('DATE_W3C')) }}
408
- * the "cycle" filter has been converted to a function: {{ ['odd', 'even']|cycle(i) }} -> {{ cycle(['odd', 'even'], i) }}
409
- * the "for" tag does not support "joined by" anymore
410
- * the "autoescape" first argument is now "true"/"false" (instead of "on"/"off")
411
- * the "parent" tag has been replaced by a "parent" function ({{ parent() }} instead of {% parent %})
412
- * the "display" tag has been replaced by a "block" function ({{ block('title') }} instead of {% display title %})
413
- * removed the grammar and simple token parser (moved to the Twig Extensions repository)
414
-
415
- Changes:
416
-
417
- * added "needs_context" option for filters and functions (the context is then passed as a first argument)
418
- * added global variables support
419
- * made macros return their value instead of echoing directly (fixes calling a macro in sandbox mode)
420
- * added the "from" tag to import macros as functions
421
- * added support for functions (a function is just syntactic sugar for a getAttribute() call)
422
- * made macros callable when sandbox mode is enabled
423
- * added an exception when a macro uses a reserved name
424
- * the "default" filter now uses the "empty" test instead of just checking for null
425
- * added the "empty" test
426
-
427
- * 0.9.10 (2010-12-16)
428
-
429
- Backward incompatibilities:
430
-
431
- * The Escaper extension is enabled by default, which means that all displayed
432
- variables are now automatically escaped. You can revert to the previous
433
- behavior by removing the extension via $env->removeExtension('escaper')
434
- or just set the 'autoescape' option to 'false'.
435
- * removed the "without loop" attribute for the "for" tag (not needed anymore
436
- as the Optimizer take care of that for most cases)
437
- * arrays and hashes have now a different syntax
438
- * arrays keep the same syntax with square brackets: [1, 2]
439
- * hashes now use curly braces (["a": "b"] should now be written as {"a": "b"})
440
- * support for "arrays with keys" and "hashes without keys" is not supported anymore ([1, "foo": "bar"] or {"foo": "bar", 1})
441
- * the i18n extension is now part of the Twig Extensions repository
442
-
443
- Changes:
444
-
445
- * added the merge filter
446
- * removed 'is_escaper' option for filters (a left over from the previous version) -- you must use 'is_safe' now instead
447
- * fixed usage of operators as method names (like is, in, and not)
448
- * changed the order of execution for node visitors
449
- * fixed default() filter behavior when used with strict_variables set to on
450
- * fixed filesystem loader compatibility with PHAR files
451
- * enhanced error messages when an unexpected token is parsed in an expression
452
- * fixed filename not being added to syntax error messages
453
- * added the autoescape option to enable/disable autoescaping
454
- * removed the newline after a comment (mimics PHP behavior)
455
- * added a syntax error exception when parent block is used on a template that does not extend another one
456
- * made the Escaper extension enabled by default
457
- * fixed sandbox extension when used with auto output escaping
458
- * fixed escaper when wrapping a Twig_Node_Print (the original class must be preserved)
459
- * added an Optimizer extension (enabled by default; optimizes "for" loops and "raw" filters)
460
- * added priority to node visitors
461
-
462
- * 0.9.9 (2010-11-28)
463
-
464
- Backward incompatibilities:
465
- * the self special variable has been renamed to _self
466
- * the odd and even filters are now tests:
467
- {{ foo|odd }} must now be written {{ foo is odd }}
468
- * the "safe" filter has been renamed to "raw"
469
- * in Node classes,
470
- sub-nodes are now accessed via getNode() (instead of property access)
471
- attributes via getAttribute() (instead of array access)
472
- * the urlencode filter had been renamed to url_encode
473
- * the include tag now merges the passed variables with the current context by default
474
- (the old behavior is still possible by adding the "only" keyword)
475
- * moved Exceptions to Twig_Error_* (Twig_SyntaxError/Twig_RuntimeError are now Twig_Error_Syntax/Twig_Error_Runtime)
476
- * removed support for {{ 1 < i < 3 }} (use {{ i > 1 and i < 3 }} instead)
477
- * the "in" filter has been removed ({{ a|in(b) }} should now be written {{ a in b }})
478
-
479
- Changes:
480
- * added file and line to Twig_Error_Runtime exceptions thrown from Twig_Template
481
- * changed trans tag to accept any variable for the plural count
482
- * fixed sandbox mode (__toString() method check was not enforced if called implicitly from complex statements)
483
- * added the ** (power) operator
484
- * changed the algorithm used for parsing expressions
485
- * added the spaceless tag
486
- * removed trim_blocks option
487
- * added support for is*() methods for attributes (foo.bar now looks for foo->getBar() or foo->isBar())
488
- * changed all exceptions to extend Twig_Error
489
- * fixed unary expressions ({{ not(1 or 0) }})
490
- * fixed child templates (with an extend tag) that uses one or more imports
491
- * added support for {{ 1 not in [2, 3] }} (more readable than the current {{ not (1 in [2, 3]) }})
492
- * escaping has been rewritten
493
- * the implementation of template inheritance has been rewritten
494
- (blocks can now be called individually and still work with inheritance)
495
- * fixed error handling for if tag when a syntax error occurs within a subparse process
496
- * added a way to implement custom logic for resolving token parsers given a tag name
497
- * fixed js escaper to be stricter (now uses a whilelist-based js escaper)
498
- * added the following filers: "constant", "trans", "replace", "json_encode"
499
- * added a "constant" test
500
- * fixed objects with __toString() not being autoescaped
501
- * fixed subscript expressions when calling __call() (methods now keep the case)
502
- * added "test" feature (accessible via the "is" operator)
503
- * removed the debug tag (should be done in an extension)
504
- * fixed trans tag when no vars are used in plural form
505
- * fixed race condition when writing template cache
506
- * added the special _charset variable to reference the current charset
507
- * added the special _context variable to reference the current context
508
- * renamed self to _self (to avoid conflict)
509
- * fixed Twig_Template::getAttribute() for protected properties
510
-
511
- * 0.9.8 (2010-06-28)
512
-
513
- Backward incompatibilities:
514
- * the trans tag plural count is now attached to the plural tag:
515
- old: `{% trans count %}...{% plural %}...{% endtrans %}`
516
- new: `{% trans %}...{% plural count %}...{% endtrans %}`
517
-
518
- * added a way to translate strings coming from a variable ({% trans var %})
519
- * fixed trans tag when used with the Escaper extension
520
- * fixed default cache umask
521
- * removed Twig_Template instances from the debug tag output
522
- * fixed objects with __isset() defined
523
- * fixed set tag when used with a capture
524
- * fixed type hinting for Twig_Environment::addFilter() method
525
-
526
- * 0.9.7 (2010-06-12)
527
-
528
- Backward incompatibilities:
529
- * changed 'as' to '=' for the set tag ({% set title as "Title" %} must now be {% set title = "Title" %})
530
- * removed the sandboxed attribute of the include tag (use the new sandbox tag instead)
531
- * refactored the Node system (if you have custom nodes, you will have to update them to use the new API)
532
-
533
- * added self as a special variable that refers to the current template (useful for importing macros from the current template)
534
- * added Twig_Template instance support to the include tag
535
- * added support for dynamic and conditional inheritance ({% extends some_var %} and {% extends standalone ? "minimum" : "base" %})
536
- * added a grammar sub-framework to ease the creation of custom tags
537
- * fixed the for tag for large arrays (some loop variables are now only available for arrays and objects that implement the Countable interface)
538
- * removed the Twig_Resource::resolveMissingFilter() method
539
- * fixed the filter tag which did not apply filtering to included files
540
- * added a bunch of unit tests
541
- * added a bunch of phpdoc
542
- * added a sandbox tag in the sandbox extension
543
- * changed the date filter to support any date format supported by DateTime
544
- * added strict_variable setting to throw an exception when an invalid variable is used in a template (disabled by default)
545
- * added the lexer, parser, and compiler as arguments to the Twig_Environment constructor
546
- * changed the cache option to only accepts an explicit path to a cache directory or false
547
- * added a way to add token parsers, filters, and visitors without creating an extension
548
- * added three interfaces: Twig_NodeInterface, Twig_TokenParserInterface, and Twig_FilterInterface
549
- * changed the generated code to match the new coding standards
550
- * fixed sandbox mode (__toString() method check was not enforced if called implicitly from a simple statement like {{ article }})
551
- * added an exception when a child template has a non-empty body (as it is always ignored when rendering)
552
-
553
- * 0.9.6 (2010-05-12)
554
-
555
- * fixed variables defined outside a loop and for which the value changes in a for loop
556
- * fixed the test suite for PHP 5.2 and older versions of PHPUnit
557
- * added support for __call() in expression resolution
558
- * fixed node visiting for macros (macros are now visited by visitors as any other node)
559
- * fixed nested block definitions with a parent call (rarely useful but nonetheless supported now)
560
- * added the cycle filter
561
- * fixed the Lexer when mbstring.func_overload is used with an mbstring.internal_encoding different from ASCII
562
- * added a long-syntax for the set tag ({% set foo %}...{% endset %})
563
- * unit tests are now powered by PHPUnit
564
- * added support for gettext via the `i18n` extension
565
- * fixed twig_capitalize_string_filter() and fixed twig_length_filter() when used with UTF-8 values
566
- * added a more useful exception if an if tag is not closed properly
567
- * added support for escaping strategy in the autoescape tag
568
- * fixed lexer when a template has a big chunk of text between/in a block
569
-
570
- * 0.9.5 (2010-01-20)
571
-
572
- As for any new release, don't forget to remove all cached templates after
573
- upgrading.
574
-
575
- If you have defined custom filters, you MUST upgrade them for this release. To
576
- upgrade, replace "array" with "new Twig_Filter_Function", and replace the
577
- environment constant by the "needs_environment" option:
578
-
579
- // before
580
- 'even' => array('twig_is_even_filter', false),
581
- 'escape' => array('twig_escape_filter', true),
582
-
583
- // after
584
- 'even' => new Twig_Filter_Function('twig_is_even_filter'),
585
- 'escape' => new Twig_Filter_Function('twig_escape_filter', array('needs_environment' => true)),
586
-
587
- If you have created NodeTransformer classes, you will need to upgrade them to
588
- the new interface (please note that the interface is not yet considered
589
- stable).
590
-
591
- * fixed list nodes that did not extend the Twig_NodeListInterface
592
- * added the "without loop" option to the for tag (it disables the generation of the loop variable)
593
- * refactored node transformers to node visitors
594
- * fixed automatic-escaping for blocks
595
- * added a way to specify variables to pass to an included template
596
- * changed the automatic-escaping rules to be more sensible and more configurable in custom filters (the documentation lists all the rules)
597
- * improved the filter system to allow object methods to be used as filters
598
- * changed the Array and String loaders to actually make use of the cache mechanism
599
- * included the default filter function definitions in the extension class files directly (Core, Escaper)
600
- * added the // operator (like the floor() PHP function)
601
- * added the .. operator (as a syntactic sugar for the range filter when the step is 1)
602
- * added the in operator (as a syntactic sugar for the in filter)
603
- * added the following filters in the Core extension: in, range
604
- * added support for arrays (same behavior as in PHP, a mix between lists and dictionaries, arrays and hashes)
605
- * enhanced some error messages to provide better feedback in case of parsing errors
606
-
607
- * 0.9.4 (2009-12-02)
608
-
609
- If you have custom loaders, you MUST upgrade them for this release: The
610
- Twig_Loader base class has been removed, and the Twig_LoaderInterface has also
611
- been changed (see the source code for more information or the documentation).
612
-
613
- * added support for DateTime instances for the date filter
614
- * fixed loop.last when the array only has one item
615
- * made it possible to insert newlines in tag and variable blocks
616
- * fixed a bug when a literal '\n' were present in a template text
617
- * fixed bug when the filename of a template contains */
618
- * refactored loaders
619
-
620
- * 0.9.3 (2009-11-11)
621
-
622
- This release is NOT backward compatible with the previous releases.
623
-
624
- The loaders do not take the cache and autoReload arguments anymore. Instead,
625
- the Twig_Environment class has two new options: cache and auto_reload.
626
- Upgrading your code means changing this kind of code:
627
-
628
- $loader = new Twig_Loader_Filesystem('/path/to/templates', '/path/to/compilation_cache', true);
629
- $twig = new Twig_Environment($loader);
630
-
631
- to something like this:
632
-
633
- $loader = new Twig_Loader_Filesystem('/path/to/templates');
634
- $twig = new Twig_Environment($loader, array(
635
- 'cache' => '/path/to/compilation_cache',
636
- 'auto_reload' => true,
637
- ));
638
-
639
- * deprecated the "items" filter as it is not needed anymore
640
- * made cache and auto_reload options of Twig_Environment instead of arguments of Twig_Loader
641
- * optimized template loading speed
642
- * removed output when an error occurs in a template and render() is used
643
- * made major speed improvements for loops (up to 300% on even the smallest loops)
644
- * added properties as part of the sandbox mode
645
- * added public properties support (obj.item can now be the item property on the obj object)
646
- * extended set tag to support expression as value ({% set foo as 'foo' ~ 'bar' %} )
647
- * fixed bug when \ was used in HTML
648
-
649
- * 0.9.2 (2009-10-29)
650
-
651
- * made some speed optimizations
652
- * changed the cache extension to .php
653
- * added a js escaping strategy
654
- * added support for short block tag
655
- * changed the filter tag to allow chained filters
656
- * made lexer more flexible as you can now change the default delimiters
657
- * added set tag
658
- * changed default directory permission when cache dir does not exist (more secure)
659
- * added macro support
660
- * changed filters first optional argument to be a Twig_Environment instance instead of a Twig_Template instance
661
- * made Twig_Autoloader::autoload() a static method
662
- * avoid writing template file if an error occurs
663
- * added $ escaping when outputting raw strings
664
- * enhanced some error messages to ease debugging
665
- * fixed empty cache files when the template contains an error
666
-
667
- * 0.9.1 (2009-10-14)
668
-
669
- * fixed a bug in PHP 5.2.6
670
- * fixed numbers with one than one decimal
671
- * added support for method calls with arguments ({{ foo.bar('a', 43) }})
672
- * made small speed optimizations
673
- * made minor tweaks to allow better extensibility and flexibility
674
-
675
- * 0.9.0 (2009-10-12)
676
-
677
- * Initial release
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/twig/twig/LICENSE DELETED
@@ -1,31 +0,0 @@
1
- Copyright (c) 2009-2014 by the Twig Team.
2
-
3
- Some rights reserved.
4
-
5
- Redistribution and use in source and binary forms, with or without
6
- modification, are permitted provided that the following conditions are
7
- met:
8
-
9
- * Redistributions of source code must retain the above copyright
10
- notice, this list of conditions and the following disclaimer.
11
-
12
- * Redistributions in binary form must reproduce the above
13
- copyright notice, this list of conditions and the following
14
- disclaimer in the documentation and/or other materials provided
15
- with the distribution.
16
-
17
- * The names of the contributors may not be used to endorse or
18
- promote products derived from this software without specific
19
- prior written permission.
20
-
21
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22
- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25
- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27
- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/twig/twig/README.rst DELETED
@@ -1,15 +0,0 @@
1
- Twig, the flexible, fast, and secure template language for PHP
2
- ==============================================================
3
-
4
- Twig is a template language for PHP, released under the new BSD license (code
5
- and documentation).
6
-
7
- Twig uses a syntax similar to the Django and Jinja template languages which
8
- inspired the Twig runtime environment.
9
-
10
- More Information
11
- ----------------
12
-
13
- Read the `documentation`_ for more information.
14
-
15
- .. _documentation: http://twig.sensiolabs.org/documentation
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/twig/twig/composer.json DELETED
@@ -1,42 +0,0 @@
1
- {
2
- "name": "twig/twig",
3
- "type": "library",
4
- "description": "Twig, the flexible, fast, and secure template language for PHP",
5
- "keywords": ["templating"],
6
- "homepage": "http://twig.sensiolabs.org",
7
- "license": "BSD-3-Clause",
8
- "authors": [
9
- {
10
- "name": "Fabien Potencier",
11
- "email": "fabien@symfony.com",
12
- "homepage": "http://fabien.potencier.org",
13
- "role": "Lead Developer"
14
- },
15
- {
16
- "name": "Twig Team",
17
- "homepage": "https://github.com/fabpot/Twig/graphs/contributors",
18
- "role": "Contributors"
19
- },
20
- {
21
- "name": "Armin Ronacher",
22
- "email": "armin.ronacher@active-4.com",
23
- "role": "Project Founder"
24
- }
25
- ],
26
- "support": {
27
- "forum": "https://groups.google.com/forum/#!forum/twig-users"
28
- },
29
- "require": {
30
- "php": ">=5.2.4"
31
- },
32
- "autoload": {
33
- "psr-0" : {
34
- "Twig_" : "lib/"
35
- }
36
- },
37
- "extra": {
38
- "branch-alias": {
39
- "dev-master": "1.15-dev"
40
- }
41
- }
42
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/vendor/twig/twig/doc/advanced.rst DELETED
@@ -1,834 +0,0 @@
1
- Extending Twig
2
- ==============
3
-
4
- .. caution::
5
-
6
- This section describes how to extend Twig as of **Twig 1.12**. If you are
7
- using an older version, read the :doc:`legacy<advanced_legacy>` chapter
8
- instead.
9
-
10
- Twig can be extended in many ways; you can add extra tags, filters, tests,
11
- operators, global variables, and functions. You can even extend the parser
12
- itself with node visitors.
13
-
14
- .. note::
15
-
16
- The first section of this chapter describes how to extend Twig easily. If
17
- you want to reuse your changes in different projects or if you want to
18
- share them with others, you should then create an extension as described
19
- in the following section.
20
-
21
- .. caution::
22
-
23
- When extending Twig without creating an extension, Twig won't be able to
24
- recompile your templates when the PHP code is updated. To see your changes
25
- in real-time, either disable template caching or package your code into an
26
- extension (see the next section of this chapter).
27
-
28
- Before extending Twig, you must understand the differences between all the
29
- different possible extension points and when to use them.
30
-
31
- First, remember that Twig has two main language constructs:
32
-
33
- * ``{{ }}``: used to print the result of an expression evaluation;
34
-
35
- * ``{% %}``: used to execute statements.
36
-
37
- To understand why Twig exposes so many extension points, let's see how to
38
- implement a *Lorem ipsum* generator (it needs to know the number of words to
39
- generate).
40
-
41
- You can use a ``lipsum`` *tag*:
42
-
43
- .. code-block:: jinja
44
-
45
- {% lipsum 40 %}
46
-
47
- That works, but using a tag for ``lipsum`` is not a good idea for at least
48
- three main reasons:
49
-
50
- * ``lipsum`` is not a language construct;
51
- * The tag outputs something;
52
- * The tag is not flexible as you cannot use it in an expression:
53
-
54
- .. code-block:: jinja
55
-
56
- {{ 'some text' ~ {% lipsum 40 %} ~ 'some more text' }}
57
-
58
- In fact, you rarely need to create tags; and that's good news because tags are
59
- the most complex extension point of Twig.
60
-
61
- Now, let's use a ``lipsum`` *filter*:
62
-
63
- .. code-block:: jinja
64
-
65
- {{ 40|lipsum }}
66
-
67
- Again, it works, but it looks weird. A filter transforms the passed value to
68
- something else but here we use the value to indicate the number of words to
69
- generate (so, ``40`` is an argument of the filter, not the value we want to
70
- transform).
71
-
72
- Next, let's use a ``lipsum`` *function*:
73
-
74
- .. code-block:: jinja
75
-
76
- {{ lipsum(40) }}
77
-
78
- Here we go. For this specific example, the creation of a function is the
79
- extension point to use. And you can use it anywhere an expression is accepted:
80
-
81
- .. code-block:: jinja
82
-
83
- {{ 'some text' ~ lipsum(40) ~ 'some more text' }}
84
-
85
- {% set lipsum = lipsum(40) %}
86
-
87
- Last but not the least, you can also use a *global* object with a method able
88
- to generate lorem ipsum text:
89
-
90
- .. code-block:: jinja
91
-
92
- {{ text.lipsum(40) }}
93
-
94
- As a rule of thumb, use functions for frequently used features and global
95
- objects for everything else.
96
-
97
- Keep in mind the following when you want to extend Twig:
98
-
99
- ========== ========================== ========== =========================
100
- What? Implementation difficulty? How often? When?
101
- ========== ========================== ========== =========================
102
- *macro* trivial frequent Content generation
103
- *global* trivial frequent Helper object
104
- *function* trivial frequent Content generation
105
- *filter* trivial frequent Value transformation
106
- *tag* complex rare DSL language construct
107
- *test* trivial rare Boolean decision
108
- *operator* trivial rare Values transformation
109
- ========== ========================== ========== =========================
110
-
111
- Globals
112
- -------
113
-
114
- A global variable is like any other template variable, except that it's
115
- available in all templates and macros::
116
-
117
- $twig = new Twig_Environment($loader);
118
- $twig->addGlobal('text', new Text());
119
-
120
- You can then use the ``text`` variable anywhere in a template:
121
-
122
- .. code-block:: jinja
123
-
124
- {{ text.lipsum(40) }}
125
-
126
- Filters
127
- -------
128
-
129
- Creating a filter is as simple as associating a name with a PHP callable::
130
-
131
- // an anonymous function
132
- $filter = new Twig_SimpleFilter('rot13', function ($string) {
133
- return str_rot13($string);
134
- });
135
-
136
- // or a simple PHP function
137
- $filter = new Twig_SimpleFilter('rot13', 'str_rot13');
138
-
139
- // or a class method
140
- $filter = new Twig_SimpleFilter('rot13', array('SomeClass', 'rot13Filter'));
141
-
142
- The first argument passed to the ``Twig_SimpleFilter`` constructor is the name
143
- of the filter you will use in templates and the second one is the PHP callable
144
- to associate with it.
145
-
146
- Then, add the filter to your Twig environment::
147
-
148
- $twig = new Twig_Environment($loader);
149
- $twig->addFilter($filter);
150
-
151
- And here is how to use it in a template:
152
-
153
- .. code-block:: jinja
154
-
155
- {{ 'Twig'|rot13 }}
156
-
157
- {# will output Gjvt #}
158
-
159
- When called by Twig, the PHP callable receives the left side of the filter
160
- (before the pipe ``|``) as the first argument and the extra arguments passed
161
- to the filter (within parentheses ``()``) as extra arguments.
162
-
163
- For instance, the following code:
164
-
165
- .. code-block:: jinja
166
-
167
- {{ 'TWIG'|lower }}
168
- {{ now|date('d/m/Y') }}
169
-
170
- is compiled to something like the following::
171
-
172
- <?php echo strtolower('TWIG') ?>
173
- <?php echo twig_date_format_filter($now, 'd/m/Y') ?>
174
-
175
- The ``Twig_SimpleFilter`` class takes an array of options as its last
176
- argument::
177
-
178
- $filter = new Twig_SimpleFilter('rot13', 'str_rot13', $options);
179
-
180
- Environment-aware Filters
181
- ~~~~~~~~~~~~~~~~~~~~~~~~~
182
-
183
- If you want to access the current environment instance in your filter, set the
184
- ``needs_environment`` option to ``true``; Twig will pass the current
185
- environment as the first argument to the filter call::
186
-
187
- $filter = new Twig_SimpleFilter('rot13', function (Twig_Environment $env, $string) {
188
- // get the current charset for instance
189
- $charset = $env->getCharset();
190
-
191
- return str_rot13($string);
192
- }, array('needs_environment' => true));
193
-
194
- Context-aware Filters
195
- ~~~~~~~~~~~~~~~~~~~~~
196
-
197
- If you want to access the current context in your filter, set the
198
- ``needs_context`` option to ``true``; Twig will pass the current context as
199
- the first argument to the filter call (or the second one if
200
- ``needs_environment`` is also set to ``true``)::
201
-
202
- $filter = new Twig_SimpleFilter('rot13', function ($context, $string) {
203
- // ...
204
- }, array('needs_context' => true));
205
-
206
- $filter = new Twig_SimpleFilter('rot13', function (Twig_Environment $env, $context, $string) {
207
- // ...
208
- }, array('needs_context' => true, 'needs_environment' => true));
209
-
210
- Automatic Escaping
211
- ~~~~~~~~~~~~~~~~~~
212
-
213
- If automatic escaping is enabled, the output of the filter may be escaped
214
- before printing. If your filter acts as an escaper (or explicitly outputs HTML
215
- or JavaScript code), you will want the raw output to be printed. In such a
216
- case, set the ``is_safe`` option::
217
-
218
- $filter = new Twig_SimpleFilter('nl2br', 'nl2br', array('is_safe' => array('html')));
219
-
220
- Some filters may need to work on input that is already escaped or safe, for
221
- example when adding (safe) HTML tags to originally unsafe output. In such a
222
- case, set the ``pre_escape`` option to escape the input data before it is run
223
- through your filter::
224
-
225
- $filter = new Twig_SimpleFilter('somefilter', 'somefilter', array('pre_escape' => 'html', 'is_safe' => array('html')));
226
-
227
- Dynamic Filters
228
- ~~~~~~~~~~~~~~~
229
-
230
- A filter name containing the special ``*`` character is a dynamic filter as
231
- the ``*`` can be any string::
232
-
233
- $filter = new Twig_SimpleFilter('*_path', function ($name, $arguments) {
234
- // ...
235
- });
236
-
237
- The following filters will be matched by the above defined dynamic filter:
238
-
239
- * ``product_path``
240
- * ``category_path``
241
-
242
- A dynamic filter can define more than one dynamic parts::
243
-
244
- $filter = new Twig_SimpleFilter('*_path_*', function ($name, $suffix, $arguments) {
245
- // ...
246
- });
247
-
248
- The filter will receive all dynamic part values before the normal filter
249
- arguments, but after the environment and the context. For instance, a call to
250
- ``'foo'|a_path_b()`` will result in the following arguments to be passed to
251
- the filter: ``('a', 'b', 'foo')``.
252
-
253
- Functions
254
- ---------
255
-
256
- Functions are defined in the exact same way as filters, but you need to create
257
- an instance of ``Twig_SimpleFunction``::
258
-
259
- $twig = new Twig_Environment($loader);
260
- $function = new Twig_SimpleFunction('function_name', function () {
261
- // ...
262
- });
263
- $twig->addFunction($function);
264
-
265
- Functions support the same features as filters, except for the ``pre_escape``
266
- and ``preserves_safety`` options.
267
-
268
- Tests
269
- -----
270
-
271
- Tests are defined in the exact same way as filters and functions, but you need
272
- to create an instance of ``Twig_SimpleTest``::
273
-
274
- $twig = new Twig_Environment($loader);
275
- $test = new Twig_SimpleTest('test_name', function () {
276
- // ...
277
- });
278
- $twig->addTest($test);
279
-
280
- Tests allow you to create custom application specific logic for evaluating
281
- boolean conditions. As a simple example, let's create a Twig test that checks if
282
- objects are 'red'::
283
-
284
- $twig = new Twig_Environment($loader)
285
- $test = new Twig_SimpleTest('red', function ($value) {
286
- if (isset($value->color) && $value->color == 'red') {
287
- return true;
288
- }
289
- if (isset($value->paint) && $value->paint == 'red') {
290
- return true;
291
- }
292
- return false;
293
- });
294
- $twig->addTest($test);
295
-
296
- Test functions should always return true/false.
297
-
298
- When creating tests you can use the ``node_class`` option to provide custom test
299
- compilation. This is useful if your test can be compiled into PHP primitives.
300
- This is used by many of the tests built into Twig::
301
-
302
- $twig = new Twig_Environment($loader)
303
- $test = new Twig_SimpleTest(
304
- 'odd',
305
- null,
306
- array('node_class' => 'Twig_Node_Expression_Test_Odd'));
307
- $twig->addTest($test);
308
-
309
- class Twig_Node_Expression_Test_Odd extends Twig_Node_Expression_Test
310
- {
311
- public function compile(Twig_Compiler $compiler)
312
- {
313
- $compiler
314
- ->raw('(')
315
- ->subcompile($this->getNode('node'))
316
- ->raw(' % 2 == 1')
317
- ->raw(')')
318
- ;
319
- }
320
- }
321
-
322
- The above example shows how you can create tests that use a node class. The
323
- node class has access to one sub-node called 'node'. This sub-node contains the
324
- value that is being tested. When the ``odd`` filter is used in code such as:
325
-
326
- .. code-block:: jinja
327
-
328
- {% if my_value is odd %}
329
-
330
- The ``node`` sub-node will contain an expression of ``my_value``. Node-based
331
- tests also have access to the ``arguments`` node. This node will contain the
332
- various other arguments that have been provided to your test.
333
-
334
- Tags
335
- ----
336
-
337
- One of the most exciting features of a template engine like Twig is the
338
- possibility to define new language constructs. This is also the most complex
339
- feature as you need to understand how Twig's internals work.
340
-
341
- Let's create a simple ``set`` tag that allows the definition of simple
342
- variables from within a template. The tag can be used like follows:
343
-
344
- .. code-block:: jinja
345
-
346
- {% set name = "value" %}
347
-
348
- {{ name }}
349
-
350
- {# should output value #}
351
-
352
- .. note::
353
-
354
- The ``set`` tag is part of the Core extension and as such is always
355
- available. The built-in version is slightly more powerful and supports
356
- multiple assignments by default (cf. the template designers chapter for
357
- more information).
358
-
359
- Three steps are needed to define a new tag:
360
-
361
- * Defining a Token Parser class (responsible for parsing the template code);
362
-
363
- * Defining a Node class (responsible for converting the parsed code to PHP);
364
-
365
- * Registering the tag.
366
-
367
- Registering a new tag
368
- ~~~~~~~~~~~~~~~~~~~~~
369
-
370
- Adding a tag is as simple as calling the ``addTokenParser`` method on the
371
- ``Twig_Environment`` instance::
372
-
373
- $twig = new Twig_Environment($loader);
374
- $twig->addTokenParser(new Project_Set_TokenParser());
375
-
376
- Defining a Token Parser
377
- ~~~~~~~~~~~~~~~~~~~~~~~
378
-
379
- Now, let's see the actual code of this class::
380
-
381
- class Project_Set_TokenParser extends Twig_TokenParser
382
- {
383
- public function parse(Twig_Token $token)
384
- {
385
- $parser = $this->parser;
386
- $stream = $parser->getStream();
387
-
388
- $name = $stream->expect(Twig_Token::NAME_TYPE)->getValue();
389
- $stream->expect(Twig_Token::OPERATOR_TYPE, '=');
390
- $value = $parser->getExpressionParser()->parseExpression();
391
- $stream->expect(Twig_Token::BLOCK_END_TYPE);
392
-
393
- return new Project_Set_Node($name, $value, $token->getLine(), $this->getTag());
394
- }
395
-
396
- public function getTag()
397
- {
398
- return 'set';
399
- }
400
- }
401
-
402
- The ``getTag()`` method must return the tag we want to parse, here ``set``.
403
-
404
- The ``parse()`` method is invoked whenever the parser encounters a ``set``
405
- tag. It should return a ``Twig_Node`` instance that represents the node (the
406
- ``Project_Set_Node`` calls creating is explained in the next section).
407
-
408
- The parsing process is simplified thanks to a bunch of methods you can call
409
- from the token stream (``$this->parser->getStream()``):
410
-
411
- * ``getCurrent()``: Gets the current token in the stream.
412
-
413
- * ``next()``: Moves to the next token in the stream, *but returns the old one*.
414
-
415
- * ``test($type)``, ``test($value)`` or ``test($type, $value)``: Determines whether
416
- the current token is of a particular type or value (or both). The value may be an
417
- array of several possible values.
418
-
419
- * ``expect($type[, $value[, $message]])``: If the current token isn't of the given
420
- type/value a syntax error is thrown. Otherwise, if the type and value are correct,
421
- the token is returned and the stream moves to the next token.
422
-
423
- * ``look()``: Looks a the next token without consuming it.
424
-
425
- Parsing expressions is done by calling the ``parseExpression()`` like we did for
426
- the ``set`` tag.
427
-
428
- .. tip::
429
-
430
- Reading the existing ``TokenParser`` classes is the best way to learn all
431
- the nitty-gritty details of the parsing process.
432
-
433
- Defining a Node
434
- ~~~~~~~~~~~~~~~
435
-
436
- The ``Project_Set_Node`` class itself is rather simple::
437
-
438
- class Project_Set_Node extends Twig_Node
439
- {
440
- public function __construct($name, Twig_Node_Expression $value, $line, $tag = null)
441
- {
442
- parent::__construct(array('value' => $value), array('name' => $name), $line, $tag);
443
- }
444
-
445
- public function compile(Twig_Compiler $compiler)
446
- {
447
- $compiler
448
- ->addDebugInfo($this)
449
- ->write('$context[\''.$this->getAttribute('name').'\'] = ')
450
- ->subcompile($this->getNode('value'))
451
- ->raw(";\n")
452
- ;
453
- }
454
- }
455
-
456
- The compiler implements a fluid interface and provides methods that helps the
457
- developer generate beautiful and readable PHP code:
458
-
459
- * ``subcompile()``: Compiles a node.
460
-
461
- * ``raw()``: Writes the given string as is.
462
-
463
- * ``write()``: Writes the given string by adding indentation at the beginning
464
- of each line.
465
-
466
- * ``string()``: Writes a quoted string.
467
-
468
- * ``repr()``: Writes a PHP representation of a given value (see
469
- ``Twig_Node_For`` for a usage example).
470
-
471
- * ``addDebugInfo()``: Adds the line of the original template file related to
472
- the current node as a comment.
473
-
474
- * ``indent()``: Indents the generated code (see ``Twig_Node_Block`` for a
475
- usage example).
476
-
477
- * ``outdent()``: Outdents the generated code (see ``Twig_Node_Block`` for a
478
- usage example).
479
-
480
- .. _creating_extensions:
481
-
482
- Creating an Extension
483
- ---------------------
484
-
485
- The main motivation for writing an extension is to move often used code into a
486
- reusable class like adding support for internationalization. An extension can
487
- define tags, filters, tests, operators, global variables, functions, and node
488
- visitors.
489
-
490
- Creating an extension also makes for a better separation of code that is
491
- executed at compilation time and code needed at runtime. As such, it makes
492
- your code faster.
493
-
494
- Most of the time, it is useful to create a single extension for your project,
495
- to host all the specific tags and filters you want to add to Twig.
496
-
497
- .. tip::
498
-
499
- When packaging your code into an extension, Twig is smart enough to
500
- recompile your templates whenever you make a change to it (when
501
- ``auto_reload`` is enabled).
502
-
503
- .. note::
504
-
505
- Before writing your own extensions, have a look at the Twig official
506
- extension repository: http://github.com/fabpot/Twig-extensions.
507
-
508
- An extension is a class that implements the following interface::
509
-
510
- interface Twig_ExtensionInterface
511
- {
512
- /**
513
- * Initializes the runtime environment.
514
- *
515
- * This is where you can load some file that contains filter functions for instance.
516
- *
517
- * @param Twig_Environment $environment The current Twig_Environment instance
518
- */
519
- function initRuntime(Twig_Environment $environment);
520
-
521
- /**
522
- * Returns the token parser instances to add to the existing list.
523
- *
524
- * @return array An array of Twig_TokenParserInterface or Twig_TokenParserBrokerInterface instances
525
- */
526
- function getTokenParsers();
527
-
528
- /**
529
- * Returns the node visitor instances to add to the existing list.
530
- *
531
- * @return array An array of Twig_NodeVisitorInterface instances
532
- */
533
- function getNodeVisitors();
534
-
535
- /**
536
- * Returns a list of filters to add to the existing list.
537
- *
538
- * @return array An array of filters
539
- */
540
- function getFilters();
541
-
542
- /**
543
- * Returns a list of tests to add to the existing list.
544
- *
545
- * @return array An array of tests
546
- */
547
- function getTests();
548
-
549
- /**
550
- * Returns a list of functions to add to the existing list.
551
- *
552
- * @return array An array of functions
553
- */
554
- function getFunctions();
555
-
556
- /**
557
- * Returns a list of operators to add to the existing list.
558
- *
559
- * @return array An array of operators
560
- */
561
- function getOperators();
562
-
563
- /**
564
- * Returns a list of global variables to add to the existing list.
565
- *
566
- * @return array An array of global variables
567
- */
568
- function getGlobals();
569
-
570
- /**
571
- * Returns the name of the extension.
572
- *
573
- * @return string The extension name
574
- */
575
- function getName();
576
- }
577
-
578
- To keep your extension class clean and lean, it can inherit from the built-in
579
- ``Twig_Extension`` class instead of implementing the whole interface. That
580
- way, you just need to implement the ``getName()`` method as the
581
- ``Twig_Extension`` provides empty implementations for all other methods.
582
-
583
- The ``getName()`` method must return a unique identifier for your extension.
584
-
585
- Now, with this information in mind, let's create the most basic extension
586
- possible::
587
-
588
- class Project_Twig_Extension extends Twig_Extension
589
- {
590
- public function getName()
591
- {
592
- return 'project';
593
- }
594
- }
595
-
596
- .. note::
597
-
598
- Of course, this extension does nothing for now. We will customize it in
599
- the next sections.
600
-
601
- Twig does not care where you save your extension on the filesystem, as all
602
- extensions must be registered explicitly to be available in your templates.
603
-
604
- You can register an extension by using the ``addExtension()`` method on your
605
- main ``Environment`` object::
606
-
607
- $twig = new Twig_Environment($loader);
608
- $twig->addExtension(new Project_Twig_Extension());
609
-
610
- Of course, you need to first load the extension file by either using
611
- ``require_once()`` or by using an autoloader (see `spl_autoload_register()`_).
612
-
613
- .. tip::
614
-
615
- The bundled extensions are great examples of how extensions work.
616
-
617
- Globals
618
- ~~~~~~~
619
-
620
- Global variables can be registered in an extension via the ``getGlobals()``
621
- method::
622
-
623
- class Project_Twig_Extension extends Twig_Extension
624
- {
625
- public function getGlobals()
626
- {
627
- return array(
628
- 'text' => new Text(),
629
- );
630
- }
631
-
632
- // ...
633
- }
634
-
635
- Functions
636
- ~~~~~~~~~
637
-
638
- Functions can be registered in an extension via the ``getFunctions()``
639
- method::
640
-
641
- class Project_Twig_Extension extends Twig_Extension
642
- {
643
- public function getFunctions()
644
- {
645
- return array(
646
- new Twig_SimpleFunction('lipsum', 'generate_lipsum'),
647
- );
648
- }
649
-
650
- // ...
651
- }
652
-
653
- Filters
654
- ~~~~~~~
655
-
656
- To add a filter to an extension, you need to override the ``getFilters()``
657
- method. This method must return an array of filters to add to the Twig
658
- environment::
659
-
660
- class Project_Twig_Extension extends Twig_Extension
661
- {
662
- public function getFilters()
663
- {
664
- return array(
665
- new Twig_SimpleFilter('rot13', 'str_rot13'),
666
- );
667
- }
668
-
669
- // ...
670
- }
671
-
672
- Tags
673
- ~~~~
674
-
675
- Adding a tag in an extension can be done by overriding the
676
- ``getTokenParsers()`` method. This method must return an array of tags to add
677
- to the Twig environment::
678
-
679
- class Project_Twig_Extension extends Twig_Extension
680
- {
681
- public function getTokenParsers()
682
- {
683
- return array(new Project_Set_TokenParser());
684
- }
685
-
686
- // ...
687
- }
688
-
689
- In the above code, we have added a single new tag, defined by the
690
- ``Project_Set_TokenParser`` class. The ``Project_Set_TokenParser`` class is
691
- responsible for parsing the tag and compiling it to PHP.
692
-
693
- Operators
694
- ~~~~~~~~~
695
-
696
- The ``getOperators()`` methods lets you add new operators. Here is how to add
697
- ``!``, ``||``, and ``&&`` operators::
698
-
699
- class Project_Twig_Extension extends Twig_Extension
700
- {
701
- public function getOperators()
702
- {
703
- return array(
704
- array(
705
- '!' => array('precedence' => 50, 'class' => 'Twig_Node_Expression_Unary_Not'),
706
- ),
707
- array(
708
- '||' => array('precedence' => 10, 'class' => 'Twig_Node_Expression_Binary_Or', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
709
- '&&' => array('precedence' => 15, 'class' => 'Twig_Node_Expression_Binary_And', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
710
- ),
711
- );
712
- }
713
-
714
- // ...
715
- }
716
-
717
- Tests
718
- ~~~~~
719
-
720
- The ``getTests()`` method lets you add new test functions::
721
-
722
- class Project_Twig_Extension extends Twig_Extension
723
- {
724
- public function getTests()
725
- {
726
- return array(
727
- new Twig_SimpleTest('even', 'twig_test_even'),
728
- );
729
- }
730
-
731
- // ...
732
- }
733
-
734
- Overloading
735
- -----------
736
-
737
- To overload an already defined filter, test, operator, global variable, or
738
- function, re-define it in an extension and register it **as late as
739
- possible** (order matters)::
740
-
741
- class MyCoreExtension extends Twig_Extension
742
- {
743
- public function getFilters()
744
- {
745
- return array(
746
- new Twig_SimpleFilter('date', array($this, 'dateFilter')),
747
- );
748
- }
749
-
750
- public function dateFilter($timestamp, $format = 'F j, Y H:i')
751
- {
752
- // do something different from the built-in date filter
753
- }
754
-
755
- public function getName()
756
- {
757
- return 'project';
758
- }
759
- }
760
-
761
- $twig = new Twig_Environment($loader);
762
- $twig->addExtension(new MyCoreExtension());
763
-
764
- Here, we have overloaded the built-in ``date`` filter with a custom one.
765
-
766
- If you do the same on the Twig_Environment itself, beware that it takes
767
- precedence over any other registered extensions::
768
-
769
- $twig = new Twig_Environment($loader);
770
- $twig->addFilter(new Twig_SimpleFilter('date', function ($timestamp, $format = 'F j, Y H:i') {
771
- // do something different from the built-in date filter
772
- }));
773
- // the date filter will come from the above registration, not
774
- // from the registered extension below
775
- $twig->addExtension(new MyCoreExtension());
776
-
777
- .. caution::
778
-
779
- Note that overloading the built-in Twig elements is not recommended as it
780
- might be confusing.
781
-
782
- Testing an Extension
783
- --------------------
784
-
785
- Functional Tests
786
- ~~~~~~~~~~~~~~~~
787
-
788
- You can create functional tests for extensions simply by creating the
789
- following file structure in your test directory::
790
-
791
- Fixtures/
792
- filters/
793
- foo.test
794
- bar.test
795
- functions/
796
- foo.test
797
- bar.test
798
- tags/
799
- foo.test
800
- bar.test
801
- IntegrationTest.php
802
-
803
- The ``IntegrationTest.php`` file should look like this::
804
-
805
- class Project_Tests_IntegrationTest extends Twig_Test_IntegrationTestCase
806
- {
807
- public f