This PR was merged into the 1.x branch.
Discussion
----------
[1.x] Updated exception messages for null vars
Updated exception messages for null vars in ```Twig_Template::getAttribute()```.
Example:
**Before:**
```
Impossible to invoke a method ("myMethod") on a NULL variable ("") in My:template.html.twig at line 1
```
**After:**
```
Impossible to invoke a method ("myMethod") on a null variable in My:template.html.twig at line 1
```
Commits
-------
ddf011d Updated exception messages for null vars in Twig_Template::getAttribute().
This PR was submitted for the master branch but it was merged into the 1.x branch instead (closes#1669).
Discussion
----------
Added an example for "and" on if statment
Commits
-------
2698a42 Added an example for "and" on if statment
This PR was merged into the 1.x branch.
Discussion
----------
Fix two failed unit tests on Windows:
1. fopen() cannot handle directory, replaced by opendir() for getting a testing resource. (also double check a resource is opened)
2. comparing paths by assertEquals() which has mixed '\' and '/' on Windows.
Commits
-------
9d7163e Fix two failed unit tests on Windows:
1. fopen() cannot handle directory, replaced by opendir() for getting a testing resource. (also double check a resource is opened)
2. comparing paths by assertEquals() which has mixed '\' and '/' on Windows.
This PR was merged into the 1.x branch.
Discussion
----------
Reduce the name of the cache directories to 1 character
Currently Twig spread the cached template over a directory tree and it's a good practice because it makes the filesystem happier (some filesystems limit the number of file per directory and some filesystems do not index the content of the directories => to access a file in a directory you may have to go through all the files in the directory to find it).
But this technique as also a few drawbacks because it will consume more inodes and in PHP because of the realpath cache which could be saturated by the path of too many directories.
`----`
The current implementation use 2 levels of directory with a 2 chars name, which end-up to `36^4 == 1,679,616` combinations and when you have a lot of templates it can be a real issue.
Per example, with 8,000 templates you will have:
- 8,000 different keys because `8,000 <<< 1,679,616` (a key is the combination of the two directories name, so 4 characters)
- 1,296 directories directly under `twig/`
- **1 file** per directory
- a total of `8,000 + 8,000 + 1,296 =` **17,296 keys** in the realpath cache.
My proposal with this PR is to reduce the name of the directories to only one character which for 8,000 templates end up to:
- 1,296 different keys (a key is the combination of the two directories name, so 2 characters)
- 36 directories directly under `twig/`
- ~**8 files** per directory
- a total of `8,000 + 1,296 + 36 =` **9,332 keys** in the realpath cache.
Note: If you don't have a lot of templates (> 1,000) it will not change anything for you.
Commits
-------
2972309 Reduce the name of the cache directories to 1 character
This PR was merged into the 1.x branch.
Discussion
----------
Fix leaks
Commits
-------
c41d305 Cleanup API - make the compiler happy
8bb7cbb Fixed memory leaks
This PR was merged into the 1.18-dev branch.
Discussion
----------
deprecated the String loader
Even if the String loader should never be used, people keep trying to use it. It's too confusing to keep and we don't really need it in tests. So, I propose to deprecate it in 1.x and remove it in 2.x
Commits
-------
3779435 deprecated the String loader
This PR was merged into the 1.18-dev branch.
Discussion
----------
added PHP 7 nightly to the test matrix and HHVM nightly
Commits
-------
a1295e9 added PHP 7 nightly to the test matrix and HHVM nightly
This PR was merged into the 1.18-dev branch.
Discussion
----------
reduced the number of times error information has to be guessed
Commits
-------
651613c reduced the number of times error information should be guessed
This PR was merged into the 1.18-dev branch.
Discussion
----------
Updates slice so that it still accepts a SimpleXMLElement
Since #1503 you cannot pass a SimpleXMLElement to slice as you get:
Catchable fatal error: Argument 1 passed to LimitIterator::__construct() must implement interface Iterator, instance of SimpleXMLElement given
As SimpleXMLElement implements Traversable but not Iterator
This checks that $item is an instance of Iterator before passing to LimitIterator
Commits
-------
aea075b Updates slice so that it still accepts a SimpleXMLElement
This PR was squashed before being merged into the 1.18-dev branch (closes#1617).
Discussion
----------
Fix time sensitive profiler test (ready)
The profiler tests fail some times because of the performance of the machine these are run on.
These changes should provide stability.
Commits
-------
a80cb35 Fix time sensitive profiler test (ready)
This PR was squashed before being merged into the 1.18-dev branch (closes#1622).
Discussion
----------
[#1621] Failing tests for Filesystem loader
See #1621
Commits
-------
f7a49f2 [#1621] Failing tests for Filesystem loader
This PR was squashed before being merged into the 1.18-dev branch (closes#1609).
Discussion
----------
get PHP version info once on construction
| Q | A
| ------------- | ---
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
Hi,
I was profiling a project and noticed that `phpversion` was called 5000 times by Twig.
This patch reduces the amount of calls without breaking anything (I hope ;) )

Commits
-------
24ff698 get PHP version info once on construction
This PR was merged into the 1.18-dev branch.
Discussion
----------
fixed named args for static methods
This fixes an obscure reflection error that gets thrown if a functioned backed by a static method is called with named arguments.
Commits
-------
7868fe8 fixed named args for static methods
This PR was merged into the 1.18-dev branch.
Discussion
----------
Fixed wrong line numbers in error messages for multi-line statements
Partially fixes#1351
Commits
-------
08c5196 Fixed wrong line numbers in error messages for multi-line statements
This PR was merged into the 1.18-dev branch.
Discussion
----------
Improved named arguments
Commits
-------
e9b8bcc Fixed determining the necessary arguments for callable functions
5f4377b Improved an exception message for missing value of optional arguments