Merge branch '1.x' into 2.x

* 1.x:
  fixed CS
This commit is contained in:
Fabien Potencier
2018-03-02 13:11:50 -08:00
9 changed files with 16 additions and 15 deletions
+7 -6
View File
@@ -189,12 +189,13 @@ class Twig_ExpressionParser
break;
}
// no break
default:
if ($token->test(Twig_Token::PUNCTUATION_TYPE, '[')) {
$node = $this->parseArrayExpression();
} elseif ($token->test(Twig_Token::PUNCTUATION_TYPE, '{')) {
$node = $this->parseHashExpression();
} elseif ($token->test(Twig_Token::OPERATOR_TYPE, '=') && ($this->parser->getStream()->look(-1)->getValue() === '==' || $this->parser->getStream()->look(-1)->getValue() === '!=')) {
} elseif ($token->test(Twig_Token::OPERATOR_TYPE, '=') && ('==' === $this->parser->getStream()->look(-1)->getValue() || '!=' === $this->parser->getStream()->look(-1)->getValue())) {
throw new Twig_Error_Syntax(sprintf('Unexpected operator of value "%s". Did you try to use "===" or "!==" for strict comparison? Use "is same as(value)" instead.', $token->getValue()), $token->getLine(), $this->parser->getStream()->getSourceContext());
} else {
throw new Twig_Error_Syntax(sprintf('Unexpected token "%s" of value "%s".', Twig_Token::typeToEnglish($token->getType()), $token->getValue()), $token->getLine(), $this->parser->getStream()->getSourceContext());
@@ -305,7 +306,7 @@ class Twig_ExpressionParser
{
while (true) {
$token = $this->parser->getCurrentToken();
if ($token->getType() == Twig_Token::PUNCTUATION_TYPE) {
if (Twig_Token::PUNCTUATION_TYPE == $token->getType()) {
if ('.' == $token->getValue() || '[' == $token->getValue()) {
$node = $this->parseSubscriptExpression($node);
} elseif ('|' == $token->getValue()) {
@@ -376,14 +377,14 @@ class Twig_ExpressionParser
$lineno = $token->getLine();
$arguments = new Twig_Node_Expression_Array(array(), $lineno);
$type = Twig_Template::ANY_CALL;
if ($token->getValue() == '.') {
if ('.' == $token->getValue()) {
$token = $stream->next();
if (
$token->getType() == Twig_Token::NAME_TYPE
Twig_Token::NAME_TYPE == $token->getType()
||
$token->getType() == Twig_Token::NUMBER_TYPE
Twig_Token::NUMBER_TYPE == $token->getType()
||
($token->getType() == Twig_Token::OPERATOR_TYPE && preg_match(Twig_Lexer::REGEX_NAME, $token->getValue()))
(Twig_Token::OPERATOR_TYPE == $token->getType() && preg_match(Twig_Lexer::REGEX_NAME, $token->getValue()))
) {
$arg = new Twig_Node_Expression_Constant($token->getValue(), $lineno);
+1 -1
View File
@@ -579,7 +579,7 @@ function twig_slice(Twig_Environment $env, $item, $start, $length = null, $prese
if ($start >= 0 && $length >= 0 && $item instanceof Iterator) {
try {
return iterator_to_array(new LimitIterator($item, $start, $length === null ? -1 : $length), $preserveKeys);
return iterator_to_array(new LimitIterator($item, $start, null === $length ? -1 : $length), $preserveKeys);
} catch (OutOfBoundsException $exception) {
return array();
}
+2 -2
View File
@@ -210,7 +210,7 @@ class Twig_Lexer
$this->moveCursor($match[0]);
if ($this->cursor >= $this->end) {
throw new Twig_Error_Syntax(sprintf('Unclosed "%s".', $this->state === self::STATE_BLOCK ? 'block' : 'variable'), $this->currentVarBlockLine, $this->source);
throw new Twig_Error_Syntax(sprintf('Unclosed "%s".', self::STATE_BLOCK === $this->state ? 'block' : 'variable'), $this->currentVarBlockLine, $this->source);
}
}
@@ -308,7 +308,7 @@ class Twig_Lexer
$this->moveCursor($match[0]);
} elseif (preg_match(self::REGEX_DQ_STRING_DELIM, $this->code, $match, null, $this->cursor)) {
list($expect, $lineno) = array_pop($this->brackets);
if ($this->code[$this->cursor] != '"') {
if ('"' != $this->code[$this->cursor]) {
throw new Twig_Error_Syntax(sprintf('Unclosed "%s".', $expect), $lineno, $this->source);
}
+1 -1
View File
@@ -131,7 +131,7 @@ class Twig_Parser
$this->stream->next();
$token = $this->getCurrentToken();
if ($token->getType() !== Twig_Token::NAME_TYPE) {
if (Twig_Token::NAME_TYPE !== $token->getType()) {
throw new Twig_Error_Syntax('A block must start with a tag name.', $token->getLine(), $this->stream->getSourceContext());
}
+1 -1
View File
@@ -80,7 +80,7 @@ class Twig_Profiler_Profile implements IteratorAggregate, Serializable
return $this->profiles;
}
public function addProfile(Twig_Profiler_Profile $profile)
public function addProfile(self $profile)
{
$this->profiles[] = $profile;
}
+1 -1
View File
@@ -38,7 +38,7 @@ final class Twig_TokenParser_For extends Twig_TokenParser
$stream->expect(Twig_Token::BLOCK_END_TYPE);
$body = $this->parser->subparse(array($this, 'decideForFork'));
if ($stream->next()->getValue() == 'else') {
if ('else' == $stream->next()->getValue()) {
$stream->expect(Twig_Token::BLOCK_END_TYPE);
$else = $this->parser->subparse(array($this, 'decideForEnd'), true);
} else {
+1 -1
View File
@@ -123,7 +123,7 @@ final class Twig_TokenStream
*/
public function isEOF()
{
return $this->tokens[$this->current]->getType() === Twig_Token::EOF_TYPE;
return Twig_Token::EOF_TYPE === $this->tokens[$this->current]->getType();
}
/**
+1 -1
View File
@@ -251,7 +251,7 @@ EOF
$twig->loadTemplate('1_include')->render(self::$params);
} catch (Throwable $e) {
}
if ($e === null) {
if (null === $e) {
$this->fail('An exception should be thrown for this test to be valid.');
}
+1 -1
View File
@@ -311,7 +311,7 @@ class CountableStub implements \Countable
}
/**
* This class is used in tests for the length filter
* This class is used in tests for the length filter.
*/
class IteratorAggregateStub implements \IteratorAggregate
{