Timber - Version 0.20.10

Version Description

  • Resolved lingering composer issues (thanks @austinpray, @lucasmichot)
  • You can now access {{comment.status}} when working with comments (thanks @simonmilz)
  • Better support for alternate setups with uploads directory (thanks @xavierpriour)
  • Major clean-up of image-handling classes (thanks @xavierpriour)
  • Starter theme now follows WP coding standards (thanks @kuus)
  • A slew of other bugs and clean-up (thanks @JeyKeu, @quinn and @jaredNova)
Download this release

Release Info

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

Code changes from version 0.20.9 to 0.20.10

Files changed (196) hide show
  1. README.md +2 -0
  2. functions/timber-image-helper.php +0 -613
  3. functions/timber-image-retina-helper.php +0 -54
  4. {functions → lib}/cache/KeyGenerator.php +0 -0
  5. {functions → lib}/cache/TimberKeyGeneratorInterface.php +0 -0
  6. {functions → lib}/cache/WPObjectCacheAdapter.php +0 -0
  7. {functions → lib}/cache/loader.php +0 -0
  8. lib/image/timber-image-operation-letterbox.php +97 -0
  9. lib/image/timber-image-operation-pngtojpg.php +49 -0
  10. lib/image/timber-image-operation-resize.php +119 -0
  11. lib/image/timber-image-operation-retina.php +66 -0
  12. lib/image/timber-image-operation.php +49 -0
  13. {functions → lib}/integrations/acf-timber.php +0 -0
  14. {functions → lib}/integrations/wpcli-timber.php +0 -0
  15. {functions → lib}/timber-admin.php +0 -0
  16. {functions → lib}/timber-archives.php +1 -1
  17. {functions → lib}/timber-comment.php +7 -0
  18. {functions → lib}/timber-core-interface.php +0 -0
  19. {functions → lib}/timber-core.php +0 -0
  20. {functions → lib}/timber-function-wrapper.php +0 -0
  21. {functions → lib}/timber-helper.php +0 -0
  22. lib/timber-image-helper.php +473 -0
  23. {functions → lib}/timber-image.php +0 -0
  24. {functions → lib}/timber-loader.php +9 -4
  25. {functions → lib}/timber-menu-item.php +0 -0
  26. {functions → lib}/timber-menu.php +0 -0
  27. {functions → lib}/timber-page.php +0 -0
  28. {functions → lib}/timber-post-getter.php +0 -0
  29. {functions → lib}/timber-post.php +0 -0
  30. {functions → lib}/timber-posts-collection.php +14 -14
  31. {functions → lib}/timber-query-iterator.php +0 -0
  32. {functions → lib}/timber-routes.php +11 -15
  33. {functions → lib}/timber-site.php +0 -0
  34. {functions → lib}/timber-term-getter.php +0 -0
  35. {functions → lib}/timber-term.php +0 -0
  36. {functions → lib}/timber-theme.php +0 -0
  37. {functions → lib}/timber-twig.php +0 -0
  38. {functions → lib}/timber-url-helper.php +9 -1
  39. {functions → lib}/timber-user.php +0 -0
  40. readme.txt +14 -1
  41. timber-starter-theme/404.php +2 -2
  42. timber-starter-theme/archive.php +24 -24
  43. timber-starter-theme/author.php +4 -4
  44. timber-starter-theme/footer.php +4 -4
  45. timber-starter-theme/functions.php +46 -46
  46. timber-starter-theme/header.php +1 -1
  47. timber-starter-theme/index.php +16 -18
  48. timber-starter-theme/js/site.js +1 -1
  49. timber-starter-theme/page.php +2 -2
  50. timber-starter-theme/search.php +9 -10
  51. timber-starter-theme/sidebar.php +1 -1
  52. timber-starter-theme/single.php +4 -6
  53. timber-starter-theme/style.css +4 -3
  54. timber-starter-theme/views/author.twig +4 -5
  55. timber-starter-theme/views/base.twig +53 -55
  56. timber-starter-theme/views/html-header.twig +10 -4
  57. timber-starter-theme/views/index.twig +0 -1
  58. timber-starter-theme/views/page-plugin.twig +3 -3
  59. timber-starter-theme/views/page.twig +1 -5
  60. timber-starter-theme/views/single-password.twig +5 -4
  61. timber-starter-theme/views/single.twig +1 -8
  62. timber-starter-theme/views/tease-post.twig +1 -1
  63. timber-starter-theme/views/tease.twig +0 -1
  64. timber.php +34 -32
  65. vendor/asm89/twig-cache-extension/README.md +11 -3
  66. vendor/asm89/twig-cache-extension/composer.json +1 -1
  67. vendor/asm89/twig-cache-extension/lib/Asm89/Twig/CacheExtension/Node/CacheNode.php +6 -4
  68. vendor/asm89/twig-cache-extension/lib/Asm89/Twig/CacheExtension/TokenParser/Cache.php +2 -1
  69. vendor/asm89/twig-cache-extension/test/Asm89/Twig/CacheExtension/Tests/FunctionalExtensionTest.php +4 -7
  70. vendor/asm89/twig-cache-extension/test/Asm89/Twig/CacheExtension/Tests/fixtures/annotation_expression.twig +3 -0
  71. vendor/autoload.php +1 -1
  72. vendor/composer/autoload_namespaces.php +1 -2
  73. vendor/composer/autoload_real.php +4 -4
  74. vendor/composer/installed.json +39 -123
  75. vendor/composer/installers/README.md +3 -1
  76. vendor/composer/installers/composer.json +1 -0
  77. vendor/composer/installers/src/Composer/Installers/ClanCatsFrameworkInstaller.php +10 -0
  78. vendor/composer/installers/src/Composer/Installers/DrupalInstaller.php +2 -1
  79. vendor/composer/installers/src/Composer/Installers/Installer.php +2 -0
  80. vendor/composer/installers/src/Composer/Installers/SMFInstaller.php +10 -0
  81. vendor/composer/installers/tests/Composer/Installers/Test/InstallerTest.php +4 -0
  82. vendor/{dannyvankooten → jarednova}/php-router/.gitignore +0 -0
  83. vendor/{dannyvankooten → jarednova}/php-router/.htaccess +0 -0
  84. vendor/{dannyvankooten → jarednova}/php-router/LICENSE +0 -0
  85. vendor/{dannyvankooten → jarednova}/php-router/README.md +0 -0
  86. vendor/{dannyvankooten → jarednova}/php-router/composer.json +26 -26
  87. vendor/{dannyvankooten → jarednova}/php-router/example.php +0 -0
  88. vendor/{dannyvankooten → jarednova}/php-router/src/PHPRouter/Route.php +0 -0
  89. vendor/{dannyvankooten → jarednova}/php-router/src/PHPRouter/Router.php +0 -0
  90. vendor/symfony/yaml/Symfony/Component/Yaml/.gitignore +0 -3
  91. vendor/symfony/yaml/Symfony/Component/Yaml/CHANGELOG.md +0 -8
  92. vendor/symfony/yaml/Symfony/Component/Yaml/Dumper.php +0 -73
  93. vendor/symfony/yaml/Symfony/Component/Yaml/Escaper.php +0 -89
  94. vendor/symfony/yaml/Symfony/Component/Yaml/Exception/DumpException.php +0 -23
  95. vendor/symfony/yaml/Symfony/Component/Yaml/Exception/ExceptionInterface.php +0 -23
  96. vendor/symfony/yaml/Symfony/Component/Yaml/Exception/ParseException.php +0 -148
  97. vendor/symfony/yaml/Symfony/Component/Yaml/Exception/RuntimeException.php +0 -23
  98. vendor/symfony/yaml/Symfony/Component/Yaml/Inline.php +0 -535
  99. vendor/symfony/yaml/Symfony/Component/Yaml/LICENSE +0 -19
  100. vendor/symfony/yaml/Symfony/Component/Yaml/Parser.php +0 -692
  101. vendor/symfony/yaml/Symfony/Component/Yaml/README.md +0 -21
  102. vendor/symfony/yaml/Symfony/Component/Yaml/Tests/DumperTest.php +0 -237
  103. vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/YtsAnchorAlias.yml +0 -31
  104. vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/YtsBasicTests.yml +0 -202
  105. vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/YtsBlockMapping.yml +0 -51
  106. vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/YtsDocumentSeparator.yml +0 -85
  107. vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/YtsErrorTests.yml +0 -25
  108. vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/YtsFlowCollections.yml +0 -60
  109. vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/YtsFoldedScalars.yml +0 -176
  110. vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/YtsNullsAndEmpties.yml +0 -45
  111. vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/YtsSpecificationExamples.yml +0 -1697
  112. vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/YtsTypeTransfers.yml +0 -244
  113. vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/embededPhp.yml +0 -1
  114. vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/escapedCharacters.yml +0 -147
  115. vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/index.yml +0 -18
  116. vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/sfComments.yml +0 -73
  117. vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/sfCompact.yml +0 -159
  118. vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/sfMergeKey.yml +0 -45
  119. vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/sfObjects.yml +0 -11
  120. vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/sfQuotes.yml +0 -33
  121. vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/sfTests.yml +0 -135
  122. vendor/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/unindentedCollections.yml +0 -62
  123. vendor/symfony/yaml/Symfony/Component/Yaml/Tests/InlineTest.php +0 -364
  124. vendor/symfony/yaml/Symfony/Component/Yaml/Tests/ParseExceptionTest.php +0 -42
  125. vendor/symfony/yaml/Symfony/Component/Yaml/Tests/ParserTest.php +0 -707
  126. vendor/symfony/yaml/Symfony/Component/Yaml/Tests/YamlTest.php +0 -31
  127. vendor/symfony/yaml/Symfony/Component/Yaml/Unescaper.php +0 -141
  128. vendor/symfony/yaml/Symfony/Component/Yaml/Yaml.php +0 -100
  129. vendor/symfony/yaml/Symfony/Component/Yaml/composer.json +0 -31
  130. vendor/symfony/yaml/Symfony/Component/Yaml/phpunit.xml.dist +0 -24
  131. vendor/twig/twig/.gitignore +4 -1
  132. vendor/twig/twig/CHANGELOG +13 -0
  133. vendor/twig/twig/composer.json +1 -1
  134. vendor/twig/twig/doc/advanced.rst +2 -2
  135. vendor/twig/twig/doc/api.rst +45 -5
  136. vendor/twig/twig/doc/filters/batch.rst +1 -1
  137. vendor/twig/twig/ext/twig/php_twig.h +1 -1
  138. vendor/twig/twig/lib/Twig/Autoloader.php +1 -1
  139. vendor/twig/twig/lib/Twig/Compiler.php +4 -2
  140. vendor/twig/twig/lib/Twig/Environment.php +54 -18
  141. vendor/twig/twig/lib/Twig/Error.php +2 -2
  142. vendor/twig/twig/lib/Twig/ExistsLoaderInterface.php +1 -1
  143. vendor/twig/twig/lib/Twig/ExpressionParser.php +2 -2
  144. vendor/twig/twig/lib/Twig/Extension/Core.php +9 -10
  145. vendor/twig/twig/lib/Twig/Extension/Escaper.php +4 -0
  146. vendor/twig/twig/lib/Twig/Extension/Profiler.php +52 -0
  147. vendor/twig/twig/lib/Twig/Extension/StringLoader.php +1 -18
  148. vendor/twig/twig/lib/Twig/FileExtensionEscapingStrategy.php +49 -0
  149. vendor/twig/twig/lib/Twig/Lexer.php +0 -2
  150. vendor/twig/twig/lib/Twig/Loader/Filesystem.php +3 -0
  151. vendor/twig/twig/lib/Twig/LoaderInterface.php +1 -1
  152. vendor/twig/twig/lib/Twig/Node.php +6 -6
  153. vendor/twig/twig/lib/Twig/Node/{SandboxedModule.php → CheckSecurity.php} +5 -23
  154. vendor/twig/twig/lib/Twig/Node/Expression/Call.php +36 -8
  155. vendor/twig/twig/lib/Twig/Node/Expression/Name.php +2 -0
  156. vendor/twig/twig/lib/Twig/Node/Module.php +49 -29
  157. vendor/twig/twig/lib/Twig/NodeVisitor/Optimizer.php +1 -1
  158. vendor/twig/twig/lib/Twig/NodeVisitor/Sandbox.php +1 -1
  159. vendor/twig/twig/lib/Twig/NodeVisitorInterface.php +1 -1
  160. vendor/twig/twig/lib/Twig/Profiler/Dumper/Blackfire.php +68 -0
  161. vendor/twig/twig/lib/Twig/Profiler/Dumper/Html.php +43 -0
  162. vendor/twig/twig/lib/Twig/Profiler/Dumper/Text.php +68 -0
  163. vendor/twig/twig/lib/Twig/Profiler/Node/EnterProfile.php +40 -0
  164. vendor/twig/twig/lib/Twig/Profiler/Node/LeaveProfile.php +34 -0
  165. vendor/twig/twig/lib/Twig/Profiler/NodeVisitor/Profiler.php +72 -0
  166. vendor/twig/twig/lib/Twig/Profiler/Profile.php +150 -0
  167. vendor/twig/twig/lib/Twig/Template.php +18 -26
  168. vendor/twig/twig/lib/Twig/Test/IntegrationTestCase.php +1 -1
  169. vendor/twig/twig/lib/Twig/Test/NodeTestCase.php +5 -3
  170. vendor/twig/twig/lib/Twig/Token.php +8 -8
  171. vendor/twig/twig/lib/Twig/TokenStream.php +1 -1
  172. vendor/twig/twig/test/Twig/Tests/ErrorTest.php +2 -2
  173. vendor/twig/twig/test/Twig/Tests/ExpressionParserTest.php +2 -2
  174. vendor/twig/twig/test/Twig/Tests/FileCachingTest.php +9 -0
  175. vendor/twig/twig/test/Twig/Tests/FileExtensionEscapingStrategyTest.php +49 -0
  176. vendor/twig/twig/test/Twig/Tests/Fixtures/autoescape/filename.test +18 -0
  177. vendor/twig/twig/test/Twig/Tests/Fixtures/exceptions/multiline_array_with_undefined_variable.test +18 -0
  178. vendor/twig/twig/test/Twig/Tests/Fixtures/exceptions/multiline_array_with_undefined_variable_again.test +18 -0
  179. vendor/twig/twig/test/Twig/Tests/Fixtures/exceptions/multiline_function_with_undefined_variable.test +12 -0
  180. vendor/twig/twig/test/Twig/Tests/Fixtures/exceptions/multiline_function_with_unknown_argument.test +9 -0
  181. vendor/twig/twig/test/Twig/Tests/Fixtures/exceptions/multiline_tag_with_undefined_variable.test +12 -0
  182. vendor/twig/twig/test/Twig/Tests/Loader/FilesystemTest.php +6 -0
  183. vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/named_quater/named_absolute.html +1 -0
  184. vendor/twig/twig/test/Twig/Tests/NativeExtensionTest.php +1 -1
  185. vendor/twig/twig/test/Twig/Tests/Node/Expression/CallTest.php +25 -0
  186. vendor/twig/twig/test/Twig/Tests/Node/Expression/FilterTest.php +1 -1
  187. vendor/twig/twig/test/Twig/Tests/Node/Expression/GetAttrTest.php +3 -3
  188. vendor/twig/twig/test/Twig/Tests/Node/Expression/NameTest.php +4 -4
  189. vendor/twig/twig/test/Twig/Tests/Node/SandboxedModuleTest.php +0 -203
  190. vendor/twig/twig/test/Twig/Tests/Profiler/Dumper/AbstractTest.php +44 -0
  191. vendor/twig/twig/test/Twig/Tests/Profiler/Dumper/BlackfireTest.php +32 -0
  192. vendor/twig/twig/test/Twig/Tests/Profiler/Dumper/HtmlTest.php +30 -0
  193. vendor/twig/twig/test/Twig/Tests/Profiler/Dumper/TextTest.php +30 -0
  194. vendor/twig/twig/test/Twig/Tests/Profiler/ProfileTest.php +99 -0
  195. vendor/twig/twig/test/Twig/Tests/TemplateTest.php +3 -3
  196. vendor/twig/twig/test/Twig/Tests/escapingTest.php +5 -6
README.md CHANGED
@@ -5,6 +5,8 @@ By Jared Novack (<a href="http://twitter.com/jarednova">@JaredNova</a>) and <a h
5
  </div>
6
 
7
  [![Build Status](https://travis-ci.org/jarednova/timber.png?branch=master)](https://travis-ci.org/jarednova/timber)
 
 
8
 
9
  ### Because WordPress is awesome, but the_loop isn't
10
  Timber helps you create fully-customized WordPress themes faster with more sustainable code. With Timber, you write your HTML using the [Twig Template Engine](http://twig.sensiolabs.org/) separate from your PHP files.
5
  </div>
6
 
7
  [![Build Status](https://travis-ci.org/jarednova/timber.png?branch=master)](https://travis-ci.org/jarednova/timber)
8
+ [![Coverage Status](https://coveralls.io/repos/jarednova/timber/badge.svg?branch=master)](https://coveralls.io/r/jarednova/timber?branch=master)
9
+ [![Dependency Status](https://www.versioneye.com/php/jarednova:timber/badge.svg)](https://www.versioneye.com/php/jarednova:timber)
10
 
11
  ### Because WordPress is awesome, but the_loop isn't
12
  Timber helps you create fully-customized WordPress themes faster with more sustainable code. With Timber, you write your HTML using the [Twig Template Engine](http://twig.sensiolabs.org/) separate from your PHP files.
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/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 → lib}/cache/KeyGenerator.php RENAMED
File without changes
{functions → lib}/cache/TimberKeyGeneratorInterface.php RENAMED
File without changes
{functions → lib}/cache/WPObjectCacheAdapter.php RENAMED
File without changes
{functions → lib}/cache/loader.php RENAMED
File without changes
lib/image/timber-image-operation-letterbox.php ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Changes image to new size, by shrinking/enlarging then padding with colored bands,
4
+ * so that no part of the image is cropped or stretched.
5
+ *
6
+ * Arguments:
7
+ * - width of new image
8
+ * - height of new image
9
+ * - color of padding
10
+ */
11
+ class TimberImageOperationLetterbox extends TimberImageOperation {
12
+
13
+ private $w, $h, $color;
14
+
15
+ /**
16
+ * @param int $w width of result image
17
+ * @param int $h height
18
+ * @param string $color hex string, for color of padding bands
19
+ */
20
+ function __construct($w, $h, $color) {
21
+ $this->w = $w;
22
+ $this->h = $h;
23
+ $this->color = $color;
24
+ }
25
+
26
+ /**
27
+ * @param string $src_filename the basename of the file (ex: my-awesome-pic)
28
+ * @param string $src_extension the extension (ex: .jpg)
29
+ * @return string the final filename to be used
30
+ * (ex: my-awesome-pic-lbox-300x200-FF3366.jpg)
31
+ */
32
+ public function filename($src_filename, $src_extension) {
33
+ $color = str_replace( '#', '', $this->color );
34
+ $newbase = $src_filename . '-lbox-' . $this->w . 'x' . $this->h . '-' . $color;
35
+ $new_name = $newbase . '.' . $src_extension;
36
+ return $new_name;
37
+ }
38
+
39
+ /**
40
+ * Performs the actual image manipulation,
41
+ * including saving the target file.
42
+ *
43
+ * @param string $load_filename filepath (not URL) to source file
44
+ * (ex: /src/var/www/wp-content/uploads/my-pic.jpg)
45
+ * @param string $save_filename filepath (not URL) where result file should be saved
46
+ * (ex: /src/var/www/wp-content/uploads/my-pic-lbox-300x200-FF3366.jpg)
47
+ * @return bool true if everything went fine, false otherwise
48
+ */
49
+ public function run($load_filename, $save_filename) {
50
+ $w = $this->w;
51
+ $h = $this->h;
52
+
53
+ $bg = imagecreatetruecolor( $w, $h );
54
+ $c = self::hexrgb( $this->color );
55
+ $bgColor = imagecolorallocate( $bg, $c['red'], $c['green'], $c['blue'] );
56
+ imagefill( $bg, 0, 0, $bgColor );
57
+ $image = wp_get_image_editor( $load_filename );
58
+ if ( !is_wp_error( $image ) ) {
59
+ $current_size = $image->get_size();
60
+ $ow = $current_size['width'];
61
+ $oh = $current_size['height'];
62
+ $new_aspect = $w / $h;
63
+ $old_aspect = $ow / $oh;
64
+ if ( $new_aspect > $old_aspect ) {
65
+ //taller than goal
66
+ $h_scale = $h / $oh;
67
+ $owt = $ow * $h_scale;
68
+ $y = 0;
69
+ $x = $w / 2 - $owt / 2;
70
+ $oht = $h;
71
+ $image->crop( 0, 0, $ow, $oh, $owt, $oht );
72
+ } else {
73
+ $w_scale = $w / $ow;
74
+ $oht = $oh * $w_scale;
75
+ $x = 0;
76
+ $y = $h / 2 - $oht / 2;
77
+ $owt = $w;
78
+ $image->crop( 0, 0, $ow, $oh, $owt, $oht );
79
+ }
80
+ $image->save( $save_filename );
81
+ $func = 'imagecreatefromjpeg';
82
+ $ext = pathinfo( $save_filename, PATHINFO_EXTENSION );
83
+ if ( $ext == 'gif' ) {
84
+ $func = 'imagecreatefromgif';
85
+ } else if ( $ext == 'png' ) {
86
+ $func = 'imagecreatefrompng';
87
+ }
88
+ $image = $func( $save_filename );
89
+ imagecopy( $bg, $image, $x, $y, 0, 0, $owt, $oht );
90
+ imagejpeg( $bg, $save_filename );
91
+ return true;
92
+ } else {
93
+ TimberHelper::error_log( $image );
94
+ }
95
+ return false;
96
+ }
97
+ }
lib/image/timber-image-operation-pngtojpg.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Implements converting a PNG file to JPG.
5
+ * Argument:
6
+ * - color to fill transparent zones
7
+ */
8
+ class TimberImageOperationPngToJpg extends TimberImageOperation {
9
+
10
+ private $color;
11
+
12
+ /**
13
+ * @param string $color hex string of color to use for transparent zones
14
+ */
15
+ function __construct($color) {
16
+ $this->color = $color;
17
+ }
18
+
19
+ /**
20
+ * @param string $src_filename the basename of the file (ex: my-awesome-pic)
21
+ * @param string $src_extension ignored
22
+ * @return string the final filename to be used (ex: my-awesome-pic.jpg)
23
+ */
24
+ function filename($src_filename, $src_extension = 'jpg') {
25
+ $new_name = $src_filename . '.jpg';
26
+ return $new_name;
27
+ }
28
+
29
+ /**
30
+ * Performs the actual image manipulation,
31
+ * including saving the target file.
32
+ *
33
+ * @param string $load_filename filepath (not URL) to source file (ex: /src/var/www/wp-content/uploads/my-pic.jpg)
34
+ * @param string $save_filename filepath (not URL) where result file should be saved
35
+ * (ex: /src/var/www/wp-content/uploads/my-pic.png)
36
+ * @return bool true if everything went fine, false otherwise
37
+ */
38
+ function run($load_filename, $save_filename){
39
+ $input = imagecreatefrompng( $load_filename );
40
+ list( $width, $height ) = getimagesize( $load_filename );
41
+ $output = imagecreatetruecolor( $width, $height );
42
+ $c = self::hexrgb( $this->color );
43
+ $color = imagecolorallocate( $output, $c['red'], $c['green'], $c['blue'] );
44
+ imagefilledrectangle( $output, 0, 0, $width, $height, $color );
45
+ imagecopy( $output, $input, 0, 0, 0, 0, $width, $height );
46
+ imagejpeg( $output, $save_filename );
47
+ return true;
48
+ }
49
+ }
lib/image/timber-image-operation-resize.php ADDED
@@ -0,0 +1,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Changes image to new size, by shrinking/enlarging
4
+ * then cropping to respect new ratio.
5
+ *
6
+ * Arguments:
7
+ * - width of new image
8
+ * - height of new image
9
+ * - crop method
10
+ */
11
+ class TimberImageOperationResize extends TimberImageOperation {
12
+
13
+ private $w, $h, $crop;
14
+
15
+ /**
16
+ * @param int $w width of new image
17
+ * @param int $h height of new image
18
+ * @param string $crop cropping method, one of: 'default', 'center', 'top', 'bottom', 'left', 'right'.
19
+ */
20
+ function __construct($w, $h, $crop) {
21
+ $this->w = $w;
22
+ $this->h = $h;
23
+ // Sanitize crop position
24
+ $allowed_crop_positions = array( 'default', 'center', 'top', 'bottom', 'left', 'right' );
25
+ if ( $crop !== false && !in_array( $crop, $allowed_crop_positions ) ) {
26
+ $crop = $allowed_crop_positions[0];
27
+ }
28
+ $this->crop = $crop;
29
+ }
30
+
31
+ /**
32
+ * @param string $src_filename the basename of the file (ex: my-awesome-pic)
33
+ * @param string $src_extension the extension (ex: .jpg)
34
+ * @return string the final filename to be used (ex: my-awesome-pic-300x200-c-default.jpg)
35
+ */
36
+ public function filename($src_filename, $src_extension) {
37
+ $result = $src_filename . '-' . $this->w . 'x' . $this->h . '-c-' . ( $this->crop ? $this->crop : 'f' ); // Crop will be either user named or f (false)
38
+ if($src_extension) {
39
+ $result .= '.'.$src_extension;
40
+ }
41
+ return $result;
42
+ }
43
+
44
+ /**
45
+ * Performs the actual image manipulation,
46
+ * including saving the target file.
47
+ *
48
+ * @param string $load_filename filepath (not URL) to source file
49
+ * (ex: /src/var/www/wp-content/uploads/my-pic.jpg)
50
+ * @param string $save_filename filepath (not URL) where result file should be saved
51
+ * (ex: /src/var/www/wp-content/uploads/my-pic-300x200-c-default.jpg)
52
+ * @return bool true if everything went fine, false otherwise
53
+ */
54
+ public function run($load_filename, $save_filename) {
55
+ $image = wp_get_image_editor( $load_filename );
56
+ if ( !is_wp_error( $image ) ) {
57
+ $w = $this->w;
58
+ $h = $this->h;
59
+ $crop = $this->crop;
60
+
61
+ $current_size = $image->get_size();
62
+ $src_w = $current_size['width'];
63
+ $src_h = $current_size['height'];
64
+ $src_ratio = $src_w / $src_h;
65
+ if ( !$h ) {
66
+ $h = round( $w / $src_ratio );
67
+ }
68
+ if ( !$w ) {
69
+ //the user wants to resize based on constant height
70
+ $w = round( $h * $src_ratio );
71
+ }
72
+ // Get ratios
73
+ $dest_ratio = $w / $h;
74
+ $src_wt = $src_h * $dest_ratio;
75
+ $src_ht = $src_w / $dest_ratio;
76
+ if ( !$crop ) {
77
+ // Always crop, to allow resizing upwards
78
+ $image->crop( 0, 0, $src_w, $src_h, $w, $h );
79
+ } else {
80
+ //start with defaults:
81
+ $src_x = $src_w / 2 - $src_wt / 2;
82
+ $src_y = ( $src_h - $src_ht ) / 6;
83
+ //now specific overrides based on options:
84
+ if ( $crop == 'center' ) {
85
+ // Get source x and y
86
+ $src_x = round( ( $src_w - $src_wt ) / 2 );
87
+ $src_y = round( ( $src_h - $src_ht ) / 2 );
88
+ } else if ( $crop == 'top' ) {
89
+ $src_y = 0;
90
+ } else if ( $crop == 'bottom' ) {
91
+ $src_y = $src_h - $src_ht;
92
+ } else if ( $crop == 'left' ) {
93
+ $src_x = 0;
94
+ } else if ( $crop == 'right' ) {
95
+ $src_x = $src_w - $src_wt;
96
+ }
97
+ // Crop the image
98
+ if ( $dest_ratio > $src_ratio ) {
99
+ $image->crop( 0, $src_y, $src_w, $src_ht, $w, $h );
100
+ } else {
101
+ $image->crop( $src_x, 0, $src_wt, $src_h, $w, $h );
102
+ }
103
+ }
104
+ $result = $image->save( $save_filename );
105
+ if ( is_wp_error( $result ) ) {
106
+ error_log( 'Error resizing image' );
107
+ error_log( print_r( $result, true ) );
108
+ return false;
109
+ } else {
110
+ return true;
111
+ }
112
+ } else if ( isset( $image->error_data['error_loading_image'] ) ) {
113
+ TimberHelper::error_log( 'Error loading ' . $image->error_data['error_loading_image'] );
114
+ } else {
115
+ TimberHelper::error_log( $image );
116
+ }
117
+ return false;
118
+ }
119
+ }
lib/image/timber-image-operation-retina.php ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Increases image size by a given factor
5
+ * Arguments:
6
+ * - factor by which to multiply image dimensions
7
+ */
8
+ class TimberImageOperationRetina extends TimberImageOperation {
9
+
10
+ private $factor;
11
+
12
+ /**
13
+ * @param int $factor to multiply original dimensions by
14
+ */
15
+ function __construct($factor) {
16
+ $this->factor = $factor;
17
+ }
18
+
19
+ /**
20
+ * @param string $src_filename the basename of the file (ex: my-awesome-pic)
21
+ * @param string $src_extension the extension (ex: .jpg)
22
+ * @return string the final filename to be used (ex: my-awesome-pic@2x.jpg)
23
+ */
24
+ function filename($src_filename, $src_extension) {
25
+ $newbase = $src_filename . '@' . $this->factor . 'x'; // add @2x, @3x, @1.5x, etc.
26
+ $new_name = $newbase . '.' . $src_extension;
27
+ return $new_name;
28
+ }
29
+
30
+ /**
31
+ * Performs the actual image manipulation,
32
+ * including saving the target file.
33
+ *
34
+ * @param string $load_filename filepath (not URL) to source file
35
+ * (ex: /src/var/www/wp-content/uploads/my-pic.jpg)
36
+ * @param string $save_filename filepath (not URL) where result file should be saved
37
+ * (ex: /src/var/www/wp-content/uploads/my-pic@2x.jpg)
38
+ * @return bool true if everything went fine, false otherwise
39
+ */
40
+ function run($load_filename, $save_filename){
41
+ $image = wp_get_image_editor( $load_filename );
42
+ if ( !is_wp_error( $image ) ) {
43
+ $current_size = $image->get_size();
44
+ $src_w = $current_size['width'];
45
+ $src_h = $current_size['height'];
46
+ $src_ratio = $src_w / $src_h;
47
+ // Get ratios
48
+ $w = $src_w * $this->factor;
49
+ $h = $src_h * $this->factor;
50
+ $image->crop( 0, 0, $src_w, $src_h, $w, $h );
51
+ $result = $image->save( $save_filename );
52
+ if ( is_wp_error( $result ) ) {
53
+ error_log( 'Error resizing image' );
54
+ error_log( print_r( $result, true ) );
55
+ return false;
56
+ } else {
57
+ return true;
58
+ }
59
+ } else if ( isset( $image->error_data['error_loading_image'] ) ) {
60
+ TimberHelper::error_log( 'Error loading ' . $image->error_data['error_loading_image'] );
61
+ } else {
62
+ TimberHelper::error_log( $image );
63
+ }
64
+ return false;
65
+ }
66
+ }
lib/image/timber-image-operation.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Each image filter is represented by a subclass of this class,m
4
+ * and each filter call is a new instance, with call arguments as properties.
5
+ *
6
+ * Only 3 methods need to be implemented:
7
+ * - constructor, storing all filter arguments
8
+ * - filename
9
+ * - run
10
+ */
11
+ abstract class TimberImageOperation {
12
+ /**
13
+ * Builds the result filename, based on source filename and extension
14
+ *
15
+ * @param string $src_filename source filename (excluding extension and path)
16
+ * @param string $src_extension source file extension
17
+ * @return string resulting filename (including extension but excluding path)
18
+ * ex: my-awesome-file.jpg
19
+ */
20
+ public abstract function filename($src_filename, $src_extension);
21
+
22
+ /**
23
+ * Performs the actual image manipulation,
24
+ * including saving the target file.
25
+ *
26
+ * @param string $load_filename filepath (not URL) to source file
27
+ * @param string $save_filename filepath (not URL) where result file should be saved
28
+ * @return bool true if everything went fine, false otherwise
29
+ */
30
+ public abstract function run($load_filename, $save_filename);
31
+
32
+ /**
33
+ * Helper method to convert hex string to rgb array
34
+ *
35
+ * @param string $hexstr hex color string (like '#FF1455')
36
+ * @return array array('red', 'green', 'blue') to int
37
+ * ex: array('red' => 255, 'green' => 20, 'blue' => 85);
38
+ */
39
+ public static function hexrgb( $hexstr ) {
40
+ if ( !strstr( $hexstr, '#' ) ) {
41
+ $hexstr = '#' . $hexstr;
42
+ }
43
+ if ( strlen( $hexstr ) == 4 ) {
44
+ $hexstr = '#' . $hexstr[1] . $hexstr[1] . $hexstr[2] . $hexstr[2] . $hexstr[3] . $hexstr[3];
45
+ }
46
+ $int = hexdec( $hexstr );
47
+ return array( "red" => 0xFF & ( $int >> 0x10 ), "green" => 0xFF & ( $int >> 0x8 ), "blue" => 0xFF & $int );
48
+ }
49
+ }
{functions → lib}/integrations/acf-timber.php RENAMED
File without changes
{functions → lib}/integrations/wpcli-timber.php RENAMED
File without changes
{functions → lib}/timber-admin.php RENAMED
File without changes
{functions → lib}/timber-archives.php RENAMED
@@ -78,7 +78,7 @@ class TimberArchives extends TimberCore
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
78
  );
79
  $r = wp_parse_args($args, $defaults);
80
 
81
+ $show_year = $r['show_year'];
82
  extract($r, EXTR_SKIP);
83
 
84
  //will need to specify which year we're looking for
{functions → lib}/timber-comment.php RENAMED
@@ -98,6 +98,13 @@ class TimberComment extends TimberCore implements TimberCoreInterface {
98
  return $this->comment_content;
99
  }
100
 
 
 
 
 
 
 
 
101
  /**
102
  * @return string
103
  */
98
  return $this->comment_content;
99
  }
100
 
101
+ /**
102
+ * @return string
103
+ */
104
+ public function status() {
105
+ return $this->comment_status;
106
+ }
107
+
108
  /**
109
  * @return string
110
  */
{functions → lib}/timber-core-interface.php RENAMED
File without changes
{functions → lib}/timber-core.php RENAMED
File without changes
{functions → lib}/timber-function-wrapper.php RENAMED
File without changes
{functions → lib}/timber-helper.php RENAMED
File without changes
lib/timber-image-helper.php ADDED
@@ -0,0 +1,473 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Implements the Twig image filters:
5
+ * https://github.com/jarednova/timber/wiki/Image-cookbook#arbitrary-resizing-of-images
6
+ * - resize
7
+ * - retina
8
+ * - letterbox
9
+ * - tojpg
10
+ *
11
+ * Implementation:
12
+ * - public static functions provide the methods that are called by the filter
13
+ * - most of the work is common to all filters (URL analysis, directory gymnastics, file caching, error management) and done by private static functions
14
+ * - the specific part (actual image processing) is delegated to dedicated subclasses of TimberImageOperation
15
+ */
16
+ class TimberImageHelper {
17
+
18
+ const BASE_UPLOADS = 1;
19
+ const BASE_CONTENT = 2;
20
+
21
+ /**
22
+ * Generates a new image with the specified dimensions.
23
+ * New dimensions are achieved by cropping to maintain ratio.
24
+ *
25
+ * @param string $src an URL (absolute or relative) to the original image
26
+ * @param int $w target width
27
+ * @param int $h target heighth
28
+ * @param string $crop
29
+ * @param bool $force_resize
30
+ * @return string (ex: )
31
+ */
32
+ public static function resize( $src, $w, $h = 0, $crop = 'default', $force = false ) {
33
+ $op = new TimberImageOperationResize($w, $h, $crop);
34
+ return self::_operate($src, $op, $force);
35
+ }
36
+
37
+ /**
38
+ * Generates a new image with increased size, for display on Retina screens.
39
+ *
40
+ * @param string $src
41
+ * @param float $multiplier
42
+ * @param boolean $force
43
+ *
44
+ * @return string url to the new image
45
+ */
46
+ public static function retina_resize( $src, $factor = 2, $force = false) {
47
+ $op = new TimberImageOperationRetina($factor);
48
+ return self::_operate($src, $op, $force);
49
+ }
50
+
51
+ /**
52
+ * Generate a new image with the specified dimensions.
53
+ * New dimensions are achieved by adding colored bands to maintain ratio.
54
+ *
55
+ * @param string $src
56
+ * @param int $w
57
+ * @param int $h
58
+ * @param string $color
59
+ * @param bool $force
60
+ * @return mixed|null|string
61
+ */
62
+ public static function letterbox( $src, $w, $h, $color = '#000000', $force = false ) {
63
+ $op = new TimberImageOperationLetterbox($w, $h, $color);
64
+ return self::_operate($src, $op, $force);
65
+ }
66
+
67
+ /**
68
+ * Generates a new image by converting the source PNG into JPG
69
+ *
70
+ * @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)
71
+ * @param string $bghex
72
+ * @return string
73
+ */
74
+ public static function img_to_jpg( $src, $bghex = '#FFFFFF', $force = false ) {
75
+ $op = new TimberImageOperationPngToJpg($bghex);
76
+ return self::_operate($src, $op, $force);
77
+ }
78
+
79
+ /**
80
+ * Deletes all resized versions of an image when the source is deleted
81
+ */
82
+ static function add_actions() {
83
+ add_action( 'delete_post', function ( $post_id ) {
84
+ $post = get_post( $post_id );
85
+ $image_types = array( 'image/jpeg', 'image/png', 'image/gif', 'image/jpg' );
86
+ if ( $post->post_type == 'attachment' && in_array( $post->post_mime_type, $image_types ) ) {
87
+ TimberImageHelper::delete_resized_files_from_url( $post->guid );
88
+ TimberImageHelper::delete_letterboxed_files_from_url( $post->guid );
89
+ }
90
+ } );
91
+ }
92
+
93
+ /**
94
+ * Adds a constant defining the path to the content directory relative to the site
95
+ * for example /wp-content or /content
96
+ */
97
+ static function add_constants() {
98
+ if ( !defined( 'WP_CONTENT_SUBDIR' ) ) {
99
+ $wp_content_path = str_replace( home_url(), '', WP_CONTENT_URL );
100
+ define( 'WP_CONTENT_SUBDIR', $wp_content_path );
101
+ }
102
+ }
103
+
104
+
105
+ /**
106
+ * load the dependencies of TimberImageOperations
107
+ * @return void
108
+ */
109
+ static function load_dependencies() {
110
+ require_once('image/timber-image-operation.php');
111
+ require_once('image/timber-image-operation-pngtojpg.php');
112
+ require_once('image/timber-image-operation-retina.php');
113
+ require_once('image/timber-image-operation-letterbox.php');
114
+ require_once('image/timber-image-operation-resize.php');
115
+ }
116
+
117
+ /**
118
+ * adds a 'relative' key to wp_upload_dir() result.
119
+ * It will contain the relative url to upload dir.
120
+ * @return void
121
+ */
122
+ static function add_filters() {
123
+ add_filter( 'upload_dir', function ( $arr ) {
124
+ $arr['relative'] = str_replace( home_url(), '', $arr['baseurl'] );
125
+ return $arr;
126
+ } );
127
+ }
128
+
129
+ //-- end of public methots --//
130
+
131
+
132
+
133
+
134
+ /**
135
+ * @return boolean true if $path is an external url, false if relative or local.
136
+ */
137
+ protected static function is_external($path) {
138
+ return TimberURLHelper::is_absolute($path) && !strstr($path, home_url());
139
+ }
140
+
141
+ /**
142
+ * Deletes resized versions of the supplied file name
143
+ *
144
+ * @param string $local_file
145
+ */
146
+ static function delete_resized_files( $local_file ) {
147
+ $info = pathinfo( $local_file );
148
+ $dir = $info['dirname'];
149
+ $ext = $info['extension'];
150
+ $filename = $info['filename'];
151
+ $searcher = '/' . $filename . '-[0-9999999]*';
152
+ foreach ( glob( $dir . $searcher ) as $found_file ) {
153
+ $regexdir = str_replace( '/', '\/', $dir );
154
+ $pattern = '/' . ( $regexdir ) . '\/' . $filename . '-[0-9]*x[0-9]*-c-[a-z]*.' . $ext . '/';
155
+ $match = preg_match( $pattern, $found_file );
156
+ //keeping these here so I know what the hell we're matching
157
+ //$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);
158
+ //$match = preg_match("/\/srv\/www\/wordpress-develop\/src\/wp-content\/uploads\/2014\/05\/arch-[0-9]*x[0-9]*-c-[a-z]*.jpg/", $filename);
159
+ if ( $match ) {
160
+ unlink( $found_file );
161
+ }
162
+ }
163
+ }
164
+
165
+ /**
166
+ * Deletes letterboxed versions of the supplied file name
167
+ *
168
+ * @param string $local_file
169
+ */
170
+ static function delete_letterboxed_files( $local_file ) {
171
+ $info = pathinfo( $local_file );
172
+ $dir = $info['dirname'];
173
+ $ext = $info['extension'];
174
+ $filename = $info['filename'];
175
+ $searcher = '/' . $filename . '-lbox-[0-9999999]*';
176
+ foreach ( glob( $dir . $searcher ) as $found_file ) {
177
+ $regexdir = str_replace( '/', '\/', $dir );
178
+ $pattern = '/' . ( $regexdir ) . '\/' . $filename . '-lbox-[0-9]*x[0-9]*-[a-zA-Z0-9]*.' . $ext . '/';
179
+ $match = preg_match( $pattern, $found_file );
180
+ if ( $match ) {
181
+ unlink( $found_file );
182
+ }
183
+ }
184
+ }
185
+
186
+
187
+ /**
188
+ * Determines the filepath corresponding to a given URL
189
+ *
190
+ * @param string $url
191
+ * @return string
192
+ */
193
+ public static function get_server_location( $url ) {
194
+ // if we're already an absolute dir, just return
195
+ if ( 0 === strpos( $url, ABSPATH ) ) {
196
+ return $url;
197
+ }
198
+ // otherwise, analyze URL then build mapping path
199
+ $au = self::analyze_url($url);
200
+ $result = self::_get_file_path($au['base'], $au['subdir'], $au['basename']);
201
+ return $result;
202
+ }
203
+
204
+ /**
205
+ * Determines the filepath where a given external file will be stored.
206
+ *
207
+ * @param string $file
208
+ * @return string
209
+ */
210
+ public static function get_sideloaded_file_loc( $file ) {
211
+ $upload = wp_upload_dir();
212
+ $dir = $upload['path'];
213
+ $filename = $file;
214
+ $file = parse_url( $file );
215
+ $path_parts = pathinfo( $file['path'] );
216
+ $basename = md5( $filename );
217
+ $ext = 'jpg';
218
+ if ( isset( $path_parts['extension'] ) ) {
219
+ $ext = $path_parts['extension'];
220
+ }
221
+ return $dir . '/' . $basename . '.' . $ext;
222
+ }
223
+
224
+ /**
225
+ * downloads an external image to the server and stores it on the server
226
+ *
227
+ * @param string $file the URL to the original file
228
+ * @return string the URL to the downloaded file
229
+ */
230
+ public static function sideload_image( $file ) {
231
+ $loc = self::get_sideloaded_file_loc( $file );
232
+ if ( file_exists( $loc ) ) {
233
+ return TimberURLHelper::preslashit( TimberURLHelper::get_rel_path( $loc ) );
234
+ }
235
+ // Download file to temp location
236
+ if ( !function_exists( 'download_url' ) ) {
237
+ require_once ABSPATH . '/wp-admin/includes/file.php';
238
+ }
239
+ $tmp = download_url( $file );
240
+ preg_match( '/[^\?]+\.(jpe?g|jpe|gif|png)\b/i', $file, $matches );
241
+ $file_array = array();
242
+ $file_array['name'] = basename( $matches[0] );
243
+ $file_array['tmp_name'] = $tmp;
244
+ // If error storing temporarily, unlink
245
+ if ( is_wp_error( $tmp ) ) {
246
+ @unlink( $file_array['tmp_name'] );
247
+ $file_array['tmp_name'] = '';
248
+ }
249
+ // do the validation and storage stuff
250
+ $locinfo = pathinfo( $loc );
251
+ $file = wp_upload_bits( $locinfo['basename'], null, file_get_contents( $file_array['tmp_name'] ) );
252
+ return $file['url'];
253
+ }
254
+
255
+ /**
256
+ * Takes in an URL and breaks it into components,
257
+ * that will then be used in the different steps of image processing.
258
+ * The image is expected to be either part of a theme, plugin, or an upload.
259
+ *
260
+ * @param string $url an URL (absolute or relative) pointing to an image
261
+ * @return array an array (see keys in code below)
262
+ */
263
+ private static function analyze_url($url) {
264
+ $result = array(
265
+ 'url' => $url, // the initial url
266
+ 'absolute' => TimberURLHelper::is_absolute($url), // is the url absolute or relative (to home_url)
267
+ 'base' => 0, // is the image in uploads dir, or in content dir (theme or plugin)
268
+ 'subdir' => '', // the path between base (uploads or content) and file
269
+ 'filename' => '', // the filename, without extension
270
+ 'extension' => '', // the file extension
271
+ 'basename' => '', // full file name
272
+ );
273
+ $upload_dir = wp_upload_dir();
274
+ $tmp = $url;
275
+ if ( 0 === strpos($tmp, ABSPATH) ) { // we've been given a dir, not an url
276
+ $result['absolute'] = true;
277
+ if ( 0 === strpos($tmp, $upload_dir['basedir']) ) {
278
+ $result['base']= self::BASE_UPLOADS; // upload based
279
+ $tmp = str_replace($upload_dir['basedir'], '', $tmp);
280
+ }
281
+ if ( 0 === strpos($tmp, WP_CONTENT_DIR) ) {
282
+ $result['base']= self::BASE_CONTENT; // content based
283
+ $tmp = str_replace(WP_CONTENT_DIR, '', $tmp);
284
+ }
285
+ } else {
286
+ if (!$result['absolute']) {
287
+ $tmp = home_url().$tmp;
288
+ }
289
+ if (0 === strpos($tmp, $upload_dir['baseurl'])) {
290
+ $result['base']= self::BASE_UPLOADS; // upload based
291
+ $tmp = str_replace($upload_dir['baseurl'], '', $tmp);
292
+ }
293
+ if (0 === strpos($tmp, content_url())) {
294
+ $result['base']= self::BASE_CONTENT; // content-based
295
+ $tmp = str_replace(content_url(), '', $tmp);
296
+ }
297
+ }
298
+ $parts = pathinfo($tmp);
299
+ $result['subdir'] = $parts['dirname'];
300
+ $result['filename'] = $parts['filename'];
301
+ $result['extension'] = $parts['extension'];
302
+ $result['basename'] = $parts['basename'];
303
+ // todo filename
304
+ return $result;
305
+ }
306
+
307
+ /**
308
+ * Builds the public URL of a file based on its different components
309
+ *
310
+ * @param int $base one of self::BASE_UPLOADS, self::BASE_CONTENT to indicate if file is an upload or a content (theme or plugin)
311
+ * @param string $subdir subdirectory in which file is stored, relative to $base root folder
312
+ * @param string $filename file name, including extension (but no path)
313
+ * @param bool $absolute should the returned URL be absolute (include protocol+host), or relative
314
+ * @return string the URL
315
+ */
316
+ private static function _get_file_url($base, $subdir, $filename, $absolute) {
317
+ $url = '';
318
+ if( self::BASE_UPLOADS == $base ) {
319
+ $upload_dir = wp_upload_dir();
320
+ $url = $upload_dir['baseurl'];
321
+ }
322
+ if( self::BASE_CONTENT == $base ) {
323
+ $url = content_url();
324
+ }
325
+ if(!empty($subdir)) {
326
+ $url .= $subdir;
327
+ }
328
+ $url .= '/'.$filename;
329
+ if(!$absolute) {
330
+ $url = str_replace(home_url(), '', $url);
331
+ }
332
+ // $url = TimberURLHelper::remove_double_slashes( $url);
333
+ return $url;
334
+ }
335
+
336
+ /**
337
+ * Builds the absolute file system location of a file based on its different components
338
+ *
339
+ * @param int $base one of self::BASE_UPLOADS, self::BASE_CONTENT to indicate if file is an upload or a content (theme or plugin)
340
+ * @param string $subdir subdirectory in which file is stored, relative to $base root folder
341
+ * @param string $filename file name, including extension (but no path)
342
+ * @return string the file location
343
+ */
344
+ private static function _get_file_path($base, $subdir, $filename) {
345
+ $path = '';
346
+ if(self::BASE_UPLOADS == $base) {
347
+ $upload_dir = wp_upload_dir();
348
+ $path = $upload_dir['basedir'];
349
+ }
350
+ if(self::BASE_CONTENT == $base) {
351
+ $path = WP_CONTENT_DIR;
352
+ }
353
+ if(!empty($subdir)) {
354
+ $path .= $subdir;
355
+ }
356
+ $path .= '/'.$filename;
357
+ return $path;
358
+ }
359
+
360
+
361
+ /**
362
+ * Main method that applies operation to src image:
363
+ * 1. break down supplied URL into components
364
+ * 2. use components to determine result file and URL
365
+ * 3. check if a result file already exists
366
+ * 4. otherwise, delegate to supplied TimberImageOperation
367
+ *
368
+ * @param string $src an URL (absolute or relative) to an image
369
+ * @param object $op object of class TimberImageOperation
370
+ * @param boolean $force if true, remove any already existing result file and forces file generation
371
+ * @return string URL to the new image - or the source one if error
372
+ *
373
+ */
374
+ private static function _operate( $src, $op, $force = false ) {
375
+ if ( empty( $src ) ) {
376
+ return '';
377
+ }
378
+ // if external image, load it first
379
+ if ( self::is_external( $src ) ) {
380
+ $src = self::sideload_image( $src );
381
+ }
382
+ // break down URL into components
383
+ $au = self::analyze_url($src);
384
+ // build URL and filenames
385
+ $new_url = self::_get_file_url(
386
+ $au['base'],
387
+ $au['subdir'],
388
+ $op->filename($au['filename'], $au['extension']),
389
+ $au['absolute']
390
+ );
391
+ $new_server_path = self::_get_file_path(
392
+ $au['base'],
393
+ $au['subdir'],
394
+ $op->filename($au['filename'], $au['extension'])
395
+ );
396
+ $old_server_path = self::_get_file_path(
397
+ $au['base'],
398
+ $au['subdir'],
399
+ $au['basename']
400
+ );
401
+ // if already exists...
402
+ if ( file_exists( $new_server_path ) ) {
403
+ if ( $force ) {
404
+ // Force operation - warning: will regenerate the image on every pageload, use for testing purposes only!
405
+ unlink( $new_server_path );
406
+ } else {
407
+ // return existing file (caching)
408
+ return $new_url;
409
+ }
410
+ }
411
+ // otherwise generate result file
412
+ if($op->run($old_server_path, $new_server_path)) {
413
+ return $new_url;
414
+ } else {
415
+ // in case of error, we return source file itself
416
+ return $src;
417
+ }
418
+ }
419
+
420
+
421
+ // -- the below methods are just used for unit testing the URL generation code
422
+ //
423
+ static function get_letterbox_file_url($url, $w, $h, $color) {
424
+ $au = self::analyze_url($url);
425
+ $op = new TimberImageOperationLetterbox($w, $h, $color);
426
+ $new_url = self::_get_file_url(
427
+ $au['base'],
428
+ $au['subdir'],
429
+ $op->filename($au['filename'], $au['extension']),
430
+ $au['absolute']
431
+ );
432
+ return $new_url;
433
+ }
434
+ public static function get_letterbox_file_path($url, $w, $h, $color ) {
435
+ $au = self::analyze_url($url);
436
+ $op = new TimberImageOperationLetterbox($w, $h, $color);
437
+ $new_path = self::_get_file_path(
438
+ $au['base'],
439
+ $au['subdir'],
440
+ $op->filename($au['filename'], $au['extension'])
441
+ );
442
+ return $new_path;
443
+ }
444
+ static function get_resize_file_url($url, $w, $h, $crop) {
445
+ $au = self::analyze_url($url);
446
+ $op = new TimberImageOperationResize($w, $h, $crop);
447
+ $new_url = self::_get_file_url(
448
+ $au['base'],
449
+ $au['subdir'],
450
+ $op->filename($au['filename'], $au['extension']),
451
+ $au['absolute']
452
+ );
453
+ return $new_url;
454
+ }
455
+ static function get_resize_file_path($url, $w, $h, $crop) {
456
+ $au = self::analyze_url($url);
457
+ $op = new TimberImageOperationResize($w, $h, $crop);
458
+ $new_path = self::_get_file_path(
459
+ $au['base'],
460
+ $au['subdir'],
461
+ $op->filename($au['filename'], $au['extension'])
462
+ );
463
+ return $new_path;
464
+ }
465
+
466
+
467
+ }
468
+
469
+
470
+ TimberImageHelper::load_dependencies();
471
+ TimberImageHelper::add_constants();
472
+ TimberImageHelper::add_actions();
473
+ TimberImageHelper::add_filters();
{functions → lib}/timber-image.php RENAMED
File without changes
{functions → lib}/timber-loader.php RENAMED
@@ -29,6 +29,7 @@ class TimberLoader {
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
  /**
@@ -64,14 +65,15 @@ class TimberLoader {
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
  /**
@@ -197,6 +199,7 @@ class TimberLoader {
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
 
@@ -219,6 +222,7 @@ class TimberLoader {
219
  } else {
220
  $paths[] = ABSPATH;
221
  }
 
222
  $loader = new Twig_Loader_Filesystem($paths);
223
  return $loader;
224
  }
@@ -236,7 +240,7 @@ class TimberLoader {
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
  }
@@ -249,6 +253,7 @@ class TimberLoader {
249
  $twig->addExtension($this->_get_cache_extension());
250
 
251
  $twig = apply_filters('twig_apply_filters', $twig);
 
252
  return $twig;
253
  }
254
 
@@ -315,7 +320,7 @@ class TimberLoader {
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
 
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
+ $this->cache_mode = apply_filters('timber/cache/mode', $this->cache_mode);
33
  }
34
 
35
  /**
65
  do_action('timber_loader_render_file', $result);
66
  }
67
  $data = apply_filters('timber_loader_render_data', $data);
68
+ $data = apply_filters('timber/loader/render_data', $data);
69
  $output = $twig->render($file, $data);
70
  }
71
 
72
  if (false !== $output && false !== $expires && null !== $key) {
73
  $this->set_cache($key, $output, self::CACHEGROUP, $expires, $cache_mode);
74
  }
75
+ $output = apply_filters('timber_output', $output);
76
+ return apply_filters('timber/output', $output);
77
  }
78
 
79
  /**
199
  $locs = array_merge($locs, $this->get_locations_caller($caller));
200
  $locs = array_unique($locs);
201
  $locs = apply_filters('timber_locations', $locs);
202
+ $locs = apply_filters('timber/locations', $locs);
203
  return $locs;
204
  }
205
 
222
  } else {
223
  $paths[] = ABSPATH;
224
  }
225
+ $paths = apply_filters('timber/loader/paths', $paths);
226
  $loader = new Twig_Loader_Filesystem($paths);
227
  return $loader;
228
  }
240
  Timber::$twig_cache = true;
241
  }
242
  if (Timber::$twig_cache) {
243
+ $twig_cache_loc = apply_filters( 'timber/cache/location', TIMBER_LOC . '/cache/twig' );
244
  if (!file_exists($twig_cache_loc)) {
245
  mkdir($twig_cache_loc, 0777, true);
246
  }
253
  $twig->addExtension($this->_get_cache_extension());
254
 
255
  $twig = apply_filters('twig_apply_filters', $twig);
256
+ $twig = apply_filters('timber/loader/twig', $twig);
257
  return $twig;
258
  }
259
 
320
  * @return \Asm89\Twig\CacheExtension\Extension
321
  */
322
  private function _get_cache_extension() {
323
+ $loader_loc = trailingslashit(TIMBER_LOC) . 'lib/cache/loader.php';
324
  require_once($loader_loc);
325
  TimberCache_Loader::register();
326
 
{functions → lib}/timber-menu-item.php RENAMED
File without changes
{functions → lib}/timber-menu.php RENAMED
File without changes
{functions → lib}/timber-page.php RENAMED
File without changes
{functions → lib}/timber-post-getter.php RENAMED
File without changes
{functions → lib}/timber-post.php RENAMED
File without changes
{functions → lib}/timber-posts-collection.php RENAMED
@@ -6,16 +6,16 @@ if ( !defined( 'ABSPATH' ) )
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] ) ) {
@@ -23,28 +23,28 @@ class TimberPostsCollection extends ArrayObject {
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() {
6
 
7
  class TimberPostsCollection extends ArrayObject {
8
 
9
+ public function __construct( $posts = array(), $post_class = 'TimberPost' ) {
10
+ $returned_posts = array();
11
+ if ( is_null( $posts ) ){
12
+ $posts = array();
13
  }
14
+ foreach ( $posts as $post_object ) {
15
  $post_class_use = $post_class;
16
 
17
  if ( is_array( $post_class ) ) {
18
+ $post_type = get_post_type( $post_object );
19
  $post_class_use = 'TimberPost';
20
 
21
  if ( isset( $post_class[$post_type] ) ) {
23
 
24
  } else {
25
  if ( is_array( $post_class ) ) {
26
+ TimberHelper::error_log( $post_type . ' of ' . $post_object->ID . ' 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 $post_object is already of the right type
34
+ if ( is_a( $post_object, $post_class_use ) ) {
35
+ $post = $post_object;
36
  } else {
37
+ $post = new $post_class_use( $post_object );
38
  }
39
 
40
  if ( isset( $post->ID ) ) {
41
+ $returned_posts[] = $post;
42
  }
43
  }
44
 
45
+ $returned_posts = self::maybe_set_preview($returned_posts);
46
 
47
+ parent::__construct( $returned_posts, $flags = 0, 'TimberPostsIterator' );
48
  }
49
 
50
  public function get_posts() {
{functions → lib}/timber-query-iterator.php RENAMED
File without changes
{functions → lib}/timber-routes.php RENAMED
@@ -27,23 +27,19 @@ class TimberRoutes {
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
  /**
27
  public static function add_route($route, $callback, $args = array()) {
28
  global $timber;
29
  if (!isset($timber->router)) {
30
+ $timber->router = new PHPRouter\Router();
31
+ $site_url = get_bloginfo('url');
32
+ $site_url_parts = explode('/', $site_url);
33
+ $site_url_parts = array_slice($site_url_parts, 3);
34
+ $base_path = implode('/', $site_url_parts);
35
+ if (!$base_path || strpos($route, $base_path) === 0) {
36
+ $base_path = '/';
37
+ } else {
38
+ $base_path = '/' . $base_path . '/';
 
 
 
39
  }
40
+ $timber->router->setBasePath($base_path);
41
  }
42
+ $timber->router->map($route, $callback, $args);
 
 
43
  }
44
 
45
  /**
{functions → lib}/timber-site.php RENAMED
File without changes
{functions → lib}/timber-term-getter.php RENAMED
File without changes
{functions → lib}/timber-term.php RENAMED
File without changes
{functions → lib}/timber-theme.php RENAMED
File without changes
{functions → lib}/timber-twig.php RENAMED
File without changes
{functions → lib}/timber-url-helper.php RENAMED
@@ -165,9 +165,17 @@ class TimberURLHelper {
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');
165
  return $path;
166
  }
167
 
168
+ /**
169
+ * @return boolean true if $path is an absolute url, false if relative.
170
+ */
171
+ public static function is_absolute($path) {
172
+ return (boolean) (strstr($path, 'http' ));
173
+ }
174
+
175
  /**
176
  * @param string $url
177
+ * @return bool true if $path is an external url, false if relative or local.
178
+ * true if it's a subdomain (http://cdn.example.org = true)
179
  */
180
  public static function is_external($url) {
181
  $has_http = strstr(strtolower($url), 'http');
{functions → lib}/timber-user.php RENAMED
File without changes
readme.txt CHANGED
@@ -2,7 +2,7 @@
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
@@ -41,6 +41,19 @@ Timber is great for any WordPress developer who cares about writing good, mainta
41
 
42
  == Changelog ==
43
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
  = 0.20.8 =
45
  * Fixed some Twig deprecation (thanks @alexlrobertson)
46
  * Support for {{img.src|retina}} filter (@jarednova)
2
  Contributors: jarednova
3
  Tags: template engine, templates, twig
4
  Requires at least: 3.7
5
+ Stable tag: 0.20.10
6
  Tested up to: 4.1
7
  PHP version: 5.3.0 or greater
8
  License: GPLv2 or later
41
 
42
  == Changelog ==
43
 
44
+ = 0.20.10 =
45
+ * Resolved lingering composer issues (thanks @austinpray, @lucasmichot)
46
+ * You can now access `{{comment.status}}` when working with comments (thanks @simonmilz)
47
+ * Better support for alternate setups with uploads directory (thanks @xavierpriour)
48
+ * Major clean-up of image-handling classes (thanks @xavierpriour)
49
+ * Starter theme now follows WP coding standards (thanks @kuus)
50
+ * A slew of other bugs and clean-up (thanks @JeyKeu, @quinn and @jaredNova)
51
+
52
+ = 0.20.9 =
53
+ * Twig goes from 1.6.2 to 1.6.3 (thanks @fabpot)
54
+ * Some clean-up items on Menus (thanks @oskarrough)
55
+ * Simplified composer installation (thanks @lucasmichot)
56
+
57
  = 0.20.8 =
58
  * Fixed some Twig deprecation (thanks @alexlrobertson)
59
  * Support for {{img.src|retina}} filter (@jarednova)
timber-starter-theme/404.php CHANGED
@@ -9,5 +9,5 @@
9
  * @since Timber 0.1
10
  */
11
 
12
- $context = Timber::get_context();
13
- Timber::render('404.twig', $context);
9
  * @since Timber 0.1
10
  */
11
 
12
+ $context = Timber::get_context();
13
+ Timber::render( '404.twig', $context );
timber-starter-theme/archive.php CHANGED
@@ -7,34 +7,34 @@
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);
7
  *
8
  * Learn more: http://codex.wordpress.org/Template_Hierarchy
9
  *
10
+ * Methods for TimberHelper can be found in the /lib 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/author.php CHANGED
@@ -2,7 +2,7 @@
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
@@ -12,9 +12,9 @@ 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);
2
  /**
3
  * The template for displaying Author Archive pages
4
  *
5
+ * Methods for TimberHelper can be found in the /lib sub-directory
6
  *
7
  * @package WordPress
8
  * @subpackage Timber
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/footer.php CHANGED
@@ -4,10 +4,10 @@
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);
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/functions.php CHANGED
@@ -1,54 +1,54 @@
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
- }
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="' . esc_url( admin_url( 'plugins.php#timber' ) ) . '">' . esc_url( 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/header.php CHANGED
@@ -4,4 +4,4 @@
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();
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/index.php CHANGED
@@ -6,24 +6,22 @@
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
-
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 /lib 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 );
 
 
timber-starter-theme/js/site.js CHANGED
@@ -1,4 +1,4 @@
1
- jQuery(document).ready(function($) {
2
 
3
  // Your JavaScript goes here
4
 
1
+ jQuery( document ).ready( function( $ ) {
2
 
3
  // Your JavaScript goes here
4
 
timber-starter-theme/page.php CHANGED
@@ -14,7 +14,7 @@
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
@@ -24,4 +24,4 @@
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);
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 /lib sub-directory
18
  *
19
  * @package WordPress
20
  * @subpackage Timber
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/search.php CHANGED
@@ -2,18 +2,17 @@
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);
2
  /**
3
  * Search results page
4
  *
5
+ * Methods for TimberHelper can be found in the /lib sub-directory
6
  *
7
+ * @package WordPress
8
+ * @subpackage Timber
9
+ * @since Timber 0.1
10
  */
11
 
12
+ $templates = array( 'search.twig', 'archive.twig', 'index.twig' );
13
+ $context = Timber::get_context();
14
 
15
+ $context['title'] = 'Search results for '. get_search_query();
16
+ $context['posts'] = Timber::get_posts();
17
 
18
+ Timber::render( $templates, $context );
 
 
 
timber-starter-theme/sidebar.php CHANGED
@@ -7,4 +7,4 @@
7
  * @subpackage Timber
8
  */
9
 
10
- Timber::render(array('sidebar.twig'), $data);
7
  * @subpackage Timber
8
  */
9
 
10
+ Timber::render( array( 'sidebar.twig' ), $data );
timber-starter-theme/single.php CHANGED
@@ -2,7 +2,7 @@
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
@@ -15,10 +15,8 @@ $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
-
2
  /**
3
  * The Template for displaying all single posts
4
  *
5
+ * Methods for TimberHelper can be found in the /lib sub-directory
6
  *
7
  * @package WordPress
8
  * @subpackage Timber
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
  }
 
 
timber-starter-theme/style.css CHANGED
@@ -1,4 +1,5 @@
1
- /* Theme Name: My Timber Starter Theme
2
- Description: Starter Theme to use with Timber
3
- Author: Upstatement and YOU!
 
4
  */
1
+ /*
2
+ * Theme Name: My Timber Starter Theme
3
+ * Description: Starter Theme to use with Timber
4
+ * Author: Upstatement and YOU!
5
  */
timber-starter-theme/views/author.twig CHANGED
@@ -1,8 +1,7 @@
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 %}
1
  {% extends "base.twig" %}
 
 
 
 
 
2
 
3
+ {% block content %}
4
+ {% for post in posts %}
5
+ {% include ["tease-"~post.post_type~".twig", "tease.twig"] %}
6
+ {% endfor %}
7
  {% endblock %}
timber-starter-theme/views/base.twig CHANGED
@@ -1,61 +1,59 @@
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="/" 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 %}
37
- </header>
38
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
 
40
- <section id="content" role="main" class="content-wrapper">
41
- {% if title %}<h1>{{title}}</h1>{% endif %}
42
- <div class="wrapper {{sidebar_class}}">
43
- {% block content %}
44
- Sorry, no content
45
- {% endblock %}
46
- </div>
47
- {% if sidebar %}
48
- <aside class="layout-sidebar">
49
- {{sidebar}}
50
- </aside>
51
- {% endif %}
52
- </section>
53
 
54
- {% block footer %}
55
- <footer id="footer">
56
- {% include 'footer.twig' %}
57
- </footer>
58
- {{ function('wp_footer') }}
59
- {% endblock %}
60
- </body>
61
- </html>
1
  {% block html_head_container %}
2
+
3
  {% include 'html-header.twig' %}
4
+ {% block head %}
5
+ {% endblock %}
6
+ </head>
7
  {% endblock %}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
 
9
+ <body class="{{body_class}}" data-template="base.twig">
10
+ <header class="header" >
11
+ {% block header %}
12
+ <div class="wrapper">
13
+ <h1 class="hdr-logo" role="banner">
14
+ <a class="hdr-logo-link" href="/" rel="home">{{site.name}}</a>
15
+ </h1>
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
+ </div>
35
+ {% endblock %}
36
+ </header>
37
 
38
+ <section id="content" role="main" class="content-wrapper">
39
+ {% if title %}<h1>{{title}}</h1>{% endif %}
40
+ <div class="wrapper {{sidebar_class}}">
41
+ {% block content %}
42
+ Sorry, no content
43
+ {% endblock %}
44
+ </div>
45
+ {% if sidebar %}
46
+ <aside class="layout-sidebar">
47
+ {{sidebar}}
48
+ </aside>
49
+ {% endif %}
50
+ </section>
51
 
52
+ {% block footer %}
53
+ <footer id="footer">
54
+ {% include 'footer.twig' %}
55
+ </footer>
56
+ {{ function('wp_footer') }}
57
+ {% endblock %}
58
+ </body>
59
+ </html>
timber-starter-theme/views/html-header.twig CHANGED
@@ -3,13 +3,19 @@
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')}}
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>
9
+ {% if wp_title %}
10
+ {{ wp_title }} - {{ site.name }}
11
+ {% else %}
12
+ {{ site.name }}
13
+ {% endif %}
14
+ </title>
15
  <meta name="description" content="{{site.description}}">
16
  <link rel="stylesheet" href="{{site.theme.link}}/style.css" type="text/css" media="screen" />
17
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
18
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
19
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
20
  <link rel="pingback" href="{{site.pingback_url}}" />
21
+ {{function('wp_head')}}
timber-starter-theme/views/index.twig CHANGED
@@ -6,5 +6,4 @@
6
  {% for post in posts %}
7
  {% include ['tease-'~post.post_type~'.twig', 'tease.twig'] %}
8
  {% endfor %}
9
-
10
  {% endblock %}
6
  {% for post in posts %}
7
  {% include ['tease-'~post.post_type~'.twig', 'tease.twig'] %}
8
  {% endfor %}
 
9
  {% endblock %}
timber-starter-theme/views/page-plugin.twig CHANGED
@@ -1,7 +1,7 @@
1
  {% extends "base.twig" %}
2
 
3
  {% block content %}
4
- <div class="container content-wrapper">
5
- {{content}}
6
- </div> <!-- /content-wrapper -->
7
  {% endblock %}
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/views/page.twig CHANGED
@@ -1,18 +1,14 @@
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 %}
1
  {% extends "base.twig" %}
2
 
3
  {% block content %}
 
4
  <div class="content-wrapper">
5
  <article class="post-type-{{post.post_type}}" id="post-{{post.ID}}">
6
  <section class="article-content">
7
  <h1 class="article-h1">{{post.title}}</h1>
 
8
  <div class="article-body">
9
  {{post.content}}
10
  </div>
11
  </section>
 
12
  </article>
13
+ </div><!-- /content-wrapper -->
 
14
  {% endblock %}
timber-starter-theme/views/single-password.twig CHANGED
@@ -1,8 +1,9 @@
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 %}
1
  {% extends "base.twig" %}
2
+
3
  {% block content %}
4
  <form class="password-form" action="/wp-login.php?action=postpass" method="post">
5
+ <label for="pwbox-{{post.ID}}">Password:</label>
6
+ <input class="password-box" name="post_password" id="pwbox-{{post.ID}}" type="password" placeholder="Password" size="20" maxlength="20" />
7
+ <input class="password-btn" type="submit" name="Submit" value="Submit" />
8
+ </form>
9
  {% endblock %}
timber-starter-theme/views/single.twig CHANGED
@@ -1,21 +1,17 @@
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>
@@ -26,10 +22,7 @@
26
  {% include "comment.twig" with {comment:cmt} %}
27
  {% endfor %}
28
  </div>
29
-
30
  </section>
31
-
32
  </article>
33
- </div> <!-- /content-wrapper -->
34
-
35
  {% endblock %}
1
  {% extends "base.twig" %}
2
 
3
  {% block content %}
 
4
  <div class="content-wrapper">
5
  <article class="post-type-{{post.post_type}}" id="post-{{post.ID}}">
6
  <section class="article-content">
7
  <h1 class="article-h1">{{post.title}}</h1>
 
8
  <p class="blog-author">
9
  <span>By</span><a href="{{post.author.path}}"> {{ post.author.name }} </a><span>&bull;</span> {{ post.post_date|date}}
10
  </p>
 
11
  <div class="article-body">
12
  {{post.content}}
13
  </div>
14
  </section>
 
15
  <section class="comments">
16
  <div class="respond">
17
  <h3 class="h2">Comments</h3>
22
  {% include "comment.twig" with {comment:cmt} %}
23
  {% endfor %}
24
  </div>
 
25
  </section>
 
26
  </article>
27
+ </div><!-- /content-wrapper -->
 
28
  {% endblock %}
timber-starter-theme/views/tease-post.twig CHANGED
@@ -1,8 +1,8 @@
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 %}
1
  {% extends "tease.twig" %}
2
+
3
  {% block content %}
4
  <h2 class="h2"><a href="{{post.link}}">{{post.title}}</a></h2>
5
  <p>{{post.get_preview(25)}}</p>
 
6
  {% if post.thumbnail.src %}
7
  <img src="{{post.thumbnail.src}}" />
8
  {% endif %}
timber-starter-theme/views/tease.twig CHANGED
@@ -2,7 +2,6 @@
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 %}
2
  {% block content %}
3
  <h2 class="h2"><a href="{{post.link}}">{{post.title}}</a></h2>
4
  <p>{{post.get_preview}}</p>
 
5
  {% if post.get_thumbnail %}
6
  <img src="{{post.thumbnail.src}}" />
7
  {% endif %}
timber.php CHANGED
@@ -4,48 +4,50 @@ 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.9
8
  Author URI: http://upstatement.com/
9
  */
10
 
11
  global $wp_version;
12
  global $timber;
13
 
14
- $composer_autoload = __DIR__ . '/vendor/autoload.php';
15
- if (file_exists($composer_autoload)){
16
- require_once($composer_autoload);
 
 
17
  }
18
 
19
- require_once(__DIR__ . '/functions/timber-twig.php');
20
- require_once(__DIR__ . '/functions/timber-helper.php');
21
- require_once(__DIR__ . '/functions/timber-url-helper.php');
22
- require_once(__DIR__ . '/functions/timber-image-helper.php');
23
-
24
- require_once(__DIR__ . '/functions/timber-core-interface.php');
25
- require_once(__DIR__ . '/functions/timber-core.php');
26
- require_once(__DIR__ . '/functions/timber-post.php');
27
- require_once(__DIR__ . '/functions/timber-post-getter.php');
28
- require_once(__DIR__ . '/functions/timber-comment.php');
29
- require_once(__DIR__ . '/functions/timber-user.php');
30
- require_once(__DIR__ . '/functions/timber-term.php');
31
- require_once(__DIR__ . '/functions/timber-term-getter.php');
32
- require_once(__DIR__ . '/functions/timber-image.php');
33
- require_once(__DIR__ . '/functions/timber-menu-item.php');
34
- require_once(__DIR__ . '/functions/timber-menu.php');
35
- require_once(__DIR__ . '/functions/timber-query-iterator.php');
36
- require_once(__DIR__ . '/functions/timber-posts-collection.php');
37
 
38
  //Other 2nd-class citizens
39
- require_once(__DIR__ . '/functions/timber-archives.php');
40
- require_once(__DIR__ . '/functions/timber-routes.php');
41
- require_once(__DIR__ . '/functions/timber-site.php');
42
- require_once(__DIR__ . '/functions/timber-theme.php');
43
- require_once(__DIR__ . '/functions/timber-loader.php');
44
- require_once(__DIR__ . '/functions/timber-function-wrapper.php');
45
- require_once(__DIR__ . '/functions/integrations/acf-timber.php');
46
- require_once(__DIR__ . '/functions/integrations/wpcli-timber.php');
47
-
48
- require_once(__DIR__ . '/functions/timber-admin.php');
49
 
50
  /** Usage:
51
  *
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.10
8
  Author URI: http://upstatement.com/
9
  */
10
 
11
  global $wp_version;
12
  global $timber;
13
 
14
+ // we look for Composer files first in the theme (theme install)
15
+ // then in the wp-content dir (site install)
16
+ if ( file_exists($composer_autoload = __DIR__ . '/vendor/autoload.php')
17
+ || file_exists($composer_autoload = WP_CONTENT_DIR.'/vendor/autoload.php')){
18
+ require_once($composer_autoload);
19
  }
20
 
21
+ require_once(__DIR__ . '/lib/timber-twig.php');
22
+ require_once(__DIR__ . '/lib/timber-helper.php');
23
+ require_once(__DIR__ . '/lib/timber-url-helper.php');
24
+ require_once(__DIR__ . '/lib/timber-image-helper.php');
25
+
26
+ require_once(__DIR__ . '/lib/timber-core-interface.php');
27
+ require_once(__DIR__ . '/lib/timber-core.php');
28
+ require_once(__DIR__ . '/lib/timber-post.php');
29
+ require_once(__DIR__ . '/lib/timber-post-getter.php');
30
+ require_once(__DIR__ . '/lib/timber-comment.php');
31
+ require_once(__DIR__ . '/lib/timber-user.php');
32
+ require_once(__DIR__ . '/lib/timber-term.php');
33
+ require_once(__DIR__ . '/lib/timber-term-getter.php');
34
+ require_once(__DIR__ . '/lib/timber-image.php');
35
+ require_once(__DIR__ . '/lib/timber-menu-item.php');
36
+ require_once(__DIR__ . '/lib/timber-menu.php');
37
+ require_once(__DIR__ . '/lib/timber-query-iterator.php');
38
+ require_once(__DIR__ . '/lib/timber-posts-collection.php');
39
 
40
  //Other 2nd-class citizens
41
+ require_once(__DIR__ . '/lib/timber-archives.php');
42
+ require_once(__DIR__ . '/lib/timber-routes.php');
43
+ require_once(__DIR__ . '/lib/timber-site.php');
44
+ require_once(__DIR__ . '/lib/timber-theme.php');
45
+ require_once(__DIR__ . '/lib/timber-loader.php');
46
+ require_once(__DIR__ . '/lib/timber-function-wrapper.php');
47
+ require_once(__DIR__ . '/lib/integrations/acf-timber.php');
48
+ require_once(__DIR__ . '/lib/integrations/wpcli-timber.php');
49
+
50
+ require_once(__DIR__ . '/lib/timber-admin.php');
51
 
52
  /** Usage:
53
  *
vendor/asm89/twig-cache-extension/README.md CHANGED
@@ -10,10 +10,10 @@ templates using several cache strategies.
10
 
11
  The extension is installable via composer:
12
 
13
- ```js
14
  {
15
  "require": {
16
- "asm89/twig-cache-extension": "*"
17
  }
18
  }
19
  ```
@@ -62,7 +62,15 @@ Cache blocks can be nested:
62
  {% endcache %}
63
  {% endfor %}
64
  {% endcache %}
 
 
 
65
 
 
 
 
 
 
66
  ```
67
 
68
  ## Cache strategies
@@ -72,7 +80,7 @@ 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
 
10
 
11
  The extension is installable via composer:
12
 
13
+ ```json
14
  {
15
  "require": {
16
+ "asm89/twig-cache-extension": "~0.1"
17
  }
18
  }
19
  ```
62
  {% endcache %}
63
  {% endfor %}
64
  {% endcache %}
65
+ ```
66
+
67
+ The annotation can also be an expression:
68
 
69
+ ```jinja
70
+ {% set version = 42 %}
71
+ {% cache 'hello_v' ~ version 900 %}
72
+ Hello {{ name }}!
73
+ {% endcache %}
74
  ```
75
 
76
  ## Cache strategies
80
 
81
  ### Lifetime
82
 
83
+ See the ["Quick start"](#quick-start) for usage information of the `LifetimeCacheStrategy`.
84
 
85
  ### Generational
86
 
vendor/asm89/twig-cache-extension/composer.json CHANGED
@@ -23,7 +23,7 @@
23
  },
24
  "extra": {
25
  "branch-alias": {
26
- "dev-master": "0.1-dev"
27
  }
28
  }
29
  }
23
  },
24
  "extra": {
25
  "branch-alias": {
26
+ "dev-master": "1.0-dev"
27
  }
28
  }
29
  }
vendor/asm89/twig-cache-extension/lib/Asm89/Twig/CacheExtension/Node/CacheNode.php CHANGED
@@ -21,15 +21,15 @@ class CacheNode extends \Twig_Node
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
  /**
@@ -42,7 +42,9 @@ class CacheNode extends \Twig_Node
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")
21
  private static $cacheCount = 1;
22
 
23
  /**
24
+ * @param \Twig_Node_Expression $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(\Twig_Node_Expression $annotation, \Twig_Node_Expression $keyInfo, \Twig_NodeInterface $body, $lineno, $tag = null)
31
  {
32
+ parent::__construct(array('key_info' => $keyInfo, 'body' => $body, 'annotation' => $annotation), array(), $lineno, $tag);
33
  }
34
 
35
  /**
42
  $compiler
43
  ->addDebugInfo($this)
44
  ->write("\$asm89CacheStrategy".$i." = \$this->getEnvironment()->getExtension('asm89_cache')->getCacheStrategy();\n")
45
+ ->write("\$asm89Key".$i." = \$asm89CacheStrategy".$i."->generateKey(")
46
+ ->subcompile($this->getNode('annotation'))
47
+ ->raw(", ")
48
  ->subcompile($this->getNode('key_info'))
49
  ->write(");\n")
50
  ->write("\$asm89CacheBody".$i." = \$asm89CacheStrategy".$i."->fetchBlock(\$asm89Key".$i.");\n")
vendor/asm89/twig-cache-extension/lib/Asm89/Twig/CacheExtension/TokenParser/Cache.php CHANGED
@@ -44,7 +44,8 @@ class Cache extends \Twig_TokenParser
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);
44
  $lineno = $token->getLine();
45
  $stream = $this->parser->getStream();
46
 
47
+ $annotation = $this->parser->getExpressionParser()->parseExpression();
48
+
49
  $key = $this->parser->getExpressionParser()->parseExpression();
50
 
51
  $stream->expect(Twig_Token::BLOCK_END_TYPE);
vendor/asm89/twig-cache-extension/test/Asm89/Twig/CacheExtension/Tests/FunctionalExtensionTest.php CHANGED
@@ -142,15 +142,12 @@ class FunctionalExtensionTest extends \PHPUnit_Framework_TestCase
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
 
142
  $rendered = $twig->render('ics_no_key.twig', array('value' => $this->getValue('asm89', 1)));
143
  }
144
 
145
+ public function testAnnotationExpression()
 
 
 
 
146
  {
147
+ $twig = $this->createTwig('indexed');
148
 
149
+ $rendered = $twig->render('annotation_expression.twig', array('value' => $this->getValue('asm89', 1), 'version' => 1));
150
+ $this->assertEquals('Hello asm89!Hello asm89!', $rendered);
151
  }
152
  }
153
 
vendor/asm89/twig-cache-extension/test/Asm89/Twig/CacheExtension/Tests/fixtures/annotation_expression.twig ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ {%- set k = "v'" ~ version -%}
2
+ {%- cache k {time: 10} -%}Hello {{ value }}!{%- endcache -%}
3
+ {%- cache 'bob'|capitalize {gcs: value} %}Hello {{ value }}!{%- endcache -%}
vendor/autoload.php CHANGED
@@ -4,4 +4,4 @@
4
 
5
  require_once __DIR__ . '/composer' . '/autoload_real.php';
6
 
7
- return ComposerAutoloaderInit6a8f2a8653a1bfa1858986237611e8be::getLoader();
4
 
5
  require_once __DIR__ . '/composer' . '/autoload_real.php';
6
 
7
+ return ComposerAutoloaderInit51eed1b778e859bfb3984400f7648ee2::getLoader();
vendor/composer/autoload_namespaces.php CHANGED
@@ -7,8 +7,7 @@ $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
  );
7
 
8
  return array(
9
  'Twig_' => array($vendorDir . '/twig/twig/lib'),
10
+ 'PHPRouter' => array($vendorDir . '/jarednova/php-router/src'),
 
11
  'Composer\\Installers\\' => array($vendorDir . '/composer/installers/src'),
12
  'Asm89\\Twig\\CacheExtension\\' => array($vendorDir . '/asm89/twig-cache-extension/lib'),
13
  );
vendor/composer/autoload_real.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
- class ComposerAutoloaderInit6a8f2a8653a1bfa1858986237611e8be
6
  {
7
  private static $loader;
8
 
@@ -19,9 +19,9 @@ class ComposerAutoloaderInit6a8f2a8653a1bfa1858986237611e8be
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,7 +44,7 @@ class ComposerAutoloaderInit6a8f2a8653a1bfa1858986237611e8be
44
  }
45
  }
46
 
47
- function composerRequire6a8f2a8653a1bfa1858986237611e8be($file)
48
  {
49
  require $file;
50
  }
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
+ class ComposerAutoloaderInit51eed1b778e859bfb3984400f7648ee2
6
  {
7
  private static $loader;
8
 
19
  return self::$loader;
20
  }
21
 
22
+ spl_autoload_register(array('ComposerAutoloaderInit51eed1b778e859bfb3984400f7648ee2', 'loadClassLoader'), true, true);
23
  self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
+ spl_autoload_unregister(array('ComposerAutoloaderInit51eed1b778e859bfb3984400f7648ee2', 'loadClassLoader'));
25
 
26
  $map = require __DIR__ . '/autoload_namespaces.php';
27
  foreach ($map as $namespace => $path) {
44
  }
45
  }
46
 
47
+ function composerRequire51eed1b778e859bfb3984400f7648ee2($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.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,7 +22,7 @@
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",
@@ -55,6 +55,7 @@
55
  "Hurad",
56
  "MODX Evo",
57
  "OXID",
 
58
  "Thelia",
59
  "WolfCMS",
60
  "agl",
@@ -94,29 +95,47 @@
94
  "zikula"
95
  ]
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",
@@ -155,17 +174,17 @@
155
  },
156
  {
157
  "name": "asm89/twig-cache-extension",
158
- "version": "0.1.0",
159
- "version_normalized": "0.1.0.0",
160
  "source": {
161
  "type": "git",
162
  "url": "https://github.com/asm89/twig-cache-extension.git",
163
- "reference": "35da9579dc0648e5bb52d02530ff81352f7e1247"
164
  },
165
  "dist": {
166
  "type": "zip",
167
- "url": "https://api.github.com/repos/asm89/twig-cache-extension/zipball/35da9579dc0648e5bb52d02530ff81352f7e1247",
168
- "reference": "35da9579dc0648e5bb52d02530ff81352f7e1247",
169
  "shasum": ""
170
  },
171
  "require": {
@@ -175,11 +194,11 @@
175
  "require-dev": {
176
  "doctrine/cache": "1.*"
177
  },
178
- "time": "2013-11-13 20:03:36",
179
  "type": "library",
180
  "extra": {
181
  "branch-alias": {
182
- "dev-master": "0.1-dev"
183
  }
184
  },
185
  "installation-source": "dist",
@@ -206,108 +225,5 @@
206
  "extension",
207
  "twig"
208
  ]
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",
237
- "autoload": {
238
- "psr-0": {
239
- "Symfony\\Component\\Yaml\\": ""
240
- }
241
- },
242
- "notification-url": "https://packagist.org/downloads/",
243
- "license": [
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",
257
- "homepage": "http://symfony.com"
258
- },
259
- {
260
- "name": "dannyvankooten/php-router",
261
- "version": "dev-master",
262
- "version_normalized": "9999999-dev",
263
- "source": {
264
- "type": "git",
265
- "url": "https://github.com/dannyvankooten/PHP-Router.git",
266
- "reference": "e9a479820b871ae4493fec30d5e433456767a505"
267
- },
268
- "dist": {
269
- "type": "zip",
270
- "url": "https://api.github.com/repos/dannyvankooten/PHP-Router/zipball/274b75c1618f69b695caa91d2c7ba0f67f0e774c",
271
- "reference": "e9a479820b871ae4493fec30d5e433456767a505",
272
- "shasum": ""
273
- },
274
- "require": {
275
- "php": ">=5.3.3",
276
- "symfony/yaml": "@dev"
277
- },
278
- "require-dev": {
279
- "phpunit/phpunit": "3.7.*"
280
- },
281
- "time": "2014-02-12 12:10:38",
282
- "type": "library",
283
- "installation-source": "source",
284
- "autoload": {
285
- "psr-0": {
286
- "PHPRouter": "src/"
287
- }
288
- },
289
- "notification-url": "https://packagist.org/downloads/",
290
- "license": [
291
- "MIT"
292
- ],
293
- "authors": [
294
- {
295
- "name": "Danny van Kooten",
296
- "email": "dannyvankooten@gmail.com",
297
- "homepage": "http://dannyvankooten.com/"
298
- },
299
- {
300
- "name": "Jefersson Nathan",
301
- "email": "malukenho@phpse.net"
302
- }
303
- ],
304
- "description": "Simple PHP Router, supports REST and reverse routing.",
305
- "homepage": "https://github.com/dannyvankooten/PHP-Router",
306
- "keywords": [
307
- "php",
308
- "rest",
309
- "router",
310
- "routing"
311
- ]
312
  }
313
  ]
1
  [
2
  {
3
  "name": "composer/installers",
4
+ "version": "v1.0.20",
5
+ "version_normalized": "1.0.20.0",
6
  "source": {
7
  "type": "git",
8
  "url": "https://github.com/composer/installers.git",
9
+ "reference": "1bff8aa77a18f3616f468ed8000cf86a5725bac3"
10
  },
11
  "dist": {
12
  "type": "zip",
13
+ "url": "https://api.github.com/repos/composer/installers/zipball/1bff8aa77a18f3616f468ed8000cf86a5725bac3",
14
+ "reference": "1bff8aa77a18f3616f468ed8000cf86a5725bac3",
15
  "shasum": ""
16
  },
17
  "replace": {
22
  "composer/composer": "1.0.*@dev",
23
  "phpunit/phpunit": "4.1.*"
24
  },
25
+ "time": "2015-01-11 03:51:11",
26
  "type": "composer-installer",
27
  "extra": {
28
  "class": "Composer\\Installers\\Installer",
55
  "Hurad",
56
  "MODX Evo",
57
  "OXID",
58
+ "SMF",
59
  "Thelia",
60
  "WolfCMS",
61
  "agl",
95
  "zikula"
96
  ]
97
  },
98
+ {
99
+ "name": "jarednova/php-router",
100
+ "version": "1.0.1",
101
+ "version_normalized": "1.0.1.0",
102
+ "dist": {
103
+ "type": "zip",
104
+ "url": "https://github.com/jarednova/PHP-Router/archive/fix_psr_0.zip",
105
+ "reference": null,
106
+ "shasum": null
107
+ },
108
+ "type": "library",
109
+ "installation-source": "dist",
110
+ "autoload": {
111
+ "psr-0": {
112
+ "PHPRouter": "src/"
113
+ }
114
+ }
115
+ },
116
  {
117
  "name": "twig/twig",
118
+ "version": "v1.18.0",
119
+ "version_normalized": "1.18.0.0",
120
  "source": {
121
  "type": "git",
122
  "url": "https://github.com/twigphp/Twig.git",
123
+ "reference": "4cf7464348e7f9893a93f7096a90b73722be99cf"
124
  },
125
  "dist": {
126
  "type": "zip",
127
+ "url": "https://api.github.com/repos/twigphp/Twig/zipball/4cf7464348e7f9893a93f7096a90b73722be99cf",
128
+ "reference": "4cf7464348e7f9893a93f7096a90b73722be99cf",
129
  "shasum": ""
130
  },
131
  "require": {
132
  "php": ">=5.2.4"
133
  },
134
+ "time": "2015-01-25 17:32:08",
135
  "type": "library",
136
  "extra": {
137
  "branch-alias": {
138
+ "dev-master": "1.18-dev"
139
  }
140
  },
141
  "installation-source": "dist",
174
  },
175
  {
176
  "name": "asm89/twig-cache-extension",
177
+ "version": "1.0.0",
178
+ "version_normalized": "1.0.0.0",
179
  "source": {
180
  "type": "git",
181
  "url": "https://github.com/asm89/twig-cache-extension.git",
182
+ "reference": "92edc2ab522997fd0a2a02b6b9e89b3e08ac5c60"
183
  },
184
  "dist": {
185
  "type": "zip",
186
+ "url": "https://api.github.com/repos/asm89/twig-cache-extension/zipball/92edc2ab522997fd0a2a02b6b9e89b3e08ac5c60",
187
+ "reference": "92edc2ab522997fd0a2a02b6b9e89b3e08ac5c60",
188
  "shasum": ""
189
  },
190
  "require": {
194
  "require-dev": {
195
  "doctrine/cache": "1.*"
196
  },
197
+ "time": "2014-05-31 13:57:16",
198
  "type": "library",
199
  "extra": {
200
  "branch-alias": {
201
+ "dev-master": "1.0-dev"
202
  }
203
  },
204
  "installation-source": "dist",
225
  "extension",
226
  "twig"
227
  ]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
228
  }
229
  ]
vendor/composer/installers/README.md CHANGED
@@ -38,7 +38,8 @@ is not needed to install packages with these frameworks:
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`
@@ -73,6 +74,7 @@ is not needed to install packages with these frameworks:
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`
 
76
  | symfony1 | **`symfony1-plugin`**
77
  | Tusk | `tusk-task`<br>`tusk-command`<br>`tusk-asset`
78
  | 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`
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-cookbook`<br>`chef-role`
42
+ | CCFramework | `ccframework-ship`<br>`ccframework-theme`
43
  | CodeIgniter | `codeigniter-library`<br>`codeigniter-third-party`<br>`codeigniter-module`
44
  | concrete5 | `concrete5-block`<br>`concrete5-package`<br>`concrete5-theme`<br>`concrete5-update`
45
  | Craft | `craft-plugin`
74
  | Roundcube | `roundcube-plugin`
75
  | shopware | `shopware-backend-plugin`<br/>`shopware-core-plugin`<br/>`shopware-frontend-plugin`<br/>`shopware-theme`
76
  | SilverStripe | `silverstripe-module`<br>`silverstripe-theme`
77
+ | SMF | `smf-module`<br>`smf-theme`
78
  | symfony1 | **`symfony1-plugin`**
79
  | Tusk | `tusk-task`<br>`tusk-command`<br>`tusk-asset`
80
  | 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`
vendor/composer/installers/composer.json CHANGED
@@ -39,6 +39,7 @@
39
  "Roundcube",
40
  "shopware",
41
  "SilverStripe",
 
42
  "symfony",
43
  "Thelia",
44
  "TYPO3",
39
  "Roundcube",
40
  "shopware",
41
  "SilverStripe",
42
+ "SMF",
43
  "symfony",
44
  "Thelia",
45
  "TYPO3",
vendor/composer/installers/src/Composer/Installers/ClanCatsFrameworkInstaller.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Composer\Installers;
3
+
4
+ class ClanCatsFrameworkInstaller extends BaseInstaller
5
+ {
6
+ protected $locations = array(
7
+ 'ship' => 'CCF/orbit/{$name}/',
8
+ 'theme' => 'CCF/app/themes/{$name}/',
9
+ );
10
+ }
vendor/composer/installers/src/Composer/Installers/DrupalInstaller.php CHANGED
@@ -4,9 +4,10 @@ namespace Composer\Installers;
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
  );
4
  class DrupalInstaller extends BaseInstaller
5
  {
6
  protected $locations = array(
7
+ 'core' => 'core/',
8
  'module' => 'modules/{$name}/',
9
  'theme' => 'themes/{$name}/',
10
+ 'library' => 'libraries/{$name}/',
11
  'profile' => 'profiles/{$name}/',
12
  'drush' => 'drush/{$name}/',
13
  );
vendor/composer/installers/src/Composer/Installers/Installer.php CHANGED
@@ -19,6 +19,7 @@ class Installer extends LibraryInstaller
19
  'bitrix' => 'BitrixInstaller',
20
  'cakephp' => 'CakePHPInstaller',
21
  'chef' => 'ChefInstaller',
 
22
  'codeigniter' => 'CodeIgniterInstaller',
23
  'concrete5' => 'Concrete5Installer',
24
  'craft' => 'CraftInstaller',
@@ -54,6 +55,7 @@ class Installer extends LibraryInstaller
54
  'roundcube' => 'RoundcubeInstaller',
55
  'shopware' => 'ShopwareInstaller',
56
  'silverstripe' => 'SilverStripeInstaller',
 
57
  'symfony1' => 'Symfony1Installer',
58
  'thelia' => 'TheliaInstaller',
59
  'tusk' => 'TuskInstaller',
19
  'bitrix' => 'BitrixInstaller',
20
  'cakephp' => 'CakePHPInstaller',
21
  'chef' => 'ChefInstaller',
22
+ 'ccframework' => 'ClanCatsFrameworkInstaller',
23
  'codeigniter' => 'CodeIgniterInstaller',
24
  'concrete5' => 'Concrete5Installer',
25
  'craft' => 'CraftInstaller',
55
  'roundcube' => 'RoundcubeInstaller',
56
  'shopware' => 'ShopwareInstaller',
57
  'silverstripe' => 'SilverStripeInstaller',
58
+ 'smf' => 'SMFInstaller',
59
  'symfony1' => 'Symfony1Installer',
60
  'thelia' => 'TheliaInstaller',
61
  'tusk' => 'TuskInstaller',
vendor/composer/installers/src/Composer/Installers/SMFInstaller.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Composer\Installers;
3
+
4
+ class SMFInstaller extends BaseInstaller
5
+ {
6
+ protected $locations = array(
7
+ 'module' => 'Sources/{$name}/',
8
+ 'theme' => 'Themes/{$name}/',
9
+ );
10
+ }
vendor/composer/installers/tests/Composer/Installers/Test/InstallerTest.php CHANGED
@@ -152,6 +152,8 @@ class InstallerTest extends TestCase
152
  array('shopware-theme', 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),
@@ -270,6 +272,8 @@ class InstallerTest extends TestCase
270
  array('silverstripe-module', 'framework/', 'silverstripe/framework', '3.0.0-rc1'),
271
  array('silverstripe-module', 'framework/', 'silverstripe/framework', 'my/branch'),
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'),
152
  array('shopware-theme', true),
153
  array('silverstripe-module', true),
154
  array('silverstripe-theme', true),
155
+ array('smf-module', true),
156
+ array('smf-theme', true),
157
  array('symfony1-plugin', true),
158
  array('thelia-module', true),
159
  array('thelia-frontoffice-template', true),
272
  array('silverstripe-module', 'framework/', 'silverstripe/framework', '3.0.0-rc1'),
273
  array('silverstripe-module', 'framework/', 'silverstripe/framework', 'my/branch'),
274
  array('silverstripe-theme', 'themes/my_theme/', 'shama/my_theme'),
275
+ array('smf-module', 'Sources/my_module/', 'shama/my_module'),
276
+ array('smf-theme', 'Themes/my_theme/', 'shama/my_theme'),
277
  array('symfony1-plugin', 'plugins/sfShamaPlugin/', 'shama/sfShamaPlugin'),
278
  array('symfony1-plugin', 'plugins/sfShamaPlugin/', 'shama/sf-shama-plugin'),
279
  array('thelia-module', 'local/modules/my_module/', 'shama/my_module'),
vendor/{dannyvankooten → jarednova}/php-router/.gitignore RENAMED
File without changes
vendor/{dannyvankooten → jarednova}/php-router/.htaccess RENAMED
File without changes
vendor/{dannyvankooten → jarednova}/php-router/LICENSE RENAMED
File without changes
vendor/{dannyvankooten → jarednova}/php-router/README.md RENAMED
File without changes
vendor/{dannyvankooten → jarednova}/php-router/composer.json RENAMED
@@ -1,26 +1,26 @@
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
- }
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/{dannyvankooten → jarednova}/php-router/example.php RENAMED
File without changes
vendor/{dannyvankooten → jarednova}/php-router/src/PHPRouter/Route.php RENAMED
File without changes
vendor/{dannyvankooten → jarednova}/php-router/src/PHPRouter/Router.php RENAMED
File without changes
vendor/symfony/yaml/Symfony/Component/Yaml/.gitignore DELETED
@@ -1,3 +0,0 @@
1
- vendor/
2
- composer.lock
3
- phpunit.xml
 
 
 
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/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/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/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/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/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
- /**
15
- * Exception class thrown when an error occurs during parsing.
16
- *
17
- * @author Fabien Potencier <fabien@symfony.com>
18
- *
19
- * @api
20
- */
21
- class ParseException extends RuntimeException
22
- {
23
- private $parsedFile;
24
- private $parsedLine;
25
- private $snippet;
26
- private $rawMessage;
27
-
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)
38
- {
39
- $this->parsedFile = $parsedFile;
40
- $this->parsedLine = $parsedLine;
41
- $this->snippet = $snippet;
42
- $this->rawMessage = $message;
43
-
44
- $this->updateRepr();
45
-
46
- parent::__construct($this->message, 0, $previous);
47
- }
48
-
49
- /**
50
- * Gets the snippet of code near the error.
51
- *
52
- * @return string The snippet of code
53
- */
54
- public function getSnippet()
55
- {
56
- return $this->snippet;
57
- }
58
-
59
- /**
60
- * Sets the snippet of code near the error.
61
- *
62
- * @param string $snippet The code snippet
63
- */
64
- public function setSnippet($snippet)
65
- {
66
- $this->snippet = $snippet;
67
-
68
- $this->updateRepr();
69
- }
70
-
71
- /**
72
- * Gets the filename where the error occurred.
73
- *
74
- * This method returns null if a string is parsed.
75
- *
76
- * @return string The filename
77
- */
78
- public function getParsedFile()
79
- {
80
- return $this->parsedFile;
81
- }
82
-
83
- /**
84
- * Sets the filename where the error occurred.
85
- *
86
- * @param string $parsedFile The filename
87
- */
88
- public function setParsedFile($parsedFile)
89
- {
90
- $this->parsedFile = $parsedFile;
91
-
92
- $this->updateRepr();
93
- }
94
-
95
- /**
96
- * Gets the line where the error occurred.
97
- *
98
- * @return int The file line
99
- */
100
- public function getParsedLine()
101
- {
102
- return $this->parsedLine;
103
- }
104
-
105
- /**
106
- * Sets the line where the error occurred.
107
- *
108
- * @param int $parsedLine The file line
109
- */
110
- public function setParsedLine($parsedLine)
111
- {
112
- $this->parsedLine = $parsedLine;
113
-
114
- $this->updateRepr();
115
- }
116
-
117
- private function updateRepr()
118
- {
119
- $this->message = $this->rawMessage;
120
-
121
- $dot = false;
122
- if ('.' === substr($this->message, -1)) {
123
- $this->message = substr($this->message, 0, -1);
124
- $dot = true;
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) {
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/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/symfony/yaml/Symfony/Component/Yaml/Inline.php DELETED
@@ -1,535 +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
- 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
-
51
- if (0 == strlen($value)) {
52
- return '';
53
- }
54
-
55
- if (function_exists('mb_internal_encoding') && ((int) ini_get('mbstring.func_overload')) & 2) {
56
- $mbEncoding = mb_internal_encoding();
57
- mb_internal_encoding('ASCII');
58
- }
59
-
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
75
- if (preg_replace('/\s+#.*$/A', '', substr($value, $i))) {
76
- throw new ParseException(sprintf('Unexpected characters near "%s".', substr($value, $i)));
77
- }
78
-
79
- if (isset($mbEncoding)) {
80
- mb_internal_encoding($mbEncoding);
81
- }
82
-
83
- return $result;
84
- }
85
-
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
- *
95
- * @throws DumpException When trying to dump PHP resource
96
- */
97
- public static function dump($value, $exceptionOnInvalidType = false, $objectSupport = false)
98
- {
99
- switch (true) {
100
- case is_resource($value):
101
- if ($exceptionOnInvalidType) {
102
- throw new DumpException(sprintf('Unable to dump PHP resources in a YAML file ("%s").', get_resource_type($value)));
103
- }
104
-
105
- return 'null';
106
- case is_object($value):
107
- if ($objectSupport) {
108
- return '!!php/object:'.serialize($value);
109
- }
110
-
111
- if ($exceptionOnInvalidType) {
112
- throw new DumpException('Object support when dumping a YAML file has been disabled.');
113
- }
114
-
115
- return 'null';
116
- case is_array($value):
117
- return self::dumpArray($value, $exceptionOnInvalidType, $objectSupport);
118
- case null === $value:
119
- return 'null';
120
- case true === $value:
121
- return 'true';
122
- case false === $value:
123
- return 'false';
124
- case ctype_digit($value):
125
- return is_string($value) ? "'$value'" : (int) $value;
126
- case is_numeric($value):
127
- $locale = setlocale(LC_NUMERIC, 0);
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
- }
145
-
146
- return $repr;
147
- case Escaper::requiresDoubleQuoting($value):
148
- return Escaper::escapeWithDoubleQuotes($value);
149
- case Escaper::requiresSingleQuoting($value):
150
- return Escaper::escapeWithSingleQuotes($value);
151
- case '' == $value:
152
- return "''";
153
- case preg_match(self::getTimestampRegex(), $value):
154
- case in_array(strtolower($value), array('null', '~', 'true', 'false')):
155
- return "'$value'";
156
- default:
157
- return $value;
158
- }
159
- }
160
-
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
- */
170
- private static function dumpArray($value, $exceptionOnInvalidType, $objectSupport)
171
- {
172
- // array
173
- $keys = array_keys($value);
174
- if ((1 == count($keys) && '0' == $keys[0])
175
- || (count($keys) > 1 && array_reduce($keys, function ($v, $w) { return (int) $v + $w; }, 0) == count($keys) * (count($keys) - 1) / 2)
176
- ) {
177
- $output = array();
178
- foreach ($value as $val) {
179
- $output[] = self::dump($val, $exceptionOnInvalidType, $objectSupport);
180
- }
181
-
182
- return sprintf('[%s]', implode(', ', $output));
183
- }
184
-
185
- // mapping
186
- $output = array();
187
- foreach ($value as $key => $val) {
188
- $output[] = sprintf('%s: %s', self::dump($key, $exceptionOnInvalidType, $objectSupport), self::dump($val, $exceptionOnInvalidType, $objectSupport));
189
- }
190
-
191
- return sprintf('{ %s }', implode(', ', $output));
192
- }
193
-
194
- /**
195
- * Parses a scalar to a YAML string.
196
- *
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
212
- $output = self::parseQuotedScalar($scalar, $i);
213
-
214
- if (null !== $delimiters) {
215
- $tmp = ltrim(substr($scalar, $i), ' ');
216
- if (!in_array($tmp[0], $delimiters)) {
217
- throw new ParseException(sprintf('Unexpected characters (%s).', substr($scalar, $i)));
218
- }
219
- }
220
- } else {
221
- // "normal" string
222
- if (!$delimiters) {
223
- $output = substr($scalar, $i);
224
- $i += strlen($output);
225
-
226
- // remove comments
227
- if (false !== $strpos = strpos($output, ' #')) {
228
- $output = rtrim(substr($output, 0, $strpos));
229
- }
230
- } elseif (preg_match('/^(.+?)('.implode('|', $delimiters).')/', substr($scalar, $i), $match)) {
231
- $output = $match[1];
232
- $i += strlen($output);
233
- } else {
234
- throw new ParseException(sprintf('Malformed inline YAML string (%s).', $scalar));
235
- }
236
-
237
- if ($evaluate) {
238
- $output = self::evaluateScalar($output, $references);
239
- }
240
- }
241
-
242
- return $output;
243
- }
244
-
245
- /**
246
- * Parses a quoted scalar to YAML.
247
- *
248
- * @param string $scalar
249
- * @param int &$i
250
- *
251
- * @return string A YAML string
252
- *
253
- * @throws ParseException When malformed inline YAML string is parsed
254
- */
255
- private static function parseQuotedScalar($scalar, &$i)
256
- {
257
- if (!preg_match('/'.self::REGEX_QUOTED_STRING.'/Au', substr($scalar, $i), $match)) {
258
- throw new ParseException(sprintf('Malformed inline YAML string (%s).', substr($scalar, $i)));
259
- }
260
-
261
- $output = substr($match[0], 1, strlen($match[0]) - 2);
262
-
263
- $unescaper = new Unescaper();
264
- if ('"' == $scalar[$i]) {
265
- $output = $unescaper->unescapeDoubleQuotedString($output);
266
- } else {
267
- $output = $unescaper->unescapeSingleQuotedString($output);
268
- }
269
-
270
- $i += strlen($match[0]);
271
-
272
- return $output;
273
- }
274
-
275
- /**
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);
290
- $i += 1;
291
-
292
- // [foo, bar, ...]
293
- while ($i < $len) {
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;
305
- case ',':
306
- case ' ':
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
- }
321
- }
322
-
323
- $output[] = $value;
324
-
325
- --$i;
326
- }
327
-
328
- ++$i;
329
- }
330
-
331
- throw new ParseException(sprintf('Malformed inline YAML string %s', $sequence));
332
- }
333
-
334
- /**
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);
349
- $i += 1;
350
-
351
- // {foo: bar, bar:foo, ...}
352
- while ($i < $len) {
353
- switch ($mapping[$i]) {
354
- case ' ':
355
- case ',':
356
- ++$i;
357
- continue 2;
358
- case '}':
359
- if (self::$objectForMap) {
360
- return (object) $output;
361
- }
362
-
363
- return $output;
364
- }
365
-
366
- // key
367
- $key = self::parseScalar($mapping, array(':', ' '), array('"', "'"), $i, false);
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.
380
- if (!isset($output[$key])) {
381
- $output[$key] = $value;
382
- }
383
- $done = true;
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.
391
- if (!isset($output[$key])) {
392
- $output[$key] = $value;
393
- }
394
- $done = true;
395
- break;
396
- case ':':
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.
404
- if (!isset($output[$key])) {
405
- $output[$key] = $value;
406
- }
407
- $done = true;
408
- --$i;
409
- }
410
-
411
- ++$i;
412
-
413
- if ($done) {
414
- continue 2;
415
- }
416
- }
417
- }
418
-
419
- throw new ParseException(sprintf('Malformed inline YAML string %s', $mapping));
420
- }
421
-
422
- /**
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:
459
- case '~' === $scalar:
460
- return;
461
- case 'true' === $scalarLower:
462
- return true;
463
- case 'false' === $scalarLower:
464
- return false;
465
- // Optimise for returning strings.
466
- case $scalar[0] === '+' || $scalar[0] === '-' || $scalar[0] === '.' || $scalar[0] === '!' || is_numeric($scalar[0]):
467
- switch (true) {
468
- case 0 === strpos($scalar, '!str'):
469
- return (string) substr($scalar, 5);
470
- case 0 === strpos($scalar, '! '):
471
- return intval(self::parseScalar(substr($scalar, 2)));
472
- case 0 === strpos($scalar, '!!php/object:'):
473
- if (self::$objectSupport) {
474
- return unserialize(substr($scalar, 13));
475
- }
476
-
477
- if (self::$exceptionOnInvalidType) {
478
- throw new ParseException('Object support when parsing a YAML file has been disabled.');
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);
487
-
488
- return '0' == $scalar[0] ? octdec($scalar) : (((string) $raw == (string) $cast) ? $cast : $raw);
489
- case '-' === $scalar[0] && ctype_digit(substr($scalar, 1)):
490
- $raw = $scalar;
491
- $cast = intval($scalar);
492
-
493
- return '0' == $scalar[1] ? octdec($scalar) : (((string) $raw == (string) $cast) ? $cast : $raw);
494
- case is_numeric($scalar):
495
- return '0x' == $scalar[0].$scalar[1] ? hexdec($scalar) : floatval($scalar);
496
- case '.inf' === $scalarLower:
497
- case '.nan' === $scalarLower:
498
- return -log(0);
499
- case '-.inf' === $scalarLower:
500
- return log(0);
501
- case preg_match('/^(-|\+)?[0-9,]+(\.[0-9]+)?$/', $scalar):
502
- return floatval(str_replace(',', '', $scalar));
503
- case preg_match(self::getTimestampRegex(), $scalar):
504
- return strtotime($scalar);
505
- }
506
- default:
507
- return (string) $scalar;
508
- }
509
- }
510
-
511
- /**
512
- * Gets a regex that matches a YAML date.
513
- *
514
- * @return string The regular expression
515
- *
516
- * @see http://www.yaml.org/spec/1.2/spec.html#id2761573
517
- */
518
- private static function getTimestampRegex()
519
- {
520
- return <<<EOF
521
- ~^
522
- (?P<year>[0-9][0-9][0-9][0-9])
523
- -(?P<month>[0-9][0-9]?)
524
- -(?P<day>[0-9][0-9]?)
525
- (?:(?:[Tt]|[ \t]+)
526
- (?P<hour>[0-9][0-9]?)
527
- :(?P<minute>[0-9][0-9])
528
- :(?P<second>[0-9][0-9])
529
- (?:\.(?P<fraction>[0-9]*))?
530
- (?:[ \t]*(?P<tz>Z|(?P<tz_sign>[-+])(?P<tz_hour>[0-9][0-9]?)
531
- (?::(?P<tz_minute>[0-9][0-9]))?))?)?
532
- $~x
533
- EOF;
534
- }
535
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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/symfony/yaml/Symfony/Component/Yaml/Parser.php DELETED
@@ -1,692 +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
- * @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 = '';
57
- $this->lines = explode("\n", $this->cleanup($value));
58
-
59
- if (!preg_match('//u', $value)) {
60
- throw new ParseException('The YAML value does not appear to be valid UTF-8.');
61
- }
62
-
63
- if (function_exists('mb_internal_encoding') && ((int) ini_get('mbstring.func_overload')) & 2) {
64
- $mbEncoding = mb_internal_encoding();
65
- mb_internal_encoding('UTF-8');
66
- }
67
-
68
- $data = array();
69
- $context = null;
70
- $allowOverwrite = false;
71
- while ($this->moveToNextLine()) {
72
- if ($this->isCurrentLineEmpty()) {
73
- continue;
74
- }
75
-
76
- // tab?
77
- if ("\t" === $this->currentLine[0]) {
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');
85
- }
86
- $context = 'sequence';
87
-
88
- if (isset($values['value']) && preg_match('#^&(?P<ref>[^ ]+) *(?P<value>.*)#u', $values['value'], $matches)) {
89
- $isRef = $matches['ref'];
90
- $values['value'] = $matches['value'];
91
- }
92
-
93
- // array
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']
102
- && preg_match('#^(?P<key>'.Inline::REGEX_QUOTED_STRING.'|[^ \'"\{\[].*?) *\:(\s+(?P<value>.+?))?\s*$#u', $values['value'], $matches)
103
- ) {
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) {
130
- $e->setParsedLine($this->getRealCurrentLineNb() + 1);
131
- $e->setSnippet($this->currentLine);
132
-
133
- throw $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'] !== '') {
158
- $value = $values['value'];
159
- } else {
160
- $value = $this->getNextEmbedBlock();
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);
245
-
246
- throw $e;
247
- }
248
-
249
- if (is_array($value)) {
250
- $first = reset($value);
251
- if (is_string($first) && 0 === strpos($first, '*')) {
252
- $data = array();
253
- foreach ($value as $alias) {
254
- $data[] = $this->refs[substr($alias, 1)];
255
- }
256
- $value = $data;
257
- }
258
- }
259
-
260
- if (isset($mbEncoding)) {
261
- mb_internal_encoding($mbEncoding);
262
- }
263
-
264
- return $value;
265
- }
266
-
267
- switch (preg_last_error()) {
268
- case PREG_INTERNAL_ERROR:
269
- $error = 'Internal PCRE error.';
270
- break;
271
- case PREG_BACKTRACK_LIMIT_ERROR:
272
- $error = 'pcre.backtrack_limit reached.';
273
- break;
274
- case PREG_RECURSION_LIMIT_ERROR:
275
- $error = 'pcre.recursion_limit reached.';
276
- break;
277
- case PREG_BAD_UTF8_ERROR:
278
- $error = 'Malformed UTF-8 data.';
279
- break;
280
- case PREG_BAD_UTF8_OFFSET_ERROR:
281
- $error = 'Offset doesn\'t correspond to the begin of a valid UTF-8 code point.';
282
- break;
283
- default:
284
- $error = 'Unable to parse.';
285
- }
286
-
287
- throw new ParseException($error, $this->getRealCurrentLineNb() + 1, $this->currentLine);
288
- }
289
-
290
- if ($isRef) {
291
- $this->refs[$isRef] = end($data);
292
- }
293
- }
294
-
295
- if (isset($mbEncoding)) {
296
- mb_internal_encoding($mbEncoding);
297
- }
298
-
299
- return empty($data) ? null : $data;
300
- }
301
-
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
- {
309
- return $this->currentLineNb + $this->offset;
310
- }
311
-
312
- /**
313
- * Returns the current line indentation.
314
- *
315
- * @return int The current line indentation
316
- */
317
- private function getCurrentLineIndentation()
318
- {
319
- return strlen($this->currentLine) - strlen(ltrim($this->currentLine, ' '));
320
- }
321
-
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();
342
-
343
- $unindentedEmbedBlock = $this->isStringUnIndentedCollectionItem($this->currentLine);
344
-
345
- if (!$this->isCurrentLineEmpty() && 0 === $newIndent && !$unindentedEmbedBlock) {
346
- throw new ParseException('Indentation problem.', $this->getRealCurrentLineNb() + 1, $this->currentLine);
347
- }
348
- } else {
349
- $newIndent = $indentation;
350
- }
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 "|")
365
- $removeCommentsPattern = '~'.self::FOLDED_SCALAR_PATTERN.'$~';
366
- $removeComments = !preg_match($removeCommentsPattern, $this->currentLine);
367
-
368
- while ($this->moveToNextLine()) {
369
- $indent = $this->getCurrentLineIndentation();
370
-
371
- if ($indent === $newIndent) {
372
- $removeComments = !preg_match($removeCommentsPattern, $this->currentLine);
373
- }
374
-
375
- if ($isItUnindentedCollection && !$this->isStringUnIndentedCollectionItem($this->currentLine)) {
376
- $this->moveToPreviousLine();
377
- break;
378
- }
379
-
380
- if ($this->isCurrentLineBlank()) {
381
- $data[] = substr($this->currentLine, $newIndent);
382
- continue;
383
- }
384
-
385
- if ($removeComments && $this->isCurrentLineComment()) {
386
- continue;
387
- }
388
-
389
- if ($indent >= $newIndent) {
390
- $data[] = substr($this->currentLine, $newIndent);
391
- } elseif (0 == $indent) {
392
- $this->moveToPreviousLine();
393
-
394
- break;
395
- } else {
396
- throw new ParseException('Indentation problem.', $this->getRealCurrentLineNb() + 1, $this->currentLine);
397
- }
398
- }
399
-
400
- return implode("\n", $data);
401
- }
402
-
403
- /**
404
- * Moves the parser to the next line.
405
- *
406
- * @return bool
407
- */
408
- private function moveToNextLine()
409
- {
410
- if ($this->currentLineNb >= count($this->lines) - 1) {
411
- return false;
412
- }
413
-
414
- $this->currentLine = $this->lines[++$this->currentLineNb];
415
-
416
- return true;
417
- }
418
-
419
- /**
420
- * Moves the parser to the previous line.
421
- */
422
- private function moveToPreviousLine()
423
- {
424
- $this->currentLine = $this->lines[--$this->currentLineNb];
425
- }
426
-
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, '#')) {
443
- $value = substr($value, 1, $pos - 2);
444
- } else {
445
- $value = substr($value, 1);
446
- }
447
-
448
- if (!array_key_exists($value, $this->refs)) {
449
- throw new ParseException(sprintf('Reference "%s" does not exist.', $value), $this->currentLine);
450
- }
451
-
452
- return $this->refs[$value];
453
- }
454
-
455
- if (preg_match('/^'.self::FOLDED_SCALAR_PATTERN.'$/', $value, $matches)) {
456
- $modifiers = isset($matches['modifiers']) ? $matches['modifiers'] : '';
457
-
458
- return $this->parseFoldedScalar($matches['separator'], preg_replace('#\d+#', '', $modifiers), intval(abs($modifiers)));
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);
466
-
467
- throw $e;
468
- }
469
- }
470
-
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
- {
482
- $notEOF = $this->moveToNextLine();
483
- if (!$notEOF) {
484
- return '';
485
- }
486
-
487
- $isCurrentLineBlank = $this->isCurrentLineBlank();
488
- $text = '';
489
-
490
- // leading blank lines are consumed before determining indentation
491
- while ($notEOF && $isCurrentLineBlank) {
492
- // newline only if not EOF
493
- if ($notEOF = $this->moveToNextLine()) {
494
- $text .= "\n";
495
- $isCurrentLineBlank = $this->isCurrentLineBlank();
496
- }
497
- }
498
-
499
- // determine indentation if not specified
500
- if (0 === $indentation) {
501
- if (preg_match('/^ +/', $this->currentLine, $matches)) {
502
- $indentation = strlen($matches[0]);
503
- }
504
- }
505
-
506
- if ($indentation > 0) {
507
- $pattern = sprintf('/^ {%d}(.*)$/', $indentation);
508
-
509
- while (
510
- $notEOF && (
511
- $isCurrentLineBlank ||
512
- preg_match($pattern, $this->currentLine, $matches)
513
- )
514
- ) {
515
- if ($isCurrentLineBlank) {
516
- $text .= substr($this->currentLine, $indentation);
517
- } else {
518
- $text .= $matches[1];
519
- }
520
-
521
- // newline only if not EOF
522
- if ($notEOF = $this->moveToNextLine()) {
523
- $text .= "\n";
524
- $isCurrentLineBlank = $this->isCurrentLineBlank();
525
- }
526
- }
527
- } elseif ($notEOF) {
528
- $text .= "\n";
529
- }
530
-
531
- if ($notEOF) {
532
- $this->moveToPreviousLine();
533
- }
534
-
535
- // replace all non-trailing single newlines with spaces in folded blocks
536
- if ('>' === $separator) {
537
- preg_match('/(\n*)$/', $text, $matches);
538
- $text = preg_replace('/(?<!\n)\n(?!\n)/', ' ', rtrim($text, "\n"));
539
- $text .= $matches[1];
540
- }
541
-
542
- // deal with trailing newlines as indicated
543
- if ('' === $indicator) {
544
- $text = preg_replace('/\n+$/s', "\n", $text);
545
- } elseif ('-' === $indicator) {
546
- $text = preg_replace('/\n+$/s', '', $text);
547
- }
548
-
549
- return $text;
550
- }
551
-
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
- {
559
- $currentIndentation = $this->getCurrentLineIndentation();
560
- $EOF = !$this->moveToNextLine();
561
-
562
- while (!$EOF && $this->isCurrentLineEmpty()) {
563
- $EOF = !$this->moveToNextLine();
564
- }
565
-
566
- if ($EOF) {
567
- return false;
568
- }
569
-
570
- $ret = false;
571
- if ($this->getCurrentLineIndentation() > $currentIndentation) {
572
- $ret = true;
573
- }
574
-
575
- $this->moveToPreviousLine();
576
-
577
- return $ret;
578
- }
579
-
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
- {
587
- return $this->isCurrentLineBlank() || $this->isCurrentLineComment();
588
- }
589
-
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
- {
597
- return '' == trim($this->currentLine, ' ');
598
- }
599
-
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
- {
607
- //checking explicitly the first char of the trim is faster than loops or strpos
608
- $ltrimmedLine = ltrim($this->currentLine, ' ');
609
-
610
- return $ltrimmedLine[0] === '#';
611
- }
612
-
613
- /**
614
- * Cleanups a YAML string to be parsed.
615
- *
616
- * @param string $value The input YAML string
617
- *
618
- * @return string A cleaned up YAML string
619
- */
620
- private function cleanup($value)
621
- {
622
- $value = str_replace(array("\r\n", "\r"), "\n", $value);
623
-
624
- // strip YAML header
625
- $count = 0;
626
- $value = preg_replace('#^\%YAML[: ][\d\.]+.*\n#su', '', $value, -1, $count);
627
- $this->offset += $count;
628
-
629
- // remove leading comments
630
- $trimmedValue = preg_replace('#^(\#.*?\n)+#s', '', $value, -1, $count);
631
- if ($count == 1) {
632
- // items have been removed, update the offset
633
- $this->offset += substr_count($value, "\n") - substr_count($trimmedValue, "\n");
634
- $value = $trimmedValue;
635
- }
636
-
637
- // remove start of the document marker (---)
638
- $trimmedValue = preg_replace('#^\-\-\-.*?\n#s', '', $value, -1, $count);
639
- if ($count == 1) {
640
- // items have been removed, update the offset
641
- $this->offset += substr_count($value, "\n") - substr_count($trimmedValue, "\n");
642
- $value = $trimmedValue;
643
-
644
- // remove end of the document marker (...)
645
- $value = preg_replace('#\.\.\.\s*$#s', '', $value);
646
- }
647
-
648
- return $value;
649
- }
650
-
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
- {
658
- $currentIndentation = $this->getCurrentLineIndentation();
659
- $notEOF = $this->moveToNextLine();
660
-
661
- while ($notEOF && $this->isCurrentLineEmpty()) {
662
- $notEOF = $this->moveToNextLine();
663
- }
664
-
665
- if (false === $notEOF) {
666
- return false;
667
- }
668
-
669
- $ret = false;
670
- if (
671
- $this->getCurrentLineIndentation() == $currentIndentation
672
- &&
673
- $this->isStringUnIndentedCollectionItem($this->currentLine)
674
- ) {
675
- $ret = true;
676
- }
677
-
678
- $this->moveToPreviousLine();
679
-
680
- return $ret;
681
- }
682
-
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 DELETED
@@ -1,21 +0,0 @@
1
- Yaml Component
2
- ==============
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
- ---------
16
-
17
- You can run the unit tests with the following command:
18
-
19
- $ cd path/to/Symfony/Component/Yaml/
20
- $ composer.phar install
21
- $ phpunit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/symfony/yaml/Symfony/Component/Yaml/Tests/DumperTest.php DELETED
@@ -1,237 +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
- $this->assertSame($expected, $this->parser->parse($this->dumper->dump($expected, 10)), $test['test']);
100
- }
101
- }
102
- }
103
- }
104
-
105
- public function testInlineLevel()
106
- {
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': { }
117
- bar: [1, foo]
118
- foobar: { foo: bar, bar: [1, foo], foobar: { foo: bar, bar: [1, foo] } }
119
-
120
- EOF;
121
- $this->assertEquals($expected, $this->dumper->dump($this->array, 1), '->dump() takes an inline level argument');
122
-
123
- $expected = <<<EOF
124
- '': bar
125
- foo: '#bar'
126
- 'foo''bar': { }
127
- bar:
128
- - 1
129
- - foo
130
- foobar:
131
- foo: bar
132
- bar: [1, foo]
133
- foobar: { foo: bar, bar: [1, foo] }
134
-
135
- EOF;
136
- $this->assertEquals($expected, $this->dumper->dump($this->array, 2), '->dump() takes an inline level argument');
137
-
138
- $expected = <<<EOF
139
- '': bar
140
- foo: '#bar'
141
- 'foo''bar': { }
142
- bar:
143
- - 1
144
- - foo
145
- foobar:
146
- foo: bar
147
- bar:
148
- - 1
149
- - foo
150
- foobar:
151
- foo: bar
152
- bar: [1, foo]
153
-
154
- EOF;
155
- $this->assertEquals($expected, $this->dumper->dump($this->array, 3), '->dump() takes an inline level argument');
156
-
157
- $expected = <<<EOF
158
- '': bar
159
- foo: '#bar'
160
- 'foo''bar': { }
161
- bar:
162
- - 1
163
- - foo
164
- foobar:
165
- foo: bar
166
- bar:
167
- - 1
168
- - foo
169
- foobar:
170
- foo: bar
171
- bar:
172
- - 1
173
- - foo
174
-
175
- EOF;
176
- $this->assertEquals($expected, $this->dumper->dump($this->array, 4), '->dump() takes an inline level argument');
177
- $this->assertEquals($expected, $this->dumper->dump($this->array, 10), '->dump() takes an inline level argument');
178
- }
179
-
180
- public function testObjectSupportEnabled()
181
- {
182
- $dump = $this->dumper->dump(array('foo' => new A(), 'bar' => 1), 0, 0, false, true);
183
-
184
- $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');
185
- }
186
-
187
- public function testObjectSupportDisabledButNoExceptions()
188
- {
189
- $dump = $this->dumper->dump(array('foo' => new A(), 'bar' => 1));
190
-
191
- $this->assertEquals('{ foo: null, bar: 1 }', $dump, '->dump() does not dump objects when disabled');
192
- }
193
-
194
- /**
195
- * @expectedException \Symfony\Component\Yaml\Exception\DumpException
196
- */
197
- public function testObjectSupportDisabledWithExceptions()
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
235
- {
236
- public $a = 'foo';
237
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/YtsBasicTests.yml DELETED
@@ -1,202 +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: 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
41
- sequence by giving the sequence an empty
42
- dash, followed by an indented list.
43
- yaml: |
44
- -
45
- - foo
46
- - bar
47
- - baz
48
- php: |
49
- array(array('foo', 'bar', 'baz'))
50
- ---
51
- test: Mixed Sequences
52
- brief: |
53
- Sequences can contain any YAML data,
54
- including strings and other sequences.
55
- yaml: |
56
- - apple
57
- -
58
- - foo
59
- - bar
60
- - x123
61
- - banana
62
- - carrot
63
- php: |
64
- array('apple', array('foo', 'bar', 'x123'), 'banana', 'carrot')
65
- ---
66
- test: Deeply Nested Sequences
67
- brief: |
68
- Sequences can be nested even deeper, with each
69
- level of indentation representing a level of
70
- depth.
71
- yaml: |
72
- -
73
- -
74
- - uno
75
- - dos
76
- php: |
77
- array(array(array('uno', 'dos')))
78
- ---
79
- test: Simple Mapping
80
- brief: |
81
- You can add a keyed list (also known as a dictionary or
82
- hash) to your document by placing each member of the
83
- list on a new line, with a colon separating the key
84
- from its value. In YAML, this type of list is called
85
- a mapping.
86
- yaml: |
87
- foo: whatever
88
- bar: stuff
89
- php: |
90
- array('foo' => 'whatever', 'bar' => 'stuff')
91
- ---
92
- test: Sequence in a Mapping
93
- brief: |
94
- A value in a mapping can be a sequence.
95
- yaml: |
96
- foo: whatever
97
- bar:
98
- - uno
99
- - dos
100
- php: |
101
- array('foo' => 'whatever', 'bar' => array('uno', 'dos'))
102
- ---
103
- test: Nested Mappings
104
- brief: |
105
- A value in a mapping can be another mapping.
106
- yaml: |
107
- foo: whatever
108
- bar:
109
- fruit: apple
110
- name: steve
111
- sport: baseball
112
- php: |
113
- array(
114
- 'foo' => 'whatever',
115
- 'bar' => array(
116
- 'fruit' => 'apple',
117
- 'name' => 'steve',
118
- 'sport' => 'baseball'
119
- )
120
- )
121
- ---
122
- test: Mixed Mapping
123
- brief: |
124
- A mapping can contain any assortment
125
- of mappings and sequences as values.
126
- yaml: |
127
- foo: whatever
128
- bar:
129
- -
130
- fruit: apple
131
- name: steve
132
- sport: baseball
133
- - more
134
- -
135
- python: rocks
136
- perl: papers
137
- ruby: scissorses
138
- php: |
139
- array(
140
- 'foo' => 'whatever',
141
- 'bar' => array(
142
- array(
143
- 'fruit' => 'apple',
144
- 'name' => 'steve',
145
- 'sport' => 'baseball'
146
- ),
147
- 'more',
148
- array(
149
- 'python' => 'rocks',
150
- 'perl' => 'papers',
151
- 'ruby' => 'scissorses'
152
- )
153
- )
154
- )
155
- ---
156
- test: Mapping-in-Sequence Shortcut
157
- todo: true
158
- brief: |
159
- If you are adding a mapping to a sequence, you
160
- can place the mapping on the same line as the
161
- dash as a shortcut.
162
- yaml: |
163
- - work on YAML.py:
164
- - work on Store
165
- php: |
166
- array(array('work on YAML.py' => array('work on Store')))
167
- ---
168
- test: Sequence-in-Mapping Shortcut
169
- todo: true
170
- brief: |
171
- The dash in a sequence counts as indentation, so
172
- you can add a sequence inside of a mapping without
173
- needing spaces as indentation.
174
- yaml: |
175
- allow:
176
- - 'localhost'
177
- - '%.sourceforge.net'
178
- - '%.freepan.org'
179
- php: |
180
- array('allow' => array('localhost', '%.sourceforge.net', '%.freepan.org'))
181
- ---
182
- todo: true
183
- test: Merge key
184
- brief: |
185
- A merge key ('<<') can be used in a mapping to insert other mappings. If
186
- the value associated with the merge key is a mapping, each of its key/value
187
- pairs is inserted into the current mapping.
188
- yaml: |
189
- mapping:
190
- name: Joe
191
- job: Accountant
192
- <<:
193
- age: 38
194
- php: |
195
- array(
196
- 'mapping' =>
197
- array(
198
- 'name' => 'Joe',
199
- 'job' => 'Accountant',
200
- 'age' => 38
201
- )
202
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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/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/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/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/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/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/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/YtsSpecificationExamples.yml DELETED
@@ -1,1697 +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
- float as whole number: !!float 1
533
- php: |
534
- array(
535
- 'canonical' => 1230.15,
536
- 'exponential' => 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
544
- spec: 2.21
545
- yaml: |
546
- null: ~
547
- true: true
548
- false: false
549
- string: '12345'
550
- php: |
551
- array(
552
- '' => null,
553
- 1 => true,
554
- 0 => false,
555
- 'string' => '12345'
556
- )
557
- ---
558
- test: Timestamps
559
- todo: true
560
- spec: 2.22
561
- yaml: |
562
- canonical: 2001-12-15T02:59:43.1Z
563
- iso8601: 2001-12-14t21:59:43.10-05:00
564
- spaced: 2001-12-14 21:59:43.10 -05:00
565
- date: 2002-12-14 # Time is noon UTC
566
- php: |
567
- array(
568
- 'canonical' => YAML::mktime( 2001, 12, 15, 2, 59, 43, 0.10 ),
569
- 'iso8601' => YAML::mktime( 2001, 12, 14, 21, 59, 43, 0.10, "-05:00" ),
570
- 'spaced' => YAML::mktime( 2001, 12, 14, 21, 59, 43, 0.10, "-05:00" ),
571
- 'date' => Date.new( 2002, 12, 14 )
572
- )
573
- ---
574
- test: legacy Timestamps test
575
- todo: true
576
- spec: legacy D4
577
- yaml: |
578
- canonical: 2001-12-15T02:59:43.00Z
579
- iso8601: 2001-02-28t21:59:43.00-05:00
580
- spaced: 2001-12-14 21:59:43.00 -05:00
581
- date: 2002-12-14
582
- php: |
583
- array(
584
- 'canonical' => Time::utc( 2001, 12, 15, 2, 59, 43, 0 ),
585
- 'iso8601' => YAML::mktime( 2001, 2, 28, 21, 59, 43, 0, "-05:00" ),
586
- 'spaced' => YAML::mktime( 2001, 12, 14, 21, 59, 43, 0, "-05:00" ),
587
- 'date' => Date.new( 2002, 12, 14 )
588
- )
589
- ---
590
- test: Various explicit families
591
- todo: true
592
- spec: 2.23
593
- yaml: |
594
- not-date: !str 2002-04-28
595
- picture: !binary |
596
- R0lGODlhDAAMAIQAAP//9/X
597
- 17unp5WZmZgAAAOfn515eXv
598
- Pz7Y6OjuDg4J+fn5OTk6enp
599
- 56enmleECcgggoBADs=
600
-
601
- application specific tag: !!something |
602
- The semantics of the tag
603
- above may be different for
604
- different documents.
605
-
606
- ruby-setup: |
607
- YAML.add_private_type( "something" ) do |type, val|
608
- "SOMETHING: #{val}"
609
- end
610
- ruby: |
611
- {
612
- 'not-date' => '2002-04-28',
613
- '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;",
614
- 'application specific tag' => "SOMETHING: The semantics of the tag\nabove may be different for\ndifferent documents.\n"
615
- }
616
- ---
617
- test: Application specific family
618
- todo: true
619
- spec: 2.24
620
- yaml: |
621
- # Establish a tag prefix
622
- --- !clarkevans.com,2002/graph/^shape
623
- # Use the prefix: shorthand for
624
- # !clarkevans.com,2002/graph/circle
625
- - !^circle
626
- center: &ORIGIN {x: 73, 'y': 129}
627
- radius: 7
628
- - !^line # !clarkevans.com,2002/graph/line
629
- start: *ORIGIN
630
- finish: { x: 89, 'y': 102 }
631
- - !^label
632
- start: *ORIGIN
633
- color: 0xFFEEBB
634
- value: Pretty vector drawing.
635
- ruby-setup: |
636
- YAML.add_domain_type( "clarkevans.com,2002", 'graph/shape' ) { |type, val|
637
- if Array === val
638
- val << "Shape Container"
639
- val
640
- else
641
- raise YAML::Error, "Invalid graph of class #{ val.class }: " + val.inspect
642
- end
643
- }
644
- one_shape_proc = Proc.new { |type, val|
645
- scheme, domain, type = type.split( /:/, 3 )
646
- if val.is_a? ::Hash
647
- val['TYPE'] = "Shape: #{type}"
648
- val
649
- else
650
- raise YAML::Error, "Invalid graph of class #{ val.class }: " + val.inspect
651
- end
652
- }
653
- YAML.add_domain_type( "clarkevans.com,2002", 'graph/circle', &one_shape_proc )
654
- YAML.add_domain_type( "clarkevans.com,2002", 'graph/line', &one_shape_proc )
655
- YAML.add_domain_type( "clarkevans.com,2002", 'graph/label', &one_shape_proc )
656
- ruby: |
657
- [
658
- {
659
- "radius" => 7,
660
- "center"=>
661
- {
662
- "x" => 73,
663
- "y" => 129
664
- },
665
- "TYPE" => "Shape: graph/circle"
666
- }, {
667
- "finish" =>
668
- {
669
- "x" => 89,
670
- "y" => 102
671
- },
672
- "TYPE" => "Shape: graph/line",
673
- "start" =>
674
- {
675
- "x" => 73,
676
- "y" => 129
677
- }
678
- }, {
679
- "TYPE" => "Shape: graph/label",
680
- "value" => "Pretty vector drawing.",
681
- "start" =>
682
- {
683
- "x" => 73,
684
- "y" => 129
685
- },
686
- "color" => 16772795
687
- },
688
- "Shape Container"
689
- ]
690
- # ---
691
- # test: Unordered set
692
- # spec: 2.25
693
- # yaml: |
694
- # # sets are represented as a
695
- # # mapping where each key is
696
- # # associated with the empty string
697
- # --- !set
698
- # ? Mark McGwire
699
- # ? Sammy Sosa
700
- # ? Ken Griff
701
- ---
702
- test: Ordered mappings
703
- todo: true
704
- spec: 2.26
705
- yaml: |
706
- # ordered maps are represented as
707
- # a sequence of mappings, with
708
- # each mapping having one key
709
- --- !omap
710
- - Mark McGwire: 65
711
- - Sammy Sosa: 63
712
- - Ken Griffy: 58
713
- ruby: |
714
- YAML::Omap[
715
- 'Mark McGwire', 65,
716
- 'Sammy Sosa', 63,
717
- 'Ken Griffy', 58
718
- ]
719
- ---
720
- test: Invoice
721
- dump_skip: true
722
- spec: 2.27
723
- yaml: |
724
- --- !clarkevans.com,2002/^invoice
725
- invoice: 34843
726
- date : 2001-01-23
727
- bill-to: &id001
728
- given : Chris
729
- family : Dumars
730
- address:
731
- lines: |
732
- 458 Walkman Dr.
733
- Suite #292
734
- city : Royal Oak
735
- state : MI
736
- postal : 48046
737
- ship-to: *id001
738
- product:
739
- -
740
- sku : BL394D
741
- quantity : 4
742
- description : Basketball
743
- price : 450.00
744
- -
745
- sku : BL4438H
746
- quantity : 1
747
- description : Super Hoop
748
- price : 2392.00
749
- tax : 251.42
750
- total: 4443.52
751
- comments: >
752
- Late afternoon is best.
753
- Backup contact is Nancy
754
- Billsmer @ 338-4338.
755
- php: |
756
- array(
757
- 'invoice' => 34843, 'date' => mktime(0, 0, 0, 1, 23, 2001),
758
- 'bill-to' =>
759
- array( 'given' => 'Chris', 'family' => 'Dumars', 'address' => array( 'lines' => "458 Walkman Dr.\nSuite #292\n", 'city' => 'Royal Oak', 'state' => 'MI', 'postal' => 48046 ) )
760
- , 'ship-to' =>
761
- array( 'given' => 'Chris', 'family' => 'Dumars', 'address' => array( 'lines' => "458 Walkman Dr.\nSuite #292\n", 'city' => 'Royal Oak', 'state' => 'MI', 'postal' => 48046 ) )
762
- , 'product' =>
763
- array(
764
- array( 'sku' => 'BL394D', 'quantity' => 4, 'description' => 'Basketball', 'price' => 450.00 ),
765
- array( 'sku' => 'BL4438H', 'quantity' => 1, 'description' => 'Super Hoop', 'price' => 2392.00 )
766
- ),
767
- 'tax' => 251.42, 'total' => 4443.52,
768
- 'comments' => "Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338.\n"
769
- )
770
- ---
771
- test: Log file
772
- todo: true
773
- spec: 2.28
774
- yaml: |
775
- ---
776
- Time: 2001-11-23 15:01:42 -05:00
777
- User: ed
778
- Warning: >
779
- This is an error message
780
- for the log file
781
- ---
782
- Time: 2001-11-23 15:02:31 -05:00
783
- User: ed
784
- Warning: >
785
- A slightly different error
786
- message.
787
- ---
788
- Date: 2001-11-23 15:03:17 -05:00
789
- User: ed
790
- Fatal: >
791
- Unknown variable "bar"
792
- Stack:
793
- - file: TopClass.py
794
- line: 23
795
- code: |
796
- x = MoreObject("345\n")
797
- - file: MoreClass.py
798
- line: 58
799
- code: |-
800
- foo = bar
801
- ruby: |
802
- y = YAML::Stream.new
803
- y.add( { 'Time' => YAML::mktime( 2001, 11, 23, 15, 01, 42, 00, "-05:00" ),
804
- 'User' => 'ed', 'Warning' => "This is an error message for the log file\n" } )
805
- y.add( { 'Time' => YAML::mktime( 2001, 11, 23, 15, 02, 31, 00, "-05:00" ),
806
- 'User' => 'ed', 'Warning' => "A slightly different error message.\n" } )
807
- y.add( { 'Date' => YAML::mktime( 2001, 11, 23, 15, 03, 17, 00, "-05:00" ),
808
- 'User' => 'ed', 'Fatal' => "Unknown variable \"bar\"\n",
809
- 'Stack' => [
810
- { 'file' => 'TopClass.py', 'line' => 23, 'code' => "x = MoreObject(\"345\\n\")\n" },
811
- { 'file' => 'MoreClass.py', 'line' => 58, 'code' => "foo = bar" } ] } )
812
- documents: 3
813
-
814
- ---
815
- test: Throwaway comments
816
- yaml: |
817
- ### These are four throwaway comment ###
818
-
819
- ### lines (the second line is empty). ###
820
- this: | # Comments may trail lines.
821
- contains three lines of text.
822
- The third one starts with a
823
- # character. This isn't a comment.
824
-
825
- # These are three throwaway comment
826
- # lines (the first line is empty).
827
- php: |
828
- array(
829
- 'this' => "contains three lines of text.\nThe third one starts with a\n# character. This isn't a comment.\n"
830
- )
831
- ---
832
- test: Document with a single value
833
- todo: true
834
- yaml: |
835
- --- >
836
- This YAML stream contains a single text value.
837
- The next stream is a log file - a sequence of
838
- log entries. Adding an entry to the log is a
839
- simple matter of appending it at the end.
840
- ruby: |
841
- "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"
842
- ---
843
- test: Document stream
844
- todo: true
845
- yaml: |
846
- ---
847
- at: 2001-08-12 09:25:00.00 Z
848
- type: GET
849
- HTTP: '1.0'
850
- url: '/index.html'
851
- ---
852
- at: 2001-08-12 09:25:10.00 Z
853
- type: GET
854
- HTTP: '1.0'
855
- url: '/toc.html'
856
- ruby: |
857
- y = YAML::Stream.new
858
- y.add( {
859
- 'at' => Time::utc( 2001, 8, 12, 9, 25, 00 ),
860
- 'type' => 'GET',
861
- 'HTTP' => '1.0',
862
- 'url' => '/index.html'
863
- } )
864
- y.add( {
865
- 'at' => Time::utc( 2001, 8, 12, 9, 25, 10 ),
866
- 'type' => 'GET',
867
- 'HTTP' => '1.0',
868
- 'url' => '/toc.html'
869
- } )
870
- documents: 2
871
-
872
- ---
873
- test: Top level mapping
874
- yaml: |
875
- # This stream is an example of a top-level mapping.
876
- invoice : 34843
877
- date : 2001-01-23
878
- total : 4443.52
879
- php: |
880
- array(
881
- 'invoice' => 34843,
882
- 'date' => mktime(0, 0, 0, 1, 23, 2001),
883
- 'total' => 4443.52
884
- )
885
- ---
886
- test: Single-line documents
887
- todo: true
888
- yaml: |
889
- # The following is a sequence of three documents.
890
- # The first contains an empty mapping, the second
891
- # an empty sequence, and the last an empty string.
892
- --- {}
893
- --- [ ]
894
- --- ''
895
- ruby: |
896
- y = YAML::Stream.new
897
- y.add( {} )
898
- y.add( [] )
899
- y.add( '' )
900
- documents: 3
901
-
902
- ---
903
- test: Document with pause
904
- todo: true
905
- yaml: |
906
- # A communication channel based on a YAML stream.
907
- ---
908
- sent at: 2002-06-06 11:46:25.10 Z
909
- payload: Whatever
910
- # Receiver can process this as soon as the following is sent:
911
- ...
912
- # Even if the next message is sent long after:
913
- ---
914
- sent at: 2002-06-06 12:05:53.47 Z
915
- payload: Whatever
916
- ...
917
- ruby: |
918
- y = YAML::Stream.new
919
- y.add(
920
- { 'sent at' => YAML::mktime( 2002, 6, 6, 11, 46, 25, 0.10 ),
921
- 'payload' => 'Whatever' }
922
- )
923
- y.add(
924
- { "payload" => "Whatever", "sent at" => YAML::mktime( 2002, 6, 6, 12, 5, 53, 0.47 ) }
925
- )
926
- documents: 2
927
-
928
- ---
929
- test: Explicit typing
930
- yaml: |
931
- integer: 12
932
- also int: ! "12"
933
- string: !str 12
934
- php: |
935
- array( 'integer' => 12, 'also int' => 12, 'string' => '12' )
936
- ---
937
- test: Private types
938
- todo: true
939
- yaml: |
940
- # Both examples below make use of the 'x-private:ball'
941
- # type family URI, but with different semantics.
942
- ---
943
- pool: !!ball
944
- number: 8
945
- color: black
946
- ---
947
- bearing: !!ball
948
- material: steel
949
- ruby: |
950
- y = YAML::Stream.new
951
- y.add( { 'pool' =>
952
- YAML::PrivateType.new( 'ball',
953
- { 'number' => 8, 'color' => 'black' } ) }
954
- )
955
- y.add( { 'bearing' =>
956
- YAML::PrivateType.new( 'ball',
957
- { 'material' => 'steel' } ) }
958
- )
959
- documents: 2
960
-
961
- ---
962
- test: Type family under yaml.org
963
- yaml: |
964
- # The URI is 'tag:yaml.org,2002:str'
965
- - !str a Unicode string
966
- php: |
967
- array( 'a Unicode string' )
968
- ---
969
- test: Type family under perl.yaml.org
970
- todo: true
971
- yaml: |
972
- # The URI is 'tag:perl.yaml.org,2002:Text::Tabs'
973
- - !perl/Text::Tabs {}
974
- ruby: |
975
- [ YAML::DomainType.new( 'perl.yaml.org,2002', 'Text::Tabs', {} ) ]
976
- ---
977
- test: Type family under clarkevans.com
978
- todo: true
979
- yaml: |
980
- # The URI is 'tag:clarkevans.com,2003-02:timesheet'
981
- - !clarkevans.com,2003-02/timesheet {}
982
- ruby: |
983
- [ YAML::DomainType.new( 'clarkevans.com,2003-02', 'timesheet', {} ) ]
984
- ---
985
- test: URI Escaping
986
- todo: true
987
- yaml: |
988
- same:
989
- - !domain.tld,2002/type\x30 value
990
- - !domain.tld,2002/type0 value
991
- different: # As far as the YAML parser is concerned
992
- - !domain.tld,2002/type%30 value
993
- - !domain.tld,2002/type0 value
994
- ruby-setup: |
995
- YAML.add_domain_type( "domain.tld,2002", "type0" ) { |type, val|
996
- "ONE: #{val}"
997
- }
998
- YAML.add_domain_type( "domain.tld,2002", "type%30" ) { |type, val|
999
- "TWO: #{val}"
1000
- }
1001
- ruby: |
1002
- { 'same' => [ 'ONE: value', 'ONE: value' ], 'different' => [ 'TWO: value', 'ONE: value' ] }
1003
- ---
1004
- test: URI Prefixing
1005
- todo: true
1006
- yaml: |
1007
- # 'tag:domain.tld,2002:invoice' is some type family.
1008
- invoice: !domain.tld,2002/^invoice
1009
- # 'seq' is shorthand for 'tag:yaml.org,2002:seq'.
1010
- # This does not effect '^customer' below
1011
- # because it is does not specify a prefix.
1012
- customers: !seq
1013
- # '^customer' is shorthand for the full
1014
- # notation 'tag:domain.tld,2002:customer'.
1015
- - !^customer
1016
- given : Chris
1017
- family : Dumars
1018
- ruby-setup: |
1019
- YAML.add_domain_type( "domain.tld,2002", /(invoice|customer)/ ) { |type, val|
1020
- if val.is_a? ::Hash
1021
- scheme, domain, type = type.split( /:/, 3 )
1022
- val['type'] = "domain #{type}"
1023
- val
1024
- else
1025
- raise YAML::Error, "Not a Hash in domain.tld/invoice: " + val.inspect
1026
- end
1027
- }
1028
- ruby: |
1029
- { "invoice"=> { "customers"=> [ { "given"=>"Chris", "type"=>"domain customer", "family"=>"Dumars" } ], "type"=>"domain invoice" } }
1030
-
1031
- ---
1032
- test: Overriding anchors
1033
- yaml: |
1034
- anchor : &A001 This scalar has an anchor.
1035
- override : &A001 >
1036
- The alias node below is a
1037
- repeated use of this value.
1038
- alias : *A001
1039
- php: |
1040
- array( 'anchor' => 'This scalar has an anchor.',
1041
- 'override' => "The alias node below is a repeated use of this value.\n",
1042
- 'alias' => "The alias node below is a repeated use of this value.\n" )
1043
- ---
1044
- test: Flow and block formatting
1045
- todo: true
1046
- yaml: |
1047
- empty: []
1048
- flow: [ one, two, three # May span lines,
1049
- , four, # indentation is
1050
- five ] # mostly ignored.
1051
- block:
1052
- - First item in top sequence
1053
- -
1054
- - Subordinate sequence entry
1055
- - >
1056
- A folded sequence entry
1057
- - Sixth item in top sequence
1058
- ruby: |
1059
- { 'empty' => [], 'flow' => [ 'one', 'two', 'three', 'four', 'five' ],
1060
- 'block' => [ 'First item in top sequence', [ 'Subordinate sequence entry' ],
1061
- "A folded sequence entry\n", 'Sixth item in top sequence' ] }
1062
- ---
1063
- test: Complete mapping test
1064
- todo: true
1065
- yaml: |
1066
- empty: {}
1067
- flow: { one: 1, two: 2 }
1068
- spanning: { one: 1,
1069
- two: 2 }
1070
- block:
1071
- first : First entry
1072
- second:
1073
- key: Subordinate mapping
1074
- third:
1075
- - Subordinate sequence
1076
- - { }
1077
- - Previous mapping is empty.
1078
- - A key: value pair in a sequence.
1079
- A second: key:value pair.
1080
- - The previous entry is equal to the following one.
1081
- -
1082
- A key: value pair in a sequence.
1083
- A second: key:value pair.
1084
- !float 12 : This key is a float.
1085
- ? >
1086
- ?
1087
- : This key had to be protected.
1088
- "\a" : This key had to be escaped.
1089
- ? >
1090
- This is a
1091
- multi-line
1092
- folded key
1093
- : Whose value is
1094
- also multi-line.
1095
- ? this also works as a key
1096
- : with a value at the next line.
1097
- ?
1098
- - This key
1099
- - is a sequence
1100
- :
1101
- - With a sequence value.
1102
- ?
1103
- This: key
1104
- is a: mapping
1105
- :
1106
- with a: mapping value.
1107
- ruby: |
1108
- { 'empty' => {}, 'flow' => { 'one' => 1, 'two' => 2 },
1109
- 'spanning' => { 'one' => 1, 'two' => 2 },
1110
- 'block' => { 'first' => 'First entry', 'second' =>
1111
- { 'key' => 'Subordinate mapping' }, 'third' =>
1112
- [ 'Subordinate sequence', {}, 'Previous mapping is empty.',
1113
- { 'A key' => 'value pair in a sequence.', 'A second' => 'key:value pair.' },
1114
- 'The previous entry is equal to the following one.',
1115
- { 'A key' => 'value pair in a sequence.', 'A second' => 'key:value pair.' } ],
1116
- 12.0 => 'This key is a float.', "?\n" => 'This key had to be protected.',
1117
- "\a" => 'This key had to be escaped.',
1118
- "This is a multi-line folded key\n" => "Whose value is also multi-line.",
1119
- 'this also works as a key' => 'with a value at the next line.',
1120
- [ 'This key', 'is a sequence' ] => [ 'With a sequence value.' ] } }
1121
- # Couldn't recreate map exactly, so we'll do a detailed check to be sure it's entact
1122
- obj_y['block'].keys.each { |k|
1123
- if Hash === k
1124
- v = obj_y['block'][k]
1125
- if k['This'] == 'key' and k['is a'] == 'mapping' and v['with a'] == 'mapping value.'
1126
- obj_r['block'][k] = v
1127
- end
1128
- end
1129
- }
1130
- ---
1131
- test: Literal explicit indentation
1132
- yaml: |
1133
- # Explicit indentation must
1134
- # be given in all the three
1135
- # following cases.
1136
- leading spaces: |2
1137
- This value starts with four spaces.
1138
-
1139
- leading line break: |2
1140
-
1141
- This value starts with a line break.
1142
-
1143
- leading comment indicator: |2
1144
- # first line starts with a
1145
- # character.
1146
-
1147
- # Explicit indentation may
1148
- # also be given when it is
1149
- # not required.
1150
- redundant: |2
1151
- This value is indented 2 spaces.
1152
- php: |
1153
- array(
1154
- 'leading spaces' => " This value starts with four spaces.\n",
1155
- 'leading line break' => "\nThis value starts with a line break.\n",
1156
- 'leading comment indicator' => "# first line starts with a\n# character.\n",
1157
- 'redundant' => "This value is indented 2 spaces.\n"
1158
- )
1159
- ---
1160
- test: Chomping and keep modifiers
1161
- yaml: |
1162
- clipped: |
1163
- This has one newline.
1164
-
1165
- same as "clipped" above: "This has one newline.\n"
1166
-
1167
- stripped: |-
1168
- This has no newline.
1169
-
1170
- same as "stripped" above: "This has no newline."
1171
-
1172
- kept: |+
1173
- This has two newlines.
1174
-
1175
- same as "kept" above: "This has two newlines.\n\n"
1176
- php: |
1177
- array(
1178
- 'clipped' => "This has one newline.\n",
1179
- 'same as "clipped" above' => "This has one newline.\n",
1180
- 'stripped' => 'This has no newline.',
1181
- 'same as "stripped" above' => 'This has no newline.',
1182
- 'kept' => "This has two newlines.\n\n",
1183
- 'same as "kept" above' => "This has two newlines.\n\n"
1184
- )
1185
- ---
1186
- test: Literal combinations
1187
- todo: true
1188
- yaml: |
1189
- empty: |
1190
-
1191
- literal: |
1192
- The \ ' " characters may be
1193
- freely used. Leading white
1194
- space is significant.
1195
-
1196
- Line breaks are significant.
1197
- Thus this value contains one
1198
- empty line and ends with a
1199
- single line break, but does
1200
- not start with one.
1201
-
1202
- is equal to: "The \\ ' \" characters may \
1203
- be\nfreely used. Leading white\n space \
1204
- is significant.\n\nLine breaks are \
1205
- significant.\nThus this value contains \
1206
- one\nempty line and ends with a\nsingle \
1207
- line break, but does\nnot start with one.\n"
1208
-
1209
- # Comments may follow a block
1210
- # scalar value. They must be
1211
- # less indented.
1212
-
1213
- # Modifiers may be combined in any order.
1214
- indented and chomped: |2-
1215
- This has no newline.
1216
-
1217
- also written as: |-2
1218
- This has no newline.
1219
-
1220
- both are equal to: " This has no newline."
1221
- php: |
1222
- array(
1223
- 'empty' => '',
1224
- 'literal' => "The \\ ' \" characters may be\nfreely used. Leading white\n space " +
1225
- "is significant.\n\nLine breaks are significant.\nThus this value contains one\n" +
1226
- "empty line and ends with a\nsingle line break, but does\nnot start with one.\n",
1227
- 'is equal to' => "The \\ ' \" characters may be\nfreely used. Leading white\n space " +
1228
- "is significant.\n\nLine breaks are significant.\nThus this value contains one\n" +
1229
- "empty line and ends with a\nsingle line break, but does\nnot start with one.\n",
1230
- 'indented and chomped' => ' This has no newline.',
1231
- 'also written as' => ' This has no newline.',
1232
- 'both are equal to' => ' This has no newline.'
1233
- )
1234
- ---
1235
- test: Folded combinations
1236
- todo: true
1237
- yaml: |
1238
- empty: >
1239
-
1240
- one paragraph: >
1241
- Line feeds are converted
1242
- to spaces, so this value
1243
- contains no line breaks
1244
- except for the final one.
1245
-
1246
- multiple paragraphs: >2
1247
-
1248
- An empty line, either
1249
- at the start or in
1250
- the value:
1251
-
1252
- Is interpreted as a
1253
- line break. Thus this
1254
- value contains three
1255
- line breaks.
1256
-
1257
- indented text: >
1258
- This is a folded
1259
- paragraph followed
1260
- by a list:
1261
- * first entry
1262
- * second entry
1263
- Followed by another
1264
- folded paragraph,
1265
- another list:
1266
-
1267
- * first entry
1268
-
1269
- * second entry
1270
-
1271
- And a final folded
1272
- paragraph.
1273
-
1274
- above is equal to: |
1275
- This is a folded paragraph followed by a list:
1276
- * first entry
1277
- * second entry
1278
- Followed by another folded paragraph, another list:
1279
-
1280
- * first entry
1281
-
1282
- * second entry
1283
-
1284
- And a final folded paragraph.
1285
-
1286
- # Explicit comments may follow
1287
- # but must be less indented.
1288
- php: |
1289
- array(
1290
- 'empty' => '',
1291
- 'one paragraph' => 'Line feeds are converted to spaces, so this value'.
1292
- " contains no line breaks except for the final one.\n",
1293
- 'multiple paragraphs' => "\nAn empty line, either at the start or in the value:\n".
1294
- "Is interpreted as a line break. Thus this value contains three line breaks.\n",
1295
- 'indented text' => "This is a folded paragraph followed by a list:\n".
1296
- " * first entry\n * second entry\nFollowed by another folded paragraph, ".
1297
- "another list:\n\n * first entry\n\n * second entry\n\nAnd a final folded paragraph.\n",
1298
- 'above is equal to' => "This is a folded paragraph followed by a list:\n".
1299
- " * first entry\n * second entry\nFollowed by another folded paragraph, ".
1300
- "another list:\n\n * first entry\n\n * second entry\n\nAnd a final folded paragraph.\n"
1301
- )
1302
- ---
1303
- test: Single quotes
1304
- todo: true
1305
- yaml: |
1306
- empty: ''
1307
- second: '! : \ etc. can be used freely.'
1308
- third: 'a single quote '' must be escaped.'
1309
- span: 'this contains
1310
- six spaces
1311
-
1312
- and one
1313
- line break'
1314
- is same as: "this contains six spaces\nand one line break"
1315
- php: |
1316
- array(
1317
- 'empty' => '',
1318
- 'second' => '! : \\ etc. can be used freely.',
1319
- 'third' => "a single quote ' must be escaped.",
1320
- 'span' => "this contains six spaces\nand one line break",
1321
- 'is same as' => "this contains six spaces\nand one line break"
1322
- )
1323
- ---
1324
- test: Double quotes
1325
- todo: true
1326
- yaml: |
1327
- empty: ""
1328
- second: "! : etc. can be used freely."
1329
- third: "a \" or a \\ must be escaped."
1330
- fourth: "this value ends with an LF.\n"
1331
- span: "this contains
1332
- four \
1333
- spaces"
1334
- is equal to: "this contains four spaces"
1335
- php: |
1336
- array(
1337
- 'empty' => '',
1338
- 'second' => '! : etc. can be used freely.',
1339
- 'third' => 'a " or a \\ must be escaped.',
1340
- 'fourth' => "this value ends with an LF.\n",
1341
- 'span' => "this contains four spaces",
1342
- 'is equal to' => "this contains four spaces"
1343
- )
1344
- ---
1345
- test: Unquoted strings
1346
- todo: true
1347
- yaml: |
1348
- first: There is no unquoted empty string.
1349
-
1350
- second: 12 ## This is an integer.
1351
-
1352
- third: !str 12 ## This is a string.
1353
-
1354
- span: this contains
1355
- six spaces
1356
-
1357
- and one
1358
- line break
1359
-
1360
- indicators: this has no comments.
1361
- #:foo and bar# are
1362
- both text.
1363
-
1364
- flow: [ can span
1365
- lines, # comment
1366
- like
1367
- this ]
1368
-
1369
- note: { one-line keys: but multi-line values }
1370
-
1371
- php: |
1372
- array(
1373
- 'first' => 'There is no unquoted empty string.',
1374
- 'second' => 12,
1375
- 'third' => '12',
1376
- 'span' => "this contains six spaces\nand one line break",
1377
- 'indicators' => "this has no comments. #:foo and bar# are both text.",
1378
- 'flow' => [ 'can span lines', 'like this' ],
1379
- 'note' => { 'one-line keys' => 'but multi-line values' }
1380
- )
1381
- ---
1382
- test: Spanning sequences
1383
- todo: true
1384
- yaml: |
1385
- # The following are equal seqs
1386
- # with different identities.
1387
- flow: [ one, two ]
1388
- spanning: [ one,
1389
- two ]
1390
- block:
1391
- - one
1392
- - two
1393
- php: |
1394
- array(
1395
- 'flow' => [ 'one', 'two' ],
1396
- 'spanning' => [ 'one', 'two' ],
1397
- 'block' => [ 'one', 'two' ]
1398
- )
1399
- ---
1400
- test: Flow mappings
1401
- yaml: |
1402
- # The following are equal maps
1403
- # with different identities.
1404
- flow: { one: 1, two: 2 }
1405
- block:
1406
- one: 1
1407
- two: 2
1408
- php: |
1409
- array(
1410
- 'flow' => array( 'one' => 1, 'two' => 2 ),
1411
- 'block' => array( 'one' => 1, 'two' => 2 )
1412
- )
1413
- ---
1414
- test: Representations of 12
1415
- todo: true
1416
- yaml: |
1417
- - 12 # An integer
1418
- # The following scalars
1419
- # are loaded to the
1420
- # string value '1' '2'.
1421
- - !str 12
1422
- - '12'
1423
- - "12"
1424
- - "\
1425
- 1\
1426
- 2\
1427
- "
1428
- # Strings containing paths and regexps can be unquoted:
1429
- - /foo/bar
1430
- - d:/foo/bar
1431
- - foo/bar
1432
- - /a.*b/
1433
- php: |
1434
- array( 12, '12', '12', '12', '12', '/foo/bar', 'd:/foo/bar', 'foo/bar', '/a.*b/' )
1435
- ---
1436
- test: "Null"
1437
- todo: true
1438
- yaml: |
1439
- canonical: ~
1440
-
1441
- english: null
1442
-
1443
- # This sequence has five
1444
- # entries, two with values.
1445
- sparse:
1446
- - ~
1447
- - 2nd entry
1448
- - Null
1449
- - 4th entry
1450
- -
1451
-
1452
- four: This mapping has five keys,
1453
- only two with values.
1454
-
1455
- php: |
1456
- array (
1457
- 'canonical' => null,
1458
- 'english' => null,
1459
- 'sparse' => array( null, '2nd entry', null, '4th entry', null ]),
1460
- 'four' => 'This mapping has five keys, only two with values.'
1461
- )
1462
- ---
1463
- test: Omap
1464
- todo: true
1465
- yaml: |
1466
- # Explicitly typed dictionary.
1467
- Bestiary: !omap
1468
- - aardvark: African pig-like ant eater. Ugly.
1469
- - anteater: South-American ant eater. Two species.
1470
- - anaconda: South-American constrictor snake. Scary.
1471
- # Etc.
1472
- ruby: |
1473
- {
1474
- 'Bestiary' => YAML::Omap[
1475
- 'aardvark', 'African pig-like ant eater. Ugly.',
1476
- 'anteater', 'South-American ant eater. Two species.',
1477
- 'anaconda', 'South-American constrictor snake. Scary.'
1478
- ]
1479
- }
1480
-
1481
- ---
1482
- test: Pairs
1483
- todo: true
1484
- yaml: |
1485
- # Explicitly typed pairs.
1486
- tasks: !pairs
1487
- - meeting: with team.
1488
- - meeting: with boss.
1489
- - break: lunch.
1490
- - meeting: with client.
1491
- ruby: |
1492
- {
1493
- 'tasks' => YAML::Pairs[
1494
- 'meeting', 'with team.',
1495
- 'meeting', 'with boss.',
1496
- 'break', 'lunch.',
1497
- 'meeting', 'with client.'
1498
- ]
1499
- }
1500
-
1501
- ---
1502
- test: Set
1503
- todo: true
1504
- yaml: |
1505
- # Explicitly typed set.
1506
- baseball players: !set
1507
- Mark McGwire:
1508
- Sammy Sosa:
1509
- Ken Griffey:
1510
- ruby: |
1511
- {
1512
- 'baseball players' => YAML::Set[
1513
- 'Mark McGwire', nil,
1514
- 'Sammy Sosa', nil,
1515
- 'Ken Griffey', nil
1516
- ]
1517
- }
1518
-
1519
- ---
1520
- test: Boolean
1521
- yaml: |
1522
- false: used as key
1523
- logical: true
1524
- answer: false
1525
- php: |
1526
- array(
1527
- false => 'used as key',
1528
- 'logical' => true,
1529
- 'answer' => false
1530
- )
1531
- ---
1532
- test: Integer
1533
- yaml: |
1534
- canonical: 12345
1535
- decimal: +12,345
1536
- octal: 014
1537
- hexadecimal: 0xC
1538
- php: |
1539
- array(
1540
- 'canonical' => 12345,
1541
- 'decimal' => 12345,
1542
- 'octal' => 12,
1543
- 'hexadecimal' => 12
1544
- )
1545
- ---
1546
- test: Float
1547
- yaml: |
1548
- canonical: 1.23015e+3
1549
- exponential: 12.3015e+02
1550
- fixed: 1,230.15
1551
- negative infinity: -.inf
1552
- not a number: .NaN
1553
- php: |
1554
- array(
1555
- 'canonical' => 1230.15,
1556
- 'exponential' => 1230.15,
1557
- 'fixed' => 1230.15,
1558
- 'negative infinity' => log(0),
1559
- 'not a number' => -log(0)
1560
- )
1561
- ---
1562
- test: Timestamp
1563
- todo: true
1564
- yaml: |
1565
- canonical: 2001-12-15T02:59:43.1Z
1566
- valid iso8601: 2001-12-14t21:59:43.10-05:00
1567
- space separated: 2001-12-14 21:59:43.10 -05:00
1568
- date (noon UTC): 2002-12-14
1569
- ruby: |
1570
- array(
1571
- 'canonical' => YAML::mktime( 2001, 12, 15, 2, 59, 43, 0.10 ),
1572
- 'valid iso8601' => YAML::mktime( 2001, 12, 14, 21, 59, 43, 0.10, "-05:00" ),
1573
- 'space separated' => YAML::mktime( 2001, 12, 14, 21, 59, 43, 0.10, "-05:00" ),
1574
- 'date (noon UTC)' => Date.new( 2002, 12, 14 )
1575
- )
1576
- ---
1577
- test: Binary
1578
- todo: true
1579
- yaml: |
1580
- canonical: !binary "\
1581
- R0lGODlhDAAMAIQAAP//9/X17unp5WZmZgAAAOfn515eXvPz7Y6OjuDg4J+fn5\
1582
- OTk6enp56enmlpaWNjY6Ojo4SEhP/++f/++f/++f/++f/++f/++f/++f/++f/+\
1583
- +f/++f/++f/++f/++f/++SH+Dk1hZGUgd2l0aCBHSU1QACwAAAAADAAMAAAFLC\
1584
- AgjoEwnuNAFOhpEMTRiggcz4BNJHrv/zCFcLiwMWYNG84BwwEeECcgggoBADs="
1585
- base64: !binary |
1586
- R0lGODlhDAAMAIQAAP//9/X17unp5WZmZgAAAOfn515eXvPz7Y6OjuDg4J+fn5
1587
- OTk6enp56enmlpaWNjY6Ojo4SEhP/++f/++f/++f/++f/++f/++f/++f/++f/+
1588
- +f/++f/++f/++f/++f/++SH+Dk1hZGUgd2l0aCBHSU1QACwAAAAADAAMAAAFLC
1589
- AgjoEwnuNAFOhpEMTRiggcz4BNJHrv/zCFcLiwMWYNG84BwwEeECcgggoBADs=
1590
- description: >
1591
- The binary value above is a tiny arrow
1592
- encoded as a gif image.
1593
- ruby-setup: |
1594
- 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;"
1595
- ruby: |
1596
- {
1597
- 'canonical' => arrow_gif,
1598
- 'base64' => arrow_gif,
1599
- 'description' => "The binary value above is a tiny arrow encoded as a gif image.\n"
1600
- }
1601
-
1602
- ---
1603
- test: Merge key
1604
- todo: true
1605
- yaml: |
1606
- ---
1607
- - &CENTER { x: 1, y: 2 }
1608
- - &LEFT { x: 0, y: 2 }
1609
- - &BIG { r: 10 }
1610
- - &SMALL { r: 1 }
1611
-
1612
- # All the following maps are equal:
1613
-
1614
- - # Explicit keys
1615
- x: 1
1616
- y: 2
1617
- r: 10
1618
- label: center/big
1619
-
1620
- - # Merge one map
1621
- << : *CENTER
1622
- r: 10
1623
- label: center/big
1624
-
1625
- - # Merge multiple maps
1626
- << : [ *CENTER, *BIG ]
1627
- label: center/big
1628
-
1629
- - # Override
1630
- << : [ *BIG, *LEFT, *SMALL ]
1631
- x: 1
1632
- label: center/big
1633
-
1634
- ruby-setup: |
1635
- center = { 'x' => 1, 'y' => 2 }
1636
- left = { 'x' => 0, 'y' => 2 }
1637
- big = { 'r' => 10 }
1638
- small = { 'r' => 1 }
1639
- node1 = { 'x' => 1, 'y' => 2, 'r' => 10, 'label' => 'center/big' }
1640
- node2 = center.dup
1641
- node2.update( { 'r' => 10, 'label' => 'center/big' } )
1642
- node3 = big.dup
1643
- node3.update( center )
1644
- node3.update( { 'label' => 'center/big' } )
1645
- node4 = small.dup
1646
- node4.update( left )
1647
- node4.update( big )
1648
- node4.update( { 'x' => 1, 'label' => 'center/big' } )
1649
-
1650
- ruby: |
1651
- [
1652
- center, left, big, small, node1, node2, node3, node4
1653
- ]
1654
-
1655
- ---
1656
- test: Default key
1657
- todo: true
1658
- yaml: |
1659
- --- # Old schema
1660
- link with:
1661
- - library1.dll
1662
- - library2.dll
1663
- --- # New schema
1664
- link with:
1665
- - = : library1.dll
1666
- version: 1.2
1667
- - = : library2.dll
1668
- version: 2.3
1669
- ruby: |
1670
- y = YAML::Stream.new
1671
- y.add( { 'link with' => [ 'library1.dll', 'library2.dll' ] } )
1672
- obj_h = Hash[ 'version' => 1.2 ]
1673
- obj_h.default = 'library1.dll'
1674
- obj_h2 = Hash[ 'version' => 2.3 ]
1675
- obj_h2.default = 'library2.dll'
1676
- y.add( { 'link with' => [ obj_h, obj_h2 ] } )
1677
- documents: 2
1678
-
1679
- ---
1680
- test: Special keys
1681
- todo: true
1682
- yaml: |
1683
- "!": These three keys
1684
- "&": had to be quoted
1685
- "=": and are normal strings.
1686
- # NOTE: the following node should NOT be serialized this way.
1687
- encoded node :
1688
- !special '!' : '!type'
1689
- !special|canonical '&' : 12
1690
- = : value
1691
- # The proper way to serialize the above node is as follows:
1692
- node : !!type &12 value
1693
- ruby: |
1694
- { '!' => 'These three keys', '&' => 'had to be quoted',
1695
- '=' => 'and are normal strings.',
1696
- 'encoded node' => YAML::PrivateType.new( 'type', 'value' ),
1697
- 'node' => YAML::PrivateType.new( 'type', 'value' ) }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/embededPhp.yml DELETED
@@ -1 +0,0 @@
1
- value: <?php echo 1 + 2 + 3 ?>
 
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/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/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/sfComments.yml DELETED
@@ -1,73 +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')
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/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/symfony/yaml/Symfony/Component/Yaml/Tests/Fixtures/sfMergeKey.yml DELETED
@@ -1,45 +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:
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]
29
- check:
30
- <<:
31
- - *foo
32
- - *dong
33
- isit: tested
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/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/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/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/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/symfony/yaml/Symfony/Component/Yaml/Tests/InlineTest.php DELETED
@@ -1,364 +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
- /**
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()
47
- {
48
- $locale = setlocale(LC_NUMERIC, 0);
49
- if (false === $locale) {
50
- $this->markTestSkipped('Your platform does not support locales.');
51
- }
52
-
53
- $required_locales = array('fr_FR.UTF-8', 'fr_FR.UTF8', 'fr_FR.utf-8', 'fr_FR.utf8', 'French_France.1252');
54
- if (false === setlocale(LC_ALL, $required_locales)) {
55
- $this->markTestSkipped('Could not set any of required locales: '.implode(", ", $required_locales));
56
- }
57
-
58
- $this->assertEquals('1.2', Inline::dump(1.2));
59
- $this->assertContains('fr', strtolower(setlocale(LC_NUMERIC, 0)));
60
-
61
- setlocale(LC_ALL, $locale);
62
- }
63
-
64
- public function testHashStringsResemblingExponentialNumericsShouldNotBeChangedToINF()
65
- {
66
- $value = '686e444';
67
-
68
- $this->assertSame($value, Inline::parse(Inline::dump($value)));
69
- }
70
-
71
- /**
72
- * @expectedException \Symfony\Component\Yaml\Exception\ParseException
73
- */
74
- public function testParseScalarWithIncorrectlyQuotedStringShouldThrowException()
75
- {
76
- $value = "'don't do somthin' like that'";
77
- Inline::parse($value);
78
- }
79
-
80
- /**
81
- * @expectedException \Symfony\Component\Yaml\Exception\ParseException
82
- */
83
- public function testParseScalarWithIncorrectlyDoubleQuotedStringShouldThrowException()
84
- {
85
- $value = '"don"t do somthin" like that"';
86
- Inline::parse($value);
87
- }
88
-
89
- /**
90
- * @expectedException \Symfony\Component\Yaml\Exception\ParseException
91
- */
92
- public function testParseInvalidMappingKeyShouldThrowException()
93
- {
94
- $value = '{ "foo " bar": "bar" }';
95
- Inline::parse($value);
96
- }
97
-
98
- /**
99
- * @expectedException \Symfony\Component\Yaml\Exception\ParseException
100
- */
101
- public function testParseInvalidMappingShouldThrowException()
102
- {
103
- Inline::parse('[foo] bar');
104
- }
105
-
106
- /**
107
- * @expectedException \Symfony\Component\Yaml\Exception\ParseException
108
- */
109
- public function testParseInvalidSequenceShouldThrowException()
110
- {
111
- Inline::parse('{ foo: bar } bar');
112
- }
113
-
114
- public function testParseScalarWithCorrectlyQuotedStringShouldReturnString()
115
- {
116
- $value = "'don''t do somthin'' like that'";
117
- $expect = "don't do somthin' like that";
118
-
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 DELETED
@@ -1,42 +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 (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")';
26
- }
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 DELETED
@@ -1,707 +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
- * @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
- */
509
- public function testSequenceInAMapping()
510
- {
511
- Yaml::parse(<<<EOF
512
- yaml:
513
- hash: me
514
- - array stuff
515
- EOF
516
- );
517
- }
518
-
519
- /**
520
- * @expectedException \Symfony\Component\Yaml\Exception\ParseException
521
- */
522
- public function testMappingInASequence()
523
- {
524
- Yaml::parse(<<<EOF
525
- yaml:
526
- - array stuff
527
- hash: me
528
- EOF
529
- );
530
- }
531
-
532
- /**
533
- * > It is an error for two equal keys to appear in the same mapping node.
534
- * > In such a case the YAML processor may continue, ignoring the second
535
- * > `key: value` pair and issuing an appropriate warning. This strategy
536
- * > preserves a consistent information model for one-pass and random access
537
- * > applications.
538
- *
539
- * @see http://yaml.org/spec/1.2/spec.html#id2759572
540
- * @see http://yaml.org/spec/1.1/#id932806
541
- *
542
- * @covers \Symfony\Component\Yaml\Parser::parse
543
- */
544
- public function testMappingDuplicateKeyBlock()
545
- {
546
- $input = <<<EOD
547
- parent:
548
- child: first
549
- child: duplicate
550
- parent:
551
- child: duplicate
552
- child: duplicate
553
- EOD;
554
- $expected = array(
555
- 'parent' => array(
556
- 'child' => 'first',
557
- ),
558
- );
559
- $this->assertSame($expected, Yaml::parse($input));
560
- }
561
-
562
- /**
563
- * @covers \Symfony\Component\Yaml\Inline::parseMapping
564
- */
565
- public function testMappingDuplicateKeyFlow()
566
- {
567
- $input = <<<EOD
568
- parent: { child: first, child: duplicate }
569
- parent: { child: duplicate, child: duplicate }
570
- EOD;
571
- $expected = array(
572
- 'parent' => array(
573
- 'child' => 'first',
574
- ),
575
- );
576
- $this->assertSame($expected, Yaml::parse($input));
577
- }
578
-
579
- public function testEmptyValue()
580
- {
581
- $input = <<<EOF
582
- hash:
583
- EOF;
584
-
585
- $this->assertEquals(array('hash' => null), Yaml::parse($input));
586
- }
587
-
588
- public function testStringBlockWithComments()
589
- {
590
- $this->assertEquals(array('content' => <<<EOT
591
- # comment 1
592
- header
593
-
594
- # comment 2
595
- <body>
596
- <h1>title</h1>
597
- </body>
598
-
599
- footer # comment3
600
- EOT
601
- ), Yaml::parse(<<<EOF
602
- content: |
603
- # comment 1
604
- header
605
-
606
- # comment 2
607
- <body>
608
- <h1>title</h1>
609
- </body>
610
-
611
- footer # comment3
612
- EOF
613
- ));
614
- }
615
-
616
- public function testFoldedStringBlockWithComments()
617
- {
618
- $this->assertEquals(array(array('content' => <<<EOT
619
- # comment 1
620
- header
621
-
622
- # comment 2
623
- <body>
624
- <h1>title</h1>
625
- </body>
626
-
627
- footer # comment3
628
- EOT
629
- )), Yaml::parse(<<<EOF
630
- -
631
- content: |
632
- # comment 1
633
- header
634
-
635
- # comment 2
636
- <body>
637
- <h1>title</h1>
638
- </body>
639
-
640
- footer # comment3
641
- EOF
642
- ));
643
- }
644
-
645
- public function testNestedFoldedStringBlockWithComments()
646
- {
647
- $this->assertEquals(array(array(
648
- 'title' => 'some title',
649
- 'content' => <<<EOT
650
- # comment 1
651
- header
652
-
653
- # comment 2
654
- <body>
655
- <h1>title</h1>
656
- </body>
657
-
658
- footer # comment3
659
- EOT
660
- )), Yaml::parse(<<<EOF
661
- -
662
- title: some title
663
- content: |
664
- # comment 1
665
- header
666
-
667
- # comment 2
668
- <body>
669
- <h1>title</h1>
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
- }
702
- }
703
-
704
- class B
705
- {
706
- public $b = 'foo';
707
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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/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/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/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.6-dev"
29
- }
30
- }
31
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/symfony/yaml/Symfony/Component/Yaml/phpunit.xml.dist DELETED
@@ -1,24 +0,0 @@
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>
10
- <testsuite name="Symfony Yaml Component Test Suite">
11
- <directory>./Tests/</directory>
12
- </testsuite>
13
- </testsuites>
14
-
15
- <filter>
16
- <whitelist>
17
- <directory>./</directory>
18
- <exclude>
19
- <directory>./vendor</directory>
20
- <directory>./Tests</directory>
21
- </exclude>
22
- </whitelist>
23
- </filter>
24
- </phpunit>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/twig/twig/.gitignore CHANGED
@@ -1,2 +1,5 @@
 
 
1
  /ext/twig/autom4te.cache/
2
-
 
1
+ /build
2
+ /composer.lock
3
  /ext/twig/autom4te.cache/
4
+ /phpunit.xml
5
+ /vendor
vendor/twig/twig/CHANGELOG CHANGED
@@ -1,3 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  * 1.16.3 (2014-12-25)
2
 
3
  * fixed regression for dynamic parent templates
1
+ * 1.18.0 (2015-XX-XX)
2
+
3
+ * fixed some error messages where the line was wrong (unknown variables or argument names)
4
+ * added a new way to customize the main Module node (via empty nodes)
5
+ * added Twig_Environment::createTemplate() to create a template from a string
6
+ * added a profiler
7
+ * fixed filesystem loader cache when different file paths are used for the same template
8
+
9
+ * 1.17.0 (2015-01-14)
10
+
11
+ * added a 'filename' autoescaping strategy, which dynamically chooses the
12
+ autoescaping strategy for a template based on template file extension.
13
+
14
  * 1.16.3 (2014-12-25)
15
 
16
  * fixed regression for dynamic parent templates
vendor/twig/twig/composer.json CHANGED
@@ -36,7 +36,7 @@
36
  },
37
  "extra": {
38
  "branch-alias": {
39
- "dev-master": "1.16-dev"
40
  }
41
  }
42
  }
36
  },
37
  "extra": {
38
  "branch-alias": {
39
+ "dev-master": "1.18-dev"
40
  }
41
  }
42
  }
vendor/twig/twig/doc/advanced.rst CHANGED
@@ -281,7 +281,7 @@ 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;
@@ -299,7 +299,7 @@ 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,
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;
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,
vendor/twig/twig/doc/api.rst CHANGED
@@ -94,14 +94,20 @@ The following options are available:
94
  replace them with a ``null`` value. When set to ``true``, Twig throws an
95
  exception instead (default to ``false``).
96
 
97
- * ``autoescape``: If set to ``true``, auto-escaping will be enabled by default
98
- for all templates (default to ``true``). As of Twig 1.8, you can set the
99
- escaping strategy to use (``html``, ``js``, ``false`` to disable).
100
- As of Twig 1.9, you can set the escaping strategy to use (``css``, ``url``,
101
- ``html_attr``, or a PHP callback that takes the template "filename" and must
 
 
 
102
  return the escaping strategy to use -- the callback cannot be a function name
103
  to avoid collision with built-in escaping strategies).
104
 
 
 
 
105
  * ``optimizations``: A flag that indicates which optimizations to apply
106
  (default to ``-1`` -- all optimizations are enabled; set it to ``0`` to
107
  disable).
@@ -279,6 +285,9 @@ Twig comes bundled with the following extensions:
279
  * *Twig_Extension_Sandbox*: Adds a sandbox mode to the default Twig
280
  environment, making it safe to evaluate untrusted code.
281
 
 
 
 
282
  * *Twig_Extension_Optimizer*: Optimizes the node tree before compilation.
283
 
284
  The core, escaper, and optimizer extensions do not need to be added to the
@@ -447,6 +456,37 @@ the extension constructor::
447
 
448
  $sandbox = new Twig_Extension_Sandbox($policy, true);
449
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
450
  Optimizer Extension
451
  ~~~~~~~~~~~~~~~~~~~
452
 
94
  replace them with a ``null`` value. When set to ``true``, Twig throws an
95
  exception instead (default to ``false``).
96
 
97
+ * ``autoescape``: If set to ``true``, HTML auto-escaping will be enabled by
98
+ default for all templates (default to ``true``).
99
+
100
+ As of Twig 1.8, you can set the escaping strategy to use (``html``, ``js``,
101
+ ``false`` to disable).
102
+
103
+ As of Twig 1.9, you can set the escaping strategy to use (``css``, ``url``,
104
+ ``html_attr``, or a PHP callback that takes the template "filename" and must
105
  return the escaping strategy to use -- the callback cannot be a function name
106
  to avoid collision with built-in escaping strategies).
107
 
108
+ As of Twig 1.17, the ``filename`` escaping strategy determines the escaping
109
+ strategy to use for a template based on the template filename extension.
110
+
111
  * ``optimizations``: A flag that indicates which optimizations to apply
112
  (default to ``-1`` -- all optimizations are enabled; set it to ``0`` to
113
  disable).
285
  * *Twig_Extension_Sandbox*: Adds a sandbox mode to the default Twig
286
  environment, making it safe to evaluate untrusted code.
287
 
288
+ * *Twig_Extension_Profiler*: Enabled the built-in Twig profiler (as of Twig
289
+ 1.18).
290
+
291
  * *Twig_Extension_Optimizer*: Optimizes the node tree before compilation.
292
 
293
  The core, escaper, and optimizer extensions do not need to be added to the
456
 
457
  $sandbox = new Twig_Extension_Sandbox($policy, true);
458
 
459
+ Profiler Extension
460
+ ~~~~~~~~~~~~~~~~~~
461
+
462
+ .. versionadded:: 1.18
463
+ The Profile extension was added in Twig 1.18.
464
+
465
+ The ``profiler`` extension enables a profiler for Twig templates; it should
466
+ only be used on your development machines as it adds some overhead::
467
+
468
+ $profile = new Twig_Profiler_Profile();
469
+ $twig->addExtension(new Twig_Extension_Profiler($profile));
470
+
471
+ $dumper = new Twig_Profiler_Dumper_Text();
472
+ echo $dumper->dump($profile);
473
+
474
+ A profile contains information about time and memory consumption for template,
475
+ block, and macro executions.
476
+
477
+ You can also dump the data in a `Blackfire.io <https://blackfire.io/>`_
478
+ compatible format::
479
+
480
+ $dumper = new Twig_Profiler_Dumper_Blackfire();
481
+ file_put_contents('/path/to/profile.prof', $dumper->dump($profile));
482
+
483
+ Upload the profile to visualize it (create a `free account
484
+ <https://blackfire.io/signup>`_ first):
485
+
486
+ .. code-block:: sh
487
+
488
+ blackfire --slot=7 upload /path/to/profile.prof
489
+
490
  Optimizer Extension
491
  ~~~~~~~~~~~~~~~~~~~
492
 
vendor/twig/twig/doc/filters/batch.rst CHANGED
@@ -5,7 +5,7 @@
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
9
  missing items:
10
 
11
  .. code-block:: jinja
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. A second parameter can be provided and used to fill in
9
  missing items:
10
 
11
  .. code-block:: jinja
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.16.3"
19
 
20
  #include "php.h"
21
 
15
  #ifndef PHP_TWIG_H
16
  #define PHP_TWIG_H
17
 
18
+ #define PHP_TWIG_VERSION "1.18.0"
19
 
20
  #include "php.h"
21
 
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 bool $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
@@ -231,13 +231,15 @@ class Twig_Compiler implements Twig_CompilerInterface
231
 
232
  public function getDebugInfo()
233
  {
 
 
234
  return $this->debugInfo;
235
  }
236
 
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,7 +253,7 @@ class Twig_Compiler implements Twig_CompilerInterface
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
  *
231
 
232
  public function getDebugInfo()
233
  {
234
+ ksort($this->debugInfo);
235
+
236
  return $this->debugInfo;
237
  }
238
 
239
  /**
240
  * Indents the generated code.
241
  *
242
+ * @param int $step The number of indentation to add
243
  *
244
  * @return Twig_Compiler The current compiler instance
245
  */
253
  /**
254
  * Outdents the generated code.
255
  *
256
+ * @param int $step The number of indentation to remove
257
  *
258
  * @return Twig_Compiler The current compiler instance
259
  *
vendor/twig/twig/lib/Twig/Environment.php CHANGED
@@ -16,7 +16,7 @@
16
  */
17
  class Twig_Environment
18
  {
19
- const VERSION = '1.16.3';
20
 
21
  protected $charset;
22
  protected $loader;
@@ -72,6 +72,7 @@ class Twig_Environment
72
  * * false: disable auto-escaping
73
  * * true: equivalent to html
74
  * * html, js: set the autoescaping to one of the supported strategies
 
75
  * * PHP callback: a PHP callback that returns an escaping strategy based on the template "filename"
76
  *
77
  * * optimizations: A flag that indicates which optimizations to apply
@@ -154,7 +155,7 @@ class Twig_Environment
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,7 +181,7 @@ class Twig_Environment
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,7 +207,7 @@ class Twig_Environment
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
  {
@@ -223,12 +224,12 @@ class Twig_Environment
223
  return $this->cache;
224
  }
225
 
226
- /**
227
- * Sets the cache directory or false if cache is disabled.
228
- *
229
- * @param string|false $cache The absolute path to the compiled templates,
230
- * or false to disable cache
231
- */
232
  public function setCache($cache)
233
  {
234
  $this->cache = $cache ? $cache : false;
@@ -255,8 +256,8 @@ class Twig_Environment
255
  /**
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
  */
@@ -310,8 +311,8 @@ class Twig_Environment
310
  /**
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
  *
@@ -345,6 +346,41 @@ class Twig_Environment
345
  return $this->loadedTemplates[$cls] = new $cls($this);
346
  }
347
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
348
  /**
349
  * Returns true if the template is still fresh.
350
  *
@@ -352,10 +388,10 @@ class Twig_Environment
352
  * this method also checks if the enabled extensions have
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,7 +662,7 @@ class Twig_Environment
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
  {
16
  */
17
  class Twig_Environment
18
  {
19
+ const VERSION = '1.18.0';
20
 
21
  protected $charset;
22
  protected $loader;
72
  * * false: disable auto-escaping
73
  * * true: equivalent to html
74
  * * html, js: set the autoescaping to one of the supported strategies
75
+ * * filename: set the autoescaping strategy based on the template filename extension
76
  * * PHP callback: a PHP callback that returns an escaping strategy based on the template "filename"
77
  *
78
  * * optimizations: A flag that indicates which optimizations to apply
155
  /**
156
  * Checks if debug mode is enabled.
157
  *
158
+ * @return bool true if debug mode is enabled, false otherwise
159
  */
160
  public function isDebug()
161
  {
181
  /**
182
  * Checks if the auto_reload option is enabled.
183
  *
184
+ * @return bool true if auto_reload is enabled, false otherwise
185
  */
186
  public function isAutoReload()
187
  {
207
  /**
208
  * Checks if the strict_variables option is enabled.
209
  *
210
+ * @return bool true if strict_variables is enabled, false otherwise
211
  */
212
  public function isStrictVariables()
213
  {
224
  return $this->cache;
225
  }
226
 
227
+ /**
228
+ * Sets the cache directory or false if cache is disabled.
229
+ *
230
+ * @param string|false $cache The absolute path to the compiled templates,
231
+ * or false to disable cache
232
+ */
233
  public function setCache($cache)
234
  {
235
  $this->cache = $cache ? $cache : false;
256
  /**
257
  * Gets the template class associated with the given string.
258
  *
259
+ * @param string $name The name for which to calculate the template class name
260
+ * @param int $index The index if it is an embedded template
261
  *
262
  * @return string The template class name
263
  */
311
  /**
312
  * Loads a template by name.
313
  *
314
+ * @param string $name The template name
315
+ * @param int $index The index if it is an embedded template
316
  *
317
  * @return Twig_TemplateInterface A template instance representing the given template name
318
  *
346
  return $this->loadedTemplates[$cls] = new $cls($this);
347
  }
348
 
349
+ /**
350
+ * Creates a template from source.
351
+ *
352
+ * This method should not be used as a generic way to load templates.
353
+ *
354
+ * @param string $name The template name
355
+ * @param int $index The index if it is an embedded template
356
+ *
357
+ * @return Twig_Template A template instance representing the given template name
358
+ *
359
+ * @throws Twig_Error_Loader When the template cannot be found
360
+ * @throws Twig_Error_Syntax When an error occurred during compilation
361
+ */
362
+ public function createTemplate($template)
363
+ {
364
+ $name = sprintf('__string_template__%s', hash('sha256', uniqid(mt_rand(), true), false));
365
+
366
+ $loader = new Twig_Loader_Chain(array(
367
+ new Twig_Loader_Array(array($name => $template)),
368
+ $current = $this->getLoader(),
369
+ ));
370
+
371
+ $this->setLoader($loader);
372
+ try {
373
+ $template = $this->loadTemplate($name);
374
+ } catch (Exception $e) {
375
+ $this->setLoader($current);
376
+
377
+ throw $e;
378
+ }
379
+ $this->setLoader($current);
380
+
381
+ return $template;
382
+ }
383
+
384
  /**
385
  * Returns true if the template is still fresh.
386
  *
388
  * this method also checks if the enabled extensions have
389
  * not changed.
390
  *
391
+ * @param string $name The template name
392
+ * @param int $time The last modification time of the cached template
393
  *
394
+ * @return bool true if the template is fresh, false otherwise
395
  */
396
  public function isTemplateFresh($name, $time)
397
  {
662
  *
663
  * @param string $name The extension name
664
  *
665
+ * @return bool Whether the extension is registered or not
666
  */
667
  public function hasExtension($name)
668
  {
vendor/twig/twig/lib/Twig/Error.php CHANGED
@@ -111,7 +111,7 @@ class Twig_Error extends Exception
111
  /**
112
  * Gets the template line where the error occurred.
113
  *
114
- * @return int 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 int $lineno The template line
125
  */
126
  public function setTemplateLine($lineno)
127
  {
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
  {
vendor/twig/twig/lib/Twig/ExistsLoaderInterface.php CHANGED
@@ -23,7 +23,7 @@ interface Twig_ExistsLoaderInterface
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
  }
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
@@ -466,8 +466,8 @@ class Twig_ExpressionParser
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
  {
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
  {
vendor/twig/twig/lib/Twig/Extension/Core.php CHANGED
@@ -95,9 +95,9 @@ class Twig_Extension_Core extends Twig_Extension
95
  /**
96
  * Sets the default format to be used by the number_format filter.
97
  *
98
- * @param int $decimal 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
  */
102
  public function setNumberFormat($decimal, $decimalPoint, $thousandSep)
103
  {
@@ -621,8 +621,8 @@ if (version_compare(PHP_VERSION, '5.3.0', '<')) {
621
  /**
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
  */
@@ -640,8 +640,8 @@ if (version_compare(PHP_VERSION, '5.3.0', '<')) {
640
  /**
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
  */
@@ -1216,7 +1216,6 @@ function _twig_escape_html_attr_callback($matches)
1216
  * Per OWASP recommendations, we'll use hex entities for any other
1217
  * characters where a named entity does not exist.
1218
  */
1219
-
1220
  return sprintf('&#x%s;', $hex);
1221
  }
1222
 
@@ -1228,7 +1227,7 @@ if (function_exists('mb_get_info')) {
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,7 +1311,7 @@ else {
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
  {
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
  */
102
  public function setNumberFormat($decimal, $decimalPoint, $thousandSep)
103
  {
621
  /**
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
  */
640
  /**
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
  */
1216
  * Per OWASP recommendations, we'll use hex entities for any other
1217
  * characters where a named entity does not exist.
1218
  */
 
1219
  return sprintf('&#x%s;', $hex);
1220
  }
1221
 
1227
  * @param Twig_Environment $env A Twig_Environment instance
1228
  * @param mixed $thing A variable
1229
  *
1230
+ * @return int The length of the value
1231
  */
1232
  function twig_length_filter(Twig_Environment $env, $thing)
1233
  {
1311
  * @param Twig_Environment $env A Twig_Environment instance
1312
  * @param mixed $thing A variable
1313
  *
1314
+ * @return int The length of the value
1315
  */
1316
  function twig_length_filter(Twig_Environment $env, $thing)
1317
  {
vendor/twig/twig/lib/Twig/Extension/Escaper.php CHANGED
@@ -64,6 +64,10 @@ class Twig_Extension_Escaper extends Twig_Extension
64
  $defaultStrategy = 'html';
65
  }
66
 
 
 
 
 
67
  $this->defaultStrategy = $defaultStrategy;
68
  }
69
 
64
  $defaultStrategy = 'html';
65
  }
66
 
67
+ if ('filename' === $defaultStrategy) {
68
+ $defaultStrategy = array('Twig_FileExtensionEscapingStrategy', 'guess');
69
+ }
70
+
71
  $this->defaultStrategy = $defaultStrategy;
72
  }
73
 
vendor/twig/twig/lib/Twig/Extension/Profiler.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of Twig.
5
+ *
6
+ * (c) 2015 Fabien Potencier
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ class Twig_Extension_Profiler extends Twig_Extension
13
+ {
14
+ private $actives;
15
+
16
+ public function __construct(Twig_Profiler_Profile $profile)
17
+ {
18
+ $this->actives = array($profile);
19
+ }
20
+
21
+ public function enter(Twig_Profiler_Profile $profile)
22
+ {
23
+ $this->actives[0]->addProfile($profile);
24
+ array_unshift($this->actives, $profile);
25
+ }
26
+
27
+ public function leave(Twig_Profiler_Profile $profile)
28
+ {
29
+ $profile->leave();
30
+ array_shift($this->actives);
31
+
32
+ if (1 === count($this->actives)) {
33
+ $this->actives[0]->leave();
34
+ }
35
+ }
36
+
37
+ /**
38
+ * {@inheritdoc}
39
+ */
40
+ public function getNodeVisitors()
41
+ {
42
+ return array(new Twig_Profiler_NodeVisitor_Profiler($this->getName()));
43
+ }
44
+
45
+ /**
46
+ * {@inheritdoc}
47
+ */
48
+ public function getName()
49
+ {
50
+ return 'profiler';
51
+ }
52
+ }
vendor/twig/twig/lib/Twig/Extension/StringLoader.php CHANGED
@@ -43,22 +43,5 @@ class Twig_Extension_StringLoader extends Twig_Extension
43
  */
44
  function twig_template_from_string(Twig_Environment $env, $template)
45
  {
46
- $name = sprintf('__string_template__%s', hash('sha256', uniqid(mt_rand(), true), false));
47
-
48
- $loader = new Twig_Loader_Chain(array(
49
- new Twig_Loader_Array(array($name => $template)),
50
- $current = $env->getLoader(),
51
- ));
52
-
53
- $env->setLoader($loader);
54
- try {
55
- $template = $env->loadTemplate($name);
56
- } catch (Exception $e) {
57
- $env->setLoader($current);
58
-
59
- throw $e;
60
- }
61
- $env->setLoader($current);
62
-
63
- return $template;
64
  }
43
  */
44
  function twig_template_from_string(Twig_Environment $env, $template)
45
  {
46
+ return $env->createTemplate($template);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
  }
vendor/twig/twig/lib/Twig/FileExtensionEscapingStrategy.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of Twig.
5
+ *
6
+ * (c) 2015 Fabien Potencier
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ /**
13
+ * Default autoescaping strategy based on file names.
14
+ *
15
+ * This strategy sets the HTML as the default autoescaping strategy,
16
+ * but changes it based on the filename.
17
+ *
18
+ * Note that there is no runtime performance impact as the
19
+ * default autoescaping strategy is set at compilation time.
20
+ *
21
+ * @author Fabien Potencier <fabien@symfony.com>
22
+ */
23
+ class Twig_FileExtensionEscapingStrategy
24
+ {
25
+ /**
26
+ * Guesses the best autoescaping strategy based on the file name.
27
+ *
28
+ * @param string $filename The template file name
29
+ *
30
+ * @return string The escaping strategy name to use
31
+ */
32
+ public static function guess($filename)
33
+ {
34
+ if (!preg_match('{\.(js|css|txt)(?:\.[^/\\\\]+)?$}', $filename, $match)) {
35
+ return 'html';
36
+ }
37
+
38
+ switch ($match[1]) {
39
+ case 'js':
40
+ return 'js';
41
+
42
+ case 'css':
43
+ return 'css';
44
+
45
+ case 'txt':
46
+ return false;
47
+ }
48
+ }
49
+ }
vendor/twig/twig/lib/Twig/Lexer.php CHANGED
@@ -317,11 +317,9 @@ class Twig_Lexer implements Twig_LexerInterface
317
  $this->pushToken(Twig_Token::INTERPOLATION_START_TYPE);
318
  $this->moveCursor($match[0]);
319
  $this->pushState(self::STATE_INTERPOLATION);
320
-
321
  } elseif (preg_match(self::REGEX_DQ_STRING_PART, $this->code, $match, null, $this->cursor) && strlen($match[0]) > 0) {
322
  $this->pushToken(Twig_Token::STRING_TYPE, stripcslashes($match[0]));
323
  $this->moveCursor($match[0]);
324
-
325
  } elseif (preg_match(self::REGEX_DQ_STRING_DELIM, $this->code, $match, null, $this->cursor)) {
326
  list($expect, $lineno) = array_pop($this->brackets);
327
  if ($this->code[$this->cursor] != '"') {
317
  $this->pushToken(Twig_Token::INTERPOLATION_START_TYPE);
318
  $this->moveCursor($match[0]);
319
  $this->pushState(self::STATE_INTERPOLATION);
 
320
  } elseif (preg_match(self::REGEX_DQ_STRING_PART, $this->code, $match, null, $this->cursor) && strlen($match[0]) > 0) {
321
  $this->pushToken(Twig_Token::STRING_TYPE, stripcslashes($match[0]));
322
  $this->moveCursor($match[0]);
 
323
  } elseif (preg_match(self::REGEX_DQ_STRING_DELIM, $this->code, $match, null, $this->cursor)) {
324
  list($expect, $lineno) = array_pop($this->brackets);
325
  if ($this->code[$this->cursor] != '"') {
vendor/twig/twig/lib/Twig/Loader/Filesystem.php CHANGED
@@ -183,6 +183,9 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface, Twig_ExistsLoaderI
183
  }
184
 
185
  foreach ($this->paths[$namespace] as $path) {
 
 
 
186
  if (is_file($path.'/'.$shortname)) {
187
  return $this->cache[$name] = $path.'/'.$shortname;
188
  }
183
  }
184
 
185
  foreach ($this->paths[$namespace] as $path) {
186
+ if (false !== $realpath = realpath($path.'/'.$shortname)) {
187
+ return $this->cache[$name] = $realpath;
188
+ }
189
  if (is_file($path.'/'.$shortname)) {
190
  return $this->cache[$name] = $path.'/'.$shortname;
191
  }
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 bool 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
@@ -28,10 +28,10 @@ class Twig_Node implements Twig_NodeInterface
28
  * The nodes are automatically made available as properties ($this->node).
29
  * The attributes are automatically made available as array items ($this['name']).
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)
37
  {
@@ -124,7 +124,7 @@ class Twig_Node implements Twig_NodeInterface
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,7 +173,7 @@ class Twig_Node implements Twig_NodeInterface
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
  {
28
  * The nodes are automatically made available as properties ($this->node).
29
  * The attributes are automatically made available as array items ($this['name']).
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)
37
  {
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/{SandboxedModule.php → CheckSecurity.php} RENAMED
@@ -3,46 +3,32 @@
3
  /*
4
  * This file is part of Twig.
5
  *
6
- * (c) 2009 Fabien Potencier
7
- * (c) 2009 Armin Ronacher
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
  /**
14
- * Represents a module node.
15
- *
16
  * @author Fabien Potencier <fabien@symfony.com>
17
  */
18
- class Twig_Node_SandboxedModule extends Twig_Node_Module
19
  {
20
  protected $usedFilters;
21
  protected $usedTags;
22
  protected $usedFunctions;
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
-
30
  $this->usedFilters = $usedFilters;
31
  $this->usedTags = $usedTags;
32
  $this->usedFunctions = $usedFunctions;
33
- }
34
 
35
- protected function compileDisplayBody(Twig_Compiler $compiler)
36
- {
37
- $compiler->write("\$this->checkSecurity();\n");
38
-
39
- parent::compileDisplayBody($compiler);
40
  }
41
 
42
- protected function compileDisplayFooter(Twig_Compiler $compiler)
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) {
@@ -55,8 +41,6 @@ class Twig_Node_SandboxedModule extends Twig_Node_Module
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")
@@ -88,8 +72,6 @@ class Twig_Node_SandboxedModule extends Twig_Node_Module
88
  ->write("}\n\n")
89
  ->write("throw \$e;\n")
90
  ->outdent()
91
- ->write("}\n")
92
- ->outdent()
93
  ->write("}\n\n")
94
  ;
95
  }
3
  /*
4
  * This file is part of Twig.
5
  *
6
+ * (c) 2015 Fabien Potencier
 
7
  *
8
  * For the full copyright and license information, please view the LICENSE
9
  * file that was distributed with this source code.
10
  */
11
 
12
  /**
 
 
13
  * @author Fabien Potencier <fabien@symfony.com>
14
  */
15
+ class Twig_Node_CheckSecurity extends Twig_Node
16
  {
17
  protected $usedFilters;
18
  protected $usedTags;
19
  protected $usedFunctions;
20
 
21
+ public function __construct(array $usedFilters, array $usedTags, array $usedFunctions)
22
  {
 
 
 
 
23
  $this->usedFilters = $usedFilters;
24
  $this->usedTags = $usedTags;
25
  $this->usedFunctions = $usedFunctions;
 
26
 
27
+ parent::__construct();
 
 
 
 
28
  }
29
 
30
+ public function compile(Twig_Compiler $compiler)
31
  {
 
 
32
  $tags = $filters = $functions = array();
33
  foreach (array('tags', 'filters', 'functions') as $type) {
34
  foreach ($this->{'used'.ucfirst($type)} as $name => $node) {
41
  }
42
 
43
  $compiler
 
 
44
  ->write("\$tags = ")->repr(array_filter($tags))->raw(";\n")
45
  ->write("\$filters = ")->repr(array_filter($filters))->raw(";\n")
46
  ->write("\$functions = ")->repr(array_filter($functions))->raw(";\n\n")
72
  ->write("}\n\n")
73
  ->write("throw \$e;\n")
74
  ->outdent()
 
 
75
  ->write("}\n\n")
76
  ;
77
  }
vendor/twig/twig/lib/Twig/Node/Expression/Call.php CHANGED
@@ -90,6 +90,9 @@ abstract class Twig_Node_Expression_Call extends Twig_Node_Expression
90
 
91
  protected function getArguments($callable, $arguments)
92
  {
 
 
 
93
  $parameters = array();
94
  $named = false;
95
  foreach ($arguments as $name => $node) {
@@ -97,7 +100,7 @@ abstract class Twig_Node_Expression_Call extends Twig_Node_Expression
97
  $named = true;
98
  $name = $this->normalizeName($name);
99
  } elseif ($named) {
100
- throw new Twig_Error_Syntax(sprintf('Positional arguments cannot be used after named arguments for %s "%s".', $this->getAttribute('type'), $this->getAttribute('name')));
101
  }
102
 
103
  $parameters[$name] = $node;
@@ -108,7 +111,7 @@ abstract class Twig_Node_Expression_Call extends Twig_Node_Expression
108
  }
109
 
110
  if (!$callable) {
111
- throw new LogicException(sprintf('Named arguments are not supported for %s "%s".', $this->getAttribute('type'), $this->getAttribute('name')));
112
  }
113
 
114
  // manage named arguments
@@ -139,35 +142,60 @@ abstract class Twig_Node_Expression_Call extends Twig_Node_Expression
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)) {
148
- throw new Twig_Error_Syntax(sprintf('Argument "%s" is defined twice for %s "%s".', $name, $this->getAttribute('type'), $this->getAttribute('name')));
 
 
 
 
 
 
 
149
  }
150
 
 
151
  $arguments[] = $parameters[$name];
152
  unset($parameters[$name]);
 
153
  } elseif (array_key_exists($pos, $parameters)) {
 
154
  $arguments[] = $parameters[$pos];
155
  unset($parameters[$pos]);
 
156
  ++$pos;
157
  } elseif ($param->isDefaultValueAvailable()) {
158
- $arguments[] = new Twig_Node_Expression_Constant($param->getDefaultValue(), -1);
159
  } elseif ($param->isOptional()) {
160
- break;
 
 
 
 
161
  } else {
162
- throw new Twig_Error_Syntax(sprintf('Value for argument "%s" is required for %s "%s".', $name, $this->getAttribute('type'), $this->getAttribute('name')));
163
  }
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;
90
 
91
  protected function getArguments($callable, $arguments)
92
  {
93
+ $callType = $this->getAttribute('type');
94
+ $callName = $this->getAttribute('name');
95
+
96
  $parameters = array();
97
  $named = false;
98
  foreach ($arguments as $name => $node) {
100
  $named = true;
101
  $name = $this->normalizeName($name);
102
  } elseif ($named) {
103
+ throw new Twig_Error_Syntax(sprintf('Positional arguments cannot be used after named arguments for %s "%s".', $callType, $callName));
104
  }
105
 
106
  $parameters[$name] = $node;
111
  }
112
 
113
  if (!$callable) {
114
+ throw new LogicException(sprintf('Named arguments are not supported for %s "%s".', $callType, $callName));
115
  }
116
 
117
  // manage named arguments
142
 
143
  $arguments = array();
144
  $names = array();
145
+ $missingArguments = array();
146
+ $optionalArguments = array();
147
  $pos = 0;
148
  foreach ($definition as $param) {
149
  $names[] = $name = $this->normalizeName($param->name);
150
 
151
  if (array_key_exists($name, $parameters)) {
152
  if (array_key_exists($pos, $parameters)) {
153
+ throw new Twig_Error_Syntax(sprintf('Argument "%s" is defined twice for %s "%s".', $name, $callType, $callName));
154
+ }
155
+
156
+ if (!empty($missingArguments)) {
157
+ throw new Twig_Error_Syntax(sprintf(
158
+ 'Argument "%s" could not be assigned for %s "%s(%s)" because it is mapped to an internal PHP function which cannot determine default value for optional argument%s "%s".',
159
+ $name, $callType, $callName, implode(', ', $names), count($missingArguments) > 1 ? 's' : '', implode('", "', $missingArguments))
160
+ );
161
  }
162
 
163
+ $arguments = array_merge($arguments, $optionalArguments);
164
  $arguments[] = $parameters[$name];
165
  unset($parameters[$name]);
166
+ $optionalArguments = array();
167
  } elseif (array_key_exists($pos, $parameters)) {
168
+ $arguments = array_merge($arguments, $optionalArguments);
169
  $arguments[] = $parameters[$pos];
170
  unset($parameters[$pos]);
171
+ $optionalArguments = array();
172
  ++$pos;
173
  } elseif ($param->isDefaultValueAvailable()) {
174
+ $optionalArguments[] = new Twig_Node_Expression_Constant($param->getDefaultValue(), -1);
175
  } elseif ($param->isOptional()) {
176
+ if (empty($parameters)) {
177
+ break;
178
+ } else {
179
+ $missingArguments[] = $name;
180
+ }
181
  } else {
182
+ throw new Twig_Error_Syntax(sprintf('Value for argument "%s" is required for %s "%s".', $name, $callType, $callName));
183
  }
184
  }
185
 
186
  if (!empty($parameters)) {
187
+ $unknownParameter = null;
188
+ foreach ($parameters as $parameter) {
189
+ if ($parameter instanceof Twig_Node) {
190
+ $unknownParameter = $parameter;
191
+ break;
192
+ }
193
+ }
194
+
195
  throw new Twig_Error_Syntax(sprintf(
196
  'Unknown argument%s "%s" for %s "%s(%s)".',
197
+ count($parameters) > 1 ? 's' : '', implode('", "', array_keys($parameters)), $callType, $callName, implode(', ', $names)
198
+ ), $unknownParameter ? $unknownParameter->getLine() : -1);
199
  }
200
 
201
  return $arguments;
vendor/twig/twig/lib/Twig/Node/Expression/Name.php CHANGED
@@ -26,6 +26,8 @@ class Twig_Node_Expression_Name extends Twig_Node_Expression
26
  {
27
  $name = $this->getAttribute('name');
28
 
 
 
29
  if ($this->getAttribute('is_defined_test')) {
30
  if ($this->isSpecial()) {
31
  $compiler->repr(true);
26
  {
27
  $name = $this->getAttribute('name');
28
 
29
+ $compiler->addDebugInfo($this);
30
+
31
  if ($this->getAttribute('is_defined_test')) {
32
  if ($this->isSpecial()) {
33
  $compiler->repr(true);
vendor/twig/twig/lib/Twig/Node/Module.php CHANGED
@@ -13,6 +13,10 @@
13
  /**
14
  * Represents a module node.
15
  *
 
 
 
 
16
  * @author Fabien Potencier <fabien@symfony.com>
17
  */
18
  class Twig_Node_Module extends Twig_Node
@@ -20,7 +24,22 @@ class Twig_Node_Module extends Twig_Node
20
  public function __construct(Twig_NodeInterface $body, Twig_Node_Expression $parent = null, Twig_NodeInterface $blocks, Twig_NodeInterface $macros, Twig_NodeInterface $traits, $embeddedTemplates, $filename)
21
  {
22
  // embedded templates are set as attributes so that they are only visited once by the visitors
23
- parent::__construct(array('parent' => $parent, 'body' => $body, 'blocks' => $blocks, 'macros' => $macros, 'traits' => $traits), array('filename' => $filename, 'index' => null, 'embedded_templates' => $embeddedTemplates), 1);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  }
25
 
26
  public function setIndex($index)
@@ -50,17 +69,20 @@ class Twig_Node_Module extends Twig_Node
50
 
51
  $this->compileClassHeader($compiler);
52
 
53
- if (count($this->getNode('blocks')) || count($this->getNode('traits')) || null === $this->getNode('parent') || $this->getNode('parent') instanceof Twig_Node_Expression_Constant) {
 
 
 
 
 
 
 
54
  $this->compileConstructor($compiler);
55
  }
56
 
57
  $this->compileGetParent($compiler);
58
 
59
- $this->compileDisplayHeader($compiler);
60
-
61
- $this->compileDisplayBody($compiler);
62
-
63
- $this->compileDisplayFooter($compiler);
64
 
65
  $compiler->subcompile($this->getNode('blocks'));
66
 
@@ -89,11 +111,11 @@ class Twig_Node_Module extends Twig_Node
89
  ;
90
 
91
  if ($parent instanceof Twig_Node_Expression_Constant) {
92
- $compiler->subcompile($this->getNode('parent'));
93
  } else {
94
  $compiler
95
  ->raw("\$this->env->resolveTemplate(")
96
- ->subcompile($this->getNode('parent'))
97
  ->raw(")")
98
  ;
99
  }
@@ -105,21 +127,6 @@ class Twig_Node_Module extends Twig_Node
105
  ;
106
  }
107
 
108
- protected function compileDisplayBody(Twig_Compiler $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)");
118
- }
119
- $compiler->raw("->display(\$context, array_merge(\$this->blocks, \$blocks));\n");
120
- }
121
- }
122
-
123
  protected function compileClassHeader(Twig_Compiler $compiler)
124
  {
125
  $compiler
@@ -138,6 +145,7 @@ class Twig_Node_Module extends Twig_Node
138
  $compiler
139
  ->write("public function __construct(Twig_Environment \$env)\n", "{\n")
140
  ->indent()
 
141
  ->write("parent::__construct(\$env);\n\n")
142
  ;
143
 
@@ -150,7 +158,7 @@ class Twig_Node_Module extends Twig_Node
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")
@@ -262,21 +270,32 @@ class Twig_Node_Module extends Twig_Node
262
  ->outdent()
263
  ->write(");\n")
264
  ->outdent()
 
265
  ->write("}\n\n")
266
  ;
267
  }
268
 
269
- protected function compileDisplayHeader(Twig_Compiler $compiler)
270
  {
271
  $compiler
272
  ->write("protected function doDisplay(array \$context, array \$blocks = array())\n", "{\n")
273
  ->indent()
 
 
274
  ;
275
- }
276
 
277
- protected function compileDisplayFooter(Twig_Compiler $compiler)
278
- {
 
 
 
 
 
 
 
 
279
  $compiler
 
280
  ->outdent()
281
  ->write("}\n\n")
282
  ;
@@ -285,6 +304,7 @@ class Twig_Node_Module extends Twig_Node
285
  protected function compileClassFooter(Twig_Compiler $compiler)
286
  {
287
  $compiler
 
288
  ->outdent()
289
  ->write("}\n")
290
  ;
13
  /**
14
  * Represents a module node.
15
  *
16
+ * Consider this class as being final. If you need to customize the behavior of
17
+ * the generated class, consider adding nodes to the following nodes: display_start,
18
+ * display_end, constructor_start, constructor_end, and class_end.
19
+ *
20
  * @author Fabien Potencier <fabien@symfony.com>
21
  */
22
  class Twig_Node_Module extends Twig_Node
24
  public function __construct(Twig_NodeInterface $body, Twig_Node_Expression $parent = null, Twig_NodeInterface $blocks, Twig_NodeInterface $macros, Twig_NodeInterface $traits, $embeddedTemplates, $filename)
25
  {
26
  // embedded templates are set as attributes so that they are only visited once by the visitors
27
+ parent::__construct(array(
28
+ 'parent' => $parent,
29
+ 'body' => $body,
30
+ 'blocks' => $blocks,
31
+ 'macros' => $macros,
32
+ 'traits' => $traits,
33
+ 'display_start' => new Twig_Node(),
34
+ 'display_end' => new Twig_Node(),
35
+ 'constructor_start' => new Twig_Node(),
36
+ 'constructor_end' => new Twig_Node(),
37
+ 'class_end' => new Twig_Node(),
38
+ ), array(
39
+ 'filename' => $filename,
40
+ 'index' => null,
41
+ 'embedded_templates' => $embeddedTemplates,
42
+ ), 1);
43
  }
44
 
45
  public function setIndex($index)
69
 
70
  $this->compileClassHeader($compiler);
71
 
72
+ if (
73
+ count($this->getNode('blocks'))
74
+ || count($this->getNode('traits'))
75
+ || null === $this->getNode('parent')
76
+ || $this->getNode('parent') instanceof Twig_Node_Expression_Constant
77
+ || count($this->getNode('constructor_start'))
78
+ || count($this->getNode('constructor_end'))
79
+ ) {
80
  $this->compileConstructor($compiler);
81
  }
82
 
83
  $this->compileGetParent($compiler);
84
 
85
+ $this->compileDisplay($compiler);
 
 
 
 
86
 
87
  $compiler->subcompile($this->getNode('blocks'));
88
 
111
  ;
112
 
113
  if ($parent instanceof Twig_Node_Expression_Constant) {
114
+ $compiler->subcompile($parent);
115
  } else {
116
  $compiler
117
  ->raw("\$this->env->resolveTemplate(")
118
+ ->subcompile($parent)
119
  ->raw(")")
120
  ;
121
  }
127
  ;
128
  }
129
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
130
  protected function compileClassHeader(Twig_Compiler $compiler)
131
  {
132
  $compiler
145
  $compiler
146
  ->write("public function __construct(Twig_Environment \$env)\n", "{\n")
147
  ->indent()
148
+ ->subcompile($this->getNode('constructor_start'))
149
  ->write("parent::__construct(\$env);\n\n")
150
  ;
151
 
158
  ->write("try {\n")
159
  ->indent()
160
  ->write("\$this->parent = \$this->env->loadTemplate(")
161
+ ->subcompile($parent)
162
  ->raw(");\n")
163
  ->outdent()
164
  ->write("} catch (Twig_Error_Loader \$e) {\n")
270
  ->outdent()
271
  ->write(");\n")
272
  ->outdent()
273
+ ->subcompile($this->getNode('constructor_end'))
274
  ->write("}\n\n")
275
  ;
276
  }
277
 
278
+ protected function compileDisplay(Twig_Compiler $compiler)
279
  {
280
  $compiler
281
  ->write("protected function doDisplay(array \$context, array \$blocks = array())\n", "{\n")
282
  ->indent()
283
+ ->subcompile($this->getNode('display_start'))
284
+ ->subcompile($this->getNode('body'))
285
  ;
 
286
 
287
+ if (null !== $parent = $this->getNode('parent')) {
288
+ $compiler->addDebugInfo($parent);
289
+ if ($parent instanceof Twig_Node_Expression_Constant) {
290
+ $compiler->write("\$this->parent");
291
+ } else {
292
+ $compiler->write("\$this->getParent(\$context)");
293
+ }
294
+ $compiler->raw("->display(\$context, array_merge(\$this->blocks, \$blocks));\n");
295
+ }
296
+
297
  $compiler
298
+ ->subcompile($this->getNode('display_end'))
299
  ->outdent()
300
  ->write("}\n\n")
301
  ;
304
  protected function compileClassFooter(Twig_Compiler $compiler)
305
  {
306
  $compiler
307
+ ->subcompile($this->getNode('class_end'))
308
  ->outdent()
309
  ->write("}\n")
310
  ;
vendor/twig/twig/lib/Twig/NodeVisitor/Optimizer.php CHANGED
@@ -36,7 +36,7 @@ class Twig_NodeVisitor_Optimizer implements Twig_NodeVisitorInterface
36
  /**
37
  * Constructor.
38
  *
39
- * @param int $optimizers The optimizer mode
40
  */
41
  public function __construct($optimizers = -1)
42
  {
36
  /**
37
  * Constructor.
38
  *
39
+ * @param int $optimizers The optimizer mode
40
  */
41
  public function __construct($optimizers = -1)
42
  {
vendor/twig/twig/lib/Twig/NodeVisitor/Sandbox.php CHANGED
@@ -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, $this->filters, $this->tags, $this->functions);
80
  }
81
 
82
  return $node;
76
  if ($node instanceof Twig_Node_Module) {
77
  $this->inAModule = false;
78
 
79
+ $node->setNode('display_start', new Twig_Node(array(new Twig_Node_CheckSecurity($this->filters, $this->tags, $this->functions), $node->getNode('display_start'))));
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 int 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/Profiler/Dumper/Blackfire.php ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of Twig.
5
+ *
6
+ * (c) 2015 Fabien Potencier
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ /**
13
+ * @author Fabien Potencier <fabien@symfony.com>
14
+ */
15
+ class Twig_Profiler_Dumper_Blackfire
16
+ {
17
+ public function dump(Twig_Profiler_Profile $profile)
18
+ {
19
+ $data = array();
20
+ $this->dumpProfile('main()', $profile, $data);
21
+ $this->dumpChildren('main()', $profile, $data);
22
+
23
+ $start = microtime(true);
24
+ $str = <<<EOF
25
+ file-format: BlackfireProbe
26
+ cost-dimensions: wt mu pmu
27
+ request-start: {$start}
28
+
29
+
30
+ EOF;
31
+
32
+ foreach ($data as $name => $values) {
33
+ $str .= "{$name}//{$values['ct']} {$values['wt']} {$values['mu']} {$values['pmu']}\n";
34
+ }
35
+
36
+ return $str;
37
+ }
38
+
39
+ private function dumpChildren($parent, Twig_Profiler_Profile $profile, &$data)
40
+ {
41
+ foreach ($profile as $p) {
42
+ if ($p->isTemplate()) {
43
+ $name = $p->getTemplate();
44
+ } else {
45
+ $name = sprintf('%s::%s(%s)', $p->getTemplate(), $p->getType(), $p->getName());
46
+ }
47
+ $this->dumpProfile(sprintf('%s==>%s', $parent, $name), $p, $data);
48
+ $this->dumpChildren($name, $p, $data);
49
+ }
50
+ }
51
+
52
+ private function dumpProfile($edge, Twig_Profiler_Profile $profile, &$data)
53
+ {
54
+ if (isset($data[$edge])) {
55
+ $data[$edge]['ct'] += 1;
56
+ $data[$edge]['wt'] += floor($profile->getDuration() * 1000000);
57
+ $data[$edge]['mu'] += $profile->getMemoryUsage();
58
+ $data[$edge]['pmu'] += $profile->getPeakMemoryUsage();
59
+ } else {
60
+ $data[$edge] = array(
61
+ 'ct' => 1,
62
+ 'wt' => floor($profile->getDuration() * 1000000),
63
+ 'mu' => $profile->getMemoryUsage(),
64
+ 'pmu' => $profile->getPeakMemoryUsage(),
65
+ );
66
+ }
67
+ }
68
+ }
vendor/twig/twig/lib/Twig/Profiler/Dumper/Html.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of Twig.
5
+ *
6
+ * (c) 2015 Fabien Potencier
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ /**
13
+ * @author Fabien Potencier <fabien@symfony.com>
14
+ */
15
+ class Twig_Profiler_Dumper_Html extends Twig_Profiler_Dumper_Text
16
+ {
17
+ static private $colors = array(
18
+ 'block' => '#dfd',
19
+ 'macro' => '#ddf',
20
+ 'template' => '#ffd',
21
+ 'big' => '#d44',
22
+ );
23
+
24
+ public function dump(Twig_Profiler_Profile $profile)
25
+ {
26
+ return '<pre>'.parent::dump($profile).'</pre>';
27
+ }
28
+
29
+ protected function formatTemplate(Twig_Profiler_Profile $profile, $prefix)
30
+ {
31
+ return sprintf('%s└ <span style="background-color: %s">%s</span>', $prefix, self::$colors['template'], $profile->getTemplate());
32
+ }
33
+
34
+ protected function formatNonTemplate(Twig_Profiler_Profile $profile, $prefix)
35
+ {
36
+ return sprintf('%s└ %s::%s(<span style="background-color: %s">%s</span>)', $prefix, $profile->getTemplate(), $profile->getType(), isset(self::$colors[$profile->getType()]) ? self::$colors[$profile->getType()] : 'auto', $profile->getName());
37
+ }
38
+
39
+ protected function formatTime(Twig_Profiler_Profile $profile, $percent)
40
+ {
41
+ return sprintf('<span style="color: %s">%.2fms/%.0f%%</span>', $percent > 20 ? self::$colors['big'] : 'auto', $profile->getDuration() * 1000, $percent);
42
+ }
43
+ }
vendor/twig/twig/lib/Twig/Profiler/Dumper/Text.php ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of Twig.
5
+ *
6
+ * (c) 2015 Fabien Potencier
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ /**
13
+ * @author Fabien Potencier <fabien@symfony.com>
14
+ */
15
+ class Twig_Profiler_Dumper_Text
16
+ {
17
+ private $root;
18
+
19
+ public function dump(Twig_Profiler_Profile $profile)
20
+ {
21
+ return $this->dumpProfile($profile);
22
+ }
23
+
24
+ protected function formatTemplate(Twig_Profiler_Profile $profile, $prefix)
25
+ {
26
+ return sprintf('%s└ %s', $prefix, $profile->getTemplate());
27
+ }
28
+
29
+ protected function formatNonTemplate(Twig_Profiler_Profile $profile, $prefix)
30
+ {
31
+ return sprintf('%s└ %s::%s(%s)', $prefix, $profile->getTemplate(), $profile->getType(), $profile->getName());
32
+ }
33
+
34
+ protected function formatTime(Twig_Profiler_Profile $profile, $percent)
35
+ {
36
+ return sprintf('%.2fms/%.0f%%', $profile->getDuration() * 1000, $percent);
37
+ }
38
+
39
+ private function dumpProfile(Twig_Profiler_Profile $profile, $prefix = '', $sibling = false)
40
+ {
41
+ if ($profile->isRoot()) {
42
+ $this->root = $profile->getDuration();
43
+ $start = $profile->getName();
44
+ } else {
45
+ if ($profile->isTemplate()) {
46
+ $start = $this->formatTemplate($profile, $prefix);
47
+ } else {
48
+ $start = $this->formatNonTemplate($profile, $prefix);
49
+ }
50
+ $prefix .= $sibling ? '│ ' : ' ';
51
+ }
52
+
53
+ $percent = $this->root ? $profile->getDuration() / $this->root * 100 : 0;
54
+
55
+ if ($profile->getDuration() * 1000 < 1) {
56
+ $str = $start."\n";
57
+ } else {
58
+ $str = sprintf("%s %s\n", $start, $this->formatTime($profile, $percent));
59
+ }
60
+
61
+ $nCount = count($profile->getProfiles());
62
+ foreach ($profile as $i => $p) {
63
+ $str .= $this->dumpProfile($p, $prefix, $i + 1 !== $nCount);
64
+ }
65
+
66
+ return $str;
67
+ }
68
+ }
vendor/twig/twig/lib/Twig/Profiler/Node/EnterProfile.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of Twig.
5
+ *
6
+ * (c) 2015 Fabien Potencier
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ /**
13
+ * Represents a profile enter node.
14
+ *
15
+ * @author Fabien Potencier <fabien@symfony.com>
16
+ */
17
+ class Twig_Profiler_Node_EnterProfile extends Twig_Node
18
+ {
19
+ public function __construct($extensionName, $type, $name, $varName)
20
+ {
21
+ parent::__construct(array(), array('extension_name' => $extensionName, 'name' => $name, 'type' => $type, 'var_name' => $varName));
22
+ }
23
+
24
+ /**
25
+ * {@inheritdoc}
26
+ */
27
+ public function compile(Twig_Compiler $compiler)
28
+ {
29
+ $compiler
30
+ ->write(sprintf("\$%s = \$this->env->getExtension(", $this->getAttribute('var_name')))
31
+ ->repr($this->getAttribute('extension_name'))
32
+ ->raw(");\n")
33
+ ->write(sprintf("\$%s->enter(\$%s = new Twig_Profiler_Profile(\$this->getTemplateName(), ", $this->getAttribute('var_name'), $this->getAttribute('var_name').'_prof'))
34
+ ->repr($this->getAttribute('type'))
35
+ ->raw(", ")
36
+ ->repr($this->getAttribute('name'))
37
+ ->raw("));\n\n")
38
+ ;
39
+ }
40
+ }
vendor/twig/twig/lib/Twig/Profiler/Node/LeaveProfile.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of Twig.
5
+ *
6
+ * (c) 2015 Fabien Potencier
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ /**
13
+ * Represents a profile leave node.
14
+ *
15
+ * @author Fabien Potencier <fabien@symfony.com>
16
+ */
17
+ class Twig_Profiler_Node_LeaveProfile extends Twig_Node
18
+ {
19
+ public function __construct($varName)
20
+ {
21
+ parent::__construct(array(), array('var_name' => $varName));
22
+ }
23
+
24
+ /**
25
+ * {@inheritdoc}
26
+ */
27
+ public function compile(Twig_Compiler $compiler)
28
+ {
29
+ $compiler
30
+ ->write("\n")
31
+ ->write(sprintf("\$%s->leave(\$%s);\n\n", $this->getAttribute('var_name'), $this->getAttribute('var_name').'_prof'))
32
+ ;
33
+ }
34
+ }
vendor/twig/twig/lib/Twig/Profiler/NodeVisitor/Profiler.php ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of Twig.
5
+ *
6
+ * (c) 2015 Fabien Potencier
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ /**
13
+ * @author Fabien Potencier <fabien@symfony.com>
14
+ */
15
+ class Twig_Profiler_NodeVisitor_Profiler implements Twig_NodeVisitorInterface
16
+ {
17
+ private $extensionName;
18
+
19
+ public function __construct($extensionName)
20
+ {
21
+ $this->extensionName = $extensionName;
22
+ }
23
+
24
+ /**
25
+ * {@inheritdoc}
26
+ */
27
+ public function enterNode(Twig_NodeInterface $node, Twig_Environment $env)
28
+ {
29
+ return $node;
30
+ }
31
+
32
+ /**
33
+ * {@inheritdoc}
34
+ */
35
+ public function leaveNode(Twig_NodeInterface $node, Twig_Environment $env)
36
+ {
37
+ if ($node instanceof Twig_Node_Module) {
38
+ $varName = $this->getVarName();
39
+ $node->setNode('display_start', new Twig_Node(array(new Twig_Profiler_Node_EnterProfile($this->extensionName, Twig_Profiler_Profile::TEMPLATE, $node->getAttribute('filename'), $varName), $node->getNode('display_start'))));
40
+ $node->setNode('display_end', new Twig_Node(array(new Twig_Profiler_Node_LeaveProfile($varName), $node->getNode('display_end'))));
41
+ } elseif ($node instanceof Twig_Node_Block) {
42
+ $varName = $this->getVarName();
43
+ $node->setNode('body', new Twig_Node_Body(array(
44
+ new Twig_Profiler_Node_EnterProfile($this->extensionName, Twig_Profiler_Profile::BLOCK, $node->getAttribute('name'), $varName),
45
+ $node->getNode('body'),
46
+ new Twig_Profiler_Node_LeaveProfile($varName),
47
+ )));
48
+ } elseif ($node instanceof Twig_Node_Macro) {
49
+ $varName = $this->getVarName();
50
+ $node->setNode('body', new Twig_Node_Body(array(
51
+ new Twig_Profiler_Node_EnterProfile($this->extensionName, Twig_Profiler_Profile::MACRO, $node->getAttribute('name'), $varName),
52
+ $node->getNode('body'),
53
+ new Twig_Profiler_Node_LeaveProfile($varName),
54
+ )));
55
+ }
56
+
57
+ return $node;
58
+ }
59
+
60
+ private function getVarName()
61
+ {
62
+ return sprintf('__internal_%s', hash('sha256', uniqid(mt_rand(), true), false));
63
+ }
64
+
65
+ /**
66
+ * {@inheritdoc}
67
+ */
68
+ public function getPriority()
69
+ {
70
+ return 0;
71
+ }
72
+ }
vendor/twig/twig/lib/Twig/Profiler/Profile.php ADDED
@@ -0,0 +1,150 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of Twig.
5
+ *
6
+ * (c) 2015 Fabien Potencier
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ /**
13
+ * @author Fabien Potencier <fabien@symfony.com>
14
+ */
15
+ class Twig_Profiler_Profile implements IteratorAggregate, Serializable
16
+ {
17
+ const ROOT = 'ROOT';
18
+ const BLOCK = 'block';
19
+ const TEMPLATE = 'template';
20
+ const MACRO = 'macro';
21
+
22
+ private $template;
23
+ private $name;
24
+ private $type;
25
+ private $starts = array();
26
+ private $ends = array();
27
+ private $profiles = array();
28
+
29
+ public function __construct($template = 'main', $type = Twig_Profiler_Profile::ROOT, $name = 'main')
30
+ {
31
+ $this->template = $template;
32
+ $this->type = $type;
33
+ $this->name = 0 === strpos($name, '__internal_') ? 'INTERNAL' : $name;
34
+ $this->enter();
35
+ }
36
+
37
+ public function getTemplate()
38
+ {
39
+ return $this->template;
40
+ }
41
+
42
+ public function getType()
43
+ {
44
+ return $this->type;
45
+ }
46
+
47
+ public function getName()
48
+ {
49
+ return $this->name;
50
+ }
51
+
52
+ public function isRoot()
53
+ {
54
+ return self::ROOT === $this->type;
55
+ }
56
+
57
+ public function isTemplate()
58
+ {
59
+ return self::TEMPLATE === $this->type;
60
+ }
61
+
62
+ public function isBlock()
63
+ {
64
+ return self::BLOCK === $this->type;
65
+ }
66
+
67
+ public function isMacro()
68
+ {
69
+ return self::MACRO === $this->type;
70
+ }
71
+
72
+ public function getProfiles()
73
+ {
74
+ return $this->profiles;
75
+ }
76
+
77
+ public function addProfile(Twig_Profiler_Profile $profile)
78
+ {
79
+ $this->profiles[] = $profile;
80
+ }
81
+
82
+ /**
83
+ * Returns the duration in microseconds.
84
+ *
85
+ * @return int
86
+ */
87
+ public function getDuration()
88
+ {
89
+ return isset($this->ends['wt']) && isset($this->starts['wt']) ? $this->ends['wt'] - $this->starts['wt'] : 0;
90
+ }
91
+
92
+ /**
93
+ * Returns the memory usage in bytes.
94
+ *
95
+ * @return int
96
+ */
97
+ public function getMemoryUsage()
98
+ {
99
+ return isset($this->ends['mu']) && isset($this->starts['mu']) ? $this->ends['mu'] - $this->starts['mu'] : 0;
100
+ }
101
+
102
+ /**
103
+ * Returns the peak memory usage in bytes.
104
+ *
105
+ * @return int
106
+ */
107
+ public function getPeakMemoryUsage()
108
+ {
109
+ return isset($this->ends['pmu']) && isset($this->starts['pmu']) ? $this->ends['pmu'] - $this->starts['pmu'] : 0;
110
+ }
111
+
112
+ /**
113
+ * Starts the profiling.
114
+ */
115
+ public function enter()
116
+ {
117
+ $this->starts = array(
118
+ 'wt' => microtime(true),
119
+ 'mu' => memory_get_usage(),
120
+ 'pmu' => memory_get_peak_usage(),
121
+ );
122
+ }
123
+
124
+ /**
125
+ * Stops the profiling.
126
+ */
127
+ public function leave()
128
+ {
129
+ $this->ends = array(
130
+ 'wt' => microtime(true),
131
+ 'mu' => memory_get_usage(),
132
+ 'pmu' => memory_get_peak_usage(),
133
+ );
134
+ }
135
+
136
+ public function getIterator()
137
+ {
138
+ return new ArrayIterator($this->profiles);
139
+ }
140
+
141
+ public function serialize()
142
+ {
143
+ return serialize(array($this->template, $this->name, $this->type, $this->starts, $this->ends, $this->profiles));
144
+ }
145
+
146
+ public function unserialize($data)
147
+ {
148
+ list($this->template, $this->name, $this->type, $this->starts, $this->ends, $this->profiles) = unserialize($data);
149
+ }
150
+ }
vendor/twig/twig/lib/Twig/Template.php CHANGED
@@ -129,10 +129,10 @@ abstract class Twig_Template implements Twig_TemplateInterface
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
  {
@@ -188,10 +188,10 @@ abstract class Twig_Template implements Twig_TemplateInterface
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
  */
@@ -218,7 +218,7 @@ abstract class Twig_Template implements Twig_TemplateInterface
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
  {
@@ -324,9 +324,9 @@ abstract class Twig_Template implements Twig_TemplateInterface
324
  * access for versions of PHP before 5.4. This is not a way to override
325
  * the way to get a variable value.
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
  *
@@ -348,12 +348,12 @@ abstract class Twig_Template implements Twig_TemplateInterface
348
  /**
349
  * Returns the attribute value for a given array/object.
350
  *
351
- * @param mixed $object The object or array from where to get the item
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
  *
@@ -488,12 +488,4 @@ abstract class Twig_Template implements Twig_TemplateInterface
488
 
489
  return $ret;
490
  }
491
-
492
- /**
493
- * This method is only useful when testing Twig. Do not use it.
494
- */
495
- public static function clearCache()
496
- {
497
- self::$cache = array();
498
- }
499
  }
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
  {
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
  */
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
  {
324
  * access for versions of PHP before 5.4. This is not a way to override
325
  * the way to get a variable value.
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
  *
348
  /**
349
  * Returns the attribute value for a given array/object.
350
  *
351
+ * @param mixed $object The object or array from where to get the item
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
  *
488
 
489
  return $ret;
490
  }
 
 
 
 
 
 
 
 
491
  }
vendor/twig/twig/lib/Twig/Test/IntegrationTestCase.php CHANGED
@@ -123,7 +123,7 @@ abstract class Twig_Test_IntegrationTestCase extends PHPUnit_Framework_TestCase
123
 
124
  if (false !== $exception) {
125
  list($class, ) = explode(':', $exception);
126
- $this->assertThat(NULL, new PHPUnit_Framework_Constraint_Exception($class));
127
  }
128
 
129
  $expected = trim($match[3], "\n ");
123
 
124
  if (false !== $exception) {
125
  list($class, ) = explode(':', $exception);
126
+ $this->assertThat(null, new PHPUnit_Framework_Constraint_Exception($class));
127
  }
128
 
129
  $expected = trim($match[3], "\n ");
vendor/twig/twig/lib/Twig/Test/NodeTestCase.php CHANGED
@@ -38,13 +38,15 @@ abstract class Twig_Test_NodeTestCase extends PHPUnit_Framework_TestCase
38
  return new Twig_Environment();
39
  }
40
 
41
- protected function getVariableGetter($name)
42
  {
 
 
43
  if (version_compare(phpversion(), '5.4.0RC1', '>=')) {
44
- return sprintf('(isset($context["%s"]) ? $context["%s"] : null)', $name, $name);
45
  }
46
 
47
- return sprintf('$this->getContext($context, "%s")', $name);
48
  }
49
 
50
  protected function getAttributeGetter()
38
  return new Twig_Environment();
39
  }
40
 
41
+ protected function getVariableGetter($name, $line = false)
42
  {
43
+ $line = $line > 0 ? "// line {$line}\n" : '';
44
+
45
  if (version_compare(phpversion(), '5.4.0RC1', '>=')) {
46
+ return sprintf('%s(isset($context["%s"]) ? $context["%s"] : null)', $line, $name, $name);
47
  }
48
 
49
+ return sprintf('%s$this->getContext($context, "%s")', $line, $name);
50
  }
51
 
52
  protected function getAttributeGetter()
vendor/twig/twig/lib/Twig/Token.php CHANGED
@@ -38,9 +38,9 @@ class Twig_Token
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
  {
@@ -89,7 +89,7 @@ class Twig_Token
89
  /**
90
  * Gets the line.
91
  *
92
- * @return int 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 int 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 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,7 +176,7 @@ class Twig_Token
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
  */
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
  {
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 int $number
105
  *
106
  * @return Twig_Token
107
  */
101
  /**
102
  * Looks at the next token.
103
  *
104
+ * @param int $number
105
  *
106
  * @return Twig_Token
107
  */
vendor/twig/twig/test/Twig/Tests/ErrorTest.php CHANGED
@@ -112,7 +112,7 @@ class Twig_Tests_ErrorTest extends PHPUnit_Framework_TestCase
112
  {% block content %}
113
  {{ parent() }}
114
  {% endblock %}",
115
- 'base' => '{% block content %}{{ foo.bar }}{% endblock %}'
116
  ),
117
  'base', 1,
118
  ),
@@ -127,7 +127,7 @@ class Twig_Tests_ErrorTest extends PHPUnit_Framework_TestCase
127
  {% block foo %}
128
  {{ foo.bar }}
129
  {% endblock %}",
130
- 'base' => '{% block content %}{% endblock %}'
131
  ),
132
  'index', 3,
133
  ),
112
  {% block content %}
113
  {{ parent() }}
114
  {% endblock %}",
115
+ 'base' => '{% block content %}{{ foo.bar }}{% endblock %}',
116
  ),
117
  'base', 1,
118
  ),
127
  {% block foo %}
128
  {{ foo.bar }}
129
  {% endblock %}",
130
+ 'base' => '{% block content %}{% endblock %}',
131
  ),
132
  'index', 3,
133
  ),
vendor/twig/twig/test/Twig/Tests/ExpressionParserTest.php CHANGED
@@ -32,7 +32,7 @@ class Twig_Tests_ExpressionParserTest extends PHPUnit_Framework_TestCase
32
  array('{% set 3 = "foo" %}'),
33
  array('{% set 1 + 2 = "foo" %}'),
34
  array('{% set "bar" = "foo" %}'),
35
- array('{% set %}{% endset %}')
36
  );
37
  }
38
 
@@ -190,7 +190,7 @@ class Twig_Tests_ExpressionParserTest extends PHPUnit_Framework_TestCase
190
  ),
191
  new Twig_Node_Expression_Constant(' baz', 1),
192
  1
193
- )
194
  ),
195
 
196
  array(
32
  array('{% set 3 = "foo" %}'),
33
  array('{% set 1 + 2 = "foo" %}'),
34
  array('{% set "bar" = "foo" %}'),
35
+ array('{% set %}{% endset %}'),
36
  );
37
  }
38
 
190
  ),
191
  new Twig_Node_Expression_Constant(' baz', 1),
192
  1
193
+ ),
194
  ),
195
 
196
  array(
vendor/twig/twig/test/Twig/Tests/FileCachingTest.php CHANGED
@@ -1,5 +1,14 @@
1
  <?php
2
 
 
 
 
 
 
 
 
 
 
3
  class Twig_Tests_FileCachingTest extends PHPUnit_Framework_TestCase
4
  {
5
  protected $fileName;
1
  <?php
2
 
3
+ /*
4
+ * This file is part of Twig.
5
+ *
6
+ * (c) Fabien Potencier
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
  class Twig_Tests_FileCachingTest extends PHPUnit_Framework_TestCase
13
  {
14
  protected $fileName;
vendor/twig/twig/test/Twig/Tests/FileExtensionEscapingStrategyTest.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of Twig.
5
+ *
6
+ * (c) Fabien Potencier
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ class Twig_Tests_FileExtensionEscapingStrategyTest extends PHPUnit_Framework_TestCase
13
+ {
14
+ /**
15
+ * @dataProvider getGuessData
16
+ */
17
+ public function testGuess($strategy, $filename)
18
+ {
19
+ $this->assertEquals($strategy, Twig_FileExtensionEscapingStrategy::guess($filename));
20
+ }
21
+
22
+ public function getGuessData()
23
+ {
24
+ return array(
25
+ // default
26
+ array('html', 'foo.html'),
27
+ array('html', 'foo.html.twig'),
28
+ array('html', 'foo'),
29
+ array('html', 'foo.bar.twig'),
30
+ array('html', 'foo.txt/foo'),
31
+ array('html', 'foo.txt/foo.js/'),
32
+
33
+ // css
34
+ array('css', 'foo.css'),
35
+ array('css', 'foo.css.twig'),
36
+ array('css', 'foo.twig.css'),
37
+
38
+ // js
39
+ array('js', 'foo.js'),
40
+ array('js', 'foo.js.twig'),
41
+ array('js', 'foo.txt/foo.js'),
42
+ array('js', 'foo.txt.twig/foo.js'),
43
+
44
+ // txt
45
+ array(false, 'foo.txt'),
46
+ array(false, 'foo.txt.twig'),
47
+ );
48
+ }
49
+ }
vendor/twig/twig/test/Twig/Tests/Fixtures/autoescape/filename.test ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ --TEST--
2
+ "filename" autoescape strategy
3
+ --TEMPLATE--
4
+ {{ br -}}
5
+ {{ include('index.html.twig') -}}
6
+ {{ include('index.txt.twig') -}}
7
+ --TEMPLATE(index.html.twig)--
8
+ {{ br -}}
9
+ --TEMPLATE(index.txt.twig)--
10
+ {{ br -}}
11
+ --DATA--
12
+ return array('br' => '<br />')
13
+ --CONFIG--
14
+ return array('autoescape' => 'filename')
15
+ --EXPECT--
16
+ &lt;br /&gt;
17
+ &lt;br /&gt;
18
+ <br />
vendor/twig/twig/test/Twig/Tests/Fixtures/exceptions/multiline_array_with_undefined_variable.test ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ --TEST--
2
+ Exception for multiline array with undefined variable
3
+ --TEMPLATE--
4
+ {% set foo = {
5
+ foo: 'foo',
6
+ bar: 'bar',
7
+
8
+
9
+ foobar: foobar,
10
+
11
+
12
+
13
+ foo2: foo2,
14
+ } %}
15
+ --DATA--
16
+ return array('foobar' => 'foobar')
17
+ --EXCEPTION--
18
+ Twig_Error_Runtime: Variable "foo2" does not exist in "index.twig" at line 11
vendor/twig/twig/test/Twig/Tests/Fixtures/exceptions/multiline_array_with_undefined_variable_again.test ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ --TEST--
2
+ Exception for multiline array with undefined variable
3
+ --TEMPLATE--
4
+ {% set foo = {
5
+ foo: 'foo',
6
+ bar: 'bar',
7
+
8
+
9
+ foobar: foobar,
10
+
11
+
12
+
13
+ foo2: foo2,
14
+ } %}
15
+ --DATA--
16
+ return array()
17
+ --EXCEPTION--
18
+ Twig_Error_Runtime: Variable "foobar" does not exist in "index.twig" at line 7
vendor/twig/twig/test/Twig/Tests/Fixtures/exceptions/multiline_function_with_undefined_variable.test ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ --TEST--
2
+ Exception for multile function with undefined variable
3
+ --TEMPLATE--
4
+ {{ include('foo',
5
+ with_context=with_context
6
+ ) }}
7
+ --TEMPLATE(foo)--
8
+ Foo
9
+ --DATA--
10
+ return array()
11
+ --EXCEPTION--
12
+ Twig_Error_Runtime: Variable "with_context" does not exist in "index.twig" at line 3
vendor/twig/twig/test/Twig/Tests/Fixtures/exceptions/multiline_function_with_unknown_argument.test ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ --TEST--
2
+ Exception for multiline function with unknown argument
3
+ --TEMPLATE--
4
+ {{ include('foo',
5
+ with_context=True,
6
+ invalid=False
7
+ ) }}
8
+ --EXCEPTION--
9
+ Twig_Error_Syntax: Unknown argument "invalid" for function "include(template, variables, with_context, ignore_missing, sandboxed)" in "index.twig" at line 4.
vendor/twig/twig/test/Twig/Tests/Fixtures/exceptions/multiline_tag_with_undefined_variable.test ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ --TEST--
2
+ Exception for multiline tag with undefined variable
3
+ --TEMPLATE--
4
+ {% include 'foo'
5
+ with vars
6
+ %}
7
+ --TEMPLATE(foo)--
8
+ Foo
9
+ --DATA--
10
+ return array()
11
+ --EXCEPTION--
12
+ Twig_Error_Runtime: Variable "vars" does not exist in "index.twig" at line 3
vendor/twig/twig/test/Twig/Tests/Loader/FilesystemTest.php CHANGED
@@ -60,6 +60,7 @@ class Twig_Tests_Loader_FilesystemTest extends PHPUnit_Framework_TestCase
60
  $loader->addPath($basePath.'/named_ter', 'named');
61
  $loader->addPath($basePath.'/normal_ter');
62
  $loader->prependPath($basePath.'/normal_final');
 
63
  $loader->prependPath($basePath.'/named_final', 'named');
64
 
65
  $this->assertEquals(array(
@@ -70,11 +71,16 @@ class Twig_Tests_Loader_FilesystemTest extends PHPUnit_Framework_TestCase
70
  ), $loader->getPaths());
71
  $this->assertEquals(array(
72
  $basePath.'/named_final',
 
73
  $basePath.'/named',
74
  $basePath.'/named_bis',
75
  $basePath.'/named_ter',
76
  ), $loader->getPaths('named'));
77
 
 
 
 
 
78
  $this->assertEquals("path (final)\n", $loader->getSource('index.html'));
79
  $this->assertEquals("path (final)\n", $loader->getSource('@__main__/index.html'));
80
  $this->assertEquals("named path (final)\n", $loader->getSource('@named/index.html'));
60
  $loader->addPath($basePath.'/named_ter', 'named');
61
  $loader->addPath($basePath.'/normal_ter');
62
  $loader->prependPath($basePath.'/normal_final');
63
+ $loader->prependPath($basePath.'/named/../named_quater', 'named');
64
  $loader->prependPath($basePath.'/named_final', 'named');
65
 
66
  $this->assertEquals(array(
71
  ), $loader->getPaths());
72
  $this->assertEquals(array(
73
  $basePath.'/named_final',
74
+ $basePath.'/named/../named_quater',
75
  $basePath.'/named',
76
  $basePath.'/named_bis',
77
  $basePath.'/named_ter',
78
  ), $loader->getPaths('named'));
79
 
80
+ $this->assertEquals(
81
+ $basePath.'/named_quater/named_absolute.html',
82
+ $loader->getCacheKey('@named/named_absolute.html')
83
+ );
84
  $this->assertEquals("path (final)\n", $loader->getSource('index.html'));
85
  $this->assertEquals("path (final)\n", $loader->getSource('@__main__/index.html'));
86
  $this->assertEquals("named path (final)\n", $loader->getSource('@named/index.html'));
vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/named_quater/named_absolute.html ADDED
@@ -0,0 +1 @@
 
1
+ named path (quater)
vendor/twig/twig/test/Twig/Tests/NativeExtensionTest.php CHANGED
@@ -20,7 +20,7 @@ class Twig_Tests_NativeExtensionTest extends PHPUnit_Framework_TestCase
20
  $twig = new Twig_Environment(new Twig_Loader_String(), array(
21
  'debug' => true,
22
  'cache' => false,
23
- 'autoescape' => false
24
  ));
25
 
26
  $d1 = new DateTime();
20
  $twig = new Twig_Environment(new Twig_Loader_String(), array(
21
  'debug' => true,
22
  'cache' => false,
23
+ 'autoescape' => false,
24
  ));
25
 
26
  $d1 = new DateTime();
vendor/twig/twig/test/Twig/Tests/Node/Expression/CallTest.php CHANGED
@@ -56,6 +56,31 @@ class Twig_Tests_Node_Expression_CallTest extends PHPUnit_Framework_TestCase
56
  $node = new Twig_Tests_Node_Expression_Call(array(), array('type' => 'function', 'name' => 'date'));
57
  $node->getArguments('date', array('Y-m-d', 'timestamp' => null, 'unknown1' => '', 'unknown2' => ''));
58
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
  }
60
 
61
  class Twig_Tests_Node_Expression_Call extends Twig_Node_Expression_Call
56
  $node = new Twig_Tests_Node_Expression_Call(array(), array('type' => 'function', 'name' => 'date'));
57
  $node->getArguments('date', array('Y-m-d', 'timestamp' => null, 'unknown1' => '', 'unknown2' => ''));
58
  }
59
+
60
+ /**
61
+ * @expectedException Twig_Error_Syntax
62
+ * @expectedExceptionMessage Argument "case_sensitivity" could not be assigned for function "substr_compare(main_str, str, offset, length, case_sensitivity)" because it is mapped to an internal PHP function which cannot determine default value for optional argument "length".
63
+ */
64
+ public function testResolveArgumentsWithMissingValueForOptionalArgument()
65
+ {
66
+ if (defined('HHVM_VERSION')) {
67
+ $this->markTestSkipped('Skip under HHVM as the behavior is not the same as plain PHP (which is an edge case anyway)');
68
+ }
69
+
70
+ $node = new Twig_Tests_Node_Expression_Call(array(), array('type' => 'function', 'name' => 'substr_compare'));
71
+ $node->getArguments('substr_compare', array('abcd', 'bc', 'offset' => 1, 'case_sensitivity' => true));
72
+ }
73
+
74
+ public function testResolveArgumentsOnlyNecessaryArgumentsForCustomFunction()
75
+ {
76
+ $node = new Twig_Tests_Node_Expression_Call(array(), array('type' => 'function', 'name' => 'custom_function'));
77
+
78
+ $this->assertEquals(array('arg1'), $node->getArguments(array($this, 'customFunction'), array('arg1' => 'arg1')));
79
+ }
80
+
81
+ public function customFunction($arg1, $arg2 = 'default', $arg3 = array())
82
+ {
83
+ }
84
  }
85
 
86
  class Twig_Tests_Node_Expression_Call extends Twig_Node_Expression_Call
vendor/twig/twig/test/Twig/Tests/Node/Expression/FilterTest.php CHANGED
@@ -74,7 +74,7 @@ class Twig_Tests_Node_Expression_FilterTest extends Twig_Test_NodeTestCase
74
 
75
  /**
76
  * @expectedException Twig_Error_Syntax
77
- * @expectedExceptionMessage Unknown argument "foobar" for filter "date(format, timezone)".
78
  */
79
  public function testCompileWithWrongNamedArgumentName()
80
  {
74
 
75
  /**
76
  * @expectedException Twig_Error_Syntax
77
+ * @expectedExceptionMessage Unknown argument "foobar" for filter "date(format, timezone)" at line 1.
78
  */
79
  public function testCompileWithWrongNamedArgumentName()
80
  {
vendor/twig/twig/test/Twig/Tests/Node/Expression/GetAttrTest.php CHANGED
@@ -34,16 +34,16 @@ class Twig_Tests_Node_Expression_GetAttrTest extends Twig_Test_NodeTestCase
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')));
41
 
42
  $args = new Twig_Node_Expression_Array(array(), 1);
43
  $args->addElement(new Twig_Node_Expression_Name('foo', 1));
44
  $args->addElement(new Twig_Node_Expression_Constant('bar', 1));
45
  $node = new Twig_Node_Expression_GetAttr($expr, $attr, $args, Twig_Template::METHOD_CALL, 1);
46
- $tests[] = array($node, sprintf('%s%s, "bar", array(0 => %s, 1 => "bar"), "method")', $this->getAttributeGetter(), $this->getVariableGetter('foo'), $this->getVariableGetter('foo')));
47
 
48
  return $tests;
49
  }
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', 1)));
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', 1)));
41
 
42
  $args = new Twig_Node_Expression_Array(array(), 1);
43
  $args->addElement(new Twig_Node_Expression_Name('foo', 1));
44
  $args->addElement(new Twig_Node_Expression_Constant('bar', 1));
45
  $node = new Twig_Node_Expression_GetAttr($expr, $attr, $args, Twig_Template::METHOD_CALL, 1);
46
+ $tests[] = array($node, sprintf('%s%s, "bar", array(0 => %s, 1 => "bar"), "method")', $this->getAttributeGetter(), $this->getVariableGetter('foo', 1), $this->getVariableGetter('foo')));
47
 
48
  return $tests;
49
  }
vendor/twig/twig/test/Twig/Tests/Node/Expression/NameTest.php CHANGED
@@ -28,10 +28,10 @@ class Twig_Tests_Node_Expression_NameTest extends Twig_Test_NodeTestCase
28
  $env1 = new Twig_Environment(null, array('strict_variables' => false));
29
 
30
  return array(
31
- version_compare(PHP_VERSION, '5.4.0') >= 0 ? array($node, '(isset($context["foo"]) ? $context["foo"] : $this->getContext($context, "foo"))', $env) : array($node, '$this->getContext($context, "foo")', $env),
32
- array($node, $this->getVariableGetter('foo'), $env1),
33
- array($self, '$this'),
34
- array($context, '$context'),
35
  );
36
  }
37
  }
28
  $env1 = new Twig_Environment(null, array('strict_variables' => false));
29
 
30
  return array(
31
+ array($node, "// line 1\n".(version_compare(PHP_VERSION, '5.4.0') >= 0 ? '(isset($context["foo"]) ? $context["foo"] : $this->getContext($context, "foo"))' : '$this->getContext($context, "foo")'), $env),
32
+ array($node, $this->getVariableGetter('foo', 1), $env1),
33
+ array($self, "// line 1\n\$this"),
34
+ array($context, "// line 1\n\$context"),
35
  );
36
  }
37
  }
vendor/twig/twig/test/Twig/Tests/Node/SandboxedModuleTest.php DELETED
@@ -1,203 +0,0 @@
1
- <?php
2
-
3
- /*
4
- * This file is part of Twig.
5
- *
6
- * (c) Fabien Potencier
7
- *
8
- * For the full copyright and license information, please view the LICENSE
9
- * file that was distributed with this source code.
10
- */
11
-
12
- class Twig_Tests_Node_SandboxedModuleTest extends Twig_Test_NodeTestCase
13
- {
14
- public function testConstructor()
15
- {
16
- $body = new Twig_Node_Text('foo', 1);
17
- $parent = new Twig_Node_Expression_Constant('layout.twig', 1);
18
- $blocks = new Twig_Node();
19
- $macros = new Twig_Node();
20
- $traits = new Twig_Node();
21
- $filename = 'foo.twig';
22
- $node = new Twig_Node_Module($body, $parent, $blocks, $macros, $traits, new Twig_Node(array()), $filename);
23
- $node = new Twig_Node_SandboxedModule($node, array('for'), array('upper'), array('cycle'));
24
-
25
- $this->assertEquals($body, $node->getNode('body'));
26
- $this->assertEquals($blocks, $node->getNode('blocks'));
27
- $this->assertEquals($macros, $node->getNode('macros'));
28
- $this->assertEquals($parent, $node->getNode('parent'));
29
- $this->assertEquals($filename, $node->getAttribute('filename'));
30
- }
31
-
32
- public function getTests()
33
- {
34
- $twig = new Twig_Environment(new Twig_Loader_String());
35
-
36
- $tests = array();
37
-
38
- $body = new Twig_Node_Text('foo', 1);
39
- $extends = null;
40
- $blocks = new Twig_Node();
41
- $macros = new Twig_Node();
42
- $traits = new Twig_Node();
43
- $filename = 'foo.twig';
44
-
45
- $node = new Twig_Node_Module($body, $extends, $blocks, $macros, $traits, new Twig_Node(array()), $filename);
46
- $node = new Twig_Node_SandboxedModule($node, array('for'), array('upper'), array('cycle'));
47
-
48
- $tests[] = array($node, <<<EOF
49
- <?php
50
-
51
- /* foo.twig */
52
- class __TwigTemplate_a2bfbf7dd6ab85666684fe9297f69363a3fc2046d90f22a317d380c18638df0d extends Twig_Template
53
- {
54
- public function __construct(Twig_Environment \$env)
55
- {
56
- parent::__construct(\$env);
57
-
58
- \$this->parent = false;
59
-
60
- \$this->blocks = array(
61
- );
62
- }
63
-
64
- protected function doDisplay(array \$context, array \$blocks = array())
65
- {
66
- \$this->checkSecurity();
67
- // line 1
68
- echo "foo";
69
- }
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()
99
- {
100
- return "foo.twig";
101
- }
102
-
103
- public function getDebugInfo()
104
- {
105
- return array ( 20 => 1,);
106
- }
107
- }
108
- EOF
109
- , $twig);
110
-
111
- $body = new Twig_Node();
112
- $extends = new Twig_Node_Expression_Constant('layout.twig', 1);
113
- $blocks = new Twig_Node();
114
- $macros = new Twig_Node();
115
- $traits = new Twig_Node();
116
- $filename = 'foo.twig';
117
-
118
- $node = new Twig_Node_Module($body, $extends, $blocks, $macros, $traits, new Twig_Node(array()), $filename);
119
- $node = new Twig_Node_SandboxedModule($node, array('for'), array('upper'), array('cycle'));
120
-
121
- $tests[] = array($node, <<<EOF
122
- <?php
123
-
124
- /* foo.twig */
125
- class __TwigTemplate_a2bfbf7dd6ab85666684fe9297f69363a3fc2046d90f22a317d380c18638df0d extends Twig_Template
126
- {
127
- public function __construct(Twig_Environment \$env)
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
- );
143
- }
144
-
145
- protected function doGetParent(array \$context)
146
- {
147
- return "layout.twig";
148
- }
149
-
150
- protected function doDisplay(array \$context, array \$blocks = array())
151
- {
152
- \$this->checkSecurity();
153
- \$this->parent->display(\$context, array_merge(\$this->blocks, \$blocks));
154
- }
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()
184
- {
185
- return "foo.twig";
186
- }
187
-
188
- public function isTraitable()
189
- {
190
- return false;
191
- }
192
-
193
- public function getDebugInfo()
194
- {
195
- return array ( 11 => 1,);
196
- }
197
- }
198
- EOF
199
- , $twig);
200
-
201
- return $tests;
202
- }
203
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/twig/twig/test/Twig/Tests/Profiler/Dumper/AbstractTest.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of Twig.
5
+ *
6
+ * (c) Fabien Potencier
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ abstract class Twig_Tests_Profiler_Dumper_AbstractTest extends PHPUnit_Framework_TestCase
13
+ {
14
+ protected function getProfile()
15
+ {
16
+ $profile = new Twig_Profiler_Profile();
17
+ $index = new Twig_Profiler_Profile('index.twig', Twig_Profiler_Profile::TEMPLATE);
18
+ $profile->addProfile($index);
19
+ $body = new Twig_Profiler_Profile('embedded.twig', Twig_Profiler_Profile::BLOCK, 'body');
20
+ $body->leave();
21
+ $index->addProfile($body);
22
+ $embedded = new Twig_Profiler_Profile('embedded.twig', Twig_Profiler_Profile::TEMPLATE);
23
+ $included = new Twig_Profiler_Profile('included.twig', Twig_Profiler_Profile::TEMPLATE);
24
+ $embedded->addProfile($included);
25
+ $index->addProfile($embedded);
26
+ $included->leave();
27
+ $embedded->leave();
28
+
29
+ $macro = new Twig_Profiler_Profile('index.twig', Twig_Profiler_Profile::MACRO, 'foo');
30
+ $macro->leave();
31
+ $index->addProfile($macro);
32
+
33
+ $embedded = clone $embedded;
34
+ $index->addProfile($embedded);
35
+ $a = range(1, 1000);
36
+ $embedded->leave();
37
+ $profile->leave();
38
+
39
+ usleep(5000);
40
+ $index->leave();
41
+
42
+ return $profile;
43
+ }
44
+ }
vendor/twig/twig/test/Twig/Tests/Profiler/Dumper/BlackfireTest.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of Twig.
5
+ *
6
+ * (c) Fabien Potencier
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ class Twig_Tests_Profiler_Dumper_BlackfireTest extends Twig_Tests_Profiler_Dumper_AbstractTest
13
+ {
14
+ public function testDump()
15
+ {
16
+ $dumper = new Twig_Profiler_Dumper_Blackfire();
17
+
18
+ $this->assertStringMatchesFormat(<<<EOF
19
+ file-format: BlackfireProbe
20
+ cost-dimensions: wt mu pmu
21
+ request-start: %d.%d
22
+
23
+ main()//1 %d %d %d
24
+ main()==>index.twig//1 %d %d %d
25
+ index.twig==>embedded.twig::block(body)//1 %d %d 0
26
+ index.twig==>embedded.twig//2 %d %d %d
27
+ embedded.twig==>included.twig//2 %d %d %d
28
+ index.twig==>index.twig::macro(foo)//1 %d %d %d
29
+ EOF
30
+ , $dumper->dump($this->getProfile()));
31
+ }
32
+ }
vendor/twig/twig/test/Twig/Tests/Profiler/Dumper/HtmlTest.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of Twig.
5
+ *
6
+ * (c) Fabien Potencier
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ class Twig_Tests_Profiler_Dumper_HtmlTest extends Twig_Tests_Profiler_Dumper_AbstractTest
13
+ {
14
+ public function testDump()
15
+ {
16
+ $dumper = new Twig_Profiler_Dumper_Html();
17
+ $this->assertStringMatchesFormat(<<<EOF
18
+ <pre>main
19
+ └ <span style="background-color: #ffd">index.twig</span> <span style="color: #d44">%d.%dms/%d%</span>
20
+ └ embedded.twig::block(<span style="background-color: #dfd">body</span>)
21
+ └ <span style="background-color: #ffd">embedded.twig</span>
22
+ │ └ <span style="background-color: #ffd">included.twig</span>
23
+ └ index.twig::macro(<span style="background-color: #ddf">foo</span>)
24
+ └ <span style="background-color: #ffd">embedded.twig</span>
25
+ └ <span style="background-color: #ffd">included.twig</span>
26
+ </pre>
27
+ EOF
28
+ , $dumper->dump($this->getProfile()));
29
+ }
30
+ }
vendor/twig/twig/test/Twig/Tests/Profiler/Dumper/TextTest.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of Twig.
5
+ *
6
+ * (c) Fabien Potencier
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ class Twig_Tests_Profiler_Dumper_TextTest extends Twig_Tests_Profiler_Dumper_AbstractTest
13
+ {
14
+ public function testDump()
15
+ {
16
+ $dumper = new Twig_Profiler_Dumper_Text();
17
+ $this->assertStringMatchesFormat(<<<EOF
18
+ main
19
+ └ index.twig %d.%dms/%d%
20
+ └ embedded.twig::block(body)
21
+ └ embedded.twig
22
+ │ └ included.twig
23
+ └ index.twig::macro(foo)
24
+ └ embedded.twig
25
+ └ included.twig
26
+
27
+ EOF
28
+ , $dumper->dump($this->getProfile()));
29
+ }
30
+ }
vendor/twig/twig/test/Twig/Tests/Profiler/ProfileTest.php ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of Twig.
5
+ *
6
+ * (c) Fabien Potencier
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ class Twig_Tests_Profiler_ProfileTest extends PHPUnit_Framework_TestCase
13
+ {
14
+ public function testConstructor()
15
+ {
16
+ $profile = new Twig_Profiler_Profile('template', 'type', 'name');
17
+
18
+ $this->assertEquals('template', $profile->getTemplate());
19
+ $this->assertEquals('type', $profile->getType());
20
+ $this->assertEquals('name', $profile->getName());
21
+ }
22
+
23
+ public function testIsRoot()
24
+ {
25
+ $profile = new Twig_Profiler_Profile('template', Twig_Profiler_Profile::ROOT);
26
+ $this->assertTrue($profile->isRoot());
27
+
28
+ $profile = new Twig_Profiler_Profile('template', Twig_Profiler_Profile::TEMPLATE);
29
+ $this->assertFalse($profile->isRoot());
30
+ }
31
+
32
+ public function testIsTemplate()
33
+ {
34
+ $profile = new Twig_Profiler_Profile('template', Twig_Profiler_Profile::TEMPLATE);
35
+ $this->assertTrue($profile->isTemplate());
36
+
37
+ $profile = new Twig_Profiler_Profile('template', Twig_Profiler_Profile::ROOT);
38
+ $this->assertFalse($profile->isTemplate());
39
+ }
40
+
41
+ public function testIsBlock()
42
+ {
43
+ $profile = new Twig_Profiler_Profile('template', Twig_Profiler_Profile::BLOCK);
44
+ $this->assertTrue($profile->isBlock());
45
+
46
+ $profile = new Twig_Profiler_Profile('template', Twig_Profiler_Profile::ROOT);
47
+ $this->assertFalse($profile->isBlock());
48
+ }
49
+
50
+ public function testIsMacro()
51
+ {
52
+ $profile = new Twig_Profiler_Profile('template', Twig_Profiler_Profile::MACRO);
53
+ $this->assertTrue($profile->isMacro());
54
+
55
+ $profile = new Twig_Profiler_Profile('template', Twig_Profiler_Profile::ROOT);
56
+ $this->assertFalse($profile->isMacro());
57
+ }
58
+
59
+ public function testGetAddProfile()
60
+ {
61
+ $profile = new Twig_Profiler_Profile();
62
+ $profile->addProfile($a = new Twig_Profiler_Profile());
63
+ $profile->addProfile($b = new Twig_Profiler_Profile());
64
+
65
+ $this->assertSame(array($a, $b), $profile->getProfiles());
66
+ $this->assertSame(array($a, $b), iterator_to_array($profile));
67
+ }
68
+
69
+ public function testGetDuration()
70
+ {
71
+ $profile = new Twig_Profiler_Profile();
72
+ $profile->leave();
73
+
74
+ $this->assertTrue($profile->getDuration() > 0);
75
+ }
76
+
77
+ public function testSerialize()
78
+ {
79
+ $profile = new Twig_Profiler_Profile('template', 'type', 'name');
80
+ $profile1 = new Twig_Profiler_Profile('template1', 'type1', 'name1');
81
+ $profile->addProfile($profile1);
82
+ $profile->leave();
83
+ $profile1->leave();
84
+
85
+ $profile2 = unserialize(serialize($profile));
86
+ $profiles = $profile->getProfiles();
87
+ $this->assertCount(1, $profiles);
88
+ $profile3 = $profiles[0];
89
+
90
+ $this->assertEquals($profile->getTemplate(), $profile2->getTemplate());
91
+ $this->assertEquals($profile->getType(), $profile2->getType());
92
+ $this->assertEquals($profile->getName(), $profile2->getName());
93
+ $this->assertEquals($profile->getDuration(), $profile2->getDuration());
94
+
95
+ $this->assertEquals($profile1->getTemplate(), $profile3->getTemplate());
96
+ $this->assertEquals($profile1->getType(), $profile3->getType());
97
+ $this->assertEquals($profile1->getName(), $profile3->getName());
98
+ }
99
+ }
vendor/twig/twig/test/Twig/Tests/TemplateTest.php CHANGED
@@ -310,7 +310,7 @@ class Twig_Tests_TemplateTest extends PHPUnit_Framework_TestCase
310
  foreach ($basicTests as $test) {
311
  // properties cannot be numbers
312
  if (($testObject[0] instanceof stdClass || $testObject[0] instanceof Twig_TemplatePropertyObject) && is_numeric($test[2])) {
313
- continue;
314
  }
315
 
316
  if ('+4' === $test[2] && $methodObject === $testObject[0]) {
@@ -347,7 +347,7 @@ class Twig_Tests_TemplateTest extends PHPUnit_Framework_TestCase
347
  }
348
  }
349
 
350
- $methodAndPropObject = new Twig_TemplateMethodAndPropObject;
351
 
352
  // additional method tests
353
  $tests = array_merge($tests, array(
@@ -396,7 +396,7 @@ class Twig_TemplateTest extends Twig_Template
396
  {
397
  parent::__construct($env);
398
  $this->useExtGetAttribute = $useExtGetAttribute;
399
- Twig_Template::clearCache();
400
  }
401
 
402
  public function getZero()
310
  foreach ($basicTests as $test) {
311
  // properties cannot be numbers
312
  if (($testObject[0] instanceof stdClass || $testObject[0] instanceof Twig_TemplatePropertyObject) && is_numeric($test[2])) {
313
+ continue;
314
  }
315
 
316
  if ('+4' === $test[2] && $methodObject === $testObject[0]) {
347
  }
348
  }
349
 
350
+ $methodAndPropObject = new Twig_TemplateMethodAndPropObject();
351
 
352
  // additional method tests
353
  $tests = array_merge($tests, array(
396
  {
397
  parent::__construct($env);
398
  $this->useExtGetAttribute = $useExtGetAttribute;
399
+ self::$cache = array();
400
  }
401
 
402
  public function getZero()
vendor/twig/twig/test/Twig/Tests/escapingTest.php CHANGED
@@ -6,7 +6,6 @@
6
  * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
7
  * @license http://framework.zend.com/license/new-bsd New BSD License
8
  */
9
-
10
  class Twig_Test_EscapingTest extends PHPUnit_Framework_TestCase
11
  {
12
  /**
@@ -17,7 +16,7 @@ class Twig_Test_EscapingTest extends PHPUnit_Framework_TestCase
17
  '"' => '&quot;',
18
  '<' => '&lt;',
19
  '>' => '&gt;',
20
- '&' => '&amp;'
21
  );
22
 
23
  protected $htmlAttrSpecialChars = array(
@@ -227,7 +226,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 $codepoint Unicode codepoint in hex notation
231
  * @return string UTF-8 literal string
232
  */
233
  protected function codepointToUtf8($codepoint)
@@ -256,7 +255,7 @@ class Twig_Test_EscapingTest extends PHPUnit_Framework_TestCase
256
  public function testJavascriptEscapingEscapesOwaspRecommendedRanges()
257
  {
258
  $immune = array(',', '.', '_'); // Exceptions to escaping ranges
259
- for ($chr=0; $chr < 0xFF; $chr++) {
260
  if ($chr >= 0x30 && $chr <= 0x39
261
  || $chr >= 0x41 && $chr <= 0x5A
262
  || $chr >= 0x61 && $chr <= 0x7A) {
@@ -279,7 +278,7 @@ class Twig_Test_EscapingTest extends PHPUnit_Framework_TestCase
279
  public function testHtmlAttributeEscapingEscapesOwaspRecommendedRanges()
280
  {
281
  $immune = array(',', '.', '-', '_'); // Exceptions to escaping ranges
282
- for ($chr=0; $chr < 0xFF; $chr++) {
283
  if ($chr >= 0x30 && $chr <= 0x39
284
  || $chr >= 0x41 && $chr <= 0x5A
285
  || $chr >= 0x61 && $chr <= 0x7A) {
@@ -302,7 +301,7 @@ class Twig_Test_EscapingTest extends PHPUnit_Framework_TestCase
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
308
  || $chr >= 0x61 && $chr <= 0x7A) {
6
  * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
7
  * @license http://framework.zend.com/license/new-bsd New BSD License
8
  */
 
9
  class Twig_Test_EscapingTest extends PHPUnit_Framework_TestCase
10
  {
11
  /**
16
  '"' => '&quot;',
17
  '<' => '&lt;',
18
  '>' => '&gt;',
19
+ '&' => '&amp;',
20
  );
21
 
22
  protected $htmlAttrSpecialChars = array(
226
  /**
227
  * Convert a Unicode Codepoint to a literal UTF-8 character.
228
  *
229
+ * @param int $codepoint Unicode codepoint in hex notation
230
  * @return string UTF-8 literal string
231
  */
232
  protected function codepointToUtf8($codepoint)
255
  public function testJavascriptEscapingEscapesOwaspRecommendedRanges()
256
  {
257
  $immune = array(',', '.', '_'); // Exceptions to escaping ranges
258
+ for ($chr = 0; $chr < 0xFF; $chr++) {
259
  if ($chr >= 0x30 && $chr <= 0x39
260
  || $chr >= 0x41 && $chr <= 0x5A
261
  || $chr >= 0x61 && $chr <= 0x7A) {
278
  public function testHtmlAttributeEscapingEscapesOwaspRecommendedRanges()
279
  {
280
  $immune = array(',', '.', '-', '_'); // Exceptions to escaping ranges
281
+ for ($chr = 0; $chr < 0xFF; $chr++) {
282
  if ($chr >= 0x30 && $chr <= 0x39
283
  || $chr >= 0x41 && $chr <= 0x5A
284
  || $chr >= 0x61 && $chr <= 0x7A) {
301
  public function testCssEscapingEscapesOwaspRecommendedRanges()
302
  {
303
  // CSS has no exceptions to escaping ranges
304
+ for ($chr = 0; $chr < 0xFF; $chr++) {
305
  if ($chr >= 0x30 && $chr <= 0x39
306
  || $chr >= 0x41 && $chr <= 0x5A
307
  || $chr >= 0x61 && $chr <= 0x7A) {