mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-16 12:26:30 +00:00
fixed CS
This commit is contained in:
@@ -132,14 +132,14 @@ class Twig_Environment
|
||||
// For BC
|
||||
if (is_string($this->originalCache)) {
|
||||
$r = new ReflectionMethod($this, 'writeCacheFile');
|
||||
if ($r->getDeclaringClass()->getName() !== __CLASS__) {
|
||||
if (__CLASS__ !== $r->getDeclaringClass()->getName()) {
|
||||
@trigger_error('The Twig_Environment::writeCacheFile method is deprecated since version 1.22 and will be removed in Twig 2.0.', E_USER_DEPRECATED);
|
||||
|
||||
$this->bcWriteCacheFile = true;
|
||||
}
|
||||
|
||||
$r = new ReflectionMethod($this, 'getCacheFilename');
|
||||
if ($r->getDeclaringClass()->getName() !== __CLASS__) {
|
||||
if (__CLASS__ !== $r->getDeclaringClass()->getName()) {
|
||||
@trigger_error('The Twig_Environment::getCacheFilename method is deprecated since version 1.22 and will be removed in Twig 2.0.', E_USER_DEPRECATED);
|
||||
|
||||
$this->bcGetCacheFilename = true;
|
||||
|
||||
@@ -199,12 +199,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());
|
||||
@@ -315,7 +316,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()) {
|
||||
@@ -386,14 +387,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);
|
||||
|
||||
|
||||
@@ -661,7 +661,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();
|
||||
}
|
||||
@@ -1216,7 +1216,7 @@ function _twig_escape_html_attr_callback($matches)
|
||||
* The following replaces characters undefined in HTML with the
|
||||
* hex entity for the Unicode replacement character.
|
||||
*/
|
||||
if (($ord <= 0x1f && $chr != "\t" && $chr != "\n" && $chr != "\r") || ($ord >= 0x7f && $ord <= 0x9f)) {
|
||||
if (($ord <= 0x1f && "\t" != $chr && "\n" != $chr && "\r" != $chr) || ($ord >= 0x7f && $ord <= 0x9f)) {
|
||||
return '�';
|
||||
}
|
||||
|
||||
@@ -1224,7 +1224,7 @@ function _twig_escape_html_attr_callback($matches)
|
||||
* Check if the current character to escape has a name entity we should
|
||||
* replace it with while grabbing the hex value of the character.
|
||||
*/
|
||||
if (strlen($chr) == 1) {
|
||||
if (1 == strlen($chr)) {
|
||||
$hex = strtoupper(substr('00'.bin2hex($chr), -2));
|
||||
} else {
|
||||
$chr = twig_convert_encoding($chr, 'UTF-16BE', 'UTF-8');
|
||||
@@ -1270,7 +1270,7 @@ if (function_exists('mb_get_info')) {
|
||||
if ($thing instanceof \Countable || is_array($thing)) {
|
||||
return count($thing);
|
||||
}
|
||||
|
||||
|
||||
if ($thing instanceof \IteratorAggregate) {
|
||||
return iterator_count($thing);
|
||||
}
|
||||
@@ -1373,7 +1373,7 @@ else {
|
||||
if ($thing instanceof \Countable || is_array($thing)) {
|
||||
return count($thing);
|
||||
}
|
||||
|
||||
|
||||
if ($thing instanceof \IteratorAggregate) {
|
||||
return iterator_count($thing);
|
||||
}
|
||||
|
||||
+2
-2
@@ -235,7 +235,7 @@ class Twig_Lexer implements Twig_LexerInterface
|
||||
$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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -337,7 +337,7 @@ class Twig_Lexer implements Twig_LexerInterface
|
||||
$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);
|
||||
}
|
||||
|
||||
|
||||
@@ -279,7 +279,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) === ':'
|
||||
&& ':' === substr($file, 1, 1)
|
||||
&& strspn($file, '/\\', 2, 1)
|
||||
)
|
||||
|| null !== parse_url($file, PHP_URL_SCHEME)
|
||||
|
||||
@@ -56,7 +56,7 @@ class Twig_NodeVisitor_Optimizer extends Twig_BaseNodeVisitor
|
||||
if (PHP_VERSION_ID < 50400 && self::OPTIMIZE_VAR_ACCESS === (self::OPTIMIZE_VAR_ACCESS & $this->optimizers) && !$env->isStrictVariables() && !$env->hasExtension('Twig_Extension_Sandbox')) {
|
||||
if ($this->inABody) {
|
||||
if (!$node instanceof Twig_Node_Expression) {
|
||||
if (get_class($node) !== 'Twig_Node') {
|
||||
if ('Twig_Node' !== get_class($node)) {
|
||||
array_unshift($this->prependedNodes, array());
|
||||
}
|
||||
} else {
|
||||
@@ -88,7 +88,7 @@ class Twig_NodeVisitor_Optimizer extends Twig_BaseNodeVisitor
|
||||
if ($node instanceof Twig_Node_Body) {
|
||||
$this->inABody = false;
|
||||
} elseif ($this->inABody) {
|
||||
if (!$expression && get_class($node) !== 'Twig_Node' && $prependedNodes = array_shift($this->prependedNodes)) {
|
||||
if (!$expression && 'Twig_Node' !== get_class($node) && $prependedNodes = array_shift($this->prependedNodes)) {
|
||||
$nodes = array();
|
||||
foreach (array_unique($prependedNodes) as $name) {
|
||||
$nodes[] = new Twig_Node_SetTemp($name, $node->getTemplateLine());
|
||||
|
||||
+1
-1
@@ -155,7 +155,7 @@ class Twig_Parser implements Twig_ParserInterface
|
||||
$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());
|
||||
}
|
||||
|
||||
|
||||
@@ -76,7 +76,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;
|
||||
}
|
||||
|
||||
@@ -698,7 +698,7 @@ abstract class Twig_Template implements Twig_TemplateInterface
|
||||
}
|
||||
@trigger_error($message, E_USER_DEPRECATED);
|
||||
|
||||
return $ret === '' ? '' : new Twig_Markup($ret, $this->env->getCharset());
|
||||
return '' === $ret ? '' : new Twig_Markup($ret, $this->env->getCharset());
|
||||
}
|
||||
|
||||
return $ret;
|
||||
|
||||
@@ -40,7 +40,7 @@ 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 {
|
||||
|
||||
@@ -61,12 +61,12 @@ class Twig_TokenParserBroker implements Twig_TokenParserBrokerInterface
|
||||
}
|
||||
}
|
||||
|
||||
public function addTokenParserBroker(Twig_TokenParserBroker $broker)
|
||||
public function addTokenParserBroker(self $broker)
|
||||
{
|
||||
$this->brokers[] = $broker;
|
||||
}
|
||||
|
||||
public function removeTokenParserBroker(Twig_TokenParserBroker $broker)
|
||||
public function removeTokenParserBroker(self $broker)
|
||||
{
|
||||
if (false !== $pos = array_search($broker, $this->brokers)) {
|
||||
unset($this->brokers[$pos]);
|
||||
|
||||
@@ -139,7 +139,7 @@ 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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -252,7 +252,7 @@ EOF
|
||||
} catch (Throwable $e) {
|
||||
} catch (Exception $e) {
|
||||
}
|
||||
if ($e === null) {
|
||||
if (null === $e) {
|
||||
$this->fail('An exception should be thrown for this test to be valid.');
|
||||
}
|
||||
|
||||
|
||||
@@ -309,7 +309,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
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user