This PR was squashed before being merged into the 2.x branch (closes#2415).
Discussion
----------
Add error message when calling parent() in a block that doesn't exist
Related: #2309
When calling `parent()` in a block that isn't defined in the parent template, you get an error message that states `Block "%s" on template "%s" does not exist`, even if the block is wrapped in an `is defined` check, which is confusing and makes debugging hard.
This fix adds a better error message indicating that you should not call `parent()` when the parent block is not defined.
Before:

After:

Commits
-------
4587f676 Add error message when calling parent() in a block that doesn't exist
This PR was merged into the 2.x branch.
Discussion
----------
Fix undef. source in exception.
closes https://github.com/twigphp/Twig/issues/2383
Two things:
- the tests fails without a corrupt cache, so maybe the message is of or the cache generation is off (i.e. not respecting the `$index`)
- passing the `$source` seems superfluous (but maybe that is only the case in the exception message)
Commits
-------
772373cf Fix undef. source in exception.
This PR was submitted for the 2.x branch but it was merged into the 1.x branch instead (closes#2403).
Discussion
----------
#1802 left/right trim
It was said in this thread that there was a preference of adding parameters to the trim filter in order to implement this.
So this feature works like:
trim(character_mask, mode), where mode is either "both", "left" or "right". It is by default "both".
This is my first pull request of this project, so I apologise in advance if something is wrong.
Commits
-------
7d8e7550#1802 left/right trim
This PR was submitted for the 2.x branch but it was merged into the 1.x branch instead (closes#2406).
Discussion
----------
Fix tokenize call in DeprecationCollector
Hi,
if fixes `Argument 1 passed to Twig_Environment::tokenize() must be an instance of Twig_Source, string given`
Commits
-------
13ca97c1 Fix tokenize call in DeprecationCollector
* 1.x:
fixed tests for PHP 5.2
fixed tests for PHP 5.2
fixed tests for PHP 5.2
Fix typo in test filename
added a note in the docs about the PSR-11 runtime loader
fixed typo
updated CHANGELOG
bumped version to 1.32
Add ContainerRuntimeLoader
tweaked docs
Update striptags.rst
fixed CS
Mention autoescape=true deprecation (issue #2386)
Fix typo.
bumped version to 1.31.1-DEV
prepared the 1.31.0 release
added a note about macros usage in the deprecated docs
This PR was merged into the 2.x branch.
Discussion
----------
Change ~ with ^ for version in composer require
Caret symbol sticks closer to semantic versioning, and will always allow non-breaking updates
Commits
-------
8a62689d Change '~' with '^' for version in composer require
This PR was submitted for the 2.x branch but it was merged into the 1.x branch instead (closes#2371).
Discussion
----------
Update striptags.rst
Add information about supported param. Replaces #2370
Commits
-------
048f5490 Update striptags.rst
This PR was squashed before being merged into the 1.x branch (closes#2388).
Discussion
----------
Mention autoescape=true deprecation (issue #2386)
Per #2386, mention the deprecation of true in favor of an explicit "html".
Commits
-------
70d03042 Mention autoescape=true deprecation (issue #2386)
This PR was merged into the 2.x branch.
Discussion
----------
Remove legacy exception catch blocks from 2.x
These `catch` blocks were only useful for compatibility with PHP versions prior to 7.0.
Commits
-------
352c01a0 Remove legacy exception catches from 2.x
This PR was merged into the 2.x branch.
Discussion
----------
Use null rather than specific length for 'to the end' in mb_substr
We use Twig with a ISO-8859-15 charset and noticed the 'capitalize'-method only yielded the first character of a string. I.e. "abcd" became "A" rather than "Abcd".
This was due to a change in the way mb_substr is used. Appearantly, using 2147483647 as a length to indicate 'everything to the end' only works with UTF-8 (and possibly other multibyte charsets). It probably triggers some internal overflow in php for at least ASCII and ISO-8859-15.
Luckily, an easy fix is available since PHP 5.4.8: just use 'null'
See these two tests for which version does what:
(old) https://3v4l.org/qdpIK
(new) https://3v4l.org/kivqK
I also used null in the slice-method. While it did not suffer from this same issue, it did an unnecessary mb_strlen. And there might be similar overflow issues with negative values of $start, but I didn't actually test that.
Commits
-------
3bea610e Use null rather than specific length for 'all characters to the end' with mb_substr