Commit Graph

1058 Commits

Author SHA1 Message Date
Arjen Brouwer 09d3095b66 Moved zval declaration 2011-11-21 23:57:44 +01:00
Arjen Brouwer c9415522a9 Removed globals 2011-11-21 23:56:11 +01:00
Arjen Brouwer ffb246083a Added config.w32 for windows builds 2011-11-21 23:54:57 +01:00
Fabien Potencier 82e3ecc6da added more unit tests 2011-11-21 14:50:30 +01:00
Fabien Potencier 0ad6075ac5 merged branch pierrejoye/master (PR #527)
Commits
-------

115edf2 - fix property access when the instance implements Iterator or similar cases, by using get_object_vars instead, thx Arnaud Leblanc for the hint.

Discussion
----------

Fix props detection for instances implementing Iterator or similar cases

Fix property access when the instance implements Iterator or similar cases, by using get_object_vars instead, thx Arnaud Leblanc for the hint.
2011-11-21 14:06:01 +01:00
Pierre Joye 115edf2a71 - fix property access when the instance implements Iterator or similar cases, by using get_object_vars instead, thx Arnaud Leblanc for the hint. 2011-11-21 14:02:02 +01:00
Fabien Potencier 7bc07dc132 removed usage of Reflection in Twig_Template::getAttribute() (thanks Pierre Joye for the property tip) 2011-11-21 10:46:19 +01:00
Derick Rethans 7a2c444054 Fixed name in license. 2011-11-21 09:44:40 +01:00
Fabien Potencier 49bd3a39bd fixed typo 2011-11-21 09:41:49 +01:00
Fabien Potencier fc6819cec2 added support for twig C extension 2011-11-21 09:36:32 +01:00
Fabien Potencier 723da85e4c merged branch derickr/master (PR #524)
Commits
-------

229c07c Added another workaround for PHP 5.4 support.
c4055d2 Merge branch 'master' of github.com:derickr/twig-ext
f7f8346 Switch LICENSE to Revised BSD.
16ca055 Move files into ext/twig.
699e123 Allow any, but the first two arguments to be optional.
952fe6f Added missing format specifier to parseparameters.
7cc2808 Added support for the new argument called 'ignoreStrictCheck'.
b7b260b Fixed exception message issue with an array element that didn't exist and strict variables checking turned on.
634d8ae Fixed compiler warnings
7077811 PHP 5.4 compatibility.
05cb73f More PHP 5.2 compatibility.
163f806 PHP 5.2 compatibility.
8e11c14 Sigh, stupid copy and paste error prevented the last tests from passing. All is well now.
2dffee9 Added a return so that the function ends after throwing an exception. This fixes a segfault too.
e9c3eda - Fixed code that was previously never hit.
53e1652 Implement HAS_PROPERTY to distinguish between not-set and NULL.
541f6c8 Use "isset" logic as fetch always works, even for elements that don't exist and they then just become NULL.
a36d11b Fixed memory leaks.
cbd975a Use the proper zend hash function here.
7b38766 Handle numeric keys for array elements too.
49b885c After instantiating the object, call the constructor and make sure we return from the function.
0ee71a7 Added TWIG_CALL_Z (to use for calling a function with one argument).
52b9ae4 Bailout when we have an exception to defer to PHP's exception handlers.
9facb8d Split TWIG_CALL_S into TWIG_CALL_S and TWIG_CALL_SB for boolean returning functions.
b8b89f6 Fixed the uninitialized ptr check. This makes all tests in Twig_TemplateTest pass!
9096e3f Use strtolower on the method names and add them as associative keys so that they are found.
0b6cefb Fixed TWIG_PROPERTY to return a NULL instead of a zval(NULL).
1e726f4 Those are array elements and not properties.
9f6495f Return the value immediately.
f7ae76e Check the property regardless of whether tmp_item is valid/set.
3c208ff We need to use strlen on hash keys.
7d36def Split TWIG_PROPERTY into TWIG_PROPERTY and TWIG_PROPERTY_CHAR so the array key can be both a zval or char.
508bb66 Made properties return properly.
4e899ca Add the properties as assoc keys, so that hash_find actually works on them.
63e1f12 Check normal property before trying to de-mangle it.
9d22fdd Fixed TWIG_GET_ARRAY_ELEMENT_ZVAL's return value.
48b0a5f Fixed compiler warning.
f19ec8a Implemented first bit for ArrayAccess support.
f196f01 Initialise variable to NULL.
803c1a9 Apparently this is needed for GCC to not optimise it out...
078690b - Remove debugging code.
1b55c97 Only add the object to the cache if there is actually an object.
f42cd14 Fix efree(NULL) when no arguments are passed in.
577169c Added missing header and switch arguments for the return around as I got that wrong.
2b58fec Added support for NULL arguments to CALL_USER_FUNC_ARRAY and made CALL_BOOLEAN use that.
f7fc1ff Fold TWIG_GET_ARRAY_ELEMENT and TWIG_PROPERTY into one worker function.
6e1dd56 Implement TWIG_GET_CLASS_NAME and make use of it.
b891ad9 Initialise ret to NULL.
828c113 Get rid of TWIG_RETURN_ARRAY_ELEMENT and use TWIG_GET_ARRAY_ELEMENT instead.
0cc719a Implemented TWIG_THROW_EXCEPTION.
701be8b Implemented TWIG_IMPLODE_ARRAY_KEYS.
3da24d9 Fixed logic and implemented normal array key return.
b918f2e Implemented TWIG_RETURN_ARRAY_ELEMENT.
e1663e8 Re-scope variables.
8bc1f02 Added the cache creating/fetching method in the code.
7367cf9 Added the cache fetching method for methods and properties.
9d40c9f Implemented TWIG_CALL_USER_FUNC_ARRAY, TWIG_GET_STATIC_PROPERTY, TWIG_GET_ARRAY_ELEMENT_ZVAL and TWIG_GET_ARRAY_ELEMENT.
2078e50 - Implemented the strtolower function.
e133074 - The extension now loads and  the pseudo code is mostly ready.
1b96539 - The parse parameters line was wrong, it still had the extra one that was   removed in Twig itself already.
d082244 - Used the template, instead of getThis(), which wouldn't exist.
07e38ef - Added more generated files to .gitignore
6aa1a64 - Stubs and more implementations.
79f6dc6 - Implement TWIG_INSTANCEOF_*
19fbee7 - Implemented TWIG_ARRAY_KEY_EXISTS (for normal arrays only).
4de3659 - Reduce compile warnings and errors. - Initialize the two method names.
a2f3c34 - Added more files to .gitignore
fad8e9a - Fixed ARG INFO
15de533 - Added pseudo code
bfc6e34 - Added a .gitignore file
75d3e66 - Updated with new code from Fabien's repository.
6edc311 - Some scaffolding implementation.
979d6ec - Added broken down original code.
e19701d - Added function declaration and headers.
430aecf - Added basic twig extension structure.

Discussion
----------

The twig extension put into ext/twig.

Hi!

Here is the twig extension as pull-request. I'll make a separate pull request for the PHP 5.4 issue that you mailed.

cheers,
Derick

---------------------------------------------------------------------------

by fzaninotto at 2011/11/20 13:40:07 -0800

Incredible!

Question: What's the plan for maintaining this as the PHP code continues to evolve?

---------------------------------------------------------------------------

by derickr at 2011/11/20 13:43:47 -0800

@fzninotto: That's still something that we need to figure out. It's just one method but yes, it does need to keep updated if the PHP's code semantics change of course.

---------------------------------------------------------------------------

by stof at 2011/11/20 13:50:03 -0800

This should be done as a separate repo IMO. People using the PHP version of Twig really don't need all the C code when cloning.

---------------------------------------------------------------------------

by derickr at 2011/11/20 13:53:23 -0800

@stof That's what I thought too, but Fabien asked me to do this. I've a repository for just the ext at https://github.com/derickr/twig-ext

---------------------------------------------------------------------------

by stof at 2011/11/20 13:54:00 -0800

@derick the link you gave is a 404

---------------------------------------------------------------------------

by derickr at 2011/11/20 14:00:36 -0800

@stof Ah, it was still private. *fixed*

---------------------------------------------------------------------------

by hhamon at 2011/11/20 21:05:49 -0800

That's awesome!!!

---------------------------------------------------------------------------

by beberlei at 2011/11/20 22:37:40 -0800

<3

---------------------------------------------------------------------------

by jmikola at 2011/11/20 22:42:45 -0800

👍

---------------------------------------------------------------------------

by dustinwhittle at 2011/11/20 22:51:37 -0800

Thanks for porting!

---------------------------------------------------------------------------

by trompette at 2011/11/20 23:28:54 -0800

It needs some serious documentation effort, bat that's awsome!

---------------------------------------------------------------------------

by fabpot at 2011/11/20 23:43:42 -0800

@stof: this is really just 3 small files, so it does not hurt to have them in the main repo. Having just one repo also eases the maintenance ans usage as when you switch from one version to another, you are sure to have the right version of the C code as well.

@fzaninotto: SensioLabs sponsored the port of the `Twig_Template::getAttribute()` method as this is the biggest bottleneck for Twig. The maintenance should probably be done by the community from now on; but anyway, SensioLabs will continue to sponsor it if needed.

---------------------------------------------------------------------------

by henrikbjorn at 2011/11/20 23:56:46 -0800

Have any gotten this to build succesfully ?

---------------------------------------------------------------------------

by fabpot at 2011/11/21 00:06:15 -0800

@henrikbjorn: we have tested it on PHP 5.2/5.3/5.4 on both Linux and Mac (we have not tried it on Windows though).

---------------------------------------------------------------------------

by tecbot at 2011/11/21 00:33:05 -0800

👍
2011-11-21 09:34:50 +01:00
Fabien Potencier 9d2272efbf fixed previous merge and added some unit tests 2011-11-21 09:04:06 +01:00
Fabien Potencier b76a574944 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.
2011-11-21 08:53:51 +01:00
Derick Rethans 229c07c6a6 Added another workaround for PHP 5.4 support. 2011-11-20 21:41:07 +00:00
Derick Rethans c4055d2eb0 Merge branch 'master' of github.com:derickr/twig-ext 2011-11-20 21:29:14 +00:00
Derick Rethans f7f8346d37 Switch LICENSE to Revised BSD. 2011-11-20 21:26:21 +00:00
Derick Rethans 16ca05529c Move files into ext/twig. 2011-11-20 21:25:05 +00:00
Andrei Shevchuk 5f30db0f41 !empty($date[0]) → !empty($date) 2011-11-20 21:39:44 +04:00
Andrei Shevchuk 0182dbc3db indentation fix 2011-11-20 15:26:45 +04:00
Andrei Shevchuk c7a06cbbfe php warning fix 2011-11-20 15:18:57 +04:00
Fabien Potencier 2e268ccd9b prepared the 1.4.0-RC1 release v1.4.0-RC1 2011-11-20 10:41:28 +01:00
Fabien Potencier c3eceb4826 adding more structure to the for doc 2011-11-20 10:26:23 +01:00
Fabien Potencier f0e751aed9 added a note about using the loop variable in a for condition 2011-11-20 10:21:02 +01:00
Andrei Shevchuk a4a2d6f763 Support of negative timestamps 2011-11-20 13:08:58 +04:00
Fabien Potencier 1b32617b97 optimized variable access when using PHP 5.4 2011-11-18 22:31:28 +01:00
Fabien Potencier 8ac3603a8b fixed a warning (PHP 5.4) 2011-11-16 08:07:47 +01:00
Fabien Potencier 684970530d merged branch arnaud-lb/test-fix (PR #513)
Commits
-------

9b4e298 fixed failing test

Discussion
----------

fixed failing test
2011-11-12 12:18:12 +01:00
Arnaud Le Blanc 9b4e298e8e fixed failing test 2011-11-12 12:01:31 +01:00
Fabien Potencier 65f09ac724 fixed typo 2011-11-10 12:53:56 +01:00
Fabien Potencier 4655dbbe42 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
2011-11-08 13:22:31 +01:00
Henrik Bjørnskov cf66a054b8 Add Autoloadig instructions for Composer
Add psr-0 autoload directive to composer.json for easier Autoloading
when using Composer as a package management tool
2011-11-08 11:58:02 +01:00
Fabien Potencier 12addb3a1f merged branch craue/patch-1 (PR #507)
Commits
-------

98a859b fixed link name for `extends` tag

Discussion
----------

fixed link name for `extends` tag
2011-11-07 22:27:18 +01:00
Christian Raue 98a859b424 fixed link name for extends tag 2011-11-07 22:04:12 +01:00
Fabien Potencier 0cbb13d8fa removed json_encode call in Twig_Error when the filename is a string (to avoid the escaping of /) 2011-11-07 20:00:46 +01:00
Fabien Potencier 24eea1615a fixed operator precedences in the doc 2011-11-07 14:46:38 +01:00
Fabien Potencier aa6b835816 converted item parameter of Twig_Template::getAttribute() to string 2011-11-07 14:18:48 +01:00
Fabien Potencier 40595b848e fixed for tag loop variable when using a condition 2011-11-07 14:01:06 +01:00
Fabien Potencier 25336fd6fd refactored "for" tag (moved some logic from the token parser to the node) 2011-11-07 13:45:45 +01:00
Fabien Potencier 10c799fd90 changed the precedence of the .. operator 2011-11-05 08:30:08 +01:00
Fabien Potencier ace74cc6a0 fixed a typo in the doc 2011-11-05 08:07:20 +01:00
Fabien Potencier a3fcbd62cb updated CHANGELOG 2011-11-05 08:03:53 +01:00
Fabien Potencier f3f5afbb13 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
2011-11-05 08:02:41 +01:00
Fabien Potencier 8a102b51b5 merged branch trompette/patch-2 (PR #501)
Commits
-------

36020a9 typo

Discussion
----------

typo
2011-11-05 08:01:41 +01:00
Benoît Merlet 36020a95c0 typo 2011-11-05 00:48:00 +01:00
Fabien Potencier 23813770de fixed for tag when using a condition with strict_variables set to false 2011-11-04 13:32:43 +01:00
Martin Hasoň 253f8136c5 added an exception for undefined templates in ArrayLoader::isFresh 2011-11-03 12:01:29 +01:00
Fabien Potencier 103e857290 refactored code 2011-11-01 11:56:04 +01:00
Fabien Potencier 9117fc1ce0 added Twig_Function_Node to allow more complex functions to have their own Node class 2011-11-01 11:49:04 +01:00
Fabien Potencier 3427adc7ec 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) 2011-11-01 11:48:05 +01:00
Fabien Potencier d1b5832ccd removed a function that is not used anymore 2011-11-01 11:29:09 +01:00