Clean ups

This commit is contained in:
SpacePossum
2016-11-16 09:31:04 +01:00
committed by Fabien Potencier
parent 3ea0f326e3
commit 1f6fd6700e
7 changed files with 8 additions and 41 deletions
+1 -1
View File
@@ -408,7 +408,7 @@ function twig_date_converter(Twig_Environment $env, $date = null, $timezone = nu
return false !== $timezone ? $date->setTimezone($timezone) : $date;
}
if ($date instanceof DateTime || $date instanceof DateTimeInterface) {
if ($date instanceof DateTimeInterface) {
$date = clone $date;
if (false !== $timezone) {
$date->setTimezone($timezone);
-19
View File
@@ -150,7 +150,6 @@ final class Twig_ExtensionSet
throw new LogicException(sprintf('Unable to register extension "%s" as it is already registered.', $class));
}
$this->lastModifiedExtension = 0;
$this->extensions[$class] = $extension;
}
@@ -163,9 +162,6 @@ final class Twig_ExtensionSet
$this->staging->addFunction($function);
}
/**
* {@inheritdoc}
*/
public function getFunctions()
{
if (!$this->initialized) {
@@ -226,9 +222,6 @@ final class Twig_ExtensionSet
$this->staging->addFilter($filter);
}
/**
* {@inheritdoc}
*/
public function getFilters()
{
if (!$this->initialized) {
@@ -292,9 +285,6 @@ final class Twig_ExtensionSet
$this->staging->addNodeVisitor($visitor);
}
/**
* {@inheritdoc}
*/
public function getNodeVisitors()
{
if (!$this->initialized) {
@@ -313,9 +303,6 @@ final class Twig_ExtensionSet
$this->staging->addTokenParser($parser);
}
/**
* {@inheritdoc}
*/
public function getTokenParsers()
{
if (!$this->initialized) {
@@ -325,9 +312,6 @@ final class Twig_ExtensionSet
return $this->parsers;
}
/**
* {@inheritdoc}
*/
public function getGlobals()
{
if (null !== $this->globals) {
@@ -364,9 +348,6 @@ final class Twig_ExtensionSet
$this->staging->addTest($test);
}
/**
* {@inheritdoc}
*/
public function getTests()
{
if (!$this->initialized) {
+2 -7
View File
@@ -72,13 +72,8 @@ class Twig_Lexer
);
}
/**
* {@inheritdoc}
*/
public function tokenize($code, $name = null)
public function tokenize(\Twig_Source $source)
{
$source = $code;
if (((int) ini_get('mbstring.func_overload')) & 2) {
$mbEncoding = mb_internal_encoding();
mb_internal_encoding('ASCII');
@@ -401,7 +396,7 @@ class Twig_Lexer
private function popState()
{
if (0 === count($this->states)) {
throw new Exception('Cannot pop state without a previous state.');
throw new LogicException('Cannot pop state without a previous state.');
}
$this->state = array_pop($this->states);
+1 -1
View File
@@ -285,7 +285,7 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface, Twig_ExistsLoaderI
{
return strspn($file, '/\\', 0, 1)
|| (strlen($file) > 3 && ctype_alpha($file[0])
&& substr($file, 1, 1) === ':'
&& ':' === $file[1]
&& strspn($file, '/\\', 2, 1)
)
|| null !== parse_url($file, PHP_URL_SCHEME)
-3
View File
@@ -41,9 +41,6 @@ class Twig_Parser
return sprintf('__internal_%s', hash('sha256', uniqid(mt_rand(), true), false));
}
/**
* {@inheritdoc}
*/
public function parse(Twig_TokenStream $stream, $test = null, $dropNeedle = false)
{
// push all variables into the stack to keep the current state of the parser
+3 -9
View File
@@ -281,8 +281,8 @@ abstract class Twig_Template
* This method checks blocks defined in the current template
* or defined in "used" traits or defined in parent templates.
*
* @param array $context The context
* @param array $blocks The current set of blocks
* @param array $context The context
* @param array $blocks The current set of blocks
*
* @return array An array of block names
*
@@ -317,7 +317,7 @@ abstract class Twig_Template
return $this->env->loadTemplate($template, $index);
} catch (Twig_Error $e) {
if (!$e->getTemplateName()) {
$e->setTemplateName($templateName ? $templateName : $this->getTemplateName());
$e->setTemplateName($templateName ?: $this->getTemplateName());
}
if ($e->getTemplateLine()) {
@@ -349,17 +349,11 @@ abstract class Twig_Template
return $this->blocks;
}
/**
* {@inheritdoc}
*/
public function display(array $context, array $blocks = array())
{
$this->displayWithErrorHandling($this->env->mergeGlobals($context), array_merge($this->blocks, $blocks));
}
/**
* {@inheritdoc}
*/
public function render(array $context)
{
$level = ob_get_level();
+1 -1
View File
@@ -58,7 +58,7 @@ class Twig_Util_DeprecationCollector
foreach ($iterator as $name => $contents) {
try {
$this->twig->parse($this->twig->tokenize($contents, $name));
$this->twig->parse($this->twig->tokenize($contents));
} catch (Twig_Error_Syntax $e) {
// ignore templates containing syntax errors
}