Timber - Version 0.22.0

Version Description

  • Added fetch method to Timber (thanks @xaivars and @erik-landvall)
  • Added a total to the pagination data array (thanks @lggorman)
  • Threaded comments get some love! (thanks @josephbergdoll)
  • A fix to date parsing when handling numeric timestamps (thanks @xaivars)
Download this release

Release Info

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

Code changes from version 0.21.10 to 0.22.0

Files changed (103) hide show
  1. README.md +7 -0
  2. lib/timber-comment.php +28 -0
  3. lib/timber-post.php +1 -1
  4. lib/timber-twig.php +2 -0
  5. readme.txt +7 -1
  6. timber-starter-theme/.gitignore +2 -0
  7. timber-starter-theme/.travis.yml +19 -0
  8. timber-starter-theme/bin/install-wp-tests.sh +78 -0
  9. timber-starter-theme/composer.json +29 -0
  10. timber-starter-theme/composer.lock +133 -0
  11. timber-starter-theme/phpunit.xml +20 -0
  12. timber-starter-theme/templates/404.twig +0 -0
  13. timber-starter-theme/templates/author.twig +0 -0
  14. timber-starter-theme/templates/base.twig +0 -0
  15. timber-starter-theme/templates/comment.twig +0 -0
  16. timber-starter-theme/templates/footer.twig +0 -0
  17. timber-starter-theme/templates/html-header.twig +0 -0
  18. timber-starter-theme/templates/index.twig +0 -0
  19. timber-starter-theme/templates/page-plugin.twig +0 -0
  20. timber-starter-theme/templates/page.twig +0 -0
  21. timber-starter-theme/templates/sidebar.twig +0 -0
  22. timber-starter-theme/templates/single-password.twig +0 -0
  23. timber-starter-theme/templates/single.twig +0 -0
  24. timber-starter-theme/templates/tease-post.twig +0 -0
  25. timber-starter-theme/templates/tease.twig +0 -0
  26. timber-starter-theme/tests/bootstrap.php +27 -0
  27. timber-starter-theme/tests/test-timber-starter-theme.php +54 -0
  28. timber.php +16 -2
  29. vendor/autoload.php +1 -1
  30. vendor/composer/autoload_real.php +4 -4
  31. vendor/composer/installed.json +11 -7
  32. vendor/twig/twig/.travis.yml +30 -19
  33. vendor/twig/twig/CHANGELOG +9 -0
  34. vendor/twig/twig/composer.json +5 -1
  35. vendor/twig/twig/doc/advanced.rst +17 -0
  36. vendor/twig/twig/doc/deprecated.rst +12 -0
  37. vendor/twig/twig/doc/recipes.rst +70 -7
  38. vendor/twig/twig/doc/templates.rst +4 -0
  39. vendor/twig/twig/ext/twig/php_twig.h +1 -1
  40. vendor/twig/twig/lib/Twig/Autoloader.php +6 -0
  41. vendor/twig/twig/lib/Twig/BaseNodeVisitor.php +2 -2
  42. vendor/twig/twig/lib/Twig/Compiler.php +1 -2
  43. vendor/twig/twig/lib/Twig/Environment.php +32 -25
  44. vendor/twig/twig/lib/Twig/ExpressionParser.php +20 -0
  45. vendor/twig/twig/lib/Twig/Extension/Core.php +47 -40
  46. vendor/twig/twig/lib/Twig/Extension/Escaper.php +12 -3
  47. vendor/twig/twig/lib/Twig/Extension/Profiler.php +2 -2
  48. vendor/twig/twig/lib/Twig/Filter.php +2 -0
  49. vendor/twig/twig/lib/Twig/Filter/Function.php +2 -0
  50. vendor/twig/twig/lib/Twig/Filter/Method.php +2 -0
  51. vendor/twig/twig/lib/Twig/Filter/Node.php +2 -0
  52. vendor/twig/twig/lib/Twig/Function.php +2 -0
  53. vendor/twig/twig/lib/Twig/Function/Function.php +2 -0
  54. vendor/twig/twig/lib/Twig/Function/Method.php +2 -0
  55. vendor/twig/twig/lib/Twig/Function/Node.php +2 -0
  56. vendor/twig/twig/lib/Twig/Lexer.php +4 -0
  57. vendor/twig/twig/lib/Twig/Loader/Array.php +0 -2
  58. vendor/twig/twig/lib/Twig/Loader/Filesystem.php +27 -7
  59. vendor/twig/twig/lib/Twig/Loader/String.php +2 -0
  60. vendor/twig/twig/lib/Twig/Node.php +2 -0
  61. vendor/twig/twig/lib/Twig/Node/Expression/Name.php +8 -0
  62. vendor/twig/twig/lib/Twig/Node/Module.php +1 -16
  63. vendor/twig/twig/lib/Twig/NodeTraverser.php +1 -2
  64. vendor/twig/twig/lib/Twig/Parser.php +1 -1
  65. vendor/twig/twig/lib/Twig/SimpleFilter.php +12 -0
  66. vendor/twig/twig/lib/Twig/SimpleFunction.php +12 -0
  67. vendor/twig/twig/lib/Twig/SimpleTest.php +12 -0
  68. vendor/twig/twig/lib/Twig/Template.php +4 -6
  69. vendor/twig/twig/lib/Twig/Test.php +2 -0
  70. vendor/twig/twig/lib/Twig/Test/Function.php +2 -0
  71. vendor/twig/twig/lib/Twig/Test/IntegrationTestCase.php +25 -3
  72. vendor/twig/twig/lib/Twig/Test/Method.php +2 -0
  73. vendor/twig/twig/lib/Twig/Test/Node.php +2 -0
  74. vendor/twig/twig/lib/Twig/Test/NodeTestCase.php +1 -1
  75. vendor/twig/twig/lib/Twig/TokenParser/AutoEscape.php +2 -0
  76. vendor/twig/twig/lib/Twig/TokenParserBroker.php +5 -1
  77. vendor/twig/twig/lib/Twig/TokenStream.php +1 -2
  78. vendor/twig/twig/lib/Twig/Util/DeprecationCollector.php +82 -0
  79. vendor/twig/twig/lib/Twig/Util/TemplateDirIterator.php +26 -0
  80. vendor/twig/twig/phpunit.xml.dist +1 -1
  81. vendor/twig/twig/test/Twig/Tests/AutoloaderTest.php +3 -0
  82. vendor/twig/twig/test/Twig/Tests/CompilerTest.php +1 -1
  83. vendor/twig/twig/test/Twig/Tests/EnvironmentTest.php +4 -0
  84. vendor/twig/twig/test/Twig/Tests/Extension/CoreTest.php +12 -12
  85. vendor/twig/twig/test/Twig/Tests/Extension/SandboxTest.php +1 -1
  86. vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/strategy.legacy.test +11 -0
  87. vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/strategy.test +0 -6
  88. vendor/twig/twig/test/Twig/Tests/Fixtures/tags/raw/{basic.test → basic.legacy.test} +0 -0
  89. vendor/twig/twig/test/Twig/Tests/Fixtures/tags/raw/{mixed_usage_with_raw.test → mixed_usage_with_raw.legacy.test} +0 -0
  90. vendor/twig/twig/test/Twig/Tests/Fixtures/tags/raw/{whitespace_control.test → whitespace_control.legacy.test} +0 -0
  91. vendor/twig/twig/test/Twig/Tests/LegacyFixtures/test.legacy.test +8 -0
  92. vendor/twig/twig/test/Twig/Tests/LegacyIntegrationTest.php +45 -0
  93. vendor/twig/twig/test/Twig/Tests/LexerTest.php +22 -22
  94. vendor/twig/twig/test/Twig/Tests/Node/Expression/FilterTest.php +1 -1
  95. vendor/twig/twig/test/Twig/Tests/Node/Expression/FunctionTest.php +1 -1
  96. vendor/twig/twig/test/Twig/Tests/Node/Expression/NameTest.php +2 -4
  97. vendor/twig/twig/test/Twig/Tests/Node/Expression/PHP53/FilterInclude.php +1 -1
  98. vendor/twig/twig/test/Twig/Tests/Node/Expression/PHP53/FunctionInclude.php +1 -1
  99. vendor/twig/twig/test/Twig/Tests/Node/Expression/PHP53/TestInclude.php +1 -1
  100. vendor/twig/twig/test/Twig/Tests/Node/Expression/TestTest.php +1 -1
  101. vendor/twig/twig/test/Twig/Tests/ParserTest.php +4 -4
  102. vendor/twig/twig/test/Twig/Tests/TemplateTest.php +9 -9
  103. vendor/twig/twig/test/Twig/Tests/escapingTest.php +1 -1
README.md CHANGED
@@ -71,6 +71,13 @@ Timber is great for any WordPress developer who cares about writing good, mainta
71
  * [**Timber Sugar**](https://github.com/Upstatement/timber-sugar) A catch-all for goodies to use w Timber.
72
  * [**Twig**](https://github.com/fabpot/Twig) The template language used by Timber.
73
 
 
 
 
 
 
 
 
74
  #### Should I use it?
75
  It's MIT-licensed, so please use in personal or commercial work. Just don't re-sell it. While Timber is still in development, it's also in-use on [hundreds of sites](http://jarednova.github.io/timber/#showcase). While much has been stabilized since the first major push back in June 2013, you should expect some breaking changes as development progresses towards a version 1.0.
76
 
71
  * [**Timber Sugar**](https://github.com/Upstatement/timber-sugar) A catch-all for goodies to use w Timber.
72
  * [**Twig**](https://github.com/fabpot/Twig) The template language used by Timber.
73
 
74
+ #### Projects that use Timber
75
+ * [**Gantry5**](https://wordpress.org/plugins/gantry5/) a framework for theme development
76
+
77
+ #### Helpful Links
78
+ * [**CSS Tricks**](https://css-tricks.com/timber-and-twig-reignited-my-love-for-wordpress/) introduction to Timber
79
+ * [**Twig for Timber Cheatsheet**](http://notlaura.com/the-twig-for-timber-cheatsheet/) by @laras126
80
+
81
  #### Should I use it?
82
  It's MIT-licensed, so please use in personal or commercial work. Just don't re-sell it. While Timber is still in development, it's also in-use on [hundreds of sites](http://jarednova.github.io/timber/#showcase). While much has been stabilized since the first major push back in June 2013, you should expect some breaking changes as development progresses towards a version 1.0.
83
 
lib/timber-comment.php CHANGED
@@ -236,6 +236,34 @@ class TimberComment extends TimberCore implements TimberCoreInterface {
236
  return $value;
237
  }
238
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
239
  /* AVATAR Stuff
240
  ======================= */
241
 
236
  return $value;
237
  }
238
 
239
+ /**
240
+ * Enqueue the WP threaded comments javascript,
241
+ * and fetch the reply link for various comments.
242
+ * @api
243
+ * @param int $comment_id
244
+ * @param int $post_id
245
+ * @return string
246
+ */
247
+ public function reply_link( $reply_text = 'Reply' ) {
248
+ if ( is_singular() && comments_open() && get_option('thread_comments') ) {
249
+ wp_enqueue_script( 'comment-reply' );
250
+ }
251
+
252
+ // Get the comments depth option from the admin panel
253
+ $max_depth = get_option('thread_comments_depth');
254
+
255
+ // Default args
256
+ $args = array(
257
+ 'add_below' => 'comment',
258
+ 'respond_id' => 'respond',
259
+ 'reply_text' => $reply_text,
260
+ 'depth' => 1,
261
+ 'max_depth' => $max_depth,
262
+ );
263
+
264
+ return get_comment_reply_link( $args, $this->ID, $this->post_id );
265
+ }
266
+
267
  /* AVATAR Stuff
268
  ======================= */
269
 
lib/timber-post.php CHANGED
@@ -729,7 +729,7 @@ class TimberPost extends TimberCore implements TimberCoreInterface {
729
  $overridden_cpage = true;
730
  }
731
 
732
- foreach($comments as $key => &$comment) {
733
  $timber_comment = new $CommentClass($comment);
734
  $timber_comments[$timber_comment->id] = $timber_comment;
735
  }
729
  $overridden_cpage = true;
730
  }
731
 
732
+ foreach( $comments as $key => &$comment ) {
733
  $timber_comment = new $CommentClass($comment);
734
  $timber_comments[$timber_comment->id] = $timber_comment;
735
  }
lib/timber-twig.php CHANGED
@@ -266,6 +266,8 @@ class TimberTwig {
266
 
267
  if ( $date instanceof DateTime ) {
268
  $timestamp = $date->getTimestamp();
 
 
269
  } else {
270
  $timestamp = strtotime( $date );
271
  }
266
 
267
  if ( $date instanceof DateTime ) {
268
  $timestamp = $date->getTimestamp();
269
+ } else if (is_numeric( $date ) ) {
270
+ $timestamp = intval( $date );
271
  } else {
272
  $timestamp = strtotime( $date );
273
  }
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.21.10
6
  Tested up to: 4.2.3
7
  PHP version: 5.3.0 or greater
8
  License: GPLv2 or later
@@ -41,6 +41,12 @@ Timber is great for any WordPress developer who cares about writing good, mainta
41
 
42
  == Changelog ==
43
 
 
 
 
 
 
 
44
  = 0.21.10 =
45
  * Removed deprecated twitterify function
46
  * Much more docs (and deprecation docs)
2
  Contributors: jarednova
3
  Tags: template engine, templates, twig
4
  Requires at least: 3.7
5
+ Stable tag: 0.22.0
6
  Tested up to: 4.2.3
7
  PHP version: 5.3.0 or greater
8
  License: GPLv2 or later
41
 
42
  == Changelog ==
43
 
44
+ = 0.22.0 =
45
+ * Added fetch method to Timber (thanks @xaivars and @erik-landvall)
46
+ * Added a total to the pagination data array (thanks @lggorman)
47
+ * Threaded comments get some love! (thanks @josephbergdoll)
48
+ * A fix to date parsing when handling numeric timestamps (thanks @xaivars)
49
+
50
  = 0.21.10 =
51
  * Removed deprecated twitterify function
52
  * Much more docs (and deprecation docs)
timber-starter-theme/.gitignore ADDED
@@ -0,0 +1,2 @@
 
 
1
+ vendor
2
+ wp-content
timber-starter-theme/.travis.yml ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ sudo: false
2
+
3
+ language: php
4
+
5
+ php:
6
+ - 5.3
7
+ - 5.4
8
+ - 5.5
9
+
10
+ env:
11
+ - WP_VERSION=latest WP_MULTISITE=0
12
+ - WP_VERSION=latest WP_MULTISITE=1
13
+
14
+ before_script:
15
+ - bash bin/install-wp-tests.sh wordpress_test root '' localhost $WP_VERSION
16
+ - composer install --dev
17
+
18
+ script:
19
+ - phpunit
timber-starter-theme/bin/install-wp-tests.sh ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+
3
+ if [ $# -lt 3 ]; then
4
+ echo "usage: $0 <db-name> <db-user> <db-pass> [db-host] [wp-version]"
5
+ exit 1
6
+ fi
7
+
8
+ DB_NAME=$1
9
+ DB_USER=$2
10
+ DB_PASS=$3
11
+ DB_HOST=${4-localhost}
12
+ WP_VERSION=${5-master}
13
+
14
+ WP_TESTS_DIR=${WP_TESTS_DIR-/tmp/wordpress-tests-lib}
15
+ WP_CORE_DIR=/tmp/wordpress/
16
+
17
+ set -ex
18
+
19
+ install_wp() {
20
+ mkdir -p $WP_CORE_DIR
21
+
22
+ if [ $WP_VERSION == 'latest' ]; then
23
+ local ARCHIVE_NAME='latest'
24
+ else
25
+ local ARCHIVE_NAME="wordpress-$WP_VERSION"
26
+ fi
27
+
28
+ wget -nv -O /tmp/wordpress.tar.gz http://wordpress.org/${ARCHIVE_NAME}.tar.gz
29
+ tar --strip-components=1 -zxmf /tmp/wordpress.tar.gz -C $WP_CORE_DIR
30
+
31
+ wget -nv -O $WP_CORE_DIR/wp-content/db.php https://raw.github.com/markoheijnen/wp-mysqli/master/db.php
32
+ }
33
+
34
+ install_test_suite() {
35
+ # portable in-place argument for both GNU sed and Mac OSX sed
36
+ if [[ $(uname -s) == 'Darwin' ]]; then
37
+ local ioption='-i ""'
38
+ else
39
+ local ioption='-i'
40
+ fi
41
+
42
+ # set up testing suite
43
+ mkdir -p $WP_TESTS_DIR
44
+ cd $WP_TESTS_DIR
45
+ svn co --quiet http://develop.svn.wordpress.org/trunk/tests/phpunit/includes/
46
+
47
+ wget -nv -O wp-tests-config.php http://develop.svn.wordpress.org/trunk/wp-tests-config-sample.php
48
+ sed $ioption "s:dirname( __FILE__ ) . '/src/':'$WP_CORE_DIR':" wp-tests-config.php
49
+ sed $ioption "s/youremptytestdbnamehere/$DB_NAME/" wp-tests-config.php
50
+ sed $ioption "s/yourusernamehere/$DB_USER/" wp-tests-config.php
51
+ sed $ioption "s/yourpasswordhere/$DB_PASS/" wp-tests-config.php
52
+ sed $ioption "s|localhost|${DB_HOST}|" wp-tests-config.php
53
+ }
54
+
55
+ install_db() {
56
+ # parse DB_HOST for port or socket references
57
+ local PARTS=(${DB_HOST//\:/ })
58
+ local DB_HOSTNAME=${PARTS[0]};
59
+ local DB_SOCK_OR_PORT=${PARTS[1]};
60
+ local EXTRA=""
61
+
62
+ if ! [ -z $DB_HOSTNAME ] ; then
63
+ if [[ "$DB_SOCK_OR_PORT" =~ ^[0-9]+$ ]] ; then
64
+ EXTRA=" --host=$DB_HOSTNAME --port=$DB_SOCK_OR_PORT --protocol=tcp"
65
+ elif ! [ -z $DB_SOCK_OR_PORT ] ; then
66
+ EXTRA=" --socket=$DB_SOCK_OR_PORT"
67
+ elif ! [ -z $DB_HOSTNAME ] ; then
68
+ EXTRA=" --host=$DB_HOSTNAME --protocol=tcp"
69
+ fi
70
+ fi
71
+
72
+ # create database
73
+ mysqladmin create $DB_NAME --user="$DB_USER" --password="$DB_PASS"$EXTRA
74
+ }
75
+
76
+ install_wp
77
+ install_test_suite
78
+ install_db
timber-starter-theme/composer.json ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "upstatement/timber-starter-theme",
3
+ "description": "Starter theme to build a Timber theme",
4
+ "type":"wordpress-theme",
5
+ "minimum-stability" : "stable",
6
+ "authors": [
7
+ {
8
+ "name": "jarednova",
9
+ "email": "jared@upstatement.com"
10
+ }
11
+ ],
12
+ "extra": {
13
+ "installer-paths": {
14
+ "../../plugins/{$name}/": [
15
+ "wpackagist-plugin/*",
16
+ "type:wordpress-plugin"
17
+ ]
18
+ }
19
+ },
20
+ "require": {
21
+ "wpackagist-plugin/timber-library": "0.21.*"
22
+ },
23
+ "repositories": [
24
+ {
25
+ "type": "composer",
26
+ "url": "http://wpackagist.org"
27
+ }
28
+ ]
29
+ }
timber-starter-theme/composer.lock ADDED
@@ -0,0 +1,133 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_readme": [
3
+ "This file locks the dependencies of your project to a known state",
4
+ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
5
+ "This file is @generated automatically"
6
+ ],
7
+ "hash": "46f646441e91cc10352e6d694cd94e86",
8
+ "packages": [
9
+ {
10
+ "name": "composer/installers",
11
+ "version": "v1.0.21",
12
+ "source": {
13
+ "type": "git",
14
+ "url": "https://github.com/composer/installers.git",
15
+ "reference": "d64e23fce42a4063d63262b19b8e7c0f3b5e4c45"
16
+ },
17
+ "dist": {
18
+ "type": "zip",
19
+ "url": "https://api.github.com/repos/composer/installers/zipball/d64e23fce42a4063d63262b19b8e7c0f3b5e4c45",
20
+ "reference": "d64e23fce42a4063d63262b19b8e7c0f3b5e4c45",
21
+ "shasum": ""
22
+ },
23
+ "replace": {
24
+ "roundcube/plugin-installer": "*",
25
+ "shama/baton": "*"
26
+ },
27
+ "require-dev": {
28
+ "composer/composer": "1.0.*@dev",
29
+ "phpunit/phpunit": "4.1.*"
30
+ },
31
+ "type": "composer-installer",
32
+ "extra": {
33
+ "class": "Composer\\Installers\\Installer",
34
+ "branch-alias": {
35
+ "dev-master": "1.0-dev"
36
+ }
37
+ },
38
+ "autoload": {
39
+ "psr-0": {
40
+ "Composer\\Installers\\": "src/"
41
+ }
42
+ },
43
+ "notification-url": "https://packagist.org/downloads/",
44
+ "license": [
45
+ "MIT"
46
+ ],
47
+ "authors": [
48
+ {
49
+ "name": "Kyle Robinson Young",
50
+ "email": "kyle@dontkry.com",
51
+ "homepage": "https://github.com/shama"
52
+ }
53
+ ],
54
+ "description": "A multi-framework Composer library installer",
55
+ "homepage": "http://composer.github.com/installers/",
56
+ "keywords": [
57
+ "Craft",
58
+ "Dolibarr",
59
+ "Hurad",
60
+ "MODX Evo",
61
+ "OXID",
62
+ "SMF",
63
+ "Thelia",
64
+ "WolfCMS",
65
+ "agl",
66
+ "aimeos",
67
+ "annotatecms",
68
+ "bitrix",
69
+ "cakephp",
70
+ "chef",
71
+ "codeigniter",
72
+ "concrete5",
73
+ "croogo",
74
+ "dokuwiki",
75
+ "drupal",
76
+ "elgg",
77
+ "fuelphp",
78
+ "grav",
79
+ "installer",
80
+ "joomla",
81
+ "kohana",
82
+ "laravel",
83
+ "lithium",
84
+ "magento",
85
+ "mako",
86
+ "mediawiki",
87
+ "modulework",
88
+ "moodle",
89
+ "phpbb",
90
+ "piwik",
91
+ "ppi",
92
+ "puppet",
93
+ "roundcube",
94
+ "shopware",
95
+ "silverstripe",
96
+ "symfony",
97
+ "typo3",
98
+ "wordpress",
99
+ "zend",
100
+ "zikula"
101
+ ],
102
+ "time": "2015-02-18 17:17:01"
103
+ },
104
+ {
105
+ "name": "wpackagist-plugin/timber-library",
106
+ "version": "0.21.8",
107
+ "source": {
108
+ "type": "svn",
109
+ "url": "http://plugins.svn.wordpress.org/timber-library/",
110
+ "reference": "tags/0.21.8"
111
+ },
112
+ "dist": {
113
+ "type": "zip",
114
+ "url": "https://downloads.wordpress.org/plugin/timber-library.0.21.8.zip",
115
+ "reference": null,
116
+ "shasum": null
117
+ },
118
+ "require": {
119
+ "composer/installers": "~1.0"
120
+ },
121
+ "type": "wordpress-plugin",
122
+ "homepage": "https://wordpress.org/plugins/timber-library/"
123
+ }
124
+ ],
125
+ "packages-dev": [],
126
+ "aliases": [],
127
+ "minimum-stability": "stable",
128
+ "stability-flags": [],
129
+ "prefer-stable": false,
130
+ "prefer-lowest": false,
131
+ "platform": [],
132
+ "platform-dev": []
133
+ }
timber-starter-theme/phpunit.xml ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <phpunit
2
+ bootstrap="tests/bootstrap.php"
3
+ backupGlobals="false"
4
+ colors="true"
5
+ convertErrorsToExceptions="true"
6
+ convertNoticesToExceptions="true"
7
+ convertWarningsToExceptions="true"
8
+ >
9
+ <testsuites>
10
+ <testsuite>
11
+ <directory prefix="test-" suffix=".php">./tests/</directory>
12
+ </testsuite>
13
+ <!-- The suite below HAS to be last to run,
14
+ as it includes a test that sets some const and would contaminate
15
+ the other tests as well. -->
16
+ <testsuite>
17
+ <directory prefix="testX-" suffix=".php">./tests/</directory>
18
+ </testsuite>
19
+ </testsuites>
20
+ </phpunit>
timber-starter-theme/templates/404.twig CHANGED
File without changes
timber-starter-theme/templates/author.twig CHANGED
File without changes
timber-starter-theme/templates/base.twig CHANGED
File without changes
timber-starter-theme/templates/comment.twig CHANGED
File without changes
timber-starter-theme/templates/footer.twig CHANGED
File without changes
timber-starter-theme/templates/html-header.twig CHANGED
File without changes
timber-starter-theme/templates/index.twig CHANGED
File without changes
timber-starter-theme/templates/page-plugin.twig CHANGED
File without changes
timber-starter-theme/templates/page.twig CHANGED
File without changes
timber-starter-theme/templates/sidebar.twig CHANGED
File without changes
timber-starter-theme/templates/single-password.twig CHANGED
File without changes
timber-starter-theme/templates/single.twig CHANGED
File without changes
timber-starter-theme/templates/tease-post.twig CHANGED
File without changes
timber-starter-theme/templates/tease.twig CHANGED
File without changes
timber-starter-theme/tests/bootstrap.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( file_exists($composer_autoload = __DIR__ . '/../vendor/autoload.php') ) {
4
+ require_once($composer_autoload);
5
+ }
6
+
7
+
8
+ $_tests_dir = getenv('WP_TESTS_DIR');
9
+ if ( !$_tests_dir ) $_tests_dir = '/tmp/wordpress-tests-lib';
10
+
11
+ require_once $_tests_dir . '/includes/functions.php';
12
+
13
+ function _manually_load_plugin() {
14
+ $plugins_dir = dirname( __FILE__ ).'/../../../plugins';
15
+ $timber = $plugins_dir.'/timber/timber.php';
16
+ if ( file_exists($timber) ) {
17
+ require_once($timber);
18
+ } else {
19
+ $timber_library = $plugins_dir.'/timber-library/timber.php';
20
+ if ( file_exists($timber_library) ) {
21
+ require_once($timber_library);
22
+ }
23
+ }
24
+ }
25
+
26
+ tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' );
27
+ require $_tests_dir . '/includes/bootstrap.php';
timber-starter-theme/tests/test-timber-starter-theme.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class TestTimberStarterTheme extends WP_UnitTestCase {
4
+
5
+ function setUp() {
6
+ self::_setupStarterTheme();
7
+ require_once(get_template_directory().'/functions.php');
8
+ }
9
+
10
+ function tearDown() {
11
+ switch_theme('twentythirteen');
12
+ }
13
+
14
+ function testFunctionsPHP() {
15
+ $context = Timber::get_context();
16
+ $this->assertEquals('StarterSite', get_class($context['site']));
17
+ $this->assertTrue(current_theme_supports('post-thumbnails'));
18
+ $this->assertEquals('bar', $context['foo']);
19
+ }
20
+
21
+ function testLoading() {
22
+ $str = Timber::compile('tease.twig');
23
+ $this->assertStringStartsWith('<article class="tease tease-" id="tease-">', $str);
24
+ $this->assertStringEndsWith('</article>', $str);
25
+ }
26
+
27
+ static function _setupStarterTheme(){
28
+ $dest = WP_CONTENT_DIR.'/themes/timber-starter-theme/';
29
+ $src = __DIR__.'/../../timber-starter-theme/';
30
+ if (is_dir($src)) {
31
+ self::_copyDirectory($src, $dest);
32
+ switch_theme('timber-starter-theme');
33
+ } else {
34
+ echo 'no its not';
35
+ }
36
+ }
37
+
38
+ static function _copyDirectory($src, $dst){
39
+ $dir = opendir($src);
40
+ @mkdir($dst);
41
+ while(false !== ( $file = readdir($dir)) ) {
42
+ if (( $file != '.' ) && ( $file != '..' )) {
43
+ if ( is_dir($src . '/' . $file) ) {
44
+ self::_copyDirectory($src . '/' . $file,$dst . '/' . $file);
45
+ }
46
+ else {
47
+ copy($src . '/' . $file,$dst . '/' . $file);
48
+ }
49
+ }
50
+ }
51
+ closedir($dir);
52
+ }
53
+
54
+ }
timber.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: Timber
4
  Plugin URI: http://timber.upstatement.com
5
  Description: The WordPress Timber Library allows you to write themes using the power Twig templates
6
  Author: Jared Novack + Upstatement
7
- Version: 0.21.10
8
  Author URI: http://upstatement.com/
9
  */
10
 
@@ -310,7 +310,7 @@ class Timber {
310
  * @param string $cache_mode
311
  * @return bool|string
312
  */
313
- public static function render( $filenames, $data = array(), $expires = false, $cache_mode = TimberLoader::CACHE_USE_DEFAULT ) {
314
  if ( $expires === true ) {
315
  //if this is reading as true; the user probably is using the old $echo param
316
  //so we should move all vars up by a spot
@@ -319,6 +319,18 @@ class Timber {
319
  }
320
  $output = self::compile( $filenames, $data, $expires, $cache_mode, true );
321
  $output = apply_filters( 'timber_compile_result', $output );
 
 
 
 
 
 
 
 
 
 
 
 
322
  echo $output;
323
  return $output;
324
  }
@@ -464,6 +476,8 @@ class Timber {
464
  $args = array_merge( $args, $prefs );
465
  }
466
  $data = array();
 
 
467
  $data['pages'] = TimberHelper::paginate_links( $args );
468
  $next = get_next_posts_page_link( $args['total'] );
469
  if ( $next ) {
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.22.0
8
  Author URI: http://upstatement.com/
9
  */
10
 
310
  * @param string $cache_mode
311
  * @return bool|string
312
  */
313
+ public static function fetch( $filenames, $data = array(), $expires = false, $cache_mode = TimberLoader::CACHE_USE_DEFAULT ) {
314
  if ( $expires === true ) {
315
  //if this is reading as true; the user probably is using the old $echo param
316
  //so we should move all vars up by a spot
319
  }
320
  $output = self::compile( $filenames, $data, $expires, $cache_mode, true );
321
  $output = apply_filters( 'timber_compile_result', $output );
322
+ return $output;
323
+ }
324
+
325
+ /**
326
+ * @param array $filenames
327
+ * @param array $data
328
+ * @param bool $expires
329
+ * @param string $cache_mode
330
+ * @return bool|string
331
+ */
332
+ public static function render( $filenames, $data = array(), $expires = false, $cache_mode = TimberLoader::CACHE_USE_DEFAULT ) {
333
+ $output = static::fetch( $filenames, $data, $expires, $cache_mode );
334
  echo $output;
335
  return $output;
336
  }
476
  $args = array_merge( $args, $prefs );
477
  }
478
  $data = array();
479
+ $data['current'] = $args['current'];
480
+ $data['total'] = $args['total'];
481
  $data['pages'] = TimberHelper::paginate_links( $args );
482
  $next = get_next_posts_page_link( $args['total'] );
483
  if ( $next ) {
vendor/autoload.php CHANGED
@@ -4,4 +4,4 @@
4
 
5
  require_once __DIR__ . '/composer' . '/autoload_real.php';
6
 
7
- return ComposerAutoloaderInit0998bd60918fc7cd5fbb070663b46709::getLoader();
4
 
5
  require_once __DIR__ . '/composer' . '/autoload_real.php';
6
 
7
+ return ComposerAutoloaderInit68e9a33653fcf1bfe1a370e1f36812f3::getLoader();
vendor/composer/autoload_real.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
- class ComposerAutoloaderInit0998bd60918fc7cd5fbb070663b46709
6
  {
7
  private static $loader;
8
 
@@ -19,9 +19,9 @@ class ComposerAutoloaderInit0998bd60918fc7cd5fbb070663b46709
19
  return self::$loader;
20
  }
21
 
22
- spl_autoload_register(array('ComposerAutoloaderInit0998bd60918fc7cd5fbb070663b46709', 'loadClassLoader'), true, true);
23
  self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
- spl_autoload_unregister(array('ComposerAutoloaderInit0998bd60918fc7cd5fbb070663b46709', 'loadClassLoader'));
25
 
26
  $map = require __DIR__ . '/autoload_namespaces.php';
27
  foreach ($map as $namespace => $path) {
@@ -44,7 +44,7 @@ class ComposerAutoloaderInit0998bd60918fc7cd5fbb070663b46709
44
  }
45
  }
46
 
47
- function composerRequire0998bd60918fc7cd5fbb070663b46709($file)
48
  {
49
  require $file;
50
  }
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
+ class ComposerAutoloaderInit68e9a33653fcf1bfe1a370e1f36812f3
6
  {
7
  private static $loader;
8
 
19
  return self::$loader;
20
  }
21
 
22
+ spl_autoload_register(array('ComposerAutoloaderInit68e9a33653fcf1bfe1a370e1f36812f3', 'loadClassLoader'), true, true);
23
  self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
+ spl_autoload_unregister(array('ComposerAutoloaderInit68e9a33653fcf1bfe1a370e1f36812f3', 'loadClassLoader'));
25
 
26
  $map = require __DIR__ . '/autoload_namespaces.php';
27
  foreach ($map as $namespace => $path) {
44
  }
45
  }
46
 
47
+ function composerRequire68e9a33653fcf1bfe1a370e1f36812f3($file)
48
  {
49
  require $file;
50
  }
vendor/composer/installed.json CHANGED
@@ -98,27 +98,31 @@
98
  },
99
  {
100
  "name": "twig/twig",
101
- "version": "v1.20.0",
102
- "version_normalized": "1.20.0.0",
103
  "source": {
104
  "type": "git",
105
  "url": "https://github.com/twigphp/Twig.git",
106
- "reference": "1ea4e5f81c6d005fe84d0b38e1c4f1955eb86844"
107
  },
108
  "dist": {
109
  "type": "zip",
110
- "url": "https://api.github.com/repos/twigphp/Twig/zipball/1ea4e5f81c6d005fe84d0b38e1c4f1955eb86844",
111
- "reference": "1ea4e5f81c6d005fe84d0b38e1c4f1955eb86844",
112
  "shasum": ""
113
  },
114
  "require": {
115
  "php": ">=5.2.7"
116
  },
117
- "time": "2015-08-12 15:56:39",
 
 
 
 
118
  "type": "library",
119
  "extra": {
120
  "branch-alias": {
121
- "dev-master": "1.20-dev"
122
  }
123
  },
124
  "installation-source": "dist",
98
  },
99
  {
100
  "name": "twig/twig",
101
+ "version": "v1.21.1",
102
+ "version_normalized": "1.21.1.0",
103
  "source": {
104
  "type": "git",
105
  "url": "https://github.com/twigphp/Twig.git",
106
+ "reference": "ca8d3aa90b6a01c82e07909fe815d6b443e75a23"
107
  },
108
  "dist": {
109
  "type": "zip",
110
+ "url": "https://api.github.com/repos/twigphp/Twig/zipball/ca8d3aa90b6a01c82e07909fe815d6b443e75a23",
111
+ "reference": "ca8d3aa90b6a01c82e07909fe815d6b443e75a23",
112
  "shasum": ""
113
  },
114
  "require": {
115
  "php": ">=5.2.7"
116
  },
117
+ "require-dev": {
118
+ "symfony/debug": "~2.7",
119
+ "symfony/phpunit-bridge": "~2.7"
120
+ },
121
+ "time": "2015-08-26 08:58:31",
122
  "type": "library",
123
  "extra": {
124
  "branch-alias": {
125
+ "dev-master": "1.21-dev"
126
  }
127
  },
128
  "installation-source": "dist",
vendor/twig/twig/.travis.yml CHANGED
@@ -1,28 +1,39 @@
1
  language: php
2
 
3
- php:
4
- - 5.2
5
- - 5.3
6
- - 5.4
7
- - 5.5
8
- - 5.6
9
- - hhvm
10
- - nightly
11
 
12
- allow_failures:
13
- - php: nightly
 
 
 
 
 
 
14
 
15
  env:
16
- - TWIG_EXT=no
17
- - TWIG_EXT=yes
 
 
 
 
18
 
19
  before_script:
20
- - if [ "$TWIG_EXT" == "yes" ]; then sh -c "cd ext/twig && phpize && ./configure --enable-twig && make && sudo make install"; fi
21
- - if [ "$TWIG_EXT" == "yes" ]; then echo "extension=twig.so" >> `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"`; fi
 
22
 
23
  matrix:
24
- exclude:
25
- - php: hhvm
26
- env: TWIG_EXT=yes
27
- - php: nightly
28
- env: TWIG_EXT=yes
 
 
1
  language: php
2
 
3
+ sudo: false
4
+
5
+ cache:
6
+ directories:
7
+ - vendor
8
+ - $HOME/.composer/cache
 
 
9
 
10
+ php:
11
+ - 5.2
12
+ - 5.3
13
+ - 5.4
14
+ - 5.5
15
+ - 5.6
16
+ - 7.0
17
+ - hhvm
18
 
19
  env:
20
+ - TWIG_EXT=no
21
+ - TWIG_EXT=yes
22
+
23
+ install:
24
+ # Composer is not available on PHP 5.2
25
+ - if [ ${TRAVIS_PHP_VERSION:0:3} != "5.2" ]; then travis_retry composer install; fi
26
 
27
  before_script:
28
+ - if [ "$TWIG_EXT" == "yes" ]; then sh -c "cd ext/twig && phpize && ./configure --enable-twig && make && make install"; fi
29
+ - if [ "$TWIG_EXT" == "yes" ]; then echo "extension=twig.so" >> `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"`; fi
30
+ - if [ ${TRAVIS_PHP_VERSION:0:3} == "5.2" ]; then sed -i.bak "s|vendor/autoload.php|test/bootstrap.php|" phpunit.xml.dist; fi
31
 
32
  matrix:
33
+ fast_finish: true
34
+ exclude:
35
+ - php: hhvm
36
+ env: TWIG_EXT=yes
37
+ allow_failures:
38
+ - php: 7.0
39
+ env: TWIG_EXT=yes
vendor/twig/twig/CHANGELOG CHANGED
@@ -1,3 +1,12 @@
 
 
 
 
 
 
 
 
 
1
  * 1.20.0 (2015-08-12)
2
 
3
  * forbid access to the Twig environment from templates and internal parts of Twig_Template
1
+ * 1.21.1 (2015-08-26)
2
+
3
+ * fixed regression when using the deprecated Twig_Test_* classes
4
+
5
+ * 1.21.0 (2015-08-24)
6
+
7
+ * added deprecation notices for deprecated features
8
+ * added a deprecation "framework" for filters/functions/tests and test fixtures
9
+
10
  * 1.20.0 (2015-08-12)
11
 
12
  * forbid access to the Twig environment from templates and internal parts of Twig_Template
vendor/twig/twig/composer.json CHANGED
@@ -29,6 +29,10 @@
29
  "require": {
30
  "php": ">=5.2.7"
31
  },
 
 
 
 
32
  "autoload": {
33
  "psr-0" : {
34
  "Twig_" : "lib/"
@@ -36,7 +40,7 @@
36
  },
37
  "extra": {
38
  "branch-alias": {
39
- "dev-master": "1.20-dev"
40
  }
41
  }
42
  }
29
  "require": {
30
  "php": ">=5.2.7"
31
  },
32
+ "require-dev": {
33
+ "symfony/phpunit-bridge": "~2.7",
34
+ "symfony/debug": "~2.7"
35
+ },
36
  "autoload": {
37
  "psr-0" : {
38
  "Twig_" : "lib/"
40
  },
41
  "extra": {
42
  "branch-alias": {
43
+ "dev-master": "1.21-dev"
44
  }
45
  }
46
  }
vendor/twig/twig/doc/advanced.rst CHANGED
@@ -267,6 +267,23 @@ arguments, but after the environment and the context. For instance, a call to
267
  ``'foo'|a_path_b()`` will result in the following arguments to be passed to
268
  the filter: ``('a', 'b', 'foo')``.
269
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
270
  Functions
271
  ---------
272
 
267
  ``'foo'|a_path_b()`` will result in the following arguments to be passed to
268
  the filter: ``('a', 'b', 'foo')``.
269
 
270
+ Deprecated Filters
271
+ ~~~~~~~~~~~~~~~~~~
272
+
273
+ .. versionadded:: 1.21
274
+ Support for deprecated filters was added in Twig 1.21.
275
+
276
+ You can mark a filter as being deprecated by setting the ``deprecated`` option
277
+ to ``true``. You can also give an alternative filter that replaces the
278
+ deprecated one when that makes sense::
279
+
280
+ $filter = new Twig_SimpleFilter('obsolete', function () {
281
+ // ...
282
+ }, array('deprecated' => true, 'alternative' => 'new_one'));
283
+
284
+ When a filter is deprecated, Twig emits a deprecation notice when compiling a
285
+ template using it. See :ref:`deprecation-notices` for more information.
286
+
287
  Functions
288
  ---------
289
 
vendor/twig/twig/doc/deprecated.rst CHANGED
@@ -5,6 +5,12 @@ This document lists all deprecated features in Twig. Deprecated features are
5
  kept for backward compatibility and removed in the next major release (a
6
  feature that was deprecated in Twig 1.x is removed in Twig 2.0).
7
 
 
 
 
 
 
 
8
  Token Parsers
9
  -------------
10
 
@@ -80,6 +86,12 @@ Tests
80
  * The ``sameas`` and ``divisibleby`` tests are deprecated in favor of ``same
81
  as`` and ``divisible by`` respectively.
82
 
 
 
 
 
 
 
83
  Nodes
84
  -----
85
 
5
  kept for backward compatibility and removed in the next major release (a
6
  feature that was deprecated in Twig 1.x is removed in Twig 2.0).
7
 
8
+ Deprecation Notices
9
+ -------------------
10
+
11
+ As of Twig 1.21, Twig generates deprecation notices when a template uses
12
+ deprecated features. See :ref:`deprecation-notices` for more information.
13
+
14
  Token Parsers
15
  -------------
16
 
86
  * The ``sameas`` and ``divisibleby`` tests are deprecated in favor of ``same
87
  as`` and ``divisible by`` respectively.
88
 
89
+ Tags
90
+ ----
91
+
92
+ * As of Twig 1.x, the ``raw`` tag is deprecated. You should use ``verbatim``
93
+ instead.
94
+
95
  Nodes
96
  -----
97
 
vendor/twig/twig/doc/recipes.rst CHANGED
@@ -1,6 +1,64 @@
1
  Recipes
2
  =======
3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  Making a Layout conditional
5
  ---------------------------
6
 
@@ -274,13 +332,14 @@ If you iterate over a set of files, you can pass the filename to the
274
  is enforced during template rendering (as Twig needs the context for some
275
  checks like allowed methods on objects).
276
 
277
- Refreshing modified Templates when APC is enabled and apc.stat = 0
278
- ------------------------------------------------------------------
279
 
280
- When using APC with ``apc.stat`` set to ``0`` and Twig cache enabled, clearing
281
- the template cache won't update the APC cache. To get around this, one can
282
- extend ``Twig_Environment`` and force the update of the APC cache when Twig
283
- rewrites the cache::
 
284
 
285
  class Twig_Environment_APC extends Twig_Environment
286
  {
@@ -289,7 +348,11 @@ rewrites the cache::
289
  parent::writeCacheFile($file, $content);
290
 
291
  // Compile cached file into bytecode cache
292
- apc_compile_file($file);
 
 
 
 
293
  }
294
  }
295
 
1
  Recipes
2
  =======
3
 
4
+ .. _deprecation-notices:
5
+
6
+ Displaying Deprecation Notices
7
+ ------------------------------
8
+
9
+ .. versionadded:: 1.21
10
+ This works as of Twig 1.21.
11
+
12
+ Deprecated features generate deprecation notices (via a call to the
13
+ ``trigger_error()`` PHP function). By default, they are silenced and never
14
+ displayed nor logged.
15
+
16
+ To easily remove all deprecated feature usages from your templates, write and
17
+ run a script along the lines of the following::
18
+
19
+ require_once __DIR__.'/vendor/autoload.php';
20
+
21
+ $twig = create_your_twig_env();
22
+
23
+ $deprecations = new Twig_Util_DeprecationCollector($twig);
24
+
25
+ print_r($deprecations->collectDir(__DIR__.'/templates'));
26
+
27
+ The ``collectDir()`` method compiles all templates found in a directory,
28
+ catches deprecation notices, and return them.
29
+
30
+ .. tip::
31
+
32
+ If your templates are not stored on the filesystem, use the ``collect()``
33
+ method instead which takes an ``Iterator``; the iterator must return
34
+ template names as keys and template contents as values (as done by
35
+ ``Twig_Util_TemplateDirIterator``).
36
+
37
+ However, this code won't find all deprecations (like using deprecated some Twig
38
+ classes). To catch all notices, register a custom error handler like the one
39
+ below::
40
+
41
+ $deprecations = array();
42
+ set_error_handler(function ($type, $msg) use (&$deprecations) {
43
+ if (E_USER_DEPRECATED === $type) {
44
+ $deprecations[] = $msg;
45
+ }
46
+ });
47
+
48
+ // run your application
49
+
50
+ print_r($deprecations);
51
+
52
+ Note that most deprecation notices are triggered during **compilation**, so
53
+ they won't be generated when templates are already cached.
54
+
55
+ .. tip::
56
+
57
+ If you want to manage the deprecation notices from your PHPUnit tests, have
58
+ a look at the `symfony/phpunit-bridge
59
+ <https://github.com/symfony/phpunit-bridge>`_ package, which eases the
60
+ process a lot.
61
+
62
  Making a Layout conditional
63
  ---------------------------
64
 
332
  is enforced during template rendering (as Twig needs the context for some
333
  checks like allowed methods on objects).
334
 
335
+ Refreshing modified Templates when OPcache or APC is enabled
336
+ ------------------------------------------------------------
337
 
338
+ When using OPcache with ``opcache.validate_timestamps`` set to ``0`` or APC
339
+ with ``apc.stat`` set to ``0`` and Twig cache enabled, clearing the template
340
+ cache won't update the cache. To get around this, one can extend
341
+ ``Twig_Environment`` and force the update of the cache when Twig rewrites the
342
+ cache::
343
 
344
  class Twig_Environment_APC extends Twig_Environment
345
  {
348
  parent::writeCacheFile($file, $content);
349
 
350
  // Compile cached file into bytecode cache
351
+ if (extension_loaded('Zend OPcache') && ini_get('opcache.enable')) {
352
+ opcache_compile_file($file);
353
+ } elseif (extension_loaded('apc') && ini_get('apc.enabled')) {
354
+ apc_compile_file($file);
355
+ }
356
  }
357
  }
358
 
vendor/twig/twig/doc/templates.rst CHANGED
@@ -60,6 +60,9 @@ Many IDEs support syntax highlighting and auto-completion for Twig:
60
  * *Emacs* via `web-mode.el`_
61
  * *Atom* via the `PHP-twig for atom`_
62
 
 
 
 
63
  Variables
64
  ---------
65
 
@@ -882,3 +885,4 @@ Extension<creating_extensions>` chapter.
882
  .. _`web-mode.el`: http://web-mode.org/
883
  .. _`regular expressions`: http://php.net/manual/en/pcre.pattern.php
884
  .. _`PHP-twig for atom`: https://github.com/reesef/php-twig
 
60
  * *Emacs* via `web-mode.el`_
61
  * *Atom* via the `PHP-twig for atom`_
62
 
63
+ Also, `TwigFiddle`_ is an online service that allows you to execute Twig templates
64
+ from a browser; it supports all versions of Twig.
65
+
66
  Variables
67
  ---------
68
 
885
  .. _`web-mode.el`: http://web-mode.org/
886
  .. _`regular expressions`: http://php.net/manual/en/pcre.pattern.php
887
  .. _`PHP-twig for atom`: https://github.com/reesef/php-twig
888
+ .. _`TwigFiddle`: http://twigfiddle.com/
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.20.0"
19
 
20
  #include "php.h"
21
 
15
  #ifndef PHP_TWIG_H
16
  #define PHP_TWIG_H
17
 
18
+ #define PHP_TWIG_VERSION "1.21.1"
19
 
20
  #include "php.h"
21
 
vendor/twig/twig/lib/Twig/Autoloader.php CHANGED
@@ -9,10 +9,14 @@
9
  * file that was distributed with this source code.
10
  */
11
 
 
 
12
  /**
13
  * Autoloads Twig classes.
14
  *
15
  * @author Fabien Potencier <fabien@symfony.com>
 
 
16
  */
17
  class Twig_Autoloader
18
  {
@@ -23,6 +27,8 @@ class Twig_Autoloader
23
  */
24
  public static function register($prepend = false)
25
  {
 
 
26
  if (PHP_VERSION_ID < 50300) {
27
  spl_autoload_register(array(__CLASS__, 'autoload'));
28
  } else {
9
  * file that was distributed with this source code.
10
  */
11
 
12
+ @trigger_error('The Twig_Autoloader class is deprecated and will be removed in 2.0. Use Composer instead.', E_USER_DEPRECATED);
13
+
14
  /**
15
  * Autoloads Twig classes.
16
  *
17
  * @author Fabien Potencier <fabien@symfony.com>
18
+ *
19
+ * @deprecated Use Composer instead. Will be removed in Twig 2.0.
20
  */
21
  class Twig_Autoloader
22
  {
27
  */
28
  public static function register($prepend = false)
29
  {
30
+ @trigger_error('Using Twig_Autoloader is deprecated. Use Composer instead.', E_USER_DEPRECATED);
31
+
32
  if (PHP_VERSION_ID < 50300) {
33
  spl_autoload_register(array(__CLASS__, 'autoload'));
34
  } else {
vendor/twig/twig/lib/Twig/BaseNodeVisitor.php CHANGED
@@ -43,8 +43,8 @@ abstract class Twig_BaseNodeVisitor implements Twig_NodeVisitorInterface
43
  /**
44
  * Called before child nodes are visited.
45
  *
46
- * @param Twig_Node $node The node to visit
47
- * @param Twig_Environment $env The Twig environment instance
48
  *
49
  * @return Twig_Node The modified node
50
  */
43
  /**
44
  * Called before child nodes are visited.
45
  *
46
+ * @param Twig_Node $node The node to visit
47
+ * @param Twig_Environment $env The Twig environment instance
48
  *
49
  * @return Twig_Node The modified node
50
  */
vendor/twig/twig/lib/Twig/Compiler.php CHANGED
@@ -21,7 +21,7 @@ class Twig_Compiler implements Twig_CompilerInterface
21
  protected $source;
22
  protected $indentation;
23
  protected $env;
24
- protected $debugInfo;
25
  protected $sourceOffset;
26
  protected $sourceLine;
27
  protected $filename;
@@ -34,7 +34,6 @@ class Twig_Compiler implements Twig_CompilerInterface
34
  public function __construct(Twig_Environment $env)
35
  {
36
  $this->env = $env;
37
- $this->debugInfo = array();
38
  }
39
 
40
  public function getFilename()
21
  protected $source;
22
  protected $indentation;
23
  protected $env;
24
+ protected $debugInfo = array();
25
  protected $sourceOffset;
26
  protected $sourceLine;
27
  protected $filename;
34
  public function __construct(Twig_Environment $env)
35
  {
36
  $this->env = $env;
 
37
  }
38
 
39
  public function getFilename()
vendor/twig/twig/lib/Twig/Environment.php CHANGED
@@ -16,7 +16,7 @@
16
  */
17
  class Twig_Environment
18
  {
19
- const VERSION = '1.20.0';
20
 
21
  protected $charset;
22
  protected $loader;
@@ -34,15 +34,15 @@ class Twig_Environment
34
  protected $tests;
35
  protected $functions;
36
  protected $globals;
37
- protected $runtimeInitialized;
38
- protected $extensionInitialized;
39
  protected $loadedTemplates;
40
  protected $strictVariables;
41
  protected $unaryOperators;
42
  protected $binaryOperators;
43
  protected $templateClassPrefix = '__TwigTemplate_';
44
- protected $functionCallbacks;
45
- protected $filterCallbacks;
46
  protected $staging;
47
 
48
  /**
@@ -86,6 +86,8 @@ class Twig_Environment
86
  {
87
  if (null !== $loader) {
88
  $this->setLoader($loader);
 
 
89
  }
90
 
91
  $options = array_merge(array(
@@ -104,15 +106,11 @@ class Twig_Environment
104
  $this->baseTemplateClass = $options['base_template_class'];
105
  $this->autoReload = null === $options['auto_reload'] ? $this->debug : (bool) $options['auto_reload'];
106
  $this->strictVariables = (bool) $options['strict_variables'];
107
- $this->runtimeInitialized = false;
108
  $this->setCache($options['cache']);
109
- $this->functionCallbacks = array();
110
- $this->filterCallbacks = array();
111
 
112
  $this->addExtension(new Twig_Extension_Core());
113
  $this->addExtension(new Twig_Extension_Escaper($options['autoescape']));
114
  $this->addExtension(new Twig_Extension_Optimizer($options['optimizations']));
115
- $this->extensionInitialized = false;
116
  $this->staging = new Twig_Extension_Staging();
117
  }
118
 
@@ -448,6 +446,8 @@ class Twig_Environment
448
  */
449
  public function clearTemplateCache()
450
  {
 
 
451
  $this->loadedTemplates = array();
452
  }
453
 
@@ -711,6 +711,8 @@ class Twig_Environment
711
  */
712
  public function removeExtension($name)
713
  {
 
 
714
  if ($this->extensionInitialized) {
715
  throw new LogicException(sprintf('Unable to remove extension "%s" as extensions have already been initialized.', $name));
716
  }
@@ -830,6 +832,8 @@ class Twig_Environment
830
  if ($name instanceof Twig_SimpleFilter) {
831
  $filter = $name;
832
  $name = $filter->getName();
 
 
833
  }
834
 
835
  if ($this->extensionInitialized) {
@@ -919,6 +923,8 @@ class Twig_Environment
919
  if ($name instanceof Twig_SimpleTest) {
920
  $test = $name;
921
  $name = $test->getName();
 
 
922
  }
923
 
924
  if ($this->extensionInitialized) {
@@ -977,6 +983,8 @@ class Twig_Environment
977
  if ($name instanceof Twig_SimpleFunction) {
978
  $function = $name;
979
  $name = $function->getName();
 
 
980
  }
981
 
982
  if ($this->extensionInitialized) {
@@ -1067,11 +1075,11 @@ class Twig_Environment
1067
  $this->globals = $this->initGlobals();
1068
  }
1069
 
1070
- /* This condition must be uncommented in Twig 2.0
1071
  if (!array_key_exists($name, $this->globals)) {
1072
- throw new LogicException(sprintf('Unable to add global "%s" as the runtime or the extensions have already been initialized.', $name));
 
 
1073
  }
1074
- */
1075
  }
1076
 
1077
  if ($this->extensionInitialized || $this->runtimeInitialized) {
@@ -1186,7 +1194,7 @@ class Twig_Environment
1186
  }
1187
 
1188
  $this->extensionInitialized = true;
1189
- $this->parsers = new Twig_TokenParserBroker();
1190
  $this->filters = array();
1191
  $this->functions = array();
1192
  $this->tests = array();
@@ -1204,11 +1212,10 @@ class Twig_Environment
1204
  {
1205
  // filters
1206
  foreach ($extension->getFilters() as $name => $filter) {
1207
- if ($name instanceof Twig_SimpleFilter) {
1208
- $filter = $name;
1209
- $name = $filter->getName();
1210
- } elseif ($filter instanceof Twig_SimpleFilter) {
1211
  $name = $filter->getName();
 
 
1212
  }
1213
 
1214
  $this->filters[$name] = $filter;
@@ -1216,11 +1223,10 @@ class Twig_Environment
1216
 
1217
  // functions
1218
  foreach ($extension->getFunctions() as $name => $function) {
1219
- if ($name instanceof Twig_SimpleFunction) {
1220
- $function = $name;
1221
- $name = $function->getName();
1222
- } elseif ($function instanceof Twig_SimpleFunction) {
1223
  $name = $function->getName();
 
 
1224
  }
1225
 
1226
  $this->functions[$name] = $function;
@@ -1228,11 +1234,10 @@ class Twig_Environment
1228
 
1229
  // tests
1230
  foreach ($extension->getTests() as $name => $test) {
1231
- if ($name instanceof Twig_SimpleTest) {
1232
- $test = $name;
1233
- $name = $test->getName();
1234
- } elseif ($test instanceof Twig_SimpleTest) {
1235
  $name = $test->getName();
 
 
1236
  }
1237
 
1238
  $this->tests[$name] = $test;
@@ -1243,6 +1248,8 @@ class Twig_Environment
1243
  if ($parser instanceof Twig_TokenParserInterface) {
1244
  $this->parsers->addTokenParser($parser);
1245
  } elseif ($parser instanceof Twig_TokenParserBrokerInterface) {
 
 
1246
  $this->parsers->addTokenParserBroker($parser);
1247
  } else {
1248
  throw new LogicException('getTokenParsers() must return an array of Twig_TokenParserInterface or Twig_TokenParserBrokerInterface instances');
16
  */
17
  class Twig_Environment
18
  {
19
+ const VERSION = '1.21.1';
20
 
21
  protected $charset;
22
  protected $loader;
34
  protected $tests;
35
  protected $functions;
36
  protected $globals;
37
+ protected $runtimeInitialized = false;
38
+ protected $extensionInitialized = false;
39
  protected $loadedTemplates;
40
  protected $strictVariables;
41
  protected $unaryOperators;
42
  protected $binaryOperators;
43
  protected $templateClassPrefix = '__TwigTemplate_';
44
+ protected $functionCallbacks = array();
45
+ protected $filterCallbacks = array();
46
  protected $staging;
47
 
48
  /**
86
  {
87
  if (null !== $loader) {
88
  $this->setLoader($loader);
89
+ } else {
90
+ @trigger_error('Not passing a Twig_LoaderInterface as the first constructor argument of Twig_Environment is deprecated.', E_USER_DEPRECATED);
91
  }
92
 
93
  $options = array_merge(array(
106
  $this->baseTemplateClass = $options['base_template_class'];
107
  $this->autoReload = null === $options['auto_reload'] ? $this->debug : (bool) $options['auto_reload'];
108
  $this->strictVariables = (bool) $options['strict_variables'];
 
109
  $this->setCache($options['cache']);
 
 
110
 
111
  $this->addExtension(new Twig_Extension_Core());
112
  $this->addExtension(new Twig_Extension_Escaper($options['autoescape']));
113
  $this->addExtension(new Twig_Extension_Optimizer($options['optimizations']));
 
114
  $this->staging = new Twig_Extension_Staging();
115
  }
116
 
446
  */
447
  public function clearTemplateCache()
448
  {
449
+ @trigger_error(sprintf('The %s method is deprecated and will be removed in Twig 2.0.', __METHOD__), E_USER_DEPRECATED);
450
+
451
  $this->loadedTemplates = array();
452
  }
453
 
711
  */
712
  public function removeExtension($name)
713
  {
714
+ @trigger_error(sprintf('The %s method is deprecated and will be removed in Twig 2.0.', __METHOD__), E_USER_DEPRECATED);
715
+
716
  if ($this->extensionInitialized) {
717
  throw new LogicException(sprintf('Unable to remove extension "%s" as extensions have already been initialized.', $name));
718
  }
832
  if ($name instanceof Twig_SimpleFilter) {
833
  $filter = $name;
834
  $name = $filter->getName();
835
+ } else {
836
+ @trigger_error(sprintf('Passing a name as a first argument to the %s method is deprecated. Pass an instance of "Twig_SimpleFilter" instead when defining filter "%s".', __METHOD__, $name), E_USER_DEPRECATED);
837
  }
838
 
839
  if ($this->extensionInitialized) {
923
  if ($name instanceof Twig_SimpleTest) {
924
  $test = $name;
925
  $name = $test->getName();
926
+ } else {
927
+ @trigger_error(sprintf('Passing a name as a first argument to the %s method is deprecated. Pass an instance of "Twig_SimpleTest" instead when defining test "%s".', __METHOD__, $name), E_USER_DEPRECATED);
928
  }
929
 
930
  if ($this->extensionInitialized) {
983
  if ($name instanceof Twig_SimpleFunction) {
984
  $function = $name;
985
  $name = $function->getName();
986
+ } else {
987
+ @trigger_error(sprintf('Passing a name as a first argument to the %s method is deprecated. Pass an instance of "Twig_SimpleFunction" instead when defining function "%s".', __METHOD__, $name), E_USER_DEPRECATED);
988
  }
989
 
990
  if ($this->extensionInitialized) {
1075
  $this->globals = $this->initGlobals();
1076
  }
1077
 
 
1078
  if (!array_key_exists($name, $this->globals)) {
1079
+ // The deprecation notice must be turned into the following exception in Twig 2.0
1080
+ @trigger_error(sprintf('Registering global variable "%s" at runtime or when the extensions have already been initialized is deprecated.', $name), E_USER_DEPRECATED);
1081
+ //throw new LogicException(sprintf('Unable to add global "%s" as the runtime or the extensions have already been initialized.', $name));
1082
  }
 
1083
  }
1084
 
1085
  if ($this->extensionInitialized || $this->runtimeInitialized) {
1194
  }
1195
 
1196
  $this->extensionInitialized = true;
1197
+ $this->parsers = new Twig_TokenParserBroker(array(), array(), false);
1198
  $this->filters = array();
1199
  $this->functions = array();
1200
  $this->tests = array();
1212
  {
1213
  // filters
1214
  foreach ($extension->getFilters() as $name => $filter) {
1215
+ if ($filter instanceof Twig_SimpleFilter) {
 
 
 
1216
  $name = $filter->getName();
1217
+ } else {
1218
+ @trigger_error(sprintf('Using an instance of "%s" for filter "%s" is deprecated. Use Twig_SimpleFilter instead.', get_class($filter), $name), E_USER_DEPRECATED);
1219
  }
1220
 
1221
  $this->filters[$name] = $filter;
1223
 
1224
  // functions
1225
  foreach ($extension->getFunctions() as $name => $function) {
1226
+ if ($function instanceof Twig_SimpleFunction) {
 
 
 
1227
  $name = $function->getName();
1228
+ } else {
1229
+ @trigger_error(sprintf('Using an instance of "%s" for function "%s" is deprecated. Use Twig_SimpleFunction instead.', get_class($function), $name), E_USER_DEPRECATED);
1230
  }
1231
 
1232
  $this->functions[$name] = $function;
1234
 
1235
  // tests
1236
  foreach ($extension->getTests() as $name => $test) {
1237
+ if ($test instanceof Twig_SimpleTest) {
 
 
 
1238
  $name = $test->getName();
1239
+ } else {
1240
+ @trigger_error(sprintf('Using an instance of "%s" for test "%s" is deprecated. Use Twig_SimpleTest instead.', get_class($test), $name), E_USER_DEPRECATED);
1241
  }
1242
 
1243
  $this->tests[$name] = $test;
1248
  if ($parser instanceof Twig_TokenParserInterface) {
1249
  $this->parsers->addTokenParser($parser);
1250
  } elseif ($parser instanceof Twig_TokenParserBrokerInterface) {
1251
+ @trigger_error('Registering a Twig_TokenParserBrokerInterface instance is deprecated.', E_USER_DEPRECATED);
1252
+
1253
  $this->parsers->addTokenParserBroker($parser);
1254
  } else {
1255
  throw new LogicException('getTokenParsers() must return an array of Twig_TokenParserInterface or Twig_TokenParserBrokerInterface instances');
vendor/twig/twig/lib/Twig/ExpressionParser.php CHANGED
@@ -578,6 +578,16 @@ class Twig_ExpressionParser
578
  throw new Twig_Error_Syntax($message, $line, $this->parser->getFilename());
579
  }
580
 
 
 
 
 
 
 
 
 
 
 
581
  if ($function instanceof Twig_SimpleFunction) {
582
  return $function->getNodeClass();
583
  }
@@ -598,6 +608,16 @@ class Twig_ExpressionParser
598
  throw new Twig_Error_Syntax($message, $line, $this->parser->getFilename());
599
  }
600
 
 
 
 
 
 
 
 
 
 
 
601
  if ($filter instanceof Twig_SimpleFilter) {
602
  return $filter->getNodeClass();
603
  }
578
  throw new Twig_Error_Syntax($message, $line, $this->parser->getFilename());
579
  }
580
 
581
+ if ($function instanceof Twig_SimpleFunction && $function->isDeprecated()) {
582
+ $message = sprintf('Twig Function "%s" is deprecated', $function->getName());
583
+ if ($test->getAlternative()) {
584
+ $message .= sprintf('. Use "%s" instead', $function->getAlternative());
585
+ }
586
+ $message .= sprintf(' in %s at line %d.', $this->parser->getFilename(), $line);
587
+
588
+ @trigger_error($message, E_USER_DEPRECATED);
589
+ }
590
+
591
  if ($function instanceof Twig_SimpleFunction) {
592
  return $function->getNodeClass();
593
  }
608
  throw new Twig_Error_Syntax($message, $line, $this->parser->getFilename());
609
  }
610
 
611
+ if ($filter instanceof Twig_SimpleFilter && $filter->isDeprecated()) {
612
+ $message = sprintf('Twig Filter "%s" is deprecated', $filter->getName());
613
+ if ($test->getAlternative()) {
614
+ $message .= sprintf('. Use "%s" instead', $filter->getAlternative());
615
+ }
616
+ $message .= sprintf(' in %s at line %d.', $this->parser->getFilename(), $line);
617
+
618
+ @trigger_error($message, E_USER_DEPRECATED);
619
+ }
620
+
621
  if ($filter instanceof Twig_SimpleFilter) {
622
  return $filter->getNodeClass();
623
  }
vendor/twig/twig/lib/Twig/Extension/Core.php CHANGED
@@ -233,11 +233,11 @@ class Twig_Extension_Core extends Twig_Extension
233
  new Twig_SimpleTest('even', null, array('node_class' => 'Twig_Node_Expression_Test_Even')),
234
  new Twig_SimpleTest('odd', null, array('node_class' => 'Twig_Node_Expression_Test_Odd')),
235
  new Twig_SimpleTest('defined', null, array('node_class' => 'Twig_Node_Expression_Test_Defined')),
236
- new Twig_SimpleTest('sameas', null, array('node_class' => 'Twig_Node_Expression_Test_Sameas')),
237
  new Twig_SimpleTest('same as', null, array('node_class' => 'Twig_Node_Expression_Test_Sameas')),
238
  new Twig_SimpleTest('none', null, array('node_class' => 'Twig_Node_Expression_Test_Null')),
239
  new Twig_SimpleTest('null', null, array('node_class' => 'Twig_Node_Expression_Test_Null')),
240
- new Twig_SimpleTest('divisibleby', null, array('node_class' => 'Twig_Node_Expression_Test_Divisibleby')),
241
  new Twig_SimpleTest('divisible by', null, array('node_class' => 'Twig_Node_Expression_Test_Divisibleby')),
242
  new Twig_SimpleTest('constant', null, array('node_class' => 'Twig_Node_Expression_Test_Constant')),
243
  new Twig_SimpleTest('empty', 'twig_test_empty'),
@@ -298,8 +298,19 @@ class Twig_Extension_Core extends Twig_Extension
298
  public function parseTestExpression(Twig_Parser $parser, Twig_NodeInterface $node)
299
  {
300
  $stream = $parser->getStream();
301
- $name = $this->getTestName($parser, $node->getLine());
302
- $class = $this->getTestNodeClass($parser, $name);
 
 
 
 
 
 
 
 
 
 
 
303
  $arguments = null;
304
  if ($stream->test(Twig_Token::PUNCTUATION_TYPE, '(')) {
305
  $arguments = $parser->getExpressionParser()->parseArguments(true);
@@ -308,46 +319,42 @@ class Twig_Extension_Core extends Twig_Extension
308
  return new $class($node, $name, $arguments, $parser->getCurrentToken()->getLine());
309
  }
310
 
311
- protected function getTestName(Twig_Parser $parser, $line)
312
  {
313
  $stream = $parser->getStream();
314
  $name = $stream->expect(Twig_Token::NAME_TYPE)->getValue();
315
  $env = $parser->getEnvironment();
316
- $testMap = $env->getTests();
317
 
318
- if (isset($testMap[$name])) {
319
- return $name;
320
  }
321
 
322
  if ($stream->test(Twig_Token::NAME_TYPE)) {
323
  // try 2-words tests
324
  $name = $name.' '.$parser->getCurrentToken()->getValue();
325
 
326
- if (isset($testMap[$name])) {
327
  $parser->getStream()->next();
328
 
329
- return $name;
330
  }
331
  }
332
 
333
  $message = sprintf('The test "%s" does not exist', $name);
334
- if ($alternatives = $env->computeAlternatives($name, array_keys($testMap))) {
335
  $message = sprintf('%s. Did you mean "%s"', $message, implode('", "', $alternatives));
336
  }
337
 
338
  throw new Twig_Error_Syntax($message, $line, $parser->getFilename());
339
  }
340
 
341
- protected function getTestNodeClass(Twig_Parser $parser, $name)
342
  {
343
- $env = $parser->getEnvironment();
344
- $testMap = $env->getTests();
345
-
346
- if ($testMap[$name] instanceof Twig_SimpleTest) {
347
- return $testMap[$name]->getNodeClass();
348
  }
349
 
350
- return $testMap[$name] instanceof Twig_Test_Node ? $testMap[$name]->getClass() : 'Twig_Node_Expression_Test';
351
  }
352
 
353
  /**
@@ -384,8 +391,8 @@ function twig_cycle($values, $position)
384
  * - a random character from a string
385
  * - a random integer between 0 and the integer parameter.
386
  *
387
- * @param Twig_Environment $env A Twig_Environment instance
388
- * @param Traversable|array|int|string $values The values to pick a random item from
389
  *
390
  * @throws Twig_Error_Runtime When $values is an empty array (does not apply to an empty string which is returned as is).
391
  *
@@ -472,9 +479,9 @@ function twig_date_format_filter(Twig_Environment $env, $date, $format = null, $
472
  * {{ post.published_at|date_modify("-1day")|date("m/d/Y") }}
473
  * </pre>
474
  *
475
- * @param Twig_Environment $env A Twig_Environment instance
476
- * @param DateTime|string $date A date
477
- * @param string $modifier A modifier string
478
  *
479
  * @return DateTime A new date object
480
  */
@@ -545,11 +552,11 @@ function twig_date_converter(Twig_Environment $env, $date = null, $timezone = nu
545
  /**
546
  * Rounds a number.
547
  *
548
- * @param int|float $value The value to round
549
- * @param int|float $precision The rounding precision
550
- * @param string $method The method to use for rounding
551
  *
552
- * @return int|float The rounded number
553
  */
554
  function twig_round($value, $precision = 0, $method = 'common')
555
  {
@@ -571,11 +578,11 @@ function twig_round($value, $precision = 0, $method = 'common')
571
  * be used. Supplying any of the parameters will override the defaults set in the
572
  * environment object.
573
  *
574
- * @param Twig_Environment $env A Twig_Environment instance
575
- * @param mixed $number A float/int/string of the number to format
576
- * @param int $decimal The number of decimal points to display.
577
- * @param string $decimalPoint The character(s) to use for the decimal point.
578
- * @param string $thousandSep The character(s) to use for the thousands separator.
579
  *
580
  * @return string The formatted number
581
  */
@@ -805,9 +812,9 @@ function twig_join_filter($value, $glue = '')
805
  * {# returns [aa, bb, cc] #}
806
  * </pre>
807
  *
808
- * @param string $value A string
809
- * @param string $delimiter The delimiter
810
- * @param int $limit The limit
811
  *
812
  * @return array The split string as an array
813
  */
@@ -1369,7 +1376,7 @@ function twig_ensure_traversable($seq)
1369
  *
1370
  * @param mixed $value A variable
1371
  *
1372
- * @return bool true if the value is empty, false otherwise
1373
  */
1374
  function twig_test_empty($value)
1375
  {
@@ -1392,7 +1399,7 @@ function twig_test_empty($value)
1392
  *
1393
  * @param mixed $value A variable
1394
  *
1395
- * @return bool true if the value is traversable
1396
  */
1397
  function twig_test_iterable($value)
1398
  {
@@ -1486,9 +1493,9 @@ function twig_constant($constant, $object = null)
1486
  /**
1487
  * Batches item.
1488
  *
1489
- * @param array $items An array of items
1490
- * @param int $size The size of the batch
1491
- * @param mixed $fill A value used to fill missing items
1492
  *
1493
  * @return array
1494
  */
233
  new Twig_SimpleTest('even', null, array('node_class' => 'Twig_Node_Expression_Test_Even')),
234
  new Twig_SimpleTest('odd', null, array('node_class' => 'Twig_Node_Expression_Test_Odd')),
235
  new Twig_SimpleTest('defined', null, array('node_class' => 'Twig_Node_Expression_Test_Defined')),
236
+ new Twig_SimpleTest('sameas', null, array('node_class' => 'Twig_Node_Expression_Test_Sameas', 'deprecated' => true, 'alternative' => 'same as')),
237
  new Twig_SimpleTest('same as', null, array('node_class' => 'Twig_Node_Expression_Test_Sameas')),
238
  new Twig_SimpleTest('none', null, array('node_class' => 'Twig_Node_Expression_Test_Null')),
239
  new Twig_SimpleTest('null', null, array('node_class' => 'Twig_Node_Expression_Test_Null')),
240
+ new Twig_SimpleTest('divisibleby', null, array('node_class' => 'Twig_Node_Expression_Test_Divisibleby', 'deprecated' => true, 'alternative' => 'divisible by')),
241
  new Twig_SimpleTest('divisible by', null, array('node_class' => 'Twig_Node_Expression_Test_Divisibleby')),
242
  new Twig_SimpleTest('constant', null, array('node_class' => 'Twig_Node_Expression_Test_Constant')),
243
  new Twig_SimpleTest('empty', 'twig_test_empty'),
298
  public function parseTestExpression(Twig_Parser $parser, Twig_NodeInterface $node)
299
  {
300
  $stream = $parser->getStream();
301
+ list($name, $test) = $this->getTest($parser, $node->getLine());
302
+
303
+ if ($test instanceof Twig_SimpleTest && $test->isDeprecated()) {
304
+ $message = sprintf('Twig Test "%s" is deprecated', $name);
305
+ if ($test->getAlternative()) {
306
+ $message .= sprintf('. Use "%s" instead', $test->getAlternative());
307
+ }
308
+ $message .= sprintf(' in %s at line %d.', $stream->getFilename(), $stream->getCurrent()->getLine());
309
+
310
+ @trigger_error($message, E_USER_DEPRECATED);
311
+ }
312
+
313
+ $class = $this->getTestNodeClass($parser, $test);
314
  $arguments = null;
315
  if ($stream->test(Twig_Token::PUNCTUATION_TYPE, '(')) {
316
  $arguments = $parser->getExpressionParser()->parseArguments(true);
319
  return new $class($node, $name, $arguments, $parser->getCurrentToken()->getLine());
320
  }
321
 
322
+ protected function getTest(Twig_Parser $parser, $line)
323
  {
324
  $stream = $parser->getStream();
325
  $name = $stream->expect(Twig_Token::NAME_TYPE)->getValue();
326
  $env = $parser->getEnvironment();
 
327
 
328
+ if ($test = $env->getTest($name)) {
329
+ return array($name, $test);
330
  }
331
 
332
  if ($stream->test(Twig_Token::NAME_TYPE)) {
333
  // try 2-words tests
334
  $name = $name.' '.$parser->getCurrentToken()->getValue();
335
 
336
+ if ($test = $env->getTest($name)) {
337
  $parser->getStream()->next();
338
 
339
+ return array($name, $test);
340
  }
341
  }
342
 
343
  $message = sprintf('The test "%s" does not exist', $name);
344
+ if ($alternatives = $env->computeAlternatives($name, array_keys($env->getTests()))) {
345
  $message = sprintf('%s. Did you mean "%s"', $message, implode('", "', $alternatives));
346
  }
347
 
348
  throw new Twig_Error_Syntax($message, $line, $parser->getFilename());
349
  }
350
 
351
+ protected function getTestNodeClass(Twig_Parser $parser, $test)
352
  {
353
+ if ($test instanceof Twig_SimpleTest) {
354
+ return $test->getNodeClass();
 
 
 
355
  }
356
 
357
+ return $test instanceof Twig_Test_Node ? $test->getClass() : 'Twig_Node_Expression_Test';
358
  }
359
 
360
  /**
391
  * - a random character from a string
392
  * - a random integer between 0 and the integer parameter.
393
  *
394
+ * @param Twig_Environment $env A Twig_Environment instance
395
+ * @param Traversable|array|int|string $values The values to pick a random item from
396
  *
397
  * @throws Twig_Error_Runtime When $values is an empty array (does not apply to an empty string which is returned as is).
398
  *
479
  * {{ post.published_at|date_modify("-1day")|date("m/d/Y") }}
480
  * </pre>
481
  *
482
+ * @param Twig_Environment $env A Twig_Environment instance
483
+ * @param DateTime|string $date A date
484
+ * @param string $modifier A modifier string
485
  *
486
  * @return DateTime A new date object
487
  */
552
  /**
553
  * Rounds a number.
554
  *
555
+ * @param int|float $value The value to round
556
+ * @param int|float $precision The rounding precision
557
+ * @param string $method The method to use for rounding
558
  *
559
+ * @return int|float The rounded number
560
  */
561
  function twig_round($value, $precision = 0, $method = 'common')
562
  {
578
  * be used. Supplying any of the parameters will override the defaults set in the
579
  * environment object.
580
  *
581
+ * @param Twig_Environment $env A Twig_Environment instance
582
+ * @param mixed $number A float/int/string of the number to format
583
+ * @param int $decimal The number of decimal points to display.
584
+ * @param string $decimalPoint The character(s) to use for the decimal point.
585
+ * @param string $thousandSep The character(s) to use for the thousands separator.
586
  *
587
  * @return string The formatted number
588
  */
812
  * {# returns [aa, bb, cc] #}
813
  * </pre>
814
  *
815
+ * @param string $value A string
816
+ * @param string $delimiter The delimiter
817
+ * @param int $limit The limit
818
  *
819
  * @return array The split string as an array
820
  */
1376
  *
1377
  * @param mixed $value A variable
1378
  *
1379
+ * @return bool true if the value is empty, false otherwise
1380
  */
1381
  function twig_test_empty($value)
1382
  {
1399
  *
1400
  * @param mixed $value A variable
1401
  *
1402
+ * @return bool true if the value is traversable
1403
  */
1404
  function twig_test_iterable($value)
1405
  {
1493
  /**
1494
  * Batches item.
1495
  *
1496
+ * @param array $items An array of items
1497
+ * @param int $size The size of the batch
1498
+ * @param mixed $fill A value used to fill missing items
1499
  *
1500
  * @return array
1501
  */
vendor/twig/twig/lib/Twig/Extension/Escaper.php CHANGED
@@ -12,6 +12,13 @@ class Twig_Extension_Escaper extends Twig_Extension
12
  {
13
  protected $defaultStrategy;
14
 
 
 
 
 
 
 
 
15
  public function __construct($defaultStrategy = 'html')
16
  {
17
  $this->setDefaultStrategy($defaultStrategy);
@@ -55,12 +62,14 @@ class Twig_Extension_Escaper extends Twig_Extension
55
  * The strategy can be a valid PHP callback that takes the template
56
  * "filename" as an argument and returns the strategy to use.
57
  *
58
- * @param mixed $defaultStrategy An escaping strategy
59
  */
60
  public function setDefaultStrategy($defaultStrategy)
61
  {
62
  // for BC
63
  if (true === $defaultStrategy) {
 
 
64
  $defaultStrategy = 'html';
65
  }
66
 
@@ -76,13 +85,13 @@ class Twig_Extension_Escaper extends Twig_Extension
76
  *
77
  * @param string $filename The template "filename"
78
  *
79
- * @return string The default strategy to use for the template
80
  */
81
  public function getDefaultStrategy($filename)
82
  {
83
  // disable string callables to avoid calling a function named html or js,
84
  // or any other upcoming escaping strategy
85
- if (!is_string($this->defaultStrategy) && is_callable($this->defaultStrategy)) {
86
  return call_user_func($this->defaultStrategy, $filename);
87
  }
88
 
12
  {
13
  protected $defaultStrategy;
14
 
15
+ /**
16
+ * Constructor.
17
+ *
18
+ * @param string|false|callable $defaultStrategy An escaping strategy
19
+ *
20
+ * @see setDefaultStrategy()
21
+ */
22
  public function __construct($defaultStrategy = 'html')
23
  {
24
  $this->setDefaultStrategy($defaultStrategy);
62
  * The strategy can be a valid PHP callback that takes the template
63
  * "filename" as an argument and returns the strategy to use.
64
  *
65
+ * @param string|false|callable $defaultStrategy An escaping strategy
66
  */
67
  public function setDefaultStrategy($defaultStrategy)
68
  {
69
  // for BC
70
  if (true === $defaultStrategy) {
71
+ @trigger_error('Using "true" as the default strategy is deprecated. Use "html" instead.', E_USER_DEPRECATED);
72
+
73
  $defaultStrategy = 'html';
74
  }
75
 
85
  *
86
  * @param string $filename The template "filename"
87
  *
88
+ * @return string|false The default strategy to use for the template
89
  */
90
  public function getDefaultStrategy($filename)
91
  {
92
  // disable string callables to avoid calling a function named html or js,
93
  // or any other upcoming escaping strategy
94
+ if (!is_string($this->defaultStrategy) && false !== $this->defaultStrategy) {
95
  return call_user_func($this->defaultStrategy, $filename);
96
  }
97
 
vendor/twig/twig/lib/Twig/Extension/Profiler.php CHANGED
@@ -11,11 +11,11 @@
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)
11
 
12
  class Twig_Extension_Profiler extends Twig_Extension
13
  {
14
+ private $actives = array();
15
 
16
  public function __construct(Twig_Profiler_Profile $profile)
17
  {
18
+ $this->actives[] = $profile;
19
  }
20
 
21
  public function enter(Twig_Profiler_Profile $profile)
vendor/twig/twig/lib/Twig/Filter.php CHANGED
@@ -9,6 +9,8 @@
9
  * file that was distributed with this source code.
10
  */
11
 
 
 
12
  /**
13
  * Represents a template filter.
14
  *
9
  * file that was distributed with this source code.
10
  */
11
 
12
+ @trigger_error('The Twig_Filter class is deprecated since version 1.12 and will be removed in 2.0. Use Twig_SimpleFilter instead.', E_USER_DEPRECATED);
13
+
14
  /**
15
  * Represents a template filter.
16
  *
vendor/twig/twig/lib/Twig/Filter/Function.php CHANGED
@@ -9,6 +9,8 @@
9
  * file that was distributed with this source code.
10
  */
11
 
 
 
12
  /**
13
  * Represents a function template filter.
14
  *
9
  * file that was distributed with this source code.
10
  */
11
 
12
+ @trigger_error('The Twig_Filter_Function class is deprecated since version 1.12 and will be removed in 2.0. Use Twig_SimpleFilter instead.', E_USER_DEPRECATED);
13
+
14
  /**
15
  * Represents a function template filter.
16
  *
vendor/twig/twig/lib/Twig/Filter/Method.php CHANGED
@@ -9,6 +9,8 @@
9
  * file that was distributed with this source code.
10
  */
11
 
 
 
12
  /**
13
  * Represents a method template filter.
14
  *
9
  * file that was distributed with this source code.
10
  */
11
 
12
+ @trigger_error('The Twig_Filter_Method class is deprecated since version 1.12 and will be removed in 2.0. Use Twig_SimpleFilter instead.', E_USER_DEPRECATED);
13
+
14
  /**
15
  * Represents a method template filter.
16
  *
vendor/twig/twig/lib/Twig/Filter/Node.php CHANGED
@@ -9,6 +9,8 @@
9
  * file that was distributed with this source code.
10
  */
11
 
 
 
12
  /**
13
  * Represents a template filter as a node.
14
  *
9
  * file that was distributed with this source code.
10
  */
11
 
12
+ @trigger_error('The Twig_Filter_Node class is deprecated since version 1.12 and will be removed in 2.0. Use Twig_SimpleFilter instead.', E_USER_DEPRECATED);
13
+
14
  /**
15
  * Represents a template filter as a node.
16
  *
vendor/twig/twig/lib/Twig/Function.php CHANGED
@@ -9,6 +9,8 @@
9
  * file that was distributed with this source code.
10
  */
11
 
 
 
12
  /**
13
  * Represents a template function.
14
  *
9
  * file that was distributed with this source code.
10
  */
11
 
12
+ @trigger_error('The Twig_Function class is deprecated since version 1.12 and will be removed in 2.0. Use Twig_SimpleFunction instead.', E_USER_DEPRECATED);
13
+
14
  /**
15
  * Represents a template function.
16
  *
vendor/twig/twig/lib/Twig/Function/Function.php CHANGED
@@ -10,6 +10,8 @@
10
  * file that was distributed with this source code.
11
  */
12
 
 
 
13
  /**
14
  * Represents a function template function.
15
  *
10
  * file that was distributed with this source code.
11
  */
12
 
13
+ @trigger_error('The Twig_Function_Function class is deprecated since version 1.12 and will be removed in 2.0. Use Twig_SimpleFunction instead.', E_USER_DEPRECATED);
14
+
15
  /**
16
  * Represents a function template function.
17
  *
vendor/twig/twig/lib/Twig/Function/Method.php CHANGED
@@ -10,6 +10,8 @@
10
  * file that was distributed with this source code.
11
  */
12
 
 
 
13
  /**
14
  * Represents a method template function.
15
  *
10
  * file that was distributed with this source code.
11
  */
12
 
13
+ @trigger_error('The Twig_Function_Method class is deprecated since version 1.12 and will be removed in 2.0. Use Twig_SimpleFunction instead.', E_USER_DEPRECATED);
14
+
15
  /**
16
  * Represents a method template function.
17
  *
vendor/twig/twig/lib/Twig/Function/Node.php CHANGED
@@ -9,6 +9,8 @@
9
  * file that was distributed with this source code.
10
  */
11
 
 
 
12
  /**
13
  * Represents a template function as a node.
14
  *
9
  * file that was distributed with this source code.
10
  */
11
 
12
+ @trigger_error('The Twig_Function_Node class is deprecated since version 1.12 and will be removed in 2.0. Use Twig_SimpleFunction instead.', E_USER_DEPRECATED);
13
+
14
  /**
15
  * Represents a template function as a node.
16
  *
vendor/twig/twig/lib/Twig/Lexer.php CHANGED
@@ -287,6 +287,10 @@ class Twig_Lexer implements Twig_LexerInterface
287
 
288
  protected function lexRawData($tag)
289
  {
 
 
 
 
290
  if (!preg_match(str_replace('%s', $tag, $this->regexes['lex_raw_data']), $this->code, $match, PREG_OFFSET_CAPTURE, $this->cursor)) {
291
  throw new Twig_Error_Syntax(sprintf('Unexpected end of file: Unclosed "%s" block', $tag), $this->lineno, $this->filename);
292
  }
287
 
288
  protected function lexRawData($tag)
289
  {
290
+ if ('raw' === $tag) {
291
+ @trigger_error(sprintf('Twig Tag "raw" is deprecated. Use "verbatim" instead in %s at line %d.', $this->filename, $this->lineno), E_USER_DEPRECATED);
292
+ }
293
+
294
  if (!preg_match(str_replace('%s', $tag, $this->regexes['lex_raw_data']), $this->code, $match, PREG_OFFSET_CAPTURE, $this->cursor)) {
295
  throw new Twig_Error_Syntax(sprintf('Unexpected end of file: Unclosed "%s" block', $tag), $this->lineno, $this->filename);
296
  }
vendor/twig/twig/lib/Twig/Loader/Array.php CHANGED
@@ -29,8 +29,6 @@ class Twig_Loader_Array implements Twig_LoaderInterface, Twig_ExistsLoaderInterf
29
  * Constructor.
30
  *
31
  * @param array $templates An array of templates (keys are the names, and values are the source code)
32
- *
33
- * @see Twig_Loader
34
  */
35
  public function __construct(array $templates)
36
  {
29
  * Constructor.
30
  *
31
  * @param array $templates An array of templates (keys are the names, and values are the source code)
 
 
32
  */
33
  public function __construct(array $templates)
34
  {
vendor/twig/twig/lib/Twig/Loader/Filesystem.php CHANGED
@@ -21,6 +21,7 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface, Twig_ExistsLoaderI
21
 
22
  protected $paths = array();
23
  protected $cache = array();
 
24
 
25
  /**
26
  * Constructor.
@@ -87,7 +88,7 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface, Twig_ExistsLoaderI
87
  public function addPath($path, $namespace = self::MAIN_NAMESPACE)
88
  {
89
  // invalidate the cache
90
- $this->cache = array();
91
 
92
  if (!is_dir($path)) {
93
  throw new Twig_Error_Loader(sprintf('The "%s" directory does not exist.', $path));
@@ -107,7 +108,7 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface, Twig_ExistsLoaderI
107
  public function prependPath($path, $namespace = self::MAIN_NAMESPACE)
108
  {
109
  // invalidate the cache
110
- $this->cache = array();
111
 
112
  if (!is_dir($path)) {
113
  throw new Twig_Error_Loader(sprintf('The "%s" directory does not exist.', $path));
@@ -150,9 +151,7 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface, Twig_ExistsLoaderI
150
  }
151
 
152
  try {
153
- $this->findTemplate($name);
154
-
155
- return true;
156
  } catch (Twig_Error_Loader $exception) {
157
  return false;
158
  }
@@ -168,18 +167,33 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface, Twig_ExistsLoaderI
168
 
169
  protected function findTemplate($name)
170
  {
 
171
  $name = $this->normalizeName($name);
172
 
173
  if (isset($this->cache[$name])) {
174
  return $this->cache[$name];
175
  }
176
 
 
 
 
 
 
 
 
 
177
  $this->validateName($name);
178
 
179
  list($namespace, $shortname) = $this->parseName($name);
180
 
181
  if (!isset($this->paths[$namespace])) {
182
- throw new Twig_Error_Loader(sprintf('There are no registered paths for namespace "%s".', $namespace));
 
 
 
 
 
 
183
  }
184
 
185
  foreach ($this->paths[$namespace] as $path) {
@@ -192,7 +206,13 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface, Twig_ExistsLoaderI
192
  }
193
  }
194
 
195
- throw new Twig_Error_Loader(sprintf('Unable to find template "%s" (looked into: %s).', $name, implode(', ', $this->paths[$namespace])));
 
 
 
 
 
 
196
  }
197
 
198
  protected function parseName($name, $default = self::MAIN_NAMESPACE)
21
 
22
  protected $paths = array();
23
  protected $cache = array();
24
+ protected $errorCache = array();
25
 
26
  /**
27
  * Constructor.
88
  public function addPath($path, $namespace = self::MAIN_NAMESPACE)
89
  {
90
  // invalidate the cache
91
+ $this->cache = $this->errorCache = array();
92
 
93
  if (!is_dir($path)) {
94
  throw new Twig_Error_Loader(sprintf('The "%s" directory does not exist.', $path));
108
  public function prependPath($path, $namespace = self::MAIN_NAMESPACE)
109
  {
110
  // invalidate the cache
111
+ $this->cache = $this->errorCache = array();
112
 
113
  if (!is_dir($path)) {
114
  throw new Twig_Error_Loader(sprintf('The "%s" directory does not exist.', $path));
151
  }
152
 
153
  try {
154
+ return false !== $this->findTemplate($name, false);
 
 
155
  } catch (Twig_Error_Loader $exception) {
156
  return false;
157
  }
167
 
168
  protected function findTemplate($name)
169
  {
170
+ $throw = func_num_args() > 1 ? func_get_arg(1) : true;
171
  $name = $this->normalizeName($name);
172
 
173
  if (isset($this->cache[$name])) {
174
  return $this->cache[$name];
175
  }
176
 
177
+ if (isset($this->errorCache[$name])) {
178
+ if (!$throw) {
179
+ return false;
180
+ }
181
+
182
+ throw new Twig_Error_Loader($this->errorCache[$name]);
183
+ }
184
+
185
  $this->validateName($name);
186
 
187
  list($namespace, $shortname) = $this->parseName($name);
188
 
189
  if (!isset($this->paths[$namespace])) {
190
+ $this->errorCache[$name] = sprintf('There are no registered paths for namespace "%s".', $namespace);
191
+
192
+ if (!$throw) {
193
+ return false;
194
+ }
195
+
196
+ throw new Twig_Error_Loader($this->errorCache[$name]);
197
  }
198
 
199
  foreach ($this->paths[$namespace] as $path) {
206
  }
207
  }
208
 
209
+ $this->errorCache[$name] = sprintf('Unable to find template "%s" (looked into: %s).', $name, implode(', ', $this->paths[$namespace]));
210
+
211
+ if (!$throw) {
212
+ return false;
213
+ }
214
+
215
+ throw new Twig_Error_Loader($this->errorCache[$name]);
216
  }
217
 
218
  protected function parseName($name, $default = self::MAIN_NAMESPACE)
vendor/twig/twig/lib/Twig/Loader/String.php CHANGED
@@ -9,6 +9,8 @@
9
  * file that was distributed with this source code.
10
  */
11
 
 
 
12
  /**
13
  * Loads a template from a string.
14
  *
9
  * file that was distributed with this source code.
10
  */
11
 
12
+ @trigger_error('The Twig_Loader_String class is deprecated since version 1.18.1 and will be removed in 2.0. Use Twig_Loader_Array instead.', E_USER_DEPRECATED);
13
+
14
  /**
15
  * Loads a template from a string.
16
  *
vendor/twig/twig/lib/Twig/Node.php CHANGED
@@ -74,6 +74,8 @@ class Twig_Node implements Twig_NodeInterface
74
  */
75
  public function toXml($asDom = false)
76
  {
 
 
77
  $dom = new DOMDocument('1.0', 'UTF-8');
78
  $dom->formatOutput = true;
79
  $dom->appendChild($xml = $dom->createElement('twig'));
74
  */
75
  public function toXml($asDom = false)
76
  {
77
+ @trigger_error(sprintf('%s is deprecated.', __METHOD__), E_USER_DEPRECATED);
78
+
79
  $dom = new DOMDocument('1.0', 'UTF-8');
80
  $dom->formatOutput = true;
81
  $dom->appendChild($xml = $dom->createElement('twig'));
vendor/twig/twig/lib/Twig/Node/Expression/Name.php CHANGED
@@ -30,11 +30,19 @@ class Twig_Node_Expression_Name extends Twig_Node_Expression
30
 
31
  if ($this->getAttribute('is_defined_test')) {
32
  if ($this->isSpecial()) {
 
 
 
 
33
  $compiler->repr(true);
34
  } else {
35
  $compiler->raw('array_key_exists(')->repr($name)->raw(', $context)');
36
  }
37
  } elseif ($this->isSpecial()) {
 
 
 
 
38
  $compiler->raw($this->specialVars[$name]);
39
  } elseif ($this->getAttribute('always_defined')) {
40
  $compiler
30
 
31
  if ($this->getAttribute('is_defined_test')) {
32
  if ($this->isSpecial()) {
33
+ if ('_self' === $name) {
34
+ @trigger_error(sprintf('Global variable "_self" is deprecated in %s at line %d', '?', $this->getLine()), E_USER_DEPRECATED);
35
+ }
36
+
37
  $compiler->repr(true);
38
  } else {
39
  $compiler->raw('array_key_exists(')->repr($name)->raw(', $context)');
40
  }
41
  } elseif ($this->isSpecial()) {
42
+ if ('_self' === $name) {
43
+ @trigger_error(sprintf('Global variable "_self" is deprecated in %s at line %d', '?', $this->getLine()), E_USER_DEPRECATED);
44
+ }
45
+
46
  $compiler->raw($this->specialVars[$name]);
47
  } elseif ($this->getAttribute('always_defined')) {
48
  $compiler
vendor/twig/twig/lib/Twig/Node/Module.php CHANGED
@@ -402,22 +402,7 @@ class Twig_Node_Module extends Twig_Node
402
  ->raw(");\n")
403
  ;
404
  } else {
405
- $compiler
406
- ->write(sprintf('%s = ', $var))
407
- ->subcompile($node)
408
- ->raw(";\n")
409
- ->write(sprintf('if (!%s', $var))
410
- ->raw(" instanceof Twig_Template) {\n")
411
- ->indent()
412
- ->write(sprintf('%s = $this->loadTemplate(%s')
413
- ->raw(', ')
414
- ->repr($compiler->getFilename())
415
- ->raw(', ')
416
- ->repr($node->getLine())
417
- ->raw(");\n", $var, $var))
418
- ->outdent()
419
- ->write("}\n")
420
- ;
421
  }
422
  }
423
  }
402
  ->raw(");\n")
403
  ;
404
  } else {
405
+ throw new LogicException('Trait templates can only be constant nodes');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
406
  }
407
  }
408
  }
vendor/twig/twig/lib/Twig/NodeTraverser.php CHANGED
@@ -19,7 +19,7 @@
19
  class Twig_NodeTraverser
20
  {
21
  protected $env;
22
- protected $visitors;
23
 
24
  /**
25
  * Constructor.
@@ -30,7 +30,6 @@ class Twig_NodeTraverser
30
  public function __construct(Twig_Environment $env, array $visitors = array())
31
  {
32
  $this->env = $env;
33
- $this->visitors = array();
34
  foreach ($visitors as $visitor) {
35
  $this->addVisitor($visitor);
36
  }
19
  class Twig_NodeTraverser
20
  {
21
  protected $env;
22
+ protected $visitors = array();
23
 
24
  /**
25
  * Constructor.
30
  public function __construct(Twig_Environment $env, array $visitors = array())
31
  {
32
  $this->env = $env;
 
33
  foreach ($visitors as $visitor) {
34
  $this->addVisitor($visitor);
35
  }
vendor/twig/twig/lib/Twig/Parser.php CHANGED
@@ -64,7 +64,7 @@ class Twig_Parser implements Twig_ParserInterface
64
  {
65
  // push all variables into the stack to keep the current state of the parser
66
  $vars = get_object_vars($this);
67
- unset($vars['stack'], $vars['env'], $vars['handlers'], $vars['visitors'], $vars['expressionParser']);
68
  $this->stack[] = $vars;
69
 
70
  // tag handlers
64
  {
65
  // push all variables into the stack to keep the current state of the parser
66
  $vars = get_object_vars($this);
67
+ unset($vars['stack'], $vars['env'], $vars['handlers'], $vars['visitors'], $vars['expressionParser'], $vars['reservedMacroNames']);
68
  $this->stack[] = $vars;
69
 
70
  // tag handlers
vendor/twig/twig/lib/Twig/SimpleFilter.php CHANGED
@@ -34,6 +34,8 @@ class Twig_SimpleFilter
34
  'pre_escape' => null,
35
  'preserves_safety' => null,
36
  'node_class' => 'Twig_Node_Expression_Filter',
 
 
37
  ), $options);
38
  }
39
 
@@ -97,4 +99,14 @@ class Twig_SimpleFilter
97
  {
98
  return $this->options['is_variadic'];
99
  }
 
 
 
 
 
 
 
 
 
 
100
  }
34
  'pre_escape' => null,
35
  'preserves_safety' => null,
36
  'node_class' => 'Twig_Node_Expression_Filter',
37
+ 'deprecated' => false,
38
+ 'alternative' => null,
39
  ), $options);
40
  }
41
 
99
  {
100
  return $this->options['is_variadic'];
101
  }
102
+
103
+ public function isDeprecated()
104
+ {
105
+ return $this->options['deprecated'];
106
+ }
107
+
108
+ public function getAlternative()
109
+ {
110
+ return $this->options['alternative'];
111
+ }
112
  }
vendor/twig/twig/lib/Twig/SimpleFunction.php CHANGED
@@ -32,6 +32,8 @@ class Twig_SimpleFunction
32
  'is_safe' => null,
33
  'is_safe_callback' => null,
34
  'node_class' => 'Twig_Node_Expression_Function',
 
 
35
  ), $options);
36
  }
37
 
@@ -87,4 +89,14 @@ class Twig_SimpleFunction
87
  {
88
  return $this->options['is_variadic'];
89
  }
 
 
 
 
 
 
 
 
 
 
90
  }
32
  'is_safe' => null,
33
  'is_safe_callback' => null,
34
  'node_class' => 'Twig_Node_Expression_Function',
35
+ 'deprecated' => false,
36
+ 'alternative' => null,
37
  ), $options);
38
  }
39
 
89
  {
90
  return $this->options['is_variadic'];
91
  }
92
+
93
+ public function isDeprecated()
94
+ {
95
+ return $this->options['deprecated'];
96
+ }
97
+
98
+ public function getAlternative()
99
+ {
100
+ return $this->options['alternative'];
101
+ }
102
  }
vendor/twig/twig/lib/Twig/SimpleTest.php CHANGED
@@ -27,6 +27,8 @@ class Twig_SimpleTest
27
  $this->options = array_merge(array(
28
  'is_variadic' => false,
29
  'node_class' => 'Twig_Node_Expression_Test',
 
 
30
  ), $options);
31
  }
32
 
@@ -49,4 +51,14 @@ class Twig_SimpleTest
49
  {
50
  return $this->options['is_variadic'];
51
  }
 
 
 
 
 
 
 
 
 
 
52
  }
27
  $this->options = array_merge(array(
28
  'is_variadic' => false,
29
  'node_class' => 'Twig_Node_Expression_Test',
30
+ 'deprecated' => false,
31
+ 'alternative' => null,
32
  ), $options);
33
  }
34
 
51
  {
52
  return $this->options['is_variadic'];
53
  }
54
+
55
+ public function isDeprecated()
56
+ {
57
+ return $this->options['deprecated'];
58
+ }
59
+
60
+ public function getAlternative()
61
+ {
62
+ return $this->options['alternative'];
63
+ }
64
  }
vendor/twig/twig/lib/Twig/Template.php CHANGED
@@ -22,8 +22,8 @@ abstract class Twig_Template implements Twig_TemplateInterface
22
  protected $parent;
23
  protected $parents = array();
24
  protected $env;
25
- protected $blocks;
26
- protected $traits;
27
 
28
  /**
29
  * Constructor.
@@ -33,8 +33,6 @@ abstract class Twig_Template implements Twig_TemplateInterface
33
  public function __construct(Twig_Environment $env)
34
  {
35
  $this->env = $env;
36
- $this->blocks = array();
37
- $this->traits = array();
38
  }
39
 
40
  /**
@@ -155,8 +153,8 @@ abstract class Twig_Template implements Twig_TemplateInterface
155
 
156
  if (null !== $template) {
157
  // avoid RCEs when sandbox is enabled
158
- if (!$template instanceof Twig_Template) {
159
- throw new \LogicException('A block must be a method on a Twig_Template instance.');
160
  }
161
 
162
  try {
22
  protected $parent;
23
  protected $parents = array();
24
  protected $env;
25
+ protected $blocks = array();
26
+ protected $traits = array();
27
 
28
  /**
29
  * Constructor.
33
  public function __construct(Twig_Environment $env)
34
  {
35
  $this->env = $env;
 
 
36
  }
37
 
38
  /**
153
 
154
  if (null !== $template) {
155
  // avoid RCEs when sandbox is enabled
156
+ if (!$template instanceof self) {
157
+ throw new LogicException('A block must be a method on a Twig_Template instance.');
158
  }
159
 
160
  try {
vendor/twig/twig/lib/Twig/Test.php CHANGED
@@ -9,6 +9,8 @@
9
  * file that was distributed with this source code.
10
  */
11
 
 
 
12
  /**
13
  * Represents a template test.
14
  *
9
  * file that was distributed with this source code.
10
  */
11
 
12
+ @trigger_error('The Twig_Test class is deprecated since version 1.12 and will be removed in 2.0. Use Twig_SimpleTest instead.', E_USER_DEPRECATED);
13
+
14
  /**
15
  * Represents a template test.
16
  *
vendor/twig/twig/lib/Twig/Test/Function.php CHANGED
@@ -9,6 +9,8 @@
9
  * file that was distributed with this source code.
10
  */
11
 
 
 
12
  /**
13
  * Represents a function template test.
14
  *
9
  * file that was distributed with this source code.
10
  */
11
 
12
+ @trigger_error('The Twig_Test_Function class is deprecated since version 1.12 and will be removed in 2.0. Use Twig_SimpleTest instead.', E_USER_DEPRECATED);
13
+
14
  /**
15
  * Represents a function template test.
16
  *
vendor/twig/twig/lib/Twig/Test/IntegrationTestCase.php CHANGED
@@ -28,7 +28,16 @@ abstract class Twig_Test_IntegrationTestCase extends PHPUnit_Framework_TestCase
28
  $this->doIntegrationTest($file, $message, $condition, $templates, $exception, $outputs);
29
  }
30
 
31
- public function getTests()
 
 
 
 
 
 
 
 
 
32
  {
33
  $fixturesDir = realpath($this->getFixturesDir());
34
  $tests = array();
@@ -38,10 +47,13 @@ abstract class Twig_Test_IntegrationTestCase extends PHPUnit_Framework_TestCase
38
  continue;
39
  }
40
 
 
 
 
 
41
  $test = file_get_contents($file->getRealpath());
42
 
43
- if (preg_match('/
44
- --TEST--\s*(.*?)\s*(?:--CONDITION--\s*(.*))?\s*((?:--TEMPLATE(?:\(.*?\))?--(?:.*?))+)\s*(?:--DATA--\s*(.*))?\s*--EXCEPTION--\s*(.*)/sx', $test, $match)) {
45
  $message = $match[1];
46
  $condition = $match[2];
47
  $templates = $this->parseTemplates($match[3]);
@@ -60,9 +72,19 @@ abstract class Twig_Test_IntegrationTestCase extends PHPUnit_Framework_TestCase
60
  $tests[] = array(str_replace($fixturesDir.'/', '', $file), $message, $condition, $templates, $exception, $outputs);
61
  }
62
 
 
 
 
 
 
63
  return $tests;
64
  }
65
 
 
 
 
 
 
66
  protected function doIntegrationTest($file, $message, $condition, $templates, $exception, $outputs)
67
  {
68
  if ($condition) {
28
  $this->doIntegrationTest($file, $message, $condition, $templates, $exception, $outputs);
29
  }
30
 
31
+ /**
32
+ * @dataProvider getLegacyTests
33
+ * @group legacy
34
+ */
35
+ public function testLegacyIntegration($file, $message, $condition, $templates, $exception, $outputs)
36
+ {
37
+ $this->testIntegration($file, $message, $condition, $templates, $exception, $outputs);
38
+ }
39
+
40
+ public function getTests($name, $legacyTests = false)
41
  {
42
  $fixturesDir = realpath($this->getFixturesDir());
43
  $tests = array();
47
  continue;
48
  }
49
 
50
+ if ($legacyTests xor false !== strpos($file->getRealpath(), '.legacy.test')) {
51
+ continue;
52
+ }
53
+
54
  $test = file_get_contents($file->getRealpath());
55
 
56
+ if (preg_match('/--TEST--\s*(.*?)\s*(?:--CONDITION--\s*(.*))?\s*((?:--TEMPLATE(?:\(.*?\))?--(?:.*?))+)\s*(?:--DATA--\s*(.*))?\s*--EXCEPTION--\s*(.*)/sx', $test, $match)) {
 
57
  $message = $match[1];
58
  $condition = $match[2];
59
  $templates = $this->parseTemplates($match[3]);
72
  $tests[] = array(str_replace($fixturesDir.'/', '', $file), $message, $condition, $templates, $exception, $outputs);
73
  }
74
 
75
+ if (!$tests) {
76
+ // add a dummy test to avoid a PHPUnit message
77
+ return array(array('not', '-', '', array(), '', array()));
78
+ }
79
+
80
  return $tests;
81
  }
82
 
83
+ public function getLegacyTests()
84
+ {
85
+ return $this->getTests('testLegacyIntegration', true);
86
+ }
87
+
88
  protected function doIntegrationTest($file, $message, $condition, $templates, $exception, $outputs)
89
  {
90
  if ($condition) {
vendor/twig/twig/lib/Twig/Test/Method.php CHANGED
@@ -9,6 +9,8 @@
9
  * file that was distributed with this source code.
10
  */
11
 
 
 
12
  /**
13
  * Represents a method template test.
14
  *
9
  * file that was distributed with this source code.
10
  */
11
 
12
+ @trigger_error('The Twig_Test_Method class is deprecated since version 1.12 and will be removed in 2.0. Use Twig_SimpleTest instead.', E_USER_DEPRECATED);
13
+
14
  /**
15
  * Represents a method template test.
16
  *
vendor/twig/twig/lib/Twig/Test/Node.php CHANGED
@@ -9,6 +9,8 @@
9
  * file that was distributed with this source code.
10
  */
11
 
 
 
12
  /**
13
  * Represents a template test as a Node.
14
  *
9
  * file that was distributed with this source code.
10
  */
11
 
12
+ @trigger_error('The Twig_Test_Node class is deprecated since version 1.12 and will be removed in 2.0.', E_USER_DEPRECATED);
13
+
14
  /**
15
  * Represents a template test as a Node.
16
  *
vendor/twig/twig/lib/Twig/Test/NodeTestCase.php CHANGED
@@ -35,7 +35,7 @@ abstract class Twig_Test_NodeTestCase extends PHPUnit_Framework_TestCase
35
 
36
  protected function getEnvironment()
37
  {
38
- return new Twig_Environment();
39
  }
40
 
41
  protected function getVariableGetter($name, $line = false)
35
 
36
  protected function getEnvironment()
37
  {
38
+ return new Twig_Environment(new Twig_Loader_Array(array()));
39
  }
40
 
41
  protected function getVariableGetter($name, $line = false)
vendor/twig/twig/lib/Twig/TokenParser/AutoEscape.php CHANGED
@@ -57,6 +57,8 @@ class Twig_TokenParser_AutoEscape extends Twig_TokenParser
57
  }
58
 
59
  if ($compat && $stream->test(Twig_Token::NAME_TYPE)) {
 
 
60
  if (false === $value) {
61
  throw new Twig_Error_Syntax('Unexpected escaping strategy as you set autoescaping to false.', $stream->getCurrent()->getLine(), $stream->getFilename());
62
  }
57
  }
58
 
59
  if ($compat && $stream->test(Twig_Token::NAME_TYPE)) {
60
+ @trigger_error('Using the autoescape tag with "true" or "false" before the strategy name is deprecated.', E_USER_DEPRECATED);
61
+
62
  if (false === $value) {
63
  throw new Twig_Error_Syntax('Unexpected escaping strategy as you set autoescaping to false.', $stream->getCurrent()->getLine(), $stream->getFilename());
64
  }
vendor/twig/twig/lib/Twig/TokenParserBroker.php CHANGED
@@ -29,8 +29,12 @@ class Twig_TokenParserBroker implements Twig_TokenParserBrokerInterface
29
  * @param array|Traversable $parsers A Traversable of Twig_TokenParserInterface instances
30
  * @param array|Traversable $brokers A Traversable of Twig_TokenParserBrokerInterface instances
31
  */
32
- public function __construct($parsers = array(), $brokers = array())
33
  {
 
 
 
 
34
  foreach ($parsers as $parser) {
35
  if (!$parser instanceof Twig_TokenParserInterface) {
36
  throw new LogicException('$parsers must a an array of Twig_TokenParserInterface');
29
  * @param array|Traversable $parsers A Traversable of Twig_TokenParserInterface instances
30
  * @param array|Traversable $brokers A Traversable of Twig_TokenParserBrokerInterface instances
31
  */
32
+ public function __construct($parsers = array(), $brokers = array(), $triggerDeprecationError = true)
33
  {
34
+ if ($triggerDeprecationError) {
35
+ @trigger_error('The '.__CLASS__.' class is deprecated since version 1.12 and will be removed in 2.0.', E_USER_DEPRECATED);
36
+ }
37
+
38
  foreach ($parsers as $parser) {
39
  if (!$parser instanceof Twig_TokenParserInterface) {
40
  throw new LogicException('$parsers must a an array of Twig_TokenParserInterface');
vendor/twig/twig/lib/Twig/TokenStream.php CHANGED
@@ -18,7 +18,7 @@
18
  class Twig_TokenStream
19
  {
20
  protected $tokens;
21
- protected $current;
22
  protected $filename;
23
 
24
  /**
@@ -30,7 +30,6 @@ class Twig_TokenStream
30
  public function __construct(array $tokens, $filename = null)
31
  {
32
  $this->tokens = $tokens;
33
- $this->current = 0;
34
  $this->filename = $filename;
35
  }
36
 
18
  class Twig_TokenStream
19
  {
20
  protected $tokens;
21
+ protected $current = 0;
22
  protected $filename;
23
 
24
  /**
30
  public function __construct(array $tokens, $filename = null)
31
  {
32
  $this->tokens = $tokens;
 
33
  $this->filename = $filename;
34
  }
35
 
vendor/twig/twig/lib/Twig/Util/DeprecationCollector.php ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of Twig.
5
+ *
6
+ * (c) Fabien Potencier
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ /**
13
+ * @author Fabien Potencier <fabien@symfony.com>
14
+ */
15
+ class Twig_Util_DeprecationCollector
16
+ {
17
+ private $twig;
18
+ private $deprecations;
19
+
20
+ public function __construct(Twig_Environment $twig)
21
+ {
22
+ $this->twig = $twig;
23
+ }
24
+
25
+ /**
26
+ * Returns deprecations for templates contained in a directory.
27
+ *
28
+ * @param string $dir A directory where templates are stored
29
+ * @param string $ext Limit the loaded templates by extension
30
+ *
31
+ * @return array() An array of deprecations
32
+ */
33
+ public function collectDir($dir, $ext = '.twig')
34
+ {
35
+ $iterator = new RegexIterator(
36
+ new RecursiveIteratorIterator(
37
+ new RecursiveDirectoryIterator($dir), RecursiveIteratorIterator::LEAVES_ONLY
38
+ ), '{'.preg_quote($ext).'$}'
39
+ );
40
+
41
+ return $this->collect(new Twig_Util_TemplateDirIterator($iterator));
42
+ }
43
+
44
+ /**
45
+ * Returns deprecations for passed templates.
46
+ *
47
+ * @param Iterator $iterator An iterator of templates (where keys are template names and values the contents of the template)
48
+ *
49
+ * @return array() An array of deprecations
50
+ */
51
+ public function collect(Iterator $iterator)
52
+ {
53
+ $this->deprecations = array();
54
+
55
+ set_error_handler(array($this, 'errorHandler'));
56
+
57
+ foreach ($iterator as $name => $contents) {
58
+ try {
59
+ $this->twig->parse($this->twig->tokenize($contents, $name));
60
+ } catch (Twig_Error_Syntax $e) {
61
+ // ignore templates containing syntax errors
62
+ }
63
+ }
64
+
65
+ restore_error_handler();
66
+
67
+ $deprecations = $this->deprecations;
68
+ $this->deprecations = array();
69
+
70
+ return $deprecations;
71
+ }
72
+
73
+ /**
74
+ * @internal
75
+ */
76
+ public function errorHandler($type, $msg)
77
+ {
78
+ if (E_USER_DEPRECATED === $type) {
79
+ $this->deprecations[] = $msg;
80
+ }
81
+ }
82
+ }
vendor/twig/twig/lib/Twig/Util/TemplateDirIterator.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of Twig.
5
+ *
6
+ * (c) Fabien Potencier
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ /**
13
+ * @author Fabien Potencier <fabien@symfony.com>
14
+ */
15
+ class Twig_Util_TemplateDirIterator extends IteratorIterator
16
+ {
17
+ public function current()
18
+ {
19
+ return file_get_contents(parent::current());
20
+ }
21
+
22
+ public function key()
23
+ {
24
+ return (string) parent::key();
25
+ }
26
+ }
vendor/twig/twig/phpunit.xml.dist CHANGED
@@ -9,7 +9,7 @@
9
  processIsolation="false"
10
  stopOnFailure="false"
11
  syntaxCheck="false"
12
- bootstrap="test/bootstrap.php"
13
  >
14
  <testsuites>
15
  <testsuite name="Twig Test Suite">
9
  processIsolation="false"
10
  stopOnFailure="false"
11
  syntaxCheck="false"
12
+ bootstrap="vendor/autoload.php"
13
  >
14
  <testsuites>
15
  <testsuite name="Twig Test Suite">
vendor/twig/twig/test/Twig/Tests/AutoloaderTest.php CHANGED
@@ -11,6 +11,9 @@
11
 
12
  class Twig_Tests_AutoloaderTest extends PHPUnit_Framework_TestCase
13
  {
 
 
 
14
  public function testAutoload()
15
  {
16
  $this->assertFalse(class_exists('FooBarFoo'), '->autoload() does not try to load classes that does not begin with Twig');
11
 
12
  class Twig_Tests_AutoloaderTest extends PHPUnit_Framework_TestCase
13
  {
14
+ /**
15
+ * @group legacy
16
+ */
17
  public function testAutoload()
18
  {
19
  $this->assertFalse(class_exists('FooBarFoo'), '->autoload() does not try to load classes that does not begin with Twig');
vendor/twig/twig/test/Twig/Tests/CompilerTest.php CHANGED
@@ -13,7 +13,7 @@ class Twig_Tests_CompilerTest extends PHPUnit_Framework_TestCase
13
  {
14
  public function testReprNumericValueWithLocale()
15
  {
16
- $compiler = new Twig_Compiler(new Twig_Environment());
17
 
18
  $locale = setlocale(LC_NUMERIC, 0);
19
  if (false === $locale) {
13
  {
14
  public function testReprNumericValueWithLocale()
15
  {
16
+ $compiler = new Twig_Compiler(new Twig_Environment($this->getMock('Twig_LoaderInterface')));
17
 
18
  $locale = setlocale(LC_NUMERIC, 0);
19
  if (false === $locale) {
vendor/twig/twig/test/Twig/Tests/EnvironmentTest.php CHANGED
@@ -14,6 +14,7 @@ class Twig_Tests_EnvironmentTest extends PHPUnit_Framework_TestCase
14
  /**
15
  * @expectedException LogicException
16
  * @expectedExceptionMessage You must set a loader first.
 
17
  */
18
  public function testRenderNoLoader()
19
  {
@@ -182,6 +183,9 @@ class Twig_Tests_EnvironmentTest extends PHPUnit_Framework_TestCase
182
  $this->assertEquals('Twig_Tests_EnvironmentTest_NodeVisitor', get_class($visitors[2]));
183
  }
184
 
 
 
 
185
  public function testRemoveExtension()
186
  {
187
  $twig = new Twig_Environment($this->getMock('Twig_LoaderInterface'));
14
  /**
15
  * @expectedException LogicException
16
  * @expectedExceptionMessage You must set a loader first.
17
+ * @group legacy
18
  */
19
  public function testRenderNoLoader()
20
  {
183
  $this->assertEquals('Twig_Tests_EnvironmentTest_NodeVisitor', get_class($visitors[2]));
184
  }
185
 
186
+ /**
187
+ * @group legacy
188
+ */
189
  public function testRemoveExtension()
190
  {
191
  $twig = new Twig_Environment($this->getMock('Twig_LoaderInterface'));
vendor/twig/twig/test/Twig/Tests/Extension/CoreTest.php CHANGED
@@ -16,7 +16,7 @@ class Twig_Tests_Extension_CoreTest extends PHPUnit_Framework_TestCase
16
  */
17
  public function testRandomFunction($value, $expectedInArray)
18
  {
19
- $env = new Twig_Environment();
20
 
21
  for ($i = 0; $i < 100; ++$i) {
22
  $this->assertTrue(in_array(twig_random($env, $value), $expectedInArray, true)); // assertContains() would not consider the type
@@ -62,18 +62,18 @@ class Twig_Tests_Extension_CoreTest extends PHPUnit_Framework_TestCase
62
  $max = mt_getrandmax();
63
 
64
  for ($i = 0; $i < 100; ++$i) {
65
- $val = twig_random(new Twig_Environment());
66
  $this->assertTrue(is_int($val) && $val >= 0 && $val <= $max);
67
  }
68
  }
69
 
70
  public function testRandomFunctionReturnsAsIs()
71
  {
72
- $this->assertSame('', twig_random(new Twig_Environment(), ''));
73
- $this->assertSame('', twig_random(new Twig_Environment(null, array('charset' => null)), ''));
74
 
75
  $instance = new stdClass();
76
- $this->assertSame($instance, twig_random(new Twig_Environment(), $instance));
77
  }
78
 
79
  /**
@@ -81,7 +81,7 @@ class Twig_Tests_Extension_CoreTest extends PHPUnit_Framework_TestCase
81
  */
82
  public function testRandomFunctionOfEmptyArrayThrowsException()
83
  {
84
- twig_random(new Twig_Environment(), array());
85
  }
86
 
87
  public function testRandomFunctionOnNonUTF8String()
@@ -90,7 +90,7 @@ class Twig_Tests_Extension_CoreTest extends PHPUnit_Framework_TestCase
90
  $this->markTestSkipped('needs iconv or mbstring');
91
  }
92
 
93
- $twig = new Twig_Environment();
94
  $twig->setCharset('ISO-8859-1');
95
 
96
  $text = twig_convert_encoding('Äé', 'ISO-8859-1', 'UTF-8');
@@ -106,7 +106,7 @@ class Twig_Tests_Extension_CoreTest extends PHPUnit_Framework_TestCase
106
  $this->markTestSkipped('needs iconv or mbstring');
107
  }
108
 
109
- $twig = new Twig_Environment();
110
  $twig->setCharset('ISO-8859-1');
111
 
112
  $input = twig_convert_encoding('Äé', 'ISO-8859-1', 'UTF-8');
@@ -117,7 +117,7 @@ class Twig_Tests_Extension_CoreTest extends PHPUnit_Framework_TestCase
117
 
118
  public function testCustomEscaper()
119
  {
120
- $twig = new Twig_Environment();
121
  $twig->getExtension('core')->setEscaper('foo', 'foo_escaper_for_test');
122
 
123
  $this->assertEquals('fooUTF-8', twig_escape_filter($twig, 'foo', 'foo'));
@@ -128,12 +128,12 @@ class Twig_Tests_Extension_CoreTest extends PHPUnit_Framework_TestCase
128
  */
129
  public function testUnknownCustomEscaper()
130
  {
131
- twig_escape_filter(new Twig_Environment(), 'foo', 'bar');
132
  }
133
 
134
  public function testTwigFirst()
135
  {
136
- $twig = new Twig_Environment();
137
  $this->assertEquals('a', twig_first($twig, 'abc'));
138
  $this->assertEquals(1, twig_first($twig, array(1, 2, 3)));
139
  $this->assertSame('', twig_first($twig, null));
@@ -142,7 +142,7 @@ class Twig_Tests_Extension_CoreTest extends PHPUnit_Framework_TestCase
142
 
143
  public function testTwigLast()
144
  {
145
- $twig = new Twig_Environment();
146
  $this->assertEquals('c', twig_last($twig, 'abc'));
147
  $this->assertEquals(3, twig_last($twig, array(1, 2, 3)));
148
  $this->assertSame('', twig_last($twig, null));
16
  */
17
  public function testRandomFunction($value, $expectedInArray)
18
  {
19
+ $env = new Twig_Environment($this->getMock('Twig_LoaderInterface'));
20
 
21
  for ($i = 0; $i < 100; ++$i) {
22
  $this->assertTrue(in_array(twig_random($env, $value), $expectedInArray, true)); // assertContains() would not consider the type
62
  $max = mt_getrandmax();
63
 
64
  for ($i = 0; $i < 100; ++$i) {
65
+ $val = twig_random(new Twig_Environment($this->getMock('Twig_LoaderInterface')));
66
  $this->assertTrue(is_int($val) && $val >= 0 && $val <= $max);
67
  }
68
  }
69
 
70
  public function testRandomFunctionReturnsAsIs()
71
  {
72
+ $this->assertSame('', twig_random(new Twig_Environment($this->getMock('Twig_LoaderInterface')), ''));
73
+ $this->assertSame('', twig_random(new Twig_Environment($this->getMock('Twig_LoaderInterface'), array('charset' => null)), ''));
74
 
75
  $instance = new stdClass();
76
+ $this->assertSame($instance, twig_random(new Twig_Environment($this->getMock('Twig_LoaderInterface')), $instance));
77
  }
78
 
79
  /**
81
  */
82
  public function testRandomFunctionOfEmptyArrayThrowsException()
83
  {
84
+ twig_random(new Twig_Environment($this->getMock('Twig_LoaderInterface')), array());
85
  }
86
 
87
  public function testRandomFunctionOnNonUTF8String()
90
  $this->markTestSkipped('needs iconv or mbstring');
91
  }
92
 
93
+ $twig = new Twig_Environment($this->getMock('Twig_LoaderInterface'));
94
  $twig->setCharset('ISO-8859-1');
95
 
96
  $text = twig_convert_encoding('Äé', 'ISO-8859-1', 'UTF-8');
106
  $this->markTestSkipped('needs iconv or mbstring');
107
  }
108
 
109
+ $twig = new Twig_Environment($this->getMock('Twig_LoaderInterface'));
110
  $twig->setCharset('ISO-8859-1');
111
 
112
  $input = twig_convert_encoding('Äé', 'ISO-8859-1', 'UTF-8');
117
 
118
  public function testCustomEscaper()
119
  {
120
+ $twig = new Twig_Environment($this->getMock('Twig_LoaderInterface'));
121
  $twig->getExtension('core')->setEscaper('foo', 'foo_escaper_for_test');
122
 
123
  $this->assertEquals('fooUTF-8', twig_escape_filter($twig, 'foo', 'foo'));
128
  */
129
  public function testUnknownCustomEscaper()
130
  {
131
+ twig_escape_filter(new Twig_Environment($this->getMock('Twig_LoaderInterface')), 'foo', 'bar');
132
  }
133
 
134
  public function testTwigFirst()
135
  {
136
+ $twig = new Twig_Environment($this->getMock('Twig_LoaderInterface'));
137
  $this->assertEquals('a', twig_first($twig, 'abc'));
138
  $this->assertEquals(1, twig_first($twig, array(1, 2, 3)));
139
  $this->assertSame('', twig_first($twig, null));
142
 
143
  public function testTwigLast()
144
  {
145
+ $twig = new Twig_Environment($this->getMock('Twig_LoaderInterface'));
146
  $this->assertEquals('c', twig_last($twig, 'abc'));
147
  $this->assertEquals(3, twig_last($twig, array(1, 2, 3)));
148
  $this->assertSame('', twig_last($twig, null));
vendor/twig/twig/test/Twig/Tests/Extension/SandboxTest.php CHANGED
@@ -163,7 +163,7 @@ class Twig_Tests_Extension_SandboxTest extends PHPUnit_Framework_TestCase
163
 
164
  public function testMacrosInASandbox()
165
  {
166
- $twig = $this->getEnvironment(true, array('autoescape' => true), array('index' => <<<EOF
167
  {%- import _self as macros %}
168
 
169
  {%- macro test(text) %}<p>{{ text }}</p>{% endmacro %}
163
 
164
  public function testMacrosInASandbox()
165
  {
166
+ $twig = $this->getEnvironment(true, array('autoescape' => 'html'), array('index' => <<<EOF
167
  {%- import _self as macros %}
168
 
169
  {%- macro test(text) %}<p>{{ text }}</p>{% endmacro %}
vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/strategy.legacy.test ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ --TEST--
2
+ "autoescape" tag accepts an escaping strategy
3
+ --TEMPLATE--
4
+ {% autoescape true js %}{{ var }}{% endautoescape %}
5
+
6
+ {% autoescape true html %}{{ var }}{% endautoescape %}
7
+ --DATA--
8
+ return array('var' => '<br />"')
9
+ --EXPECT--
10
+ \x3Cbr\x20\x2F\x3E\x22
11
+ &lt;br /&gt;&quot;
vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/strategy.test CHANGED
@@ -1,10 +1,6 @@
1
  --TEST--
2
  "autoescape" tag accepts an escaping strategy
3
  --TEMPLATE--
4
- {% autoescape true js %}{{ var }}{% endautoescape %}
5
-
6
- {% autoescape true html %}{{ var }}{% endautoescape %}
7
-
8
  {% autoescape 'js' %}{{ var }}{% endautoescape %}
9
 
10
  {% autoescape 'html' %}{{ var }}{% endautoescape %}
@@ -13,5 +9,3 @@ return array('var' => '<br />"')
13
  --EXPECT--
14
  \x3Cbr\x20\x2F\x3E\x22
15
  &lt;br /&gt;&quot;
16
- \x3Cbr\x20\x2F\x3E\x22
17
- &lt;br /&gt;&quot;
1
  --TEST--
2
  "autoescape" tag accepts an escaping strategy
3
  --TEMPLATE--
 
 
 
 
4
  {% autoescape 'js' %}{{ var }}{% endautoescape %}
5
 
6
  {% autoescape 'html' %}{{ var }}{% endautoescape %}
9
  --EXPECT--
10
  \x3Cbr\x20\x2F\x3E\x22
11
  &lt;br /&gt;&quot;
 
 
vendor/twig/twig/test/Twig/Tests/Fixtures/tags/raw/{basic.test → basic.legacy.test} RENAMED
File without changes
vendor/twig/twig/test/Twig/Tests/Fixtures/tags/raw/{mixed_usage_with_raw.test → mixed_usage_with_raw.legacy.test} RENAMED
File without changes
vendor/twig/twig/test/Twig/Tests/Fixtures/tags/raw/{whitespace_control.test → whitespace_control.legacy.test} RENAMED
File without changes
vendor/twig/twig/test/Twig/Tests/LegacyFixtures/test.legacy.test ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ --TEST--
2
+ Old test classes usage
3
+ --TEMPLATE--
4
+ {{ 'foo' is multi word ? 'yes' : 'no' }}
5
+ --DATA--
6
+ return array()
7
+ --EXPECT--
8
+ no
vendor/twig/twig/test/Twig/Tests/LegacyIntegrationTest.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_LegacyIntegrationTest extends Twig_Test_IntegrationTestCase
13
+ {
14
+ public function getExtensions()
15
+ {
16
+ return array(
17
+ new LegacyTwigTestExtension(),
18
+ );
19
+ }
20
+
21
+ public function getFixturesDir()
22
+ {
23
+ return dirname(__FILE__).'/LegacyFixtures/';
24
+ }
25
+ }
26
+
27
+ class LegacyTwigTestExtension extends Twig_Extension
28
+ {
29
+ public function getTests()
30
+ {
31
+ return array(
32
+ 'multi word' => new Twig_Test_Method($this, 'is_multi_word'),
33
+ );
34
+ }
35
+
36
+ public function is_multi_word($value)
37
+ {
38
+ return false !== strpos($value, ' ');
39
+ }
40
+
41
+ public function getName()
42
+ {
43
+ return 'legacy_integration_test';
44
+ }
45
+ }
vendor/twig/twig/test/Twig/Tests/LexerTest.php CHANGED
@@ -14,7 +14,7 @@ class Twig_Tests_LexerTest extends PHPUnit_Framework_TestCase
14
  {
15
  $template = '{% § %}';
16
 
17
- $lexer = new Twig_Lexer(new Twig_Environment());
18
  $stream = $lexer->tokenize($template);
19
 
20
  $stream->expect(Twig_Token::BLOCK_START_TYPE);
@@ -25,7 +25,7 @@ class Twig_Tests_LexerTest extends PHPUnit_Framework_TestCase
25
  {
26
  $template = '{{ §() }}';
27
 
28
- $lexer = new Twig_Lexer(new Twig_Environment());
29
  $stream = $lexer->tokenize($template);
30
 
31
  $stream->expect(Twig_Token::VAR_START_TYPE);
@@ -42,7 +42,7 @@ class Twig_Tests_LexerTest extends PHPUnit_Framework_TestCase
42
 
43
  protected function countToken($template, $type, $value = null)
44
  {
45
- $lexer = new Twig_Lexer(new Twig_Environment());
46
  $stream = $lexer->tokenize($template);
47
 
48
  $count = 0;
@@ -67,7 +67,7 @@ class Twig_Tests_LexerTest extends PHPUnit_Framework_TestCase
67
  ."baz\n"
68
  ."}}\n";
69
 
70
- $lexer = new Twig_Lexer(new Twig_Environment());
71
  $stream = $lexer->tokenize($template);
72
 
73
  // foo\nbar\n
@@ -87,7 +87,7 @@ class Twig_Tests_LexerTest extends PHPUnit_Framework_TestCase
87
  ."baz\n"
88
  ."}}\n";
89
 
90
- $lexer = new Twig_Lexer(new Twig_Environment());
91
  $stream = $lexer->tokenize($template);
92
 
93
  // foo\nbar
@@ -102,17 +102,17 @@ class Twig_Tests_LexerTest extends PHPUnit_Framework_TestCase
102
  {
103
  $template = '{# '.str_repeat('*', 100000).' #}';
104
 
105
- $lexer = new Twig_Lexer(new Twig_Environment());
106
  $lexer->tokenize($template);
107
 
108
  // should not throw an exception
109
  }
110
 
111
- public function testLongRaw()
112
  {
113
- $template = '{% raw %}'.str_repeat('*', 100000).'{% endraw %}';
114
 
115
- $lexer = new Twig_Lexer(new Twig_Environment());
116
  $lexer->tokenize($template);
117
 
118
  // should not throw an exception
@@ -122,7 +122,7 @@ class Twig_Tests_LexerTest extends PHPUnit_Framework_TestCase
122
  {
123
  $template = '{{ '.str_repeat('x', 100000).' }}';
124
 
125
- $lexer = new Twig_Lexer(new Twig_Environment());
126
  $lexer->tokenize($template);
127
 
128
  // should not throw an exception
@@ -132,7 +132,7 @@ class Twig_Tests_LexerTest extends PHPUnit_Framework_TestCase
132
  {
133
  $template = '{% '.str_repeat('x', 100000).' %}';
134
 
135
- $lexer = new Twig_Lexer(new Twig_Environment());
136
  $lexer->tokenize($template);
137
 
138
  // should not throw an exception
@@ -142,7 +142,7 @@ class Twig_Tests_LexerTest extends PHPUnit_Framework_TestCase
142
  {
143
  $template = '{{ 922337203685477580700 }}';
144
 
145
- $lexer = new Twig_Lexer(new Twig_Environment());
146
  $stream = $lexer->tokenize($template);
147
  $stream->next();
148
  $node = $stream->next();
@@ -155,7 +155,7 @@ class Twig_Tests_LexerTest extends PHPUnit_Framework_TestCase
155
  "{{ 'foo \' bar' }}" => 'foo \' bar',
156
  '{{ "foo \" bar" }}' => 'foo " bar',
157
  );
158
- $lexer = new Twig_Lexer(new Twig_Environment());
159
  foreach ($tests as $template => $expected) {
160
  $stream = $lexer->tokenize($template);
161
  $stream->expect(Twig_Token::VAR_START_TYPE);
@@ -167,7 +167,7 @@ class Twig_Tests_LexerTest extends PHPUnit_Framework_TestCase
167
  {
168
  $template = 'foo {{ "bar #{ baz + 1 }" }}';
169
 
170
- $lexer = new Twig_Lexer(new Twig_Environment());
171
  $stream = $lexer->tokenize($template);
172
  $stream->expect(Twig_Token::TEXT_TYPE, 'foo ');
173
  $stream->expect(Twig_Token::VAR_START_TYPE);
@@ -184,7 +184,7 @@ class Twig_Tests_LexerTest extends PHPUnit_Framework_TestCase
184
  {
185
  $template = '{{ "bar \#{baz+1}" }}';
186
 
187
- $lexer = new Twig_Lexer(new Twig_Environment());
188
  $stream = $lexer->tokenize($template);
189
  $stream->expect(Twig_Token::VAR_START_TYPE);
190
  $stream->expect(Twig_Token::STRING_TYPE, 'bar #{baz+1}');
@@ -195,7 +195,7 @@ class Twig_Tests_LexerTest extends PHPUnit_Framework_TestCase
195
  {
196
  $template = '{{ "bar # baz" }}';
197
 
198
- $lexer = new Twig_Lexer(new Twig_Environment());
199
  $stream = $lexer->tokenize($template);
200
  $stream->expect(Twig_Token::VAR_START_TYPE);
201
  $stream->expect(Twig_Token::STRING_TYPE, 'bar # baz');
@@ -210,7 +210,7 @@ class Twig_Tests_LexerTest extends PHPUnit_Framework_TestCase
210
  {
211
  $template = '{{ "bar #{x" }}';
212
 
213
- $lexer = new Twig_Lexer(new Twig_Environment());
214
  $lexer->tokenize($template);
215
  }
216
 
@@ -218,7 +218,7 @@ class Twig_Tests_LexerTest extends PHPUnit_Framework_TestCase
218
  {
219
  $template = '{{ "bar #{ "foo#{bar}" }" }}';
220
 
221
- $lexer = new Twig_Lexer(new Twig_Environment());
222
  $stream = $lexer->tokenize($template);
223
  $stream->expect(Twig_Token::VAR_START_TYPE);
224
  $stream->expect(Twig_Token::STRING_TYPE, 'bar ');
@@ -235,7 +235,7 @@ class Twig_Tests_LexerTest extends PHPUnit_Framework_TestCase
235
  {
236
  $template = '{% foo "bar #{ "foo#{bar}" }" %}';
237
 
238
- $lexer = new Twig_Lexer(new Twig_Environment());
239
  $stream = $lexer->tokenize($template);
240
  $stream->expect(Twig_Token::BLOCK_START_TYPE);
241
  $stream->expect(Twig_Token::NAME_TYPE, 'foo');
@@ -253,7 +253,7 @@ class Twig_Tests_LexerTest extends PHPUnit_Framework_TestCase
253
  {
254
  $template = "{{ 1 and\n0}}";
255
 
256
- $lexer = new Twig_Lexer(new Twig_Environment());
257
  $stream = $lexer->tokenize($template);
258
  $stream->expect(Twig_Token::VAR_START_TYPE);
259
  $stream->expect(Twig_Token::NUMBER_TYPE, 1);
@@ -275,7 +275,7 @@ bar
275
 
276
  ';
277
 
278
- $lexer = new Twig_Lexer(new Twig_Environment());
279
  $lexer->tokenize($template);
280
  }
281
 
@@ -294,7 +294,7 @@ bar
294
 
295
  ';
296
 
297
- $lexer = new Twig_Lexer(new Twig_Environment());
298
  $lexer->tokenize($template);
299
  }
300
  }
14
  {
15
  $template = '{% § %}';
16
 
17
+ $lexer = new Twig_Lexer(new Twig_Environment($this->getMock('Twig_LoaderInterface')));
18
  $stream = $lexer->tokenize($template);
19
 
20
  $stream->expect(Twig_Token::BLOCK_START_TYPE);
25
  {
26
  $template = '{{ §() }}';
27
 
28
+ $lexer = new Twig_Lexer(new Twig_Environment($this->getMock('Twig_LoaderInterface')));
29
  $stream = $lexer->tokenize($template);
30
 
31
  $stream->expect(Twig_Token::VAR_START_TYPE);
42
 
43
  protected function countToken($template, $type, $value = null)
44
  {
45
+ $lexer = new Twig_Lexer(new Twig_Environment($this->getMock('Twig_LoaderInterface')));
46
  $stream = $lexer->tokenize($template);
47
 
48
  $count = 0;
67
  ."baz\n"
68
  ."}}\n";
69
 
70
+ $lexer = new Twig_Lexer(new Twig_Environment($this->getMock('Twig_LoaderInterface')));
71
  $stream = $lexer->tokenize($template);
72
 
73
  // foo\nbar\n
87
  ."baz\n"
88
  ."}}\n";
89
 
90
+ $lexer = new Twig_Lexer(new Twig_Environment($this->getMock('Twig_LoaderInterface')));
91
  $stream = $lexer->tokenize($template);
92
 
93
  // foo\nbar
102
  {
103
  $template = '{# '.str_repeat('*', 100000).' #}';
104
 
105
+ $lexer = new Twig_Lexer(new Twig_Environment($this->getMock('Twig_LoaderInterface')));
106
  $lexer->tokenize($template);
107
 
108
  // should not throw an exception
109
  }
110
 
111
+ public function testLongVerbatim()
112
  {
113
+ $template = '{% verbatim %}'.str_repeat('*', 100000).'{% endverbatim %}';
114
 
115
+ $lexer = new Twig_Lexer(new Twig_Environment($this->getMock('Twig_LoaderInterface')));
116
  $lexer->tokenize($template);
117
 
118
  // should not throw an exception
122
  {
123
  $template = '{{ '.str_repeat('x', 100000).' }}';
124
 
125
+ $lexer = new Twig_Lexer(new Twig_Environment($this->getMock('Twig_LoaderInterface')));
126
  $lexer->tokenize($template);
127
 
128
  // should not throw an exception
132
  {
133
  $template = '{% '.str_repeat('x', 100000).' %}';
134
 
135
+ $lexer = new Twig_Lexer(new Twig_Environment($this->getMock('Twig_LoaderInterface')));
136
  $lexer->tokenize($template);
137
 
138
  // should not throw an exception
142
  {
143
  $template = '{{ 922337203685477580700 }}';
144
 
145
+ $lexer = new Twig_Lexer(new Twig_Environment($this->getMock('Twig_LoaderInterface')));
146
  $stream = $lexer->tokenize($template);
147
  $stream->next();
148
  $node = $stream->next();
155
  "{{ 'foo \' bar' }}" => 'foo \' bar',
156
  '{{ "foo \" bar" }}' => 'foo " bar',
157
  );
158
+ $lexer = new Twig_Lexer(new Twig_Environment($this->getMock('Twig_LoaderInterface')));
159
  foreach ($tests as $template => $expected) {
160
  $stream = $lexer->tokenize($template);
161
  $stream->expect(Twig_Token::VAR_START_TYPE);
167
  {
168
  $template = 'foo {{ "bar #{ baz + 1 }" }}';
169
 
170
+ $lexer = new Twig_Lexer(new Twig_Environment($this->getMock('Twig_LoaderInterface')));
171
  $stream = $lexer->tokenize($template);
172
  $stream->expect(Twig_Token::TEXT_TYPE, 'foo ');
173
  $stream->expect(Twig_Token::VAR_START_TYPE);
184
  {
185
  $template = '{{ "bar \#{baz+1}" }}';
186
 
187
+ $lexer = new Twig_Lexer(new Twig_Environment($this->getMock('Twig_LoaderInterface')));
188
  $stream = $lexer->tokenize($template);
189
  $stream->expect(Twig_Token::VAR_START_TYPE);
190
  $stream->expect(Twig_Token::STRING_TYPE, 'bar #{baz+1}');
195
  {
196
  $template = '{{ "bar # baz" }}';
197
 
198
+ $lexer = new Twig_Lexer(new Twig_Environment($this->getMock('Twig_LoaderInterface')));
199
  $stream = $lexer->tokenize($template);
200
  $stream->expect(Twig_Token::VAR_START_TYPE);
201
  $stream->expect(Twig_Token::STRING_TYPE, 'bar # baz');
210
  {
211
  $template = '{{ "bar #{x" }}';
212
 
213
+ $lexer = new Twig_Lexer(new Twig_Environment($this->getMock('Twig_LoaderInterface')));
214
  $lexer->tokenize($template);
215
  }
216
 
218
  {
219
  $template = '{{ "bar #{ "foo#{bar}" }" }}';
220
 
221
+ $lexer = new Twig_Lexer(new Twig_Environment($this->getMock('Twig_LoaderInterface')));
222
  $stream = $lexer->tokenize($template);
223
  $stream->expect(Twig_Token::VAR_START_TYPE);
224
  $stream->expect(Twig_Token::STRING_TYPE, 'bar ');
235
  {
236
  $template = '{% foo "bar #{ "foo#{bar}" }" %}';
237
 
238
+ $lexer = new Twig_Lexer(new Twig_Environment($this->getMock('Twig_LoaderInterface')));
239
  $stream = $lexer->tokenize($template);
240
  $stream->expect(Twig_Token::BLOCK_START_TYPE);
241
  $stream->expect(Twig_Token::NAME_TYPE, 'foo');
253
  {
254
  $template = "{{ 1 and\n0}}";
255
 
256
+ $lexer = new Twig_Lexer(new Twig_Environment($this->getMock('Twig_LoaderInterface')));
257
  $stream = $lexer->tokenize($template);
258
  $stream->expect(Twig_Token::VAR_START_TYPE);
259
  $stream->expect(Twig_Token::NUMBER_TYPE, 1);
275
 
276
  ';
277
 
278
+ $lexer = new Twig_Lexer(new Twig_Environment($this->getMock('Twig_LoaderInterface')));
279
  $lexer->tokenize($template);
280
  }
281
 
294
 
295
  ';
296
 
297
+ $lexer = new Twig_Lexer(new Twig_Environment($this->getMock('Twig_LoaderInterface')));
298
  $lexer->tokenize($template);
299
  }
300
  }
vendor/twig/twig/test/Twig/Tests/Node/Expression/FilterTest.php CHANGED
@@ -25,7 +25,7 @@ class Twig_Tests_Node_Expression_FilterTest extends Twig_Test_NodeTestCase
25
 
26
  public function getTests()
27
  {
28
- $environment = new Twig_Environment();
29
  $environment->addFilter(new Twig_SimpleFilter('bar', 'bar', array('needs_environment' => true)));
30
  $environment->addFilter(new Twig_SimpleFilter('barbar', 'twig_tests_filter_barbar', array('needs_context' => true, 'is_variadic' => true)));
31
 
25
 
26
  public function getTests()
27
  {
28
+ $environment = new Twig_Environment($this->getMock('Twig_LoaderInterface'));
29
  $environment->addFilter(new Twig_SimpleFilter('bar', 'bar', array('needs_environment' => true)));
30
  $environment->addFilter(new Twig_SimpleFilter('barbar', 'twig_tests_filter_barbar', array('needs_context' => true, 'is_variadic' => true)));
31
 
vendor/twig/twig/test/Twig/Tests/Node/Expression/FunctionTest.php CHANGED
@@ -23,7 +23,7 @@ class Twig_Tests_Node_Expression_FunctionTest extends Twig_Test_NodeTestCase
23
 
24
  public function getTests()
25
  {
26
- $environment = new Twig_Environment();
27
  $environment->addFunction(new Twig_SimpleFunction('foo', 'foo', array()));
28
  $environment->addFunction(new Twig_SimpleFunction('bar', 'bar', array('needs_environment' => true)));
29
  $environment->addFunction(new Twig_SimpleFunction('foofoo', 'foofoo', array('needs_context' => true)));
23
 
24
  public function getTests()
25
  {
26
+ $environment = new Twig_Environment($this->getMock('Twig_LoaderInterface'));
27
  $environment->addFunction(new Twig_SimpleFunction('foo', 'foo', array()));
28
  $environment->addFunction(new Twig_SimpleFunction('bar', 'bar', array('needs_environment' => true)));
29
  $environment->addFunction(new Twig_SimpleFunction('foofoo', 'foofoo', array('needs_context' => true)));
vendor/twig/twig/test/Twig/Tests/Node/Expression/NameTest.php CHANGED
@@ -21,16 +21,14 @@ class Twig_Tests_Node_Expression_NameTest extends Twig_Test_NodeTestCase
21
  public function getTests()
22
  {
23
  $node = new Twig_Node_Expression_Name('foo', 1);
24
- $self = new Twig_Node_Expression_Name('_self', 1);
25
  $context = new Twig_Node_Expression_Name('_context', 1);
26
 
27
- $env = new Twig_Environment(null, array('strict_variables' => true));
28
- $env1 = new Twig_Environment(null, array('strict_variables' => false));
29
 
30
  return array(
31
  array($node, "// line 1\n".(PHP_VERSION_ID >= 50400 ? '(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
  }
21
  public function getTests()
22
  {
23
  $node = new Twig_Node_Expression_Name('foo', 1);
 
24
  $context = new Twig_Node_Expression_Name('_context', 1);
25
 
26
+ $env = new Twig_Environment($this->getMock('Twig_LoaderInterface'), array('strict_variables' => true));
27
+ $env1 = new Twig_Environment($this->getMock('Twig_LoaderInterface'), array('strict_variables' => false));
28
 
29
  return array(
30
  array($node, "// line 1\n".(PHP_VERSION_ID >= 50400 ? '(isset($context["foo"]) ? $context["foo"] : $this->getContext($context, "foo"))' : '$this->getContext($context, "foo")'), $env),
31
  array($node, $this->getVariableGetter('foo', 1), $env1),
 
32
  array($context, "// line 1\n\$context"),
33
  );
34
  }
vendor/twig/twig/test/Twig/Tests/Node/Expression/PHP53/FilterInclude.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- $env = new Twig_Environment();
4
  $env->addFilter(new Twig_SimpleFilter('anonymous', function () {}));
5
 
6
  return $env;
1
  <?php
2
 
3
+ $env = new Twig_Environment(new Twig_Loader_Array(array()));
4
  $env->addFilter(new Twig_SimpleFilter('anonymous', function () {}));
5
 
6
  return $env;
vendor/twig/twig/test/Twig/Tests/Node/Expression/PHP53/FunctionInclude.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- $env = new Twig_Environment();
4
  $env->addFunction(new Twig_SimpleFunction('anonymous', function () {}));
5
 
6
  return $env;
1
  <?php
2
 
3
+ $env = new Twig_Environment(new Twig_Loader_Array(array()));
4
  $env->addFunction(new Twig_SimpleFunction('anonymous', function () {}));
5
 
6
  return $env;
vendor/twig/twig/test/Twig/Tests/Node/Expression/PHP53/TestInclude.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- $env = new Twig_Environment();
4
  $env->addTest(new Twig_SimpleTest('anonymous', function () {}));
5
 
6
  return $env;
1
  <?php
2
 
3
+ $env = new Twig_Environment(new Twig_Loader_Array(array()));
4
  $env->addTest(new Twig_SimpleTest('anonymous', function () {}));
5
 
6
  return $env;
vendor/twig/twig/test/Twig/Tests/Node/Expression/TestTest.php CHANGED
@@ -25,7 +25,7 @@ class Twig_Tests_Node_Expression_TestTest extends Twig_Test_NodeTestCase
25
 
26
  public function getTests()
27
  {
28
- $environment = new Twig_Environment();
29
  $environment->addTest(new Twig_SimpleTest('barbar', 'twig_tests_test_barbar', array('is_variadic' => true, 'need_context' => true)));
30
 
31
  $tests = array();
25
 
26
  public function getTests()
27
  {
28
+ $environment = new Twig_Environment($this->getMock('Twig_LoaderInterface'));
29
  $environment->addTest(new Twig_SimpleTest('barbar', 'twig_tests_test_barbar', array('is_variadic' => true, 'need_context' => true)));
30
 
31
  $tests = array();
vendor/twig/twig/test/Twig/Tests/ParserTest.php CHANGED
@@ -31,7 +31,7 @@ class Twig_Tests_ParserTest extends PHPUnit_Framework_TestCase
31
  new Twig_Token(Twig_Token::BLOCK_END_TYPE, '', 1),
32
  new Twig_Token(Twig_Token::EOF_TYPE, '', 1),
33
  ));
34
- $parser = new Twig_Parser(new Twig_Environment());
35
  $parser->parse($stream);
36
  }
37
 
@@ -94,7 +94,7 @@ class Twig_Tests_ParserTest extends PHPUnit_Framework_TestCase
94
 
95
  public function testParseIsReentrant()
96
  {
97
- $twig = new Twig_Environment(null, array(
98
  'autoescape' => false,
99
  'optimizations' => 0,
100
  ));
@@ -120,7 +120,7 @@ class Twig_Tests_ParserTest extends PHPUnit_Framework_TestCase
120
  // see https://github.com/symfony/symfony/issues/4218
121
  public function testGetVarName()
122
  {
123
- $twig = new Twig_Environment(null, array(
124
  'autoescape' => false,
125
  'optimizations' => 0,
126
  ));
@@ -137,7 +137,7 @@ EOF
137
 
138
  protected function getParser()
139
  {
140
- $parser = new TestParser(new Twig_Environment());
141
  $parser->setParent(new Twig_Node());
142
  $parser->stream = $this->getMockBuilder('Twig_TokenStream')->disableOriginalConstructor()->getMock();
143
 
31
  new Twig_Token(Twig_Token::BLOCK_END_TYPE, '', 1),
32
  new Twig_Token(Twig_Token::EOF_TYPE, '', 1),
33
  ));
34
+ $parser = new Twig_Parser(new Twig_Environment($this->getMock('Twig_LoaderInterface')));
35
  $parser->parse($stream);
36
  }
37
 
94
 
95
  public function testParseIsReentrant()
96
  {
97
+ $twig = new Twig_Environment($this->getMock('Twig_LoaderInterface'), array(
98
  'autoescape' => false,
99
  'optimizations' => 0,
100
  ));
120
  // see https://github.com/symfony/symfony/issues/4218
121
  public function testGetVarName()
122
  {
123
+ $twig = new Twig_Environment($this->getMock('Twig_LoaderInterface'), array(
124
  'autoescape' => false,
125
  'optimizations' => 0,
126
  ));
137
 
138
  protected function getParser()
139
  {
140
+ $parser = new TestParser(new Twig_Environment($this->getMock('Twig_LoaderInterface')));
141
  $parser->setParent(new Twig_Node());
142
  $parser->stream = $this->getMockBuilder('Twig_TokenStream')->disableOriginalConstructor()->getMock();
143
 
vendor/twig/twig/test/Twig/Tests/TemplateTest.php CHANGED
@@ -89,7 +89,7 @@ class Twig_Tests_TemplateTest extends PHPUnit_Framework_TestCase
89
  */
90
  public function testGetAttributeWithSandbox($object, $item, $allowed, $useExt)
91
  {
92
- $twig = new Twig_Environment();
93
  $policy = new Twig_Sandbox_SecurityPolicy(array(), array(), array(/*method*/), array(/*prop*/), array());
94
  $twig->addExtension(new Twig_Extension_Sandbox($policy, !$allowed));
95
  $template = new Twig_TemplateTest($twig, $useExt);
@@ -133,8 +133,8 @@ class Twig_Tests_TemplateTest extends PHPUnit_Framework_TestCase
133
  */
134
  public function testGetAttributeWithTemplateAsObject($useExt)
135
  {
136
- $template = new Twig_TemplateTest(new Twig_Environment(), $useExt);
137
- $template1 = new Twig_TemplateTest(new Twig_Environment(), false);
138
 
139
  $this->assertInstanceof('Twig_Markup', $template->getAttribute($template1, 'string'));
140
  $this->assertEquals('some_string', $template->getAttribute($template1, 'string'));
@@ -173,7 +173,7 @@ class Twig_Tests_TemplateTest extends PHPUnit_Framework_TestCase
173
  public function testGetAttributeOnArrayWithConfusableKey($useExt = false)
174
  {
175
  $template = new Twig_TemplateTest(
176
- new Twig_Environment(),
177
  $useExt
178
  );
179
 
@@ -212,7 +212,7 @@ class Twig_Tests_TemplateTest extends PHPUnit_Framework_TestCase
212
  */
213
  public function testGetAttribute($defined, $value, $object, $item, $arguments, $type, $useExt = false)
214
  {
215
- $template = new Twig_TemplateTest(new Twig_Environment(), $useExt);
216
 
217
  $this->assertEquals($value, $template->getAttribute($object, $item, $arguments, $type));
218
  }
@@ -222,7 +222,7 @@ class Twig_Tests_TemplateTest extends PHPUnit_Framework_TestCase
222
  */
223
  public function testGetAttributeStrict($defined, $value, $object, $item, $arguments, $type, $useExt = false, $exceptionMessage = null)
224
  {
225
- $template = new Twig_TemplateTest(new Twig_Environment(null, array('strict_variables' => true)), $useExt);
226
 
227
  if ($defined) {
228
  $this->assertEquals($value, $template->getAttribute($object, $item, $arguments, $type));
@@ -244,7 +244,7 @@ class Twig_Tests_TemplateTest extends PHPUnit_Framework_TestCase
244
  */
245
  public function testGetAttributeDefined($defined, $value, $object, $item, $arguments, $type, $useExt = false)
246
  {
247
- $template = new Twig_TemplateTest(new Twig_Environment(), $useExt);
248
 
249
  $this->assertEquals($defined, $template->getAttribute($object, $item, $arguments, $type, true));
250
  }
@@ -254,7 +254,7 @@ class Twig_Tests_TemplateTest extends PHPUnit_Framework_TestCase
254
  */
255
  public function testGetAttributeDefinedStrict($defined, $value, $object, $item, $arguments, $type, $useExt = false)
256
  {
257
- $template = new Twig_TemplateTest(new Twig_Environment(null, array('strict_variables' => true)), $useExt);
258
 
259
  $this->assertEquals($defined, $template->getAttribute($object, $item, $arguments, $type, true));
260
  }
@@ -264,7 +264,7 @@ class Twig_Tests_TemplateTest extends PHPUnit_Framework_TestCase
264
  */
265
  public function testGetAttributeCallExceptions($useExt = false)
266
  {
267
- $template = new Twig_TemplateTest(new Twig_Environment(), $useExt);
268
 
269
  $object = new Twig_TemplateMagicMethodExceptionObject();
270
 
89
  */
90
  public function testGetAttributeWithSandbox($object, $item, $allowed, $useExt)
91
  {
92
+ $twig = new Twig_Environment($this->getMock('Twig_LoaderInterface'));
93
  $policy = new Twig_Sandbox_SecurityPolicy(array(), array(), array(/*method*/), array(/*prop*/), array());
94
  $twig->addExtension(new Twig_Extension_Sandbox($policy, !$allowed));
95
  $template = new Twig_TemplateTest($twig, $useExt);
133
  */
134
  public function testGetAttributeWithTemplateAsObject($useExt)
135
  {
136
+ $template = new Twig_TemplateTest(new Twig_Environment($this->getMock('Twig_LoaderInterface')), $useExt);
137
+ $template1 = new Twig_TemplateTest(new Twig_Environment($this->getMock('Twig_LoaderInterface')), false);
138
 
139
  $this->assertInstanceof('Twig_Markup', $template->getAttribute($template1, 'string'));
140
  $this->assertEquals('some_string', $template->getAttribute($template1, 'string'));
173
  public function testGetAttributeOnArrayWithConfusableKey($useExt = false)
174
  {
175
  $template = new Twig_TemplateTest(
176
+ new Twig_Environment($this->getMock('Twig_LoaderInterface')),
177
  $useExt
178
  );
179
 
212
  */
213
  public function testGetAttribute($defined, $value, $object, $item, $arguments, $type, $useExt = false)
214
  {
215
+ $template = new Twig_TemplateTest(new Twig_Environment($this->getMock('Twig_LoaderInterface')), $useExt);
216
 
217
  $this->assertEquals($value, $template->getAttribute($object, $item, $arguments, $type));
218
  }
222
  */
223
  public function testGetAttributeStrict($defined, $value, $object, $item, $arguments, $type, $useExt = false, $exceptionMessage = null)
224
  {
225
+ $template = new Twig_TemplateTest(new Twig_Environment($this->getMock('Twig_LoaderInterface'), array('strict_variables' => true)), $useExt);
226
 
227
  if ($defined) {
228
  $this->assertEquals($value, $template->getAttribute($object, $item, $arguments, $type));
244
  */
245
  public function testGetAttributeDefined($defined, $value, $object, $item, $arguments, $type, $useExt = false)
246
  {
247
+ $template = new Twig_TemplateTest(new Twig_Environment($this->getMock('Twig_LoaderInterface')), $useExt);
248
 
249
  $this->assertEquals($defined, $template->getAttribute($object, $item, $arguments, $type, true));
250
  }
254
  */
255
  public function testGetAttributeDefinedStrict($defined, $value, $object, $item, $arguments, $type, $useExt = false)
256
  {
257
+ $template = new Twig_TemplateTest(new Twig_Environment($this->getMock('Twig_LoaderInterface'), array('strict_variables' => true)), $useExt);
258
 
259
  $this->assertEquals($defined, $template->getAttribute($object, $item, $arguments, $type, true));
260
  }
264
  */
265
  public function testGetAttributeCallExceptions($useExt = false)
266
  {
267
+ $template = new Twig_TemplateTest(new Twig_Environment($this->getMock('Twig_LoaderInterface')), $useExt);
268
 
269
  $object = new Twig_TemplateMagicMethodExceptionObject();
270
 
vendor/twig/twig/test/Twig/Tests/escapingTest.php CHANGED
@@ -146,7 +146,7 @@ class Twig_Test_EscapingTest extends PHPUnit_Framework_TestCase
146
 
147
  public function setUp()
148
  {
149
- $this->env = new Twig_Environment();
150
  }
151
 
152
  public function testHtmlEscapingConvertsSpecialChars()
146
 
147
  public function setUp()
148
  {
149
+ $this->env = new Twig_Environment($this->getMock('Twig_LoaderInterface'));
150
  }
151
 
152
  public function testHtmlEscapingConvertsSpecialChars()