mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-12 10:26:32 +00:00
fixed CS
This commit is contained in:
@@ -145,11 +145,11 @@ class Twig_Compiler implements Twig_CompilerInterface
|
||||
{
|
||||
if (is_int($value) || is_float($value)) {
|
||||
$this->raw($value);
|
||||
} else if (null === $value) {
|
||||
} elseif (null === $value) {
|
||||
$this->raw('null');
|
||||
} else if (is_bool($value)) {
|
||||
} elseif (is_bool($value)) {
|
||||
$this->raw($value ? 'true' : 'false');
|
||||
} else if (is_array($value)) {
|
||||
} elseif (is_array($value)) {
|
||||
$this->raw('array(');
|
||||
$i = 0;
|
||||
foreach ($value as $key => $value) {
|
||||
|
||||
@@ -695,7 +695,7 @@ class Twig_Environment
|
||||
foreach($parsers as $parser) {
|
||||
if ($parser instanceof Twig_TokenParserInterface) {
|
||||
$this->parsers->addTokenParser($parser);
|
||||
} else if ($parser instanceof Twig_TokenParserBrokerInterface) {
|
||||
} elseif ($parser instanceof Twig_TokenParserBrokerInterface) {
|
||||
$this->parsers->addTokenParserBroker($parser);
|
||||
} else {
|
||||
throw new Twig_Error_Runtime('getTokenParsers() must return an array of Twig_TokenParserInterface or Twig_TokenParserBrokerInterface instances');
|
||||
|
||||
@@ -306,7 +306,7 @@ function twig_cycle($values, $i)
|
||||
/**
|
||||
* Returns a random value depending on the supplied parameter type:
|
||||
* - a random item from a Traversable or array
|
||||
* - a random character from a string
|
||||
* - a random character from a string
|
||||
* - a random integer between 0 and the integer parameter
|
||||
*
|
||||
* @param Twig_Environment $env A Twig_Environment instance
|
||||
@@ -708,6 +708,7 @@ function twig_in_filter($value, $compare)
|
||||
if (!strlen((string) $value)) {
|
||||
return empty($compare);
|
||||
}
|
||||
|
||||
return false !== strpos($compare, (string) $value);
|
||||
} elseif (is_object($compare) && $compare instanceof Traversable) {
|
||||
return in_array($value, iterator_to_array($compare, false));
|
||||
@@ -998,5 +999,6 @@ function twig_test_empty($value)
|
||||
if ($value instanceof Countable) {
|
||||
return 0 == count($value);
|
||||
}
|
||||
|
||||
return false === $value || (empty($value) && '0' != $value);
|
||||
}
|
||||
|
||||
+5
-3
@@ -146,6 +146,7 @@ class Twig_Lexer implements Twig_LexerInterface
|
||||
if ($this->position == count($this->positions[0]) - 1) {
|
||||
$this->pushToken(Twig_Token::TEXT_TYPE, substr($this->code, $this->cursor));
|
||||
$this->cursor = $this->end;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -177,7 +178,7 @@ class Twig_Lexer implements Twig_LexerInterface
|
||||
$this->moveCursor($match[0]);
|
||||
$this->lexRawData();
|
||||
// {% line \d+ %}
|
||||
} else if (preg_match($this->regexes['lex_block_line'], $this->code, $match, null, $this->cursor)) {
|
||||
} elseif (preg_match($this->regexes['lex_block_line'], $this->code, $match, null, $this->cursor)) {
|
||||
$this->moveCursor($match[0]);
|
||||
$this->lineno = (int) $match[1];
|
||||
} else {
|
||||
@@ -316,11 +317,11 @@ class Twig_Lexer implements Twig_LexerInterface
|
||||
$this->moveCursor($match[0]);
|
||||
$this->pushState(self::STATE_INTERPOLATION);
|
||||
|
||||
} else if (preg_match(self::REGEX_DQ_STRING_PART, $this->code, $match, null, $this->cursor) && strlen($match[0]) > 0) {
|
||||
} elseif (preg_match(self::REGEX_DQ_STRING_PART, $this->code, $match, null, $this->cursor) && strlen($match[0]) > 0) {
|
||||
$this->pushToken(Twig_Token::STRING_TYPE, stripcslashes($match[0]));
|
||||
$this->moveCursor($match[0]);
|
||||
|
||||
} else if (preg_match(self::REGEX_DQ_STRING_DELIM, $this->code, $match, null, $this->cursor)) {
|
||||
} 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] != '"') {
|
||||
@@ -329,6 +330,7 @@ class Twig_Lexer implements Twig_LexerInterface
|
||||
|
||||
$this->popState();
|
||||
++$this->cursor;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,6 +148,7 @@ class Twig_NodeVisitor_Escaper implements Twig_NodeVisitorInterface
|
||||
$line = $node->getLine();
|
||||
$name = new Twig_Node_Expression_Constant('escape', $line);
|
||||
$args = new Twig_Node(array(new Twig_Node_Expression_Constant((string) $type, $line), new Twig_Node_Expression_Constant(null, $line), new Twig_Node_Expression_Constant(true, $line)));
|
||||
|
||||
return new Twig_Node_Expression_Filter($node, $name, $args, $line);
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ class Twig_NodeVisitor_SafeAnalysis implements Twig_NodeVisitorInterface
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -24,6 +25,7 @@ class Twig_NodeVisitor_SafeAnalysis implements Twig_NodeVisitorInterface
|
||||
foreach($this->data[$hash] as &$bucket) {
|
||||
if ($bucket['key'] === $node) {
|
||||
$bucket['value'] = $safe;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ abstract class Twig_Template implements Twig_TemplateInterface
|
||||
public function displayParentBlock($name, array $context, array $blocks = array())
|
||||
{
|
||||
$name = (string) $name;
|
||||
|
||||
|
||||
if (isset($this->traits[$name])) {
|
||||
$this->traits[$name][0]->displayBlock($name, $context, $blocks);
|
||||
} elseif (false !== $parent = $this->getParent($context)) {
|
||||
@@ -122,7 +122,7 @@ abstract class Twig_Template implements Twig_TemplateInterface
|
||||
public function displayBlock($name, array $context, array $blocks = array())
|
||||
{
|
||||
$name = (string) $name;
|
||||
|
||||
|
||||
if (isset($blocks[$name])) {
|
||||
$b = $blocks;
|
||||
unset($b[$name]);
|
||||
|
||||
@@ -86,6 +86,7 @@ class Twig_TokenParserBroker implements Twig_TokenParserBrokerInterface
|
||||
}
|
||||
$broker = prev($this->brokers);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user