This PR was squashed before being merged into the 1.x branch (closes#2478).
Discussion
----------
Drop support for HHVM
Commits
-------
b6a4895e fixed tests for PHP 7.2
6ff8d6f4 dropped support for HHVM
This PR was merged into the 1.x branch.
Discussion
----------
added PHP 7.2 to the test matrix
Commits
-------
0768f10b added PHP 7.2 to the test matrix
This PR was merged into the 1.x branch.
Discussion
----------
Fix code for older versions of PHP
Commits
-------
75f2231a fixed code for older versions of PHP
This PR was merged into the 1.x branch.
Discussion
----------
Support PHPUnit 6 for testing extensions
When testing a Twig extension via the provided test cases [according to the documentation](https://twig.sensiolabs.org/doc/2.x/advanced.html#testing-an-extension), PHPUnit 6 is not supported.
I think we should force people who haven't upgraded to upgrade to PHPUnit 6 instead of limiting the ones who did.
Also, Twig 2.x runs only on PHP 7. People using Twig 2.x would most likely also test their code on PHP 7. Even though PHPUnit 5 supports PHP 7, I think most people who have updated PHP could update or would have already updated PHPUnit.
Commits
-------
8ebaf8e6 Support PHPUnit 6 for testing extensions
This PR was merged into the 1.x branch.
Discussion
----------
Prepare for php 7.2
* allow `|length` of `null`
* allow `|length` of objects not implementing `\Countable`
*To get no errors when running with PHP 7.2 You need to use phpunit
^6.1, otherwise the `each` function, used by phpunit, triggers errors.
You can do so by running phpunit like:
`SYMFONY_PHPUNIT_VERSION=6.1 phpnightly vendor/bin/simple-phpunit`*
Commits
-------
d2b7a01a Prepare for php 7.2
This PR was merged into the 1.x branch.
Discussion
----------
Fix generating template name in createTemplate() method
Before this change the name for the template was generated randomly based on uniqid(mt_rand()). It generated new file whenever the template was loaded as string using the `template_from_string` function even the template was the same. The generated file wasn't used anymore.
Now the cache file is generated by the content of template so using the `template_from_string` is much faster and doesn't pollute the cache folder with unneeded files.
Commits
-------
a7c8b082 Fix generating template name in createTemplate() method
Before this change the name for the template was generated randomly based on uniqid(mt_rand()). It generated new file whenever the template was loaded as string using the `template_from_string` even the template was the same. The generated file wasn't used anymore.
Now the cache file is generated by the content of template so using the `template_from_string` is faster and doesn't pollute the cache folder with unneeded files.
* allow `|length` of `null`
* allow `|length` of objects not implementing `\Countable`
* To get no errors when running with PHP 7.2 You need to use phpunit
^6.1, otherwise the `each` function, used by phpunit, triggers errors.
You can do so by running phpunit like:
`SYMFONY_PHPUNIT_VERSION=6.1 phpnightly vendor/bin/simple-phpunit` *
This PR was submitted for the 2.x branch but it was merged into the 1.x branch instead (closes#2461).
Discussion
----------
Fix typo in `advanced.rst` file
Commits
-------
a264fc62 Fix typo in `advanced.rst` file
This PR was merged into the 1.x branch.
Discussion
----------
fixed edge case in the method cache for Twig attributes
closes#2447
Commits
-------
413be416 fixed edge case in the method cache for Twig attributes
This PR was submitted for the master branch but it was merged into the 1.x branch instead (closes#2448).
Discussion
----------
Wrong stdClass class name generates warning
Commits
-------
38987c93 Wrong stdClass class name generates warning
This PR was merged into the 1.x branch.
Discussion
----------
Fix#2431
See title
Commits
-------
a5c2da6d test if is_object before calling method_exists, fixes#2431
This PR was squashed before being merged into the 1.x branch (closes#2434).
Discussion
----------
Autoescape test addition; collision fix in Array Loader.
This PR makes two changes. It was created while testing a third issue that was discovered to be fixed in the latest version.
## Added JS to Autoescape: name test
This adds "index.js.html" to the autoescape:name test, proving the functionality of the JS escape system and the name guessing strategy.
## Fixed collision in Array Loader
While trying to run the above test, it was discovered that the Array Loader uses the content of the template file as the "key" for determining which compiled template to load.
As the above test uses identical content for both HTML and JS templates this led to the compiled HTML template always being loaded.
This change prepends the content with the filename, which vaguely follows the same mechanism as the "options" (which are appended after `getCacheKey` is called).
**This change might be a backwards-incompatible change** depending on your interpretation of how `Loader/Array` is intended to be used.
The class itself states:
> This loader should only be used for unit testing.
The assumption is it's OK for this to occur.
Test cases have been updated to take this key change into account, and an additional test has been added to confirm `Loader/Array` specifically has the capability to resolve two files with the same content to different keys.
Commits
-------
da82b41a Autoescape test addition; collision fix in Array Loader.
This PR was submitted for the master branch but it was merged into the 1.x branch instead (closes#2262).
Discussion
----------
Call clearstatcache() before calling is_dir().
The result of is_dir() is cached.
So call clearstatcache() before calling 2nd is_dir().
Commits
-------
96638c0d Call clearstatcache() before calling is_dir().
This PR was squashed before being merged into the 1.x branch (closes#2420).
Discussion
----------
Make "length" filter and "empty" test consider __toString [Twig 1.x]
Use case: When you have variables in your views that are actually objects but implement `__toString`, they feel like strings: For example, `{{ something }}` will make use of that to-string-conversion.
What does *not* work is
**a)** `{{ something | length }}`, because that will only have a meaningful return value for objects implementing `\Countable`. This interface, however, may have a totally different semantic/purpose for the object in question.
**b)** `{% if something is empty %}`, because
> empty checks if a variable is an empty string, an empty array, an empty hash, exactly false, or exactly null `[http://twig.sensiolabs.org/doc/2.x/tests/empty.html]`
... and obviously `something !== null` in this case.
For template designers, this may be surprising if they don't actually care about the object-or-string difference, they just "use" the variable.
This change tries to address this as it changes the behavior for such objects that have a `__toString` method and are *not* `\Countable`.
*Yes*, it's a BC break in edge cases:
For a), objects that implement a `__toString` but not `\Countable` would previously yield `1` for `{{ object | length }}`, and now would return the length of the string returned by `__toString`.
For b), testing (defined) variables that are objects implementing `__toString` and that return `''`, the test now is `false`.
Commits
-------
f5193e92 Make "length" filter and "empty" test consider __toString [Twig 1.x]
This PR was submitted for the 2.x branch but it was merged into the 1.x branch instead (closes#2427).
Discussion
----------
Fixed JS escaping for unicode characters with higher code points
Unicode characters with higher code points were being escaped incorrectly. When these characters are escaped, they should maintain their surrogate halves. Previously, Twig was dropping the first surrogate half.
https://mathiasbynens.be/notes/javascript-escapes#unicode-code-point
> The tetragram for centre symbol (𝌆) has code point U+1D306, so you could write it as \u{1D306}. For comparison, if you were to use simple Unicode escapes to represent this symbol, you’d have to write out the surrogate halves separately: '\uD834\uDF06'.
Commits
-------
7f913495 Fixed JS escaping for unicode characters with higher code points
This PR was submitted for the 2.x branch but it was merged into the 1.x branch instead (closes#2422).
Discussion
----------
Updated the vim-twig link
The other project is not maintained anymore and the author recommends this fork.
Commits
-------
955d5abd Updated the vim-twig link