1 x cleanups

This commit is contained in:
SpacePossum
2016-11-16 11:22:15 +01:00
committed by Fabien Potencier
parent 61bf5da0ac
commit 2ea7d78f17
5 changed files with 14 additions and 13 deletions
+5 -5
View File
@@ -296,8 +296,8 @@ function twig_cycle($values, $position)
* - a random character from a string
* - a random integer between 0 and the integer parameter.
*
* @param Twig_Environment $env
* @param Traversable|array|int|string $values The values to pick a random item from
* @param Twig_Environment $env
* @param Traversable|array|int|float|string $values The values to pick a random item from
*
* @throws Twig_Error_Runtime When $values is an empty array (does not apply to an empty string which is returned as is).
*
@@ -991,7 +991,7 @@ function twig_escape_filter(Twig_Environment $env, $string, $strategy = 'html',
$string = twig_convert_encoding($string, 'UTF-8', $charset);
}
if (0 == strlen($string) ? false : (1 == preg_match('/^./su', $string) ? false : true)) {
if (0 == strlen($string) ? false : 1 !== preg_match('/^./su', $string)) {
throw new Twig_Error_Runtime('The string to escape is not a valid UTF-8 string.');
}
@@ -1008,7 +1008,7 @@ function twig_escape_filter(Twig_Environment $env, $string, $strategy = 'html',
$string = twig_convert_encoding($string, 'UTF-8', $charset);
}
if (0 == strlen($string) ? false : (1 == preg_match('/^./su', $string) ? false : true)) {
if (0 == strlen($string) ? false : 1 !== preg_match('/^./su', $string)) {
throw new Twig_Error_Runtime('The string to escape is not a valid UTF-8 string.');
}
@@ -1025,7 +1025,7 @@ function twig_escape_filter(Twig_Environment $env, $string, $strategy = 'html',
$string = twig_convert_encoding($string, 'UTF-8', $charset);
}
if (0 == strlen($string) ? false : (1 == preg_match('/^./su', $string) ? false : true)) {
if (0 == strlen($string) ? false : 1 !== preg_match('/^./su', $string)) {
throw new Twig_Error_Runtime('The string to escape is not a valid UTF-8 string.');
}
+1 -1
View File
@@ -43,7 +43,7 @@ class Twig_Node_Expression_Array extends Twig_Node_Expression
foreach ($this->getKeyValuePairs() as $pair) {
// we compare the string representation of the keys
// to avoid comparing the line numbers which are not relevant here.
if ((string) $key == (string) $pair['key']) {
if ((string) $key === (string) $pair['key']) {
return true;
}
}
+2 -2
View File
@@ -146,7 +146,7 @@ abstract class Twig_Node_Expression_Call extends Twig_Node_Expression
throw new Twig_Error_Syntax(sprintf('Argument "%s" is defined twice for %s "%s".', $name, $callType, $callName));
}
if (!empty($missingArguments)) {
if (count($missingArguments)) {
throw new Twig_Error_Syntax(sprintf(
'Argument "%s" could not be assigned for %s "%s(%s)" because it is mapped to an internal PHP function which cannot determine default value for optional argument%s "%s".',
$name, $callType, $callName, implode(', ', $names), count($missingArguments) > 1 ? 's' : '', implode('", "', $missingArguments))
@@ -218,7 +218,7 @@ abstract class Twig_Node_Expression_Call extends Twig_Node_Expression
private function getCallableParameters($callable, $isVariadic)
{
list($r, $_) = $this->reflectCallable($callable);
list($r) = $this->reflectCallable($callable);
if (null === $r) {
return array();
}
+5 -4
View File
@@ -133,13 +133,14 @@ class Twig_NodeVisitor_Optimizer extends Twig_BaseNodeVisitor
return $node;
}
$exprNode = $node->getNode('expr');
if (
$node->getNode('expr') instanceof Twig_Node_Expression_BlockReference ||
$node->getNode('expr') instanceof Twig_Node_Expression_Parent
$exprNode instanceof Twig_Node_Expression_BlockReference ||
$exprNode instanceof Twig_Node_Expression_Parent
) {
$node->getNode('expr')->setAttribute('output', true);
$exprNode->setAttribute('output', true);
return $node->getNode('expr');
return $exprNode;
}
return $node;
+1 -1
View File
@@ -50,7 +50,7 @@ final class Twig_TemplateWrapper
*/
public function display($context = array())
{
return $this->template->display($context);
$this->template->display($context);
}
/**