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.
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
Commits
-------
253f813 added an exception for undefined templates in ArrayLoader::isFresh
Discussion
----------
added an exception for undefined templates in ArrayLoader::isFresh
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`?
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.