{
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) {
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');
/**
* 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
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));
if ($value instanceof Countable) {
return 0 == count($value);
}
+
return false === $value || (empty($value) && '0' != $value);
}
if ($this->position == count($this->positions[0]) - 1) {
$this->pushToken(Twig_Token::TEXT_TYPE, substr($this->code, $this->cursor));
$this->cursor = $this->end;
+
return;
}
$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 {
$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] != '"') {
$this->popState();
++$this->cursor;
+
return;
}
}
$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);
}
}
}
}
+
return null;
}
foreach($this->data[$hash] as &$bucket) {
if ($bucket['key'] === $node) {
$bucket['value'] = $safe;
+
return;
}
}
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)) {
public function displayBlock($name, array $context, array $blocks = array())
{
$name = (string) $name;
-
+
if (isset($blocks[$name])) {
$b = $blocks;
unset($b[$name]);
}
$broker = prev($this->brokers);
}
+
return null;
}