From 0768f10b9d4a2cfb5d96e5535545641d7f99dd16 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 11 May 2017 13:29:29 -0700 Subject: [PATCH 1/5] added PHP 7.2 to the test matrix --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 19f8fb570..55978877a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,6 +15,7 @@ php: - 5.6 - 7.0 - 7.1 + - nightly - hhvm env: @@ -41,3 +42,5 @@ matrix: env: TWIG_EXT=yes - php: 7.1 env: TWIG_EXT=yes + - php: nightly + env: TWIG_EXT=yes From 8ebaf8e64422dd5876e089d81347f10f0bb87e68 Mon Sep 17 00:00:00 2001 From: Haralan Dobrev Date: Sat, 22 Apr 2017 15:26:03 +0300 Subject: [PATCH 2/5] Support PHPUnit 6 for testing extensions --- lib/Twig/Test/IntegrationTestCase.php | 8 ++++++-- lib/Twig/Test/NodeTestCase.php | 4 +++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/Twig/Test/IntegrationTestCase.php b/lib/Twig/Test/IntegrationTestCase.php index 2253f7165..df4dbf670 100644 --- a/lib/Twig/Test/IntegrationTestCase.php +++ b/lib/Twig/Test/IntegrationTestCase.php @@ -9,13 +9,16 @@ * file that was distributed with this source code. */ +use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Constraint\Exception as ExceptionConstraint; + /** * Integration test helper. * * @author Fabien Potencier * @author Karma Dordrak */ -abstract class Twig_Test_IntegrationTestCase extends PHPUnit_Framework_TestCase +abstract class Twig_Test_IntegrationTestCase extends TestCase { /** * @return string @@ -196,7 +199,8 @@ abstract class Twig_Test_IntegrationTestCase extends PHPUnit_Framework_TestCase if (false !== $exception) { list($class) = explode(':', $exception); - $this->assertThat(null, new PHPUnit_Framework_Constraint_Exception($class)); + $constraintClass = class_exists(ExceptionConstraint::class) ? ExceptionConstraint::class : \PHPUnit_Framework_Constraint_Exception::class; + $this->assertThat(null, new $constraintClass($class)); } $expected = trim($match[3], "\n "); diff --git a/lib/Twig/Test/NodeTestCase.php b/lib/Twig/Test/NodeTestCase.php index a6b550cf8..64c885b51 100644 --- a/lib/Twig/Test/NodeTestCase.php +++ b/lib/Twig/Test/NodeTestCase.php @@ -1,5 +1,7 @@ Date: Thu, 11 May 2017 14:48:03 -0700 Subject: [PATCH 3/5] bumped version to 1.34 --- CHANGELOG | 2 +- composer.json | 2 +- ext/twig/php_twig.h | 2 +- lib/Twig/Environment.php | 8 ++++---- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 752a12724..9422ce194 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,4 @@ -* 1.33.3 (2017-XX-XX) +* 1.34.0 (2017-XX-XX) * n/a diff --git a/composer.json b/composer.json index b89f14ca8..0ea731c94 100644 --- a/composer.json +++ b/composer.json @@ -41,7 +41,7 @@ }, "extra": { "branch-alias": { - "dev-master": "1.33-dev" + "dev-master": "1.34-dev" } } } diff --git a/ext/twig/php_twig.h b/ext/twig/php_twig.h index 656cbfba8..f60ba470c 100644 --- a/ext/twig/php_twig.h +++ b/ext/twig/php_twig.h @@ -15,7 +15,7 @@ #ifndef PHP_TWIG_H #define PHP_TWIG_H -#define PHP_TWIG_VERSION "1.33.3-DEV" +#define PHP_TWIG_VERSION "1.34.0-DEV" #include "php.h" diff --git a/lib/Twig/Environment.php b/lib/Twig/Environment.php index d75a42568..f26289897 100644 --- a/lib/Twig/Environment.php +++ b/lib/Twig/Environment.php @@ -16,11 +16,11 @@ */ class Twig_Environment { - const VERSION = '1.33.3'; - const VERSION_ID = 13303; + const VERSION = '1.34.0-DEV'; + const VERSION_ID = 13400; const MAJOR_VERSION = 1; - const MINOR_VERSION = 33; - const RELEASE_VERSION = 3; + const MINOR_VERSION = 34; + const RELEASE_VERSION = 0; const EXTRA_VERSION = 'DEV'; protected $charset; From 75f2231a456eadd5882febee6752e54fcc5e9114 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 11 May 2017 14:51:50 -0700 Subject: [PATCH 4/5] fixed code for older versions of PHP --- .travis.yml | 6 +++--- CHANGELOG | 2 +- composer.json | 2 +- doc/intro.rst | 3 ++- lib/Twig/Test/IntegrationTestCase.php | 3 +-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 19f8fb570..fda9ac87e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,6 @@ cache: - $HOME/.composer/cache/files php: - - 5.2 - 5.3 - 5.4 - 5.5 @@ -25,13 +24,14 @@ before_install: - if [[ ! $TRAVIS_PHP_VERSION = hhvm* ]]; then phpenv config-rm xdebug.ini || echo "xdebug not available"; fi install: - # Composer is not available on PHP 5.2 - - if [ ${TRAVIS_PHP_VERSION:0:3} != "5.2" ]; then travis_retry composer install; fi + - travis_retry composer install 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 + matrix: fast_finish: true exclude: diff --git a/CHANGELOG b/CHANGELOG index 9422ce194..b97aedb8f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,6 @@ * 1.34.0 (2017-XX-XX) - * n/a + * dropped PHP 5.2 support * 1.33.2 (2017-04-20) diff --git a/composer.json b/composer.json index 0ea731c94..a1b277612 100644 --- a/composer.json +++ b/composer.json @@ -27,7 +27,7 @@ "forum": "https://groups.google.com/forum/#!forum/twig-users" }, "require": { - "php": ">=5.2.7" + "php": ">=5.3.3" }, "require-dev": { "symfony/phpunit-bridge": "~3.3@dev", diff --git a/doc/intro.rst b/doc/intro.rst index 352286927..d631430f7 100644 --- a/doc/intro.rst +++ b/doc/intro.rst @@ -28,7 +28,8 @@ Slim, Yii, Laravel, Codeigniter and Kohana — just to name a few. Prerequisites ------------- -Twig needs at least **PHP 5.2.7** to run. +Twig needs at least **PHP 5.2.7** to run. As of 1.34, the minimum requirement +was bumped to **PHP 5.3.3**. Installation ------------ diff --git a/lib/Twig/Test/IntegrationTestCase.php b/lib/Twig/Test/IntegrationTestCase.php index df4dbf670..88d0718e5 100644 --- a/lib/Twig/Test/IntegrationTestCase.php +++ b/lib/Twig/Test/IntegrationTestCase.php @@ -10,7 +10,6 @@ */ use PHPUnit\Framework\TestCase; -use PHPUnit\Framework\Constraint\Exception as ExceptionConstraint; /** * Integration test helper. @@ -199,7 +198,7 @@ abstract class Twig_Test_IntegrationTestCase extends TestCase if (false !== $exception) { list($class) = explode(':', $exception); - $constraintClass = class_exists(ExceptionConstraint::class) ? ExceptionConstraint::class : \PHPUnit_Framework_Constraint_Exception::class; + $constraintClass = class_exists('PHPUnit\Framework\Constraint\Exception') ? 'PHPUnit\Framework\Constraint\Exception' : 'PHPUnit_Framework_Constraint_Exception'; $this->assertThat(null, new $constraintClass($class)); } From 3aa2e884ae6a9399d87696894f2c10ef245c1c9b Mon Sep 17 00:00:00 2001 From: SpacePossum Date: Fri, 12 May 2017 10:40:10 +0200 Subject: [PATCH 5/5] Length filter non-mb_string on 7.x fix. --- lib/Twig/Extension/Core.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/Twig/Extension/Core.php b/lib/Twig/Extension/Core.php index 62ea64d91..ffa1d9fe1 100644 --- a/lib/Twig/Extension/Core.php +++ b/lib/Twig/Extension/Core.php @@ -1363,6 +1363,10 @@ else { */ function twig_length_filter(Twig_Environment $env, $thing) { + if (null === $thing) { + return 0; + } + if (is_scalar($thing)) { return strlen($thing); } @@ -1371,7 +1375,11 @@ else { return strlen((string) $thing); } - return count($thing); + if ($thing instanceof \Countable || is_array($thing)) { + return count($thing); + } + + return 1; } /**