Merge branch '1.x' into 2.x

* 1.x:
  reworded docs
  Update number_format.rst
  fixed tests for PHP 7.2
  dropped support for HHVM
This commit is contained in:
Fabien Potencier
2017-05-22 08:17:55 +02:00
8 changed files with 34 additions and 45 deletions
+7 -8
View File
@@ -9,21 +9,20 @@ cache:
matrix:
include:
- php: hhvm-stable
sudo: required
dist: trusty
- php: 7.0
- php: 7.1
- php: nightly
allow_failures:
- php: hhvm-stable
fast_finish: true
before_install:
- if [[ ! $TRAVIS_PHP_VERSION = hhvm* ]]; then phpenv config-rm xdebug.ini || echo "xdebug not available"; fi
- if [[ $TRAVIS_PHP_VERSION = hhvm* ]]; then echo hhvm.php7.all=1 >> /etc/hhvm/php.ini; fi
- phpenv config-rm xdebug.ini
install:
- travis_retry composer install
script: ./vendor/bin/simple-phpunit
script: |
if [[ $TRAVIS_PHP_VERSION = 7.* || $TRAVIS_PHP_VERSION = nightly ]]; then
SYMFONY_PHPUNIT_VERSION=6.1 ./vendor/bin/simple-phpunit
else
./vendor/bin/simple-phpunit
fi
+1
View File
@@ -53,6 +53,7 @@
* 1.34.0 (2017-XX-XX)
* dropped HHVM support
* dropped PHP 5.2 support
* 1.33.2 (2017-04-20)
+8
View File
@@ -15,6 +15,14 @@ separator using the additional arguments:
{{ 9800.333|number_format(2, '.', ',') }}
To format negative numbers, wrap the number with parentheses (needed because of
Twig's :ref:`precedence of operators <twig-expressions>`:
.. code-block:: jinja
{{ -9800.333|number_format(2, '.', ',') }} {# outputs : -9 #}
{{ (-9800.333)|number_format(2, '.', ',') }} {# outputs : -9.800,33 #}
If no formatting options are provided then Twig will use the default formatting
options of:
-5
View File
@@ -234,11 +234,6 @@ class Twig_Error extends Exception
$r = new ReflectionObject($template);
$file = $r->getFileName();
// hhvm has a bug where eval'ed files comes out as the current directory
if (is_dir($file)) {
$file = '';
}
$exceptions = array($e = $this);
while ($e = $e->getPrevious()) {
$exceptions[] = $e;
+16 -24
View File
@@ -913,30 +913,22 @@ function twig_escape_filter(Twig_Environment $env, $string, $strategy = 'html',
// Using a static variable to avoid initializing the array
// each time the function is called. Moving the declaration on the
// top of the function slow downs other escaping strategies.
static $htmlspecialcharsCharsets;
if (null === $htmlspecialcharsCharsets) {
if (defined('HHVM_VERSION')) {
$htmlspecialcharsCharsets = array('utf-8' => true, 'UTF-8' => true);
} else {
$htmlspecialcharsCharsets = array(
'ISO-8859-1' => true, 'ISO8859-1' => true,
'ISO-8859-15' => true, 'ISO8859-15' => true,
'utf-8' => true, 'UTF-8' => true,
'CP866' => true, 'IBM866' => true, '866' => true,
'CP1251' => true, 'WINDOWS-1251' => true, 'WIN-1251' => true,
'1251' => true,
'CP1252' => true, 'WINDOWS-1252' => true, '1252' => true,
'KOI8-R' => true, 'KOI8-RU' => true, 'KOI8R' => true,
'BIG5' => true, '950' => true,
'GB2312' => true, '936' => true,
'BIG5-HKSCS' => true,
'SHIFT_JIS' => true, 'SJIS' => true, '932' => true,
'EUC-JP' => true, 'EUCJP' => true,
'ISO8859-5' => true, 'ISO-8859-5' => true, 'MACROMAN' => true,
);
}
}
static $htmlspecialcharsCharsets = array(
'ISO-8859-1' => true, 'ISO8859-1' => true,
'ISO-8859-15' => true, 'ISO8859-15' => true,
'utf-8' => true, 'UTF-8' => true,
'CP866' => true, 'IBM866' => true, '866' => true,
'CP1251' => true, 'WINDOWS-1251' => true, 'WIN-1251' => true,
'1251' => true,
'CP1252' => true, 'WINDOWS-1252' => true, '1252' => true,
'KOI8-R' => true, 'KOI8-RU' => true, 'KOI8R' => true,
'BIG5' => true, '950' => true,
'GB2312' => true, '936' => true,
'BIG5-HKSCS' => true,
'SHIFT_JIS' => true, 'SJIS' => true, '932' => true,
'EUC-JP' => true, 'EUCJP' => true,
'ISO8859-5' => true, 'ISO-8859-5' => true, 'MACROMAN' => true,
);
if (isset($htmlspecialcharsCharsets[$charset])) {
return htmlspecialchars($string, ENT_QUOTES | ENT_SUBSTITUTE, $charset);
@@ -7,6 +7,7 @@
{{ date(date3) == date('2010-10-04 13:45') ? 'OK' : 'KO' }}
{{ date(date4) == date('2010-10-04 13:45') ? 'OK' : 'KO' }}
{{ date(date5) == date('1964-01-02 03:04') ? 'OK' : 'KO' }}
{{ date() > date('-1day') ? 'OK' : 'KO' }}
--DATA--
date_default_timezone_set('UTC');
return array(
@@ -23,3 +24,4 @@ OK
OK
OK
OK
OK
-4
View File
@@ -13,10 +13,6 @@ class Twig_Tests_NativeExtensionTest extends PHPUnit_Framework_TestCase
{
public function testGetProperties()
{
if (defined('HHVM_VERSION')) {
$this->markTestSkipped('Skip under HHVM as the behavior is not the same as plain PHP (which is an edge case anyway)');
}
$twig = new Twig_Environment(new Twig_Loader_Array(array('index' => '{{ d1.date }}{{ d2.date }}')), array(
'debug' => true,
'cache' => false,
@@ -63,10 +63,6 @@ class Twig_Tests_Node_Expression_CallTest extends PHPUnit_Framework_TestCase
*/
public function testResolveArgumentsWithMissingValueForOptionalArgument()
{
if (defined('HHVM_VERSION')) {
$this->markTestSkipped('Skip under HHVM as the behavior is not the same as plain PHP (which is an edge case anyway)');
}
$node = new Twig_Tests_Node_Expression_Call(array(), array('type' => 'function', 'name' => 'substr_compare'));
$this->getArguments($node, array('substr_compare', array('abcd', 'bc', 'offset' => 1, 'case_sensitivity' => true)));
}