From: Fabien Potencier Date: Tue, 28 Feb 2012 20:47:03 +0000 (+0100) Subject: fixed CS X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=8274e84d4ea7650b91a58557fa58f0f6de3eccaa;p=konrad%2Ftwig.git fixed CS --- diff --git a/lib/Twig/Compiler.php b/lib/Twig/Compiler.php index b1330b0..0cce6a4 100644 --- a/lib/Twig/Compiler.php +++ b/lib/Twig/Compiler.php @@ -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) { diff --git a/lib/Twig/Environment.php b/lib/Twig/Environment.php index 165430b..e69ff9d 100644 --- a/lib/Twig/Environment.php +++ b/lib/Twig/Environment.php @@ -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'); diff --git a/lib/Twig/Extension/Core.php b/lib/Twig/Extension/Core.php index e0daffb..f585b65 100644 --- a/lib/Twig/Extension/Core.php +++ b/lib/Twig/Extension/Core.php @@ -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); } diff --git a/lib/Twig/Lexer.php b/lib/Twig/Lexer.php index e7068bb..4958cb6 100644 --- a/lib/Twig/Lexer.php +++ b/lib/Twig/Lexer.php @@ -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; } } diff --git a/lib/Twig/NodeVisitor/Escaper.php b/lib/Twig/NodeVisitor/Escaper.php index 7a80caa..f682beb 100644 --- a/lib/Twig/NodeVisitor/Escaper.php +++ b/lib/Twig/NodeVisitor/Escaper.php @@ -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); } diff --git a/lib/Twig/NodeVisitor/SafeAnalysis.php b/lib/Twig/NodeVisitor/SafeAnalysis.php index f068a16..89d8794 100644 --- a/lib/Twig/NodeVisitor/SafeAnalysis.php +++ b/lib/Twig/NodeVisitor/SafeAnalysis.php @@ -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; } } diff --git a/lib/Twig/Template.php b/lib/Twig/Template.php index 7cb36c9..5fd95ef 100644 --- a/lib/Twig/Template.php +++ b/lib/Twig/Template.php @@ -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]); diff --git a/lib/Twig/TokenParserBroker.php b/lib/Twig/TokenParserBroker.php index 4b2ff41..b214e99 100644 --- a/lib/Twig/TokenParserBroker.php +++ b/lib/Twig/TokenParserBroker.php @@ -86,6 +86,7 @@ class Twig_TokenParserBroker implements Twig_TokenParserBrokerInterface } $broker = prev($this->brokers); } + return null; }