Skip to content

Commit

Permalink
feature #2478 Drop support for HHVM (fabpot)
Browse files Browse the repository at this point in the history
This PR was squashed before being merged into the 1.x branch (closes #2478).

Discussion
----------

Drop support for HHVM

Commits
-------

b6a4895 fixed tests for PHP 7.2
6ff8d6f dropped support for HHVM
  • Loading branch information
fabpot committed May 22, 2017
2 parents 860f801 + b6a4895 commit c6bd2df
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 45 deletions.
12 changes: 7 additions & 5 deletions .travis.yml
Expand Up @@ -15,14 +15,13 @@ php:
- 7.0
- 7.1
- nightly
- hhvm

env:
- TWIG_EXT=no
- TWIG_EXT=yes

before_install:
- if [[ ! $TRAVIS_PHP_VERSION = hhvm* ]]; then phpenv config-rm xdebug.ini || echo "xdebug not available"; fi
- phpenv config-rm xdebug.ini

install:
- travis_retry composer install
Expand All @@ -31,13 +30,16 @@ before_script:
- if [ "$TWIG_EXT" == "yes" ]; then sh -c "cd ext/twig && phpize && ./configure --enable-twig && make && make install"; fi
- if [ "$TWIG_EXT" == "yes" ]; then echo "extension=twig.so" >> `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"`; fi

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
matrix:
fast_finish: true
exclude:
- php: hhvm
env: TWIG_EXT=yes
- php: 7.0
env: TWIG_EXT=yes
- php: 7.1
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG
@@ -1,5 +1,6 @@
* 1.34.0 (2017-XX-XX)

* dropped HHVM support
* dropped PHP 5.2 support

* 1.33.2 (2017-04-20)
Expand Down
5 changes: 0 additions & 5 deletions lib/Twig/Error.php
Expand Up @@ -332,11 +332,6 @@ protected function guessTemplateInfo()
$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 instanceof self || method_exists($e, 'getPrevious')) && $e = $e->getPrevious()) {
$exceptions[] = $e;
Expand Down
43 changes: 17 additions & 26 deletions lib/Twig/Extension/Core.php
@@ -1,8 +1,7 @@
<?php

if (!defined('ENT_SUBSTITUTE')) {
// use 0 as hhvm does not support several flags yet
define('ENT_SUBSTITUTE', 0);
define('ENT_SUBSTITUTE', 8);
}

/*
Expand Down Expand Up @@ -1006,30 +1005,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);
Expand Down
2 changes: 1 addition & 1 deletion test/Twig/Tests/Fixtures/filters/urlencode_deprecated.test
@@ -1,5 +1,5 @@
--TEST--
"url_encode" filter for PHP < 5.4 and HHVM
"url_encode" filter for PHP < 5.4
--CONDITION--
defined('PHP_QUERY_RFC3986')
--TEMPLATE--
Expand Down
2 changes: 2 additions & 0 deletions test/Twig/Tests/Fixtures/functions/date.test
Expand Up @@ -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(
Expand All @@ -23,3 +24,4 @@ OK
OK
OK
OK
OK
4 changes: 0 additions & 4 deletions test/Twig/Tests/NativeExtensionTest.php
Expand Up @@ -16,10 +16,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,
Expand Down
4 changes: 0 additions & 4 deletions test/Twig/Tests/Node/Expression/CallTest.php
Expand Up @@ -63,10 +63,6 @@ public function testGetArgumentsWithWrongNamedArgumentNames()
*/
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'));
$node->getArguments('substr_compare', array('abcd', 'bc', 'offset' => 1, 'case_sensitivity' => true));
}
Expand Down

0 comments on commit c6bd2df

Please sign in to comment.