Merge branch '1.x' into 2.x

* 1.x:
  Fix integration tests
  Fix PHP 8 compat
  Install the phpunit-bridge with PHP 7.4 when testing nightly
  Add PHP 8 / nightly in Travis matrix
  Drop support for PHP 7.0
This commit is contained in:
Fabien Potencier
2020-05-19 15:03:51 +02:00
14 changed files with 34 additions and 25 deletions
+15 -13
View File
@@ -15,34 +15,36 @@ env:
before_install:
- phpenv config-rm xdebug.ini || return 0
- echo memory_limit = -1 >> ~/.phpenv/versions/$TRAVIS_PHP_VERSION/etc/conf.d/travis.ini
install:
- travis_retry composer install
- ([[ $TRAVIS_PHP_VERSION = 7.0 ]] || (cd extra/cssinliner-extra && travis_retry composer install))
- ([[ $TRAVIS_PHP_VERSION = 7.0 ]] || (cd extra/html-extra && travis_retry composer install))
- ([[ $TRAVIS_PHP_VERSION = 7.0 ]] || (cd extra/inky-extra && travis_retry composer install))
- ([[ $TRAVIS_PHP_VERSION = 7.0 ]] || (cd extra/intl-extra && travis_retry composer install))
- ([[ $TRAVIS_PHP_VERSION = 7.0 ]] || (cd extra/markdown-extra && travis_retry composer install))
- ([[ $TRAVIS_PHP_VERSION < 7.2 ]] || (cd extra/string-extra && travis_retry composer install))
- |
# install the phpunit-bridge with PHP 7.4 when testing nightly
if [[ $TRAVIS_PHP_VERSION = nightly ]]; then
(cd / && wget https://storage.googleapis.com/travis-ci-language-archives/php/binaries/ubuntu/16.04/x86_64/php-7.4.tar.bz2 -O - | tar -xj)
phpenv global 7.4;
./vendor/bin/simple-phpunit install;
phpenv global nightly;
fi
script:
- ./vendor/bin/simple-phpunit
- ([[ $TRAVIS_PHP_VERSION = 7.0 ]] || (cd extra/cssinliner-extra && ./vendor/bin/simple-phpunit))
- ([[ $TRAVIS_PHP_VERSION = 7.0 ]] || (cd extra/html-extra && ./vendor/bin/simple-phpunit))
- ([[ $TRAVIS_PHP_VERSION = 7.0 ]] || (cd extra/inky-extra && ./vendor/bin/simple-phpunit))
- ([[ $TRAVIS_PHP_VERSION = 7.0 ]] || (cd extra/intl-extra && ./vendor/bin/simple-phpunit))
- ([[ $TRAVIS_PHP_VERSION = 7.0 ]] || (cd extra/markdown-extra && ./vendor/bin/simple-phpunit))
- (cd extra/cssinliner-extra && ./vendor/bin/simple-phpunit)
- (cd extra/html-extra && ./vendor/bin/simple-phpunit)
- (cd extra/inky-extra && ./vendor/bin/simple-phpunit)
- (cd extra/intl-extra && ./vendor/bin/simple-phpunit)
- (cd extra/markdown-extra && ./vendor/bin/simple-phpunit)
- ([[ $TRAVIS_PHP_VERSION < 7.2 ]] || (cd extra/string-extra && ./vendor/bin/simple-phpunit))
matrix:
fast_finish: true
include:
- php: 7.0
dist: trusty
- php: 7.1
- php: 7.2
- php: 7.3
- php: 7.4
- php: nightly
- stage: integration tests
php: 7.3
script: ./drupal_test.sh
+2 -1
View File
@@ -306,7 +306,8 @@
# 1.43.0 (2020-XX-XX)
* Drop PHP 5.5 and 5.6 support
* Fix PHP 8 compatibility
* Drop PHP 5.5 5.6, and 7.0 support
* Fix ambiguous syntax parsing
# 1.42.5 (2020-02-11)
+2 -1
View File
@@ -5,6 +5,7 @@
"keywords": ["templating"],
"homepage": "https://twig.symfony.com",
"license": "BSD-3-Clause",
"minimum-stability": "dev",
"authors": [
{
"name": "Fabien Potencier",
@@ -23,7 +24,7 @@
}
],
"require": {
"php": "^7.0",
"php": "^7.1.3|^8.0",
"symfony/polyfill-mbstring": "^1.3",
"symfony/polyfill-ctype": "^1.8"
},
+1 -1
View File
@@ -26,7 +26,7 @@ Slim, Yii, Laravel, and Codeigniter — just to name a few.
Prerequisites
-------------
Twig needs at least **PHP 7.0.0** to run.
Twig needs at least **PHP 7.1.3** to run.
Installation
------------
+1 -1
View File
@@ -23,7 +23,7 @@ use Twig\Node\Expression\ConstantExpression;
class EmbedNode extends IncludeNode
{
// we don't inject the module to avoid node visitors to traverse it twice (as it will be already visited in the main module)
public function __construct(string $name, int $index, AbstractExpression $variables = null, bool $only = false, bool $ignoreMissing = false, int $lineno, string $tag = null)
public function __construct(string $name, int $index, ?AbstractExpression $variables, bool $only, bool $ignoreMissing, int $lineno, string $tag = null)
{
parent::__construct(new ConstantExpression('not_used', $lineno), $variables, $only, $ignoreMissing, $lineno, $tag);
@@ -22,7 +22,7 @@ use Twig\Node\Node;
*/
class BlockReferenceExpression extends AbstractExpression
{
public function __construct(Node $name, Node $template = null, int $lineno, string $tag = null)
public function __construct(Node $name, ?Node $template, int $lineno, string $tag = null)
{
$nodes = ['name' => $name];
if (null !== $template) {
+2 -1
View File
@@ -259,7 +259,8 @@ abstract class CallExpression extends AbstractExpression
$isPhpVariadic = false;
if ($isVariadic) {
$argument = end($parameters);
if ($argument && $argument->isArray() && $argument->isDefaultValueAvailable() && [] === $argument->getDefaultValue()) {
$isArray = $argument && $argument->hasType() && 'array' === $argument->getType()->getName();
if ($isArray && $argument->isDefaultValueAvailable() && [] === $argument->getDefaultValue()) {
array_pop($parameters);
} elseif ($argument && $argument->isVariadic()) {
array_pop($parameters);
+1 -1
View File
@@ -25,7 +25,7 @@ class ForNode extends Node
{
private $loop;
public function __construct(AssignNameExpression $keyTarget, AssignNameExpression $valueTarget, AbstractExpression $seq, AbstractExpression $ifexpr = null, Node $body, Node $else = null, int $lineno, string $tag = null)
public function __construct(AssignNameExpression $keyTarget, AssignNameExpression $valueTarget, AbstractExpression $seq, ?AbstractExpression $ifexpr, Node $body, ?Node $else, int $lineno, string $tag = null)
{
$body = new Node([$body, $this->loop = new ForLoopNode($lineno, $tag)]);
+1 -1
View File
@@ -21,7 +21,7 @@ use Twig\Compiler;
*/
class IfNode extends Node
{
public function __construct(Node $tests, Node $else = null, int $lineno, string $tag = null)
public function __construct(Node $tests, ?Node $else, int $lineno, string $tag = null)
{
$nodes = ['tests' => $tests];
if (null !== $else) {
+1 -1
View File
@@ -22,7 +22,7 @@ use Twig\Node\Expression\AbstractExpression;
*/
class IncludeNode extends Node implements NodeOutputInterface
{
public function __construct(AbstractExpression $expr, AbstractExpression $variables = null, bool $only = false, bool $ignoreMissing = false, int $lineno, string $tag = null)
public function __construct(AbstractExpression $expr, ?AbstractExpression $variables, bool $only, bool $ignoreMissing, int $lineno, string $tag = null)
{
$nodes = ['expr' => $expr];
if (null !== $variables) {
+1 -1
View File
@@ -20,7 +20,7 @@ use Twig\Compiler;
*/
class WithNode extends Node
{
public function __construct(Node $body, Node $variables = null, bool $only = false, int $lineno, string $tag = null)
public function __construct(Node $body, ?Node $variables, bool $only, int $lineno, string $tag = null)
{
$nodes = ['body' => $body];
if (null !== $variables) {
@@ -1,5 +1,7 @@
--TEST--
Twig is able to deal with SimpleXMLElement instances as variables
--CONDITION--
version_compare(phpversion(), '8.0', '<')
--TEMPLATE--
Hello '{{ images.image.0.group }}'!
{{ images.image.0.group.attributes.myattr }}
-2
View File
@@ -43,7 +43,6 @@ Twig supports the in operator
{{ ''~dir_object in dir_object ? 'KO' : 'OK' }}
{{ resource in [''~resource] ? 'KO' : 'OK' }}
{{ resource in [resource + 1 - 1] ? 'KO' : 'OK' }}
{{ dir_object in [''~dir_object] ? 'KO' : 'OK' }}
{{ 5 in 125 ? 'KO' : 'OK' }}
@@ -106,7 +105,6 @@ OK
OK
OK
OK
OK
OK
+4
View File
@@ -61,6 +61,10 @@ class CallTest extends TestCase
public function testResolveArgumentsWithMissingValueForOptionalArgument()
{
if (\PHP_VERSION_ID >= 80000) {
$this->markTestSkipped('substr_compare() has a default value in 8.0, so the test does not work anymore, one should find another PHP built-in function for this test to work in PHP 8.');
}
$this->expectException(SyntaxError::class);
$this->expectExceptionMessage('Argument "case_sensitivity" could not be assigned for function "substr_compare(main_str, str, offset, length, case_sensitivity)" because it is mapped to an internal PHP function which cannot determine default value for optional argument "length".');