dropped PHP 5.x support

This commit is contained in:
Fabien Potencier
2016-12-16 14:17:23 +01:00
parent 12e75458bc
commit 747d7bea87
8 changed files with 29 additions and 63 deletions
+20 -26
View File
@@ -3,37 +3,31 @@ language: php
sudo: false
cache:
directories:
- vendor
- $HOME/.composer/cache/files
directories:
- vendor
- $HOME/.composer/cache/files
matrix:
include:
- php: hhvm-stable
sudo: required
dist: trusty
group: edge
env: TWIG_EXT=no
- php: 7.0
env: TWIG_EXT=no
- php: 7.1
env: TWIG_EXT=no
allow_failures:
- php: hhvm-stable
sudo: required
dist: trusty
group: edge
env: TWIG_EXT=no
fast_finish: true
include:
- php: hhvm-stable
sudo: required
dist: trusty
env: TWIG_EXT=no
- php: 7.0
env: TWIG_EXT=no
- php: 7.1
env: TWIG_EXT=no
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
- 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
install:
- travis_retry composer install
- 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
- 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
+1 -1
View File
@@ -12,7 +12,7 @@
* removed Twig_Autoloader (use Composer instead)
* removed `true` as an equivalent to `html` for the auto-escaping strategy
* removed pre-1.8 autoescape tag syntax
* dropped support for PHP 5.2, 5.3, 5.4, and 5.5
* dropped support for PHP 5.x
* removed the ability to register a global variable after the runtime or the extensions have been initialized
* improved the performance of the filesystem loader
* removed features that were deprecated in 1.x
+1 -1
View File
@@ -50,4 +50,4 @@
}
},
"minimum-stability": "dev"
}
}
+1 -1
View File
@@ -28,7 +28,7 @@ Slim, Yii, Laravel, Codeigniter and Kohana — just to name a few.
Prerequisites
-------------
Twig needs at least **PHP 5.6.0** to run.
Twig needs at least **PHP 7.0.0** to run.
Installation
------------
+4 -6
View File
@@ -61,9 +61,6 @@ class Twig_Node_Expression_Name extends Twig_Node_Expression
;
}
} else {
// When Twig will require PHP 7.0, the Template::notFound() method
// will be removed and the code inlined like this:
// (function () { throw new Exception(...); })();
$compiler
->raw('(isset($context[')
->string($name)
@@ -71,11 +68,12 @@ class Twig_Node_Expression_Name extends Twig_Node_Expression
->string($name)
->raw(', $context) ? $context[')
->string($name)
->raw('] : $this->notFound(')
->raw('] : (function () { throw new Twig_Error_Runtime(\'Variable ')
->string($name)
->raw(', ')
->raw(' does not exist.\', ')
->repr($this->lineno)
->raw('))')
->raw(', $this->getSourceContext()); })()')
->raw(')')
;
}
}
+1 -8
View File
@@ -43,14 +43,7 @@ class Twig_Parser
public function parse(Twig_TokenStream $stream, $test = null, $dropNeedle = false)
{
// push all variables into the stack to keep the current state of the parser
// using get_object_vars() instead of foreach would lead to https://bugs.php.net/71336
// This hack can be removed when min version if PHP 7.0
$vars = array();
foreach ($this as $k => $v) {
$vars[$k] = $v;
}
$vars = get_object_vars($this);
unset($vars['stack'], $vars['env'], $vars['handlers'], $vars['visitors'], $vars['expressionParser'], $vars['reservedMacroNames']);
$this->stack[] = $vars;
-19
View File
@@ -417,25 +417,6 @@ abstract class Twig_Template
*/
abstract protected function doDisplay(array $context, array $blocks = array());
/**
* Throws an exception for an unknown variable.
*
* This method is for internal use only and should never be called
* directly.
*
* This is an implementation detail due to a PHP limitation before version 7.0.
*
* @return mixed The content of the context variable
*
* @throws Twig_Error_Runtime if the variable does not exist and Twig is running in strict mode
*
* @internal
*/
final protected function notFound($name, $line)
{
throw new Twig_Error_Runtime(sprintf('Variable "%s" does not exist.', $name), $line, $this->getSourceContext());
}
/**
* Returns the attribute value for a given array/object.
*
+1 -1
View File
@@ -27,7 +27,7 @@ class Twig_Tests_Node_Expression_NameTest extends Twig_Test_NodeTestCase
$env = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('strict_variables' => true));
$env1 = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('strict_variables' => false));
$output = '(isset($context["foo"]) || array_key_exists("foo", $context) ? $context["foo"] : $this->notFound("foo", 1))';
$output = '(isset($context["foo"]) || array_key_exists("foo", $context) ? $context["foo"] : (function () { throw new Twig_Error_Runtime(\'Variable "foo" does not exist.\', 1, $this->getSourceContext()); })())';
return array(
array($node, "// line 1\n".$output, $env),