This PR was submitted for the master branch but it was merged into the 1.x branch instead (closes#1807).
Discussion
----------
Inline original source code in compiled templates
For introspection purposes (e.g. instead of https://github.com/symfony/symfony/pull/15653) it is sometimes useful to be able to retrieve the original template source code.
I propose to inline it commented after the compiled class declaration.
This creates no memory nor cpu overhead while still allowing to get the source with very simple parsing logic.
Commits
-------
c9fb373 Inline original source code in compiled templates
This PR was merged into the 1.x branch.
Discussion
----------
Traversable support for 'replace', 'merge' and 'sort'
Add traversable support to:
* replace
* merge
* sort
Other changes:
* Removes some not need checks
* ~~Make unit test skip if it cannot write to cache because of the user running the test~~
* Tests added for traversable support
* Doc updates
Deprecating:
I think the undocumented (and multibyte not supported) use of `replace(string, string)` can be removed in Twig 2.0.
Adding MB support and documentation of the feature was turned down (https://github.com/twigphp/Twig/pull/1618)
However removing it is a BC break (https://github.com/twigphp/Twig/pull/1445#issuecomment-48746926)
Commits
-------
2a17303 Mark test skipped if cannot write to cache directory.
This PR was merged into the 1.x branch.
Discussion
----------
Fix variable names for the deprecation triggering code
Closes https://github.com/twigphp/Twig/issues/1800
Commits
-------
dd446c0 Fix variable names for the deprecation triggering code
This PR was merged into the 1.x branch.
Discussion
----------
fix escaping strategy detection based on filename
Fixessymfony/symfony#15095
It previously excluded any fileextension (not just `.twig`) which is pretty wrong.
Commits
-------
e403363 fix escaping strategy detection based on filename
This PR was squashed before being merged into the 1.x branch (closes#1796).
Discussion
----------
OPcache support fix
According this recipe http://twig.sensiolabs.org/doc/recipes.html#refreshing-modified-templates-when-opcache-or-apc-is-enabled when using OPcache:
```
class Twig_Environment_APC extends Twig_Environment
{
protected function writeCacheFile($file, $content)
{
parent::writeCacheFile($file, $content);
// Compile cached file into bytecode cache
if (extension_loaded('Zend OPcache') && ini_get('opcache.enable')) {
opcache_compile_file($file);
} elseif (extension_loaded('apc') && ini_get('apc.enabled')) {
apc_compile_file($file);
}
}
}
```
it takes an error:
```
Cannot redeclare class __TwigTemplate_12e7606b10ee267fa4174f660f86451aed936cc5680300a6442092f337c910cf
```
This is due to fact that the function ```opcache_compile_file($file)``` executes the file. But it should not do so in accordance with the documentation: http://php.net/manual/en/function.opcache-compile-file.php
There is a bug report: https://bugs.php.net/bug.php?id=66066 (since 2013 👎).
This patch prevents reexecution of the compiled template.
Commits
-------
2c4af24 OPcache support fix
This PR was merged into the 1.x branch.
Discussion
----------
fixed support for Twig_Test_* classes (regression)
fixes#1791
Commits
-------
9561582 fixed support for Twig_Test_* classes
This PR was merged into the 1.x branch.
Discussion
----------
added a note about TwigFiddle
Not sure where to mention it, the IDE section seems ok.
ping @ninsuo
Commits
-------
bc9911e added a note about TwigFiddle
This PR was merged into the 1.x branch.
Discussion
----------
optimized the filesystem loader
* added a cache for templates that do not exist
* sped up Filesystem::exists() by avoiding the creation of exceptions
same as d2b97b49f2 that was reverted because of a BC break
and same as what is in 2.0 (but in a BC way).
Commits
-------
21b128a optimized the filesystem loader
This PR was merged into the 1.x branch.
Discussion
----------
move property initialization to the declaration when possible
From #1781
Commits
-------
5951d1f move property initialization to the declaration when possible
* added a cache for templates that do not exist
* sped up Filesystem::exists() by avoiding the creation of exceptions
same as d2b97b49f2 that was reverted because of a BC break
and same as what is in 2.0 (but in a BC way).
This PR was merged into the 1.x branch.
Discussion
----------
Add missing deprecation triggers
Assetic is extending the ``Twig_Function`` class directly currently, and this was not triggering any deprecation warning
Commits
-------
cb98576 Add missing deprecation triggers
This PR was merged into the 1.x branch.
Discussion
----------
enhance travis setup
- require php 7 to pass
- allow failures for php7 + twig extension
- use container-based infrastructure
- <del>composer self-update to get rid of the outdated warning</del>
- add travis cache for composer
- use travis fast finish
Commits
-------
11baf55 use travis cache for composer and fast finish
7b579df fix php 5.2 compatibility
118598e enhance travis setup
- require php 7 pass (except with extension)
- use container-based infrastructure
- composer self-update to get rid of the outdated warning
- install --prefer-source because travis auth fails against dist
This PR was merged into the 1.x branch.
Discussion
----------
Fix the deprecation warning for functions and tests
Otherwise, when a function does not define any filter, the message looks like that:
```
Using an instance of "Twig_Environment" for function "nelmio_js_logger" is deprecated. Use Twig_SimpleFunction instead.
```
This happens because the notice about the undefined variable gets silenced too, and ``get_class(null)`` returns the current class.
Commits
-------
1687097 Fix the deprecation warning for functions and tests
This PR was merged into the 1.x branch.
Discussion
----------
Deprecation notices
Added a way to warn our users of deprecation features. This framework can be used for core features, but also for functions/tests/filters created by third-party. I haven't added something for tags as it can be done easily in the token parser class.
Fixes#1756 and #1767
Commits
-------
56c7382 added Twig_Util_DeprecationCollector to collect deprecation notices for a set of templates
2da6bae tweaked some deprecation messages
cc98028 added deprecation notices for deprecated classes
c6ab7de optimized legacy tests management
eebfdc7 added a way to manage legacy tests in fixtures
8c4291a removed usage of deprecated features, marked some tests as being legacy
b5db9dc added the Symfony PHPUnit bridge to better manage deprecation notices
23c3922 added deprecated notices for deprecated features
bd87ba8 added some documentation about deprecation notices
d16b7bf added a way to trigger deprecation notices for filters and functions
21f536b added deprecation for the raw tag
efcfe8e added deprecation notices for deprecated tests
65e70a2 fixed CS