Fabien Potencier [Mon, 21 Nov 2011 08:02:49 +0000]
fixed previous merge and added some unit tests
Fabien Potencier [Mon, 21 Nov 2011 07:53:51 +0000]
merged branch shvchk/patch-2 (PR #522)
Commits
-------
5f30db0 !empty($date[0]) → !empty($date)
0182dbc indentation fix
c7a06cb php warning fix
a4a2d6f Support of negative timestamps
Discussion
----------
Support of negative timestamps
Date could be checked against this condition, as proposed in my patch:
```php
ctype_digit((string) $date)
|| (('-' === $date[0])
&& (ctype_digit(substr($date, 1))))
```
or this:
```php
preg_match('/^\-?\d+/', $date)
```
Second is maybe more readable, but 20% slower.
---------------------------------------------------------------------------
by nikic at 2011/11/20 01:59:16 -0800
Couldn't we do an int validation here? I.e. `if (false !== filter_var($date, FILTER_VALIDATE_INT)) { ... }`. That will allow both positive and negative integers in the allowed integer range. Note though that it will no longer allow ints starting with a zero (apart from zero itself). To support that one would need to pass the ALLOW_OCTAL flag.
Some tests: http://codepad.viper-7.com/w0MDTH
---------------------------------------------------------------------------
by damianb at 2011/11/20 07:50:39 -0800
@nikic why not `ctype_digit`?
---------------------------------------------------------------------------
by nikic at 2011/11/20 07:53:26 -0800
@damianb ctype_digit is what this PR wants to replace, because it does not allow negative numbers. Replacing it with `ctype_digit((string) $date) || (!empty($date[0]) && ('-' === $date[0]) && ctype_digit(substr($date, 1)))` seems like overkill to me though, that's why I proposed to use `false !== filter_var($date, FILTER_VALIDATE_INT)` instead, which apart from being shorter is also semantically more correct.
---------------------------------------------------------------------------
by damianb at 2011/11/20 08:03:09 -0800
@nikic But does filter_var with FILTER_VALIDATE_INT perform better than what's proposed?
Also, I would think that the `empty($date[0])` should just be replaced with an empty check on the `$date` var itself - seems quite pointless to check if the first character is empty, that'd imply that either a) the string itself is empty b) `date[0] == 0`, which could result in a nasty gotcha for someone down the road.
---------------------------------------------------------------------------
by shvchk at 2011/11/20 09:36:17 -0800
@damianb, you are right, I will update the code.
@nikic, on 32-bit systems ```PHP_INT_MAX``` is ```
2147483647```, so your code will fail on such systems for 01.01.1900, for example, which is ```-
2208988800``` and is not that rarely used.
Andrei Shevchuk [Sun, 20 Nov 2011 17:39:44 +0000]
!empty($date[0]) → !empty($date)
Andrei Shevchuk [Sun, 20 Nov 2011 11:26:45 +0000]
indentation fix
Andrei Shevchuk [Sun, 20 Nov 2011 11:18:57 +0000]
php warning fix
Fabien Potencier [Sun, 20 Nov 2011 09:41:28 +0000]
prepared the 1.4.0-RC1 release
Fabien Potencier [Sun, 20 Nov 2011 09:26:23 +0000]
adding more structure to the for doc
Fabien Potencier [Sun, 20 Nov 2011 09:20:20 +0000]
added a note about using the loop variable in a for condition
Andrei Shevchuk [Sun, 20 Nov 2011 09:08:58 +0000]
Support of negative timestamps
Fabien Potencier [Fri, 18 Nov 2011 20:54:44 +0000]
optimized variable access when using PHP 5.4
Fabien Potencier [Wed, 16 Nov 2011 07:07:47 +0000]
fixed a warning (PHP 5.4)
Fabien Potencier [Sat, 12 Nov 2011 11:18:12 +0000]
merged branch arnaud-lb/test-fix (PR #513)
Commits
-------
9b4e298 fixed failing test
Discussion
----------
fixed failing test
Arnaud Le Blanc [Sat, 12 Nov 2011 11:01:31 +0000]
fixed failing test
Fabien Potencier [Thu, 10 Nov 2011 11:53:56 +0000]
fixed typo
Fabien Potencier [Tue, 8 Nov 2011 12:22:31 +0000]
merged branch henrikbjorn/composer-autoload (PR #509)
Commits
-------
cf66a05 Add Autoloadig instructions for Composer
Discussion
----------
Add Autoloadig instructions for Composer
Add psr-0 autoload directive to composer.json for easier Autoloading
when using Composer as a package management tool
Henrik Bjørnskov [Tue, 8 Nov 2011 10:58:02 +0000]
Add Autoloadig instructions for Composer
Add psr-0 autoload directive to composer.json for easier Autoloading
when using Composer as a package management tool
Fabien Potencier [Mon, 7 Nov 2011 21:27:18 +0000]
merged branch craue/patch-1 (PR #507)
Commits
-------
98a859b fixed link name for `extends` tag
Discussion
----------
fixed link name for `extends` tag
Christian Raue [Mon, 7 Nov 2011 21:04:12 +0000]
fixed link name for `extends` tag
Fabien Potencier [Mon, 7 Nov 2011 19:00:46 +0000]
removed json_encode call in Twig_Error when the filename is a string (to avoid the escaping of /)
Fabien Potencier [Mon, 7 Nov 2011 13:46:38 +0000]
fixed operator precedences in the doc
Fabien Potencier [Mon, 7 Nov 2011 13:18:48 +0000]
converted item parameter of Twig_Template::getAttribute() to string
Fabien Potencier [Sat, 5 Nov 2011 08:49:18 +0000]
fixed for tag loop variable when using a condition
Fabien Potencier [Sat, 5 Nov 2011 07:54:48 +0000]
refactored "for" tag (moved some logic from the token parser to the node)
Fabien Potencier [Sat, 5 Nov 2011 07:30:08 +0000]
changed the precedence of the .. operator
Fabien Potencier [Sat, 5 Nov 2011 07:07:20 +0000]
fixed a typo in the doc
Fabien Potencier [Sat, 5 Nov 2011 07:03:53 +0000]
updated CHANGELOG
Fabien Potencier [Sat, 5 Nov 2011 07:02:41 +0000]
merged branch hason/arrayloader (PR #496)
Commits
-------
253f813 added an exception for undefined templates in ArrayLoader::isFresh
Discussion
----------
added an exception for undefined templates in ArrayLoader::isFresh
Fabien Potencier [Sat, 5 Nov 2011 07:01:41 +0000]
merged branch trompette/patch-2 (PR #501)
Commits
-------
36020a9 typo
Discussion
----------
typo
Benoît Merlet [Fri, 4 Nov 2011 23:48:00 +0000]
typo
Fabien Potencier [Fri, 4 Nov 2011 12:32:43 +0000]
fixed for tag when using a condition with strict_variables set to false
Martin Hasoň [Thu, 3 Nov 2011 11:01:29 +0000]
added an exception for undefined templates in ArrayLoader::isFresh
Fabien Potencier [Tue, 1 Nov 2011 10:54:32 +0000]
refactored code
Fabien Potencier [Tue, 1 Nov 2011 10:49:04 +0000]
added Twig_Function_Node to allow more complex functions to have their own Node class
Fabien Potencier [Tue, 1 Nov 2011 08:31:49 +0000]
added Twig_Filter_Node to allow more complex tests to have their own Node class (the default filter has been converted to use this new feature)
Fabien Potencier [Tue, 1 Nov 2011 10:29:09 +0000]
removed a function that is not used anymore
Fabien Potencier [Tue, 1 Nov 2011 07:57:23 +0000]
migrated most tests to proper Node classes
Fabien Potencier [Tue, 1 Nov 2011 07:43:09 +0000]
moved the defined test to a Twig_Test_Node class
Fabien Potencier [Mon, 31 Oct 2011 19:57:30 +0000]
added Twig_Test_Node to allow more complex tests to have their own Node class (sameas has been converted as an example)
Fabien Potencier [Mon, 31 Oct 2011 17:46:05 +0000]
added a better error message when a template is empty but contain a BOM
Fabien Potencier [Mon, 31 Oct 2011 08:05:09 +0000]
optimized tokenizer by pre-computing all start tag positions (memory and CPU)
Fabien Potencier [Sun, 30 Oct 2011 22:07:03 +0000]
optimized a comparison in the tokenizer
Fabien Potencier [Sun, 30 Oct 2011 13:47:32 +0000]
added notes in the doc about how the defined test and the default filter work
Fabien Potencier [Sun, 30 Oct 2011 13:46:53 +0000]
merged branch nikic/allowIsDefinedOnMethods (PR #490)
Commits
-------
930330f Allow defined test and default filter on methods
Discussion
----------
Allow defined test and default filter on methods
Patch for #487.
---------------------------------------------------------------------------
by fabpot at 2011/10/30 03:45:49 -0700
Problem is when some of the arguments reference variables that do not exist (`foo.bar(bar.foobar)`). That's why I've added the check on arguments.
---------------------------------------------------------------------------
by nikic at 2011/10/30 03:58:58 -0700
@fabpot I'm not exactly sure what is the expected behavior in that case. When writing `foo.defined(undefined)|default()` I think an exception is the expected behavior (because there is an undefined variable without default, even if it is in the method arguments). With `foo.undefined(undefined)|default()` on the other hand I'm not sure. One could argue that as the method does not exist the arguments never need to be evaluated.
---------------------------------------------------------------------------
by fabpot at 2011/10/30 05:49:46 -0700
The same code is used for the `defined` test: what would be the expected behavior for `foo.defined(underfined) is defined`?
Fabien Potencier [Sun, 30 Oct 2011 10:43:00 +0000]
merged branch nikic/patch-1 (PR #489)
Commits
-------
7da9f2f Make long var/block tests faster
Discussion
----------
Make long var/block tests faster
When using `*` every single character is a different token, whereas with `x` there is only a single token. I don't think this hurts the actual test, but it improves the test runtime by something like 2/3 seconds on my machine.
nikic [Sun, 30 Oct 2011 10:19:27 +0000]
Allow defined test and default filter on methods
nikic [Sun, 30 Oct 2011 10:03:56 +0000]
Make long var/block tests faster
Fabien Potencier [Sat, 29 Oct 2011 13:12:58 +0000]
fixed previous commit
Fabien Potencier [Sat, 29 Oct 2011 12:56:00 +0000]
renamed none to null in doc
Fabien Potencier [Sat, 29 Oct 2011 12:53:37 +0000]
changed the documentation to advertize null as begin the null value and none as an alias
Fabien Potencier [Sat, 29 Oct 2011 12:50:10 +0000]
fixed in operator for empty strings
Fabien Potencier [Sat, 29 Oct 2011 12:38:23 +0000]
merged branch nikic/updateExtensionDocs (PR #488)
Commits
-------
2ebc788 Update extension docs and interface
Discussion
----------
Update extension docs and interface
Followup to #484: Twig isn't using globals for functions anymore.
nikic [Sat, 29 Oct 2011 12:05:14 +0000]
Update extension docs and interface
Twig isn't using globals for functions anymore.
Fabien Potencier [Fri, 28 Oct 2011 15:23:01 +0000]
fixed typo in doc
Fabien Potencier [Thu, 27 Oct 2011 19:47:32 +0000]
merged branch phmLabs/documentation_return (PR #483)
Commits
-------
389f2c2 Changed mode from 0755 to 0644
c48bd2f Fixed wrong used PHPDoc tags
Discussion
----------
Fixed wrong used PHPDoc tags
@param was used instead of @return
---------------------------------------------------------------------------
by fabpot at 2011/10/25 05:47:59 -0700
Can you revert the mode change (from 0644 to 0755)?
Fabien Potencier [Thu, 27 Oct 2011 16:30:53 +0000]
added more unit tests for defined and default
Fabien Potencier [Thu, 27 Oct 2011 16:23:43 +0000]
fixed the "defined" test and the "default" filter
Fabien Potencier [Wed, 26 Oct 2011 20:04:54 +0000]
added more unit tests (some do not pass... yet)
Fabien Potencier [Wed, 26 Oct 2011 09:28:33 +0000]
added missing supported charset for htmlspecialchars
Fabien Potencier [Wed, 26 Oct 2011 07:33:02 +0000]
fixed deep nested defined tests
Fabien Potencier [Wed, 26 Oct 2011 08:27:18 +0000]
removed unneeded complexity in GetAttr node
Fabien Potencier [Wed, 26 Oct 2011 07:29:16 +0000]
added a way to change Twig's options when running integration tests (updated tests accordingly)
Fabien Potencier [Wed, 26 Oct 2011 06:05:11 +0000]
Revert "fixed exception"
This reverts commit
df47659e9de71a48a24f31ed0cc16a2674a06d43.
Fabien Potencier [Tue, 25 Oct 2011 15:37:58 +0000]
fixed example in doc (closes #484)
Nils Langner [Tue, 25 Oct 2011 14:49:17 +0000]
Changed mode from 0755 to 0644
Fabien Potencier [Tue, 25 Oct 2011 14:33:42 +0000]
added some references to the doc
Nils Langner [Tue, 25 Oct 2011 12:32:16 +0000]
Fixed wrong used PHPDoc tags
Fabien Potencier [Tue, 25 Oct 2011 12:23:37 +0000]
reverted mode change from previous commit
Fabien Potencier [Tue, 25 Oct 2011 12:23:22 +0000]
merged branch phmLabs/Twig_NodeInterface_Bug (PR #482)
Commits
-------
c91357d Moved interfaces
Discussion
----------
Moved interfaces
The Countable and IteratorAggregate interfaces have to be part of the Twig_NodeInterface as the Twig_NodeInterface is used as a typehint and the function tries to iterate over its elements.
E.g:
Twig_NodeTraverser::traverseForVisitor
foreach ($node as $k => $n)
Fabien Potencier [Tue, 25 Oct 2011 12:14:55 +0000]
Revert "added a tip for the block tag"
This reverts commit
1a2175fc4992b74a473845eab0972d464086398f.
Nils Langner [Tue, 25 Oct 2011 12:13:26 +0000]
Moved interfaces
Fabien Potencier [Tue, 25 Oct 2011 12:11:52 +0000]
added a tip for the block tag
Fabien Potencier [Tue, 25 Oct 2011 12:01:54 +0000]
merged branch yegeniy/patch-1 (PR #474)
Commits
-------
cf03a65 add another example add another example to constant.rst
Discussion
----------
add another example
An example for using the `constant` function
---------------------------------------------------------------------------
by yegeniy at 2011/10/19 09:48:37 -0700
Should be ready.
---------------------------------------------------------------------------
by nikic at 2011/10/19 10:58:01 -0700
I think you should just add that as a line to the other example, so you got this in the end:
```rst
``constant``
============
``constant`` returns the constant value for a given string:
.. code-block:: jinja
{{ some_date|date(constant('DATE_W3C')) }}
{{ constant('Namespace\\Classname::CONSTANT_NAME') }}
```
---------------------------------------------------------------------------
by fabpot at 2011/10/21 07:24:32 -0700
That's indeed a good addition to the doc. Can you squash your commits in to one before I merge this pull request? Thanks.
---------------------------------------------------------------------------
by yegeniy at 2011/10/22 06:28:58 -0700
Thanks!
Fabien Potencier [Tue, 25 Oct 2011 11:59:24 +0000]
fixed typos
Fabien Potencier [Tue, 25 Oct 2011 11:58:27 +0000]
changed the way extensions are loaded (addFilter/addFunction/addGlobal/addTest/addNodeVisitor/addTokenParser/addExtension can now be called in any order)
Eugene Wolfson [Tue, 18 Oct 2011 22:47:02 +0000]
add another example
add another example to constant.rst
Fabien Potencier [Mon, 17 Oct 2011 11:01:40 +0000]
added Twig_Environment::display()
Fabien Potencier [Mon, 17 Oct 2011 00:48:36 +0000]
simplified some code
Fabien Potencier [Sun, 16 Oct 2011 23:16:34 +0000]
added more unit tests
Fabien Potencier [Sun, 16 Oct 2011 20:18:02 +0000]
added an optimization when the same temporary variable would have been created twice
Fabien Potencier [Sun, 16 Oct 2011 09:15:40 +0000]
fixed doc
Fabien Potencier [Sun, 16 Oct 2011 09:09:54 +0000]
made the escape filter smarter when the encoding is not supported by PHP
Fabien Potencier [Sun, 16 Oct 2011 09:08:36 +0000]
added a convert_encoding filter
Fabien Potencier [Sun, 16 Oct 2011 03:46:09 +0000]
added a Twig_Node_Expression_DefaultFilter to replace the current way of dealing with default filters
Fabien Potencier [Sat, 15 Oct 2011 08:57:18 +0000]
added public getters on the environment to be able to get various stuff
Fabien Potencier [Fri, 14 Oct 2011 23:10:30 +0000]
fixed exception
Fabien Potencier [Fri, 14 Oct 2011 09:46:15 +0000]
fixed download page in the docs
Fabien Potencier [Thu, 13 Oct 2011 06:20:40 +0000]
merged branch trompette/patch-1 (PR #465)
Commits
-------
0451cfd typo
Discussion
----------
typo
Benoît Merlet [Wed, 12 Oct 2011 12:45:28 +0000]
typo
Fabien Potencier [Sat, 8 Oct 2011 12:30:37 +0000]
updated CHANGELOG
Fabien Potencier [Thu, 6 Oct 2011 17:22:19 +0000]
refactored Twig_Node_Expression_GetAttr for better readability of compiled templates
Fabien Potencier [Fri, 30 Sep 2011 15:04:06 +0000]
optimized variable access when possible
Fabien Potencier [Thu, 6 Oct 2011 14:37:14 +0000]
refactored 'defined' test and 'default' filter
Node manipulations have been moved outside the compile() method.
That's needed if we want to be able to visit all nodes that will be
compiled.
Fabien Potencier [Thu, 6 Oct 2011 13:01:29 +0000]
optimized lexer by pre-computing regexes
Fabien Potencier [Thu, 6 Oct 2011 11:13:28 +0000]
made an optimization by removing array_merge usage
Fabien Potencier [Sat, 8 Oct 2011 12:05:18 +0000]
bumped version to 1.4.0-DEV
Fabien Potencier [Sat, 8 Oct 2011 12:04:10 +0000]
prepared the 1.3.0-RC1 release
Fabien Potencier [Sat, 8 Oct 2011 12:03:38 +0000]
updated CHANGELOG
Fabien Potencier [Tue, 4 Oct 2011 07:58:29 +0000]
prepared the 1.3.0-RC1 release
Fabien Potencier [Mon, 3 Oct 2011 21:08:58 +0000]
fixed a unit test for PHPUnit 3.6
Fabien Potencier [Fri, 30 Sep 2011 20:49:47 +0000]
fixed optimizer