diff --git a/core/composer.lock b/core/composer.lock index bcd5b501b9014e0124429e795fbef4c6550cba2a..619720cf61c3a90a440337246d9428539710bcfb 100644 --- a/core/composer.lock +++ b/core/composer.lock @@ -4,7 +4,7 @@ "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "8f0a2765121612251cd2967473bb66e0", + "hash": "304089b3fa329c66764fdc353c5e0e83", "packages": [ { "name": "behat/mink", @@ -2850,20 +2850,20 @@ }, { "name": "twig/twig", - "version": "v1.18.0", + "version": "v1.18.1", "source": { "type": "git", "url": "https://github.com/twigphp/Twig.git", - "reference": "4cf7464348e7f9893a93f7096a90b73722be99cf" + "reference": "9f70492f44398e276d1b81c1b43adfe6751c7b7f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/4cf7464348e7f9893a93f7096a90b73722be99cf", - "reference": "4cf7464348e7f9893a93f7096a90b73722be99cf", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/9f70492f44398e276d1b81c1b43adfe6751c7b7f", + "reference": "9f70492f44398e276d1b81c1b43adfe6751c7b7f", "shasum": "" }, "require": { - "php": ">=5.2.4" + "php": ">=5.2.7" }, "type": "library", "extra": { @@ -2903,7 +2903,7 @@ "keywords": [ "templating" ], - "time": "2015-01-25 17:32:08" + "time": "2015-04-19 08:30:27" }, { "name": "zendframework/zend-escaper", diff --git a/core/vendor/composer/installed.json b/core/vendor/composer/installed.json index 0091deb6551ffeb20508369b42be22f0c53d746b..8031865da7d2e77c7da33050e54840c2e84d61c8 100644 --- a/core/vendor/composer/installed.json +++ b/core/vendor/composer/installed.json @@ -3100,23 +3100,23 @@ }, { "name": "twig/twig", - "version": "v1.18.0", - "version_normalized": "1.18.0.0", + "version": "v1.18.1", + "version_normalized": "1.18.1.0", "source": { "type": "git", "url": "https://github.com/twigphp/Twig.git", - "reference": "4cf7464348e7f9893a93f7096a90b73722be99cf" + "reference": "9f70492f44398e276d1b81c1b43adfe6751c7b7f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/4cf7464348e7f9893a93f7096a90b73722be99cf", - "reference": "4cf7464348e7f9893a93f7096a90b73722be99cf", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/9f70492f44398e276d1b81c1b43adfe6751c7b7f", + "reference": "9f70492f44398e276d1b81c1b43adfe6751c7b7f", "shasum": "" }, "require": { - "php": ">=5.2.4" + "php": ">=5.2.7" }, - "time": "2015-01-25 17:32:08", + "time": "2015-04-19 08:30:27", "type": "library", "extra": { "branch-alias": { diff --git a/core/vendor/twig/twig/.travis.yml b/core/vendor/twig/twig/.travis.yml index 1fbff7599395561973e6a6fa3cf5dc2b1c12b615..a6274ff6bd1c4a09fc7fd68c17e9151fee8edc8d 100644 --- a/core/vendor/twig/twig/.travis.yml +++ b/core/vendor/twig/twig/.travis.yml @@ -7,6 +7,12 @@ php: - 5.5 - 5.6 - hhvm + - nightly + - hhvm-nightly + +allow_failures: + - php: nightly + - php: hhvm-nightly env: - TWIG_EXT=no @@ -20,3 +26,7 @@ matrix: exclude: - php: hhvm env: TWIG_EXT=yes + - php: hhvm-nightly + env: TWIG_EXT=yes + - php: nightly + env: TWIG_EXT=yes diff --git a/core/vendor/twig/twig/CHANGELOG b/core/vendor/twig/twig/CHANGELOG index fdc9e2c62b763b60c3be8c54d6685d88b980190a..edd6757c1820549a51fe6f43d9419c28cae194e0 100644 --- a/core/vendor/twig/twig/CHANGELOG +++ b/core/vendor/twig/twig/CHANGELOG @@ -1,4 +1,11 @@ -* 1.18.0 (2015-XX-XX) +* 1.18.1 (2015-04-19) + + * fixed memory leaks in the C extension + * deprecated Twig_Loader_String + * fixed the slice filter when used with a SimpleXMLElement object + * fixed filesystem loader when trying to load non-files (like directories) + +* 1.18.0 (2015-01-25) * fixed some error messages where the line was wrong (unknown variables or argument names) * added a new way to customize the main Module node (via empty nodes) diff --git a/core/vendor/twig/twig/composer.json b/core/vendor/twig/twig/composer.json index 6f7e50ce120be3586d3da3419937b974ddfe2626..20d8ca7d3e760b2506915b8a94a0542cce90511f 100644 --- a/core/vendor/twig/twig/composer.json +++ b/core/vendor/twig/twig/composer.json @@ -27,7 +27,7 @@ "forum": "https://groups.google.com/forum/#!forum/twig-users" }, "require": { - "php": ">=5.2.4" + "php": ">=5.2.7" }, "autoload": { "psr-0" : { diff --git a/core/vendor/twig/twig/doc/api.rst b/core/vendor/twig/twig/doc/api.rst index 3ff5d1a2acde222a1943e3ddf78296d00276fda1..cdeaffdb0493003398bff2b84177e0f976142292 100644 --- a/core/vendor/twig/twig/doc/api.rst +++ b/core/vendor/twig/twig/doc/api.rst @@ -106,7 +106,9 @@ The following options are available: to avoid collision with built-in escaping strategies). As of Twig 1.17, the ``filename`` escaping strategy determines the escaping - strategy to use for a template based on the template filename extension. + strategy to use for a template based on the template filename extension (this + strategy does not incur any overhead at runtime as auto-escaping is done at + compilation time.) * ``optimizations``: A flag that indicates which optimizations to apply (default to ``-1`` -- all optimizations are enabled; set it to ``0`` to diff --git a/core/vendor/twig/twig/doc/deprecated.rst b/core/vendor/twig/twig/doc/deprecated.rst index 30aaac1bac746bc50e3c6a4c315a5d0a1178eb30..bde62ba5f7b1bc1aa708593c60275d7296992624 100644 --- a/core/vendor/twig/twig/doc/deprecated.rst +++ b/core/vendor/twig/twig/doc/deprecated.rst @@ -101,6 +101,12 @@ Interfaces those constants Twig_Template::ANY_CALL, Twig_Template::ARRAY_CALL, Twig_Template::METHOD_CALL) +Loaders +------- + +* As of Twig 1.x, ``Twig_Loader_String`` is deprecated and will be removed in + 2.0. + Globals ------- diff --git a/core/vendor/twig/twig/doc/installation.rst b/core/vendor/twig/twig/doc/installation.rst index eeaef9a725b78891da634495ba3f17380326936c..afdcf16593b23ea37e050dd4b34a8a3be7679e47 100644 --- a/core/vendor/twig/twig/doc/installation.rst +++ b/core/vendor/twig/twig/doc/installation.rst @@ -50,8 +50,11 @@ Installing the C extension The C extension was added in Twig 1.4. .. note:: - The C extension is **optional** but as it brings some nice performance - improvements, you might want to install it in your production environment. + + The C extension is **optional** but it brings some nice performance + improvements. Note that the extension is not a replacement for the PHP + code; it only implements a small part of the PHP code to improve the + performance at runtime; you must still install the regular PHP code. Twig comes with a C extension that enhances the performance of the Twig runtime engine; install it like any other PHP extensions: diff --git a/core/vendor/twig/twig/doc/recipes.rst b/core/vendor/twig/twig/doc/recipes.rst index 64090d913f2a414807e037249b91f570d1ad8b53..86cede630263ccaf771058ea50c8d8d5729a2f29 100644 --- a/core/vendor/twig/twig/doc/recipes.rst +++ b/core/vendor/twig/twig/doc/recipes.rst @@ -316,56 +316,6 @@ This can be easily achieved with the following code:: return $node; } -Using the Template name to set the default Escaping Strategy ------------------------------------------------------------- - -.. versionadded:: 1.8 - This recipe requires Twig 1.8 or later. - -The ``autoescape`` option determines the default escaping strategy to use when -no escaping is applied on a variable. When Twig is used to mostly generate -HTML files, you can set it to ``html`` and explicitly change it to ``js`` when -you have some dynamic JavaScript files thanks to the ``autoescape`` tag: - -.. code-block:: jinja - - {% autoescape 'js' %} - ... some JS ... - {% endautoescape %} - -But if you have many HTML and JS files, and if your template names follow some -conventions, you can instead determine the default escaping strategy to use -based on the template name. Let's say that your template names always end -with ``.html`` for HTML files, ``.js`` for JavaScript ones, and ``.css`` for -stylesheets, here is how you can configure Twig:: - - class TwigEscapingGuesser - { - function guess($filename) - { - // get the format - $format = substr($filename, strrpos($filename, '.') + 1); - - switch ($format) { - case 'js': - return 'js'; - case 'css': - return 'css'; - case 'html': - default: - return 'html'; - } - } - } - - $loader = new Twig_Loader_Filesystem('/path/to/templates'); - $twig = new Twig_Environment($loader, array( - 'autoescape' => array(new TwigEscapingGuesser(), 'guess'), - )); - -This dynamic strategy does not incur any overhead at runtime as auto-escaping -is done at compilation time. - Using a Database to store Templates ----------------------------------- diff --git a/core/vendor/twig/twig/ext/twig/php_twig.h b/core/vendor/twig/twig/ext/twig/php_twig.h index 13bb8cd3075de9ed66c718c02d19ef0b0925d358..9bf6d1152e89d93997ffccce07480d63aec9e056 100644 --- a/core/vendor/twig/twig/ext/twig/php_twig.h +++ b/core/vendor/twig/twig/ext/twig/php_twig.h @@ -15,17 +15,21 @@ #ifndef PHP_TWIG_H #define PHP_TWIG_H -#define PHP_TWIG_VERSION "1.18.0" +#define PHP_TWIG_VERSION "1.18.1" #include "php.h" extern zend_module_entry twig_module_entry; #define phpext_twig_ptr &twig_module_entry +#ifndef PHP_WIN32 +zend_module_entry *get_module(void); +#endif #ifdef ZTS #include "TSRM.h" #endif PHP_FUNCTION(twig_template_get_attributes); +PHP_RSHUTDOWN_FUNCTION(twig); #endif diff --git a/core/vendor/twig/twig/ext/twig/twig.c b/core/vendor/twig/twig/ext/twig/twig.c index 5c482bedb7c3071506bbdeb54dc0cf0b243da528..ae5b1470ec85312249319469ac7be29cd8f83c29 100644 --- a/core/vendor/twig/twig/ext/twig/twig.c +++ b/core/vendor/twig/twig/ext/twig/twig.c @@ -54,11 +54,22 @@ ZEND_BEGIN_ARG_INFO_EX(twig_template_get_attribute_args, ZEND_SEND_BY_VAL, ZEND_ ZEND_ARG_INFO(0, isDefinedTest) ZEND_END_ARG_INFO() -zend_function_entry twig_functions[] = { +#ifndef PHP_FE_END +#define PHP_FE_END { NULL, NULL, NULL, 0, 0 } +#endif + +static const zend_function_entry twig_functions[] = { PHP_FE(twig_template_get_attributes, twig_template_get_attribute_args) - {NULL, NULL, NULL} + PHP_FE_END }; +PHP_RSHUTDOWN_FUNCTION(twig) +{ +#if ZEND_DEBUG + CG(unclean_shutdown) = 0; /* get rid of PHPUnit's exit() and report memleaks */ +#endif + return SUCCESS; +} zend_module_entry twig_module_entry = { STANDARD_MODULE_HEADER, @@ -67,7 +78,7 @@ zend_module_entry twig_module_entry = { NULL, NULL, NULL, - NULL, + PHP_RSHUTDOWN(twig), NULL, PHP_TWIG_VERSION, STANDARD_MODULE_PROPERTIES @@ -78,7 +89,7 @@ zend_module_entry twig_module_entry = { ZEND_GET_MODULE(twig) #endif -int TWIG_ARRAY_KEY_EXISTS(zval *array, zval *key) +static int TWIG_ARRAY_KEY_EXISTS(zval *array, zval *key) { if (Z_TYPE_P(array) != IS_ARRAY) { return 0; @@ -100,7 +111,7 @@ int TWIG_ARRAY_KEY_EXISTS(zval *array, zval *key) } } -int TWIG_INSTANCE_OF(zval *object, zend_class_entry *interface TSRMLS_DC) +static int TWIG_INSTANCE_OF(zval *object, zend_class_entry *interface TSRMLS_DC) { if (Z_TYPE_P(object) != IS_OBJECT) { return 0; @@ -108,7 +119,7 @@ int TWIG_INSTANCE_OF(zval *object, zend_class_entry *interface TSRMLS_DC) return instanceof_function(Z_OBJCE_P(object), interface TSRMLS_CC); } -int TWIG_INSTANCE_OF_USERLAND(zval *object, char *interface TSRMLS_DC) +static int TWIG_INSTANCE_OF_USERLAND(zval *object, char *interface TSRMLS_DC) { zend_class_entry **pce; if (Z_TYPE_P(object) != IS_OBJECT) { @@ -120,7 +131,7 @@ int TWIG_INSTANCE_OF_USERLAND(zval *object, char *interface TSRMLS_DC) return instanceof_function(Z_OBJCE_P(object), *pce TSRMLS_CC); } -zval *TWIG_GET_ARRAYOBJECT_ELEMENT(zval *object, zval *offset TSRMLS_DC) +static zval *TWIG_GET_ARRAYOBJECT_ELEMENT(zval *object, zval *offset TSRMLS_DC) { zend_class_entry *ce = Z_OBJCE_P(object); zval *retval; @@ -143,7 +154,7 @@ zval *TWIG_GET_ARRAYOBJECT_ELEMENT(zval *object, zval *offset TSRMLS_DC) return NULL; } -int TWIG_ISSET_ARRAYOBJECT_ELEMENT(zval *object, zval *offset TSRMLS_DC) +static int TWIG_ISSET_ARRAYOBJECT_ELEMENT(zval *object, zval *offset TSRMLS_DC) { zend_class_entry *ce = Z_OBJCE_P(object); zval *retval; @@ -166,7 +177,7 @@ int TWIG_ISSET_ARRAYOBJECT_ELEMENT(zval *object, zval *offset TSRMLS_DC) return 0; } -char *TWIG_STRTOLOWER(const char *str, int str_len) +static char *TWIG_STRTOLOWER(const char *str, int str_len) { char *item_dup; @@ -175,7 +186,7 @@ char *TWIG_STRTOLOWER(const char *str, int str_len) return item_dup; } -zval *TWIG_CALL_USER_FUNC_ARRAY(zval *object, char *function, zval *arguments TSRMLS_DC) +static zval *TWIG_CALL_USER_FUNC_ARRAY(zval *object, char *function, zval *arguments TSRMLS_DC) { zend_fcall_info fci; zval ***args = NULL; @@ -227,7 +238,7 @@ zval *TWIG_CALL_USER_FUNC_ARRAY(zval *object, char *function, zval *arguments TS return retval_ptr; } -int TWIG_CALL_BOOLEAN(zval *object, char *functionName TSRMLS_DC) +static int TWIG_CALL_BOOLEAN(zval *object, char *functionName TSRMLS_DC) { zval *ret; int res; @@ -238,7 +249,7 @@ int TWIG_CALL_BOOLEAN(zval *object, char *functionName TSRMLS_DC) return res; } -zval *TWIG_GET_STATIC_PROPERTY(zval *class, char *prop_name TSRMLS_DC) +static zval *TWIG_GET_STATIC_PROPERTY(zval *class, char *prop_name TSRMLS_DC) { zval **tmp_zval; zend_class_entry *ce; @@ -256,7 +267,7 @@ zval *TWIG_GET_STATIC_PROPERTY(zval *class, char *prop_name TSRMLS_DC) return *tmp_zval; } -zval *TWIG_GET_ARRAY_ELEMENT_ZVAL(zval *class, zval *prop_name TSRMLS_DC) +static zval *TWIG_GET_ARRAY_ELEMENT_ZVAL(zval *class, zval *prop_name TSRMLS_DC) { zval **tmp_zval; @@ -288,7 +299,7 @@ zval *TWIG_GET_ARRAY_ELEMENT_ZVAL(zval *class, zval *prop_name TSRMLS_DC) return NULL; } -zval *TWIG_GET_ARRAY_ELEMENT(zval *class, char *prop_name, int prop_name_length TSRMLS_DC) +static zval *TWIG_GET_ARRAY_ELEMENT(zval *class, char *prop_name, int prop_name_length TSRMLS_DC) { zval **tmp_zval; @@ -314,7 +325,7 @@ zval *TWIG_GET_ARRAY_ELEMENT(zval *class, char *prop_name, int prop_name_length return NULL; } -zval *TWIG_PROPERTY(zval *object, zval *propname TSRMLS_DC) +static zval *TWIG_PROPERTY(zval *object, zval *propname TSRMLS_DC) { zval *tmp = NULL; @@ -331,7 +342,7 @@ zval *TWIG_PROPERTY(zval *object, zval *propname TSRMLS_DC) return tmp; } -int TWIG_HAS_PROPERTY(zval *object, zval *propname TSRMLS_DC) +static int TWIG_HAS_PROPERTY(zval *object, zval *propname TSRMLS_DC) { if (Z_OBJ_HT_P(object)->has_property) { #if PHP_VERSION_ID >= 50400 @@ -343,7 +354,7 @@ int TWIG_HAS_PROPERTY(zval *object, zval *propname TSRMLS_DC) return 0; } -int TWIG_HAS_DYNAMIC_PROPERTY(zval *object, char *prop, int prop_len TSRMLS_DC) +static int TWIG_HAS_DYNAMIC_PROPERTY(zval *object, char *prop, int prop_len TSRMLS_DC) { if (Z_OBJ_HT_P(object)->get_properties) { return zend_hash_quick_exists( @@ -356,7 +367,7 @@ int TWIG_HAS_DYNAMIC_PROPERTY(zval *object, char *prop, int prop_len TSRMLS_DC) return 0; } -zval *TWIG_PROPERTY_CHAR(zval *object, char *propname TSRMLS_DC) +static zval *TWIG_PROPERTY_CHAR(zval *object, char *propname TSRMLS_DC) { zval *tmp_name_zval, *tmp; @@ -367,12 +378,7 @@ zval *TWIG_PROPERTY_CHAR(zval *object, char *propname TSRMLS_DC) return tmp; } -int TWIG_CALL_B_0(zval *object, char *method) -{ - return 0; -} - -zval *TWIG_CALL_S(zval *object, char *method, char *arg0 TSRMLS_DC) +static zval *TWIG_CALL_S(zval *object, char *method, char *arg0 TSRMLS_DC) { zend_fcall_info fci; zval **args[1]; @@ -410,7 +416,7 @@ zval *TWIG_CALL_S(zval *object, char *method, char *arg0 TSRMLS_DC) return retval_ptr; } -int TWIG_CALL_SB(zval *object, char *method, char *arg0 TSRMLS_DC) +static int TWIG_CALL_SB(zval *object, char *method, char *arg0 TSRMLS_DC) { zval *retval_ptr; int success; @@ -425,51 +431,7 @@ int TWIG_CALL_SB(zval *object, char *method, char *arg0 TSRMLS_DC) return success; } -int TWIG_CALL_Z(zval *object, char *method, zval *arg1 TSRMLS_DC) -{ - zend_fcall_info fci; - zval **args[1]; - zval *zfunction; - zval *retval_ptr; - int success; - - args[0] = &arg1; - - MAKE_STD_ZVAL(zfunction); - ZVAL_STRING(zfunction, method, 1); - fci.size = sizeof(fci); - fci.function_table = EG(function_table); - fci.function_name = zfunction; - fci.symbol_table = NULL; -#if PHP_VERSION_ID >= 50300 - fci.object_ptr = object; -#else - fci.object_pp = &object; -#endif - fci.retval_ptr_ptr = &retval_ptr; - fci.param_count = 1; - fci.params = args; - fci.no_separation = 0; - - if (zend_call_function(&fci, NULL TSRMLS_CC) == FAILURE) { - FREE_DTOR(zfunction); - if (retval_ptr) { - zval_ptr_dtor(&retval_ptr); - } - return 0; - } - - FREE_DTOR(zfunction); - - success = (retval_ptr && (Z_TYPE_P(retval_ptr) == IS_BOOL) && Z_LVAL_P(retval_ptr)); - if (retval_ptr) { - zval_ptr_dtor(&retval_ptr); - } - - return success; -} - -int TWIG_CALL_ZZ(zval *object, char *method, zval *arg1, zval *arg2 TSRMLS_DC) +static int TWIG_CALL_ZZ(zval *object, char *method, zval *arg1, zval *arg2 TSRMLS_DC) { zend_fcall_info fci; zval **args[2]; @@ -516,7 +478,7 @@ int TWIG_CALL_ZZ(zval *object, char *method, zval *arg1, zval *arg2 TSRMLS_DC) # define Z_UNSET_ISREF_P(pz) pz->is_ref = 0 #endif -void TWIG_NEW(zval *object, char *class, zval *arg0, zval *arg1 TSRMLS_DC) +static void TWIG_NEW(zval *object, char *class, zval *arg0, zval *arg1 TSRMLS_DC) { zend_class_entry **pce; @@ -561,7 +523,7 @@ static int twig_add_array_key_to_string(void *pDest APPLY_TSRMLS_DC, int num_arg return 0; } -char *TWIG_IMPLODE_ARRAY_KEYS(char *joiner, zval *array TSRMLS_DC) +static char *TWIG_IMPLODE_ARRAY_KEYS(char *joiner, zval *array TSRMLS_DC) { smart_str collector = { 0, 0, 0 }; @@ -572,24 +534,6 @@ char *TWIG_IMPLODE_ARRAY_KEYS(char *joiner, zval *array TSRMLS_DC) return collector.c; } -static void TWIG_THROW_EXCEPTION(char *exception_name TSRMLS_DC, char *message, ...) -{ - char *buffer; - va_list args; - zend_class_entry **pce; - - if (zend_lookup_class(exception_name, strlen(exception_name), &pce TSRMLS_CC) == FAILURE) { - return; - } - - va_start(args, message); - vspprintf(&buffer, 0, message, args); - va_end(args); - - zend_throw_exception_ex(*pce, 0 TSRMLS_CC, buffer); - efree(buffer); -} - static void TWIG_RUNTIME_ERROR(zval *template TSRMLS_DC, char *message, ...) { char *buffer; @@ -794,6 +738,7 @@ PHP_FUNCTION(twig_template_get_attributes) ) { if (isDefinedTest) { + efree(item); RETURN_TRUE; } @@ -806,6 +751,7 @@ PHP_FUNCTION(twig_template_get_attributes) if (free_ret) { zval_ptr_dtor(&ret); } + efree(item); return; } /* @@ -819,9 +765,11 @@ PHP_FUNCTION(twig_template_get_attributes) */ if (strcmp("array", type) == 0 || Z_TYPE_P(object) != IS_OBJECT) { if (isDefinedTest) { + efree(item); RETURN_FALSE; } if (ignoreStrictCheck || !TWIG_CALL_BOOLEAN(TWIG_PROPERTY_CHAR(template, "env" TSRMLS_CC), "isStrictVariables" TSRMLS_CC)) { + efree(item); return; } /* @@ -852,7 +800,9 @@ PHP_FUNCTION(twig_template_get_attributes) if (0 == zend_hash_num_elements(Z_ARRVAL_P(object))) { TWIG_RUNTIME_ERROR(template TSRMLS_CC, "Key \"%s\" does not exist as the array is empty", item); } else { - TWIG_RUNTIME_ERROR(template TSRMLS_CC, "Key \"%s\" for array with keys \"%s\" does not exist", item, TWIG_IMPLODE_ARRAY_KEYS(", ", object TSRMLS_CC)); + char *array_keys = TWIG_IMPLODE_ARRAY_KEYS(", ", object TSRMLS_CC); + TWIG_RUNTIME_ERROR(template TSRMLS_CC, "Key \"%s\" for array with keys \"%s\" does not exist", item, array_keys); + efree(array_keys); } } else { char *type_name = zend_zval_type_name(object); @@ -865,6 +815,7 @@ PHP_FUNCTION(twig_template_get_attributes) item, type_name, Z_STRVAL_P(object)); zval_ptr_dtor(&object); } + efree(item); return; } } @@ -878,6 +829,7 @@ PHP_FUNCTION(twig_template_get_attributes) if (Z_TYPE_P(object) != IS_OBJECT) { if (isDefinedTest) { + efree(item); RETURN_FALSE; } /* @@ -888,6 +840,7 @@ PHP_FUNCTION(twig_template_get_attributes) } */ if (ignoreStrictCheck || !TWIG_CALL_BOOLEAN(TWIG_PROPERTY_CHAR(template, "env" TSRMLS_CC), "isStrictVariables" TSRMLS_CC)) { + efree(item); return; } @@ -898,7 +851,7 @@ PHP_FUNCTION(twig_template_get_attributes) TWIG_RUNTIME_ERROR(template TSRMLS_CC, "Impossible to invoke a method (\"%s\") on a %s variable (\"%s\")", item, type_name, Z_STRVAL_P(object)); zval_ptr_dtor(&object); - + efree(item); return; } /* @@ -939,16 +892,19 @@ PHP_FUNCTION(twig_template_get_attributes) if (tmp_item || TWIG_HAS_PROPERTY(object, zitem TSRMLS_CC) || TWIG_HAS_DYNAMIC_PROPERTY(object, item, item_len TSRMLS_CC)) { if (isDefinedTest) { + efree(item); RETURN_TRUE; } if (TWIG_CALL_SB(TWIG_PROPERTY_CHAR(template, "env" TSRMLS_CC), "hasExtension", "sandbox" TSRMLS_CC)) { TWIG_CALL_ZZ(TWIG_CALL_S(TWIG_PROPERTY_CHAR(template, "env" TSRMLS_CC), "getExtension", "sandbox" TSRMLS_CC), "checkPropertyAllowed", object, zitem TSRMLS_CC); } if (EG(exception)) { + efree(item); return; } ret = TWIG_PROPERTY(object, zitem TSRMLS_CC); + efree(item); RETURN_ZVAL(ret, 1, 0); } } @@ -1021,19 +977,22 @@ PHP_FUNCTION(twig_template_get_attributes) efree(lcItem); if (isDefinedTest) { + efree(item); RETURN_FALSE; } if (ignoreStrictCheck || !TWIG_CALL_BOOLEAN(TWIG_PROPERTY_CHAR(template, "env" TSRMLS_CC), "isStrictVariables" TSRMLS_CC)) { + efree(item); return; } TWIG_RUNTIME_ERROR(template TSRMLS_CC, "Method \"%s\" for object \"%s\" does not exist", item, TWIG_GET_CLASS_NAME(object TSRMLS_CC)); + efree(item); return; } if (isDefinedTest) { efree(tmp_method_name_get); efree(tmp_method_name_is); - efree(lcItem); + efree(lcItem);efree(item); RETURN_TRUE; } /* @@ -1046,11 +1005,11 @@ PHP_FUNCTION(twig_template_get_attributes) if (TWIG_CALL_SB(TWIG_PROPERTY_CHAR(template, "env" TSRMLS_CC), "hasExtension", "sandbox" TSRMLS_CC)) { TWIG_CALL_ZZ(TWIG_CALL_S(TWIG_PROPERTY_CHAR(template, "env" TSRMLS_CC), "getExtension", "sandbox" TSRMLS_CC), "checkMethodAllowed", object, zmethod TSRMLS_CC); } + zval_ptr_dtor(&zmethod); if (EG(exception)) { efree(tmp_method_name_get); efree(tmp_method_name_is); - efree(lcItem); - zval_ptr_dtor(&zmethod); + efree(lcItem);efree(item); return; } /* @@ -1068,6 +1027,9 @@ PHP_FUNCTION(twig_template_get_attributes) ret = TWIG_CALL_USER_FUNC_ARRAY(object, method, arguments TSRMLS_CC); if (EG(exception) && TWIG_INSTANCE_OF(EG(exception), spl_ce_BadMethodCallException TSRMLS_CC)) { if (ignoreStrictCheck || !TWIG_CALL_BOOLEAN(TWIG_PROPERTY_CHAR(template, "env" TSRMLS_CC), "isStrictVariables" TSRMLS_CC)) { + efree(tmp_method_name_get); + efree(tmp_method_name_is); + efree(lcItem);efree(item); zend_clear_exception(TSRMLS_C); return; } @@ -1076,7 +1038,6 @@ PHP_FUNCTION(twig_template_get_attributes) efree(tmp_method_name_get); efree(tmp_method_name_is); efree(lcItem); - zval_ptr_dtor(&zmethod); } /* // useful when calling a template method from a template @@ -1087,6 +1048,7 @@ PHP_FUNCTION(twig_template_get_attributes) return $ret; */ + efree(item); // ret can be null, if e.g. the called method throws an exception if (ret) { if (TWIG_INSTANCE_OF_USERLAND(object, "Twig_TemplateInterface" TSRMLS_CC)) { diff --git a/core/vendor/twig/twig/lib/Twig/Autoloader.php b/core/vendor/twig/twig/lib/Twig/Autoloader.php index 36b10951c00b095af3b744a701e3796827d73db2..87f74153874ee1149944f05d27c980dfb0442129 100644 --- a/core/vendor/twig/twig/lib/Twig/Autoloader.php +++ b/core/vendor/twig/twig/lib/Twig/Autoloader.php @@ -23,10 +23,10 @@ class Twig_Autoloader */ public static function register($prepend = false) { - if (version_compare(phpversion(), '5.3.0', '>=')) { - spl_autoload_register(array(__CLASS__, 'autoload'), true, $prepend); - } else { + if (PHP_VERSION_ID < 50300) { spl_autoload_register(array(__CLASS__, 'autoload')); + } else { + spl_autoload_register(array(__CLASS__, 'autoload'), true, $prepend); } } diff --git a/core/vendor/twig/twig/lib/Twig/Environment.php b/core/vendor/twig/twig/lib/Twig/Environment.php index 0cb9bb7ceabc4e2aefd3eecd07169af5e7330bc2..9acc31a0e78013a2959d84322c78b9b4b926c887 100644 --- a/core/vendor/twig/twig/lib/Twig/Environment.php +++ b/core/vendor/twig/twig/lib/Twig/Environment.php @@ -16,7 +16,7 @@ */ class Twig_Environment { - const VERSION = '1.18.0'; + const VERSION = '1.18.1'; protected $charset; protected $loader; diff --git a/core/vendor/twig/twig/lib/Twig/Error.php b/core/vendor/twig/twig/lib/Twig/Error.php index afb8ddde08d2721ee30b7f2022a47b1195c56297..90650c5fe0d2bd856935e25e741684895f17cd6d 100644 --- a/core/vendor/twig/twig/lib/Twig/Error.php +++ b/core/vendor/twig/twig/lib/Twig/Error.php @@ -57,7 +57,7 @@ class Twig_Error extends Exception */ public function __construct($message, $lineno = -1, $filename = null, Exception $previous = null) { - if (version_compare(PHP_VERSION, '5.3.0', '<')) { + if (PHP_VERSION_ID < 50300) { $this->previous = $previous; parent::__construct(''); } else { @@ -188,7 +188,7 @@ protected function guessTemplateInfo() $template = null; $templateClass = null; - if (version_compare(phpversion(), '5.3.6', '>=')) { + if (PHP_VERSION_ID >= 50306) { $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS | DEBUG_BACKTRACE_PROVIDE_OBJECT); } else { $backtrace = debug_backtrace(); diff --git a/core/vendor/twig/twig/lib/Twig/Extension/Core.php b/core/vendor/twig/twig/lib/Twig/Extension/Core.php index 4dbee873cfba073f06d1160e1a233d56c71d7d69..346006d32830d84655988beee73d60f8f010c975 100644 --- a/core/vendor/twig/twig/lib/Twig/Extension/Core.php +++ b/core/vendor/twig/twig/lib/Twig/Extension/Core.php @@ -617,7 +617,7 @@ function twig_urlencode_filter($url) return rawurlencode($url); } -if (version_compare(PHP_VERSION, '5.3.0', '<')) { +if (PHP_VERSION_ID < 50300) { /** * JSON encodes a variable. * @@ -707,7 +707,7 @@ function twig_slice(Twig_Environment $env, $item, $start, $length = null, $prese $item = $item->getIterator(); } - if ($start >= 0 && $length >= 0) { + if ($start >= 0 && $length >= 0 && $item instanceof Iterator) { try { return iterator_to_array(new LimitIterator($item, $start, $length === null ? -1 : $length), $preserveKeys); } catch (OutOfBoundsException $exception) { @@ -1073,9 +1073,7 @@ function twig_escape_filter(Twig_Environment $env, $string, $strategy = 'html', return $string; case 'url': - // hackish test to avoid version_compare that is much slower, this works unless PHP releases a 5.10.* - // at that point however PHP 5.2.* support can be removed - if (PHP_VERSION < '5.3.0') { + if (PHP_VERSION_ID < 50300) { return str_replace('%7E', '~', rawurlencode($string)); } diff --git a/core/vendor/twig/twig/lib/Twig/Loader/Filesystem.php b/core/vendor/twig/twig/lib/Twig/Loader/Filesystem.php index 329a23ff1a19a681b17abec06deeee38639bf591..818a461c58f15299afeb95c6cb0a1d6021ad0eb2 100644 --- a/core/vendor/twig/twig/lib/Twig/Loader/Filesystem.php +++ b/core/vendor/twig/twig/lib/Twig/Loader/Filesystem.php @@ -183,10 +183,11 @@ protected function findTemplate($name) } foreach ($this->paths[$namespace] as $path) { - if (false !== $realpath = realpath($path.'/'.$shortname)) { - return $this->cache[$name] = $realpath; - } if (is_file($path.'/'.$shortname)) { + if (false !== $realpath = realpath($path.'/'.$shortname)) { + return $this->cache[$name] = $realpath; + } + return $this->cache[$name] = $path.'/'.$shortname; } } diff --git a/core/vendor/twig/twig/lib/Twig/Loader/String.php b/core/vendor/twig/twig/lib/Twig/Loader/String.php index 2099c09c9ae0e9d1b477c09dde064835b8974c86..63d6890a30ef1cc9020ef9f7a1edcdd47ea3e4a4 100644 --- a/core/vendor/twig/twig/lib/Twig/Loader/String.php +++ b/core/vendor/twig/twig/lib/Twig/Loader/String.php @@ -19,6 +19,8 @@ * source code of the template). If you don't want to see your cache grows out of * control, you need to take care of clearing the old cache file by yourself. * + * @deprecated since 1.18.1 (to be removed in 2.0) + * * @author Fabien Potencier <fabien@symfony.com> */ class Twig_Loader_String implements Twig_LoaderInterface, Twig_ExistsLoaderInterface diff --git a/core/vendor/twig/twig/lib/Twig/Node/Embed.php b/core/vendor/twig/twig/lib/Twig/Node/Embed.php index 4c9456dc0594d73668e59075c3332231cafa36a1..c54d2cce57f61365a076543bae9898175e95d286 100644 --- a/core/vendor/twig/twig/lib/Twig/Node/Embed.php +++ b/core/vendor/twig/twig/lib/Twig/Node/Embed.php @@ -28,9 +28,13 @@ public function __construct($filename, $index, Twig_Node_Expression $variables = protected function addGetTemplate(Twig_Compiler $compiler) { $compiler - ->write("\$this->env->loadTemplate(") + ->write("\$this->loadTemplate(") ->string($this->getAttribute('filename')) ->raw(', ') + ->repr($compiler->getFilename()) + ->raw(', ') + ->repr($this->getLine()) + ->raw(', ') ->string($this->getAttribute('index')) ->raw(")") ; diff --git a/core/vendor/twig/twig/lib/Twig/Node/Expression/Call.php b/core/vendor/twig/twig/lib/Twig/Node/Expression/Call.php index d09e06f8f9606215eba44fe45530b012cd4330b0..998160b40c3dffd875062c03ab614ba3a4a4cc30 100644 --- a/core/vendor/twig/twig/lib/Twig/Node/Expression/Call.php +++ b/core/vendor/twig/twig/lib/Twig/Node/Expression/Call.php @@ -120,6 +120,8 @@ protected function getArguments($callable, $arguments) } elseif (is_object($callable) && !$callable instanceof Closure) { $r = new ReflectionObject($callable); $r = $r->getMethod('__invoke'); + } elseif (is_string($callable) && false !== strpos($callable, '::')) { + $r = new ReflectionMethod($callable); } else { $r = new ReflectionFunction($callable); } diff --git a/core/vendor/twig/twig/lib/Twig/Node/Expression/Name.php b/core/vendor/twig/twig/lib/Twig/Node/Expression/Name.php index 4cbdea9753804add34c3672575b37b7f2ec25b2c..0bfcdbc459410c2523c03145a5fd874a2df7067a 100644 --- a/core/vendor/twig/twig/lib/Twig/Node/Expression/Name.php +++ b/core/vendor/twig/twig/lib/Twig/Node/Expression/Name.php @@ -46,7 +46,7 @@ public function compile(Twig_Compiler $compiler) // remove the non-PHP 5.4 version when PHP 5.3 support is dropped // as the non-optimized version is just a workaround for slow ternary operator // when the context has a lot of variables - if (version_compare(phpversion(), '5.4.0RC1', '>=')) { + if (PHP_VERSION_ID >= 50400) { // PHP 5.4 ternary operator performance was optimized $compiler ->raw('(isset($context[') diff --git a/core/vendor/twig/twig/lib/Twig/Node/Import.php b/core/vendor/twig/twig/lib/Twig/Node/Import.php index 230665541a7d79f5896fe1b6aa364101cb803859..5e4aa115ef90e9fb234554337e2d06d42ba99f4e 100644 --- a/core/vendor/twig/twig/lib/Twig/Node/Import.php +++ b/core/vendor/twig/twig/lib/Twig/Node/Import.php @@ -39,8 +39,12 @@ public function compile(Twig_Compiler $compiler) $compiler->raw("\$this"); } else { $compiler - ->raw('$this->env->loadTemplate(') + ->raw('$this->loadTemplate(') ->subcompile($this->getNode('expr')) + ->raw(', ') + ->repr($compiler->getFilename()) + ->raw(', ') + ->repr($this->getLine()) ->raw(")") ; } diff --git a/core/vendor/twig/twig/lib/Twig/Node/Include.php b/core/vendor/twig/twig/lib/Twig/Node/Include.php index 06548884a13d07ee3fbe4a5088db4e695f4f9f99..46b06852dd46b580a62652c8b34a736ae289b923 100644 --- a/core/vendor/twig/twig/lib/Twig/Node/Include.php +++ b/core/vendor/twig/twig/lib/Twig/Node/Include.php @@ -60,12 +60,15 @@ public function compile(Twig_Compiler $compiler) protected function addGetTemplate(Twig_Compiler $compiler) { - $method = $this->getNode('expr') instanceof Twig_Node_Expression_Constant ? 'loadTemplate' : 'resolveTemplate'; $compiler - ->write(sprintf('$this->env->%s(', $method)) - ->subcompile($this->getNode('expr')) - ->raw(')') - ; + ->write("\$this->loadTemplate(") + ->subcompile($this->getNode('expr')) + ->raw(', ') + ->repr($compiler->getFilename()) + ->raw(', ') + ->repr($this->getLine()) + ->raw(")") + ; } protected function addTemplateArguments(Twig_Compiler $compiler) diff --git a/core/vendor/twig/twig/lib/Twig/Node/Module.php b/core/vendor/twig/twig/lib/Twig/Node/Module.php index c156e295975aa3e6ebb6471c0d314b44abc4cf6d..78022632bbc461d25b7e52689a7ae893db3d55f6 100644 --- a/core/vendor/twig/twig/lib/Twig/Node/Module.php +++ b/core/vendor/twig/twig/lib/Twig/Node/Module.php @@ -114,8 +114,12 @@ protected function compileGetParent(Twig_Compiler $compiler) $compiler->subcompile($parent); } else { $compiler - ->raw("\$this->env->resolveTemplate(") + ->raw("\$this->loadTemplate(") ->subcompile($parent) + ->raw(', ') + ->repr($compiler->getFilename()) + ->raw(', ') + ->repr($this->getNode('parent')->getLine()) ->raw(")") ; } @@ -155,19 +159,13 @@ protected function compileConstructor(Twig_Compiler $compiler) } elseif ($parent instanceof Twig_Node_Expression_Constant) { $compiler ->addDebugInfo($parent) - ->write("try {\n") - ->indent() - ->write("\$this->parent = \$this->env->loadTemplate(") + ->write("\$this->parent = \$this->loadTemplate(") ->subcompile($parent) + ->raw(', ') + ->repr($compiler->getFilename()) + ->raw(', ') + ->repr($this->getNode('parent')->getLine()) ->raw(");\n") - ->outdent() - ->write("} catch (Twig_Error_Loader \$e) {\n") - ->indent() - ->write("\$e->setTemplateFile(\$this->getTemplateName());\n") - ->write(sprintf("\$e->setTemplateLine(%d);\n\n", $parent->getLine())) - ->write("throw \$e;\n") - ->outdent() - ->write("}\n\n") ; } @@ -395,8 +393,12 @@ protected function compileLoadTemplate(Twig_Compiler $compiler, $node, $var) { if ($node instanceof Twig_Node_Expression_Constant) { $compiler - ->write(sprintf("%s = \$this->env->loadTemplate(", $var)) + ->write(sprintf("%s = \$this->loadTemplate(", $var)) ->subcompile($node) + ->raw(', ') + ->repr($compiler->getFilename()) + ->raw(', ') + ->repr($node->getLine()) ->raw(");\n") ; } else { @@ -407,7 +409,12 @@ protected function compileLoadTemplate(Twig_Compiler $compiler, $node, $var) ->write(sprintf("if (!%s", $var)) ->raw(" instanceof Twig_Template) {\n") ->indent() - ->write(sprintf("%s = \$this->env->loadTemplate(%s);\n", $var, $var)) + ->write(sprintf("%s = \$this->loadTemplate(%s") + ->raw(', ') + ->repr($compiler->getFilename()) + ->raw(', ') + ->repr($node->getLine()) + ->raw(");\n", $var, $var)) ->outdent() ->write("}\n") ; diff --git a/core/vendor/twig/twig/lib/Twig/Node/SandboxedModule.php b/core/vendor/twig/twig/lib/Twig/Node/SandboxedModule.php deleted file mode 100644 index 410332cc3654b029515bd1d97f65ec935dc2651c..0000000000000000000000000000000000000000 --- a/core/vendor/twig/twig/lib/Twig/Node/SandboxedModule.php +++ /dev/null @@ -1,96 +0,0 @@ -<?php - -/* - * This file is part of Twig. - * - * (c) 2009 Fabien Potencier - * (c) 2009 Armin Ronacher - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -/** - * Represents a module node. - * - * @author Fabien Potencier <fabien@symfony.com> - */ -class Twig_Node_SandboxedModule extends Twig_Node_Module -{ - protected $usedFilters; - protected $usedTags; - protected $usedFunctions; - - public function __construct(Twig_Node_Module $node, array $usedFilters, array $usedTags, array $usedFunctions) - { - parent::__construct($node->getNode('body'), $node->getNode('parent'), $node->getNode('blocks'), $node->getNode('macros'), $node->getNode('traits'), $node->getAttribute('embedded_templates'), $node->getAttribute('filename')); - - $this->setAttribute('index', $node->getAttribute('index')); - - $this->usedFilters = $usedFilters; - $this->usedTags = $usedTags; - $this->usedFunctions = $usedFunctions; - } - - protected function compileDisplayBody(Twig_Compiler $compiler) - { - $compiler->write("\$this->checkSecurity();\n"); - - parent::compileDisplayBody($compiler); - } - - protected function compileDisplayFooter(Twig_Compiler $compiler) - { - parent::compileDisplayFooter($compiler); - - $tags = $filters = $functions = array(); - foreach (array('tags', 'filters', 'functions') as $type) { - foreach ($this->{'used'.ucfirst($type)} as $name => $node) { - if ($node instanceof Twig_Node) { - ${$type}[$name] = $node->getLine(); - } else { - ${$type}[$node] = null; - } - } - } - - $compiler - ->write("protected function checkSecurity()\n", "{\n") - ->indent() - ->write("\$tags = ")->repr(array_filter($tags))->raw(";\n") - ->write("\$filters = ")->repr(array_filter($filters))->raw(";\n") - ->write("\$functions = ")->repr(array_filter($functions))->raw(";\n\n") - ->write("try {\n") - ->indent() - ->write("\$this->env->getExtension('sandbox')->checkSecurity(\n") - ->indent() - ->write(!$tags ? "array(),\n" : "array('".implode("', '", array_keys($tags))."'),\n") - ->write(!$filters ? "array(),\n" : "array('".implode("', '", array_keys($filters))."'),\n") - ->write(!$functions ? "array()\n" : "array('".implode("', '", array_keys($functions))."')\n") - ->outdent() - ->write(");\n") - ->outdent() - ->write("} catch (Twig_Sandbox_SecurityError \$e) {\n") - ->indent() - ->write("\$e->setTemplateFile(\$this->getTemplateName());\n\n") - ->write("if (\$e instanceof Twig_Sandbox_SecurityNotAllowedTagError && isset(\$tags[\$e->getTagName()])) {\n") - ->indent() - ->write("\$e->setTemplateLine(\$tags[\$e->getTagName()]);\n") - ->outdent() - ->write("} elseif (\$e instanceof Twig_Sandbox_SecurityNotAllowedFilterError && isset(\$filters[\$e->getFilterName()])) {\n") - ->indent() - ->write("\$e->setTemplateLine(\$filters[\$e->getFilterName()]);\n") - ->outdent() - ->write("} elseif (\$e instanceof Twig_Sandbox_SecurityNotAllowedFunctionError && isset(\$functions[\$e->getFunctionName()])) {\n") - ->indent() - ->write("\$e->setTemplateLine(\$functions[\$e->getFunctionName()]);\n") - ->outdent() - ->write("}\n\n") - ->write("throw \$e;\n") - ->outdent() - ->write("}\n") - ->outdent() - ->write("}\n\n") - ; - } -} diff --git a/core/vendor/twig/twig/lib/Twig/NodeVisitor/Optimizer.php b/core/vendor/twig/twig/lib/Twig/NodeVisitor/Optimizer.php index 6b4233b53a65e52c6c6a7498a347d5d175236416..b9f9a5bfa66ad68cdb0dce1811f40e8d330741ac 100644 --- a/core/vendor/twig/twig/lib/Twig/NodeVisitor/Optimizer.php +++ b/core/vendor/twig/twig/lib/Twig/NodeVisitor/Optimizer.php @@ -56,7 +56,7 @@ public function enterNode(Twig_NodeInterface $node, Twig_Environment $env) $this->enterOptimizeFor($node, $env); } - if (!version_compare(phpversion(), '5.4.0RC1', '>=') && self::OPTIMIZE_VAR_ACCESS === (self::OPTIMIZE_VAR_ACCESS & $this->optimizers) && !$env->isStrictVariables() && !$env->hasExtension('sandbox')) { + if (PHP_VERSION_ID < 50400 && self::OPTIMIZE_VAR_ACCESS === (self::OPTIMIZE_VAR_ACCESS & $this->optimizers) && !$env->isStrictVariables() && !$env->hasExtension('sandbox')) { if ($this->inABody) { if (!$node instanceof Twig_Node_Expression) { if (get_class($node) !== 'Twig_Node') { diff --git a/core/vendor/twig/twig/lib/Twig/Template.php b/core/vendor/twig/twig/lib/Twig/Template.php index 70d19e740b549b68b9c31179a6e63c2f28d1e6fd..caf96428b275a522aba106e7960d24515ae02622 100644 --- a/core/vendor/twig/twig/lib/Twig/Template.php +++ b/core/vendor/twig/twig/lib/Twig/Template.php @@ -78,7 +78,7 @@ public function getParent(array $context) } if (!isset($this->parents[$parent])) { - $this->parents[$parent] = $this->env->loadTemplate($parent); + $this->parents[$parent] = $this->loadTemplate($parent); } } catch (Twig_Error_Loader $e) { $e->setTemplateFile(null); @@ -240,6 +240,30 @@ public function getBlockNames() return array_keys($this->blocks); } + protected function loadTemplate($template, $templateName = null, $line = null, $index = null) + { + try { + if (is_array($template)) { + return $this->env->resolveTemplate($template); + } + + if ($template instanceof Twig_Template) { + return $template; + } + + return $this->env->loadTemplate($template, $index); + } catch (Twig_Error $e) { + $e->setTemplateFile($templateName ? $templateName : $this->getTemplateName()); + if (!$line) { + $e->guess(); + } else { + $e->setTemplateLine($line); + } + + throw $e; + } + } + /** * Returns all blocks. * diff --git a/core/vendor/twig/twig/lib/Twig/Test/NodeTestCase.php b/core/vendor/twig/twig/lib/Twig/Test/NodeTestCase.php index 9eb44614f5c3e5adfb10f888bc858d32ad1068d9..bf865211bbfb8893565dfdbb07c894191df4d1ad 100644 --- a/core/vendor/twig/twig/lib/Twig/Test/NodeTestCase.php +++ b/core/vendor/twig/twig/lib/Twig/Test/NodeTestCase.php @@ -42,7 +42,7 @@ protected function getVariableGetter($name, $line = false) { $line = $line > 0 ? "// line {$line}\n" : ''; - if (version_compare(phpversion(), '5.4.0RC1', '>=')) { + if (PHP_VERSION_ID >= 50400) { return sprintf('%s(isset($context["%s"]) ? $context["%s"] : null)', $line, $name, $name); } diff --git a/core/vendor/twig/twig/test/Twig/Tests/EnvironmentTest.php b/core/vendor/twig/twig/test/Twig/Tests/EnvironmentTest.php index b791e57f5c6add1b9cd72044cc3d4bdf2b08e0b4..ee127e01e0024ae78998cf98c96b7e23a516f1cc 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/EnvironmentTest.php +++ b/core/vendor/twig/twig/test/Twig/Tests/EnvironmentTest.php @@ -46,7 +46,7 @@ public function escapingStrategyCallback($filename) public function testGlobals() { // globals can be added after calling getGlobals - $twig = new Twig_Environment(new Twig_Loader_String()); + $twig = new Twig_Environment($this->getMock('Twig_LoaderInterface')); $twig->addGlobal('foo', 'foo'); $twig->getGlobals(); $twig->addGlobal('foo', 'bar'); @@ -54,7 +54,7 @@ public function testGlobals() $this->assertEquals('bar', $globals['foo']); // globals can be modified after runtime init - $twig = new Twig_Environment(new Twig_Loader_String()); + $twig = new Twig_Environment($this->getMock('Twig_LoaderInterface')); $twig->addGlobal('foo', 'foo'); $globals = $twig->getGlobals(); $twig->initRuntime(); @@ -63,7 +63,7 @@ public function testGlobals() $this->assertEquals('bar', $globals['foo']); // globals can be modified after extensions init - $twig = new Twig_Environment(new Twig_Loader_String()); + $twig = new Twig_Environment($this->getMock('Twig_LoaderInterface')); $twig->addGlobal('foo', 'foo'); $twig->getGlobals(); $twig->getFunctions(); @@ -72,7 +72,7 @@ public function testGlobals() $this->assertEquals('bar', $globals['foo']); // globals can be modified after extensions and runtime init - $twig = new Twig_Environment(new Twig_Loader_String()); + $twig = new Twig_Environment($loader = new Twig_Loader_Array(array('index' => '{{foo}}'))); $twig->addGlobal('foo', 'foo'); $twig->getGlobals(); $twig->getFunctions(); @@ -81,15 +81,15 @@ public function testGlobals() $globals = $twig->getGlobals(); $this->assertEquals('bar', $globals['foo']); - $twig = new Twig_Environment(new Twig_Loader_String()); + $twig = new Twig_Environment($loader); $twig->getGlobals(); $twig->addGlobal('foo', 'bar'); - $template = $twig->loadTemplate('{{foo}}'); + $template = $twig->loadTemplate('index'); $this->assertEquals('bar', $template->render(array())); /* to be uncomment in Twig 2.0 // globals cannot be added after runtime init - $twig = new Twig_Environment(new Twig_Loader_String()); + $twig = new Twig_Environment($this->getMock('Twig_LoaderInterface')); $twig->addGlobal('foo', 'foo'); $globals = $twig->getGlobals(); $twig->initRuntime(); @@ -101,7 +101,7 @@ public function testGlobals() } // globals cannot be added after extensions init - $twig = new Twig_Environment(new Twig_Loader_String()); + $twig = new Twig_Environment($this->getMock('Twig_LoaderInterface')); $twig->addGlobal('foo', 'foo'); $globals = $twig->getGlobals(); $twig->getFunctions(); @@ -113,7 +113,7 @@ public function testGlobals() } // globals cannot be added after extensions and runtime init - $twig = new Twig_Environment(new Twig_Loader_String()); + $twig = new Twig_Environment($this->getMock('Twig_LoaderInterface')); $twig->addGlobal('foo', 'foo'); $globals = $twig->getGlobals(); $twig->getFunctions(); @@ -126,7 +126,7 @@ public function testGlobals() } // test adding globals after initRuntime without call to getGlobals - $twig = new Twig_Environment(new Twig_Loader_String()); + $twig = new Twig_Environment($this->getMock('Twig_LoaderInterface')); $twig->initRuntime(); try { $twig->addGlobal('bar', 'bar'); @@ -142,17 +142,17 @@ public function testExtensionsAreNotInitializedWhenRenderingACompiledTemplate() $options = array('cache' => sys_get_temp_dir().'/twig', 'auto_reload' => false, 'debug' => false); // force compilation - $twig = new Twig_Environment(new Twig_Loader_String(), $options); - $cache = $twig->getCacheFilename('{{ foo }}'); + $twig = new Twig_Environment($loader = new Twig_Loader_Array(array('index' => '{{ foo }}')), $options); + $cache = $twig->getCacheFilename('index'); if (!is_dir(dirname($cache))) { mkdir(dirname($cache), 0777, true); } - file_put_contents($cache, $twig->compileSource('{{ foo }}', '{{ foo }}')); + file_put_contents($cache, $twig->compileSource('{{ foo }}', 'index')); // check that extensions won't be initialized when rendering a template that is already in the cache $twig = $this ->getMockBuilder('Twig_Environment') - ->setConstructorArgs(array(new Twig_Loader_String(), $options)) + ->setConstructorArgs(array($loader, $options)) ->setMethods(array('initExtensions')) ->getMock() ; @@ -160,7 +160,7 @@ public function testExtensionsAreNotInitializedWhenRenderingACompiledTemplate() $twig->expects($this->never())->method('initExtensions'); // render template - $output = $twig->render('{{ foo }}', array('foo' => 'bar')); + $output = $twig->render('index', array('foo' => 'bar')); $this->assertEquals('bar', $output); unlink($cache); @@ -168,7 +168,7 @@ public function testExtensionsAreNotInitializedWhenRenderingACompiledTemplate() public function testAddExtension() { - $twig = new Twig_Environment(new Twig_Loader_String()); + $twig = new Twig_Environment($this->getMock('Twig_LoaderInterface')); $twig->addExtension(new Twig_Tests_EnvironmentTest_Extension()); $this->assertArrayHasKey('test', $twig->getTags()); @@ -184,7 +184,7 @@ public function testAddExtension() public function testRemoveExtension() { - $twig = new Twig_Environment(new Twig_Loader_String()); + $twig = new Twig_Environment($this->getMock('Twig_LoaderInterface')); $twig->addExtension(new Twig_Tests_EnvironmentTest_Extension()); $twig->removeExtension('environment_test'); diff --git a/core/vendor/twig/twig/test/Twig/Tests/ExpressionParserTest.php b/core/vendor/twig/twig/test/Twig/Tests/ExpressionParserTest.php index 983849ea12d308b1284d18e7bea87e4bacf37dc6..ff263cf284119ef5814c597d8d999d9357efde32 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/ExpressionParserTest.php +++ b/core/vendor/twig/twig/test/Twig/Tests/ExpressionParserTest.php @@ -17,7 +17,7 @@ class Twig_Tests_ExpressionParserTest extends PHPUnit_Framework_TestCase */ public function testCanOnlyAssignToNames($template) { - $env = new Twig_Environment(new Twig_Loader_String(), array('cache' => false, 'autoescape' => false)); + $env = new Twig_Environment($this->getMock('Twig_LoaderInterface'), array('cache' => false, 'autoescape' => false)); $parser = new Twig_Parser($env); $parser->parse($env->tokenize($template, 'index')); @@ -41,7 +41,7 @@ public function getFailingTestsForAssignment() */ public function testArrayExpression($template, $expected) { - $env = new Twig_Environment(new Twig_Loader_String(), array('cache' => false, 'autoescape' => false)); + $env = new Twig_Environment($this->getMock('Twig_LoaderInterface'), array('cache' => false, 'autoescape' => false)); $stream = $env->tokenize($template, 'index'); $parser = new Twig_Parser($env); @@ -54,7 +54,7 @@ public function testArrayExpression($template, $expected) */ public function testArraySyntaxError($template) { - $env = new Twig_Environment(new Twig_Loader_String(), array('cache' => false, 'autoescape' => false)); + $env = new Twig_Environment($this->getMock('Twig_LoaderInterface'), array('cache' => false, 'autoescape' => false)); $parser = new Twig_Parser($env); $parser->parse($env->tokenize($template, 'index')); @@ -149,7 +149,7 @@ public function getTestsForArray() */ public function testStringExpressionDoesNotConcatenateTwoConsecutiveStrings() { - $env = new Twig_Environment(new Twig_Loader_String(), array('cache' => false, 'autoescape' => false, 'optimizations' => 0)); + $env = new Twig_Environment($this->getMock('Twig_LoaderInterface'), array('cache' => false, 'autoescape' => false, 'optimizations' => 0)); $stream = $env->tokenize('{{ "a" "b" }}', 'index'); $parser = new Twig_Parser($env); @@ -161,7 +161,7 @@ public function testStringExpressionDoesNotConcatenateTwoConsecutiveStrings() */ public function testStringExpression($template, $expected) { - $env = new Twig_Environment(new Twig_Loader_String(), array('cache' => false, 'autoescape' => false, 'optimizations' => 0)); + $env = new Twig_Environment($this->getMock('Twig_LoaderInterface'), array('cache' => false, 'autoescape' => false, 'optimizations' => 0)); $stream = $env->tokenize($template, 'index'); $parser = new Twig_Parser($env); @@ -220,7 +220,7 @@ public function getTestsForString() */ public function testAttributeCallDoesNotSupportNamedArguments() { - $env = new Twig_Environment(new Twig_Loader_String(), array('cache' => false, 'autoescape' => false)); + $env = new Twig_Environment($this->getMock('Twig_LoaderInterface'), array('cache' => false, 'autoescape' => false)); $parser = new Twig_Parser($env); $parser->parse($env->tokenize('{{ foo.bar(name="Foo") }}', 'index')); @@ -231,7 +231,7 @@ public function testAttributeCallDoesNotSupportNamedArguments() */ public function testMacroCallDoesNotSupportNamedArguments() { - $env = new Twig_Environment(new Twig_Loader_String(), array('cache' => false, 'autoescape' => false)); + $env = new Twig_Environment($this->getMock('Twig_LoaderInterface'), array('cache' => false, 'autoescape' => false)); $parser = new Twig_Parser($env); $parser->parse($env->tokenize('{% from _self import foo %}{% macro foo() %}{% endmacro %}{{ foo(name="Foo") }}', 'index')); @@ -243,7 +243,7 @@ public function testMacroCallDoesNotSupportNamedArguments() */ public function testMacroDefinitionDoesNotSupportNonNameVariableName() { - $env = new Twig_Environment(new Twig_Loader_String(), array('cache' => false, 'autoescape' => false)); + $env = new Twig_Environment($this->getMock('Twig_LoaderInterface'), array('cache' => false, 'autoescape' => false)); $parser = new Twig_Parser($env); $parser->parse($env->tokenize('{% macro foo("a") %}{% endmacro %}', 'index')); @@ -256,7 +256,7 @@ public function testMacroDefinitionDoesNotSupportNonNameVariableName() */ public function testMacroDefinitionDoesNotSupportNonConstantDefaultValues($template) { - $env = new Twig_Environment(new Twig_Loader_String(), array('cache' => false, 'autoescape' => false)); + $env = new Twig_Environment($this->getMock('Twig_LoaderInterface'), array('cache' => false, 'autoescape' => false)); $parser = new Twig_Parser($env); $parser->parse($env->tokenize($template, 'index')); @@ -275,7 +275,7 @@ public function getMacroDefinitionDoesNotSupportNonConstantDefaultValues() */ public function testMacroDefinitionSupportsConstantDefaultValues($template) { - $env = new Twig_Environment(new Twig_Loader_String(), array('cache' => false, 'autoescape' => false)); + $env = new Twig_Environment($this->getMock('Twig_LoaderInterface'), array('cache' => false, 'autoescape' => false)); $parser = new Twig_Parser($env); $parser->parse($env->tokenize($template, 'index')); @@ -300,7 +300,7 @@ public function getMacroDefinitionSupportsConstantDefaultValues() */ public function testUnknownFunction() { - $env = new Twig_Environment(new Twig_Loader_String(), array('cache' => false, 'autoescape' => false)); + $env = new Twig_Environment($this->getMock('Twig_LoaderInterface'), array('cache' => false, 'autoescape' => false)); $parser = new Twig_Parser($env); $parser->parse($env->tokenize('{{ cycl() }}', 'index')); @@ -312,7 +312,7 @@ public function testUnknownFunction() */ public function testUnknownFilter() { - $env = new Twig_Environment(new Twig_Loader_String(), array('cache' => false, 'autoescape' => false)); + $env = new Twig_Environment($this->getMock('Twig_LoaderInterface'), array('cache' => false, 'autoescape' => false)); $parser = new Twig_Parser($env); $parser->parse($env->tokenize('{{ 1|lowe }}', 'index')); @@ -324,7 +324,7 @@ public function testUnknownFilter() */ public function testUnknownTest() { - $env = new Twig_Environment(new Twig_Loader_String(), array('cache' => false, 'autoescape' => false)); + $env = new Twig_Environment($this->getMock('Twig_LoaderInterface'), array('cache' => false, 'autoescape' => false)); $parser = new Twig_Parser($env); $parser->parse($env->tokenize('{{ 1 is nul }}', 'index')); diff --git a/core/vendor/twig/twig/test/Twig/Tests/FileCachingTest.php b/core/vendor/twig/twig/test/Twig/Tests/FileCachingTest.php index 3eaee593b08ab7e0baa13a0d2ec1f438b2ce69b0..6f5bfee418508abc2477b78e018ff69c576ca1a8 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/FileCachingTest.php +++ b/core/vendor/twig/twig/test/Twig/Tests/FileCachingTest.php @@ -26,7 +26,7 @@ public function setUp() $this->markTestSkipped(sprintf('Unable to run the tests as "%s" is not writable.', $this->tmpDir)); } - $this->env = new Twig_Environment(new Twig_Loader_String(), array('cache' => $this->tmpDir)); + $this->env = new Twig_Environment(new Twig_Loader_Array(array('index' => 'index', 'index2' => 'index2')), array('cache' => $this->tmpDir)); } public function tearDown() @@ -40,7 +40,7 @@ public function tearDown() public function testWritingCacheFiles() { - $name = 'This is just text.'; + $name = 'index'; $this->env->loadTemplate($name); $cacheFileName = $this->env->getCacheFilename($name); @@ -50,7 +50,7 @@ public function testWritingCacheFiles() public function testClearingCacheFiles() { - $name = 'I will be deleted.'; + $name = 'index2'; $this->env->loadTemplate($name); $cacheFileName = $this->env->getCacheFilename($name); diff --git a/core/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/slice.test b/core/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/slice.test index c10fe9355fef34e6b6257388adf2f405da573d69..b49b89fe56d25cedd39bb89822786a85806bd6b3 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/slice.test +++ b/core/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/slice.test @@ -24,8 +24,9 @@ {{ arr|slice(3)|join('') }} {{ arr[2:]|join('') }} +{{ xml|slice(1)|join('')}} --DATA-- -return array('start' => 1, 'length' => 2, 'arr' => new ArrayObject(array(1, 2, 3, 4))) +return array('start' => 1, 'length' => 2, 'arr' => new ArrayObject(array(1, 2, 3, 4)), 'xml' => new SimpleXMLElement('<items><item>1</item><item>2</item></items>')) --EXPECT-- 23 23 @@ -49,4 +50,5 @@ bc 1 4 -34 \ No newline at end of file +34 +2 diff --git a/core/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/extends_as_array_with_empty_name.test b/core/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/extends_as_array_with_empty_name.test new file mode 100644 index 0000000000000000000000000000000000000000..acc74f6a148dacc741a06ff757ed05508c25b478 --- /dev/null +++ b/core/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/extends_as_array_with_empty_name.test @@ -0,0 +1,12 @@ +--TEST-- +"extends" tag +--TEMPLATE-- +{% extends ["", "bar.twig"] %} +--TEMPLATE(bar.twig)-- +{% block content %} +foo +{% endblock %} +--DATA-- +return array() +--EXPECT-- +foo diff --git a/core/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/extends_as_array_with_null_name.test b/core/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/extends_as_array_with_null_name.test new file mode 100644 index 0000000000000000000000000000000000000000..cfa648d419ea8255a28b22da69457cafba4c54c0 --- /dev/null +++ b/core/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/inheritance/extends_as_array_with_null_name.test @@ -0,0 +1,12 @@ +--TEST-- +"extends" tag +--TEMPLATE-- +{% extends [null, "bar.twig"] %} +--TEMPLATE(bar.twig)-- +{% block content %} +foo +{% endblock %} +--DATA-- +return array() +--EXPECT-- +foo diff --git a/core/vendor/twig/twig/test/Twig/Tests/Loader/FilesystemTest.php b/core/vendor/twig/twig/test/Twig/Tests/Loader/FilesystemTest.php index a9d611956d8928b85a14daf37bc356c032e4d4b5..03c1eb9f172c1019ff87a668495ce34078d821aa 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/Loader/FilesystemTest.php +++ b/core/vendor/twig/twig/test/Twig/Tests/Loader/FilesystemTest.php @@ -146,4 +146,30 @@ public function testLoadTemplateAndRenderBlockWithCache() $template = $twig->loadTemplate('blocks.html.twig'); $this->assertSame('block from theme 2', $template->renderBlock('b2', array())); } + + public function getArrayInheritanceTests() + { + return array( + 'valid array inheritance' => array('array_inheritance_valid_parent.html.twig'), + 'array inheritance with null first template' => array('array_inheritance_null_parent.html.twig'), + 'array inheritance with empty first template' => array('array_inheritance_empty_parent.html.twig'), + 'array inheritance with non-existent first template' => array('array_inheritance_nonexistent_parent.html.twig'), + ); + } + + /** + * @dataProvider getArrayInheritanceTests + * + * @param $templateName string Template name with array inheritance + */ + public function testArrayInheritance($templateName) + { + $loader = new Twig_Loader_Filesystem(array()); + $loader->addPath(dirname(__FILE__).'/Fixtures/inheritance'); + + $twig = new Twig_Environment($loader); + + $template = $twig->loadTemplate($templateName); + $this->assertSame('VALID Child', $template->renderBlock('body', array())); + } } diff --git a/core/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/inheritance/array_inheritance_empty_parent.html.twig b/core/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/inheritance/array_inheritance_empty_parent.html.twig new file mode 100644 index 0000000000000000000000000000000000000000..6977ebf66cd2e3570953196b801fcfe216b9a630 --- /dev/null +++ b/core/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/inheritance/array_inheritance_empty_parent.html.twig @@ -0,0 +1,3 @@ +{% extends ['','parent.html.twig'] %} + +{% block body %}{{ parent() }} Child{% endblock %} diff --git a/core/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/inheritance/array_inheritance_nonexistent_parent.html.twig b/core/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/inheritance/array_inheritance_nonexistent_parent.html.twig new file mode 100644 index 0000000000000000000000000000000000000000..5b50a8b211c8d1f487aa6d49ee23b6b74f40feca --- /dev/null +++ b/core/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/inheritance/array_inheritance_nonexistent_parent.html.twig @@ -0,0 +1,3 @@ +{% extends ['nonexistent.html.twig','parent.html.twig'] %} + +{% block body %}{{ parent() }} Child{% endblock %} diff --git a/core/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/inheritance/array_inheritance_null_parent.html.twig b/core/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/inheritance/array_inheritance_null_parent.html.twig new file mode 100644 index 0000000000000000000000000000000000000000..a16b3adedb835a534e175b9685f8b557aef93aac --- /dev/null +++ b/core/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/inheritance/array_inheritance_null_parent.html.twig @@ -0,0 +1,3 @@ +{% extends [null,'parent.html.twig'] %} + +{% block body %}{{ parent() }} Child{% endblock %} diff --git a/core/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/inheritance/array_inheritance_valid_parent.html.twig b/core/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/inheritance/array_inheritance_valid_parent.html.twig new file mode 100644 index 0000000000000000000000000000000000000000..4940dad4167c426bfcbe83220b38f215983f1eba --- /dev/null +++ b/core/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/inheritance/array_inheritance_valid_parent.html.twig @@ -0,0 +1,3 @@ +{% extends ['parent.html.twig','spare_parent.html.twig'] %} + +{% block body %}{{ parent() }} Child{% endblock %} diff --git a/core/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/inheritance/parent.html.twig b/core/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/inheritance/parent.html.twig new file mode 100644 index 0000000000000000000000000000000000000000..d594c0ed49dd21d7b045723d6af779ee7e6a2e37 --- /dev/null +++ b/core/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/inheritance/parent.html.twig @@ -0,0 +1 @@ +{% block body %}VALID{% endblock %} diff --git a/core/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/inheritance/spare_parent.html.twig b/core/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/inheritance/spare_parent.html.twig new file mode 100644 index 0000000000000000000000000000000000000000..70b7360a2c037b179c11a493a1fd4ad68d2204dd --- /dev/null +++ b/core/vendor/twig/twig/test/Twig/Tests/Loader/Fixtures/inheritance/spare_parent.html.twig @@ -0,0 +1 @@ +{% block body %}SPARE PARENT{% endblock %} diff --git a/core/vendor/twig/twig/test/Twig/Tests/NativeExtensionTest.php b/core/vendor/twig/twig/test/Twig/Tests/NativeExtensionTest.php index 9bc6079ffd43d1e4b9c13cd6e4fe979d6bb79f9f..36b632984bc5ad1f8dfd18ed71714c047a5f058d 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/NativeExtensionTest.php +++ b/core/vendor/twig/twig/test/Twig/Tests/NativeExtensionTest.php @@ -17,7 +17,7 @@ public function testGetProperties() $this->markTestSkipped('Skip under HHVM as the behavior is not the same as plain PHP (which is an edge case anyway)'); } - $twig = new Twig_Environment(new Twig_Loader_String(), array( + $twig = new Twig_Environment(new Twig_Loader_Array(array('index' => '{{ d1.date }}{{ d2.date }}')), array( 'debug' => true, 'cache' => false, 'autoescape' => false, @@ -25,7 +25,7 @@ public function testGetProperties() $d1 = new DateTime(); $d2 = new DateTime(); - $output = $twig->render('{{ d1.date }}{{ d2.date }}', compact('d1', 'd2')); + $output = $twig->render('index', compact('d1', 'd2')); // If it fails, PHP will crash. $this->assertEquals($output, $d1->date.$d2->date); diff --git a/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/CallTest.php b/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/CallTest.php index 9cd9715648d6940a357a7cbde4a382be049485cf..af4e3519cb18987dc0b509d89271554db4414a5d 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/CallTest.php +++ b/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/CallTest.php @@ -78,6 +78,16 @@ public function testResolveArgumentsOnlyNecessaryArgumentsForCustomFunction() $this->assertEquals(array('arg1'), $node->getArguments(array($this, 'customFunction'), array('arg1' => 'arg1'))); } + public function testGetArgumentsForStaticMethod() + { + $node = new Twig_Tests_Node_Expression_Call(array(), array('type' => 'function', 'name' => 'custom_static_function')); + $this->assertEquals(array('arg1'), $node->getArguments(__CLASS__.'::customStaticFunction', array('arg1' => 'arg1'))); + } + + public static function customStaticFunction($arg1, $arg2 = 'default', $arg3 = array()) + { + } + public function customFunction($arg1, $arg2 = 'default', $arg3 = array()) { } diff --git a/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/FilterTest.php b/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/FilterTest.php index 2b85141cd65fe9f5fffcde1324d8924b4c9d7981..4aefa7e551dac3ced2eff2c8d27cf92ace3fba06 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/FilterTest.php +++ b/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/FilterTest.php @@ -64,7 +64,7 @@ public function getTests() $tests[] = array($node, 'twig_reverse_filter($this->env, "abc", true)'); // filter as an anonymous function - if (version_compare(phpversion(), '5.3.0', '>=')) { + if (PHP_VERSION_ID >= 50300) { $node = $this->createFilter(new Twig_Node_Expression_Constant('foo', 1), 'anonymous'); $tests[] = array($node, 'call_user_func_array($this->env->getFilter(\'anonymous\')->getCallable(), array("foo"))'); } @@ -112,7 +112,7 @@ protected function createFilter($node, $name, array $arguments = array()) protected function getEnvironment() { - if (version_compare(phpversion(), '5.3.0', '>=')) { + if (PHP_VERSION_ID >= 50300) { return include 'PHP53/FilterInclude.php'; } diff --git a/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/FunctionTest.php b/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/FunctionTest.php index 4d4a72192d2882d8a6f21a3eb6522282a27a967a..209b8cf83a13ecdda2bce2be643e141daf5a05db 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/FunctionTest.php +++ b/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/FunctionTest.php @@ -63,7 +63,7 @@ public function getTests() $tests[] = array($node, 'twig_date_converter($this->env, 0, "America/Chicago")'); // function as an anonymous function - if (version_compare(phpversion(), '5.3.0', '>=')) { + if (PHP_VERSION_ID >= 50300) { $node = $this->createFunction('anonymous', array(new Twig_Node_Expression_Constant('foo', 1))); $tests[] = array($node, 'call_user_func_array($this->env->getFunction(\'anonymous\')->getCallable(), array("foo"))'); } @@ -78,7 +78,7 @@ protected function createFunction($name, array $arguments = array()) protected function getEnvironment() { - if (version_compare(phpversion(), '5.3.0', '>=')) { + if (PHP_VERSION_ID >= 50300) { return include 'PHP53/FunctionInclude.php'; } diff --git a/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/NameTest.php b/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/NameTest.php index d013affad0888de2e6b2791310c36187a261a189..905d8ee9b1853a192b0fcefe36410f5cfa4a5f04 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/NameTest.php +++ b/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/NameTest.php @@ -28,7 +28,7 @@ public function getTests() $env1 = new Twig_Environment(null, array('strict_variables' => false)); return array( - array($node, "// line 1\n".(version_compare(PHP_VERSION, '5.4.0') >= 0 ? '(isset($context["foo"]) ? $context["foo"] : $this->getContext($context, "foo"))' : '$this->getContext($context, "foo")'), $env), + array($node, "// line 1\n".(PHP_VERSION_ID >= 50400 ? '(isset($context["foo"]) ? $context["foo"] : $this->getContext($context, "foo"))' : '$this->getContext($context, "foo")'), $env), array($node, $this->getVariableGetter('foo', 1), $env1), array($self, "// line 1\n\$this"), array($context, "// line 1\n\$context"), diff --git a/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/TestTest.php b/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/TestTest.php index 2f54a5a2efdb28510223c3a728f03baf487cadcf..e62a8afddb787d684e6c94bd276c7c54766fe122 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/TestTest.php +++ b/core/vendor/twig/twig/test/Twig/Tests/Node/Expression/TestTest.php @@ -32,7 +32,7 @@ public function getTests() $tests[] = array($node, '(null === "foo")'); // test as an anonymous function - if (version_compare(phpversion(), '5.3.0', '>=')) { + if (PHP_VERSION_ID >= 50300) { $node = $this->createTest(new Twig_Node_Expression_Constant('foo', 1), 'anonymous', array(new Twig_Node_Expression_Constant('foo', 1))); $tests[] = array($node, 'call_user_func_array($this->env->getTest(\'anonymous\')->getCallable(), array("foo", "foo"))'); } @@ -47,7 +47,7 @@ protected function createTest($node, $name, array $arguments = array()) protected function getEnvironment() { - if (version_compare(phpversion(), '5.3.0', '>=')) { + if (PHP_VERSION_ID >= 50300) { return include 'PHP53/TestInclude.php'; } diff --git a/core/vendor/twig/twig/test/Twig/Tests/Node/ImportTest.php b/core/vendor/twig/twig/test/Twig/Tests/Node/ImportTest.php index 0c340a939576941c1f152da78cf6256d4eed8b82..36525b251f88eea2ed88c0778bd49ab6afe2dc47 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/Node/ImportTest.php +++ b/core/vendor/twig/twig/test/Twig/Tests/Node/ImportTest.php @@ -31,7 +31,7 @@ public function getTests() $tests[] = array($node, <<<EOF // line 1 -\$context["macro"] = \$this->env->loadTemplate("foo.twig"); +\$context["macro"] = \$this->loadTemplate("foo.twig", null, 1); EOF ); diff --git a/core/vendor/twig/twig/test/Twig/Tests/Node/IncludeTest.php b/core/vendor/twig/twig/test/Twig/Tests/Node/IncludeTest.php index 03f10d400d0c41fcc795f808bd3a7af47801dab5..6fe5c17bf760ba4a66fe4172971b28b65d48f959 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/Node/IncludeTest.php +++ b/core/vendor/twig/twig/test/Twig/Tests/Node/IncludeTest.php @@ -34,7 +34,7 @@ public function getTests() $node = new Twig_Node_Include($expr, null, false, false, 1); $tests[] = array($node, <<<EOF // line 1 -\$this->env->loadTemplate("foo.twig")->display(\$context); +\$this->loadTemplate("foo.twig", null, 1)->display(\$context); EOF ); @@ -47,7 +47,7 @@ public function getTests() $node = new Twig_Node_Include($expr, null, false, false, 1); $tests[] = array($node, <<<EOF // line 1 -\$this->env->resolveTemplate(((true) ? ("foo") : ("foo")))->display(\$context); +\$this->loadTemplate(((true) ? ("foo") : ("foo")), null, 1)->display(\$context); EOF ); @@ -56,14 +56,14 @@ public function getTests() $node = new Twig_Node_Include($expr, $vars, false, false, 1); $tests[] = array($node, <<<EOF // line 1 -\$this->env->loadTemplate("foo.twig")->display(array_merge(\$context, array("foo" => true))); +\$this->loadTemplate("foo.twig", null, 1)->display(array_merge(\$context, array("foo" => true))); EOF ); $node = new Twig_Node_Include($expr, $vars, true, false, 1); $tests[] = array($node, <<<EOF // line 1 -\$this->env->loadTemplate("foo.twig")->display(array("foo" => true)); +\$this->loadTemplate("foo.twig", null, 1)->display(array("foo" => true)); EOF ); @@ -71,7 +71,7 @@ public function getTests() $tests[] = array($node, <<<EOF // line 1 try { - \$this->env->loadTemplate("foo.twig")->display(array("foo" => true)); + \$this->loadTemplate("foo.twig", null, 1)->display(array("foo" => true)); } catch (Twig_Error_Loader \$e) { // ignore missing template } diff --git a/core/vendor/twig/twig/test/Twig/Tests/Node/ModuleTest.php b/core/vendor/twig/twig/test/Twig/Tests/Node/ModuleTest.php index b15a47551144b00fb5112ee854502614af5ca2cb..5facc55a4c6abbd1e5d6b7ade60d175e07661397 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/Node/ModuleTest.php +++ b/core/vendor/twig/twig/test/Twig/Tests/Node/ModuleTest.php @@ -30,7 +30,7 @@ public function testConstructor() public function getTests() { - $twig = new Twig_Environment(new Twig_Loader_String()); + $twig = new Twig_Environment($this->getMock('Twig_LoaderInterface')); $tests = array(); @@ -46,7 +46,7 @@ public function getTests() <?php /* foo.twig */ -class __TwigTemplate_a2bfbf7dd6ab85666684fe9297f69363a3fc2046d90f22a317d380c18638df0d extends Twig_Template +class __TwigTemplate_e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 extends Twig_Template { public function __construct(Twig_Environment \$env) { @@ -87,22 +87,14 @@ public function getDebugInfo() <?php /* foo.twig */ -class __TwigTemplate_a2bfbf7dd6ab85666684fe9297f69363a3fc2046d90f22a317d380c18638df0d extends Twig_Template +class __TwigTemplate_e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 extends Twig_Template { public function __construct(Twig_Environment \$env) { parent::__construct(\$env); // line 1 - try { - \$this->parent = \$this->env->loadTemplate("layout.twig"); - } catch (Twig_Error_Loader \$e) { - \$e->setTemplateFile(\$this->getTemplateName()); - \$e->setTemplateLine(1); - - throw \$e; - } - + \$this->parent = \$this->loadTemplate("layout.twig", "foo.twig", 1); \$this->blocks = array( ); } @@ -115,7 +107,7 @@ protected function doGetParent(array \$context) protected function doDisplay(array \$context, array \$blocks = array()) { // line 2 - \$context["macro"] = \$this->env->loadTemplate("foo.twig"); + \$context["macro"] = \$this->loadTemplate("foo.twig", "foo.twig", 2); // line 1 \$this->parent->display(\$context, array_merge(\$this->blocks, \$blocks)); } @@ -132,7 +124,7 @@ public function isTraitable() public function getDebugInfo() { - return array ( 34 => 1, 32 => 2, 11 => 1,); + return array ( 26 => 1, 24 => 2, 11 => 1,); } } EOF @@ -152,12 +144,12 @@ public function getDebugInfo() <?php /* foo.twig */ -class __TwigTemplate_a2bfbf7dd6ab85666684fe9297f69363a3fc2046d90f22a317d380c18638df0d extends Twig_Template +class __TwigTemplate_e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 extends Twig_Template { protected function doGetParent(array \$context) { // line 2 - return \$this->env->resolveTemplate(((true) ? ("foo") : ("foo"))); + return \$this->loadTemplate(((true) ? ("foo") : ("foo")), "foo.twig", 2); } protected function doDisplay(array \$context, array \$blocks = array()) diff --git a/core/vendor/twig/twig/test/Twig/Tests/NodeVisitor/OptimizerTest.php b/core/vendor/twig/twig/test/Twig/Tests/NodeVisitor/OptimizerTest.php index 72c777c1ef242f9929cce209ca4d0cb166297e49..b5ea7aac26fe38b26e3a7845844626d66f664e7c 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/NodeVisitor/OptimizerTest.php +++ b/core/vendor/twig/twig/test/Twig/Tests/NodeVisitor/OptimizerTest.php @@ -12,7 +12,7 @@ class Twig_Tests_NodeVisitor_OptimizerTest extends PHPUnit_Framework_TestCase { public function testRenderBlockOptimizer() { - $env = new Twig_Environment(new Twig_Loader_String(), array('cache' => false, 'autoescape' => false)); + $env = new Twig_Environment($this->getMock('Twig_LoaderInterface'), array('cache' => false, 'autoescape' => false)); $stream = $env->parse($env->tokenize('{{ block("foo") }}', 'index')); @@ -24,7 +24,7 @@ public function testRenderBlockOptimizer() public function testRenderParentBlockOptimizer() { - $env = new Twig_Environment(new Twig_Loader_String(), array('cache' => false, 'autoescape' => false)); + $env = new Twig_Environment($this->getMock('Twig_LoaderInterface'), array('cache' => false, 'autoescape' => false)); $stream = $env->parse($env->tokenize('{% extends "foo" %}{% block content %}{{ parent() }}{% endblock %}', 'index')); @@ -36,11 +36,11 @@ public function testRenderParentBlockOptimizer() public function testRenderVariableBlockOptimizer() { - if (version_compare(phpversion(), '5.4.0RC1', '>=')) { + if (PHP_VERSION_ID >= 50400) { return; } - $env = new Twig_Environment(new Twig_Loader_String(), array('cache' => false, 'autoescape' => false)); + $env = new Twig_Environment($this->getMock('Twig_LoaderInterface'), array('cache' => false, 'autoescape' => false)); $stream = $env->parse($env->tokenize('{{ block(name|lower) }}', 'index')); $node = $stream->getNode('body')->getNode(0)->getNode(1); @@ -54,7 +54,7 @@ public function testRenderVariableBlockOptimizer() */ public function testForOptimizer($template, $expected) { - $env = new Twig_Environment(new Twig_Loader_String(), array('cache' => false)); + $env = new Twig_Environment($this->getMock('Twig_LoaderInterface'), array('cache' => false)); $stream = $env->parse($env->tokenize($template, 'index')); diff --git a/core/vendor/twig/twig/test/Twig/Tests/Profiler/Dumper/AbstractTest.php b/core/vendor/twig/twig/test/Twig/Tests/Profiler/Dumper/AbstractTest.php index 9020d3f39024c156a37c08f94d3a9e4f93a2c630..555a5e744527aaa371dbdf7c326e8dc18d8c1433 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/Profiler/Dumper/AbstractTest.php +++ b/core/vendor/twig/twig/test/Twig/Tests/Profiler/Dumper/AbstractTest.php @@ -32,13 +32,14 @@ protected function getProfile() $embedded = clone $embedded; $index->addProfile($embedded); - $a = range(1, 1000); + usleep(500); $embedded->leave(); - $profile->leave(); - usleep(5000); + usleep(4500); $index->leave(); + $profile->leave(); + return $profile; } } diff --git a/core/vendor/twig/twig/test/Twig/Tests/Profiler/Dumper/HtmlTest.php b/core/vendor/twig/twig/test/Twig/Tests/Profiler/Dumper/HtmlTest.php index 1593a031cf5d1ae03be99245cc234355848f098a..66a68c4beae924478c843ec85dbe30eaae1e4806 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/Profiler/Dumper/HtmlTest.php +++ b/core/vendor/twig/twig/test/Twig/Tests/Profiler/Dumper/HtmlTest.php @@ -15,7 +15,7 @@ public function testDump() { $dumper = new Twig_Profiler_Dumper_Html(); $this->assertStringMatchesFormat(<<<EOF -<pre>main +<pre>main <span style="color: #d44">%d.%dms/%d%</span> â”” <span style="background-color: #ffd">index.twig</span> <span style="color: #d44">%d.%dms/%d%</span> â”” embedded.twig::block(<span style="background-color: #dfd">body</span>) â”” <span style="background-color: #ffd">embedded.twig</span> diff --git a/core/vendor/twig/twig/test/Twig/Tests/Profiler/Dumper/TextTest.php b/core/vendor/twig/twig/test/Twig/Tests/Profiler/Dumper/TextTest.php index 2fac9a7180f35b1a52e26b0bc9304a3f196d841a..e2ea165ace4816987188958f1515d245e4e72e61 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/Profiler/Dumper/TextTest.php +++ b/core/vendor/twig/twig/test/Twig/Tests/Profiler/Dumper/TextTest.php @@ -15,7 +15,7 @@ public function testDump() { $dumper = new Twig_Profiler_Dumper_Text(); $this->assertStringMatchesFormat(<<<EOF -main +main %d.%dms/%d% â”” index.twig %d.%dms/%d% â”” embedded.twig::block(body) â”” embedded.twig diff --git a/core/vendor/twig/twig/test/Twig/Tests/Profiler/ProfileTest.php b/core/vendor/twig/twig/test/Twig/Tests/Profiler/ProfileTest.php index 43f5bc42fa576cf6942c536c8c81878dd8a709b0..f786f06ca05a8252bfb431cbcc2a58bd49c3e943 100644 --- a/core/vendor/twig/twig/test/Twig/Tests/Profiler/ProfileTest.php +++ b/core/vendor/twig/twig/test/Twig/Tests/Profiler/ProfileTest.php @@ -69,9 +69,10 @@ public function testGetAddProfile() public function testGetDuration() { $profile = new Twig_Profiler_Profile(); + usleep(1); $profile->leave(); - $this->assertTrue($profile->getDuration() > 0); + $this->assertTrue($profile->getDuration() > 0, sprintf('Expected duration > 0, got: %f', $profile->getDuration())); } public function testSerialize()